Location: PHPKode > projects > H-tracker > index.php
<?
//
//  H-Tracker v0.2
//    http://h-tracker.org
//    Based on TorrentTrader (http://www.torrenttrader.org)
//
//
require_once("backend/functions.php");
dbconn(true);
 
stdhead("$SITENAME");

//Using Mozilla is a Good Mod [by hack346]
$SITENAME = $site_config['SITENAME'];
$browsernav = $_SERVER['HTTP_USER_AGENT'];
if(!strpos($browsernav, "Firefox")) {
begin_frame("" . WARNING . "");
echo '<center><img border="0" src="images/warning.png"/></center>';
echo '<center><font size=2><b>Warning!</b></font></center>';
echo '<center><br />It appears as though you are running <font class=error>'.$browsernav.' </font><br> this site was <b>NOT</b> intended to be viewed with this browser <br>and chances are it will not look right and may not even function correctly.</center>';
echo '<center>'.$SITENAME.' suggests that you browse happy and consider switching to one of the many better alternatives.</center>';
echo '<center><br /><a href="http://www.mozilla.com/firefox?from=sfx&uid=244951&t=331"><img border="0" alt="Get Firefox!" title="Get Firefox!" src="images/firefox.png"/></a></center>';
echo '<center><br /><strong>Get a SAFER browser !</strong></center>';
end_frame();
} 

if ($site_config['SHOUTBOX']){
	begin_frame("Shoutbox");
	echo '<IFRAME class=shoutbox_size name="shout_frame" src="'.$site_config["SITEURL"].'/shoutbox.php" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" align="middle"></IFRAME>';
	end_frame();
}

