|
#1
|
|||
|
|||
ajax browse help please
can anyone help me please im trying to add torrent new tags so when a new torrent gets uploaded it says new, to this ajax browse but not having any success
Code:
<?php require_once("include/bittorrent.php"); if(eregi(basename(__FILE__),$_SERVER['REQUEST_URI'])){ print("<h2>You know you're not allowed to look directly at scripts.. so stop trying to peak</h2>"); die(); } // == TheHippy Ajax Browse Class 2010 // // == class browseTorrents extends db { // $active statuses are 1=active only, 2=dead only, 3=active and dead public function getTorrentList($cats_id=0,$active=3,$page=1,$stext=0) { $cats = genrelist(); $cattotal = count($cats); $output = ""; $perpage = "25"; $offset = ($page - 1) * $perpage; $where = ""; $ccase = ""; if($cats_id != "0"){ $where = " WHERE "; $ccase .= "`torrents`.`category`='" . urlencode($cats_id) . "'"; } if($stext != "0"){ if($where == " WHERE "){ $ccase .= " AND `torrents`.`name` LIKE '%" . htmlspecialchars($stext) . "%'"; } else { $where = " WHERE "; $ccase .= "`torrents`.`name` LIKE '%" . htmlspecialchars($stext) . "%'"; } } switch($active) { case 1: if($where == " WHERE "){ $ccase .= " AND `torrents`.`visible`='yes'"; } else { $where = " WHERE "; $ccase .= "`torrents`.`visible`='yes'"; } break; case 2: if($where == " WHERE "){ $ccase .= " AND `torrents`.`visible`='no'"; } else { $where = " WHERE "; $ccase .= "`torrents`.`visible`='no'"; } break; case 3: break; } // = This counts the total torrents for pagination $sql2 = "SELECT `torrents`.`id`, `torrents`.`name` AS `torrentname`, `torrents`.`filename`, `torrents`.`description`,`torrents`.`category`, `torrents`.`size`, `torrents`.`added`, `torrents`.`type`, `torrents`.`numfiles`, `torrents`.`comments`, `torrents`.`views`, `torrents`.`hits`, `torrents`.`times_completed`, `torrents`.`leechers`, `torrents`.`seeders`, `torrents`.`owner`, `users`.`username`,`users`.`privacy`, `users`.`id` AS `user_id`, `categories`.`name` FROM `torrents` LEFT JOIN `users` ON `users`.`id`=`torrents`.`owner` LEFT JOIN `categories` ON `categories`.`id`=`torrents`.`category` " . $where . $ccase . ""; $gettotals = $this->query($sql2); $totalt = $this->rows; $maxpage = ceil($totalt/$perpage); $npage = array(); // = This makes the pagination if($page > 1){ $pagefirst = "document.getElementById('page').value='1';"; $npage[] = " <span class=\"ajaxclicker\" onmousedown=\"$pagefirst\" onclick=\"doBrowse();\">« First Page</span> "; $pagel = "document.getElementById('page').value='$maxpage';"; $lastpage = "<span class=\"ajaxclicker\" onmousedown=\"$pagel\" onclick=\"doBrowse();\">" . $maxpage . "</span>"; $pageback = $page-1; $pageba = "document.getElementById('page').value='$pageback';"; $npage[] = " <span class=\"ajaxclicker\" onmousedown=\"$pageba\" onclick=\"doBrowse();\"><img title=Back border='0' src=\"pic/prevpager.png\"/></span> "; if($page < $maxpage){ $pageforr = $page+1; $pagefor = "document.getElementById('page').value='$pageforr';"; $npage[] = " <span class=\"ajaxclicker\" onmousedown=\"$pagefor\" onclick=\"doBrowse();\"><img title='page $page' border='0' src=\"pic/nextpager.png\"/></span> "; $pagelast = "document.getElementById('page').value='$maxpage';"; $npage[] = " <span class=\"ajaxclicker\" onmousedown=\"$pagelast\" onclick=\"doBrowse();\">Last Page »</span> "; $pagel = "document.getElementById('page').value='$maxpage';"; $lastpage = "<span class=\"ajaxclicker\" onmousedown=\"$pagel\" onclick=\"doBrowse();\">" . $maxpage . "</span>"; } } if($maxpage > 1){ if($page == 1){ $pageforr = $page+1; $pagefor = "document.getElementById('page').value='$pageforr';"; $npage[] = " <span class=\"ajaxclicker\" onmousedown=\"$pagefor\" onclick=\"doBrowse();\"><img title='Page $page' border='0' src=\"pic/nextpager.png\"/></span> "; $pagelast = "document.getElementById('page').value='$maxpage';"; $npage[] = " <span class=\"ajaxclicker\" onmousedown=\"$pagelast\" onclick=\"doBrowse();\">Last Page »</span>"; } } $output .= "<span class=\"ajaxclicker\" onclick=\"doBrowse();\"><b>Refresh Table</b></span>"; $output .= "<br><div border=\"0\" style=\"text-align:center;\"><span id=\"totalrecords\">Total Torrents found: $totalt</span>"; foreach($npage as $key=>$val) { $output .= $val; } $output .= "</div>"; // = This makes the actual query to populate the table of results $sql = "SELECT `torrents`.`id`, `torrents`.`name` AS `torrentname`, `torrents`.`filename`, `torrents`.`ori_descr`, torrents.free,`torrents`.`category`, torrents.10days, categories.name AS cat_name, categories.image AS cat_pic, `torrents`.`size`, `torrents`.`added`, `torrents`.`type`, `torrents`.`numfiles`, `torrents`.`comments`, `torrents`.`views`, `torrents`.`hits`, `torrents`.`times_completed`, `torrents`.`leechers`, `torrents`.`seeders`, `torrents`.`owner`, `users`.`username`,`users`.`privacy`, `users`.`id` AS `user_id`, `categories`.`name`,users.class as owner_class FROM `torrents` LEFT JOIN `users` ON `users`.`id`=`torrents`.`owner` LEFT JOIN `categories` ON `categories`.`id`=`torrents`.`category` " . $where . $ccase . " ORDER BY `torrents`.`id` DESC LIMIT $offset,$perpage"; $tors = $this->query($sql); $total = $this->rows; // = Start building what'll be displayed in the users browser if($this->rows > 0){ $output .= "<br />\n"; $output .= "<table border=\"0\" align=\"center\" class=\"row3\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n"; $output .= " <tr>\n"; $output .= " <td class=\"colhead\" align=\"center\">Genre</td>\n"; $output .= " <td class=\"colhead\" align=\"center\">Name</td>\n"; $output .= " <td class=\"colhead\" width=\"8%\" align=\"center\">Added</td>\n"; $output .= " <td class=\"colhead\" align=\"center\"><img border='0' src='pic/comments.png' alt='Comments' title='Comments' /></td>\n"; $output .= " <td class=\"colhead\" width=\"8%\" align=\"center\">Size</td>\n"; $output .= " <td class=\"colhead\" align=\"center\"><img border='0' src='pic/snatched.png' alt='Snatches' title='Snatches' /></td>\n"; $output .= " <td class=\"colhead\" align=\"center\"><img border='0' src='pic/seeders.png' alt='Seeders' title='Seeders' /></td>\n"; $output .= " <td class=\"colhead\" align=\"center\"><img border='0' src='pic/leechers.png' alt='Leechers' title='Leechers' /></td>\n"; $output .= " <td class=\"colhead\" align=\"center\">Upped by</td>\n"; $output .= " </tr>\n"; while($tor = mysql_fetch_array($tors)){ /* $ttl = (28*24) - floor((time() - $tor["added"]) / 3600); if ($ttl == 1){ $ttl .= "<br />Hour"; } else { $ttl .= "<br />Hours"; } */ $leecha = ""; $leechb = ""; $seeda = ""; $seedb = ""; if($tor['leechers'] > 0){ $leecha = "<strong><a href=\"details.php?id=" . $tor['id'] . "&dllist=1#leechers\"><font color=green>"; $leechb = "</a></strong></font>"; } if($tor['seeders'] > 0){ $seeda = "<strong><a href=\"details.php?id=" . $tor['id'] . "&dllist=1#seeders\"><font color=green>"; $seedb = "</a></strong></font>"; } if($tor['comments'] >= 1){ $com1 = "<strong><a href=\"details.php?id=" . $tor['id'] . "&page=0#startcomments\"><font color=green>"; $com2 = "</a></strong></font>"; } $thisisfrees = ($tor[free]=="yes" ? "<img align=right src=pic/freedownload.gif title='This torrent is freeleech so only upload counts!'>" : ""); $doubleuptag = ($tor["10days"]=="yes" ? "<img align=right src='pic/2xup.png' alt='x2' title='This torrent is x2 upload'>" : ""); $dispname = htmlspecialchars($tor["torrentname"]); $dispname1 = htmlspecialchars($tor["ori_descr"]); if (get_user_class() >= UC_VIP){ $dl = ("<a align=right href=\"download.php/" . $tor['id'] . "/" . rawurlencode($tor["filename"]) . "\"><img align=right src=pic/blank.gif class=dl border=0 title='Download $dispname' alt=Download></a>"); } $added = "" . get_elapsed_times(sql_timestamp_to_unix_timestamp($tor["added"])) . " ago"; $detaila = "<strong><a title=\"$dispname1\" href=\"details.php?id=" . $tor['id'] . "\">"; $detailb = "</a></strong>"; $filesa = "<strong><a href=\"filelist.php?id=" . $tor['id'] . "\">"; $filesb = "</a></strong>"; $ownera = "<strong><a href=\"" . $tor['username'] . ".usr\"><font color=\"".get_user_class_color($tor["owner_class"])."\">"; $ownerb = "</a></strong></font>"; $catega = "<span ><span>"; $categb = "</span></span>"; $downla = "<a href=\"download.php?torrent=" . $tor['id'] . "\">"; $downlb = "</a>"; $output .= " <tr class=browse>"; $output .= " <td align=\"left\"><img border=\"0\" src=\"pic/categorypics/" . $tor["cat_pic"] . "\" title=\"" . $tor["cat_name"] . "\" /></td>\n"; $output .= " <td align=\"left\"><b>". $detaila . $tor['torrentname'] . $detailb ."$dl $thisisfrees $doubleuptag</b></a>\n"; $output .= " <td align=\"center\">$added</td>\n"; // $output .= " <td align=\"center\">" . $ttl . "</td>\n"; $output .= " <td align=\"center\"><a href=\"details.php?id=" . $tor['id'] . "&page=0#startcomments\">" . $tor['comments'] . "</a></td>\n"; $output .= " <td align=\"center\">" . str_replace(" ", " ", mksize($tor["size"])) . "</td>\n"; $output .= " <td align=\"center\"><a href=viewsnatches.php?id=$tor[id]>" . $tor['times_completed'] . "</a></td>\n"; $output .= " <td align=\"center\"><b><font color=red>" . $seeda . $tor['seeders'] . $seedb . "</td></font>\n"; $output .= " <td align=\"center\"><b><font color=red>" . $leecha . $tor['leechers'] . $leechb . "</td></font></b>\n"; $output .= " <td align=\"center\">" . $ownera . $tor['username'] . $ownerb . "</td>\n"; $output .= " </tr>"; } $output .= "</table>\n"; } else { $output.= "<h2>Sorry: There are no torrents that match your criteria, try amending your options.</h2>"; } $output .= "<br /><div style=\"text-align:center;\"><span id=\"totalrecords\">Total Torrents found: $totalt</span>"; foreach($npage as $key=>$val) { $output .= $val; } $output .= "</div>"; // = Amend with your website address below... //$output.= "<br /><span class=\"linktopage\"><strong>Link to this page: </strong>https://gettorrents.org/browse.php?cat_id=" . $cats_id . "&active=" . $active . "&page=" . $page . "&search=" . $stext . "</span>"; return $output; } } ?> |
#2
|
|||
|
|||
im looking for the browse.php with cats dro down so n i do not le the one that on it to an oe have a good browse page ?
this one crap PHP Code:
|
#3
|
|||
|
|||
Don't know if this will do, but try:
change this: PHP Code:
PHP Code:
Last edited by Krypto; 6th January 2013 at 08:52. |
#4
|
|||
|
|||
yup that works then i add this code in but to clear the new tags but not working it used to work before i updated the browse.php to ajax
Code:
if ($_GET['clear_new']){ mysql_query("UPDATE users SET last_browse=".gmtime()." where id=".$CURUSER['id']); header("Location: browse.php"); } so in my first post is browse.class.php and this is the borwse.php Code:
<?php //ini_set("display_errors","2"); //ERROR_REPORTING(E_ALL); // == If not working, uncomment above for debugging. /* +------------------------------------------------ | TBDev.net BitTorrent Tracker PHP | ============================================= | by CoLdFuSiOn | (c) 2003 - 2009 TBDev.Net | http://www.tbdev.net | ============================================= | svn: http://sourceforge.net/projects/tbdevnet/ | Licence Info: GPL +------------------------------------------------ | $Date$ | $Revision$ | $Author$ | $URL$ +------------------------------------------------ = Ajax Browse by TheHippy 2010 */ ob_start("ob_gzhandler"); require_once("include/bittorrent.php"); include("class/db.class.php"); include("class/browse.class.php"); dbconn(false); loggedinorreturn(); getpage(); parked(); if ($_GET['clear_new']){ mysql_query("UPDATE users SET last_browse=".gmtime()." where id=".$CURUSER['id']); header("Location: browse.php"); } $torrents = array(); $res = mysql_query("SELECT torrent, seeder, COUNT(*) AS c FROM peers GROUP BY torrent, seeder"); while ($row = mysql_fetch_assoc($res)) { if ($row["seeder"] == "yes") $key = "seeders"; else $key = "leechers"; $torrents[$row["torrent"]][$key] = $row["c"]; } $res = mysql_query("SELECT torrent, COUNT(*) AS c FROM comments GROUP BY torrent"); while ($row = mysql_fetch_assoc($res)) { $torrents[$row["torrent"]]["comments"] = $row["c"]; } $fields = explode(":", "comments:leechers:seeders"); $res = mysql_query("SELECT id, seeders, leechers, comments FROM torrents"); while ($row = mysql_fetch_assoc($res)) { $id = $row["id"]; $torr = $torrents[$id]; foreach ($fields as $field) { if (!isset($torr[$field])) $torr[$field] = 0; } $update = array(); foreach ($fields as $field) { if ($torr[$field] != $row[$field]) $update[] = "$field = " . $torr[$field]; } if (count($update)) mysql_query("UPDATE torrents SET " . implode(",", $update) . " WHERE id = $id"); } $deadtime = deadtime(); mysql_query("DELETE FROM peers WHERE last_action < FROM_UNIXTIME($deadtime)"); $deadtime -= $max_dead_torrent_time; mysql_query("UPDATE torrents SET visible='no' WHERE visible='yes' AND last_action < FROM_UNIXTIME($deadtime)"); //--- Added by Wilba -------------------------------- //mysql_query("UPDATE users SET last_browse=".gmtime()." where id=".$CURUSER['id']); //--------------------------------------------------- mysql_query("UPDATE torrents SET free = 'yes' WHERE free = 'no' AND seeders>='3'")or sqlerr(__FILE__, __LINE__); mysql_query("UPDATE torrents SET free = 'no' WHERE free = 'yes' AND seeders<'10'") or sqlerr(__FILE__, __LINE__); mysql_query("UPDATE torrents SET free = 'yes' WHERE size > '1073741824' AND seeders>='1'") or sqlerr(__FILE__, __LINE__); mysql_query("UPDATE torrents SET free = 'no' WHERE size > '1073741824' AND seeders<'10'") or sqlerr(__FILE__, __LINE__); mysql_query("UPDATE torrents SET free = 'yes' WHERE size > '1073741824'") or sqlerr(__FILE__, __LINE__); //mysql_query ("UPDATE torrents SET request = 'yes' WHERE request = ''") or sqlerr(__FILE__, __LINE__); //mysql_query ("UPDATE torrents SET request = 'yes' WHERE request = 'no'") or sqlerr(__FILE__, __LINE__); //=== remove donor status if time up AND set class back to power user... remember to set the class number for your system===// $res = mysql_query("SELECT id, modcomment FROM users WHERE donor='yes' AND donoruntil < NOW() AND donoruntil <> '0000-00-00 00:00:00'") or sqlerr(__FILE__, __LINE__); if (mysql_num_rows($res) > 0) { $dt = sqlesc(get_date_time()); $subject = sqlesc("Donor status removed by system."); $msg = sqlesc("Your Donor status has timed out and has been auto-removed by the system, and your VIP status has been removed. We would like to thank you once again for your support to Gettorrents.org. If you wish to re-new your donation, you can do so by going to http://gettorrents.org/donate.php. Cheers!\n"); while ($arr = mysql_fetch_assoc($res)) { ///---AUTOSYSTEM MODCOMMENT---// $modcomment = htmlspecialchars($arr["modcomment"]); $modcomment = gmdate("d-m-Y") . " - Donor status removed by -System.\n". $modcomment; $modcom = sqlesc($modcomment); ///---AUTOSYSTEM MODCOMMENT---// mysql_query("UPDATE users SET class = '0', donor = 'no', donoruntil = '0000-00-00 00:00:00', modcomment = $modcom WHERE id = $arr[id]") or sqlerr(__FILE__, __LINE__); mysql_query("INSERT INTO messages (sender, receiver, added, msg, subject, poster) VALUES(0, $arr[id], $dt, $msg, $subject, 0)") or sqlerr(__FILE__, __LINE__); } } //===end===// //=== remove donor status if time up AND set class back to power user... remember to set the class number for your system===// $res = mysql_query("SELECT id, modcomment FROM users WHERE donor='no' AND donoruntil < NOW() AND donoruntil <> '0000-00-00 00:00:00'") or sqlerr(__FILE__, __LINE__); if (mysql_num_rows($res) > 0) { $dt = sqlesc(get_date_time()); $subject = sqlesc("Donor status removed by system."); $msg = sqlesc("Your Donor status has timed out and has been auto-removed by the system, and your VIP status has been removed. We would like to thank you once again for your support to Gettorrents.org. If you wish to re-new your donation, you can do so by going to http://gettorrents.org/donate.php. Cheers!\n"); while ($arr = mysql_fetch_assoc($res)) { ///---AUTOSYSTEM MODCOMMENT---// $modcomment = htmlspecialchars($arr["modcomment"]); $modcomment = gmdate("d-m-Y") . " - Donor status removed by -System.\n". $modcomment; $modcom = sqlesc($modcomment); ///---AUTOSYSTEM MODCOMMENT---// mysql_query("UPDATE users SET class = '0', donor = 'no', donoruntil = '0000-00-00 00:00:00', modcomment = $modcom WHERE id = $arr[id]") or sqlerr(__FILE__, __LINE__); mysql_query("INSERT INTO messages (sender, receiver, added, msg, subject, poster) VALUES(0, $arr[id], $dt, $msg, $subject, 0)") or sqlerr(__FILE__, __LINE__); } } //===end===// //$HTMLOUT .= "<div id='view_cate_area' style='display:none;'>"; //print out the tag cloud //require_once "include/sb_inc.php"; //$HTMLOUT .= top5() . "</div><br /><br />"; $cats = genrelist(); $output = ""; $cid = (isset($_GET['cat_id'])) ? $_GET['cat_id'] : "0"; $aid = (isset($_GET['active'])) ? $_GET['active'] : "3"; $pid = (isset($_GET['page'])) ? $_GET['page'] : "1"; $stext = (isset($_GET['search'])) ? htmlspecialchars($_GET['search']) : ""; $output.= "<input type=\"hidden\" id=\"cater\" value=\"" . $cid . "\" />"; $output.= "<input type=\"hidden\" id=\"active\" value=\"" . $aid . "\" />"; $output.= "<input type=\"hidden\" id=\"page\" value=\"" . $pid . "\" />"; $cattotal = count($cats); $i = 2; $output.= "<center><a href=\"javascript:view_cate('view_cate_area', 'view_cate_link');\"><font id=\"view_cate_link\"><img border='0' src=\"pic/plus2.gif?v=2\"/> Show categories</font></a><div id=\"view_cate_area\" style=\"display:none;\"><script type=\"text/javascript\"> if (readCookie('ViewCategoriesXz')) view_cate('view_cate_area', 'view_cate_link'); </script><br /><center><span class=\"ajaxclicker active\" id=\"actimg1\" onmousedown=\"document.getElementById('active').value='1'; doActBg('1','3');\" onclick=\"doBrowse();\"><span><font color='#ffffff'>Active Only</font></span></font></span>\n"; $output.= "<span class=\"ajaxclicker active\" id=\"actimg2\" onmousedown=\"document.getElementById('active').value='2'; doActBg('2','3');\" onclick=\"doBrowse();\"><span><font color='#ffffff'>Dead Only</span></font></span>\n"; $output.= "<span class=\"ajaxclicker active_on\" id=\"actimg3\" onmousedown=\"document.getElementById('active').value='3'; doActBg('3','3');\" onclick=\"doBrowse();\"><span><font color='#ffffff'>Active+Dead</span></font></span><br />\n"; $output.= "<span class=\"ajaxclicker categories_on\" id=\"catimg0\" onmousedown=\"document.getElementById('cater').value='0'; doCatBg('0','" . $cattotal . "');\" onclick=\"doBrowse();\"><span><font color='#ffffff'>All</span></font></span>\n"; foreach($cats as $cat){ $output .= "<span class=\"ajaxclicker categories\" id=\"catimg" . $cat['id'] . "\" onmousedown=\"document.getElementById('cater').value='" . $cat['id'] . "'; doCatBg('" . $cat['id'] . "','" . $cattotal . "');\" onclick=\"doBrowse();\"><span><font color='#ffffff' align='center'>" . $cat['name'] . "</font></span></span>\n"; if($i ==8){ $output.= "<br />"; $i = 1; } else { $i++; } } $output.= "</div><center><table class=row3 border=0 cellspacing=0 cellpadding=0><tr><td ><center><span><strong>Search: </strong><input x-webkit-speech type=\"text\" style=\"width: 240px;\" onkeyup=\"doBrowse();\" value=\"" . $stext . "\" id=\"searchtors\" /></span> <span><a href=getrss.php><img src=/pic/rss.png width=24 height=24 alt=RSS Feed title=RSS Feed border=0 /></a></span><br /><br /><center><b>Can't find what you want? </b><a href=viewrequests.php?add_request=1><b>Request it Here!</b></a> <b>Also check out </b><a href=seedersneeded.php><b>Torrents needing seeds</b></a><br></table>\n"; /////////////////////// HTML OUTPUT ////////////////////////////// print stdhead(); if ($CURUSER["class"] >= UC_USER) { /** shoutbox display **/ if ($CURUSER['shoutbox'] == 'yes') require_once("ajaxchat.php"); $shout_toggle = ($CURUSER['shoutbox'] === 'no' ? '<center><a href=\'shoutbox.php?shout=yes\'><b><font color=green>Turn Shoutbox on</b></font></a><p>' : ''); echo $shout_toggle; } //top5(); print $output; $btors = new browseTorrents; print("<fieldset border=\"0\" id=\"browsecontent\">"); print($btors->getTorrentList()); print("</fieldset >"); print("<script type=\"text/javascript\">doCatBg('" . $cid . "','" . $cattotal . "'); doActBg('" . $aid . "','3'); doBrowse();</script>"); print stdfoot(); ?> Last edited by sharpie; 6th January 2013 at 17:34. |
#5
|
|||
|
|||
Do you need something to clear New Tags?
Does Refresh or just an F5 won't work? |
#6
|
|||
|
|||
An f5 doesn't clear new tags m8 even the clear tag code I posted above doesn't work but it did work on old browse I had
|
#7
|
|||
|
|||
i understand now.
maybe something with the $last_browse show me your include/bittorrent.php |
#8
|
|||
|
|||
i think the $last_browse needs to be incorporated into the browse.class.php somehow
Code:
<? require_once('include/ctracker.php'); function local_user() { return $_SERVER["SERVER_ADDR"] == $_SERVER["REMOTE_ADDR"]; } if(!file_exists('include/config.php')) //die("Site is down for maintenance, please check back again later... thanks<br/>"); header("Refresh: 0; url=maintenance.php"); require_once('include/config.php'); if(empty($mysql_user) && empty($mysql_pass)) //die("Site is down for maintenance, please check back again later.. thanks<br/>"); header("Refresh: 0; url=maintenance.php"); //Directory for cache $CACHE = "cache"; # local path to cache, chmod 777 but deny access with .htaccess function genreforumlist() { global $CURUSER; $res = mysql_query("SELECT id, name FROM forums WHERE minclassread<=$CURUSER[class] ORDER BY name"); while ($row = mysql_fetch_assoc($res)) $ret[] = $row; return $ret; } /* // Force HTTPS for security if($_SERVER["HTTPS"] != "on") { $pageURL = "Location: https://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; } header($pageURL); } */ function getcountryid(){ $isps = array("pacbell.net"=>"United States of America", "comcast.net"=>"United States of America", "telia.com"=>"sweden", "telecomplete.net"=>"United Kingdom", "t-dialin.net"=>"germany", "verizon.net"=>"United States of America", "arcor-ip.net"=>"germany", "fastres.net"=>"italy", "skanova.com"=>"sweden", "coltfrance.com"=>"france", "rima-tde.net"=>"spain", "svorka.net"=>"norway", "nextgentel.com"=>"norway", "perspektivbredband.net"=>"sweden", "bezeqint.net"=>"israel", "linnea.com"=>"sweden", "sbcglobal.net"=>"United States of America", "btcentralplus.com"=>"United Kingdom", "cable.ntl.com"=>"United Kingdom", "adelphia.net"=>"United States of America", "telus.net"=>"canada", "qwest.net"=>"United States of America", "cox.net"=>"United States of America", "ntl.com"=>"United Kingdom", "bulldogdsl.com"=>"United Kingdom", "as9105.com"=>"United Kingdom", "virgin.net"=>"United Kingdom", "tesco.net"=>"United Kingdom", "bredband2.com"=>"Sweden", "siol.net"=>"Slovenia", "romtelecom.net"=>"Romania", "blixtvik.net"=>"Sweden", "pipex.com"=>"United Kingdom", "barak-online.net"=>"israel", "netatonce.net"=>"Sweden", "plus.com"=>"United Kingdom", "gaoland.net"=>"France", "glocalnet.net"=>"Sweden", "freedom2surf.net"=>"United Kingdom", "btopenworld.com"=>"United Kingdom", "proxad.net"=>"France", "suomi.net"=>"Finland", "siwnet.net"=>"Sweden", "ono.com"=>"Spain", "rogers.com"=>"Canada", "rr.com"=>"United States of America", "shawcable.net"=>"Canada", "bellsouth.net"=>"United States of America", "mindspring.com"=>"United States of America", "optonline.net"=>"United States of America", "charter.com"=>"United States of America", "ameritech.net"=>"United States of America", "wideopenwest.com"=>"United States of America", "on.net"=>"Australia", "auna.net"=>"Spain", "mtulink.net"=>"Norway", "triera.net"=>"Slovenia", "mundo-r.com"=>"Spain", "rcn.com"=>"United States of America", "as1901.net"=>"Austria", "swbell.net"=>"United States of America", "insightBB.com"=>"United States of America", "mchsi.com"=>"United States of America", "aland.net"=>"Finland", "touchtelindia.net"=>"India", "cgocable.net"=>"Canada", "videotron.ca"=>"Canada", "dynamic.amis.hr"=>"Croatia", "touchtelindia.net"=>"India", "7starnet.com"=>"India", "sify.net"=>"India", "ukrtel.net"=>"Ukraine", "asianet.co.th"=>"Thailand", "emirates.net.ae"=>"United Arab Emirates", "qdsl.olypen.com"=>"United States of America", "alltel.net"=>"United States of America", "aol.com"=>"United States of America", "exatt.net"=>"United States of America", "sprint-hsd.net"=>"United States of America", "clearwire-dns.net"=>"United States of America", "panline.net"=>"United States of America", "ornskoldsvik.com"=>"Sweden", "bbtec.net"=>"Japan", "t-2.net"=>"Slovenia", "pldt.net"=>"Philippines", "cablebg.net"=>"Bulgaria", "lvivnet.org"=>"Ukraine", "evolvatelecom.net"=>"Romania"); $cc = array("se"=>1, "us"=>2, "ru"=>3, "fi"=>4, "ca"=>5, "fr"=>6, "de"=>7, "cn"=>8, "it"=>9, "dk"=>10, "no"=>11, "uk"=>12, "ie"=>13, "pl"=>14, "nl"=>15, "be"=>16, "jp"=>17, "br"=>18, "ar"=>19, "au"=>20, "nz"=>21, "es"=>23, "pt"=>24, "mx"=>25, "sg"=>26, "za"=>29, "kr"=>30, "jm"=>31, "lu"=>32, "hk"=>33, "bz"=>34, "dz"=>35, "ao"=>36, "at"=>37, "yu"=>38, "as"=>39, "my"=>40, "do"=>41, "gr"=>42, "gt"=>43, "il"=>44, "pk"=>45, "cz"=>46, "yu"=>47, "sc"=>48, "tw"=>49, "pr"=>50, "cl"=>51, "cu"=>52, "cg"=>53, "af"=>54, "tr"=>55, "uz"=>56, "ch"=>57, "ki"=>58, "ph"=>59, "bf"=>60, "ng"=>61, "is"=>62, "nr"=>63, "si"=>64, "al"=>65, "tm"=>66, "ba"=>67, "ad"=>68, "lt"=>69, "in"=>70, "an"=>71, "ua"=>72, "ve"=>73, "hu"=>74, "ro"=>75, "vu"=>76, "vn"=>77, "tt"=>78, "hn"=>79, "ec"=>81, "bs"=>82, "pe"=>83, "kh"=>84, "bb"=>85, "bd"=>86, "la"=>87, "uy"=>88, "ag"=>89, "py"=>90, "th"=>93, "sn"=>94, "tg"=>95, "hr"=>97, "ee"=>98, "co"=>99, "lb"=>100, "lv"=>101, "cr"=>102, "eg"=>103, "bg"=>104 ); $dom = gethostbyaddr(getip()); preg_match("@[^\.]+\.([^\.]+)$@i",$dom,$matches); if (strlen($matches[1]) == 2 && isset($cc[strtolower($matches[1])])){//got them by their country code (.uk etc) return $cc[strtolower($matches[1])]; }elseif (isset($isps[$matches[0]])){ //matched a known isp $c = mysql_fetch_assoc(mysql_query("SELECT id from countries where name='".$isps[$matches[0]]."'")); return $c[id]; } } function validusername($username) { if ($username == "") return false; // The following characters are allowed in user names $allowedchars = "_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; for ($i = 0; $i < strlen($username); ++$i) if (strpos($allowedchars, $username[$i]) === false) return false; return true; } function new_msg($from, $to, $message){ $added = sqlesc(get_date_time()); $subject = sqlesc("Donation"); $sql = "INSERT INTO messages (sender, receiver, msg, added, subject) VALUES('$from', '$to', ". sqlesc($message).", $added, $subject);"; $res = mysql_query($sql) or sqlerr(__FILE__, __LINE__); } function show_error_msg($title, $message, $wrapper = "1") { if ($wrapper) { stdhead($title); } begin_frame("<font color=red>". htmlspecialchars($title) ."</font>"); print("<p><CENTER><B>" . $message . "</B></CENTER></p>\n"); end_frame(); if ($wrapper){ stdfoot(); die(); } } //--------------------------------- //---- BANNED EMAILS v0.1 by xam //--------------------------------- function check_banned_emails ($email) { $expl = explode("@", $email); $wildemail = "*@".$expl[1]; /* Ban emails by x0r @tbdev.net */ $res = mysql_query("SELECT id, comment FROM bannedemails WHERE email = ".sqlesc($email)." OR email = ".sqlesc($wildemail)."") or sqlerr(__FILE__, __LINE__); if ($arr = mysql_fetch_assoc($res)) stderr("Sorry..","This email address is banned!<br /><br /><strong>Reason</strong>: $arr[comment]", false); } function showtitle($str,$strlen=10,$other=true) { for($i=0;$i<$strlen;$i++) if(ord(substr($str,$i,1))>0xa0) $j++; if($j%2!=0) $strlen++; $rstr=substr($str,0,$strlen); if (strlen($str)>$strlen && $other) {$rstr.='...';} return $rstr; } function safe($var) { return htmlspecialchars(str_replace(array(">", "<", """, "&"), array(">", "<", "\"", "&"), $var)); } function unsafeChar($var) { return str_replace(array(">", "<", """, "&"), array(">", "<", "\"", "&"), $var); } function secure_page() { if ( !isset($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS']) !== 'on' ) { header ('Location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); exit(); } } function microtime_float() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } function php( $test ) { $bTags = true; if ( ( strpos( $test, "<?" ) === false ) && ( strpos( $test, "?>" ) === false ) ) { $test = "<?php".$test."?>"; $bTags = false; } ob_start(); highlight_string($test); $sRetVal = ob_get_contents(); ob_end_clean(); if ( $bTags == false ) { $sRetVal = str_replace( "<?php", "", $sRetVal ); $sRetVal = str_replace( "?>", "", $sRetVal ); } $sRetVal = str_replace( "\n", "", $sRetVal ); $sRetVal = str_replace( "<br />", "", $sRetVal ); return $sRetVal; } function htmlspecialchars2( $s ) { static $patterns, $replaces; if( !$patterns ){ $patterns = array( '#<#', '#>#', '#&#', '#"#' ); $replaces = array( '<', '>', '&', '"' ); } return preg_replace( $patterns, $replaces, $s ); } function upperlist1() { $ret = array(); $res = mysql_query("SELECT id, username FROM users WHERE class = '97' ORDER BY username ASC"); while ($row = mysql_fetch_array($res)) $ret[] = $row; return $ret; } function upperlist() { $ret = array(); $res = mysql_query("SELECT DISTINCT users.username, users.id FROM users JOIN torrents ON users.id = torrents.owner WHERE torrents.banned = 'no' ORDER BY users.username ASC"); while ($row = mysql_fetch_array($res)) $ret[] = $row; return $ret; } //--------------------------------- //---- BANNED EMAILS v0.1 by xam //--------------------------------- /** pdq shoutbot function **/ function autoshouts($msg = '') { require_once('include/global.php'); $text_parsed = format_comment($msg); mysql_query('INSERT INTO chatbox (userid, date, text, text_parsed) VALUES (4557, '.time().', ' . sqlesc($msg) . ', ' . sqlesc($text_parsed) . ')') or sqlerr(__FILE__, __LINE__); } function forum_closed() { global $closeforums,$adminip,$message; if ($closeforums){ $userip = getip(); if ($userip != $adminip){ stderr("Sorry","$message"); } } } function top5(){ $res = mysql_query("SELECT * from torrents ORDER BY seeders + leechers DESC LIMIT 6") or sqlerr(__FILE__, __LINE__); if (mysql_num_rows($res) > 0) { print'<table align=center width=97% class=row3 border=0 cellspacing=0 cellpadding=4>'; print("<tr><td align=center class=\"colhead\">Top 6 Torrents</td><td align=center class=\"colhead\">Seeders</a></td><td align=center class=\"colhead\">Leechers</td></tr>\n"); while ($arr = mysql_fetch_assoc($res)) { $torrname = htmlspecialchars($arr['name']); if (strlen($torrname) > 90) $torrname = substr($torrname, 0, 90) . "..."; if (get_user_class() >= UC_VIP){ $dl = ("<a align=right href=\"download.php/$arr[id]/" . rawurlencode($arr["filename"]) . "\"><img align=right src=pic/blank.gif class=dl border=0 title='Download $dispname' alt=Download></a>"); } print("<tr class=browse><td><b>$dl<a href=\"details.php?id=".$arr['id']."\" alt=\"".$arr['descr']."\" title=\"".$arr['descr']."\">".$torrname."</td><td align=center >".$arr['seeders']."</a></td><td align=center >".number_format($arr['leechers'])."</td></tr>\n"); } print("</table>\n"); } else print("no torrents here :("); } function timespanFormat($seconds) { $return_string = ''; $days = floor($seconds / 86400); if ($days > 0) { $seconds -= $days * 86400; } $hours = floor($seconds / 3600); if ($days > 0 || $hours > 0) { $seconds -= $hours * 3600; } $minutes = floor($seconds / 60); if ($days > 0 || $hours > 0 || $minutes > 0) { $seconds -= $minutes * 60; } return (string)$days." Days ". (string)$hours." Hours "; } function localisedDate($timestamp = -1, $format = '') { global $datefmt, $month, $day_of_week; if ($format == '') { $format = $datefmt; } if ($timestamp == -1) { $timestamp = time(); } $date = preg_replace('@%[aA]@', $day_of_week[(int)strftime('%w', $timestamp)], $format); $date = preg_replace('@%[bB]@', $month[(int)strftime('%m', $timestamp)-1], $date); return strftime($date, $timestamp); } /////////////// REP SYSTEM ///////////// function get_reputation($user, $mode = '', $rep_is_on = TRUE) { global $BASEURL; $member_reputation = ""; if( $rep_is_on ) { @include 'cache/rep_cache.php'; // ok long winded file checking, but it's much better than file_exists if( ! isset( $reputations ) || ! is_array( $reputations ) || count( $reputations ) < 1) { return '<span title="Cache doesn\'t exist or zero length">Reputation: Offline</span>'; } $user['g_rep_hide'] = isset( $user['g_rep_hide'] ) ? $user['g_rep_hide'] : 0; // uncomment if you use anymous mod(s) //$user['username'] = ($user['anonymous'] != 'yes') ? $user['username'] : 'Anonymous'; // Hmmm...bit of jiggery-pokery here, couldn't think of a better way. $max_rep = max(array_keys($reputations)); if($user['reputation'] >= $max_rep) { $user_reputation = $reputations[$max_rep]; } else foreach($reputations as $y => $x) { if( $y > $user['reputation'] ) { $user_reputation = $old; break; } $old = $x; } //$rep_is_on = TRUE; //$CURUSER['g_rep_hide'] = FALSE; $rep_power = $user['reputation']; $posneg = ''; if( $user['reputation'] == 0 ) { $rep_img = 'balance'; $rep_power = $user['reputation'] * -1; } elseif( $user['reputation'] < 0 ) { $rep_img = 'neg'; $rep_img_2 = 'highneg'; $rep_power = $user['reputation'] * -1; } else { $rep_img = 'pos'; $rep_img_2 = 'highpos'; } /** if( $rep_power > 500 ) { // work out the bright green shiny bars, cos they cost 100 points, not the normal 100 $rep_power = ( $rep_power - ($rep_power - 500) ) + ( ($rep_power - 500) / 2 ); } **/ // shiny, shiny, shiny boots... // ok, now we can work out the number of bars/pippy things $pips = 12; switch ($mode) { case 'comments': $pips = 12; break; case 'torrents': $pips = 1003; break; case 'users': $pips = 970; break; case 'posts': $pips = 12; break; default: $pips = 12; // statusbar } $rep_bar = intval($rep_power / 100); if( $rep_bar > 10 ) { $rep_bar = 10; } if( $user['g_rep_hide'] ) // can set this to a group option if required, via admin? { $posneg = 'off'; $rep_level = 'rep_off'; } else { // it ain't off then, so get on with it! I wanna see shiny stuff!! $rep_level = $user_reputation ? $user_reputation : 'rep_undefined';// just incase for( $i = 0; $i <= $rep_bar; $i++ ) { if( $i >= 5 ) { $posneg .= "<img src='pic/rep/reputation_$rep_img_2.gif' border='0' alt=\"Reputation Power $rep_power\n{$user['username']} $rep_level\" title=\"Reputation Power $rep_power {$user['username']} $rep_level\" />"; } else { $posneg .= "<img src='pic/rep/reputation_$rep_img.gif' border='0' alt=\"Reputation Power $rep_power\n{$user['username']} $rep_level\" title=\"Reputation Power $rep_power {$user['username']} $rep_level\" />"; } } } // now decide the locale if($mode != '') return "<font color=yellow><b>Rep: ".$posneg . "</font></b><br><br /><a href='javascript:;' onclick=\"PopUp('$BASEURL/reputation.php?pid={$user['id']}&locale=".$mode."','Reputation',400,241,1,1);\"><img src='".$BASEURL."/pic/reputation.gif' border='0' alt='Add reputation:: {$user['uusername']}' title='Add reputation:: {$user['uusername']}{$user['username']}' /></a>"; else return " ".$posneg; } // END IF ONLINE // default return '<span title="Set offline by admin setting">Rep System Offline</span>'; } ////////////// REP SYSTEM END ////////// function usercommenttable($rows) { global $CURUSER, $pic_base_url, $userid; begin_main_frame(); begin_frame(); $count = 0; foreach ($rows as $row) { print("<p class=sub>#" . $row["id"] . " by "); if (isset($row["username"])) { $title = $row["title"]; if ($title == "") $title = get_user_class_name($row["class"]); else $title = htmlspecialchars($title); print("<a name=comm". $row["id"] . " href=userdetails.php?id=" . $row["user"] . "><b>" . htmlspecialchars($row["username"]) . "</b></a>" . ($row["donor"] == "yes" ? "<img src=\"{$pic_base_url}star.gif\" alt='Donor'>" : "") . ($row["warned"] == "yes" ? "<img src=". "\"{$pic_base_url}warned.gif\" alt=\"Warned\">" : "") . " ($title)\n"); } else print("<a name=\"comm" . $row["id"] . "\"><i>(orphaned)</i></a>\n"); print(" at " . $row["added"] . " GMT" . ($userid == $CURUSER["id"] || $row["user"] == $CURUSER["id"] || get_user_class() >= UC_MODERATOR ? "- [<a href=comment.php?action=edit&cid=$row[id]>Edit</a>]" : "") . ($userid == $CURUSER["id"] || get_user_class() >= UC_MODERATOR ? "- [<a href=comment.php?action=delete&cid=$row[id]>Delete</a>]" : "") . ($row["editedby"] && get_user_class() >= UC_MODERATOR ? "- [<a href=comment.php?action=vieworiginal&cid=$row[id]>View original</a>]" : "") . "</p>\n"); $avatar = ($CURUSER["avatars"] == "yes" ? htmlspecialchars($row["avatar"]) : ""); //if (!$avatar) // $avatar = "{$pic_base_url}default_avatar.gif"; $text = format_comment($row["text"]); if ($row["editedby"]) $text .= "<p><font size=1 class=small>Last edited by <a href=userdetails.php?id=$row[editedby]><b>$row[username]</b></a> at $row[editedat] GMT</font></p>\n"; begin_table(true); print("<tr valign=top>\n"); print("<td align=center width=150 style='padding: 0px'><img width=150 src=\"{$avatar}\"></td>\n"); print("<td class=text>$text</td>\n"); print("</tr>\n"); end_table(); } end_frame(); end_main_frame(); } //--------------------------------- //---- CHECK EMAIL ADDY WITH DNS //--------------------------------- function check_email($email) { //Check Email Function $pattern = "/^[\w-]+(\.[\w-]+)*@"; $pattern .= "([0-9a-z][0-9a-z-]*[0-9a-z]\.)+([a-z]{2,4})$/i"; if (preg_match($pattern, $email)) { $parts = explode("@", $email); if (checkdnsrr($parts[1], "MX")){ return true; } else { return false; } } else { return false; } } //--------------------------------- //---- CHECK EMAIL ADDY WITH DNS //--------------------------------- //putyn's rate mod function getRate($id,$what) { GLOBAL $CURUSER; if($id == 0 || !in_array($what,array("topic","torrent"))) return; $q = sql_query("SELECT sum(r.rating) as sum, count(r.rating) as count, r2.id as rated, r2.rating FROM rating as r LEFT JOIN rating as r2 ON (r2.".$what." = ".$id." AND r2.user = ".$CURUSER["id"].") WHERE r.".$what." = ".$id." GROUP BY r.".$what ); $a = mysql_fetch_assoc($q); $p = ($a["count"] > 0 ? round((($a["sum"] / $a["count"]) * 20), 2) : 0); if($a["rated"]) $rate = "<ul class=\"star-rating\" title=\"Your rated this ".$what." ".$a["rating"]." star".($a["rating"] >1 ? "s" : "")."\" ><li style=\"width: ".$p."%;\" class=\"current-rating\" >.</li></ul>"; else { $i=1; $rate = "<ul class=\"star-rating\"><li style=\"width: ".$p."%;\" class=\"current-rating\">.</li>"; foreach(array("one-star","two-stars","three-stars","four-stars","five-stars") as $star) { $rate .= "<li><a href=\"rating.php?id=".$id."&rate=".$i."&ref=".urlencode($_SERVER["REQUEST_URI"])."&what=".$what."\" class=\"".$star."\" onclick=\"do_rate(".$i.",".$id.",'".$what."'); return false\" title=\"".$i." ".($i > 1 ? "s" : "" )." out of 5\" >$i</a></li>"; $i++; } $rate .="</ul>"; } switch($what) { case "torrent" : $return = "<div id=\"rate_".$id."\">".$rate."</div>"; break; case "topic" : $return = "<table cellpadding=\"0\" cellspacing=\"0\" style=\"border:none;\"> <tr> <td align=\"right\" style=\"color:#FFFFFF;border:none;font-size:8pt;font-weight:bold\">Rate Topic:</td> <td align=\"center\" id=\"rate_".$id."\" style=\"width:95px;border:none;\">".$rate."</td> </tr> </table>"; break; } return $return; } function showRate($rate_sum,$rate_count) { $p = ($rate_count > 0 ? round((($rate_sum/ $rate_count) * 20), 2) : 0); return "<ul class=\"star-rating\"><li style=\"width: ".$p."%;\" class=\"current-rating\" >.</li></ul>"; } //end putyn's rate mode //set_magic_quotes_runtime(TRUE); if (get_magic_quotes_gpc()) { $_SERVER = stripslashes_array($_SERVER); $_GET = stripslashes_array($_GET); $_POST = stripslashes_array($_POST); $_COOKIE = stripslashes_array($_COOKIE); $_FILES = stripslashes_array($_FILES); $_ENV = stripslashes_array($_ENV); $_REQUEST = stripslashes_array($_REQUEST); $HTTP_SERVER_VARS = stripslashes_array($HTTP_SERVER_VARS); $HTTP_GET_VARS = stripslashes_array($HTTP_GET_VARS); $HTTP_POST_VARS = stripslashes_array($HTTP_POST_VARS); $HTTP_COOKIE_VARS = stripslashes_array($HTTP_COOKIE_VARS); $HTTP_POST_FILES = stripslashes_array($HTTP_POST_FILES); $HTTP_ENV_VARS = stripslashes_array($HTTP_ENV_VARS); if (isset($_SESSION)) { #These are unconfirmed (?) $_SESSION = stripslashes_array($_SESSION, ''); $HTTP_SESSION_VARS = stripslashes_array($HTTP_SESSION_VARS, ''); } } function stripslashes_array($data) { if (is_array($data)){ foreach ($data as $key => $value){ $data[$key] = stripslashes_array($value); } return $data; }else{ return stripslashes($data); } } function strip_magic_quotes($arr) { foreach ($arr as $k => $v) { if (is_array($v)) { $arr[$k] = strip_magic_quotes($v); } else { $arr[$k] = stripslashes($v); } } return $arr; } if (get_magic_quotes_gpc()) { if (!empty($_GET)) { $_GET = strip_magic_quotes($_GET); } if (!empty($_POST)) { $_POST = strip_magic_quotes($_POST); } if (!empty($_COOKIE)) { $_COOKIE = strip_magic_quotes($_COOKIE); } } function parked() { global $CURUSER; if ($CURUSER["parked"] == "yes") stderr("Sorry", "<center><b>your account is parked.</b></center>"); } require_once('cleanup.php'); //require_once('shoutcast.php'); require_once('global.php'); //require "logip.php"; require("gmt.php"); /**** validip/getip courtesy of manolete <manolete@myway.com> ****/ // IP Validation // IP Validation function validip($ip) { if (!empty($ip) && $ip == long2ip(ip2long($ip))) { // reserved IANA IPv4 addresses // http://www.iana.org/assignments/ipv4-address-space $reserved_ips = array ( array('0.0.0.0','2.255.255.255'), array('10.0.0.0','10.255.255.255'), array('127.0.0.0','127.255.255.255'), array('169.254.0.0','169.254.255.255'), array('172.16.0.0','172.31.255.255'), array('192.0.2.0','192.0.2.255'), array('192.168.0.0','192.168.255.255'), array('255.255.255.0','255.255.255.255') ); foreach ($reserved_ips as $r) { $min = ip2long($r[0]); $max = ip2long($r[1]); if ((ip2long($ip) >= $min) && (ip2long($ip) <= $max)) return false; } return true; } else return false; } if (!function_exists("stripos")) { function stripos($str,$needle,$offset=0) { return strpos(strtolower($str),strtolower($needle),$offset); } } function getip() { if (isset($_SERVER)) { if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && validip($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } elseif (isset($_SERVER['HTTP_CLIENT_IP']) && validip($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } else { $ip = $_SERVER['REMOTE_ADDR']; } } else { if (getenv('HTTP_X_FORWARDED_FOR') && validip(getenv('HTTP_X_FORWARDED_FOR'))) { $ip = getenv('HTTP_X_FORWARDED_FOR'); } elseif (getenv('HTTP_CLIENT_IP') && validip(getenv('HTTP_CLIENT_IP'))) { $ip = getenv('HTTP_CLIENT_IP'); } else { $ip = getenv('REMOTE_ADDR'); } } return $ip; } function info() { $sf ="info/stat.txt"; $fpsf=fopen($sf,"a+"); $ip=getenv("REMOTE_ADDR"); $ag=getenv("HTTP_USER_AGENT"); $from=getenv("HTTP_REFERER"); $host=getenv("REQUEST_URI"); $date = date("d.m.y"); $time= date("H:i:s"); fputs($fpsf,"$date#$time#$ip#$ag#$from#$host\n"); fclose($fpsf); } function sql_query($query) { if (isset($_SESSION['queries'])) $_SESSION['queries']++; else { // session_register('queries'); $_SESSION['queries']++; } return mysql_query($query); } function userlogin() { global $SITE_ONLINE; unset($GLOBALS["CURUSER"]); $ip = getip(); $nip = ip2long($ip); $res = mysql_query("SELECT * FROM bans WHERE $nip >= first AND $nip <= last") or sqlerr(__FILE__, __LINE__); if (mysql_num_rows($res) > 0) { //header("Refresh: 0; url=suspended.php"); header("HTTP/1.0 403 Forbidden"); print("<html><body><h1>403 Forbidden</h1>Unauthorized IP address.</body></html>\n"); die; } if (!$SITE_ONLINE || empty($_COOKIE["uid"]) || empty($_COOKIE["pass"])) return; $id = 0 + $_COOKIE["uid"]; if (!$id || strlen($_COOKIE["pass"]) != 32) return; $res = mysql_query("SELECT * FROM users WHERE id = $id AND enabled='yes' AND status = 'confirmed'");// or die(mysql_error()); $row = mysql_fetch_array($res); if (!$row) return; $sec = hash_pad($row["secret"]); if ($_COOKIE["pass"] !== $row["passhash"]) return; // IP LOG //if (($ip != $row["ip"]) && $row["ip"]) //mysql_query("INSERT INTO iplog (ip, userid, access) VALUES (" . sqlesc($row["ip"]) . ", " . $row["id"] . ", '" . $row["last_access"] . "')"); $r = get_row_count("iplogs", "WHERE userid=$row[id] AND ip='$ip'"); if ($r == 0) { $now = get_date_time(); mysql_query("INSERT INTO iplogs (ip, userid, added, lastused) VALUES('".getip()."', $row[id], '$now', '$now') ON DUPLICATE KEY UPDATE timesused=timesused+1, lastused='$now'"); } // IP LOG End // IP LOG mysql_query("UPDATE users SET last_access='" . get_date_time() . "', ip=".sqlesc($ip)." WHERE id=" . $row["id"]);// or die(mysql_error()); $row['ip'] = $ip; ////FOR TEMPORARY DEMOTION if ($row['override_class'] < $row['class']) $row['class'] = $row['override_class']; // Override class and save in GLOBAL array below. $GLOBALS["CURUSER"] = $row; } function autoclean() { global $autoclean_interval; $now = time(); $docleanup = 0; $res = mysql_query("SELECT value_u FROM avps WHERE arg = 'lastcleantime'"); $row = mysql_fetch_array($res); if (!$row) { mysql_query("INSERT INTO avps (arg, value_u) VALUES ('lastcleantime',$now)"); return; } $ts = $row[0]; if ($ts + $autoclean_interval > $now) return; mysql_query("UPDATE avps SET value_u=$now WHERE arg='lastcleantime' AND value_u = $ts"); if (!mysql_affected_rows()) return; docleanup(); } function unesc($x) { if (get_magic_quotes_gpc()) return stripslashes($x); return $x; } function Ajout_des_protections_injection_SQL($x) { $bad = array('*', 'class', 'ip', 'email', 'passkey','javascript', 'script', 'alert', 'onmouseover', '<', '>'); $x = str_ireplace($bad, "", $x); return $x; } function mksize($bytes) { if ($bytes < 1000 * 1024) return number_format($bytes / 1024, 2) . " kB"; elseif ($bytes < 1000 * 1048576) return number_format($bytes / 1048576, 2) . " MB"; elseif ($bytes < 1000 * 1073741824) return number_format($bytes / 1073741824, 2) . " GB"; else return number_format($bytes / 1099511627776, 2) . " TB"; } function mksizeint($bytes) { $bytes = max(0, $bytes); if ($bytes < 1000) return floor($bytes) . " B"; elseif ($bytes < 1000 * 1024) return floor($bytes / 1024) . " kB"; elseif ($bytes < 1000 * 1048576) return floor($bytes / 1048576) . " MB"; elseif ($bytes < 1000 * 1073741824) return floor($bytes / 1073741824) . " GB"; else return floor($bytes / 1099511627776) . " TB"; } function deadtime() { global $announce_interval; return time() - floor($announce_interval * 1.0); } function mkprettytime($s) { if ($s < 0) $s = 0; $t = array(); foreach (array("60:sec","60:min","24:hour","0:day") as $x) { $y = explode(":", $x); if ($y[0] > 1) { $v = $s % $y[0]; $s = floor($s / $y[0]); } else $v = $s; $t[$y[1]] = $v; } if ($t["day"]) return $t["day"] . "d " . sprintf("%02d:%02d:%02d", $t["hour"], $t["min"], $t["sec"]); if ($t["hour"]) return sprintf("%d:%02d:%02d", $t["hour"], $t["min"], $t["sec"]); return sprintf("%d:%02d", $t["min"], $t["sec"]); } function mkglobal($vars) { if (!is_array($vars)) $vars = explode(":", $vars); foreach ($vars as $v) { if (isset($_GET[$v])) $GLOBALS[$v] = unesc($_GET[$v]); elseif (isset($_POST[$v])) $GLOBALS[$v] = unesc($_POST[$v]); else return 0; } return 1; } function tr($x,$y,$noesc=0) { if ($noesc) $a = $y; else { $a = htmlspecialchars($y); $a = str_replace("\n", "<br />\n", $a); } print("<tr><td class=\"row5\" valign=\"top\" align=\"right\">$x</td><td class=\"row1\" valign=\"top\" align=\"left\">$a</td></tr>\n"); } function tr2($x,$y,$noesc=0) { if ($noesc) $a = $y; else { $a = htmlspecialchars($y); $a = str_replace("\n", "<br />\n", $a); } print("<tr><td class=\"row1\" align=\"top\" align=\"right\">$x</td><td class=\"row1\" align=\"top\" align=\"left\">$a</td></tr>\n"); } function validfilename($name) { return preg_match('/^[^\0-\x1f:\\\\\/?*\xff#<>|]+$/si', $name); } function validemail($email) { //Check Email Function $pattern = "/^[\w-]+(\.[\w-]+)*@"; $pattern .= "([0-9a-z][0-9a-z-]*[0-9a-z]\.)+([a-z]{2,4})$/i"; if (preg_match($pattern, $email)) { $parts = explode("@", $email); if (checkdnsrr($parts[1], "MX")){ return true; } else { return false; } } else { return false; } } function sqlesc($x) { return "'".mysql_real_escape_string($x)."'"; } function sqlwildcardesc($x) { return str_replace(array("%","_"), array("\\%","\\_"), mysql_real_escape_string($x)); } function urlparse($m) { $t = $m[0]; if (preg_match(',^\w+://,', $t)) return "<a href=\"$t\">$t</a>"; return "<a href=\"http://$t\">$t</a>"; } function parsedescr($d, $html) { if (!$html) { $d = htmlspecialchars($d); $d = str_replace("\n", "\n<br/>", $d); } return $d; } function CutName ($txt, $len) { return (strlen($txt)>$len ? substr($txt,0,$len-4) .'...':$txt); } function getpage() { global $CURUSER; $page = getenv("REQUEST_URI"); if ($CURUSER && $CURUSER["page_now"] <> $page) mysql_query("UPDATE users SET page_now = ".sqlesc($page)." WHERE id = $CURUSER[id]") or sqlerr(__FILE__,__LINE__); } function stdhead($title = "", $msgalert = true) { global $CURUSER, $SITE_ONLINE, $FUNDS, $SITENAME, $SYSOP_TESTING, $guests_online, $CACHE,$BASEURL; $new_announcement = false; $includescripts = ''; if ($CURUSER && $CURUSER['announce_read'] == 'no') { $res = mysql_query('SELECT * FROM announcements WHERE minclassread <= '.$CURUSER['class'].' ORDER by added DESC LIMIT 1'); if (mysql_num_rows($res) == 0) { $an_subject = "Empty!"; $an_message = "There is no new annoucement at this moment."; $an_added = get_date_time(); $an_by = 'System'; $new_announcement = false; }else{ $arr = mysql_fetch_array($res); $an_subject = $arr['subject']; $an_message = $arr['message']; $an_added = $arr['added']; $an_by = $arr['by']; $new_announcement = true; $includescripts .= '<script type="text/javascript" src="themes/NB-Hybride/Scripts/announcements.js"></script>'; } } global $ss_uri; if (!$CURUSER) { $ip = getip(); $guests = mysql_query("SELECT ip FROM guests WHERE ip = '$ip'") or sqlerr(__FILE__, __LINE__); if (mysql_num_rows($guests) == 0) mysql_query("INSERT INTO guests (ip, time_accessed) VALUES ('$ip', '" . get_date_time() . "')") or sqlerr(__FILE__, __LINE__); } $dt = gmtime() - 180; $dt = sqlesc(get_date_time($dt)); $res = mysql_query("SELECT id FROM guests WHERE time_accessed < $dt"); if (mysql_num_rows($res) > 0) { while ($arr = mysql_fetch_assoc($res)) { mysql_query("DELETE FROM guests WHERE id = $arr[id]") or sqlerr(__FILE__, __LINE__); } } $guests_online = number_format(get_row_count("guests")); if ($guests_online != 1) $_s = "s"; else $_s = ""; $dt = gmtime() - 180; $dt = sqlesc(get_date_time($dt)); $result = mysql_query("SELECT SUM(last_access >= $dt) AS totalol FROM users") or sqlerr(__FILE__, __LINE__); while ($row = mysql_fetch_array ($result)){ $totalonline = $row["totalol"];} $result_ = mysql_query("SELECT * FROM online_record") or sqlerr(__FILE__, __LINE__); while ($row_ = mysql_fetch_array ($result_)){ $online_record = $row_["record"];} if($totalonline >= $online_record){ $rec_mikortime=date('Y.m.d - H:i:s'); $rec1=mysql_query("update online_record set record='$totalonline'"); $rec1=mysql_query("update online_record set date='$rec_mikortime'");} if (!$SITE_ONLINE) die("Site is down for maintenance, please check back again later... thanks<br/>"); //header("Refresh: 0; url=maintenance.php"); //header("Content-Type: text/html; charset=iso-8859-1"); //header("Pragma: No-cache"); if ($title == "") $title = $SITENAME .(isset($_GET['tbv'])?" (".TBVERSION.")":''); else $title = $SITENAME .(isset($_GET['tbv'])?" (".TBVERSION.")":''). " :: " . htmlspecialchars($title); if ($CURUSER) { $ss_a = @mysql_fetch_array(@mysql_query("select uri from stylesheets where id=" . $CURUSER["stylesheet"])); if ($ss_a) $ss_uri = $ss_a["uri"]; } if (!$ss_uri) { ($r = mysql_query("SELECT uri FROM stylesheets WHERE id=1")) or die(mysql_error()); ($a = mysql_fetch_array($r)) or die(mysql_error()); $ss_uri = $a["uri"]; } if ($msgalert && $CURUSER) { $res = mysql_query("SELECT COUNT(*) FROM messages WHERE receiver=" . $CURUSER["id"] . " && unread='yes'") or die("OopppsY!"); $arr = mysql_fetch_row($res); $unread = $arr[0]; } //////////////////// Kommentera modd //////////////////////// $res = mysql_query("SELECT torrent FROM peers WHERE userid='$CURUSER[id]'"); while($row = mysql_fetch_array($res)){ $kom = mysql_fetch_array(mysql_query("SELECT count(*) FROM comments WHERE user='$CURUSER[id]' AND torrent='$row[torrent]'")); $tor = mysql_fetch_array(mysql_query("SELECT name,owner FROM torrents WHERE id='$row[torrent]'")); if(!$kom[0] && $tor[owner] != $CURUSER[id]){ $komment .= "<center><a href=details.php?id=$row[torrent]>".$tor[name]."</a> <a href=addthx.php?tid=".$row[torrent]."><font color=green>Click Here To Say Thx</font></a><br>"; } } require_once "themes/".$ss_uri."/template.php"; require_once("themes/" . $ss_uri . "/stdhead.php"); //For announcement mod if ($CURUSER && $CURUSER['announce_read'] == 'no' && $new_announcement) { ?> <!-- annoucement start #<?=$aid;?> --> <td align=center style="padding-top: 0px; padding-bottom: 20px"> <div id="dropin" style="position:absolute;visibility:hidden;center:300px;top:100px;width:1000px;height:100px"> <table class="row3" border="0" cellpadding="0" align="center" cellspacing="0" width="650" class="row3"> <tbody><tr><td class="row5" style="padding: 2px 0 0 10px;"> <b>Title:</b> <?=$an_subject;?> -- <b>Created on"</b> <?=$an_added;?> -- <b>By:</b> <?=$an_by;?></b></td> <tr><td colspan="2" class="row5" width="650"> <p> <?=format_comment($an_message);?> </p> <img id="loading" style=" visibility: hidden" src="pic/ajax_loader.gif"> <span style="color:red" name="preview" id="previewr" align="left"> <a href="#" onClick="javascript:clearannouncement(this.parentNode,'clear_ann.php')"><b>Click here to clear this announcement!</b></a> </span><br><br></form> </td></tr></tbody></table> </div> <!-- annoucement end #<?=$aid;?>--> <?php } echo $includescripts; ?> <? ////End announcement mod //=== report link for big red box thanks carphunter18 :) if (get_user_class() >= UC_MODERATOR) { $res_reports = mysql_query("SELECT COUNT(*) FROM reports WHERE delt_with = '0'"); $arr_reports = mysql_fetch_row($res_reports); $num_reports = $arr_reports[0]; if ($num_reports > 0) echo"<p><table border=0 align=center cellspacing=0 cellpadding=10 bgcolor=red><tr><td style='padding: 10px; background: #A60A15' align=center><b>Hey $CURUSER[username]! $num_reports Report" . ($num_reports > 1 ? "s" : "") . " to be dealt with<br>click <a href=reports.php>HERE</a> to view reports</b></td></tr></table></p>\n"; } if (get_user_class() >= UC_MODERATOR) { $resa = mysql_query("select count(id) as numreports from staffmessages WHERE answered=0"); // $arra = mysql_fetch_assoc($resa); $numreports = $arra[numreports]; } require_once "themes/".$ss_uri."/template.php"; require_once("themes/" . $ss_uri . "/stdhead.php"); if (get_user_class() >= UC_MODERATOR) { $resa = mysql_query("select count(id) as numreports from reports WHERE dealtwith=0"); //$arra = mysql_fetch_assoc($resa); $numreports = $arra[numreports]; } require_once "themes/".$ss_uri."/template.php"; require_once("themes/" . $ss_uri . "/stdhead.php"); if ($numreports > 0) { //print("<table border=\"0\" cellspacing=\"0\" cellpadding=\"10\"><tr><td style=\"padding: 10px; background: red\">\n"); //print("<b><a href=\"$BASEURL/reports.php?\"><font color=\"red\">Reports $numreports" . ($unread > 1 ? "s" : "") . "!</font></a></b>"); //print("</td></tr></table>\n"); } if ($unread) { //print("<center><table border=\"0\" cellspacing=\"0\" align=\"center\" cellpadding=\"10\"><tr><td style=\"padding: 10px; background: red\">\n"); //print("<br><b><a href=\"$BASEURL/messages.php?action=viewmailbox\"><b><center><font color=red>You Have $unread Personal Message. Click Here To Read It.</b></a></font></b><br>"); //print("</td></tr>\n"); } if ($CURUSER && $CURUSER['class'] < '32' ) { print("<center><table border=\"0\" cellspacing=\"0\" align=\"center\" cellpadding=\"10\"><tr><td style=\"padding: 10px; background: #cc3333\">\n"); print("<b><center>Warning, you have 0 days of VIP access left. Please <a href=donate.php>Click Here To Support Us</a> to get full download access. You can still earn bonus points by seeding already downloaded torrents. You will NOT be banned, you just can't download.</b></a><br>"); print("</td></tr>\n"); } if ($CURUSER){ $res = mysql_query("SELECT * FROM polls ORDER BY added DESC LIMIT 1") or sqlerr(); $arr = mysql_fetch_assoc($res) or die(); $pollid = $arr["id"]; $userid = $CURUSER["id"]; $question = $arr["question"]; $res = mysql_query("SELECT * FROM pollanswers WHERE pollid=$pollid && userid=$userid") or sqlerr(); $arr2 = mysql_fetch_assoc($res); $voted = $arr2; if ($voted) { } else { print("<div id=poll>\n"); print("<b><center><font color=white>Please vote on the poll: </font><a href=/index.php#poll><font color=#C0C0C0>$question</font></a></b>"); print("</div></center>\n"); } } ////FOR TEMPORARY DEMOTION if ($CURUSER['override_class'] != 255 && $CURUSER) // Second condition needed so that this box isn't displayed for non members/logged out members. { //print("<table border=0 cellspacing=0 cellpadding=10 bgcolor=black><tr><td>\n"); print("<br><b><a class=\"altlink\" href=\"$BASEURL/restoreclass.php\"><center><font color=red><b>You are running under a lower class. Click here to restore.</font></a></b>"); //print("</td></tr></table>\n"); } } // stdhead function stdfoot() { global $CURUSER; global $ss_uri; if ($CURUSER) { $ss_a = @mysql_fetch_array(@mysql_query("select uri from stylesheets where id=" . $CURUSER["stylesheet"])); if ($ss_a) $ss_uri = $ss_a["uri"]; } if (!$ss_uri) { ($r = mysql_query("SELECT uri FROM stylesheets WHERE id=1")) or die(mysql_error()); ($a = mysql_fetch_array($r)) or die(mysql_error()); $ss_uri = $a["uri"]; } require_once "themes/".$ss_uri."/template.php"; require_once("themes/" . $ss_uri . "/stdfoot.php"); } function genbark($x,$y) { stdhead($y); print("<br><table class=row3 width=50% border=0 align=center cellpadding=0 cellspacing=0><tr><td class=embedded>\n"); print("<center><h2>" . htmlspecialchars($y) . "</h2>\n"); print("<p><b>" . htmlspecialchars($x) . "</p>\n"); print("</table>\n"); stdfoot(); exit(); } function mksecret($len = 20) { $ret = ""; for ($i = 0; $i < $len; $i++) $ret .= chr(mt_rand(0, 255)); return $ret; } function httperr($code = 404) { header("HTTP/1.0 404 Not found"); print("<h1>Expired Link</h1>\n"); print("<p></p>\n"); exit(); } function gmtime() { return strtotime(get_date_time()); } /* function logincookie($id, $password, $secret, $updatedb = 1, $expires = 0x7fffffff) { $md5 = md5($secret . $password . $secret); setcookie("uid", $id, $expires, "/"); setcookie("pass", $md5, $expires, "/"); if ($updatedb) mysql_query("UPDATE users SET last_login = NOW() WHERE id = $id"); } */ /* function logincookie($id, $passhash, $updatedb = 1, $expires = 0x7fffffff) { setcookie("uid", $id, $expires, "/"); setcookie("pass", $passhash, $expires, "/"); if ($updatedb) mysql_query("UPDATE users SET last_login = NOW() WHERE id = $id"); } */ function logincookie($id, $passhash, $expires = 0x7fffffff) { if ($expires != 0x7fffffff) { $expires = time() + 900; } setcookie("uid", $id, $expires, "/"); setcookie("pass", $passhash, $expires, "/"); // if ($updatedb) mysql_query("UPDATE users SET last_login = NOW() WHERE id = $id"); } function logoutcookie() { setcookie("uid", "", 0x7fffffff, "/"); setcookie("pass", "", 0x7fffffff, "/"); } function loggedinorreturn() { global $CURUSER; if (!$CURUSER) { header("Location: login.php?returnto=" . urlencode($_SERVER["REQUEST_URI"])); //header("Location: login.php"); exit(); } } function deletetorrent($id) { global $torrent_dir; mysql_query("DELETE FROM torrents WHERE id = $id"); mysql_query("DELETE FROM bookmarks WHERE torrentid = $id"); mysql_query("DELETE FROM snatched WHERE torrentid = $id"); foreach(explode(".","peers.files.comments.ratings") as $x) mysql_query("DELETE FROM $x WHERE torrent = $id"); mysql_query("DELETE FROM coins WHERE torrentid = $id"); unlink("$torrent_dir/$id.torrent"); } function pager($rpp, $count, $href, $opts = array()) { $pages = ceil($count / $rpp); if (!$opts['lastpagedefault']) $pagedefault = 0; else { $pagedefault = floor(($count - 1) / $rpp); if ($pagedefault < 0) $pagedefault = 0; } if (isset($_GET['page'])) { $page = 0 + (int) $_GET['page']; if ($page < 0) $page = $pagedefault; } else $page = $pagedefault; //$pager = "<td class=\"pager\">Page</td><td class=\"pagebr\"> </td>"; $mp = $pages - 1; $as = "<b>«</b>"; if ($page >= 1) { $pager .= "<td class=\"page\">"; $pager .= "<a href=\"{$href}page=" . ($page - 1) . "\" style=\"text-decoration: none;\">$as</a>"; $pager .= "</td><td class=\"pagebr\"> </td>"; } $as = "<b>»</b>"; if ($page < $mp && $mp >= 0) { $pager2 .= "<td class=\"page\">"; $pager2 .= "<a href=\"{$href}page=" . ($page + 1) . "\" style=\"text-decoration: none;\">$as</a>"; $pager2 .= "</td>$bregs"; }else $pager2 .= $bregs; if ($count) { $pagerarr = array(); $dotted = 0; $dotspace = 3; $dotend = $pages - $dotspace; $curdotend = $page - $dotspace; $curdotstart = $page + $dotspace; for ($i = 0; $i < $pages; $i++) { if (($i >= $dotspace && $i <= $curdotend) || ($i >= $curdotstart && $i < $dotend)) { if (!$dotted) $pagerarr[] = "<td class=\"pager\">...</td><td class=\"pagebr\"> </td>"; $dotted = 1; continue; } $dotted = 0; $start = $i * $rpp + 1; $end = $start + $rpp - 1; if ($end > $count) $end = $count; $text = $i+1; if ($i != $page) $pagerarr[] = "<td class=\"pager\"><a title=\"$start - $end\" href=\"{$href}page=$i\" style=\"text-decoration: none;\"><b>$text</b></a></td><td class=\"pagebr\"> </td>"; else $pagerarr[] = "<td class=\"highlight\"><b>$text</b></td><td class=\"pagebr\"> </td>"; } $pagerstr = join("", $pagerarr); $pagertop = "<table align=\"center\" class=\"row2\">$pager $pagerstr $pager2</table><br>\n"; $ptop = "<b><br><font color=yellow>$count itemsgg in $i Pages</font></b><br /><br /><center><table class=\"main\">$pager $pagerstr $pager2</table>\n"; //$pagertop = "<table class=\"main\"><tr>$pager $pagerstr $pager2</tr></table>\n"; //$pagerbottom = "<br /><br /><center><table class=\"main\">$pager $pagerstr $pager2</table><br>\n"; $pagerbottom = "<b><br><center><font color=yellow>$count items in $i Pages</font></b><br /><br /><table class=\"main\">$pager $pagerstr $pager2</table><br>\n"; } else { $pagertop = $pager; $pagerbottom = $pagertop; } $start = $page * $rpp; return array($pagertop, $pagerbottom, "LIMIT $start,$rpp"); } function pager1($rpp, $count, $href, $opts = array()) { $pages = ceil($count / $rpp); if (!$opts["lastpagedefault"]) $pagedefault = 0; else { $pagedefault = floor(($count - 1) / $rpp); if ($pagedefault < 0) $pagedefault = 0; } if (isset($_GET["page"])) { $page = 0 + $_GET["page"]; if ($page < 0) $page = $pagedefault; } else $page = $pagedefault; $pager = ""; $mp = $pages - 1; $as = "<b><< Prev</b>"; if ($page >= 1) { $pager .= "<a href=\"{$href}page=" . ($page - 1) . "\">"; $pager .= $as; $pager .= "</a>"; } else $pager .= $as; $pager .= " "; $as = "<b>Next >></b>"; if ($page < $mp && $mp >= 0) { $pager .= "<a href=\"{$href}page=" . ($page + 1) . "\">"; $pager .= $as; $pager .= "</a>"; } else $pager .= $as; if ($count) { $pagerarr = array(); $dotted = 0; $dotspace = 3; $dotend = $pages - $dotspace; $curdotend = $page - $dotspace; $curdotstart = $page + $dotspace; for ($i = 0; $i < $pages; $i++) { if (($i >= $dotspace && $i <= $curdotend) || ($i >= $curdotstart && $i < $dotend)) { if (!$dotted) $pagerarr[] = "..."; $dotted = 1; continue; } $dotted = 0; $start = $i * $rpp + 1; $end = $start + $rpp - 1; if ($end > $count) $end = $count; //$text = "$start - $end"; $text = "$i - ".$i+1; if ($i != $page) $pagerarr[] = "<a title='$start - $end' href=\"{$href}page=$i\"><b>[$text]</b></a>"; else $pagerarr[] = "<b>[$text]</b>"; } $pagerstr = join(" ", $pagerarr); $pagertop = "<p align=\"center\">$pager<br />$pagerstr</p>\n"; $pagerbottom = "<p align=\"center\">$pagerstr<br />$pager</p>\n"; } else { $pagertop = "<p align=\"center\">$pager</p>\n"; $pagerbottom = $pagertop; } $start = $page * $rpp; return array($pagertop, $pagerbottom, "LIMIT $start,$rpp"); } function downloaderdata($res) { $rows = array(); $ids = array(); $peerdata = array(); while ($row = mysql_fetch_assoc($res)) { $rows[] = $row; $id = $row["id"]; $ids[] = $id; $peerdata[$id] = array(downloaders => 0, seeders => 0, comments => 0); } if (count($ids)) { $allids = implode(",", $ids); $res = mysql_query("SELECT COUNT(*) AS c, torrent, seeder FROM peers WHERE torrent IN ($allids) GROUP BY torrent, seeder"); while ($row = mysql_fetch_assoc($res)) { if ($row["seeder"] == "yes") $key = "seeders"; else $key = "downloaders"; $peerdata[$row["torrent"]][$key] = $row["c"]; } $res = mysql_query("SELECT COUNT(*) AS c, torrent FROM comments WHERE torrent IN ($allids) GROUP BY torrent"); while ($row = mysql_fetch_assoc($res)) { $peerdata[$row["torrent"]]["comments"] = $row["c"]; } } return array($rows, $peerdata); } function commenttable2($rows) { global $CURUSER, $pic_base_url, $userid; begin_main_frame(); begin_frame(); $count = 0; foreach ($rows as $row) { print("<table border=0 cellspacing=0 cellpadding=0 width='700'><tr><td class=colhead>"); print("<p class=colhead>#" . $row["id"] . " By "); if (isset($row["username"])) { $title = $row["title"]; $lclass = (int)$row["class"]; if ($title == "") $title = get_user_class_name($row["class"]); print("<a name=comm". $row["id"] ." href=\"" . $row["username"] . ".usr\"><b><font color=\"".get_user_class_color($lclass)."\">" .htmlspecialchars($row["username"]) . "</b></font></a>" . ($row["donor"] == "yes" ? "<img src=\"{$pic_base_url}star.gif\" alt='Donor'>" : "") . ($row["warned"] == "yes" ? "<img src="."\"{$pic_base_url}warned.gif\" alt=\"Warned\">" : ""). " ($title)\n"); } else print("<a name=\"comm" . $row["id"] . "\"><i>(orphaned)</i></a>\n"); print(" on " . $row["added"] . " GMT" . ($userid == $CURUSER["id"] || $row["user"] == $CURUSER["id"] || get_user_class() >= UC_MODERATOR ? "- [<a href=comment.php?action=edit&cid=$row[id]>Edit</a>]" : "") . ($userid == $CURUSER["id"] || get_user_class() >= UC_MODERATOR ? "- [<a href=comment.php?action=delete&cid=$row[id]>Delete</a>]" : "") . ($row["editedby"] && get_user_class() >= UC_MODERATOR ? "- [<a href=comment.php?action=vieworiginal&cid=$row[id]>View original</a>]" : "") . "</p>\n"); $avatar = ($CURUSER["avatars"] == "yes" ? htmlspecialchars($row["avatar"]) : ""); print("</td></tr></table></td>"); $text = format_comment($row["text"]); if ($row["editedby"]) $text .= "<p><font size=1 class=small>Last edited by <a href=\"userdetails.php?id=$row[editedby]\"><b>$row[username]</b></a> at $row[editedat] GMT</font></p>\n"; begin_table(true); $res3 = mysql_query("SELECT id,username,class,avatar,donor,title,enabled,warned,downloaded,uploaded FROM users WHERE id=$row[user]") or sqlerr(__FILE__, __LINE__); $arr3 = mysql_fetch_assoc($res3); if ($arr3["enabled"] == "yes") $avatar = ($CURUSER["avatars"] == "yes" ? htmlspecialchars($row["avatar"]) : ""); else $avatar = "pic/disabled_avatar.gif"; if (!$avatar) $avatar = "pic/noavatar.png"; if ($arr3["downloaded"] > 0) { $ratio = number_format($arr3["uploaded"] / $arr3["downloaded"], 2); $ratio = "<font color=\"" . get_ratio_color($ratio) . "\">$ratio</font>"; } else if ($arr3["uploaded"] > 0) $ratio = "Inf."; else $ratio = "---"; $uploaded = mksize($arr3["uploaded"]); $downloaded = mksize($arr3["downloaded"]); // Comments Count Start [ShadoW69] $res4 = mysql_query("SELECT COUNT(*) FROM comments") or sqlerr(__FILE__, __LINE__); $arr4 = mysql_fetch_row($res4); if (($arr3[id]) == ($arr4[user])) { $comments = "---"; } else { $res5 = mysql_query("SELECT COUNT(*) FROM comments WHERE user=$arr3[id]") or sqlerr(__FILE__, __LINE__); $arr5 = mysql_fetch_row($res5); $comments = $arr5[0]; } //Comments Count End $class_name = get_user_class_name($arr3["class"]); $class_color = get_user_class_color($arr3["class"]); $title = "{$arr3["title"]}"; if (!$title) $title = ""; else $title = "{$arr3["title"]}<br>"; $lclass = (int)$arr3["class"]; print("<tr class=row1 valign=top><td width=100 align=center style='padding: 0px'>" .($avatar ? "<img width=100 src=\"{$avatar}\" alt='Avatar' class='avatar'></a><br>" : ""). ""); print("</td>\n"); print("<td class=text>$text</td>\n"); print("</tr>\n"); end_table(); } end_frame(); end_main_frame(); } function commenttable($rows) { global $CURUSER, $pic_base_url; begin_main_frame(); //begin_frame(); $count = 0; foreach ($rows as $row) { $id = 0 + $_GET["id"]; $res2 = mysql_query("SELECT torrents.id FROM torrents WHERE torrents.id = $id") or sqlerr(); $arr2 = mysql_fetch_assoc($res2); $commentid = $row[id]; print("<a name=$commentid></a>\n"); print("<table border=0 cellspacing=0 align=center cellpadding=2 width='100%'><tr><td class=row6>"); print("<table border=0 cellspacing=0 align=center cellpadding=2 width='100%'><tr><td colspan=2>"); print("<p align=center class=colhead>#" . $row["id"] . " "); if (isset($row["username"])) { $title = $row["title"]; $lclass = (int)$row["class"]; $added = "" . get_elapsed_times(sql_timestamp_to_unix_timestamp($row["added"])) . " ago"; if ($title == "") $title = get_user_class_name($row["class"]); print("<a name=comm". $row["id"] ." href=\"" . $row["username"] . ".usr\"><b><font color=\"".get_user_class_color($lclass)."\">" .htmlspecialchars($row["username"]) . "</b></font></a>" . ($row["donor"] == "yes" ? " <img src=\"{$pic_base_url}star1.gif\" alt='Donor'>" : ""). ($row["warned"] == "yes" ? "<img src="."\"{$pic_base_url}warned.gif\" alt=\"Warned\">" : ""). " ($title)\n"); } else print("<a name=\"comm" . $row["id"] . "\"><i>(orphaned)</i></a>\n"); print("$added" . ($userid == $CURUSER["id"] || $row["user"] == $CURUSER["id"] || get_user_class() >= UC_MODERATOR ? " [<a href=comment.php?action=edit&cid=$row[id]>Edit</a>] -" : "") . ($userid == $CURUSER["id"] || get_user_class() >= UC_MODERATOR ? " [<a href=comment.php?action=delete&cid=$row[id]>Delete</a>]" : "") . ($row["editedby"] && get_user_class() >= UC_MODERATOR ? " [<a href=comment.php?action=vieworiginal&cid=$row[id]>Original</a>]" : "") . "</p>\n"); $avatar = ($CURUSER["avatars"] == "yes" ? htmlspecialchars($row["avatar"]) : ""); print("</td></tr></table></td>"); //print("</td></tr></table>"); $text = format_comment($row["text"]); if ($row["editedby"]) $text .= "<p><font size=1 class=small>Last edited by <a href=\"userdetails.php?id=$row[editedby]\"><b>$row[username]</b></a> at $row[editedat] GMT</font></p>\n"; begin_table(true); $res3 = mysql_query("SELECT id,username,class,avatar,donor,title,enabled,warned,downloaded,uploaded FROM users WHERE id=$row[user]") or sqlerr(__FILE__, __LINE__); $arr3 = mysql_fetch_assoc($res3); if ($arr3["enabled"] == "yes") $avatar = ($CURUSER["avatars"] == "yes" ? htmlspecialchars($row["avatar"]) : ""); else $avatar = "pic/disabled_avatar.gif"; if (!$avatar) $avatar = "themes/NB-Hybride/images/noavatar.png"; if ($arr3["downloaded"] > 0) { $ratio = number_format($arr3["uploaded"] / $arr3["downloaded"], 2); $ratio = "<font color=\"" . get_ratio_color($ratio) . "\">$ratio</font>"; } else if ($arr3["uploaded"] > 0) $ratio = "Inf."; else $ratio = "---"; $uploaded = mksize($arr3["uploaded"]); $downloaded = mksize($arr3["downloaded"]); // Comments Count Start [ShadoW69] $res4 = mysql_query("SELECT COUNT(*) FROM comments") or sqlerr(__FILE__, __LINE__); $arr4 = mysql_fetch_row($res4); if (($arr3[id]) == ($arr4[user])) { $comments = "---"; } else { $res5 = mysql_query("SELECT COUNT(*) FROM comments WHERE user=$arr3[id]") or sqlerr(__FILE__, __LINE__); $arr5 = mysql_fetch_row($res5); $comments = $arr5[0]; } //Comments Count End $class_name = get_user_class_name($arr3["class"]); $class_color = get_user_class_color($arr3["class"]); $title = "{$arr3["title"]}"; if (!$title) $title = ""; else $title = "{$arr3["title"]}<br>"; print("<tr class=row3 valign=top><td width=100 align=center style='padding: 0px'>" .($avatar ? "<img width=100 src=\"{$avatar}\" alt='Avatar' class='avatar'></a><br>" : ""). ""); ?> <? print("</td>\n"); print("<td class=row1>$text</td>\n"); print("</tr>\n"); end_table(); } //end_frame(); end_main_frame(); } function searchfield($s) { return preg_replace(array('/[^a-z0-9]/si', '/^\s*/s', '/\s*$/s', '/\s+/s'), array(" ", "", "", " "), $s); } function genrelist() { $ret = array(); $res = mysql_query("SELECT id, name FROM categories ORDER BY name"); while ($row = mysql_fetch_array($res)) $ret[] = $row; return $ret; } function linkcolor($num) { if (!$num) return "red"; // if ($num == 1) // return "yellow"; return "green"; } function ratingpic($num) { global $pic_base_url; $r = round($num * 2) / 2; if ($r < 1 || $r > 5) return; return "<img src=\"/pic/".rank_."$r.gif\" border=\"0\" alt=\"$num / 5\" />"; } function get_percent_completed_image($p) { $maxpx = "50"; // Maximum amount of pixels for the progress bar if ($p == 0) $progress = "<img src=\"/pic/progbar-rest.gif\" height=9 width=" . ($maxpx) . " />"; if ($p == 100) $progress = "<img src=\"/pic/progbar-green.gif\" height=9 width=" . ($maxpx) . " />"; if ($p >= 1 && $p <= 30) $progress = "<img src=\"/pic/progbar-red.gif\" height=9 width=" . ($p*($maxpx/100)) . " /><img src=\"/pic/progbar-rest.gif\" height=9 width=" . ((100-$p)*($maxpx/100)) . " />"; if ($p >= 31 && $p <= 65) $progress = "<img src=\"/pic/progbar-yellow.gif\" height=9 width=" . ($p*($maxpx/100)) . " /><img src=\"/pic/progbar-rest.gif\" height=9 width=" . ((100-$p)*($maxpx/100)) . " />"; if ($p >= 66 && $p <= 99) $progress = "<img src=\"/pic/progbar-green.gif\" height=9 width=" . ($p*($maxpx/100)) . " /><img src=\"/pic/progbar-rest.gif\" height=9 width=" . ((100-$p)*($maxpx/100)) . " />"; return "<img src=\"/pic/bar_left.gif\" />" . $progress ."<img src=\"/pic/bar_right.gif\" />"; } function get_percent_completed_image1($p) { $img = "progress-"; if ($p == 100) $img .= "5"; elseif (($p >= 0) && ($p <= 10)) $img .= "0"; elseif (($p >= 11) && ($p <= 40)) $img .= "1"; elseif (($p >= 41) && ($p <= 60)) $img .= "2"; elseif (($p >= 61) && ($p <= 80)) $img .= "3"; elseif (($p >= 81) && ($p <= 99)) $img .= "4"; return "<img src=\"pic/".$img.".gif\"/>"; } function writecomment($userid, $comment) { $res = mysql_query("SELECT modcomment FROM users WHERE id = '$userid'") or sqlerr(__FILE__, __LINE__); $arr = mysql_fetch_assoc($res); $modcomment = gmdate("d-m-Y") . " - " . $comment . "" . ($arr[modcomment] != "" ? "\n\n" : "") . "$arr[modcomment]"; $modcom = sqlesc($modcomment); return mysql_query("UPDATE users SET modcomment = $modcom WHERE id = '$userid'") or sqlerr(__FILE__, __LINE__); } function torrenttable($res, $variant = "index") { global $torrent_ttl,$pic_base_url, $CURUSER; $browse_res = mysql_query("SELECT last_browse FROM users WHERE id='".$CURUSER['id']."'"); $browse_arr = mysql_fetch_row($browse_res); $last_browse = $browse_arr[0]; $time_now = gmtime(); if ($last_browse > $time_now) { $last_browse=$time_now; } if ($CURUSER["class"] < UC_VIP) { $gigs = $CURUSER["uploaded"] / (1024*1024*1024); $ratio = (($CURUSER["downloaded"] > 0) ? ($CURUSER["uploaded"] / $CURUSER["downloaded"]) : 0); if ($gigs < 5) $wait = 0; elseif ($ratio < 0.65 || $gigs < 6.) $wait =0; elseif ($ratio < 0.80 || $gigs < 8) $wait = 0; elseif ($ratio < 0.95 || $gigs < 9.) $wait = 0; else $wait = 0; $elapsed = floor((gmtime() - strtotime($row["added"])) / 3600); if ($elapsed < $wait) $wait = number_format($wait - $elapsed); } //begin_table(true); ?> <? // sorting by MarkoStamcar $count_get = 0; foreach ($_GET as $get_name => $get_value) { $get_name = mysql_escape_string(strip_tags(str_replace(array("\"","'"),array("",""),$get_name))); $get_value = mysql_escape_string(strip_tags(str_replace(array("\"","'"),array("",""),$get_value))); if ($get_name != "sort" && $get_name != "type") { if ($count_get > 0) { $oldlink = $oldlink . "&" . $get_name . "=" . $get_value; } else { $oldlink = $oldlink . $get_name . "=" . $get_value; } $count_get++; } } if ($count_get > 0) { $oldlink = $oldlink . "&"; } if ($_GET['sort'] == "1") { if ($_GET['type'] == "desc") { $link1 = "asc"; } else { $link1 = "desc"; } } if ($_GET['sort'] == "2") { if ($_GET['type'] == "desc") { $link2 = "asc"; } else { $link2 = "desc"; } } if ($_GET['sort'] == "3") { if ($_GET['type'] == "desc") { $link3 = "asc"; } else { $link3 = "desc"; } } if ($_GET['sort'] == "4") { if ($_GET['type'] == "desc") { $link4 = "asc"; } else { $link4 = "desc"; } } if ($_GET['sort'] == "5") { if ($_GET['type'] == "desc") { $link5 = "asc"; } else { $link5 = "desc"; } } if ($_GET['sort'] == "6") { if ($_GET['type'] == "desc") { $link6 = "asc"; } else { $link6 = "desc"; } } if ($_GET['sort'] == "7") { if ($_GET['type'] == "desc") { $link7 = "asc"; } else { $link7 = "desc"; } } if ($_GET['sort'] == "8") { if ($_GET['type'] == "desc") { $link8 = "asc"; } else { $link8 = "desc"; } } if ($_GET['sort'] == "9") { if ($_GET['type'] == "desc") { $link9 = "asc"; } else { $link9 = "desc"; } } if ($link1 == "") { $link1 = "asc"; } // for torrent name if ($link2 == "") { $link2 = "desc"; } if ($link3 == "") { $link3 = "desc"; } if ($link4 == "") { $link4 = "asc"; } if ($link5 == "") { $link5 = "desc"; } if ($link6 == "") { $link6 = "desc"; } if ($link7 == "") { $link7 = "desc"; } if ($link8 == "") { $link8 = "desc"; } if ($link9 == "") { $link9 = "asc"; } //////////////////////////////// My Torrents Sort by Lost ///////////////////////////// if ($variant == "mytorrents") $returnpage = ""; else $returnpage = "browse.php"; //////////////////////////////// end of My Torrents Sort by Lost //////////////////////////// ?> <table border="0" align="center" class="row3" width="100%" cellspacing=0 cellpadding=0> <tr> <td class="colhead" align=center>Genre</td> <td class="colhead" align=center><a title="Click to Sort by Name" href="?<? $returnpage ?><? print $oldlink; ?>sort=1&type=<? print $link1; ?>">Name</a></td> <!--<td class="heading" align=left>DL</td>--> <? if ($wait) { print("<td class=\"colhead\" align=\"center\">WT</td>\n"); } if ($variant == "mytorrents") { //print("<td class=\"colhead\" align=\"center\">Edit</td>\n"); //print("<td class=\"colhead\" align=\"center\">Visible</td>\n"); } ?> <!--<td class="colhead" align="center"><a href="browse.php?sort=6&type=desc">S</a></td>--> <!--<td class=colhead align="center"><a title="Times Completed" href="?<? $returnpage ?><? print $oldlink; ?>sort=6&type=<? print $link6; ?>">S</a></td>--> <!--<td class="colhead" align="center">Dl</td>--> <!--<td class="colhead" align="center"><a title="Click to Sort by Files" href="?<? $returnpage ?><? print $oldlink; ?>sort=2&type=<? print $link2; ?>">Files</a></td>--> <!--<td class="colhead" align="center">Files</a></td>--> <td class="colhead" width="8%" align="center"><a title="Click to Sort by Date" href="?<? $returnpage ?><? print $oldlink; ?>sort=4&type=<? print $link4; ?>">Added</a></td> <td class="colhead" align="center"><a title="Click to Sort by Comments" href="?<? $returnpage ?><? print $oldlink; ?>sort=3&type=<? print $link3; ?>"><img border='0' src="pic/comments.png" alt="Comments" title="Comments" /></a></td> <!--<td class="colhead" align="center">Rating</td>--> <!--<td class="colhead" align="center"><a title="Click to Sort by Date" href="?<? $returnpage ?><? print $oldlink; ?>sort=4&type=<? print $link4; ?>">Added</a></td>--> <td class="colhead" align="center"><a title="Click to Sort by Size" href="?<? $returnpage ?><? print $oldlink; ?>sort=5&type=<? print $link5; ?>">Size</a></td> <td class="colhead" align="center"><a title="Click to Sort by Snatches" href="?<? $returnpage ?><? print $oldlink; ?>sort=6&type=<? print $link6; ?>"><img border='0' src="pic/snatched.png" alt="Snatches" title="Snatches" /></a></td> <!-- <td class="colhead" align=right>Views</td> <td class="colhead" align=right>Hits</td> --> <td class="colhead" align="center"><a title="Click to Sort by Seeders" href="?<? $returnpage ?><? print $oldlink; ?>sort=7&type=<? print $link7; ?>"><img border='0' src="pic/seeders.png" alt="Seeders" title="Seeders" /></a></td> <td class="colhead" align="center"><a title="Click to Sort by Leechers" href="?<? $returnpage ?><? print $oldlink; ?>sort=8&type=<? print $link8; ?>"><img border='0' src="pic/leechers.png" alt="Leechers" title="Leechers" /></a></td> <td class="colhead" align="center">Upped by</td> <? if ($variant == "index") //print("<td class=\"colhead\" align=\"center\">Upped by</td>\n"); print("</tr>\n"); while ($row = mysql_fetch_assoc($res)) { $id = $row["id"]; print("<tr class=browse>\n"); print("<td align=\"left\" style=\"padding: 0px\">"); if (isset($row["cat_name"])) { print("<a href=\"browse.php?cat=" . $row["category"] . "\">"); if (isset($row["cat_pic"]) && $row["cat_pic"] != "") //print("<img class=\"$row[cat_name]\" border=\"0\" src=/pic/blank2.gif title=\"" . $row["cat_name"] . "\" />"); print("<img border=\"0\" src=\"pic/categorypics/" . $row["cat_pic"] . "\" title=\"" . $row["cat_name"] . "\" />"); else print($row["cat_name"]); print("</a>"); } else print("-"); print("</td>\n"); $upnam = ($row["username"]); // SQL query to get Advertise Details from Database. $upclq = mysql_query("SELECT advertisename FROM users WHERE username = '$upnam'") or qlerr(); $upclas = mysql_fetch_array($upclq); $addnam = $upclas['advertisename']; $uprow = (" <font color=red><i>Anonymous</i></font>"); //if (get_user_class() >= UC_USER) if($row["anonymous"] == "yes" AND get_user_class() > UC_MODERATOR AND $CURUSER["id"] != $row["username"]) //$uprow = "" . (isset($row["username"]) ? ("<a href=/$row[username].usr". "><b><font color=green>" .htmlspecialchars ($row["username"]) . "</b></a>") : "<i>(unknown)</i></font>") . "\n"; $uprow = "<b>" . (isset($row["username"]) ? ("<a title=$row[username] href=/$row[username].usr". "><font color=\"".get_user_class_color($row["owner_class"])."\">" . htmlspecialchars($row["username"]) . "</font></a></b>") : "<i>(unknown)</i>") . "\n"; // Bookmarks mod $bookt = mysql_query("SELECT torrentid FROM snatched WHERE finished = 'yes' AND torrentid = $row[id] AND userid = $CURUSER[id]"); if (mysql_num_rows($bookt) > 0) //print("<img border=0 align=right src=/pic/check_1.gif alt=Bookmark title='Already Downloaded!!'>\n"); $bookt = ("<img border=0 align=right src=/pic/check_1.gif alt='You Already Downloaded This Torrent!!' title='You Already Downloaded This Torrent!!'>"); else $bookt = (""); //end bookmarks // Bookmarks mod $bookts = mysql_query("SELECT torrentid FROM bookmarks WHERE torrentid = $row[id] AND userid = $CURUSER[id]"); if (mysql_num_rows($bookts) > 0) //print("<img border=0 align=right src=/pic/check_1.gif alt=Bookmark title='Already Downloaded!!'>\n"); $bookts = ("<a href='bookmark.php?torrent=$row[id]&action=delete'><img border=0 align=right src=/pic/delete.png alt='Un-Bookmark This Torrent!!' title='Un-Bookmark This Torrent!!'></a>"); else $bookts = ("<a href='bookmark.php?torrent=$row[id]&action=add'><img border=0 align=right src=/pic/add.png alt='Bookmark This Torrent!!' title='Bookmark This Torrent!!'></a>"); //end bookmarks $timezone = display_date_time($row["utadded"] , $CURUSER[tzoffset]); $added1 = display_date_time($row["utadded"] , $CURUSER[tzoffset] ); $added = "" . get_elapsed_times(sql_timestamp_to_unix_timestamp($row["added"])) . " ago"; $nukereason = htmlspecialchars($row["nukereason"]); $doubleuptag = ($row["10days"]=="yes" ? "<img align=right src='pic/2xup.png' alt='x2' title='This torrent is x2 upload'>" : ""); $thisisnuked = ($row["nuked"] == "yes" ? "<img src='pic/nuked2.gif' alt='Nuked' title='Nuked: $nukereason'>" : ""); $thisisfrees = ($row[free]=="yes" ? "<img align=right src=pic/freedownload.gif title='This torrent is freeleech so only upload counts!'>" : ""); //$thisisfrees = ($row[free]=="yes" ? "<b><a href=browse.php?free=1><font color=green>[Free]</a></font></b>" : ""); //$scene = ($row[scene]=="yes" ? "<img align=right src=pic/blank.gif class=scene title='This Is A Scene Release Torrent'>" : ""); if (get_user_class() < UC_VIP){ $request = ($row[request]=="yes" ? "<a target=_blank href=donate.php><img align=right src=pic/blank.gif class=req title='This torrent will remain vip for 7 days from $added1 please donate or wait' ></a>" : ""); } $dispname = htmlspecialchars($row["name"]); $comments = htmlspecialchars($row["comments"]); if (get_user_class() >= UC_OWNER){ //$del = (" <a href=\"fastdelete.php?id=$row[id]\"><img align=right src=pic/n.png border=0 title='Delete $dispname' alt='Delete'></a>"); } if (get_user_class() >= UC_VIP){ $dl = ("<a align=right href=\"download.php/$id/" . rawurlencode($row["filename"]) . "\"><img align=right src=pic/blank.gif class=dl border=0 title='Download $dispname' alt=Download></a>"); } $newtag = ((sql_timestamp_to_unix_timestamp($row['added']) >= $last_browse)? ' <img align=left src=pic/new.png>' : ''); $sticky = ($row[sticky]=="yes" ? "<img src='pic/sticky.gif' bored='0' alt='sticky'>" : ""); if (!empty($row['genre'])) { $a = split(',',$row['genre']); foreach ($a as $value) { //echo(" <a href=\"browse.php?search=" . $value . "\">" . $value . "</a> / "); } } if ($row["tags"] == "") { $keywords = ""; } else { $tags = explode(",", $row["tags"]); //$keywords = "<br> "; $keywords = "<br> "; foreach ($tags as $tag){ $tag = str_replace(" ", "",$tag); $keywords .= "<b><a href='browse.php?search=$tag&cat=0&incldead=1'>$tag</a></b> ,"; } $keywords = substr($keywords, 0, (strlen($keywords) - 2)); } //print("<tr><td ><b>Search Tags:</b></td><td>" . $keywords . "</td></tr>\n"); if (!empty($row['genre'])) $genres = "<br> <b>" . htmlspecialchars($row["genre"]) . "</b>"; else $genres = ""; //$genres = ""; if (!empty($row['description'])) { $description = "(" . htmlspecialchars($row["description"]) . ")"; } else { $description = ""; } $char = 75; //Max long... //print("<td align=\"left\"><a href=\"#\" onclick=\"show_details('".$row['id']."', 'details'); return false;\"><img src=\"/pic/plus.gif\" border=\"0\" title=\"Show torrent info in this page\"/></a>"); print("<td align=\"left\"><img align=left src=\"/pic/cross.gif\" onclick=\"show_details('".$row['id']."', 'details')\" border=\"0\" title=\"Click here to show torrent description\"/></a><a href=\"details.php?"); //print("<td class=\"main\" align=\"left\"><a href=\"details.php?"); if ($variant == "mytorrents") print("returnto=" . urlencode($_SERVER["REQUEST_URI"]) . "&"); print("id=$id"); if ($variant == "index") print(""); if (sql_timestamp_to_unix_timestamp($row["added"]) >= $last_browse) print("\" title=\"". $dispname . "\"><b> " . CutName($dispname, $char) . " </b></a><font color=blue><b> NEW!</b></font>$del $bookt $bookts $dl $thisisfrees $thisisnuked<br> $doubleuptag</div>"); //print("\" title=\"". $dispname . "\"><font color=red><b>NEW!</b></font><b>" . CutName($dispname, $char) . " </a></b>$thisisnuked<br>$thisisfrees<b>($added) By $uprow</b> $keywords $sticky $thisisfree $del $request $doubleuptag</div>"); else print("\" title=\"" . $dispname . "\"><b>" . CutName($dispname, $char) . "</b></a>$del $bookt $bookts $dl $thisisfrees $thisisnuked $doubleuptag</a>"); //print("\" title=\"" . $dispname . "\"><b>" . CutName($dispname, $char) . "</a></b> $bookt<b>($added) $added1 By $uprow</b> $genres $thisisfrees $thisisnuked $del $request $doubleuptag</a>"); if ($CURUSER["downloadpos"] != "no") if ($variant == "index") if ($wait) { $elapsed = floor((gmtime() - strtotime($row["added"])) / 3600); if ($elapsed < $wait) { $color = dechex(floor(127*($wait - $elapsed)/48 + 128)*65536); print("<td class=\"main\" align=\"right\"><a title='You need to wait " . number_format($wait - $elapsed) . " hour(s) to download this file. If you require this torrent before this time please click here to donate' href=\"donate.php\"><font color=\"red\"><b>" . number_format($wait - $elapsed) . " h</font></a></td>\n"); } else print("<td class=\"main\" align=\"center\"><b>---</b></td>\n"); } /* if ($row["nfoav"] && get_user_class() >= UC_POWER_USER) print("<a href=viewnfo.php?id=$row[id]><img align=right src=pic/viewnfo.png border=0 title='View NFO'></a>\n"); */ //print("$bookt\n"); /* // Bookmarks mod $bookt = mysql_query("SELECT torrentid FROM bookmarks WHERE torrentid = $row[id] AND userid = $CURUSER[id]"); if (mysql_num_rows($bookt) > 0) print("<a href=bookmark.php?torrent=$id&action=delete><img align=center border=0 src=pic/delete.png alt=Bookmark title='Un-Bookmark this torrent'></a>\n"); else print("<a href=bookmark.php?torrent=$id&action=add><img align=center border=0 src=pic/blank.gif class=bk alt=Bookmark title='Bookmark this torrent'></a>\n"); //end bookmarks */ if ($CURUSER["downloadpos"] != "no") if ($CURUSER['class'] >= UC_VIP) //print("$bookt $bookts\n"); //print("<a href=\"download.php?id=$id&name=" . rawurlencode($row["filename"]) . "\"><img src=pic/download.png border=0 title='Download'></a>\n"); //print("<div style='clear:none;white-space:nowrap;float:right;top:0;right:0'> <a href=\"download.php/$id/" . rawurlencode($row["filename"]) . "\"><img src=pic/blank.gif class=dl border=0 title='Download $dispname' alt=Download></a></div>\n"); //print("$bookt $bookts\n"); if ($variant == "index") if ($row["times_completed"] != 1) $_s = "s"; //print("<td width=1% align=right class=main>$del</a></td>\n"); if ($row["type"] == "single") print("<td width=\"1%\" class=\"main\" align=\"ceneter\"><b>" . $row["numfiles"] . "</b></td>\n"); else { if ($variant == "index") print("<td class=\"main\" align=\"center\"> $added</td>\n"); //print("<td class=\"row2\" width=\"30%\" align=\"center\">$added</td>\n"); //print("<td width=\"20%\" class=\"main\" align=\"center\"><b>" . str_replace(" ", " ", mksize($row["size"])) . " </b>In <b><a href=\"details.php?id=$id&hit=1&filelist=1\">" . $row["numfiles"] . "</a></b> File$s</td>\n"); else //print("<td width=\"1%\" class=\"main\" align=\"center\"><b><a href=\"details.php?id=$id&filelist=1#filelist\">" . $row["numfiles"] . "</a></b></td>\n"); print("<td class=\"main\" align=\"center\"> $added</td>\n"); } if (!$row["comments"]) print("<td width=\"1%\" class=\"main\" align=\"center\"><b></b></td>\n"); else { if ($variant == "index") print("<td width=\"1%\" class=\"main\" align=\"center\"><b><a href=\"details.php?id=$id&hit=1&tocomm=1\" title='$comments Comment$_s'><div class=list-commenticon>" . $row["comments"] . "</div></a></b></td>\n"); else print("<td width=\"1%\" class=\"main\" align=\"center\"><b><a href=\"details.php?id=$id&page=0#startcomments\">" . $row["comments"] . "</a></b></td>\n"); } print("</td>\n"); //print("<td class=\"row3\" width=\"100%\" align=\"center\">$added1<br>($added)</td>\n"); //print("<td class=\"row2\" align=\"center\">" . str_replace(" ", "<br />", $row["added"]) . "</td>\n"); print("<td width=\"1%\" class=\"main\" align=\"right\"><center>" . str_replace(" ", " ", mksize($row["size"])) . "</td>\n"); // print("<td align=\"right\">" . $row["views"] . "</td>\n"); // print("<td align=\"right\">" . $row["hits"] . "</td>\n"); $_s = ""; if ($row["times_completed"] != 1) $_s = "s"; //print("<td align=center class=main><a href=viewsnatches.php?id=$row[id]>" . number_format($row["times_completed"]) . " time$_s</a></td>\n"); print("<td align=center class=main><a href=viewsnatches.php?id=$row[id]>" . number_format($row["times_completed"]) . "</a></td>\n"); if ($row["seeders"]) { if ($variant == "index") { if ($row["leechers"]) $ratio = $row["seeders"] / $row["leechers"]; else $ratio = 1; print("<td width=\"2%\" class=\"main\" align=\"center\"><b><a href=\"details.php?id=$id&dllist=1#seeders\"><font color=green>" . $row["seeders"] . "</font></a></b>"); } else print("<td width=\"5%\"align=\"right\"><a class=\"" . linkcolor($row["seeders"]) . "\" href=\"details.php?id=$id&dllist=1#seeders\"><b><font color=green>" . $row["seeders"] . "</a></b></font></td>\n"); } else print("<td class=\"main\" align=\"right\"><b><font color=red><span class=\"" . linkcolor($row["seeders"]) . "\">" . $row["seeders"] . "</span></b></font></td>\n"); if ($row["leechers"]) { if ($variant == "index") print("<td width=\"2%\" align=\"center\"><b><a href=\"details.php?id=$id&dllist=1#leechers\"><font color=green>" . number_format($row["leechers"]) . ($peerlink ? "</a></b>" : "") . "</b></td>\n"); else print("<td class=\"main\" width=\"5%\" align=\"center\"><b><a class=\"" . linkcolor($row["leechers"]) . "\" href=\"details.php?id=$id&dllist=1#leechers\"><b><font color=green> " .$row["leechers"] . "</a></font></b></td>\n"); } else print("<td align=\"center\" class=\"main\"><b> <font color=red>0 </b></font></td>\n"); if ($variant == "index") ######################################## # Advertise Upload MOD 2005. YeOK # ######################################## $upnam = ($row["username"]); // SQL query to get Advertise Details from Database. $upclq = mysql_query("SELECT anonymous FROM users WHERE username = '$upnam'") or qlerr(); $upclas = mysql_fetch_array($upclq); $addnam = $upclas['anonymous']; $uprow = ("<td class=\"main\" align=\"center\"> <i>*Anonymous*</i>"); $uprow = "<td class=\"main\" align=\"center\"><b>" . (isset($row["username"]) ? ("<a title=$row[username] href=/$row[username].usr". "><font color=\"".get_user_class_color($row["owner_class"])."\">" . htmlspecialchars($row["username"]) . "</font></a></b>") : "<i>(unknown)</i>") . "</td>\n"; //$uprow = "<td class=\"main\" align=\"right\">" . (isset($row["username"]) ? ("<a href=userdetails.php?id=" . $row["owner"] . "><b>" . htmlspecialchars($row["username"]) . "</b></a>") : "<i>(unknown)</i>") . "</td>\n"; //print("<b>$uprow</b></td>\n"); print($uprow); print("</tr>\n"); print("<tr><td width=100% id=\"id-".$row['id']."\" class=\"toggle_descr\" colspan=\"10\"></td></tr>\n"); } end_table(); return $rows; } function hash_pad($hash) { return str_pad($hash, 20); } function hash_where($name, $hash) { $shhash = preg_replace('/ *$/s', "", $hash); return "($name = " . sqlesc($hash) . " OR $name = " . sqlesc($shhash) . ")"; } function get_user_icons($arr, $big = false) { if ($big) { $donorpic = "star1.gif"; $dd = "downloaddisabled.gif"; $leechwarnpic = "warnedbig.gif"; $warnedpic = "warnedbig.gif"; $disabledpic = "disabledbig.gif"; //$style = "style='margin-left: 4pt'"; } else { $donorpic = "star1.gif"; $dd = "downloaddisabled.gif"; $leechwarnpic = "warned.gif"; $warnedpic = "warnedbig.gif"; $disabledpic = "disabled.gif"; //$style = "style=\"margin-left: 2pt\""; } $pics = $arr["donor"] == "yes" ? " <img src=pic/$donorpic title='$arr[username] has donated to the site' border=0 $style>" : ""; if ($arr["enabled"] == "yes") $pics .= ($arr["warned"] == "yes" ? " <img src=pic/$warnedpic title=\"$arr[timeswarned] Warning(s)\" border=0 $style>" : "") . ($arr["downloadpos"] == "no" ? " <img src=pic/$dd title=\"Download Disabled\" border=0 $style>" : ""); else $pics .= " <img src=pic/$disabledpic title=\"Be good, and you won't end up like this user\" border=0 $style>\n"; return $pics; } function verify_passkey($passkey) { global $CURUSER; if (strlen($CURUSER['passkey']) != 32) { do { $CURUSER['passkey'] = md5($CURUSER['username'].get_date_time().$CURUSER['passhash']); $notok=mysql_query("UPDATE users SET passkey='$CURUSER[passkey]' WHERE id=$CURUSER[id]") === FALSE; } while($notok); } return($CURUSER['passkey']==$passkey); } // Old dbconn() function, now isn't called, but is done automatically when it's included if (!@mysql_connect($mysql_host, $mysql_user, $mysql_pass)) { switch (mysql_errno()) { case 1040: case 2002: if ($_SERVER[REQUEST_METHOD] == "GET") die("<html><head><meta http-equiv=refresh content=\"5 $_SERVER[REQUEST_URI]\"></head><body><table border=0 style=background-color:#111111 width=100% height=100%><tr><td><h3 align=center><font color=#c5c5c5>The server load is very high at the moment. Please try again in a few moments</font></h3></td></tr></table></body></html>"); else die("Too many users. Please press the Refresh button in your browser to retry."); default: die("[" . mysql_errno() . "] dbconn: mysql_connect: " . mysql_error()); } } mysql_select_db($mysql_db) or die('dbconn: mysql_select_db: ' + mysql_error()); userlogin(); if (basename($_SERVER['SCRIPT_FILENAME']) == 'index.php') register_shutdown_function("autoclean"); // Empty dbconn for compatibility function dbconn() { } ?> Last edited by sharpie; 7th January 2013 at 14:20. |
#9
|
|||
|
|||
Quote:
right before the stdfoot PHP Code:
|
The Following User Says Thank You to ndbj For This Useful Post: | ||
romano1 (14th January 2013)
|
#10
|
|||
|
|||
added m8 but still shows new tags after i refresh page:(
|
Tags |
ajax , browse |
|
|