Location: PHPKode > projects > PHPFreeNews > phpfn/Inc/Statistics.php
<?php

/*	+--------------------------------------------------------------
	| PHPFreeNews - News Headlines on your website                |
	| Developed by Jim Willsher.                                  |
	| http://www.phpfreenews.co.uk                                |
	+-------------------------------------------------------------+
*/

if (! defined('IN_PHPFN'))
	die('Illegal attempt to access script directly!');

CheckAuthority();

$query					= mysql_query("SELECT count(*) FROM news_posts");
$newscount				= mysql_result($query, 0);

$query					= mysql_query("SELECT count(*) FROM news_posts WHERE Visible='1'");
$visiblenewscount		= mysql_result($query, 0);

$query					= mysql_query("SELECT count(*) FROM news_posts WHERE Approved !='1'");
$unapprovednewscount	= mysql_result($query, 0);

$query					= mysql_query("SELECT count(*) FROM news_posts WHERE Archived='1'");
$archivednewscount		= mysql_result($query, 0);

$query					= mysql_query("SELECT count(*) FROM news_posts WHERE AuthorID=$LoggedInUserId");
$mynewscount			= mysql_result($query, 0);

$query					= mysql_query("SELECT count(*) FROM news_comments");
$commentcount			= mysql_result($query, 0);

$query					= mysql_query("SELECT count(*) FROM news_comments WHERE Approved !='1'");
$unapprovedcommentcount	= mysql_result($query, 0);

$query					= mysql_query("SELECT count(*) FROM news_images");
$imagecount				= mysql_result($query, 0);

$query					= mysql_query("SELECT count(*) FROM news_users");
$usercount				= mysql_result($query, 0);

$query					= mysql_query("SELECT count(*) FROM news_categories");
$catcount				= mysql_result($query, 0);

$query					= mysql_query("SELECT count(*) FROM news_templates");
$templatecount			= mysql_result($query, 0);

$query					= mysql_query("SELECT TimesRead, Headline FROM news_posts ORDER BY TimesRead DESC LIMIT 1");
$row 					= mysql_fetch_array($query, MYSQL_ASSOC);
$mostreadheadline 		= $row['Headline'];
$mostreadcount 			= $row['TimesRead'];

// Display the heading
DisplayGroupHeading('System Statistics');
?>
	<br /><br />
	<table align="center" border="1" width="90%" cellspacing="0" cellpadding="3">
		<tr>
			<th width="15%" nowrap>
				<b>Total Posts:</b>
			</th>
			<td>
				<?= $newscount ?> (<?=$visiblenewscount?> visible, <?=$unapprovednewscount?> unapproved)
			</td>
		</tr>

		<tr>
			<th width="15%" nowrap>
				<b>Archived Posts:</b>
			</th>
			<td>
				<?= $archivednewscount ?>
			</td>
		</tr>

		<tr>
			<th width="15%" nowrap>
				<b>Your Posts:</b>
			</th>
			<td>
				<?= $mynewscount ?>
			</td>
		</tr>

		<?
		if ($EnableComments)
		{
			?>
			<tr>
				<th width="15%" nowrap>
					<b>Comments:</b>
				</th>
				<td>
					<?= $commentcount ?> (<?=$unapprovedcommentcount?> unapproved)
				</td>
			</tr>
			<?
		}
		?>

		<tr>
			<th width="15%" nowrap>
				<b>Images:</b>
			</th>
			<td>
				<?= $imagecount ?>
			</td>
		</tr>

		<tr>
			<th width="15%" nowrap>
				<b>Users:</b>
			</th>
			<td>
				<?= $usercount ?>
			</td>
		</tr>

		<tr>
			<th width="15%" nowrap>
				<b>Categories:</b>
			</th>
			<td>
				<?= $catcount ?>
			</td>
		</tr>

		<tr>
			<th width="15%" nowrap>
				<b>Templates:</b>
			</th>
			<td>
				<?= $templatecount ?>
			</td>
		</tr>

		<tr>
			<th width="15%" nowrap>
				<b>Most-Read Article:</b>
			</th>
			<td>
				<?= $mostreadheadline ?> (Viewed <?= $mostreadcount ?> times)
			</td>
		</tr>
	</table>
Return current item: PHPFreeNews