Location: PHPKode > projects > Nail Streaming Server > nailss_v12/statistics.php
<?php
session_start();
@include_once( getcwd()."/includes/configuration.php" );
include_once( getcwd()."/includes/misc.php" );
include_once( getcwd()."/includes/login.php" );
include_once( getcwd()."/layout/header.php" );

if($backend != "mysql")
{
	die( "MySQL Backend Required" );
}

connect_to($dbhost, $dbuser, $dbpass, $dbname);

$mkTime = mktime();
$mkTime = $mkTime - (31*24*60*60);
$aMonthAgo = date("Y-m-d H:m:s", $mkTime);

$sql0 = "DELETE FROM `played` WHERE `Timestamp` <= '$aMonthAgo'";

$deleteResult0 = mysql_query($sql0);

$sql1 = "SELECT DISTINCT `Directory`, COUNT(*) FROM `played` WHERE 1 GROUP BY `Directory` ORDER BY COUNT(*) DESC LIMIT 0, 25";
$selectResult1 = mysql_query($sql1);

echo( "<table border=\"0\" cellpadding=\"0\" cellspacing=\"5\" width=\"100%\">
<tr><td>
<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">
<tr class=\"tableheader\"><td colspan=\"4\"><center><h3>Top 25 Directories</h3></center></td></tr>" );

while($row = mysql_fetch_array($selectResult1))
{
	echo( "<tr><td colspan=\"3\"><a href=\"$baseURL"."index.php?dir=".customEncodeURL($row["Directory"])."\">".$row["Directory"]."</a></td><td>".$row["COUNT(*)"]."</td></tr>" ); 
}

echo( "</table>
</td></tr>
</table><p>&nbsp;</p>" );

$sql1 = "SELECT DISTINCT `File`, COUNT(*) FROM `played` WHERE 1 GROUP BY `File` ORDER BY COUNT(*) DESC LIMIT 0, 25";
$selectResult1 = mysql_query($sql1);

echo( "<table border=\"0\" cellpadding=\"0\" cellspacing=\"5\" width=\"100%\">
<tr><td>
<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">
<tr class=\"tableheader\"><td colspan=\"4\"><center><h3>Top 25 Files</h3></center></td></tr>" );

while($row = mysql_fetch_array($selectResult1))
{
	$sql2 = "SELECT * FROM `played` WHERE `File` = '".$row["File"]."'";
	$selectResult2 = mysql_query($sql2);
	$row2 = mysql_fetch_array($selectResult2);
	echo( "<tr><td colspan=\"3\"><a href=\"$baseURL"."play.php?dir=".customEncodeURL($row2["Directory"])."&file=".customEncodeURL($row["File"])."\">".$row["File"]."</a></td><td>".$row["COUNT(*)"]."</td></tr>" ); 
}

echo( "</table>
</td></tr>
</table><p>&nbsp;</p>" );

$sql1 = "SELECT DISTINCT `IP`, COUNT(*) FROM `played` WHERE 1 GROUP BY `IP` ORDER BY COUNT(*) DESC LIMIT 0, 25";
$selectResult1 = mysql_query($sql1);

echo( "<table border=\"0\" cellpadding=\"0\" cellspacing=\"5\" width=\"100%\">
<tr><td>
<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">
<tr class=\"tableheader\"><td colspan=\"4\"><center><h3>Top 25 IP Addresses</h3></center></td></tr>" );

while($row = mysql_fetch_array($selectResult1))
{
	echo( "<tr><td colspan=\"3\">".$row["IP"]."</td><td>".$row["COUNT(*)"]."</td></tr>" ); 
}

echo( "</table>
</td></tr>
</table><p>&nbsp;</p>" );

$sql1 = "SELECT DISTINCT `Player`, COUNT(*) FROM `played` WHERE 1 GROUP BY `Player` ORDER BY COUNT(*) DESC LIMIT 0, 25";
$selectResult1 = mysql_query($sql1);

echo( "<table border=\"0\" cellpadding=\"0\" cellspacing=\"5\" width=\"100%\">
<tr><td>
<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">
<tr class=\"tableheader\"><td colspan=\"4\"><center><h3>Top 25 Players</h3></center></td></tr>" );

while($row = mysql_fetch_array($selectResult1))
{
	echo( "<tr><td colspan=\"3\">".$row["Player"]."</td><td>".$row["COUNT(*)"]."</td></tr>" ); 
}

echo( "</table>
</td></tr>
</table><p>&nbsp;</p>" );
?>
Return current item: Nail Streaming Server