if($CURUSER){   
if ($site_config['NEWSON']){
	begin_frame("News".(get_user_class() >= 7 ? "<a href=\"admincp.php?action=news&do=add\">&nbsp;<img src=\"".$site_config['SITEURL']."/images/buttons/add.png\" border=\"0\" title=\"Add News\"></a>" : ""));
	$res = mysql_query("SELECT * FROM news WHERE ADDDATE(added, INTERVAL 45 DAY) > '".get_date_time()."' ORDER BY added DESC LIMIT 10") or die(mysql_error());
	if (mysql_num_rows($res) > 0){
		$news_flag = 0;

		while($array = mysql_fetch_array($res)){
			$user = mysql_fetch_assoc(mysql_query("SELECT username FROM users WHERE id = $array[userid]")) or die(mysql_error());

			$numcomm = number_format(get_row_count("comments", "WHERE news='".$array['id']."'"));

			if ($news_flag < 2) { //show first 2 items expanded
        echo "<FIELDSET><LEGEND>". $array['title'] . "&nbsp;<a href=\"javascript: klappe_news('a".$array['id']."')\"><img border=\"0\" src=\"".$site_config["SITEURL"]."/images/minus.gif\" id=\"pica".$array['id']."\" alt=\"Show/Hide\"></a></LEGEND>";
        echo "<table cellpadding=3 border=0 width=100% align=center>";
				print("<td class=row1 rowspan=3 align=center valign=middle width=15%><img src=\"images/news/".$array['cat']."\"></td><td class=table_head width=85% align=left valign=top>");
				print("<B>Posted:</B> " . date("d-M-y", utc_to_tz_time($array['added'])) . " <B>By:</B> $user[username]".(get_user_class() >= 7 ? "&nbsp;&nbsp;<a href=\"admincp.php?action=news&do=edit&newsid=$array[id]\"><img src=\"".$site_config['SITEURL']."/images/buttons/edit.png\" border=\"0\" title=\"Edit\"></a><a href=\"admincp.php?action=news&do=delete&newsid=$array[id]\">&nbsp;&nbsp;<img src=\"".$site_config['SITEURL']."/images/buttons/delete.png\" border=\"0\" title=\"Delete\"></a>" : "")."</td></tr><tr><td class=row2 colspan=2>");
				
				print("<div id=\"ka".$array['id']."\" style=\"display: block;\" class=news> ".format_comment($array["body"],0)." </div></td></tr><tr><td class=rowend>Comments (<a href=comments.php?type=news&id=".$array['id'].">".$numcomm."</a>)<br> ");

				$news_flag = ($news_flag + 1);
              echo "</td></tr></table></FIELDSET>\n";    
			}else{

        echo "<FIELDSET><LEGEND>". $array['title'] . "&nbsp;<a href=\"javascript: klappe_news('a".$array['id']."')\"><img border=\"0\" src=\"".$site_config["SITEURL"]."/images/plus.gif\" id=\"pica".$array['id']."\" alt=\"Show/Hide\"></a></LEGEND>";
        echo "<table cellpadding=3 border=0 width=100%>";
                print("<td class=row1 rowspan=3 align=center valign=middle width=15%><img src=\"images/news/".$array['cat']."\"></td><td class=table_head width=85% align=left valign=top>");
                print("<B>Posted:</B> " . date("d-M-y", utc_to_tz_time($array['added'])) . " <B>By:</B> $user[username]".(get_user_class() >= 7 ? "&nbsp;&nbsp;<a href=\"admincp.php?action=news&do=edit&newsid=$array[id]\"><img src=\"".$site_config['SITEURL']."/images/buttons/edit.png\" border=\"0\" title=\"Edit\"></a><a href=\"admincp.php?action=news&do=delete&newsid=$array[id]\">&nbsp;&nbsp;<img src=\"".$site_config['SITEURL']."/images/buttons/delete.png\" border=\"0\" title=\"Delete\"></a>" : "")."</td></tr><tr><td class=row2 colspan=2>");
                
                print("<div id=\"ka".$array['id']."\" style=\"display: none;\" class=news> ".format_comment($array["body"],0)."</div></td></tr><tr><td class=rowend>Comments (<a href=comments.php?type=news&id=".$array['id'].">".$numcomm."</a>)<br> ");
                echo "</td></tr></table></FIELDSET>\n"; 
			}
		}
	}else{
		echo "<BR><b>No news currently at this time</b>";
	}
	end_frame();
}
}
 if($CURUSER){   
//Site Releases
$caption = "Releases".(get_user_class() == 7 ? "<a href=\"indexadd.php\">&nbsp;<img src=\"".$site_config['SITEURL']."/images/buttons/add.png\" border=\"0\" title=\"Add New Release\"></a>" : ""); 
if ($site_config['RELEASESON']){
begin_frame($caption);
$count = get_row_count("indexreleases");
print("<table cellspacing=\"0\" cellpadding=\"3\" width=\"100%\"><tr><td>");
if (!$count) {
	print("No releases on Tracker...");
} else {
	include "codecs.php";
	$perpage = 2;
	list($pagertop, $pagerbottom, $limit) = pager($perpage, $count, $_SERVER["PHP_SELF"] . "?" );
	print("</td></tr>");
	$res = mysql_query("SELECT indexreleases.*, categories.id AS catid, categories.name AS catname, categories.image AS catimage FROM indexreleases LEFT JOIN categories ON indexreleases.cat = categories.id ORDER BY id DESC $limit") or sqlerr(__FILE__, __LINE__);
	while ($release = mysql_fetch_array($res)) {
		$catid = $release["catid"];
		$catname = $release["catname"];
		$catimage = $release["catimage"];
		print("<tr><td>");
        print("$pagertop"); 
		print("<table width=\"98%\" class=\"table_table\" cellspacing=\"0\" cellpadding=\"5\" align=\"center\">");
		print("<tr><td class=\"table_head\" colspan=\"2\" align=\"center\">".htmlspecialchars($release["name"]).(get_user_class() >= 7 ? "&nbsp;&nbsp;<a href=\"indexedit.php?action=edit&id=$release[id]&returnto=" . urlencode($_SERVER['PHP_SELF']) . "\"><img src=\"".$site_config['SITEURL']."/images/buttons/edit.png\" border=\"0\" title=\"Edit\"></a><a href=\"indexdelete.php?action=delete&id=$release[id]&returnto=" . urlencode($_SERVER['PHP_SELF']) . "\">&nbsp;&nbsp;<img src=\"".$site_config['SITEURL']."/images/buttons/delete.png\" border=\"0\" title=\"Delete\"></a>" : "")."</td></tr>");
		print("<tr valign=\"top\"><td align=\"center\" class=\"row1\"><a href='$release[poster]' rel='ibox'><IMG  src=$release[poster] width=150 height=200 border=0></a></td>");
		print("<td class=row2><div align=\"left\">".(!empty($catname) ? "<a href=\"torrents.php?cat=$catid\"><img src=\"images/categories/$catimage\" alt=\"$catname\" title=\"$catname\" align=\"right\" border=\"0\" /></a>" : "")."<b>Genre: </b>".htmlspecialchars($release["genre"])."<br /><b>Director: </b>".htmlspecialchars($release["director"])."<br /><b>Actors: </b>".htmlspecialchars($release["actors"])."<br /></div><div align=\"left\"><hr align=\"left\" width=\"85%\" color=\"#000000\" size=\"1\"></div><div align=\"left\"><b>Description: </b>".htmlspecialchars($release["descr"])."<br /></div><div align=\"left\"><hr align=\"left\" width=\"85%\" color=\"#000000\" size=\"1\"></div><div align=\"left\"><b>Quality: </b>".$release_quality[$release["quality"]]."<br /><b>Video: </b>".$video_codec[$release["video_codec"]].", $release[video_kbps] kb/s, $release[video_size]<br /><b>Audio: </b>".$audio_codec[$release["audio_codec"]].", $release[audio_kbps] kb/s<br /><b>Duration: </b>$release[time]<br /><b>Language: </b>".$audio_lang[$release["audio_lang"]]."<br /><b>Translation: </b>".$audio_trans[$release["audio_trans"]]."</div><div align=\"right\">".($release[imdb] ? "<a href=\"$release[imdb]\" class=\"online\"><img src=\"".$site_config["SITEURL"]."/images/torrents/imdb.png\" border=\"0\" alt='Visit IMDB'></a> " : "")."<br><a href=\"torrents-details.php?id=$release[torrentid]\" alt=\"$release[name]\" title=\"$release[name]\"><img src=\"".$site_config["SITEURL"]."/images/torrents/details.png\" border=\"0\" alt='Torrent details'></a></div></td>");
		print("</tr>");
        print("<tr><td class=table_end colspan=2></td></tr>"); 
		print("</table>");
		print("</td></tr>");
	}
	print("<tr><td>");
	print("$pagerbottom");
	print("</td></tr>");
}
print("</table>");
end_frame();
}
}

