<?php

    
//Input connection info here.
    
$server_name "";
    
$server_username "";
    
$server_password "";
    
$db_name "ftpsearch";

    
//Anything placed in the above blanks will be overriden by settings in the ftpsetup.inc.php file
    
include("ftpsetup.inc.php");


    
$link mysql_connect($server_name,$server_username,$server_password)
    or die(
"COULDNT CONNECT!  Could not perform query; the server could not be reached");
    
mysql_select_db($db_name);

    
$releasever "9/24/2003";
?>
<html>
<head>
<title>LK FTPSearch Server Statistics</title>
</head>

<?php
    
//highlighting to show source
    
if ($_REQUEST["showsource"] == 1highlight_file("ftpstats.php");

?>
<br>
LK FTPSearch Server Statistics:<br>

<table border="1">

    <tr>
        <td><b>Server</b></td>
        <td><b># files/folders shared</b></td>
        <td><b>Size of everything shared</b></td>
        <td><b>Reliability</b></td>
        <td><b>Description</b></td>
    </tr>

    <?php
        $serverresult 
mysql_query("SELECT * from ftpservers ORDER BY reliability DESC");
        while(
$singleserver mysql_fetch_array($serverresult,MYSQL_BOTH)){



            
//get number of files and GB on this server
            
$countresult mysql_query("SELECT count(*),sum(bytesize) from ftpfiles where serverID = $singleserver[ID]");
            
$counts mysql_fetch_array($countresult,MYSQL_BOTH);
            
$filecount $counts[0];
            
$filesize sizeEval($counts[1]);

            
$foldercountresult mysql_query("SELECT count(*) as foldercount from ftpfolders where serverID = $singleserver[ID]");
            
$foldercountarray mysql_fetch_array($foldercountresultMYSQL_BOTH);
            
$foldercount $foldercountarray[0];

            echo 
"<tr>
                <td><a href = \"ftp://"
;
            if (
$singleserver['username'] != "anonymous")
                echo 
"$singleserver[username]:$singleserver[pwd]@";

                echo 
"$singleserver[name]";

                echo 
"\" TARGET = \"_BLANK\">";
                echo
"$singleserver[name]</a>";
                echo 
"<br><font size = \"1\">id=$singleserver[ID]</font>";
                if(
$allowforcedupdate) echo"<font size = 1><br><a href = \"$forcedupdateurl?serverID=$singleserver[ID]\" TARGET = \"_BLANK\">force update</a></font></td>";

                echo
"
                <td>
$filecount <font size = \"2\"><b>files</b></font><br>$foldercount <font size = \"2\"><b>folders</b></font></td>
                <td>
$filesize</td>
                <td>
$singleserver[reliability]</td>
                <td>
$singleserver[description]</td>
            </tr>
            "
;

        }

    
//print totals

    
$totalsq mysql_query("SELECT count(*),sum(bytesize)/(1024*1024*1024) from ftpfiles");
    
$totals mysql_fetch_array($totalsq,MYSQL_BOTH);


    echo
"
    <tr>
        <td><b>Totals</b></td>
        <td>
$totals[0]</td>
        <td>
$totals[1] <b>GB</b></td>
    </tr>
    "
;

?>

</table>
<?php
    
function sizeEval($filesize){
        
//note:  filesize given in bytes
        
if($filesize 1073741824){
            return(
round($filesize 1073741824,2) . "<B> GB</B>");
        }elseif(
$filesize 1048576){
            return(
round($filesize 1048576,2) . "<B> MB</B>");
        }else{
        
//if($filesize > 1024){
            
return(round($filesize 1024,2) . "<B> KB</B>");
        }
        
//Showing Bytes is stupid
        /*else{
            return($filesize . "<B> B</B>");
        }*/
    
}
?>
<br>
<font color = "red"><B>NEW!!!</B></font><br>
To add a description for your server, put a file that starts with "FTPSEARCHDESC" in the root directory of your server, followed by the message.
<br>
Example: "FTPSEARCHDESChi, welcome to the coolest server ever.  there are over 50k filez here!  no h4x0ring plz thx!"
<br>
<center>
<font size ="2">
[<a href = "./ftpstats.php">server stats</a>]
[<a href = "./ftpsearch.php">search</a>]
[<a href = "./ftphist.php">search history</a>]
<br>
[<a href = "./ftpstats.php?showsource=1">source</a>]&nbsp&nbsp&nbsp&nbsp&nbsp

<br>
<?php echo "$releasever release" ?>
</center>
</html>

LK FTPSearch Server Statistics:
Server # files/folders shared Size of everything shared Reliability Description
ftp.microsoft.com
id=1
0 files
5 folders
0 KB 14
ftp.ea.com
id=5
4749 files
0 folders
26.58 GB 10
ftp.linksys.com
id=3
4176 files
0 folders
68.7 GB 10
ftp.blizzard.com
id=4
2737 files
0 folders
21.9 GB 10
ftp.bioware.com
id=6
1684 files
0 folders
30.87 GB 10
ftp.idsoftware.com
id=7
563 files
0 folders
21.53 GB 10
ftp.mozilla.org
id=8
0 files
0 folders
0 KB 10
ftp.sun.com
id=9
0 files
0 folders
0 KB 10
Totals 13938 169.5945 GB

NEW!!!
To add a description for your server, put a file that starts with "FTPSEARCHDESC" in the root directory of your server, followed by the message.
Example: "FTPSEARCHDESChi, welcome to the coolest server ever. there are over 50k filez here! no h4x0ring plz thx!"
[server stats] [search] [search history]
[source]     
9/24/2003 release