firefly007 |
22nd June 2013 18:03 |
upload.php
PHP Code:
<?php
/* *-------------------------------------------------------------------------------* *---------------- | ____| |__ __/ ____| __ \ --------------* *---------------- | |__ _ __ ___ ___| | | (___ | |__) | --------------* *---------------- | __| '__/ _ \/ _ \ | \___ \| ___/ --------------* *---------------- | | | | | __/ __/ | ____) | | --------------* *---------------- |_| |_| \___|\___|_| |_____/|_| --------------* *-------------------------------------------------------------------------------* *--------------------------- FreeTSP RC 3.0 -------------------------------* *------------------- The Alternate BitTorrent Source -----------------------* *-------------------------------------------------------------------------------* *-------------------------------------------------------------------------------* *-- This program is free software; you can redistribute it and/or modify --* *-- it under the terms of the GNU General Public License as published by --* *-- the Free Software Foundation; either version 2 of the License, or --* *-- (at your option) any later version. --* *-- --* *-- This program is distributed in the hope that it will be useful, --* *-- but WITHOUT ANY WARRANTY; without even the implied warranty of --* *-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --* *-- GNU General Public License for more details. --* *-- --* *-- You should have received a copy of the GNU General Public License --* *-- along with this program; if not, write to the Free Software --* *-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --* *-- --* *-------------------------------------------------------------------------------* *------------ Original Credits to tbSource, Bytemonsoon, TBDev -------------* *-------------------------------------------------------------------------------* *-------- Developed By: Krypto, Fireknight, Subzero --------* *-------------------------------------------------------------------------------* *----------------- First Release Date August 2010 -------------------* *----------- http://www.freetsp.info -----------* *------ 2010 FreeTSP Development Team ------* *-------------------------------------------------------------------------------* */
require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'functions'.DIRECTORY_SEPARATOR.'function_main.php'); require_once(INCL_DIR.'function_user.php'); require_once(INCL_DIR.'function_vfunctions.php'); require_once(INCL_DIR.'function_bbcode.php'); require_once(INCL_DIR.'function_page_verify.php');
db_connect(false); logged_in();
$newpage = new page_verify(); $newpage->create('_upload_');
?> <style type="text/css"> <!-- .passkey { height: 15px; width: 500px; border: thin solid #333333; background-color: #000000; display: block; } --> </style>
<div align='center'> <form name='upload' enctype='multipart/form-data' action='takeupload.php' method='post'> <input type='hidden' name='MAX_FILE_SIZE' value="<?=$max_torrent_size?>" /> <p>The tracker's announce url is <b><?= $announce_urls[0] ?></b></p> <table width='100%' border='1' cellspacing='0' cellpadding='10'>
<?php
tr("Torrent File", "<input type='file' name='file' size='80' />\n", 1);
tr("Torrent Name", "<input type='text' name='name' size='80' />(Taken from filename if not specified. <b>Please use descriptive names.</b>)\n", 1);
tr("NFO file", "<input type='file' name='nfo' size='80' />(<b>Required.</b> Can only be viewed by Power Users.)\n", 1);
tr("Poster", "<input type=text name=poster size=80 />(Direct link for a poster image to be shown on the details page)\n", 1);
tr("Trailer", "<input type='text' name='tube' size='80' value='".$row["tube"]."'>(Direct link for youtube trailer)", 1);
echo("<tr><td class='rowhead' style='padding: 10px'>Description</td><td align='center' style='padding: 3px'>".textbbcode("upload", "descr", htmlspecialchars($row["ori_descr"])) . "</td></tr>\n");
$s = "<select name='type'>\n<option value='0'>(choose one)</option>\n";
$cats = genrelist();
foreach ($cats as $row) { $s .= "<option value='" . $row["id"] . "'>" . htmlspecialchars($row["name"]) . "</option>\n"; } $s .= "</select>\n";
tr("Type", $s, 1);
?> <tr><td align='center' colspan='2'><input type='submit' class='btn' value='Upload' /></td></tr> </table> </form> </div>
<?php
site_footer();
?>
takeupload.php
PHP Code:
<?php
/* *-------------------------------------------------------------------------------* *---------------- | ____| |__ __/ ____| __ \ --------------* *---------------- | |__ _ __ ___ ___| | | (___ | |__) | --------------* *---------------- | __| '__/ _ \/ _ \ | \___ \| ___/ --------------* *---------------- | | | | | __/ __/ | ____) | | --------------* *---------------- |_| |_| \___|\___|_| |_____/|_| --------------* *-------------------------------------------------------------------------------* *--------------------------- FreeTSP RC 3.0 -------------------------------* *------------------- The Alternate BitTorrent Source -----------------------* *-------------------------------------------------------------------------------* *-------------------------------------------------------------------------------* *-- This program is free software; you can redistribute it and/or modify --* *-- it under the terms of the GNU General Public License as published by --* *-- the Free Software Foundation; either version 2 of the License, or --* *-- (at your option) any later version. --* *-- --* *-- This program is distributed in the hope that it will be useful, --* *-- but WITHOUT ANY WARRANTY; without even the implied warranty of --* *-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --* *-- GNU General Public License for more details. --* *-- --* *-- You should have received a copy of the GNU General Public License --* *-- along with this program; if not, write to the Free Software --* *-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --* *-- --* *-------------------------------------------------------------------------------* *------------ Original Credits to tbSource, Bytemonsoon, TBDev -------------* *-------------------------------------------------------------------------------* *-------- Developed By: Krypto, Fireknight, Subzero --------* *-------------------------------------------------------------------------------* *----------------- First Release Date August 2010 -------------------* *----------- http://www.freetsp.info -----------* *------ 2010 FreeTSP Development Team ------* *-------------------------------------------------------------------------------* */
require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'functions'.DIRECTORY_SEPARATOR.'function_main.php'); require_once(INCL_DIR.'function_user.php'); require_once(INCL_DIR.'function_vfunctions.php'); require_once(INCL_DIR.'function_torrenttable.php'); require_once(INCL_DIR.'function_benc.php'); require_once(INCL_DIR.'function_page_verify.php');
ini_set("upload_max_filesize",$max_torrent_size);
db_connect(); logged_in();
$newpage = new page_verify(); $newpage->check('_upload_');
if (get_user_class() < UC_USER) die;
foreach(explode(":","descr:type:name") AS $v) { if (!isset($_POST[$v])) error_message("error","Upload Failed!","Missing Form Data"); }
if (!isset($_FILES["file"])) error_message("error","Upload Failed!","Missing Form Data");
$f = $_FILES["file"]; $fname = unesc($f["name"]);
if (empty($fname)) { error_message("error","Upload Failed!","Empty filename!"); }
$nfo = sqlesc('');
if(isset($_FILES['nfo']) && !empty($_FILES['nfo']['name'])) { $nfofile = $_FILES['nfo'];
if ($nfofile['name'] == '') error_message("error","Upload Failed!","No NFO!");
if ($nfofile['size'] == 0) error_message("error","Upload Failed!","0-byte NFO");
if ($nfofile['size'] > 65535) error_message("error","Upload Failed!","NFO is too big! Max 65,535 bytes.");
$nfofilename = $nfofile['tmp_name'];
if (@!is_uploaded_file($nfofilename)) error_message("error","Upload Failed!","NFO Upload Failed");
$nfo = sqlesc(str_replace("\x0d\x0d\x0a", "\x0d\x0a", @file_get_contents($nfofilename))); }
$descr = unesc($_POST["descr"]);
$tube = unesc($_POST["tube"]);
if (!$descr) { error_message("error","Upload Failed!","You must enter a Description!"); }
$catid = (0 + $_POST["type"]);
if (!is_valid_id($catid)) { error_message("error","Upload Failed!","You must select a Category to put the torrent in!"); }
if (!validfilename($fname)) { error_message("error","Upload Failed!","Invalid Filename!"); }
if (!preg_match('/^(.+)\.torrent$/si', $fname, $matches)) { error_message("error","Upload Failed!","Invalid Filename (Not a .torrent)."); }
$shortfname = $torrent = $matches[1];
if (!empty($_POST["name"])) { $torrent = unesc($_POST["name"]); }
if (!empty($_POST["poster"])) { $poster = unesc($_POST["poster"]); }
$tmpname = $f["tmp_name"];
if (!is_uploaded_file($tmpname)) { error_message("error","Upload Failed!","eek"); }
if (!filesize($tmpname)) { error_message("error","Upload Failed!","Empty file!"); }
$dict = bdec_file($tmpname, $max_torrent_size);
if (!isset($dict)) { error_message("error","Upload Failed!","What the hell did you upload? This is not a bencoded file!"); }
function dict_check($d, $s) { if ($d["type"] != "dictionary") { error_message("error","Upload Failed","not a dictionary"); }
$a = explode(":", $s); $dd = $d["value"]; $ret = array(); $t = '';
foreach ($a AS $k) { unset($t);
if (preg_match('/^(.*)\((.*)\)$/', $k, $m)) { $k = $m[1]; $t = $m[2]; }
if (!isset($dd[$k])) { error_message("error","Upload Failed!","Dictionary is missing Key(s)"); }
if (isset($t)) { if ($dd[$k]["type"] != $t) { error_message("error","Upload Failed!","Invalid entry in Dictionary"); } $ret[] = $dd[$k]["value"]; } else { $ret[] = $dd[$k]; } } return $ret; }
function dict_get($d, $k, $t) { if ($d["type"] != "dictionary") { error_message("error","Upload Failed!","Not a Dictionary"); }
$dd = $d["value"];
if (!isset($dd[$k])) { return; }
$v = $dd[$k];
if ($v["type"] != $t) { error_message("error","Upload Failed!","Invalid Dictionary entry type"); } return $v["value"]; }
list($ann, $info) = dict_check($dict, "announce(string):info"); list($dname, $plen, $pieces) = dict_check($info, "name(string):piece length(integer):pieces(string)");
if (!in_array($ann, $announce_urls, 1)) error_message("error","Upload Failed!","Invalid Announce URL! must be <b>" . $announce_urls[0] . "</b>");
if (strlen($pieces) % 20 != 0) { error_message("error","Upload Failed!","Invalid Pieces"); }
$filelist = array(); $totallen = dict_get($info, "length", "integer");
if (isset($totallen)) { $filelist[] = array($dname, $totallen); $type = "single"; } else { $flist = dict_get($info, "files", "list");
if (!isset($flist)) { error_message("error","Upload Failed!","missing both length and files"); }
if (!count($flist)) { error_message("error","Upload Failed!","No Files"); }
$totallen = 0;
foreach ($flist AS $fn) { list($ll, $ff) = dict_check($fn, "length(integer):path(list)"); $totallen += $ll; $ffa = array(); foreach ($ff AS $ffe) { if ($ffe["type"] != "string") { error_message("error","Upload Failed!","Filename Error"); }
$ffa[] = $ffe["value"]; }
if (!count($ffa)) { error_message("error","Upload Failed!","Filename Error"); }
$ffe = implode("/", $ffa); $filelist[] = array($ffe, $ll); } $type = "multi"; }
$infohash = pack("H*", sha1($info["string"]));
// Replace punctuation characters with spaces
$torrent = str_replace("_", " ", $torrent); $torrent = str_replace(".torrent", " ", $torrent); $torrent = str_replace(".rar", " ", $torrent); $torrent = str_replace(".avi", " ", $torrent); $torrent = str_replace(".mpeg", " ", $torrent); $torrent = str_replace(".exe", " ", $torrent); $torrent = str_replace(".zip", " ", $torrent); $torrent = str_replace(".wmv", " ", $torrent); $torrent = str_replace(".iso", " ", $torrent); $torrent = str_replace(".bin", " ", $torrent); $torrent = str_replace(".txt", " ", $torrent); $torrent = str_replace(".nfo", " ", $torrent); $torrent = str_replace(".7z", " ", $torrent); $torrent = str_replace(".mp3", " ", $torrent); $torrent = str_replace(".", " ", $torrent);
$nfo = sqlesc(str_replace("\x0d\x0d\x0a", "\x0d\x0a", @file_get_contents($nfofilename)));
$ret = sql_query("INSERT INTO torrents (search_text, filename, owner, visible, tube, info_hash, name, size, numfiles, type, descr, ori_descr, category, save_as, added, last_action, nfo, poster) VALUES (" . implode(",", array_map("sqlesc", array(searchfield("$shortfname $dname $torrent"), $fname, $CURUSER["id"], "no", $tube, $infohash, $torrent, $totallen, count($filelist), $type, $descr, $descr, 0 + $_POST["type"], $dname))) . ", '" . get_date_time() . "', '" . get_date_time() . "', $nfo, '".$poster."' )");
if (!$ret) { if (mysql_errno() == 1062) { error_message("error","Upload Failed!","torrent already uploaded!"); } mysql_err(); }
$id = mysql_insert_id();
@sql_query("DELETE FROM files WHERE torrent = $id");
foreach ($filelist AS $file) { @sql_query("INSERT INTO files (torrent, filename, size) VALUES ($id, ".sqlesc($file[0]).",".$file[1].")"); }
move_uploaded_file($tmpname, "$torrent_dir/$id.torrent");
write_log("Torrent $id ($torrent) was uploaded by " . $CURUSER["username"]);
/* RSS feeds */
if (($fd1 = @fopen("rss.xml", "w")) && ($fd2 = fopen("rssdd.xml", "w"))) { $cats = ""; $res = sql_query("SELECT id, name FROM categories");
while ($arr = mysql_fetch_assoc($res)) { $cats[$arr["id"]] = $arr["name"]; }
$s = "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n<rss version=\"0.91\">\n<channel>\n" . "<title>$site_name</title>\n<description>0-week torrents</description>\n<link>$site_url/</link>\n"; @fwrite($fd1, $s); @fwrite($fd2, $s);
$r = sql_query("SELECT id,name,descr,filename,category FROM torrents ORDER BY added DESC LIMIT 15") OR sqlerr(__FILE__, __LINE__);
while ($a = mysql_fetch_assoc($r)) { $cat = $cats[$a["category"]];
$s = "<item>\n<title>" . htmlspecialchars($a["name"] . " ($cat)") . "</title>\n" . "<description>" . htmlspecialchars($a["descr"]) . "</description>\n";
@fwrite($fd1, $s); @fwrite($fd2, $s); @fwrite($fd1, "<link>$site_url/details.php?id=$a[id]&hit=1</link>\n</item>\n"); $filename = htmlspecialchars($a["filename"]); @fwrite($fd2, "<link>$site_url/download.php/$a[id]/$filename</link>\n</item>\n"); } $s = "</channel>\n</rss>\n";
@fwrite($fd1, $s); @fwrite($fd2, $s); @fclose($fd1); @fclose($fd2); }
/* Email notifs
$res = sql_query("SELECT name FROM categories WHERE id=$catid") OR sqlerr(); $arr = mysql_fetch_assoc($res); $cat = $arr["name"]; $res = sql_query("SELECT email FROM users WHERE enabled='yes' AND notifs LIKE '%[cat$catid]%'") OR sqlerr(); $uploader = $CURUSER['username'];
$size = mksize($totallen); $description = ($html ? strip_tags($descr) : $descr);
$body = <<<EOD A new torrent has been uploaded.
Name: $torrent Size: $size Category: $cat Uploaded by: $uploader
Description ------------------------------------------------------------------------------- $description -------------------------------------------------------------------------------
You can use the URL below to download the torrent (you may have to login).
$site_url/details.php?id=$id&hit=1
-- $site_name EOD; $to = ""; $nmax = 100; // Max recipients per message $nthis = 0; $ntotal = 0; $total = mysql_num_rows($res); while ($arr = mysql_fetch_row($res)) { if ($nthis == 0) { $to = $arr[0]; } else { $to .= "," . $arr[0]; } ++$nthis; ++$ntotal; if ($nthis == $nmax || $ntotal == $total) { if (!mail("Multiple recipients <$site_email>", "New torrent - $torrent", $body, "From: $site_email\r\nBcc: $to", "-f$site_email")) { "error","Signup Failed!",("error","Error", "Your torrent has been been uploaded. DO NOT RELOAD THE PAGE!\n" . "There was however a problem delivering the e-mail notifcations.\n" . "Please let an administrator know about this error!\n"); } $nthis = 0; } } */
header("Location: $site_url/details.php?id=$id&uploaded=1");
?>
index.php
PHP Code:
<?php
/* *-------------------------------------------------------------------------------* *---------------- | ____| |__ __/ ____| __ \ --------------* *---------------- | |__ _ __ ___ ___| | | (___ | |__) | --------------* *---------------- | __| '__/ _ \/ _ \ | \___ \| ___/ --------------* *---------------- | | | | | __/ __/ | ____) | | --------------* *---------------- |_| |_| \___|\___|_| |_____/|_| --------------* *-------------------------------------------------------------------------------* *--------------------------- FreeTSP RC 3.0 -------------------------------* *------------------- The Alternate BitTorrent Source -----------------------* *-------------------------------------------------------------------------------* *-------------------------------------------------------------------------------* *-- This program is free software; you can redistribute it and/or modify --* *-- it under the terms of the GNU General Public License as published by --* *-- the Free Software Foundation; either version 2 of the License, or --* *-- (at your option) any later version. --* *-- --* *-- This program is distributed in the hope that it will be useful, --* *-- but WITHOUT ANY WARRANTY; without even the implied warranty of --* *-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --* *-- GNU General Public License for more details. --* *-- --* *-- You should have received a copy of the GNU General Public License --* *-- along with this program; if not, write to the Free Software --* *-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --* *-- --* *-------------------------------------------------------------------------------* *------------ Original Credits to tbSource, Bytemonsoon, TBDev -------------* *-------------------------------------------------------------------------------* *-------- Developed By: Krypto, Fireknight, Subzero --------* *-------------------------------------------------------------------------------* *----------------- First Release Date August 2010 -------------------* *----------- http://www.freetsp.info -----------* *------ 2010 FreeTSP Development Team ------* *-------------------------------------------------------------------------------* */
require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'functions'.DIRECTORY_SEPARATOR.'function_main.php'); require_once(INCL_DIR.'function_user.php'); require_once(INCL_DIR.'function_vfunctions.php'); require_once(INCL_DIR.'function_bbcode.php');
db_connect(true); logged_in();
// Cached latest user - Credits Bigjoos if ($CURUSER) { $cache_newuser = ROOT_DIR."cache/newuser.txt"; $cache_newuser_life = 2 * 60 ; //2 min
if (file_exists($cache_newuser) && is_array(unserialize(file_get_contents($cache_newuser))) && (time() - filemtime($cache_newuser)) < $cache_newuser_life)
$arr = unserialize(@file_get_contents($cache_newuser));
else { $r_new = sql_query("SELECT id , username FROM users ORDER BY id DESC LIMIT 1 ") OR sqlerr(__FILE__, __LINE__); $arr = mysql_fetch_assoc($r_new);
$handle = fopen($cache_newuser, "w+");
fwrite($handle, serialize($arr)); fclose($handle); }
$new_user = " <a href=\"$site_url/userdetails.php?id={$arr["id"]}\">" . htmlspecialchars($arr["username"]) . "</a>\n"; }
// Stats Begin - Credits Bigjoos $cache_stats = ROOT_DIR."cache/stats.txt"; $cache_stats_life = 2 * 60; // 5min
if (file_exists($cache_stats) && is_array(unserialize(file_get_contents($cache_stats))) && (time() - filemtime($cache_stats)) < $cache_stats_life)
$row = unserialize(@file_get_contents($cache_stats));
else { $stats = mysql_query("SELECT *, seeders + leechers AS peers, seeders / leechers AS ratio, unconnectables / (seeders + leechers) AS ratiounconn FROM stats WHERE id = '1' LIMIT 1") OR sqlerr(__FILE__, __LINE__); $row = mysql_fetch_assoc($stats);
$handle = fopen($cache_stats, "w+");
fwrite($handle, serialize($row)); fclose($handle); }
$seeders = number_format($row['seeders']); $leechers = number_format($row['leechers']); $registered = number_format($row['regusers']); $unverified = number_format($row['unconusers']); $torrents = number_format($row['torrents']); $torrentstoday = number_format($row['torrentstoday']); $ratiounconn = $row['ratiounconn']; $unconnectables = $row['unconnectables']; $ratio = round(($row['ratio'] * 100)); $peers = number_format($row['peers']); $numactive = number_format($row['numactive']); $donors = number_format($row['donors']); $forumposts = number_format($row['forumposts']); $forumtopics = number_format($row['forumtopics']); // End
site_header();
?> <style type="text/css"> <!-- .cont .cont .shoutthead { float: right; } .onlinehead { position: relative; bottom: 9px; } .tableuse td{ border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; } --> </style>
<font class='small'>Welcome to our Newest Member, <b><?php echo $new_user?></b>!</font> <?php
if (isset($CURUSER)) { print("<table width='100%' class='mtable' border='0' cellspacing='0' cellpadding='0'><tr><td class='embedded'>"); print("<h2>Recent News");
if (get_user_class() >= UC_ADMINISTRATOR) print(" - <font class='small'>[<a class='altlink' href='news.php'><b>News Page</b></a>]</font>"); print("</h2>\n");
$news_file = ROOT_DIR."cache/news.txt"; $expire = 15 * 60; // 15min
if (file_exists($news_file) && filemtime($news_file) > (time() - $expire)) { $news2 = unserialize(file_get_contents($news_file)); } else { $res = sql_query("SELECT id, userid, added, body FROM news WHERE added + ( 3600 *24 *45 ) > ".time()." ORDER BY added DESC LIMIT 10") OR sqlerr(__FILE__, __LINE__);
while ($news1 = mysql_fetch_assoc($res) ) { $news2[] = $news1; }
$output = serialize($news2); $fp = fopen($news_file,"w");
fputs($fp, $output); fclose($fp); } if ($news2) { print("<table width='100%' border='1' cellspacing='0' cellpadding='10'><tr><td class='text'>\n<ul>"); foreach ($news2 AS $array) {
print("<li>" . gmdate("Y-m-d",strtotime($array['added'])) . " - " . format_comment($array['body'],0)); if (get_user_class() >= UC_ADMINISTRATOR) { print(" <font size='-2'>[<a class='altlink' href='news.php?action=edit&newsid=" . $array['id'] . "&returnto=" . urlencode($_SERVER['PHP_SELF']) . "'><b>E</b></a>]</font>"); echo(" <font size='-2'>[<a class='altlink' href='news.php?action=delete&newsid=" . $array['id'] . "&returnto=" . urlencode($_SERVER['PHP_SELF']) . "'><b>D</b></a>]</font>"); } print("</li>"); } print("</ul></td></tr></table>\n"); } }
if ($CURUSER) { ?> <script type="text/javascript" src="js/poll.core.js"></script> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript">$(document).ready(function(){loadpoll();});</script>
<div class="cont"><div class="sthead"><div class="headtxt">Poll</div></div> <?php
if (get_user_class() >= UC_MODERATOR) print(" - <font class=\"small\">[<a href='makepoll.php?returnto=/index.php'><b>New</b></a>]</font>\n"); ?> </h2>
<table width="100%" border="0" cellpadding="10" cellspacing="0" class="mtable"> <tr> <td align="center"> <div id="poll_container"> <div id="loading_poll" style="display:none"></div> <noscript> <b>This Requires Javascript Enabled</b> </noscript> </div> <br/> </td> </tr> </table>
<?php } ?></div>
<?php if (isset($CURUSER)) { ?>
<script type='text/javascript'>
function SmileIT(smile,form,text) { document.forms[form].elements[text].value = document.forms[form].elements[text].value+" "+smile+" "; document.forms[form].elements[text].focus(); } </script>
<script type='text/javascript'><!--
function mySubmit() { setTimeout('document.shbox.reset()',100); } //--></script> <div class="cont"><div class="sthead"><div class="headtxt">Top Ten</div></div ><? //Start of Last X torrents with poster and marquee mod $query="SELECT id, name, poster FROM torrents WHERE poster <> '' ORDER BY added DESC LIMIT 5"; $result=mysql_query($query);$num = mysql_num_rows($result); print(""); //print("<h2>Torrents</h2>"); print("<table cellpadding=2 width=100% align=center><tr><td colspan=1 align=center><marquee scrollAmount=3 onMouseover=this.scrollAmount=0 onMouseout=this.scrollAmount=3 scrolldelay=0 direction=left>"); while ($row = mysql_fetch_assoc($result)) { $id = $row['id']; $name = $row['name']; $poster = $row['poster']; $name = str_replace('_', ' ' , $name); $name = str_replace('.', ' ' , $name); $name = substr($name, 0, 50); print("<a href=$BASEURL/details.php?id=$id title=$name><img src=$poster width=100 height=142 title=$name border=0></a>"); } print("</marquee></td></tr></table>"); //End of Last X torrents with poster and marquee mod ?> </div>
<div class="cont"><div class="sthead"><div class="headtxt">Top Ten</div></div><?
if ($CURUSER) { $res = mysql_query("SELECT id,category,seeders, leechers, name from torrents ORDER BY seeders + leechers DESC LIMIT 5") or sqlerr(__FILE__, __LINE__); $num = mysql_num_rows($res);
if ($num > 0) { print("<h2 align=left> " .TOP_TEN_TORRENTS. " </h2> <table align=center border=1 cellspacing=0 cellpadding=5 width=100%><tr>"); print("<td class=colhead align=center><b>" .TYPE. "</b></td>"); print("<td class=colhead align=left><b>" .NAME. "</b></td>"); print("<td class=colhead align=center width=15%><b><img src=pic/seeders.gi border=none alt=" .SEEDERS. "></b></td>"); print("<td class=colhead align=center width=15%><b><img src=pic/leechers.gi border=none alt=" .LEECHERS. "></b></td></tr>");
for ($i = 0; $i < $num; ++$i) { while ($row = mysql_fetch_assoc($res)) {
//////// Retrieve Category Image ////////// $cros = mysql_query("SELECT name, image FROM categories WHERE id=$row[category]"); if (mysql_num_rows($cros) == 1) { $corr = mysql_fetch_assoc($cros); $cat_img = "<img src=$site_url/images/caticons/" . $corr[image] . " border=0 alt='$corr[name]'>"; } /////// End Category Image ////////////// print("<tr><td width=40 align=center style='padding: 0px'>$cat_img</td>"); print("<td align=left><a href=details.php?id=$row[id]><b>$row[name]</b></a></td>"); print("<td align=center><font color=red>" .number_format($row['seeders'])."</font></td>"); //print("<td align=center>" .number_format($row['seeders'])."</td></tr>\n"); print("<td align=center>" .number_format($row['leechers'])."</td></tr>\n"); } } } print("</tr></table>"); } } ?></div> <div class="cont"><div class="sthead"><div class="headtxt">Forums</div></div> <? ///////////////////////////////////////////////// LAST X FORUM POSTS
print("<table id=torrenttable border=1 width=100% cellspacing=0 cellpadding=5><tr>". "<td class=tabletitle align=left>Topic Title</td>". "<td class=tabletitle align=left>Posts</td>". "<td class=tabletitle align=left>Views</td>". "<td class=tabletitle align=left>Author</td>". "<td class=tabletitle align=left>Last Post</td>". "</tr>");
$res = mysql_query("SELECT posts.id AS pid, posts.topicid, posts.userid AS userpost, posts.added, topics.id AS tid, topics.userid AS usertopic, topics.subject, topics.forumid, topics.lastpost, topics.views, forums.name, forums.minclassread, forums.postcount, users.username, topicposter.username AS tusername FROM posts, topics, forums, users, users AS topicposter WHERE posts.topicid = topics.id AND topics.forumid = forums.id AND posts.userid = users.id AND topics.userid = topicposter.id AND minclassread <=" . $CURUSER["class"] . " ORDER BY posts.added DESC LIMIT 5");
while ($postsx = mysql_fetch_assoc($res)) { print("<tr><td><a href=\"forums.php?action=viewtopic&topicid={$postsx["tid"]}&page=p{$postsx["pid"]}#{$postsx["pid"]}\"><b>{$postsx["subject"]}</b></a>in <a href=\"forums.php?action=viewforum&forumid={$postsx["forumid"]}\">{$postsx["name"]}</a></td>". "<td align='right'>{$postsx["postcount"]}</td>". "<td align='right'>{$postsx["views"]}</td>". "<td><a href=userdetails.php?id={$postsx["usertopic"]}><b>{$postsx["tusername"]}</b></a></td>". "<td>{$postsx["added"]}by <a href=userdetails.php?id={$postsx["userpost"]}><b>{$postsx["username"]}</b></a></td></tr>"); } print("</table>"); ///////////////////////////////////////////////// END LAST X FORUM POSTS ?> </div>
<div class="useron"><? // users on index - Credits Bigjoos $active3 = ""; $file = ROOT_DIR."cache/active.txt"; $expire = 30; // 30 seconds
if (file_exists($file) && filemtime($file) > (time() - $expire)) { $active3 = unserialize(file_get_contents($file)); } else { $dt = sqlesc(get_date_time(gmtime() - 180)); $active1 = sql_query("SELECT id, username, class, warned, enabled, added, donor FROM users WHERE last_access >= $dt ORDER BY class DESC") OR sqlerr(__FILE__, __LINE__);
while ($active2 = mysql_fetch_assoc($active1)) { $active3[] = $active2; } $OUTPUT = serialize($active3); $fp = fopen($file, "w");
fputs($fp, $OUTPUT); fclose($fp); } // end else
$activeusers = "";
if (is_array($active3)) foreach ($active3 AS $arr) { if ($activeusers) $activeusers .= ",\n"; $activeusers .= "<span style=\"white-space: nowrap;\">"; $arr["username"] = "<font color='#" . get_user_class_color($arr['class']) . "'> " . htmlspecialchars($arr['username']) . "</font>";
$donator = $arr["donor"] === "yes"; $warned = $arr["warned"] === "yes";
if ($CURUSER) $activeusers .= "<a class='altlink_user' href='$site_url/userdetails.php?id={$arr["id"]}'><b>{$arr["username"]}</b></a>"; else $activeusers .= "<b>{$arr["username"]}</b>";
if ($donator) $activeusers .= "<img src='".$image_dir."star.png' alt='Donated' title='Donated' />";
if ($warned) $activeusers .= "<img src='".$image_dir."warned.png' alt='Warned' title='Warned' />"; $activeusers .= "</span>"; }
$fh = fopen("./cache/active.txt", "r");
$string = file_get_contents("cache/active.txt"); $count = preg_match_all( '/username/', $string, $dummy ); ?> <? if (!$activeusers) $activeusers = "Sorry - No Users Presently Active "; ?>
<table border='0' cellpadding='10' cellspacing='0' width='101'> <tr class='tableuse'> </tr> </table>
<? if (!$activeusers) $activeusers = "Sorry - No Users Presently Active "; ?> <? // users on index - Credits Bigjoos $active3 = ""; $file = ROOT_DIR."cache/active.txt"; $expire = 30; // 30 seconds
if (file_exists($file) && filemtime($file) > (time() - $expire)) { $active3 = unserialize(file_get_contents($file)); } else { $dt = sqlesc(get_date_time(gmtime() - 180)); $active1 = sql_query("SELECT id, username, class, warned, enabled, added, donor FROM users WHERE last_access >= $dt ORDER BY class DESC") OR sqlerr(__FILE__, __LINE__);
while ($active2 = mysql_fetch_assoc($active1)) { $active3[] = $active2; } $OUTPUT = serialize($active3); $fp = fopen($file, "w");
fputs($fp, $OUTPUT); fclose($fp); } // end else
$activeusers = "";
if (is_array($active3)) foreach ($active3 AS $arr) { if ($activeusers) $activeusers .= ",\n"; $activeusers .= "<span style=\"white-space: nowrap;\">"; $arr["username"] = "<font color='#" . get_user_class_color($arr['class']) . "'> " . htmlspecialchars($arr['username']) . "</font>";
$donator = $arr["donor"] === "yes"; $warned = $arr["warned"] === "yes";
if ($CURUSER) $activeusers .= "<a class='altlink_user' href='$site_url/userdetails.php?id={$arr["id"]}'><b>{$arr["username"]}</b></a>"; else $activeusers .= "<b>{$arr["username"]}</b>";
if ($donator) $activeusers .= "<img src='".$image_dir."star.png' alt='Donated' title='Donated' />";
if ($warned) $activeusers .= "<img src='".$image_dir."warned.png' alt='Warned' title='Warned' />"; $activeusers .= "</span>"; }
$fh = fopen("./cache/active.txt", "r");
$string = file_get_contents("cache/active.txt"); $count = preg_match_all( '/username/', $string, $dummy ); ?> <?php //==Cached Last24 by putyn function last24hours() { global $CURUSER, $last24cache, $last24record ;
$last24cache = ROOT_DIR.'/cache/last24/'.date('dmY').'.txt'; $last24record = ROOT_DIR.'/cache/last24record.txt'; $_last24 = (file_exists($last24cache) ? unserialize(file_get_contents($last24cache)) : array()); $_last24record = (file_exists($last24record) ? unserialize(file_get_contents($last24record)) : array('num'=>0,'date'=>0));
if(!isset($_last24[$CURUSER['id']]) || empty($_last24[$CURUSER['id']])) { $_last24[$CURUSER['id']] = array($CURUSER['username'],$CURUSER['class']); $_newcount = count($_last24);
if(isset($_last24record['num']) && $_last24record['num']<$_newcount) { $_last24record['num'] = $_newcount; $_last24record['date'] = time();
file_put_contents($last24record,serialize($_last24record)); } file_put_contents($last24cache,serialize($_last24)); } } ?></div> </div> <div class="cont"> <table width="100%" border="1"> <tr> <td width="89%" bgcolor="#28282a"><div align="center">ShoutBox</div></td> <td width="11%" bgcolor="#28282a3"> <div class="onlinehead"><div class="headtxtw"> <div align="center"> <?=($count)?> Online</div> </div> </div> </td> </tr> <tr> <td><iframe src='shoutbox.php' width='670px' height='398' frameborder='0' name='sbox' marginwidth='0' marginheight='0' allowtransparency='true'></iframe></td> <td> <table width='84' height="381" border='0' cellpadding='10' cellspacing='0' class="onlinename"> <tr class='tableuse'> <td width="64" class='text'><div align="center"> <?=$activeusers?> </div></td> </tr> </table></td> </tr> </table> </div>
<form action='shoutbox.php' method='get' target='sbox' name='shbox'> <p align='center'>Message: <input type='text' name='shbox_text' size='80' /> <input type='submit' class='btn' value=' Shout ' /> <input type='hidden' name='sent' value='yes' />
<?php if (get_user_class() >= UC_MODERATOR) { ?> <a href="javascript:popUp('shoutbox_commands.php')">[ Commands ]</a> <?php } ?> <a href="javascript:%20SmileIT(':-)','shbox','shbox_text')"><img border='0' src='<?=$image_dir?>smilies/smile1.gif' alt='' width='18' height='18' /></a>
<a href="javascript:%20SmileIT(':smile:','shbox','shbox_text')"><img border='0' src='<?=$image_dir?>smilies/smile2.gif' alt='' width='18' height='18' /></a>
<a href="javascript:%20SmileIT(':-D','shbox','shbox_text')"><img border='0' src='<?=$image_dir?>smilies/grin.gif' alt='' width='18' height='18' /></a>
<a href="javascript:%20SmileIT(':evo:','shbox','shbox_text')"><img src='<?=$image_dir?>smilies/evo.gif' alt='' width='18' height='18' border='0' /></a>
<a href="javascript:%20SmileIT(':-|','shbox','shbox_text')"><img border='0' src='<?=$image_dir?>smilies/noexpression.gif' alt='' width='18' height='18' /></a>
<a href="javascript:%20SmileIT(':-/','shbox','shbox_text')"><img border='0' src='<?=$image_dir?>smilies/confused.gif' alt='' width='18' height='18' /></a>
<a href="javascript:%20SmileIT(':-(','shbox','post')"><img border='0' src='<?=$image_dir?>smilies/sad.gif' alt='' width='18' height='18' /></a>
<a href="javascript:%20SmileIT(':weep:','shbox','shbox_text')"><img src='<?=$image_dir?>smilies/weep.gif' alt='' width='18' height='18' border='0' /></a>
<a href="javascript:%20SmileIT(':-O','shbox','shbox_text')"><img src='<?=$image_dir?>smilies/ohmy.gif' alt='' border='0' width='18' height='18' /></a>
<a href="javascript:%20SmileIT('8-)','shbox','shbox_text')"><img src='<?=$image_dir?>smilies/cool1.gif' alt='' width='18' height='18' border='0' /></a>
<a href="javascript:%20SmileIT(':yawn:','shbox','shbox_text')"><img src='<?=$image_dir?>smilies/yawn.gif' alt='' width='18' height='18' border='0' /></a>
<a href="javascript:%20SmileIT(':sly:','shbox','shbox_text')"><img src='<?=$image_dir?>smilies/sly.gif' alt='' width='18' height='18' border='0' /></a>
<a href="javascript:%20SmileIT(':greedy:','shbox','shbox_text')"><img src='<?=$image_dir?>smilies/greedy.gif' alt='' width='18' height='18' border='0' /></a>
<a href="javascript:%20SmileIT(':weirdo:','shbox','shbox_text')"><img src='<?=$image_dir?>smilies/weirdo.gif' alt='' width='18' height='18' border='0' /></a>
<a href="javascript:%20SmileIT(':sneaky:','shbox','shbox_text')"><img src='<?=$image_dir?>smilies/sneaky.gif' alt='' width='18' height='18' border='0' /></a>
<a href="javascript:%20SmileIT(':kiss:','shbox','shbox_text')"><img src='<?=$image_dir?>smilies/kiss.gif' alt='' width='18' height='18' border='0' /></a>
<a href="javascript:%20SmileIT(':geek:','shbox','shbox_text')"><img src='<?=$image_dir?>smilies/geek.gif' alt='' width='18' height='18' border='0' /></a>
<a href="javascript:%20SmileIT(':evil:','shbox','shbox_text')"><img src='<?=$image_dir?>smilies/evil.gif' alt='' width='18' height='18' border='0' /></a>
<a href="javascript:%20SmileIT(':yucky:','shbox','shbox_text')"><img src='<?=$image_dir?>smilies/yucky.gif' alt='' width='18' height='18' border='0' /></a>
<a href="javascript:%20SmileIT(':shit:','shbox','shbox_text')"><img src='<?=$image_dir?>smilies/shit.gif' alt='' width='18' height='18' border='0' /></a>
<a href="javascript:%20SmileIT(':?:','shbox','shbox_text')"><img src='<?=$image_dir?>smilies/question.gif' alt='' width='18' height='18' border='0' /></a>
<a href="javascript:%20SmileIT(':!:','shbox','shbox_text')"><img src='<?=$image_dir?>smilies/idea.gif' alt='' width='18' height='18' border='0' /></a>
<font size='1'><a href='shoutbox.php' target='sbox'><img src="http://icons.iconarchive.com/icons/deleket/soft-scraps/24/Button-Reload-icon.png" alt="Refresh" class="refreshicon" /></a></font><a href="javascript:popUp('more.php')"><img src="http://icons.iconarchive.com/icons/deleket/keriyo-emoticons/24/Smiley-icon.png" alt="more Smilies" class="moresmile" /></a> </form></div>
<div class="cont"><div class="sthead"><div class="headtxt">Stats</div></div> <table width=100%border=1 cellspacing=0 cellpadding=10><tr><td align=center> <table class='main' border='1' cellspacing='0' cellpadding='5'> <tr> <td class='rowhead'>Registered Users</td><td align='right'><?=$registered?>/<?=$max_users?></td> <td class='rowhead'>Users Online</td><td align='right'><?=$numactive?></td> </tr> <tr> <td class='rowhead'>Unconfirmed Users</td><td align='right'><?=$unverified?></td> <td class='rowhead'>Donors</td><td align='right'><?=$donors?></td> </tr> <tr> <td colspan='4'> </td> </tr> <tr> <td class='rowhead'>Forum Topics</td><td align='right'><?=$forumtopics?></td> <td class='rowhead'>Torrents</td><td align='right'><?=$torrents?></td> </tr> <tr> <td class='rowhead'>Forum Posts</td><td align='right'><?=$forumposts?></td> <td class='rowhead'>New Torrents Today</td><td align='right'><?=$torrentstoday?></td> </tr> <tr> <td colspan='4'> </td> </tr> <tr> <td class='rowhead'>Peers</td><td align='right'><?=$peers?></td> <td class='rowhead'>Unconnectable Peers</td><td align='right'><?=$unconnectables?></td> </tr> <tr> <td class='rowhead'>Seeders</td><td align='right'><?=$seeders?></td> <td class='rowhead' align='right'><b>Unconnectables Ratio (%)</b></td><td align='right'><b><?=round($ratiounconn * 100)?></b></td> </tr> <tr> <td class='rowhead'>Leechers</td><td align='right'><?=$leechers?></td> <td class='rowhead'>Seeder/Leecher Ratio (%)</td><td align='right'><?=$ratio?></td> </tr> </table> <? //print("<p align=center><font class=small>Updated ".date('Y-m-d H:i:s', filemtime($file))."</font></p>"); ?> </td><td align=center> <table width=175 class=interiortable border=1 cellspacing=0 cellpadding=4> <tr><td class=rowcenter colspan=2>Last 10 visitors</td></tr> <? $file = "$CACHE/index/lastten.txt";
$expire = 30; // 30 seconds if (file_exists($file) && filemtime($file) > (time() - $expire)) { $records = unserialize(file_get_contents($file)); } else { $result = mysql_query("SELECT username,class,last_access,id FROM users WHERE last_access != '0000-00-00 00:00:00' ORDER BY last_access DESC LIMIT 10"); while ($record = mysql_fetch_array($result) ) { $records[] = $record; } $OUTPUT = serialize($records); $fp = fopen($file,"w"); fputs($fp, $OUTPUT); fclose($fp); } // end else
foreach ($records as $arr) { switch ($arr["class"]) { //case UC_SYSOP: case UC_SYSOP: $arr["username"] = "<font color=#FF0000>" . $arr["username"] . "</font>"; break; case UC_ADMINISTRATOR: $arr["username"] = "<font color=#B000B0>" . $arr["username"] . "</font>"; break; case UC_MODERATOR: $arr["username"] = "<font color=#FE2E2E>" . $arr["username"] . "</font>"; break; case UC_UPLOADER: $arr["username"] = "<font color=#0000FF>" . $arr["username"] . "</font>"; break; case UC_VIP: $arr["username"] = "<font color=#009F00>" . $arr["username"] . "</font>"; break; case UC_POWER_USER: $arr["username"] = "<font color=#f9a200>" . $arr["username"] . "</font>"; break; break; case UC_USER: $arr["username"] = "<font color=#8E35EF>" . $arr["username"] . "</font>"; break; } $time = gmtime() - sql_timestamp_to_unix_timestamp($arr[last_access]); if ($CURUSER) echo "<tr><td style=\"border-right: none; padding-left: 5px\"><a href=userdetails.php?id=".$arr[id]."><b>".$arr[username]."</b></a></td><td style=\"border-left: none; padding-right: 5px\">".mkprettytime($time)." ago</td></tr>"; else echo "<tr><td style=\"border-right: none; padding-left: 5px\"><b>".$arr[username]."</b></td><td style=\"border-left: none; padding-right: 5px\">".mkprettytime($time)." ago</td></tr>"; } ?> </table> <? //print("<p align=center><font class=small>Updated ".date('Y-m-d H:i:s', filemtime($file))."</font></p>"); ?> </td></tr></table> </div> <div class="cont"><?php
//==Cached Last24 by putyn function las24hours_display() { global $CURUSER, $last24cache, $last24record ;
$_last24 = (file_exists($last24cache) ? unserialize(file_get_contents($last24cache)) : array()); $_last24record = (file_exists($last24record) ? unserialize(file_get_contents($last24record)) : array('num'=>0,'date'=>0));
$txt = '';
$str = file_get_contents(ROOT_DIR.'/cache/last24/'.date('dmY').'.txt'); //$_matches = preg_match_all('/a:2/', $str, $dummy);
if(!is_array($_last24)) $txt = 'No 24 Hour Record'; else { //$txt .= '<h2>Active Users in the Last 24hrs - ('.$_matches.') </h2> $txt .= '<div class="sthead"><div class="headtxt">Active Users in the Last 24hrs</div></div> <table border=\'0\' cellpadding=\'10\' cellspacing=\'0\' width=\'100%\'> <tr class=\'table\'> <td class=\'text\'><span>'; $c = count($_last24); $i = 0;
foreach($_last24 AS $id=>$username) { $txt .= '<a class=\'altlink_user\' href=\'./userdetails.php?id='.$id.'\'><font color=\'#'.get_user_class_color($username[1]).'\'><b>'.$username[0].'</b></font></a>'.(($c-1) == $i ? '' : ',')."\n"; $i++; }
$txt .= '</span></td></tr>'; $txt .= '<tr class=\'table\'><td class=\'text\'><span>Most ever visited in 24 hours was '.$_last24record['num'].' Members : '.get_date_time($_last24record['date'],'DATE').' </span></td></tr></table>'; } return $txt; } last24hours(); print las24hours_display();
if (isset($CURUSER)) { ?></div> <div class="cont"><div class="sthead"><div class="headtxt">Disclaimer</div></div> <table width='100%' border='0' cellpadding='10' cellspacing='0' class="mtable"> <tr> <td align='center'> <b>None of the files shown here are actually hosted on this server. The links are provided solely by this site's users. The administrator of this site <font color='#ff0000'><?=$site_name?></font> cannot be held responsible for what its users post, or any other actions of its users. You may not use this site to distribute or download any material when you do not have the legal rights to do so. It is your own responsibility to adhere to these terms.</b> </td> </tr> </table></div> <div class="cont"><div class="sthead"><div class="headtxt">Server load</div></div> <table width=100% border=0 cellspacing=0 cellpadding=10><tr><td align=center> <table class=interiortable border=0 width=402><tr><td style='padding: 0px; background-repeat: repeat-x'> <? $percent = min(100, round(exec('ps ax | grep -c apache') / 256 * 30 )); echo "Our Tracker Load: ($percent %)(these stats are an approximation)<table class=interiortable border=0 width=400><tr><td style='padding: 0px; background-image: url(pic/loadbarbg.gif); background-repeat: repeat-x'>";
if ($percent <= 70) $pic = "http://www.bvlist.com/images/loadbargreen.gif"; elseif ($percent <= 90) $pic = "http://www.bvlist.com/images/loadbaryellow.gif"; else $pic = "http://www.bvlist.com/images/loadbarred.gif"; $width = $percent * 8; echo "<img height=15 width=$width src=\"/$pic\" alt='$percent%'></td></tr></table>"; echo "" . trim(exec('uptime')) . "";
$percent = min(100, round(exec('ps ax | grep -c apache') / 256 * 150)); echo "Global Server Load (All websites on current host servers): ($percent %)<table class=interiortable border=0 width=400><tr><td style='padding: 0px; background-image: url(images/loadbarbg.gif); background-repeat: repeat-x'>";
if ($percent <= 70) $pic = "http://www.bvlist.com/images/loadbargreen.gif"; elseif ($percent <= 90) $pic = "http://www.bvlist.com/images/loadbaryellow.gif"; else $pic = "http://www.bvlist.com/images/loadbarred.gif"; $width = $percent * 8; echo "<img height=15 width=$width src=\"$pic\" alt='$percent%'></td></tr></table>"; ?>
</td></tr></table> </div> <?php
}
site_footer();
?>
Fixed the shoutbox width on index to.
|