//STATS START
if($CURUSER){
begin_frame("Stats");
    $date_time = get_date_time(gmtime()-(3600*24));
    $registered = number_format(get_row_count("users"));
    $ncomments = number_format(get_row_count("comments"));
    $guests = number_format(getguests());
    $nmessages = number_format(get_row_count("messages"));
    $totaltoday = number_format(get_row_count("users", "WHERE users.last_access>='$date_time'"));
    $regtoday = number_format(get_row_count("users", "WHERE users.added>='$date_time'"));
    $male = number_format(get_row_count("users", "WHERE gender = 'Male'"));
    $female = number_format(get_row_count("users", "WHERE gender = 'Female'"));
    $notselect = number_format(get_row_count("users", "WHERE gender = ''"));
    $warned_users = number_format(get_row_count("users", "WHERE warned = 'yes'"));
    $disabled = number_format(get_row_count("users", "WHERE enabled = 'no'"));
    $unverified = number_format(get_row_count("users", "WHERE status = 'pending'"));
    $torrents = number_format(get_row_count("torrents"));
    $todaytor = number_format(get_row_count("torrents", "WHERE torrents.added>='$date_time'"));   
    $dead = number_format(get_row_count("torrents", "WHERE visible = 'no'"));
    $result = mysql_query("SELECT SUM(downloaded) AS totaldl FROM users"); 
    while ($row = mysql_fetch_array ($result)) { 
    $totaldownloaded = $row["totaldl"]; 
    } 
    $result = mysql_query("SELECT SUM(uploaded) AS totalul FROM users"); 
    while ($row = mysql_fetch_array ($result)) { 
    $totaluploaded = $row["totalul"]; 
    }
    $seeders = get_row_count("peers", "WHERE seeder='yes'");
    $leechers = get_row_count("peers", "WHERE seeder='no'");
    if ($leechers == 0)
        $ratio = 0;
    else
    $ratio = round($seeders / $leechers * 100);
    $peers = number_format($seeders + $leechers);
    $seeders = number_format($seeders);
    $leechers = number_format($leechers);
if(ereg("Opera", getenv("HTTP_USER_AGENT"))) $browser = "opera";
else if(ereg("Chrome", getenv("HTTP_USER_AGENT"))) $browser = "chrome";
else if(ereg("MSIE", getenv("HTTP_USER_AGENT"))) $browser = "ie";
else if(ereg("Safari", getenv("HTTP_USER_AGENT"))) $browser = "safari";
else if((ereg("Nav", getenv("HTTP_USER_AGENT"))) || (ereg("Gold", getenv("HTTP_USER_AGENT"))) || 
(ereg("X11", getenv("HTTP_USER_AGENT"))) || (ereg("Mozilla", getenv("HTTP_USER_AGENT"))) || 
(ereg("Netscape", getenv("HTTP_USER_AGENT"))) ) 
$browser = "mozilla";
else $browser = "oth"; 

$mozilla=$ie=$safari=$opera=$chrome=$oth=0;
$revamp = false;

$date = date('d');
//echo $date;
if($date == "01")
{
$mon = date('m');
$open = fopen("cache/date.txt", "r"); 
$size = filesize("cache/date.txt");
$lines = fread($open, $size);
fclose($open);

    if($mon != $lines)
    {
        $revamp = true;
        $open = fopen("cache/date.txt", "w");
        fwrite($open,$mon);
        fclose($open);
    }
    else
    {
         $revamp = false;
    }
}

if($revamp == false)
{
    $lines = file("cache/browser.txt");
    foreach ($lines as $line_num => $line)
    {
        //echo $line."<br>";
        $fp = strpos($line,'****');
        $nam = substr($line,0,$fp);
        $sp = strpos($line,'++++');
        $val = substr($line,$fp+4,$sp-($fp+4));
        //echo($val."<br>");
        //echo("-----------");

        if($nam == "mozilla")
            $mozilla = $val;
        else if($nam == "ie")
            $ie = $val;
        else if($nam == "safari")
            $safari = $val;
        else if($nam == "opera")
            $opera = $val;
        else if($nam == "chrome")
            $chrome = $val;
        else if($nam == "oth")
            $oth = $val;
    }
}

if($browser == "mozilla")
    $mozilla = $mozilla+1;
else if($browser == "ie")
    $ie = $ie+1;
else if($browser == "safari")
    $safari = $safari+1;
else if($browser == "opera")
    $opera = $opera+1;
else if($browser == "chrome")
    $chrome = $chrome+1;
else if($browser == "oth")
    $oth = $oth+1; 
 

$open = fopen("cache/browser.txt", "w");
fwrite($open,"ie****".$ie."++++"."\nmozilla****".$mozilla."++++"."\nsafari****".$safari."++++".
    "\nopera****".$opera."++++"."\nchrome****".$chrome."++++".
    "\noth****".$oth."++++");
fwrite($open,"\n");
fclose($open);

$tot = $mozilla+$ie+$safari+$opera+$chrome+$oth;
echo"<table width=\"100%\" class=\"tablebg\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">

<td align=\"center\"  valign=top>
<table class=\"row1\" cellspacing=\"0\" cellpadding=\"4\">
<tr><td class=\"rowtabhead\" align=center colspan=2>Members</td></tr>
<tr><td class=\"row2\" align=center colspan=3><img src=\"images/users/male.png\" title=\"Male\" alt=\"Male\">$male&nbsp;&nbsp;&nbsp;&nbsp;<img src=\"images/users/female.png\" title=\"Female\" alt=\"Female\">$female&nbsp;&nbsp;&nbsp;&nbsp;<img src=\"images/users/na.png\" alt=\"Gender Not Selectet\">&nbsp;$notselect<br />Total: $registered</td></tr>
<tr><td class=\"row1\">New Today</td><td align=right class=\"row2\">$regtoday</td></tr> 
<tr><td class=\"row1\">Unconfirmed users</td><td align=right class=\"row2\">$unverified</td></tr>
<tr><td class=\"row1\">Warned users</td><td align=right class=\"row2\">$warned_users</td></tr>
<tr><td class=\"row1\">Disabled users</td><td align=right class=\"row2\">$disabled</td></tr>
<tr><td class=\"rowend\" align=center colspan=2></td></tr>
</table></td>
<td align=\"center\"  valign=top>
<table class=table_col1 border=1 cellspacing=0 cellpadding=2>
<tr><td class=\"rowtabhead\" align=center colspan=2>Torrents</td></tr> 
<tr><td class=\"row1\">Torrents</td><td align=right class=\"row2\">$torrents</td></tr>
<tr><td class=\"row1\">New Today</td><td align=right class=\"row2\">$todaytor</td></tr> 
<tr><td class=\"row1\">Dead torrents</td><td align=right class=\"row2\">$dead</td></tr>
<tr><td class=\"row1\">Peers</td><td align=right class=\"row2\">$peers</td></tr>";
if (isset($peers)) {
echo"<tr><td class=\"row1\">Local Seeders</td><td align=right class=\"row2\">$seeders</td></tr>
<tr><td class=\"row1\">Local Leechers </td><td align=right class=\"row2\">$leechers</td></tr>
<tr><td class=\"row1\">Seed/Leech Ratio (%)</td><td align=right class=\"row2\">$ratio</td></tr>";
}
echo"<tr><td class=\"rowend\" align=center colspan=2></td></tr>";
echo"</td></table>
<td align=\"center\" valign=top>
<table class=\"table_head\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=120>";
echo "<tr><td class=\"rowtabhead\" align=center colspan=2>Browsers</td></tr> ";
echo "<tr><td class=\"row1\"><img src=\"".$site_config["SITEURL"]."/images/stats/moz.png\" border=\"0\" alt=\"Mozilla\"></td><td class=\"row2\"> ".(round($mozilla*10000/$tot)/100)." %</td></tr>";
echo "<tr><td class=\"row1\"><img src=\"".$site_config["SITEURL"]."/images/stats/chr.png\" border=\"0\" alt=\"Google Chrome\"></td><td class=\"row2\"> ".(round($chrome*10000/$tot)/100)." %</td></tr>";
echo "<tr><td class=\"row1\"><img src=\"".$site_config["SITEURL"]."/images/stats/ie.png\" border=\"0\" alt=\"Internet Explorer\"></td><td class=\"row2\"> ".(round($ie*10000/$tot)/100)." %</td></tr>";   
echo "<tr><td class=\"row1\"><img src=\"".$site_config["SITEURL"]."/images/stats/saf.png\" border=\"0\" alt=\"Safari\"></td><td class=\"row2\"> ".(round($safari*10000/$tot)/100)." %</td></tr>";
echo "<tr><td class=\"row1\"><img src=\"".$site_config["SITEURL"]."/images/stats/opera.png\" border=\"0\" alt=\"Opera\"></td><td class=\"row2\"> ".(round($opera*10000/$tot)/100)." %</td></tr>";
echo "<tr><td class=\"row1\"><img src=\"".$site_config["SITEURL"]."/images/stats/oth.png\" border=\"0\" alt=\"Others\"></td><td class=\"row2\"> ".(round($oth*10000/$tot)/100)." %</td></tr>";
echo "<tr><td class=\"rowend\" align=center colspan=2></td></tr>
</table></td>
<td align=\"center\"  valign=top>
<table class=\"table_head\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\">";
echo "<tr><td class=\"rowtabhead\" align=center colspan=2>Others</td></tr>
<tr><td class=\"row1\">Comments Posted</td><td align=right class=\"row2\">" . $ncomments . "</td></tr>
<tr><td class=\"row1\">Messages Sent</td><td align=right class=\"row2\">" . $nmessages . "</td></tr>  
<tr><td class=\"row1\">Visited Today</td><td align=right class=\"row2\">" . $totaltoday . "</td></tr>  
<tr><td class=\"row1\">Guests Online</td><td align=right class=\"row2\">" . $guests . "</td></tr>  
<tr><td class=\"row1\">Downloaded</td><td align=right class=\"row2\">" . mksize($totaldownloaded) . "</td></tr>  
<tr><td class=\"row1\">Uploaded</td><td align=right class=\"row2\">" . mksize($totaluploaded) . "</td></tr>  
<tr><td class=\"rowend\" align=center colspan=2></td></tr>
</table></td>
</td></table>";
end_frame();
}
//STATS END
if ($site_config['DISCLAIMERON']){
begin_frame("" . DISCLAIMER . "");

?> 
<center><div align="center"><font class="small"><img src="./images/en.gif" width="20" height="15"></font></div><? echo stripslashes($site_config['DISCLAIMERTXT']); ?>
<?
end_frame();
}
stdfoot();
?>
Return current item: H-tracker