Location: PHPKode > projects > DDL CMS > Upload these files to your webspace/topsites/templates/admin_statistics.tpl
<?php

$times =& IniParse("{$GLOBALS['DDIR']}/times");

$DB->Connect();

$stats = $DB->Row("SELECT SUM(Current_In) AS Current_In," .
                  "SUM(Current_Out) AS Current_Out," .
                  "SUM(Current_Prod) AS Current_Prod," .
                  "SUM(Total_In) AS Total_In," .
                  "SUM(Total_Out) AS Total_Out," .
                  "SUM(Total_Prod) AS Total_Prod " .
                  "FROM topsites_Accounts");

?>
<script type="text/javascript">
function checkForm(form)
{
    if( !confirm('Are you sure you want to do this?') )
    {
        return false;
    }

    return true;
}
</script>
<?php
if( isset($message) )
{
?>
<div id="message">
<?php echo $message; ?>
</div>
<br />
<?php
}
?>


<table>
<tr>
<td height=30>
<b>Current Statistics</b>
</td>
</tr>

<tr>
<td>
Last Rerank Timestamp
</td>
<td>
<?php echo date($date_format, $times['Rerank']); ?>
</td>
</tr>

<tr>
<td>
Last Reset Timestamp
</td>
<td>
<?php echo date($date_format, $times['Reset']); ?>
</td>
</tr>

<tr>
<td>
Last Total Reset Timestamp
</td>
<td>
<?php echo date($date_format, $times['Total_Reset']); ?>
</td>
</tr>

<tr>
<td height=30>
<b>Hits Since The Last Reset</b>
</td>
</tr>

<tr>
<td>
Hits In
</td>
<td>
<?php echo FormatNumber($stats['Current_In']); ?>
</td>
</tr>

<tr>
<td>
Hits Out
</td>
<td>
<?php echo FormatNumber($stats['Current_Out']); ?>
</td>
</tr>

<tr>
<td>
Productivity
</td>
<td>
<?php echo FormatNumber($stats['Current_Prod']); ?>
</td>
</tr>

<tr>
<td height=30>
<b>Hits Since The Last Total Reset</b>
</td>
</tr>

<tr>
<td>
Total Hits In
</td>
<td>
<?php echo FormatNumber($stats['Total_In']); ?>
</td>
</tr>

<tr>
<td>
Total Hits Out
</td>
<td>
<?php echo FormatNumber($stats['Total_Out']); ?>
</td>
</tr>

<tr>
<td>
Total Productivity
</td>
<td>
<?php echo FormatNumber($stats['Total_Prod']); ?>
</td>
</tr>


<tr>
<td height=30>
<b>Averages Since The Last Total Reset</b>
</td>
</tr>

<tr>
<td>
Hits In Per Day
</td>
<td>
<?php echo FormatNumber(GetAverage($stats['Total_In'], $times['Total_Reset'], 86400)); ?>
</td>
</tr>

<tr>
<td>
Hits In Per Week
</td>
<td>
<?php echo FormatNumber(GetAverage($stats['Total_In'], $times['Total_Reset'], 604800)); ?>
</td>
</tr>

<tr>
<td>
Hits In Per Month
</td>
<td>
<?php echo FormatNumber(GetAverage($stats['Total_In'], $times['Total_Reset'], 2592000)); ?>
</td>
</tr>

<tr>
<td>
Hits Out Per Day
</td>
<td>
<?php echo FormatNumber(GetAverage($stats['Total_Out'], $times['Total_Reset'], 86400)); ?>
</td>
</tr>

<tr>
<td>
Hits Out Per Week
</td>
<td>
<?php echo FormatNumber(GetAverage($stats['Total_Out'], $times['Total_Reset'], 604800)); ?>
</td>
</tr>

<tr>
<td>
Hits Out Per Month
</td>
<td>
<?php echo FormatNumber(GetAverage($stats['Total_Out'], $times['Total_Reset'], 2592000)); ?>
</td>
</tr>

</table>

<?php

if( $GLOBALS['CATEGORIES'] )
{

?>

<br />

<table>
<tr>
<td>
Category Statistics
</td>
</tr>

<?php

$result = $DB->Query("SELECT Category,SUM(Current_In) AS Current_In," .
                     "SUM(Current_Out) AS Current_Out," .
                     "SUM(Current_Prod) AS Current_Prod," .
                     "SUM(Total_In) AS Total_In," .
                     "SUM(Total_Out) AS Total_Out," .
                     "SUM(Total_Prod) AS Total_Prod " .
                     "FROM topsites_Accounts GROUP BY Category");

while( $stats = $DB->NextRow($result) )
{

?>
<tr>
<td>
<?php echo $stats['Category']; ?>
</td>
</tr>

<tr>
<td>
Hits In
</td>
<td>
<?php echo FormatNumber($stats['Current_In']); ?>
</td>
</tr>

<tr>
<td>
Hits Out
</td>
<td>
<?php echo FormatNumber($stats['Current_Out']); ?>
</td>
</tr>

<tr>
<td>
Productivity
</td>
<td>
<?php echo FormatNumber($stats['Current_Prod']); ?>
</td>
</tr>

<tr>
<td>
Total Hits In
</td>
<td>
<?php echo FormatNumber($stats['Total_In']); ?>
</td>
</tr>

<tr>
<td>
Total Hits Out
</td>
<td>
<?php echo FormatNumber($stats['Total_Out']); ?>
</td>
</tr>

<tr>
<td>
Total Productivity
</td>
<td>
<?php echo FormatNumber($stats['Total_Prod']); ?>
</td>
</tr>
<?php
}

$DB->Free($result);
?>

</table>

<?php
}
?>

<br />

<table>
<tr>
<tdheight=30>
<b>Historical Statistics</b>
</td>
</tr>

<tr>
<td>
Date
</td>
<td>
In
</td>
<td>
Out
</td>
<td>
Productivity
</td>
<td>
Active
</td>
<td>
Top Member
</td>
</tr>


<?php

$result = $DB->Query("SELECT UNIX_TIMESTAMP(Date_Added) AS theDate," .
                     "SUM(Current_Prod) AS Current_Prod," .
                     "SUM(Current_In) AS Current_In," .
                     "SUM(Current_Out) AS Current_Out," .
                     "MAX(Active) AS Active," .
                     "Top_Ranked " .
                     "FROM topsites_AdminStats GROUP BY Date_Added");


while( $stats = $DB->NextRow($result) )
{
?>
<tr>
<td>
<?php
	if($stats['theDate'] == 0)
	{
		echo date($date_format, time());
	}
	else
	{
		echo date($date_format, $stats['theDate']);
	}
?>
</td>
<td>
<?php echo $stats['Current_In']; ?>
</td>
<td>
<?php echo $stats['Current_Out']; ?>
</td>
<td>
<?php echo $stats['Current_Prod']; ?>
</td>
<td>
<?php echo $stats['Active']; ?>
</td>
<td>
<?php echo $stats['Top_Ranked']; ?>
</td>
</tr>
<?php
}

$DB->Free($result);
?>

</table>

<br />

<form name="form" action="admin.php" target="_self" method="post" onSubmit="return checkForm(this);">

<table>
<tr>
<td>
<input type="submit" value="Clear Historical Stats">
</td>
</tr>
</table>

<input type="hidden" name="Run" value="ClearAdminStats">
</form>
Return current item: DDL CMS