Bravo List
Register
Go Back   > Bravo List > Source Code > Archived Trackers > BT.Manager (phpMyBitTorrent)
Reply
  #1  
Old 6th September 2012, 04:11
Giorgatzelos's Avatar
Giorgatzelos Giorgatzelos is offline
Senior Member
 
Join Date: Nov 2009
Greece
Posts: 300
Default imdb link error
Hey i still have two non working "things" that should work for my site...one is this...
When i click on the imdb link as u can see i get this error:

Code:
Fatal error: Call to undefined method Imdb::setid() in /home/******/public_html/ajax.php on line 2184
This is my ajax.php
PHP Code:
<?php
/*
*----------------------------phpMyBitTorrent V 2.0.4---------------------------*
*--- The Ultimate BitTorrent Tracker and BMS (Bittorrent Management System) ---*
*--------------   Created By Antonio Anzivino (aka DJ Echelon)   --------------*
*-------------------   And Joe Robertson (aka joeroberts)   -------------------*
*-------------               http://www.p2pmania.it               -------------*
*------------ Based on the Bit Torrent Protocol made by Bram Cohen ------------*
*-------------              http://www.bittorrent.com             -------------*
*------------------------------------------------------------------------------*
*------------------------------------------------------------------------------*
*--   This program is free software; you can redistribute it and/or modify   --*
*--   it under the terms of the GNU General Public License as published by   --*
*--   the Free Software Foundation; either version 2 of the License, or      --*
*--   (at your option) any later version.                                    --*
*--                                                                          --*
*--   This program is distributed in the hope that it will be useful,        --*
*--   but WITHOUT ANY WARRANTY; without even the implied warranty of         --*
*--   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          --*
*--   GNU General Public License for more details.                           --*
*--                                                                          --*
*--   You should have received a copy of the GNU General Public License      --*
*--   along with this program; if not, write to the Free Software            --*
*-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA --*
*--                                                                          --*
*------------------------------------------------------------------------------*
*------              ï¿½2010 phpMyBitTorrent Development Team              ------*
*-----------               http://phpmybittorrent.com               -----------*
*------------------------------------------------------------------------------*
*-------------------   Saturday, JUN 27, 2009 1:05 AM   -----------------------*
*/
define('IN_PMBT'true);
require_once(
"include/config.php");
if (
$use_rsa) require_once("include/rsalib.php");
require_once(
"include/class.user.php");
if (
$use_rsa$rsa = New RSA($rsa_modulo$rsa_public$rsa_private);
$user = @new User($_COOKIE["btuser"]);

define("AUTH_PENDING",0);
define("AUTH_GRANTED",1);
define("AUTH_DENIED",2);
define("AUTH_NONE",3);
function 
hex_to_base32($hex) {
  
$b32_alpha_to_rfc3548_chars = array(
    
'0' => 'A',
    
'1' => 'B',
    
'2' => 'C',
    
'3' => 'D',
    
'4' => 'E',
    
'5' => 'F',
    
'6' => 'G',
    
'7' => 'H',
    
'8' => 'I',
    
'9' => 'J',
    
'a' => 'K',
    
'b' => 'L',
    
'c' => 'M',
    
'd' => 'N',
    
'e' => 'O',
    
'f' => 'P',
    
'g' => 'Q',
    
'h' => 'R',
    
'i' => 'S',
    
'j' => 'T',
    
'k' => 'U',
    
'l' => 'V',
    
'm' => 'W',
    
'n' => 'X',
    
'o' => 'Y',
    
'p' => 'Z',
    
'q' => '2',
    
'r' => '3',
    
's' => '4',
    
't' => '5',
    
'u' => '6',
    
'v' => '7'
  
);
  for (
$pos 0$pos strlen($hex); $pos += 10) {
    
$hs substr($hex,$pos,10);
    
$b32_alpha_part base_convert($hs,16,32);
    
$expected_b32_len strlen($hs) * 0.8;
    
$actual_b32_len strlen($b32_alpha_part);
    
$b32_padding_needed $expected_b32_len $actual_b32_len;
    for (
$i $b32_padding_needed$i 0$i--) {
      
$b32_alpha_part '0' $b32_alpha_part;
    }
    
$b32_alpha .= $b32_alpha_part;
  }
  for (
$i 0$i strlen($b32_alpha); $i++) {
    
$b32_rfc3548 .= $b32_alpha_to_rfc3548_chars[$b32_alpha[$i]];
  }
  return 
$b32_rfc3548;
}
function 
getauthstatus($torrent) {
        global 
$user$db$db_prefix;
        if (
$torrent["owner"] != 0) {
                
$sql "SELECT * FROM ".$db_prefix."_privacy_global WHERE master = '".$torrent["owner"]."' AND slave = '".$user->id."' LIMIT 1;";
                
$res $db->sql_query($sql);
                if (
$row $db->sql_fetchrow($res)) {
                        if (
$row["status"] == "whitelist") return AUTH_GRANTED;
                        elseif (
$row["status"] == "blacklistlist") return AUTH_DENIED;
                }
                
$sql "SELECT * FROM ".$db_prefix."_privacy_file WHERE torrent = '".$torrent["id"]."' AND slave = '".$user->id."' LIMIT 1;";
                
$res $db->sql_query($sql) or btsqlerror($sql);
                if (
$row $db->sql_fetchrow($res)) {
                        if (
$row["status"] == "granted") return AUTH_GRANTED;
                        elseif (
$row["status"] == "denied") return AUTH_DENIED;
                        return 
AUTH_PENDING;
                } else return 
AUTH_NONE;
        } else return 
AUTH_NONE;
}
function 
str_links($text){
$text preg_replace(
    array(
"/(\A|[^=\]'\"a-zA-Z0-9])((http|ftp|https|ftps|irc):\/\/[^<>\s]+)/i","/\[url=((http|ftp|https|ftps|irc):\/\/[^<>\s]+?)\]((\s|.)+?)\[\/url\]/i","/\[url\]((http|ftp|https|ftps|irc):\/\/[^<>\s]+?)\[\/url\]/i"),
    array(
"\\1","\\3",""), $text);

}
function 
error($string) {
        
OpenErrTable("Error");
        if (
is_array($string)) {
                echo 
_btalertmsg;
                echo 
"<UL>";
                foreach (
$string as $msg) {
                        echo 
"<LI>".$msg."</LI>";
                }
                echo 
"</UL>";
        } else {
                 echo 
"<p class=\"errortext\">".$string."</p>";
        }
        echo 
"<p class=\"errortext\">"._btgoback."</p>";
        
CloseErrTable();
        
ob_end_flush();
$db->sql_close();
die();

}

if (isset(
$btlanguage) AND is_readable("language/".$btlanguage.".php")) $language $btlanguage;
if (isset(
$bttheme) AND is_readable("themes/".$bttheme."/main.php")) $theme $bttheme;
if (
is_readable("language/$language.php"))
        include_once(
"language/$language.php");
else
        include_once(
"language/english.php");

if (
is_readable("themes/$theme/main.php")) {
        require_once(
"themes/$theme/main.php");
} else {
        die(
"You should not see this...");
}
if (
is_banned($user$reason)) {
echo 
"<meta http-equiv=\"refresh\" content=\"0;url=ban.php?reson=".urlencode($reason)."\">";        die();
}
if (
$user->user) {
        
//Update online user list
        
$pagename 'index.php';
        
$sqlupdate "UPDATE ".$db_prefix."_online_users SET last_action = NOW() WHERE id = ".$user->id.";";
        
$sqlinsert "INSERT INTO ".$db_prefix."_online_users VALUES ('".$user->id."','".addslashes($pagename)."', NOW(), NOW())";
        
$res $db->sql_query($sqlupdate);
        if (!
$db->sql_affectedrows($res)) $db->sql_query($sqlinsert);
}



switch (
$op) {
        case 
"check_username": {
        if (!
$user->userloginrequired("user",true);
        if( !isset( 
$_GET['username'] ) || empty( $_GET['username'] ) ){
        
error("No username specified!");
        }
        
// check for that username
        
$sql "SELECT COUNT(`id`) FROM `".$db_prefix."_users` WHERE `username` = '".$_GET['username']."'";
        
$res $db->sql_query($sql);
        
$num $db_sql_fetchfield$res0);
        if( 
$num != ){
        print(
"Username taken!");
        }
        
ob_end_flush();
$db->sql_close();
die();

        }
        case 
'getactive':{
$usql "SELECT id FROM ".$db_prefix."_online_users WHERE page='index.php' AND UNIX_TIMESTAMP(NOW()-last_action) < 600";
$ures $db->sql_query($usql)or print(mysql_error());
$utot $db->sql_numrows($ures);
print(
$utot);
                
ob_end_flush();
$db->sql_close();
die();

        }
        case 
'private__chat':{
$shoutannounce format_comment($shout_config['announce_ment'], falsetrue);
parse_smiles($shoutannounce);
                                echo 
"<div class=\"".$utc3."\" onMouseOver=\"this.className='over';\" onMouseOut=\"this.className='$utc3';\"><p class=\"shout\" bgcolor=\"#53B54F\">".$shoutannounce."</p></div>";
$utc2 $btback1;
//$db->sql_query("ALTER TABLE `torrent_shouts` ADD `id_to` INT( 10 ) NOT NULL DEFAULT '0';";
                
$sql "SELECT S.*, U.id as uid, U.can_do as can_do, U.donator AS donator, U.warned as warned, U.level as level, IF(U.name IS NULL, U.username, U.name) as user_name FROM ".$db_prefix."_shouts S LEFT JOIN ".$db_prefix."_users U ON S.user = U.id WHERE S.id_to ='".$to."' AND S.user = '".$user->id."' OR S.user='".$to."' AND S.id_to ='".$user->id."' ORDER BY posted DESC LIMIT ".$shout_config['shouts_to_show'].";";
                
$shoutres $db->sql_query($sql) or btsqlerror($sql);
$num2s $db->sql_numrows($shoutres);
                if (
$num2s 0) {
                        while (
$shout $db->sql_fetchrow($shoutres)) {
                        
$donator ='';
                        if(
$shout['donator'] == 'true')$donator ='<img src="http://www.bvlist.com/images/donator.gif" height="16" width="16" title="donator" alt="donator" />';

if (
$num2s 1)
{
$ucs++;
}
if(
$ucs%== 0)
{
$utc3 "od";
$utc2 $btback1;
}
else
{
$utc3 "even";
$utc2 $btback2;
}
$i++;
$caneditshout false;
$candeleteshout false;
if (
$user->moderator$caneditshout true;
if (
$user->moderator$candeleteshout true;
if (
$user->id == $shout['uid'] AND $shout_config['canedit_on'] =="yes"$caneditshout true;
if (
$user->id == $shout['uid'] AND $shout_config['candelete_on'] =="yes"$candeleteshout true;
                                echo 
"<p>";
                                
$warn "";
                                
$quote addslashes($shout["text"]);
                                
$text format_comment($shout["text"], falsetrue);
                                
parse_smiles($text);
                                if(
$shout["warned"] == "1"$warn '<img src="http://www.bvlist.com/images/warning.gif" alt="warned" />';
                                
$shout_time gmdate("Y-m-d H:i:s"sql_timestamp_to_unix_timestamp($shout['posted'])+(60 get_user_timezone($user->id)));
                                echo 
"<div class=\"".$utc3."\" onMouseOver=\"this.className='over';\" onMouseOut=\"this.className='$utc3';\"><p class=\"shout\" bgcolor=\"#53B54F\">";
                                if(
preg_match("/\/notice (.*)/",$text,$m)){
                                
$text preg_replace('/\/notice/','',$text);
                                }elseif(
preg_match("/\/me (.*)/",$text,$m)){
                                
$text preg_replace('/\/me/','',$text);
                                echo
"<b><span class=\"".$shout['level']."\" ondblclick=\"sndReq('op=private__chat&to=".$shout['uid']."', 'shout_out'); toggleprivate('shout_send','".$shout['uid']."');\"><font color=\"".getusercolor($shout["can_do"])."\">".htmlspecialchars($shout["user_name"])."</font></span></b>:";
                                }else{
                                echo (
$candeleteshout "<a ondblclick=\"if(confirm('Delete Shout?')==true)sndReq('op=take_delete_shout&shout=".$shout['id']."', 'shoutTD')\">" pic("drop.gif","",_btalt_edit) ."</a>" "").($caneditshout  "<a ondblclick=\"sndReq('op=edit_shout&shout=".$shout['id']."', 'shoutTD')\">" pic("edit.gif","",_btalt_edit) ."</a>" "").($shout_config['bbcode_on'] =="yes" "<a onclick=\"comment_smile('<<<@!1!@>>>',Shoutform.text);\"><img src=\"http://www.bvlist.com/images/bbcode/bbcode_quote.gif\" border=\"0\" alt=\"quote\"></a>":"")."[<span class=\"shout_time\">".$shout_time."</span>] <b><span class=\"".$shout['level']."\" ondblclick=\"sndReq('op=private__chat&to=".$shout['uid']."', 'shout_out'); toggleprivate('shout_send','".$shout['uid']."');\"><font color=\"".getusercolor($shout["can_do"])."\">".htmlspecialchars($shout["user_name"])."</font></span></b>".$warn.$donator.": ";
                                }
                                echo 
str_replace("\n","<br />",$text);
                                echo 
"</p>";
                                echo 
"<hr></div></p>\n";
                        }
                } else {
                        echo 
"<p align=\"center\">"._btnoshouts."</p>\n";
                }
                
$db->sql_freeresult($shoutres);
        
ob_end_flush();
$db->sql_close();
die();
        }
        case 
'activeusers':{
$sql "SELECT O.id AS id, O.page AS page, UNIX_TIMESTAMP(O.logged_in) AS logged_in, IF(U.name IS NULL, U.username, U.name) as name, U.warned AS warned, U.can_do as can_do, U.level AS level, U.Show_online AS Show_online, U.uploaded as uploaded, U.downloaded AS downloaded FROM ".$db_prefix."_online_users O LEFT JOIN ".$db_prefix."_users U ON O.id = U.id WHERE  O.page='index.php' AND UNIX_TIMESTAMP(NOW()-last_action) < 600 AND U.Show_online = true;";
$res $db->sql_query($sql);
$tot $db->sql_numrows($res);
$i 1;
$simple "\n<p>";
$advanced "<table border=\"1\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";
$advanced .= "<thead><tr><td><p align=\"center\"><b>"._btusername."</b></p></td><td><p align=\"center\"><b>"._btratio."</b></p></td><td><p align=\"center\"><b>"._btpagename."</b></p></td><td><p align=\"center\"><b>"._btloggedinfor."</b></p></td></tr></thead>\n<tbody>\n";
if (
$db->sql_numrows($res) == 0$simple .= _btnouseronline;
else {
        while (
$row $db->sql_fetchrow($res)) {

                
$simple .= "<a href=\"user.php?op=profile&id=".$row["id"]."\"><font color=\"".getusercolor($row["can_do"])."\">";
                
$simple .= htmlspecialchars($row["name"])."</font></a>";
                if (
$row["level"] == "premium"$simple .= pic("icon_premium.gif",'','Premium');
                elseif (
$row["level"] == "uploader"$simple .= pic("icon_uploader.gif",'','Uploader');
                elseif (
$row["level"] == "moderator"$simple .= pic("icon_moderator.gif",'','Moderator');
                elseif (
$row["level"] == "admin"$simple .= pic("icon_admin.gif",'','Admin');
                if(
$row["warned"] == "1"$simple .= '<img src="http://www.bvlist.com/images/warning.gif" alt="warned" />';
                if (
$i $tot$simple .= ", ";
                
$i++;

                
$advanced .= "<tr>";
                
$advanced .= "<td><p><a href=\"user.php?op=profile&id=".$row["id"]."\"><font color=\"".getusercolor($row["can_do"])."\">";
                
$advanced .= htmlspecialchars($row["name"])."</font></a>";
                if (
$row["level"] == "premium"$advanced .= pic("icon_premium.gif",'','holder');
                elseif (
$row["level"] == "moderator"$advanced .= pic("icon_moderator.gif",'','holder');
                elseif (
$row["level"] == "admin"$advanced .= pic("icon_admin.gif",'','holder');
                if(
$row["warned"] == "1"$advanced .= '<img src="http://www.bvlist.com/images/warning.gif" alt="warned" />';
                
$advanced .= "</p></td>";

                if (
$row["uploaded"] == AND $row["downloaded"] == 0$ratio "---";
                elseif (
$row["downloaded"] == 0$ratio "&infin;";
                else {
                        
$ratio $row["uploaded"]/$row["downloaded"];

                        if (
$ratio 0.1$ratio "<font color=\"#ff0000\">" number_format($ratio2) . "</font>";
                        elseif (
$ratio 0.2$ratio "<font color=\"#ee0000\">" number_format($ratio2) . "</font>";
                        elseif (
$ratio 0.3$ratio "<font color=\"#dd0000\">" number_format($ratio2) . "</font>";
                        elseif (
$ratio 0.4$ratio "<font color=\"#cc0000\">" number_format($ratio2) . "</font>";
                        elseif (
$ratio 0.5$ratio "<font color=\"#bb0000\">" number_format($ratio2) . "</font>";
                        elseif (
$ratio 0.6$ratio "<font color=\"#aa0000\">" number_format($ratio2) . "</font>";
                        elseif (
$ratio 0.7$ratio "<font color=\"#990000\">" number_format($ratio2) . "</font>";
                        elseif (
$ratio 0.8$ratio "<font color=\"#880000\">" number_format($ratio2) . "</font>";
                        elseif (
$ratio 0.9$ratio "<font color=\"#770000\">" number_format($ratio2) . "</font>";
                        elseif (
$ratio 1)   $ratio "<font color=\"#660000\">" number_format($ratio2) . "</font>";
                        else 
$ratio "<font color=\"#00FF00\">".  number_format($ratio2) . "</font>";
                }
                
$advanced .= "<td><p>".$ratio."</p></td>";
                
$advanced .= "<td><p>";
                if (
defined("_btpage_".$row["page"])) $advanced .= constant("_btpage_".$row["page"]);
                
$advanced .= "</p></td>";
                
$advanced .= "<td><p>".mkprettytime(time()-$row["logged_in"])."</p></td>";
                
$advanced .= "</tr>\n";    
        }
    
$simple .="<br><br><p>Legend: Admin <img src=\"themes/".$theme."/pics/icon_admin.gif\" alt=\"holder\">, Moderator<img src=\"themes/".$theme."/pics/icon_moderator.gif\" alt=\"holder\">, Premium<img src=\"themes/".$theme."/pics/icon_premium.gif\" alt=\"holder\"> </p><div style='font-size: 8pt;' align=\"center\"><a href=\"javascript:advanced();\">"._btadvancedmode."</a></div>";
        
$simple .= "";
}
$advanced .= "</tbody></table>\n";
$db->sql_freeresult($res);

//Simple mode
echo "<div id=\"users_simple\" class=\"show\">";
echo 
$simple;
echo 
"</div>";

//Advanced mode
echo "<div id=\"users_advanced\" class=\"hide\">";
echo 
$advanced;
echo 
"<br><p>Legend: Admin <img src=\"themes/".$theme."/pics/icon_admin.gif\" alt=\"holder\">, Moderator<img src=\"themes/".$theme."/pics/icon_moderator.gif\" alt=\"holder\">, Premium<img src=\"themes/".$theme."/pics/icon_premium.gif\" alt=\"holder\"> </p><div style='font-size: 8pt;' align=\"center\"><a href=\"javascript:simple();\">"._btsimplemode."</a></div>";
echo 
"</div>";
        
ob_end_flush();
$db->sql_close();
die();
        }
        case 
'edit_torrent_descr':{
        
// check for valid ID
        
if( !isset( $_GET['torrent'] ) || !is_numeric$_GET['torrent'] ) ){
        
error("Invalid torrent!" );
        }
        
// get the torrent description
        
$sql "SELECT `descr`, `owner` FROM `".$db_prefix."_torrents` WHERE `id` = '".$_GET['torrent']."'";
        
$res $db->sql_query($sql);
        
$descr $db->sql_fetchrow$res );
        
// make sure user is owner of torrent
        
if (!$descr['owner'] = $user->id OR !$user->moderator){
        
error("Invalid permissions!");
        }
        print( 
"<textarea enctype=\"multipart/form-data\" rows=\"10\" cols=\"80\" style=\"border:0px\" onblur=\"if(confirm('Save changes to torrent description?')==true){sndReq('op=save_torrent_descr&torrent=".$_GET['torrent']."&descr='+escape(this.value), 'descrTD".$_GET['torrent']."')}\">".$descr['descr']."</textarea>" );
        
ob_end_flush();
$db->sql_close();
die();

        }
        case 
'more_smiles':{
        if (!
$user->userloginrequired("user",true);
                
$sql "SELECT * FROM ".$db_prefix."_smiles GROUP BY file ORDER BY id ASC;";
        
$smile_res $db->sql_query($sql);
        if (
$db->sql_numrows($smile_res) > 0) {
                
$smile_rows $db->sql_fetchrowset($smile_res);
                echo 
"<p>";
                foreach (
$smile_rows as $smile) {
                        echo 
" <img src=\"smiles/".$smile["file"]."\" onclick=\"comment_smile('".$smile["code"]."',Shoutform.text);\" border=\"0\" alt=\"".$smile["alt"]."\">\n";
                }
                echo 
"</p>";
        }
        
$db->sql_freeresult($smile_res);

        
ob_end_flush();
$db->sql_close();
die();

        }
        case 
'view_shout':{
        if (!
$user->userloginrequired("user",true);
                if(
$user->can_shout == 'false'){
        echo 
"YouR shout rights have been banned";
        
ob_end_flush();
$db->sql_close();
die();
}
$utc3 "od";
$ucs =0;
$i 0;
$shoutannounce format_comment($shout_config['announce_ment'], falsetrue);
parse_smiles($shoutannounce);
                                echo 
"<div class=\"".$utc3."\" onMouseOver=\"this.className='over';\" onMouseOut=\"this.className='$utc3';\"><p class=\"shout\" bgcolor=\"#53B54F\">".$shoutannounce."</p></div>";

        if(isset(
$shotuser)){
        
$privateonly "WHERE S.id_to ='".$shotuser."' AND S.user = '".$user->id."' OR  S.id_to ='".$user->id."' AND S.user = '".$shotuser."'";
        }else{
        
$privateonly '';
        }
$utc2 $btback1;
                
$sql "SELECT S.*, U.id as uid, U.can_do as can_do, U.donator AS donator, U.warned as warned, U.level as level, IF(U.name IS NULL, U.username, U.name) as user_name FROM ".$db_prefix."_shouts S LEFT JOIN ".$db_prefix."_users U ON S.user = U.id ".$privateonly." ORDER BY posted DESC LIMIT ".$shout_config['shouts_to_show'].";";
                
$shoutres $db->sql_query($sql) or btsqlerror($sql);
$num2s $db->sql_numrows($shoutres);
                if (
$num2s 0) {
                        while (
$shout $db->sql_fetchrow($shoutres)) {
                        
$donator ='';
                        if(
$shout['donator'] == 'true')$donator ='<img src="http://www.bvlist.com/images/donator.gif" height="16" width="16" title="donator" alt="donator" />';

//$num2s = $db->sql_numrows($shoutres);
if ($num2s 1)
{
$ucs++;
}
if(
$ucs%== 0)
{
$utc3 "od";
$utc2 $btback1;
}
else
{
$utc3 "even";
$utc2 $btback2;
}
$i++;
$caneditshout false;
$candeleteshout false;
if (
$user->moderator$caneditshout true;
if (
$user->moderator$candeleteshout true;
if (
$user->id == $shout['uid'] AND $shout_config['canedit_on'] =="yes"$caneditshout true;
if (
$user->id == $shout['uid'] AND $shout_config['candelete_on'] =="yes"$candeleteshout true;
if (
$shout['id_to']!=0){
if (
$user->id == $shout['id_to'] OR $user->id == $shout['uid']){
                                echo 
"<p>";
                                
$warn "";
                                
$quote addslashes($shout["text"]);
                                
$text format_comment($shout["text"], falsetrue);
                                
parse_smiles($text);
                                if(
$shout["warned"] == "1"$warn '<img src="http://www.bvlist.com/images/warning.gif" alt="warned" />';
                                
$shout_time gmdate("Y-m-d H:i:s"sql_timestamp_to_unix_timestamp($shout['posted'])+(60 get_user_timezone($user->id)));
                                echo 
"<div class=\"".$utc3."\" onMouseOver=\"this.className='over';\" onMouseOut=\"this.className='$utc3';\"><p class=\"shout\" bgcolor=\"#53B54F\">";
                                if(
preg_match("/\/notice (.*)/",$text,$m)){
                                
$text preg_replace('/\/notice/','',$text);
                                }elseif(
preg_match("/\/me (.*)/",$text,$m)){
                                
$text preg_replace('/\/me/','',$text);
                                echo 
_btprivates."<b><span class=\"".$shout['level']."\" ondblclick=\"sndReq('op=private__chat&to=".$shout['uid']."', 'shout_out'); toggleprivate('shout_send','".$shout['uid']."');\"><font color=\"".getusercolor($shout["can_do"])."\">".htmlspecialchars($shout["user_name"])."</font></span></b>".$warn.$donator.":";
                                }else{
                                echo (
$candeleteshout "<a ondblclick=\"if(confirm('Delete Shout?')==true)sndReq('op=take_delete_shout&shout=".$shout['id']."', 'shoutTD')\">" pic("drop.gif","",_btalt_edit) ."</a>" "").($caneditshout  "<a ondblclick=\"sndReq('op=edit_shout&shout=".$shout['id']."', 'shoutTD')\">" pic("edit.gif","",_btalt_edit) ."</a>" "").($shout_config['bbcode_on'] =="yes" "<a onclick=\"comment_smile('<<<@!2!@>>>',Shoutform.text);\"><img src=\"http://www.bvlist.com/images/bbcode/bbcode_quote.gif\" border=\"0\" alt=\"quote\"></a>":"")."[<span class=\"shout_time\">".$shout_time."</span>]"._btprivates." <b><span class=\"".$shout['level']."\" ondblclick=\"sndReq('op=private__chat&to=".$shout['uid']."', 'shout_out'); toggleprivate('shout_send','".$shout['uid']."');\"><font color=\"".getusercolor($shout["can_do"])."\">".htmlspecialchars($shout["user_name"])."</font></span></b>".$warn.$donator.": ";
                                }
                                echo 
str_replace("\n","<br />",$text);
                                echo 
"</p>";
                                echo 
"<hr></div>\n";
                                }
                                }
                                if (
$shout['id_to']==0){
                                echo 
"<p>";
                                
$warn "";
                                
$quote addslashes($shout["text"]);
                                
$text format_comment($shout["text"], falsetrue);
                                
parse_smiles($text);
                                if(
$shout["warned"] == "1"$warn '<img src="http://www.bvlist.com/images/warning.gif" alt="warned" />';
                                
$shout_time gmdate("Y-m-d H:i:s"sql_timestamp_to_unix_timestamp($shout['posted'])+(60 get_user_timezone($user->id)));
                                echo 
"<div class=\"".$utc3."\" onMouseOver=\"this.className='over';\" onMouseOut=\"this.className='$utc3';\"><p class=\"shout\" bgcolor=\"#53B54F\">";
                                if(
preg_match("/\/notice (.*)/",$text,$m)){
                                
$text preg_replace('/\/notice/','',$text);
                                }elseif(
preg_match("/\/me (.*)/",$text,$m)){
                                
$text preg_replace('/\/me/','',$text);
                                echo
"<b><span class=\"".$shout['level']."\" ondblclick=\"sndReq('op=private__chat&to=".$shout['uid']."', 'shout_out'); toggleprivate('shout_send','".$shout['uid']."');\"><font color=\"".getusercolor($shout["can_do"])."\">".htmlspecialchars($shout["user_name"])."</font></span></b>:";
                                }else{
                                echo (
$candeleteshout "<a ondblclick=\"if(confirm('Delete Shout?')==true)sndReq('op=take_delete_shout&shout=".$shout['id']."', 'shoutTD')\">" pic("drop.gif","",_btalt_edit) ."</a>" "").($caneditshout  "<a ondblclick=\"sndReq('op=edit_shout&shout=".$shout['id']."', 'shoutTD')\">" pic("edit.gif","",_btalt_edit) ."</a>" "").($shout_config['bbcode_on'] =="yes" "<a onclick=\"comment_smile('<<<@!3!@>>>',Shoutform.text);\"><img src=\"http://www.bvlist.com/images/bbcode/bbcode_quote.gif\" border=\"0\" alt=\"quote\"></a>":"")."[<span class=\"shout_time\">".$shout_time."</span>] <b><span class=\"".$shout['level']."\" ondblclick=\"sndReq('op=private__chat&to=".$shout['uid']."', 'shout_out'); toggleprivate('shout_send','".$shout['uid']."');\"><font color=\"".getusercolor($shout["can_do"])."\">".htmlspecialchars($shout["user_name"])."</font></span></b>".$warn.$donator.": ";
                                }
                                echo 
str_replace("\n","<br />",$text);
                                echo 
"</p>";
                                echo 
"<hr></div>\n";
                                }
                        }
                } else {
                        echo 
"<p align=\"center\">"._btnoshouts."</p>\n";
                }
                
$db->sql_freeresult($shoutres);
ob_end_flush();
$db->sql_close();
die();

        }
        case 
'edit_shout':{
        
//echo $_GET['shout'];
        // check for valid ID
        
if( !isset( $_GET['shout'] ) || !is_numeric$_GET['shout'] ) ){
        
error("Invalid torrent!" );
        }
        
// get the torrent description
        
$sql "SELECT `text`, `user` FROM `".$db_prefix."_shouts` WHERE `id` = '".$_GET['shout']."'";
        
$res $db->sql_query($sql) or btsqlerror($sql);
        
$shout $db->sql_fetchrow$res );
        
// make sure user is owner of torrent
        
if ($shout['user'] != $user->id AND !$user->moderator){
        
error("Invalid permissions!");
        }
        print( 
"<form mane=\"shoutedit\" id=\"shoutedit\"><textarea name=\"textedit\" id=\"textedit\" enctype=\"multipart/form-data\" rows=\"1\" cols=\"80\" style=\"border:1px\" >".$shout['text']."</textarea><input type=\"button\" onclick=\"sndReq('op=take_edit_shout&shout=".$_GET['shout']."&shout_text='+escape(textedit.value), 'shoutTD')\" value=\""._btshoutnow."\" /><input type=\"button\" onclick=\"sndReq('op=take_edit_shout_cancel', 'shoutTD')\" value=\"Cancel\" /></form>" );
        
ob_end_flush();
$db->sql_close();
die();

        }
        case 
'edit_archive_shout':{
        
//echo $_GET['shout'];
        // check for valid ID
        
if( !isset( $_GET['shout'] ) || !is_numeric$_GET['shout'] ) ){
        
error("Invalid torrent!" );
        }
        
// get the torrent description
        
$sql "SELECT `text`, `user` FROM `".$db_prefix."_shouts` WHERE `id` = '".$_GET['shout']."'";
        
$res $db->sql_query($sql) or btsqlerror($sql);
        
$shout $db->sql_fetchrow$res );
        
// make sure user is owner of torrent
        
if ($shout['user'] != $user->id AND !$user->moderator){
        
error("Invalid permissions!");
        }
        print( 
"<form mane=\"shoutedit\" id=\"shoutedit\"><textarea name=\"textedit\" id=\"textedit\" enctype=\"multipart/form-data\" rows=\"1\"  style=\"border:1px\" >".$shout['text']."</textarea><br /><input type=\"button\" onclick=\"sndReq('op=take_edit_archive_shout&shout=".$_GET['shout']."&shout_text='+escape(textedit.value), 'shout_shell_".$_GET['shout']."')\" value=\""._btshoutnow."\" /><input type=\"button\" onclick=\"sndReq('op=take_edit_shout_cancel', 'shout_archive_edit_".$_GET['shout']."')\" value=\"Cancel\" /></form>" );
        
ob_end_flush();
$db->sql_close();
die();

        }
        case 
'take_delete_shout':{
        
$sql "SELECT `text`, `user` FROM `".$db_prefix."_shouts` WHERE `id` = '".$_GET['shout']."'";
        
$res $db->sql_query($sql) or btsqlerror($sql);
        
$shout $db->sql_fetchrow$res );
        
// make sure user is owner of torrent
        
if ($shout['user'] != $user->id AND !$user->moderator){
        
error("Invalid permissions!");
        }

        
$db->sql_query("DELETE FROM `".$db_prefix."_shouts` WHERE `".$db_prefix."_shouts`.`id`='".$_GET['shout']."' LIMIT 1");
        
ob_end_flush();
$db->sql_close();
die();

        }
        case 
'take_delete_archive_shout':{
        
$sql "SELECT `text`, `user` FROM `".$db_prefix."_shouts` WHERE `id` = '".$_GET['shout']."'";
        
$res $db->sql_query($sql) or btsqlerror($sql);
        
$shout $db->sql_fetchrow$res );
        
// make sure user is owner of torrent
        
if ($shout['user'] != $user->id AND !$user->moderator){
        
error("Invalid permissions!");
        }

        
$db->sql_query("DELETE FROM `".$db_prefix."_shouts` WHERE `".$db_prefix."_shouts`.`id`='".$_GET['shout']."' LIMIT 1");
        
ob_end_flush();
$db->sql_close();
die();

        }
        case 
'take_edit_shout_cancel':{
echo 
"";
        
ob_end_flush();
$db->sql_close();
die();

        }
        case 
'take_edit_shout':{
                  
//die($_SERVER['QUERY_STRING']);
         
$shout str_replace("op=take_edit_shout&shout=".$_GET['shout']."&shout_text=","",$_SERVER['QUERY_STRING']);
         
$shout str_replace("/amp2/","&",$shout);
         
$shout urldecode($shout);
         
$shout addslashes($shout);
                  
//die(urldecode($shout));
        
$sql "SELECT `text`, `user` FROM `".$db_prefix."_shouts` WHERE `id` = '".$_GET['shout']."'";
        
$res $db->sql_query($sql) or btsqlerror($sql);
        
$shout2 $db->sql_fetchrow$res );
        
// make sure user is owner of torrent
        
if ($shout2['user'] != $user->id AND !$user->moderator){
        
error("Invalid permissions!");
        }
        
$upd_sql "UPDATE `".$db_prefix."_shouts` SET `text` = '".$shout."' WHERE `id` = '".$_GET['shout']."'";
        
$db->sql_query($upd_sql) or btsqlerror($upd_sql);
        
//print( nl2br( stripslashes( $_GET['descr'] ) ) );
        
ob_end_flush();
$db->sql_close();
die();

        }
        case 
'take_edit_archive_shout':{
                  
//die($_SERVER['QUERY_STRING']);
         
$shout str_replace("op=take_edit_archive_shout&shout=".$_GET['shout']."&shout_text=","",$_SERVER['QUERY_STRING']);
         
$shout str_replace("/amp2/","&",$shout);
         
$shout urldecode($shout);
                                
$shout3 format_comment($shoutfalsetrue);
                                
parse_smiles($shout3);
                  
//die($shout);
        
$sql "SELECT `text`, `user` FROM `".$db_prefix."_shouts` WHERE `id` = '".$_GET['shout']."'";
        
$res $db->sql_query($sql) or btsqlerror($sql);
        
$shout2 $db->sql_fetchrow$res );
        
// make sure user is owner of torrent
        
if ($shout2['user'] != $user->id AND !$user->moderator){
        
error("Invalid permissions!");
        }
        
$upd_sql "UPDATE `".$db_prefix."_shouts` SET `text` = '".$shout."' WHERE `id` = '".$_GET['shout']."'";
        
//$db->sql_query($upd_sql) or btsqlerror($upd_sql);
        //print( nl2br( stripslashes( $_GET['descr'] ) ) );
echo"    <td class=\"alt1\" id=\"shout_shell_".$_GET['shout']."\" width=\"1%\" align=\"left\">

        <div id=\"shout_"
.$_GET['shout']."\">
        "
.$shout3."
        </div>
        <div id=\"shout_archive_edit_"
.$_GET['shout']."\">
        </div>

    </td>
"
;
        
ob_end_flush();
$db->sql_close();
die();

        }
        case 
'take_shout':{
        if(
$user->can_shout == 'false'){
        echo 
"YouR shout rights have been banned";
        
ob_end_flush();
$db->sql_close();
die();
}
        if (!
$user->userloginrequired("user",true);
         if (
strlen($_GET['text']) < 1) continue;
                  
//print($_SERVER['QUERY_STRING']);
                 
if(isset($sendto)){
                 
$resend "sendto=".$sendto."&";
                 
$sendtable ", id_to";
                 
$sendtorow ", '".$sendto."'";
                 }
                 else
                 {
                 
$resend '';
                 
$sendtable '';
                 
$sendtorow '';
                 }
                 
                 
         
$shout str_replace("op=take_shout&".$resend."text=","",$_SERVER['QUERY_STRING']);
         
$shout str_replace("/amp2/","&",$shout);
        
// die($shout);
        
$shout urldecode($shout);
if (
$shout == "/empty" && $user->admin) {
//$db->sql_query("TRUNCATE TABLE ".$db_prefix."_shouts");
$shout '/notice The modshout has been truncated by '.$user->name;
#die('The modshout has been truncated');
}
if (
$shout == "/prune" && $user->admin) {
$db->sql_query("TRUNCATE TABLE ".$db_prefix."_shouts");
$shout '/notice The modshout has been truncated by '.$user->name;
#die('The modshout has been truncated');
}
if (
$shout == "/pruneshout" && $user->admin) {
$db->sql_query("TRUNCATE TABLE ".$db_prefix."_shouts");
$shout '/notice The modshout has been truncated by '.$user->name;
#die('The modshout has been truncated');
}
if(
preg_match("/\/deletenotice/",$shout,$matches) && $user->admin) {
    
$db->sql_query("DELETE FROM ".$db_prefix."_shouts WHERE text LIKE '%/notice%'");
}
if(
preg_match("/\/unwarn (.*)/",$shout,$m) && $user->admin) {
$res $db->sql_query("SELECT * FROM ".$db_prefix."_users WHERE username ='".escape($m[1])."' OR name = '".escape($m[1])."' OR clean_username = '".escape(strtolower($m[1]))."';");
if (!
$res) echo "No Such user found";
$row $db->sql_fetchrow($res);
if(
$row[id]==|| $row[id] == "")echo "No Such user found";
if(
$row[id] == $user->id)
{
echo 
"You can not unWarn your self";
}
else{
     
$modcomment "[ " gmdate("Y-m-d H:i:s"time()) . " - WARN deleted by " getusername($user) . " ]\n" $row['modcomment'];
     
$added3 gmdate("Y-m-d H:i:s"time());
     
$msg3 "Your WARNNING was deleted by " $user->name "!";
     
$db->sql_query("INSERT INTO ".$db_prefix."_private_messages (sender, recipient, subject, text, sent) VALUES('"$user->id ."', '".$row[id]."', 'WARNNING',  '" $msg3 "', NOW())") or btsqlerror();
     
$db->sql_query("UPDATE ".$db_prefix."_users SET  modcomment='".$modcomment."', warned='0', warn_kapta='0', warn_hossz='0' WHERE id='".$row[id]."'") or die(mysql_error()); 
$shout "/notice $m[1]'s warnning has been removed";
}
}
if(
preg_match("/\/warn (.*)/",$shout,$m) && $user->admin) {
$res $db->sql_query("SELECT * FROM ".$db_prefix."_users WHERE username ='".escape($m[1])."' OR name = '".escape($m[1])."' OR clean_username = '".escape(strtolower($m[1]))."';");
if (!
$res) echo "No Such user found";
$row $db->sql_fetchrow($res);
if(
$row[id]==|| $row[id] == "")echo "No Such user found";
if(
$row[id] == $user->id)
{
echo 
"You can not Warn your self";
}
if(
$row[level] == 'admin')
{
echo 
"This level is expempt You Ars";
}else{
     
$weeks "unlimited time";
     
$warnlength = -1;
     
$added2 = (gmdate("Y-m-d H:i:s"time()));
     
$modcomment =  "" gmdate("Y-m-d H:i:s"time()) . " - WARNed for " $weeks "  by " getusername($user) . " - Reason: Shoutbox Warned " $row['modcomment']."";
     
$msg2 = ("You have been WARNNED by " getusername($user) . " for  " $weeks "  with reason: Shoutbox Warned.");
     
$db->sql_query("INSERT INTO ".$db_prefix."_private_messages (sender, recipient, subject, text, sent) VALUES('"$user->id ."', '".$row[id]."', 'WARNNING',  '" $msg2 "', NOW())") or die(mysql_error());
     
$db->sql_query("UPDATE ".$db_prefix."_users SET  modcomment='".$modcomment."', warned='1', warn_kapta='" strtotime(gmdate("Y-m-d H:i:s"time())) . "', warn_hossz='".$warnlength."' WHERE id= '".$row[id]."'") or die(mysql_error());
$shout "/notice $m[1] has been Warned!!";
}
}
if(
preg_match("/\/ban (.*) : (.*)/",$shout,$m) && $user->admin) {
//die($m[1] ." and ".$m[2]);
if($m[2] == "" || !isset($m[2]))die("no reason given");
$res $db->sql_query("SELECT * FROM ".$db_prefix."_users WHERE username ='".escape($m[1])."' OR name = '".escape($m[1])."' OR clean_username = '".escape(strtolower($m[1]))."';");
if (!
$res) echo "No Such user found";
$row $db->sql_fetchrow($res);
if(
$row[id]==|| $row[id] == "")echo "No Such user found";
if(
$row[id] == $user->id)
{
echo 
"You can not Ban your self";
}else{
                        
$sql "UPDATE ".$db_prefix."_users SET ban = 1, banreason = '".strip_tags($m[2])."' WHERE username = '".$row['username']." AND id NOT IN (1,2,3,4,5)';";
                        
$db->sql_query($sql) or btsqlerror($sql);
                        if(
$forumshare)forum_ban ($$row['username'], strip_tags($reason_user)); 
echo 
"banned ".$m[1]." test";
$shout "";
}
}
if(
preg_match("/\/unban (.*)/",$shout,$m) && $user->admin) {
$res $db->sql_query("SELECT * FROM ".$db_prefix."_users WHERE username ='".escape($m[1])."' OR name = '".escape($m[1])."' OR clean_username = '".escape(strtolower($m[1]))."';");
if (!
$res) echo "No Such user found";
$row $db->sql_fetchrow($res);
if(
$row[id]==|| $row[id] == "")echo "No Such user found";
if(
$row[id] == $user->id)
{
echo 
"You can not Warn your self";
}else{
                        
$db->sql_query("UPDATE ".$db_prefix."_users SET ban = 0, banreason = NULL WHERE id = '".$row['id']."';");
                        if(
$forumshare)forum_unban ($row['id']); 
echo 
"unbanned ".$m[1]." test";
$shout "";
}
}
if(
preg_match("/\/banshout (.*)/",$shout,$m) && $user->admin) {
$res $db->sql_query("SELECT * FROM ".$db_prefix."_users WHERE username ='".escape($m[1])."' OR name = '".escape($m[1])."' OR clean_username = '".escape(strtolower($m[1]))."';");
if (!
$res) echo "No Such user found";
$row $db->sql_fetchrow($res);
if(
$row[id]==|| $row[id] == "")echo "No Such user found";
if(
$row[id] == $user->id)
{
echo 
"You can not Warn your self";
}else{
                
$sql "UPDATE ".$db_prefix."_users SET can_shout = 'false' WHERE id = '".$row['id']."';";
                if (!
$db->sql_query($sql)) btsqlerror($sql);
}
}
if(
preg_match("/\/unbanshout (.*)/",$shout,$m) && $user->admin) {
$res $db->sql_query("SELECT * FROM ".$db_prefix."_users WHERE username ='".escape($m[1])."' OR name = '".escape($m[1])."' OR clean_username = '".escape(strtolower($m[1]))."';");
if (!
$res) echo "No Such user found";
$row $db->sql_fetchrow($res);
if(
$row[id]==|| $row[id] == "")echo "No Such user found";
if(
$row[id] == $user->id)
{
echo 
"You can not Warn your self";
}else{
                
$sql "UPDATE ".$db_prefix."_users SET can_shout = 'true' WHERE id = '".$row['id']."';";
                if (!
$db->sql_query($sql)) btsqlerror($sql);
$shout "/notice $m[1] has been Warned!!";
}
}
if(
preg_match("/\/slapuser (.*)/",$shout,$m)) {
$shout "/me Slaps $m[1] ";
}
if(
preg_match("/\/pmuser (.*);(.*)/",$shout,$m)) {
if(!
is_numeric($m[1])) $m[1] = getuser($m[1]);

echo 
"pm to userid{$m[1]} saying $m[2]";
     
$db->sql_query("INSERT INTO ".$db_prefix."_private_messages (sender, recipient, subject, text, sent) VALUES('"$user->id ."', '".$m[1]."', 'Quick Pm From shouts',  '" escape($m[2]) . "', NOW())") or die(mysql_error());
$shout '';
}
$shout preg_replace("/\/warn (.*)/","",$shout);
$shout preg_replace("/\/empty/",'',$shout);
$shout preg_replace("/\/ban (.*)/",'',$shout);
$shout preg_replace("/\/unban (.*)/",'',$shout);
$shout preg_replace("/\/warn (.*)/",'',$shout);
$shout preg_replace("/\/unwarn (.*)/",'',$shout);
//$shout = preg_replace("/\/help/",'',$shout);
$shout preg_replace("/\/prune/",'',$shout);
$shout preg_replace("/\/pruneshout/",'',$shout);
$shout preg_replace("/\/deletenotice/",'',$shout);
if (
$shout == '/help') {
//die("help set");
    
$shout "<<<@!4!@>>>";
echo 
format_comment($shoutfalsetrue);//die($shout);
//ob_end_flush();
//$db->sql_close();
//die();
$shout "";

}
if(!
$user->admin)
$shout preg_replace("/\/notice/",'',$shout); 
                if(
$shout_config['allow_url'] == "no")$shout str_links($shout);
                if (
$shout != "") {
                        
$sql "INSERT INTO ".$db_prefix."_shouts (user, text, posted".$sendtable.") VALUES ('".$user->id."', '".addslashes(strip_tags(urldecode($shout)))."', NOW()".$sendtorow.");";
                        
$db->sql_query($sql)or btsqlerror($sql);
                }
$shoutannounce format_comment($shout_config['announce_ment'], falsetrue);
parse_smiles($shoutannounce);
                                echo 
"<div class=\"".$utc3."\" onMouseOver=\"this.className='over';\" onMouseOut=\"this.className='$utc3';\"><p class=\"shout\" bgcolor=\"#53B54F\">".$shoutannounce."</p></div>";
                if(!isset(
$sendto))$sql "SELECT S.*, U.id as uid, U.can_do as can_do, U.donator AS donator, U.warned as warned, U.level as level, IF(U.name IS NULL, U.username, U.name) as user_name FROM ".$db_prefix."_shouts S LEFT JOIN ".$db_prefix."_users U ON S.user = U.id ORDER BY posted DESC LIMIT ".$shout_config['shouts_to_show'].";";
                else
                
$sql "SELECT S.*, U.id as uid, U.can_do as can_do, U.donator AS donator, U.warned as warned, U.warned as warned, U.level as level, IF(U.name IS NULL, U.username, U.name) as user_name FROM ".$db_prefix."_shouts S LEFT JOIN ".$db_prefix."_users U ON S.user = U.id WHERE S.id_to ='".$sendto."' AND S.user = '".$user->id."' OR S.id_to ='".$user->id."' AND S.user = '".$sendto."' ORDER BY posted DESC LIMIT ".$shout_config['shouts_to_show'].";";
                
                
$shoutres $db->sql_query($sql) or btsqlerror($sql);
$num2s $db->sql_numrows($shoutres);
                if (
$num2s 0) {
                        while (
$shout $db->sql_fetchrow($shoutres)) {
                        
$donator ='';
                        if(
$shout['donator'] == 'true')$donator ='<img src="http://www.bvlist.com/images/donator.gif" height="16" width="16" title="donator" alt="donator" />';
if (
$num2s 1)
{
$ucs++;
}
if(
$ucs%== 0)
{
$utc3 "od";
$utc2 $btback1;
}
else
{
$utc3 "even";
$utc2 $btback2;
}
$i++;
$caneditshout false;
$candeleteshout false;
if (
$user->moderator$caneditshout true;
if (
$user->moderator$candeleteshout true;
if (
$user->id == $shout['uid'] AND $shout_config['canedit_on'] =="yes"$caneditshout true;
if (
$user->id == $shout['uid'] AND $shout_config['candelete_on'] =="yes"$candeleteshout true;
if (
$shout['id_to']!=0){
if (
$user->id == $shout['id_to'] OR $user->id == $shout['uid']){
                                echo 
"<p>";
                                
$warn "";
                                
$quote addslashes($shout["text"]);
                                
$text format_comment($shout["text"], falsetrue);
                                
parse_smiles($text);
                                if(
preg_match("/\/staffmesage (.*)/",$text,$m) AND $user->moderator){
                                }
                                if(
$shout["warned"] == "1"$warn '<img src="http://www.bvlist.com/images/warning.gif" alt="warned" />';
                                
$shout_time gmdate("Y-m-d H:i:s"sql_timestamp_to_unix_timestamp($shout['posted'])+(60 get_user_timezone($user->id)));
                                echo 
"<div class=\"".$utc3."\" onMouseOver=\"this.className='over';\" onMouseOut=\"this.className='$utc3';\"><p class=\"shout\" bgcolor=\"#53B54F\">";
                                if(
preg_match("/\/notice (.*)/",$text,$m)){
                                
$text preg_replace('/\/notice/','',$text);
                                }elseif(
preg_match("/\/me (.*)/",$text,$m)){
                                
$text preg_replace('/\/me/','',$text);
                                echo 
_btprivates."<b><span class=\"".$shout['level']."\" ondblclick=\"sndReq('op=private__chat&to=".$shout['uid']."', 'shout_out'); toggleprivate('shout_send','".$shout['uid']."');\"><font color=\"".getusercolor($shout["can_do"])."\">".htmlspecialchars($shout["user_name"])."</font></span></b>".$warn.$donator.":";
                                }else{
                                echo (
$candeleteshout "<a ondblclick=\"if(confirm('Delete Shout?')==true)sndReq('op=take_delete_shout&shout=".$shout['id']."', 'shoutTD')\">" pic("drop.gif","",_btalt_edit) ."</a>" "").($caneditshout  "<a ondblclick=\"sndReq('op=edit_shout&shout=".$shout['id']."', 'shoutTD')\">" pic("edit.gif","",_btalt_edit) ."</a>" "").($shout_config['bbcode_on'] =="yes" "<a onclick=\"comment_smile('<<<@!5!@>>>',Shoutform.text);\"><img src=\"http://www.bvlist.com/images/bbcode/bbcode_quote.gif\" border=\"0\" alt=\"quote\"></a>":"")."[<span class=\"shout_time\">".$shout_time."</span>][PM] <b><span class=\"".$shout['level']."\" ondblclick=\"sndReq('op=private__chat&to=".$shout['uid']."', 'shout_out'); toggleprivate('shout_send','".$shout['uid']."');\"><font color=\"".getusercolor($shout["can_do"])."\">".htmlspecialchars($shout["user_name"])."</font></span></b>".$warn.$donator.": ";
                                }
                                echo 
str_replace("\n","<br />",$text);
                                echo 
"</p>";
                                echo 
"<hr></div>\n";
                                }
                                }
                                if (
$shout['id_to']==0){
                                echo 
"<p>";
                                
$warn "";
                                
$quote addslashes($shout["text"]);
                                
$text format_comment($shout["text"], falsetrue);
                                
parse_smiles($text);
                                if(
$shout["warned"] == "1"$warn '<img src="http://www.bvlist.com/images/warning.gif" alt="warned" />';
                                
$shout_time gmdate("Y-m-d H:i:s"sql_timestamp_to_unix_timestamp($shout['posted'])+(60 get_user_timezone($user->id)));
                                echo 
"<div class=\"".$utc3."\" onMouseOver=\"this.className='over';\" onMouseOut=\"this.className='$utc3';\"><p class=\"shout\" bgcolor=\"#53B54F\">";
                                if(
preg_match("/\/notice (.*)/",$text,$m)){
                                
$text preg_replace('/\/notice/','',$text);
                                }elseif(
preg_match("/\/me (.*)/",$text,$m)){
                                
$text preg_replace('/\/me/','',$text);
                                echo
"<b><span class=\"".$shout['level']."\" ondblclick=\"sndReq('op=private__chat&to=".$shout['uid']."', 'shout_out'); toggleprivate('shout_send','".$shout['uid']."');\"><font color=\"".getusercolor($shout["can_do"])."\">".htmlspecialchars($shout["user_name"])."</font></span></b>".$warn.$donator.":";
                                }else{
                                echo (
$candeleteshout "<a ondblclick=\"if(confirm('Delete Shout?')==true)sndReq('op=take_delete_shout&shout=".$shout['id']."', 'shoutTD')\">" pic("drop.gif","",_btalt_edit) ."</a>" "").($caneditshout  "<a ondblclick=\"sndReq('op=edit_shout&shout=".$shout['id']."', 'shoutTD')\">" pic("edit.gif","",_btalt_edit) ."</a>" "").($shout_config['bbcode_on'] =="yes" "<a onclick=\"comment_smile('<<<@!6!@>>>',Shoutform.text);\"><img src=\"http://www.bvlist.com/images/bbcode/bbcode_quote.gif\" border=\"0\" alt=\"quote\"></a>":"")."[<span class=\"shout_time\">".$shout_time."</span>] <b><span class=\"".$shout['level']."\" ondblclick=\"sndReq('op=private__chat&to=".$shout['uid']."', 'shout_out'); toggleprivate('shout_send','".$shout['uid']."');\"><font color=\"".getusercolor($shout["can_do"])."\">".htmlspecialchars($shout["user_name"])."</font></span></b>".$warn.$donator.": ";
                                }
                                echo 
str_replace("\n","<br />",$text);
                                echo 
"</p>";
                                echo 
"<hr></div>\n";
                                }
                        }
                } else {
                        echo 
"<p align=\"center\">"._btnoshouts."</p>\n";
                }
                
$db->sql_freeresult($shoutres);
ob_end_flush();
$db->sql_close();
die();

        }
        case 
'save_torrent_descr':{
        
// check for valid ID
        
if( !isset( $_GET['torrent'] ) || !is_numeric$_GET['torrent'] ) ){
        
error("Invalid torrent!" );
        }
        
// get the torrent description
        
$sql "SELECT `owner` FROM `".$db_prefix."_torrents` WHERE `id` = '".$_GET['torrent']."'";
        
$res $db->sql_query($sql);
        
$descr $db->sql_fetchrow$res );
        
// make sure user is owner of torrent
        
if (!$descr['owner'] = $user->id OR !$user->moderator){
        
error("Invalid permissions!");
        }
        
$descr addslashes($_GET['descr']);
        
$upd_sql "UPDATE `".$db_prefix."_torrents` SET `descr` = '".$descr."' WHERE `id` = '".$_GET['torrent']."'";
        
$db->sql_query($upd_sql) or btsqlerror($upd_sql);
        print( 
nl2brstripslashes$_GET['descr'] ) ) );
        
ob_end_flush();
$db->sql_close();
die();

        }
        case 
'change_banned_torrent':{
        if( !isset( 
$_GET['torrent'] ) || !is_numeric$_GET['torrent'] ) ){
        
error("Invalid torrent!" );
        }
        
// check is mod or higher
        
if(!$user->moderator){
        
error("Invalid permissions!" );
        }
        
// create the select
        
print( "<select onchange=\"if(confirm('Save banned state?')==true){sndReq('op=save_banned_torrent&torrent=".$_GET['torrent']."&banned='+this.selectedIndex, 'bannedChange')}\">
        <option value=\"\" selected=\"selected\">Banned?</option>
        <option value=\"1\">Yes</option>
        <option value=\"0\">No</option>
        </select>
        "
);
        
ob_end_flush();
$db->sql_close();
die();

        }
        case 
'save_banned_torrent':{
        
//check valid torrent
        
if( !isset( $_GET['torrent'] ) || !is_numeric$_GET['torrent'] ) ){
        
error("Invalid torrent!" );
        }
        
// check is mod or higher
        
if(!$user->moderator){
        
error("Invalid permissions!" );
        }
        
// convert $_GET['banned'] to 'yes' or 'no'
        
switch( $_GET['banned'] ){
        case 
$state 'yes'; break;
        case 
$state 'no'; break;
        default : 
$state 'no'; break;
        }
        
// do the SQL
        
$sql "UPDATE `".$db_prefix."_torrents` SET `banned` = '".$state."' WHERE `id` = '".$_GET['id']."' LIMIT 1";
        
$db->sql_query($sql) or btsqlerror($sql);
        
// print the outcome
        
print( $state );
        
ob_end_flush();
$db->sql_close();
die();

        }
        case 
'change_type_torrent':{
        
//check valid torrent
        
if( !isset( $_GET['torrent'] ) || !is_numeric$_GET['torrent'] ) ){
        print( 
"Invalid torrent!" );
        
ob_end_flush();
$db->sql_close();
die();

        }
        
// check is mod or higher
        
if(!$user->moderator){
        
error("Invalid permissions!" );
        
ob_end_flush();
$db->sql_close();
die();

        }
        
// create the select
        
print("<select onchange=\"if(confirm('Save type change?')==true){sndReq('op=save_type_torrent&torrent=".$_GET['torrent']."&type='+this.options[this.selectedIndex].value, 'catTD')}\">");
        
$cats catlist();
        print(
"<option value=\"\">(choose one)</option>\n");
        foreach (
$cats as $row){
        print(
"<option value=\"".$row["id"]."\">".htmlspecialchars($row["name"])."</option>\n");
        }
        print(
"</select>\n");
        
ob_end_flush();
$db->sql_close();
die();

        }
        case 
'save_type_torrent':{
        
//check valid torrent
        
if( !isset( $_GET['torrent'] ) || !is_numeric$_GET['torrent'] ) ){
        
error("Invalid torrent!" );
        
ob_end_flush();
$db->sql_close();
die();

        }
        
// check is mod or higher
        
if(!$user->moderator){
        
error("Invalid permissions!" );
        
ob_end_flush();
$db->sql_close();
die();

        }
        
// do the SQL
        
$sql "UPDATE `".$db_prefix."_torrents` SET `category` = '".$_GET['type']."' WHERE `id` = '".$_GET['torrent']."' LIMIT 1";
        
$db->sql_query($sql) or btsqlerror($sql);
        
// get the category in text form
        
$res "SELECT `name` FROM `".$db_prefix."_categories` WHERE `id` = '".$_GET['type']."'";
        
$cats_res $db->sql_query($res);
        
$cat $db->sql_fetchrow$cats_res);
        
// print the outcome
        
print( $cat['name'] );
        
ob_end_flush();
$db->sql_close();
die();

        }
        case 
'edit_torrent_comment':{
        
//check valid comment
        
if( !isset( $_GET['comment'] ) || !is_numeric$_GET['comment'] ) || !is_valid_id($_GET['comment']) ){
        
error("Invalid comment!" );
        
ob_end_flush();
$db->sql_close();
die();

        }
        
// get comment details
        
$sql "SELECT `user`, `text` FROM `".$db_prefix."_comments` WHERE `id` = '".$_GET['comment']."' LIMIT 1";
        
$res $db->sql_query($sql);
        
$details $db->sql_fetchrow$res );
        
// check owner
        
if(!$user->moderator || $user->id != $details['user'] ){
        
error("Invalid permissions!");
        
ob_end_flush();
$db->sql_close();
die();

        }
        print(
"<textarea rows=\"8\" cols=\"25\" onblur=\"if(confirm('Save changes?')==true){sndReq('op=save_torrent_comment&comment=".$_GET['comment']."&text='+escape(this.value), 'comment_".$_GET['comment']."')}\">".$details['text']."</textarea>");
        
ob_end_flush();
$db->sql_close();
die();

        }
        case 
'save_torrent_comment':{
        
//check valid comment
        
if( !isset( $_GET['comment'] ) || !is_numeric$_GET['comment'] ) || !is_valid_id($_GET['comment']) ){
        
error("Invalid comment!" );
        
ob_end_flush();
$db->sql_close();
die();

        }
        
// get comment details
        
$sql "SELECT `user` FROM `".$db_prefix."_comments` WHERE `id` = '".$_GET['comment']."' LIMIT 1";
        
$res $db->sql_query($sql);
        
$details $db->sql_fetchrow$res );
        
// check owner
        
if(!$user->moderator || $user->id != $details['user'] ){
        
error("Invalid permissions!");
        
ob_end_flush();
$db->sql_close();
die();

        }
        
// make sure not blank
        
if( !isset( $_GET['text'] ) || empty( $_GET['text'] ) ){
        
error("Body can not be empty!");
        
ob_end_flush();
$db->sql_close();
die();

        }
        
// save changes
        
$editedat get_date_time();
        
$db->sql_query("UPDATE `".$db_prefix."_comments` SET `text` = '".$_GET['text']."' WHERE `id` = '".$_GET['comment']."' LIMIT 1");
        
// print out the comment
        
print( nl2brstripslashes$_GET['text'] ) ) );
        
ob_end_flush();
$db->sql_close();
die();

        }
        case 
'delete_torrent_comment':{
        
$postid $_GET["postid"];
        if (!
$user->moderator || !is_valid_id($postid)){
        
error("Invalid operation!" );
        die;
        }
        
//------- Delete comment
        
$db->sql_query("DELETE FROM `".$db_prefix."_comments` WHERE id=$postid");
        
ob_end_flush();
$db->sql_close();
die();

        }
        case 
'close_view_details':{
        echo 
"<span id=ID" $_GET['torrent'] . "><p onclick=\"sndReq('op=view_details&torrent=" $_GET['torrent'] . "', 'ID" $_GET['torrent'] . "')\">".pic("plus.gif","",_btddetails)."</p></span>";
        
ob_end_flush();
$db->sql_close();
die();

        }
        case 
'close_view_details_page':{
        echo 
"";
        
ob_end_flush();
$db->sql_close();
die();

        }
        case 
'view_peers_page':{
        if(!
$user->user)error("your not allowed to view peers with out being loged in");
        if (
$_GET["tracker"] == "" AND $_GET["type"] != "link" AND $user->user) {
        
OpenTable(_btsource);
                if (!isset(
$_GET['torrent']) OR !is_numeric($_GET['torrent']) OR $_GET['torrent'] < 1error(_bterridnotset);
                
$password urldecode($password);
                
$sql "SELECT password FROM ".$db_prefix."_torrents WHERE id = '".$_GET['torrent']."' AND (password IS NULL OR password = '".$_GET["pass"]."') LIMIT 1;";
                
$res $db->sql_query($sql);
                if (
$db->sql_numrows($res) < 1) die(); //Password is wrong or not set
                
$db->sql_freeresult($res);
                
$i 0;
                
$tropen false;
                
$sql "SELECT P.id AS pid, P.peer_id AS peer_id, P.downloaded AS downloaded, P.uploaded AS uploaded, P.download_speed AS download_speed, P.upload_speed AS upload_speed, P.ip AS ip, P.real_ip AS real_ip, P.to_go AS to_go, P.seeder AS seeder, UNIX_TIMESTAMP(P.started) AS started_ts, UNIX_TIMESTAMP(P.last_action) AS last_action_ts, P.connectable AS connectable, P.client AS client, P.version AS clientversion, U.id AS uid, U.username AS username, U.name AS name, U.avatar AS avatar, U.can_do as can_do, U.level AS level, T.size AS torrent_size FROM ".$db_prefix."_peers P LEFT JOIN ".$db_prefix."_users U ON U.id = P.uid LEFT JOIN ".$db_prefix."_torrents T ON T.id = P.torrent WHERE P.torrent = '".$_GET['torrent']."' ORDER BY P.seeder ASC;";
                
$res $db->sql_query($sql) or print_r($db->sql_error());
                if (
$db->sql_numrows($res) < 1) break;

                echo 
"<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" class=\"peertable\">\n";
                while (
$row $db->sql_fetchrow($res)) {
                        if (!
$tropen) {
                                echo 
"<tr style=\"height:150px\">\n";
                                
$tropen true;
                        }
                        
#This box contains all data of the single user
                        
echo "<td width=\"1%\">\n";
                        echo 
"<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n";


                        echo 
"<tr>\n<td style=\"vertical-align:bottom\">";
                        
#This table contains peer attributes
                        
echo "<div align=\"center\">";
                        echo 
"<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" style=\"width:90px;\">";
                        echo 
"<tr>";

                        
#Column not yet assigned
                        
echo "<td width=\"20%\">";
                        echo 
"<p align=\"center\">";
                         
$perc sprintf("%.2f%%", (- ($row["to_go"] / $row["torrent_size"])) * 100);
                       
$s _btuploadedbts.": ".mksize($row["uploaded"])."<br />";
                        
$s .= _btdownloadedbts.": ".mksize($row["downloaded"])."<br />";
                        
$s .= _btpercent.": ".sprintf("%.2f%%", (- ($row["to_go"] / $row["torrent_size"])) * 100)."<br />";
                        
##RATIO START
                        
$s .= _btratio.": ";
                        if (
$row["downloaded"])
                                
$s .= number_format($row["uploaded"]/$row["downloaded"],2);
                        else
                                if (
$e["uploaded"])
                                        
$s .= number_format($row["uploaded"]/$row["torrent_size"],2);
                                else
                                        
$s .= "---";
                        
$s .= "<br />";
                        
$s .= _btuploadspeed": "mksize($row["upload_speed"])."/s<br />";
                        if (
$row["seeder"] == "no") {
                                if (
$row["download_speed"]) {
                                        
$edt_m = ($row["to_go"] / $row["download_speed"])/60//to minutes
                                        
$edt = ($edt_m 60)."m"//minutes
                                        
$edt_h floor($edt_m 60);
                                        if (
$edt_h>0$edt $edt_h."h ".$edt;
                                } else {
                                        
$edt "&infin;";
                                }
                                
$s .= _btdownloadspeed.": "mksize($row["download_speed"])."/s<br />";
                                
$s .= _btedt." ".$edt;
                        }
                        
##RATIO END
                        
echo help(pic("help.gif","",null),$s,_bttransfer);
                        echo 
"</p>\n";
                        echo 
"</td>\n";

                        
#Seeder or Leecher
                        
echo "<td width=\"20%\">";
                        echo 
"<p align=\"center\">";
                        if (
$row["seeder"] == "yes") echo pic("upload.gif","",_btseeder);
                        else echo 
pic("download.gif","",_btleecher);
                        echo 
"</p>\n";
                        echo 
"</td>\n";

                        
#Client Information
                        
echo "<td width=\"20%\">";
                        echo 
"<p align=\"center\">";
                        
$client $row["client"]." ".$row["clientversion"];
                        if (
$row["client"] != "" AND is_readable("client_icons/".$row["client"].".gif")) echo "<img src=\"client_icons/".htmlspecialchars($row["client"]).".gif\" alt=\"".$client."\" title=\"".$client."\" />";
                        else echo 
"<img src=\"client_icons/Unknown.gif\" alt=\"".$client."\" title=\"".$client."\" />";
                        echo 
"</p>\n";
                        echo 
"</td>\n";

                        
#Active or passive
                        
echo "<td width=\"20%\">";
                        echo 
"<p align=\"center\">";
                        if (
$row["connectable"] == "yes") echo pic("icon_active.gif","",constant("_btalt_icon_active.gif"));
                        else echo 
pic("icon_passive.gif","",constant("_btalt_icon_passive.gif"));
                        echo 
"</p>";
                        echo 
"</td>\n";

                        
#Time information
                        
echo "<td width=\"20%\">";
                        echo 
"<p align=\"center\">";
                        
$s _btconnected.": ".mkprettytime(time()-$row["started_ts"]);
                        
$s .= "<br />";
                        
$s .= _btidle.": ".mkprettytime(time()-$row["last_action_ts"]);
                        
help(pic("clock.gif"),$s,_dtimeconnected);
                        echo 
"</p>";
                        echo
"</td>\n";

                        echo 
"</tr>\n";
                        echo 
"</table>\n";
                        echo 
"</div>";
                        
#End of peer attributes

                        
echo "</td>\n";
                        echo 
"</tr>\n";

                        
#User name and avatar with profile link
                        
echo "<tr>\n";
                        echo 
"<td style=\"height:120px\"><p align=\"center\">";
                        if (!
$user->admin$ip preg_replace('/\.\d+$/'".xxx"long2ip($row["ip"]));
                        else 
$ip long2ip($row["ip"]);
                        if (
$row["uid"] != 0) {
                                
$usertxt "<a href=\"user.php?op=profile&id=".$row["uid"]."\" target=\"_top\">";
                                if (
$row["avatar"] == "blank.gif" OR !is_readable("avatars/".$row["avatar"])) { //No avatar
                                        
$usertxt .= pic("noavatar.png");
                                } else {
                                        
$usertxt .= "<img src=\"avatars/".$row["avatar"]."\" alt=\"".str_replace("**user**",($row["name"] == "") ? $row["username"]:$row["name"],_btalt_avatar)."\" border=\"0\">";
                                }
                                
$usertxt .= "<br />";
                                if (
$row["name"] != ""$usertxt .= "<font color=\"".getusercolor($row["can_do"])."\">".$row["name"]."</font>";
                                else 
$usertxt .= "<font color=\"".getusercolor($row["can_do"])."\">".$row["username"]."</font>";

                                if (
$row["level"] == "admin"$usertxt .= pic("icon_admin.gif");
                                elseif (
$row["level"] == "premium"$usertxt .= pic("icon_premium.gif");

                                
$usertxt .= "</a>";
                        } else {
                                
$usertxt pic("noavatar.png");
                                
$usertxt.= "<br />".$ip;
                        }
                        
$usertxt.="<table class=main border=0 width=100><tr><td style='padding: 0px; background-image: url(images/loadbarbg.gif); background-repeat: repeat-x'>";
                        
$pic "loadbargreen.gif";
                        
$width round($perc);
                        
$usertxt.="<img height=15 width=$width src=\"http://www.bvlist.com/images/$pic\" alt='$donatein%'><br><font size='1'color=\"white\"><center>$perc</center></font></td></tr></table>";
                        echo 
$usertxt;
                        echo 
"</p></td>";
                        echo 
"</tr>\n";
                        
#End of user name, avatar & link


                        
echo "</table>\n";
                        echo 
"</td>\n";
                        
#End of user box

                        
$i++;
                        if (
$i == 4) {
                                
$i 0;
                                echo 
"</tr>\n";
                                
$tropen false;
                        }
                }
                if (
$tropen) {
                        for (; 
$i<;$i++) echo "<td width=\"20%\"></td>\n";
                        echo 
"</tr>\n";
                }
                echo 
"</table>\n";

                
$db->sql_freeresult($res);
        
CloseTable();
}
        
ob_end_flush();
$db->sql_close();
die();

        }
        case 
'view_files_page':{
        if (isset(
$_GET["numfiles"]) AND  $_GET["numfiles"] <= 2$height 150;
        elseif (isset(
$_GET["numfiles"]) AND  $_GET["numfiles"] <= 2$height 300;
        else 
$height 450;
        
$id $_GET['torrent'];
        
$password= (isset($_GET["pass"]))? $_GET["pass"] : '';
        
        
OpenTable(_btfilelist);
                if (!isset(
$id) OR !is_numeric($id) OR $id 1error(_bterridnotset);
                
$password urldecode($password);
                
$sql "SELECT password FROM ".$db_prefix."_torrents WHERE id = '".$id."' AND (password IS NULL OR password = '".$password."') LIMIT 1;";
                
$res $db->sql_query($sql);
                if (
$db->sql_numrows($res) < 1) die(); //Password is wrong or not set
                
$db->sql_freeresult($res);

                
$sql "SELECT A.id as id, A.seeders, A.banned, A.leechers, A.info_hash, A.filename, UNIX_TIMESTAMP() - UNIX_TIMESTAMP(A.last_action) AS lastseed, A.numratings, A.name, IF(A.numratings < '$minvotes', NULL, ROUND(A.ratingsum / A.numratings, 1)) AS rating, A.save_as, A.descr, A.visible, A.size, A.added, A.views, A.downloaded, A.completed, A.type, A.numfiles, A.owner, A.ownertype, A.complaints, A.evidence, A.tracker, B.name AS cat_name, IF(C.name IS NULL, C.username, C.name) as ownername, A.tracker_update, IF(A.tracker_update>(sysdate()-INTERVAL 15 MINUTE), 0, 1) as can_tracker_update FROM ".$db_prefix."_torrents A LEFT JOIN ".$db_prefix."_categories B ON A.category = B.id LEFT JOIN ".$db_prefix."_users C ON A.owner = C.id WHERE A.id = '".$id."';";
                
$res $db->sql_query($sql) or btsqlerror($sql);
                
$torrent $db->sql_fetchrow($res);


                if (
can_download($user,$torrent)) {
                        
$can_access true;
                } else{
                        
$can_access false;
                }

                if(!
$fres $db->sql_query("SELECT * FROM ".$db_prefix."_files WHERE torrent = '".$torrent["id"]."' ORDER BY id")) btsqlerror("SELECT * FROM ".$db_prefix."_files WHERE torrent = '".$id."' ORDER BY id");
                echo 
"<table class=\"filelist\" align=\"middle\">\n<thead><tr><td width=\"4%\"><p></p></td><td width=\"24%\" align=\"center\"><p><b>"._btname."</b></p></td><td width=\"24%\" align=\"center\"><p><b>"._btsize."</b></p></td><td width=\"24%\" align=\"center\"><p><b>"._btmagnetlink."</b></p></td><td width=\"24%\" align=\"center\"><p><b>"._bted2klink."</b></p></td></tr>\n</thead>\n<tbody>";
                while (
$frow $db->sql_fetchrow($fres)) {
                        echo 
"<tr>";
                        
//File extension lookup
                        
preg_match('/^(?P<name>.*)\\.(?P<ext>[A-Za-z0-9]+)$/'$frow["filename"], $filename);
                        
$ext strtolower($filename["ext"]);
                        
$name $filename["name"];
                        if (!
file_exists("file_icons/".$ext.".png")) $ext "unknown";
                        echo 
"<td align\"right\"><p><img src=\"file_icons/".$ext.".png\" alt=\"Icon\"></p></td>";
                        echo 
"<td align=\"left\"><p>";
                        echo 
htmlspecialchars(str_replace(Array(".","_"),Array(" "," "),stripslashes($name))).".".$filename["ext"];
                        echo 
"</p></td>";
                        echo 
"<td align=\"center\"><p>" mksize($frow["size"]) . "</p></td>";
                        if(
$frow["magnet"] != "" AND $can_access) echo "<td align=\"center\"><p><a href=\"".stripslashes($frow["magnet"])."\">".pic("magnet_active.gif","",_btmagnetlinkdownload)."</a></p></td>";
                        else echo 
"<td align=\"center\">".pic("magnet_inactive.gif","",_btnomagnet)."</td>";
                        if(
$frow["ed2k"] != "" AND $can_access) echo "<td align=\"center\"><p><a href='".str_replace("'","",$frow["ed2k"])."'>".pic("ed2k_active.gif","",_bted2klinkdownload)."</a></p></td>";
                        else echo 
"<td align=\"center\"><p>".pic("ed2k_inactive.gif","",_btnoed2k)."</p></td>";
                        echo 
"</tr>\n";
                }
                echo 
"</tbody>\n</table>\n";
                
$db->sql_freeresult($fres);
        
CloseTable();
        
ob_end_flush();
$db->sql_close();
die();

        }
        case 
'view_rate_page':{
        
OpenTable(_btrate);
        echo 
"<table border=\"0\" cellpadding=\"2\" cellspacing=\"3\" width=\"100%\">";

        
#Star Rating
        
$s "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><p>";
        if (!isset(
$_GET["torrentrating"])) {
        if (
$minvotes 1) {
                
$s .= str_replace("__minvotes__"$minvotes_btminvotes);
                if (
$_GET['torrentnumratings'])
                        
$s .= _btonly $_GET['torrentnumratings'];
                else
                        
$s .= _btnone;
                
$s .= ")";
        } else
                
$s .= _btnovotes;
        } else {
        
$rpic ratingpic($_GET["torrentrating"]);
        
$s .= $rpic"(" $_GET["torrentrating"] . " "_btoo5 " "$_GET['torrentnumratings'] . " " .  _btvotestot.")";
        
$s .= "</p></td></tr><tr><td><p>";

        }
        
$s .= " ";
        
$ratings = array(
        
=> _btvot5,
        
=> _btvot4,
        
=> _btvot3,
        
=> _btvot2,
        
=> _btvot1
        
);
        if (
$_GET["owner"] != $user->id AND ($user->user)) {
        
$xres $db->sql_query("SELECT rating, added FROM ".$db_prefix."_ratings WHERE torrent = '".$_GET['torrent']."' AND user = '" $user->id."'") or btsqlerror("SELECT rating, added FROM ".$db_prefix."_ratings WHERE torrent = '".$_GET['torrent']."' AND user = '" $user->id."'");
        if (
$xrow $db->sql_fetchrow($xres))
                
$s .= "("._btyourate." <b>\"" $xrow["rating"] . " - ".$ratings[$xrow["rating"]]. "\"</b> "formatTimeStamp($xrow["added"]) . ")";
        else {
                
$s .= "<form method=\"post\" action=\"rate.php?op=star\"><input type=\"hidden\" name=\"id\" value=\"".$_GET['torrent']."\" />\n";
                
$s .= "<select name=\"rating\">\n";
                
$s .= "<option value=\"0\">("._btaddrating.")</option>\n";
                foreach (
$ratings as $k => $v) {
                        
$s .= "<option value=\"$k\">$k - $v</option>\n";
                }
                
$s .= "</select>\n";
                
$s .= "<input type=\"submit\" value=\""._btvotenow."\" />";
                
$s .= "</form>\n";
        }
        
$db->sql_freeresult($xres);
        } elseif (
$_GET["owner"] == $user->id AND ($user->user)) {
               
$s .= "("._btnovoteowntorrent.")";
        } else {
                
$s .= _btlogintorate;
        }


        
$s .= "</p></td></tr></table>";
        echo 
"<tr><td><p>"._btrating."</p></td><td>".$s."</td></tr>";

        
#Complaints
        
if ($torrent_complaints) {
        
#Separator
        
echo "<tr><td><HR SIZE=1 NOSHADE></td><td></td></tr>\n";

        
$complaintsql ="SELECT score FROM ".$db_prefix."_complaints WHERE torrent ='".$_GET['torrent']."' AND user = '".$user->id."';";
        
$complaintres $db->sql_query($complaintsql) or btsqlerror($complaintsql);
        
$scorerepl = Array("**p**","**n**");
        
$complaints explode(",",$_GET["complaints"]);
        
$btcomplaints getcomplaints();
        if (
$db->sql_numrows($complaintres) != 0) {
                list (
$score) = $db->sql_fetchrow($complaintres);
                
$complaint_form "<p>"._btcomplyouvoted."<b>".$btcomplaints[$score]."</b></p>";
                
$complaint_form.= "<p>".str_replace($scorerepl,$complaints,_btcomplatthemoment);
                
$complaint_form.= _btcomplexplain."</p>\n";
        } else {
                if (
$_GET["owner"] != $user->id AND $user->user) {
                        
$complaint_form "<form action=\"rate.php?op=complaint\" method=\"POST\"><INPUT type=\"hidden\" name=\"id\" value=\"".$_GET['torrent']."\">\n";
                        
$complaint_form.= "<p>"._btcomplaintform;
                        
$complaint_form.= _btcomplisay;
                        
$complaint_form.= "<select name=\"complaint\">";
                        foreach (
$btcomplaints as $k => $val$complaint_form.= "<option value=\"".$k."\">".$val."</option>";
                        
$complaint_form.= "</select><input type=\"submit\" value=\""._btsend."\"></p>\n</form>\n<br />\n";
                }
                
$complaint_form.= "<p>".str_replace($scorerepl,$complaints,_btcomplatthemoment);
                
$complaint_form.= _btcomplexplain."</p>";
        }
        echo 
"<tr><td valign=\"top\"><p>"._btcomplaints."</p></td><td>".$complaint_form."</td></tr>";
}

echo 
"</table>";
CloseTable();
        
ob_end_flush();
$db->sql_close();
die();

        }
        case 
'view_coments_page':{
        if(isset(
$_GET["amp;torrent"]))$_GET["torrent"] = $_GET["amp;torrent"];
        if(isset(
$_GET["amp;password"]))$_GET["password"] = $_GET["amp;password"];
OpenTable(_btcomments);
if (
$user->user) echo "<p align=center><a class=index href=takethankyou.php?id=".$_GET['torrent']."> <img src=./smiles/thankyou.gif border = 0></a><br> <h2><center></center></h2></p>";
#Read Comments
echo "<iframe src=\"frame.php?op=commentlist&amp;id=".$_GET['torrent']."&amp;password=".$_GET["password"]."\" width=\"100%\" height=\"200\" align=\"middle\" scrolling=\"yes\" marginwidth=\"0\" marginheight=\"0\"></iframe>\n";

#Post comment form, if user is logged in
if ($user->user) {


        echo 
"<table border=\"0\" cellpadding=\"2\" cellspacing=\"3\" width=\"100%\">\n";
        echo 
"<tr><td><HR SIZE=1 NOSHADE></td></tr>\n";
    echo 
"<tr><td><p>"._btaddcomment."</p></td><td>";
        echo 
"<form name=\"torrentComment\" method=\"POST\" action=\"comment.php\">";
        echo 
"<p><textarea rows=\"7\" cols=\"40\" name=\"comment\"></textarea><br>";

        
#Smiles
        
$sql "SELECT * FROM ".$db_prefix."_smiles GROUP BY file ORDER BY id ASC LIMIT 14;";
        
$smile_res $db->sql_query($sql);
        if (
$db->sql_numrows($smile_res) > 0) {
                
$smile_rows $db->sql_fetchrowset($smile_res);


                foreach (
$smile_rows as $smile) {
                        echo 
"<a onclick=\"comment_smile('".$smile["code"]."',torrentComment.comment);\"><img src=\"smiles/".$smile["file"]."\" border=\"0\" alt=\"".$smile["alt"]."\"></a>\n";
                }
        }
        
$db->sql_freeresult($smile_res);
        echo 
"</p>";
        echo 
"<p><input type=\"submit\" value=\""._btsend."\"></p>";
        echo 
"<input type=\"hidden\" name=\"id\" value=\"".$_GET['torrent']."\"><input type=\"hidden\" name=\"op\" value=\"add\">";
        echo 
"</form>";
        echo 
"</td></tr>";
        echo 
"</table>";
}
CloseTable();
        
ob_end_flush();
$db->sql_close();
die();

        }
        case 
'view_details_page':{
        if(isset(
$_GET["amp;torrent"]))$_GET['torrent'] = $_GET["amp;torrent"];
        echo
"<span id=CL" $_GET['torrent'] . ">";
        
OpenTable(_btinfo);


        
$sql "SELECT A.id as id,A.post_img,A.screen1,A.screen2,A.screen3,A.screen4, A.imdb, A.exeem, A.seeders, A.leechers, A.tot_peer, A.speed, A.info_hash, A.filename, A.banned, A.nuked, A.nukereason, A.password, UNIX_TIMESTAMP() - UNIX_TIMESTAMP(A.last_action) AS lastseed, A.numratings, A.name, IF(A.numratings < '".$minvotes."', NULL, ROUND(A.ratingsum / A.numratings, 1)) AS rating, A.save_as, A.descr, A.visible, A.size, A.plen, A.added, A.views, A.downloaded, A.completed, A.type, A.private, A.min_ratio, A.numfiles, A.owner, A.ownertype, A.complaints, A.evidence, A.tracker, A.tracker_list, A.dht as dht, A.md5sum as md5sum, A.uploader_host as user_host, B.name AS cat_name, IF(C.name IS NULL, C.username, C.name) as ownername, A.tracker_update, COUNT(S.status) as auths FROM ".$db_prefix."_torrents A LEFT JOIN ".$db_prefix."_categories B ON A.category = B.id LEFT JOIN ".$db_prefix."_users C ON A.owner = C.id LEFT JOIN ".$db_prefix."_privacy_file S ON S.torrent = A.id AND S.status = 'pending' WHERE A.id = '".$_GET['torrent']."' GROUP BY A.id LIMIT 1;";                $res $db->sql_query($sql) or btsqlerror($sql);
        
$torrent $db->sql_fetchrow($res);
        
$db->sql_freeresult($res);
        if (
can_download($user,$torrent)) {
        
$can_access true;
        } else {
        
$can_access false;
        }
$infohash_hex preg_replace_callback('/./s'"hex_esc"str_pad($torrent["info_hash"],20));
if (
$torrent["password"] != "" AND !$user->premium AND $password != $torrent["password"] AND (!$user->user OR $user->id != $torrent["owner"])) {
        
//Query user for Password
        
OpenTable(_btpassword);
        echo 
"<form action=\"details.php\" method=\"GET\">\n";
        echo 
"<input type=\"hidden\" name=\"id\" value=\"".$id."\" />";
        echo 
"<p align=\"center\">"._btpasswordquery."</p>";
        echo 
"<p align=\"center\">"._btpassword." <input type=\"password\" name=\"password\" value=\"\" /> <input type=\"submit\" value=\""._btsend."\" /></p>";

        if (
$password != "") { //Means that password is wrong
                
echo "<p>&nbsp</p>";
                echo 
"<p align=\"center\">"._btpasswordwrong."</p>";
        }
        echo 
"</form>\n";
        
CloseTable();
        
ob_end_flush();
$db->sql_close();
die();

}
if (
$torrent["type"] != "link") {
        if (
$torrent["tracker"] == ""$width "20%";
        else 
$width "33%";
        if (
$torrent["tracker"] == "") {
                
$complsql "SELECT SUM(T.size-P.to_go)/(COUNT(P.id)*T.size) as complete FROM ".$db_prefix."_torrents T, ".$db_prefix."_peers P WHERE T.id = '".$_GET['torrent']."' AND P.torrent = '".$_GET['torrent']."';";
                
$complres $db->sql_query($complsql) or bterror($complsql);
                list (
$completepercent) = $db->sql_fetchrow($complres);
                
$db->sql_freeresult($complres);
                if (
$torrent["leechers"] > AND $torrent["speed"] > 0) {
                        
$ro $torrent["seeders"]/$torrent["leechers"];
                        
$speed_leech = ($ro == 0) ? round($torrent["speed"]/$torrent["leechers"]) : min($torrent["speed"],round($torrent["speed"]*$ro));
                        
$edt_m = ($torrent["size"] / $speed_leech)/60//to minutes
                        
$edt = ($edt_m 60)."m"//minutes
                        
$edt_h floor($edt_m 60);
                        if (
$edt_h>0$edt $edt_h."h ".$edt;
                        
$speed_leech mksize($speed_leech)."/s";
                } else {
                        
$speed_leech "--";
                        
$edt "--";
                }
        }
}
#Torrent Name
echo "<table class=\"details\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" >\n";
echo 
"<tr><td><HR SIZE=1 NOSHADE></td></tr>\n";
echo 
"<tr><td class=\"torrentname\" align=\"center\">".htmlspecialchars(str_replace(Array(".","_"),Array(" "," "),stripslashes($torrent["name"])))."</td>";
echo 
"</tr>\n";
echo 
"<tr><td><HR SIZE=1 NOSHADE></td></tr>\n";
echo 
"</table>\n";
echo 
"<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\" class=\"details\">\n";
#Actions
$flag getauthstatus($torrent);
echo 
"<tr><td><p>"._btactions."</p></td><td><p>";
if (
$torrent["filename"] != "" AND $torrent["type"] != "link") {
        
$passlink "";
        if (
$torrent["password"] != ""$passlink "&amp;password=".urlencode($torrent["password"]);
        if (
$can_access) {
                echo 
pic("download.gif","download.php?id=".$_GET['torrent'].$passlink,_btalt_download);
                if (
$user->passkey != "")
                        
help(pic("export.gif","download.php?id=".$_GET['torrent'].$passlink."&amp;export=1"),_btexportexplain,_btexport);
        } elseif (
$user->user AND $torrent_global_privacy AND $torrent["owner"] != $user->id AND $torrent["ownertype"] != 2) {
                if (
$flag == AUTH_NONE) echo pic("lock_request.gif","details.php?op=authorization&amp;id=".$_GET['torrent'].$passlink,_btalt_lock_request);
                else echo 
pic("lock.gif",null,_btalt_lock);
        } elseif (
$download_level "user") {
                
help(pic("download.gif","",null),_btregistereddownload);
        } elseif (
$download_level "premium") {
                
help(pic("download.gif","",null),_btpremiumdownload);
        }
}
if (
$torrent["exeem"] != "" AND $can_access) echo pic("exeem.gif",$torrent["exeem"],_btalt_exeem);

if (
$torrent["dht"] == "yes") {
        echo 
pic("magnet.gif","magnet:?xt=urn:btih:".hex_to_base32($infohash_hex),_btalt_magnet);
}
if (
$user->moderator OR ($torrent["owner"] == $user->id AND $torrent["owner"] != "0")) echo pic("edit.gif","edit.php?id=".$torrent["id"],_btalt_edit).pic("drop.gif","edit.php?op=delete&amp;id=".$torrent["id"],_btalt_drop);
    
#Ban button
        
if ($user->moderator AND $torrent["banned"] != "yes"){
            echo 
pic("ban.png","edit.php?op=ban&amp;id=".$torrent["id"],_btban);
        }
    
#Scrape button
        
if ($user->moderator AND $torrent["tracker"] != ""){
             echo 
pic("refresh.png","scrape-external.php?id=".$torrent["id"]."&amp;tracker=".$torrent["tracker"]."&amp;back=yes",_btalt_scrape);
                   }

if (
$torrent["owner"] == $user->id AND $torrent_global_privacy AND $torrent["tracker"] == "") {
        if (
$torrent["auths"] > 0) echo pic("auth_pending.gif","mytorrents.php?op=displaytorrent&amp;id=".$torrent["id"],_btalt_auth_pending);
        else echo 
pic("auth_none.gif","mytorrents.php?op=displaytorrent&amp;id=".$torrent["id"],_btalt_auth_none);
}
echo 
"</p></td></tr>\n";

#Download As
#if ($torrent["save_as"] != "") {
#        echo "<tr><td><p>"._btdownloadas."</p></td><td><p>".$torrent["save_as"];
#        if ($torrent["md5sum"] != "") echo "<br />md5sum: ".$torrent["md5sum"];
#        echo "</p></td></tr>\n";
#}

#Download Authorization
if ($torrent_global_privacy AND $user->user AND !$user->premium AND $torrent_global_privacy AND $download_level=="user" AND $torrent["owner"] != $user->id AND $torrent["private"] == "true" AND $torrent["owner"] != 0) {
        echo 
"<tr><td><p>"._btauthstatus."</p></td>";
        switch (
$flag) {
                case 
AUTH_PENDING: {
                        echo 
"<td><p class=\"pending\">"._btdwauthpending."</p></td>";
                        break;
                }
                case 
AUTH_GRANTED: {
                        echo 
"<td><p class =\"granted\">"._btdwauthgranted."</p></td>";
                        break;
                }
                case 
AUTH_DENIED: {
                        echo 
"<td><p class =\"denied\">"._btdwauthdenied."<p></td>";
                        break;
                }
                case 
AUTH_NONE: {
                        echo 
"<td><p class =\"pending\">"._btdwauthnorequest."<p></td>";
                        break;
                }
        }
        echo 
"</tr>\n";
}


#Poster
if($torrent["post_img"] !=''){
echo 
"<tr><td><HR SIZE=1 NOSHADE></td><td><HR SIZE=1 NOSHADE></td></tr>\n";
echo 
"<tr><td><p>"._bt_poster."</p></td><td><img src=\"".$torrent["post_img"]."\" border=\"0\"></td></tr>\n";
echo 
"<tr><td><HR SIZE=1 NOSHADE></td><td><HR SIZE=1 NOSHADE></td></tr>\n";
}





#Size
echo "<tr><td><p>"._btdim."</p></td><td><p>".mksize($torrent["size"])."</p></td></tr>\n";
#Pieces
#if ($torrent["type"] != "link") echo "<tr><td><p>"._btpieces."</p></td><td><p>".str_replace(Array("**n**","**l**"),Array(intval(($torrent["size"]/$torrent["plen"])),mksize($torrent["plen"])),_btpiecesstring)."</p></td></tr>\n";
#Minimum Ratio
if ($torrent["private"] == "true" AND $torrent["min_ratio"] > "0.00" AND ($user->moderator OR $torrent["owner"] == $user->id))
        echo 
"<tr><td><p>"._btminratio."</p></td><td><p>".number_format($torrent["min_ratio"],2)."</p></td></tr>\n";
#Separator
echo "<tr><td><HR SIZE=1 NOSHADE></td><td></td></tr>\n";

#Description
$descript format_comment($torrent["descr"],false,true);
parse_smiles($descript);
#Description
if (!empty($torrent["descr"])) {//Sometimes massive upload Torrents do not have description
        
echo "<tr><td><p>"._btdescription."</p></td><td id=\"descrTD".$torrent['id']."\">".($user->admin "<a ondblclick=\"sndReq('op=edit_torrent_descr&torrent=".$torrent['id']."', 'descrTD".$torrent['id']."')\">" pic("edit.gif","",_btalt_edit) ."</a>" "");
        if (
$descript != strip_tags($descript)) //Means it is written in HTML
                
echo $descript;
        else
                echo 
"<p>".str_replace("\n","<br>",$descript)."</p>";
        echo 
"</td></tr>\n";
}



#Sceenshot
if($torrent["screen1"] !=''){
echo 
"<tr><td><HR SIZE=1 NOSHADE></td><td><HR SIZE=1 NOSHADE></td></tr>\n";
echo 
"<tr><td><p>"._bt_screensa."</p></td><td><a href=\"".stripslashes($torrent["screen1"])."\" title=\"Click For Full Size\"><img src=\"".stripslashes($torrent["screen1"])."\" width=\"300\" border=\"0\"><br>Click Here For Full Size</a></td></tr>\n";
echo 
"<tr><td><HR SIZE=1 NOSHADE></td><td><HR SIZE=1 NOSHADE></td></tr>\n";
}
if(
$torrent["screen2"] !=''){
echo 
"<tr><td><HR SIZE=1 NOSHADE></td><td><HR SIZE=1 NOSHADE></td></tr>\n";
echo 
"<tr><td><p>"._bt_screensb."</p></td><td><a href=\"".stripslashes($torrent["screen2"])."\" title=\"Click For Full Size\"><img src=\"".stripslashes($torrent["screen2"])."\" width=\"300\" border=\"0\"><br>Click Here For Full Size</a></td></tr>\n";
echo 
"<tr><td><HR SIZE=1 NOSHADE></td><td><HR SIZE=1 NOSHADE></td></tr>\n";
}
if(
$torrent["screen3"] !=''){
echo 
"<tr><td><HR SIZE=1 NOSHADE></td><td><HR SIZE=1 NOSHADE></td></tr>\n";
echo 
"<tr><td><p>"._bt_screensc."</p></td><td><a href=\"".stripslashes($torrent["screen3"])."\" title=\"Click For Full Size\"><img src=\"".stripslashes($torrent["screen3"])."\" width=\"300\" border=\"0\"><br>Click Here For Full Size</a></td></tr>\n";
echo 
"<tr><td><HR SIZE=1 NOSHADE></td><td><HR SIZE=1 NOSHADE></td></tr>\n";
}
if(
$torrent["screen4"] !=''){
echo 
"<tr><td><HR SIZE=1 NOSHADE></td><td><HR SIZE=1 NOSHADE></td></tr>\n";
echo 
"<tr><td><p>"._bt_screensd."</p></td><td><a href=\"".stripslashes($torrent["screen4"])."\" title=\"Click For Full Size\"><img src=\"".stripslashes($torrent["screen4"])."\" width=\"300\" border=\"0\"><br>Click Here For Full Size</a></td></tr>\n";
echo 
"<tr><td><HR SIZE=1 NOSHADE></td><td><HR SIZE=1 NOSHADE></td></tr>\n";
}


if (
$torrent["imdb"]=='') {
print(
"<tr><td><p>IMDB:</p></td><td>No Imdb Link Available</td></tr>");
}else{
print(
"<tr><td><p>IMDB:</p></td><td><a href=".$torrent['imdb']." target=_blank><img src=images/imdb.png border=0 ></a></tr></tr>\n");

}






if (
$torrent["tube"]=='') { 
print (
"<tr><td><p>Youtube:</p</td><td><img src=/images/novideo2.jpg border=\"0\" width=\"200\" height=\"164\" ></td></tr>");
}else{
print (
"<tr><td><p>Youtube:</p></td><td><object type=\"application/x-shockwave-flash\" data="str_replace("watch?v=""v/"htmlspecialchars($torrent["tube"])) ." width=\"400\" height=\"326\"><param name=\"movie\" value='"str_replace("watch?v=""v/"htmlspecialchars($torrent["tube"])) ."' /><param name=\"FlashVars\" value=\"playerMode=embedded\" /></object></td></tr>");  

}
#Info Hash & Tracker
if ($torrent["type"] != "link") {
        
#Separator
        
echo "<tr><td><HR SIZE=1 NOSHADE></td><td></td></tr>\n";

        echo 
"<tr><td><p>";
        
help(pic("help.gif"),_btinfohashhelp,_btinfohash);
        echo 
_btinfohash."</p></td>";
        echo 
"<td><p>".$infohash_hex."</p></td></tr>\n";
echo 
"<tr><td><HR SIZE=1 NOSHADE></td><td></td></tr>\n";
        
##Single Tracker
        
echo "<tr><td><p>"._bttracker."</p></td><td><p>";
        if (
$torrent["tracker"] == "") {
                echo 
$siteurl;
        } else {
                echo 
"<a href=\"".preg_replace('/announce.*$/'''$torrent["tracker"])."\">".$torrent["tracker"]."</a>";
        }
        echo 
"</p></td></tr>\n";
        if (
$torrent["tracker_list"] != "") {
                echo 
"<tr><td><HR SIZE=1 NOSHADE></td><td></td></tr>\n";
        echo 
"<tr><td><p>"._bttrackers."</p></td><td>\n";
                
$trackers explode("\n\n",$torrent["tracker_list"]);
                for (
$i 0$i count($trackers); $i++) {
                        
$trackers[$i] = explode("\n",$trackers[$i]);

                        echo 
"<p>".str_replace("*",$i,_bttrackergroup)."\n";
                        echo 
"<ul>\n";
                        for (
$j 0$j count($trackers[$i]); $j++) {
                                echo 
"<li>";
                                
$pos strpos($trackers[$i][$j], $announce_url);
                                if (
$pos !== false) echo "<p>".$siteurl."</p>\n";
                                else echo 
"<p><a href=\"".preg_replace('/announce.*$/'''$trackers[$i][$j])."\">".$trackers[$i][$j]."</a></p>";
                                echo 
"</li>\n";
                        }
                        echo 
"</ul>\n";
                        echo 
"<br />\n";

                }
                unset(
$trackers);
                echo 
"</td></tr>\n";
        }

}

#Separator
echo "<tr><td><HR SIZE=1 NOSHADE></td><td></td></tr>\n";


#Category
echo "<tr><td><p>"._bttype."</p></td><td id=\"catTD\"><p ondblclick=\"sndReq('op=change_type_torrent&torrent=".$torrent["id"]."', 'catTD')\">".$torrent["cat_name"]."</p></td></tr>\n";

#File number
echo "<tr><td><p>"._btnfile."</p></td><td><p>".$torrent["numfiles"]."</p></td></tr>\n";

#Uploaded by
echo "<tr><td><p>"._btuppedby."</p></td><td><p>";
switch (
$torrent["ownertype"]) {
        case 
0: {
                echo 
"<a href=\"user.php?op=profile&amp;id=".$torrent["owner"]."\">".htmlspecialchars($torrent["ownername"])."</a>";
                if (
$user->admin) echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[".htmlspecialchars($torrent["user_host"])."]";
                break;
        }
        case 
1: {
                if (
$user->moderator) echo "<a href=\"user.php?op=profile&amp;id=".$torrent["owner"]."\">".htmlspecialchars($torrent["ownername"])."</a>";
                else echo 
"<i>"._btunknown."</i>";
                if (
$user->admin) echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[".htmlspecialchars($torrent["user_host"])."]";
        }
        case 
2: {
                if (
$user->admin) echo "[".htmlspecialchars($torrent["user_host"])."]";
                else echo 
"<i>"._btunknown."</i>";
        }
}
echo 
"</p></td></tr>\n";

#Last Seed
if($torrent["type"]!="link" AND $torrent["tracker"] == ""){
        echo 
"<tr><td><p>"._btlastseeder."</p></td><td><p>".mkprettytime($torrent["lastseed"]) ." "._btago."</p></td></tr>\n";
#Separator
echo "<tr><td><HR SIZE=1 NOSHADE></td><td></td></tr>\n";
#snatched
if ($user->user) echo "<tr><td><p>ΠληÏοφοÏίες Î›Î®ÏˆÎ·Ï‚/Αποστολής: </font></p></td><td><p><a href=\"viewsnatches.php?id=" $_GET['torrent'] . "\"><font ><h3>           Î Ïοβολή!</h3></font></a>";
                  
}
print(
"<tr><td><p>Καμμένο Torrent:</p></td><td><p>".$torrent["nuked"]."</p></td></tr>\n");
if (
$torrent["nuked"] == "Îαί")print("<tr><td><p>Λόγος:</td><td><p>".$torrent["nukereason"]."</p></td></tr>\n");
if (
$torrent["nuked"] == "Όχι")print("<tr><td><p>Λόγος:</td><td><p>".$torrent["nukereason"]."</p></td></tr>\n");
echo 
"<tr><td><HR SIZE=1 NOSHADE></td><td></td></tr>\n";
#reseed
if ($user->user)echo "<tr><td><p>ΠαÏάκληση Î•Ï€Î±Î½Î±Ï„Ïοφοδοσίας:</p></td><td><p><a href=\"re-seed.php?id=" $_GET['torrent'] . "\"><font ><h3>           Î•Ï€Î±Î½Î±Ï„Ïοφοδοσία Î¤ÏŽÏα!</h3></font></a>";

#Separator
echo "<tr><td><HR SIZE=1 NOSHADE></td><td></td></tr>\n";


#Views
echo "<tr><td><p>"._btview."</p></td><td><p>".$torrent["views"]."</p></td></tr>\n";

#Downloads
echo "<tr><td><p>"._btdownloaded."</p></td><td><p>".$torrent["downloaded"]."</p></td></tr>\n";

#Completed
echo "<tr><td><p>"._btsnatch."</p></td><td><p>".$torrent["completed"]."</p></td></tr>\n";

if (
$user->user AND $torrent["password"] != "" AND ($user->id == $torrent["owner"] OR $user->premium)) {
        
#Separator
        
echo "<tr><td><HR SIZE=1 NOSHADE></td><td></td></tr>\n";

        echo 
"<tr><td><p>"._btpassword."</p></td><td><p>".htmlspecialchars($torrent["password"])."</p></td></tr>\n";
        echo 
"<tr><td><p>"._btdirectlink."</p></td><td><p>".$siteurl."/details.php?id=".$_GET['torrent']."&amp;password=".urlencode($password)."</p></td></tr>\n";
}

$sql "SELECT C.user AS id, IF(U.name IS NULL, U.username, U.name) AS username, U.level FROM torrent_download_completed C, torrent_users U WHERE C.user = U.id AND C.torrent = '".$_GET['torrent']."';";
$comres $db->sql_query($sql);

if (
$db->sql_numrows($comres) > 0) {
        
#Separator
        
echo "<tr><td><HR SIZE=1 NOSHADE></td><td></td></tr>\n";

        
$lst = Array();
        while (
$comrow $db->sql_fetchrow($comres)) {
                
$img = ($comrow["level"] != "user") ? pic("icon_".$comrow["level"].".gif") : "";
                
$lst[] = "<a href=\"user.php?op=profile&amp;id=".$comrow["id"]."\">".$comrow["username"].$img."</a>";
        }

        echo 
"<tr><td><p>"._btcompletedby."</p></td><td><p>".implode(", ",$lst)."</p></td></tr>\n";
}

$db->sql_freeresult($comres);
echo 
"</table>";
CloseTable();
echo
"</span>";
        
ob_end_flush();
$db->sql_close();
die();

        }
        case 
'view_nfo_page':{
        
$nfo "";
        
$nf fopen("torrent/".$_GET['torrent'].".nfo","rb");
        while (!
feof($nf)) $nfo .= fread($nf,100);
        
fclose($nf);
        
OpenTable("NFO");
        echo 
"<p class=\"nfo\">".nl2br(str_replace(" ","&nbsp;",htmlentities($nfo)))."</p>";
        
CloseTable();
        unset(
$nfo);
        
ob_end_flush();
$db->sql_close();
die();
        }
        case 
'view_details':{

        echo
"<span id=CL" $_GET['torrent'] . "><span id=ID2" $_GET['torrent'] . "><p onclick=\"sndReq('op=close_view_details&torrent=" $_GET['torrent'] . "', 'CL" $_GET['torrent'] . "')\">".pic("minus.gif","",_btddetails)."</p></span>";
        
$sql "SELECT A.id as id, A.exeem, A.seeders, A.leechers, A.tot_peer, A.speed, A.info_hash, A.filename, A.banned, A.nuked, A.nukereason, A.password, UNIX_TIMESTAMP() - UNIX_TIMESTAMP(A.last_action) AS lastseed, A.numratings, A.name, IF(A.numratings < '".$minvotes."', NULL, ROUND(A.ratingsum / A.numratings, 1)) AS rating, A.save_as, A.descr, A.visible, A.size, A.plen, A.added, A.views, A.downloaded, A.completed, A.type, A.private, A.min_ratio, A.numfiles, A.owner, A.ownertype, A.complaints, A.evidence, A.tracker, A.tracker_list, A.dht as dht, A.md5sum as md5sum, A.uploader_host as user_host, B.name AS cat_name, IF(C.name IS NULL, C.username, C.name) as ownername, A.tracker_update, COUNT(S.status) as auths FROM ".$db_prefix."_torrents A LEFT JOIN ".$db_prefix."_categories B ON A.category = B.id LEFT JOIN ".$db_prefix."_users C ON A.owner = C.id LEFT JOIN ".$db_prefix."_privacy_file S ON S.torrent = A.id AND S.status = 'pending' WHERE A.id = '".$_GET['torrent']."' GROUP BY A.id LIMIT 1;";
        
$res $db->sql_query($sql) or btsqlerror($sql);
        
$torrent $db->sql_fetchrow($res);
        
$db->sql_freeresult($res);
        if (
can_download($user,$torrent)) {
        
$can_access true;
        } else {
        
$can_access false;
        }
$infohash_hex preg_replace_callback('/./s'"hex_esc"str_pad($torrent["info_hash"],20));
if (
$torrent["password"] != "" AND !$user->premium AND $password != $torrent["password"] AND (!$user->user OR $user->id != $torrent["owner"])) {
//Query user for Password
        
OpenTable(_btpassword);
        echo 
"<form action=\"details.php\" method=\"GET\">\n";
        echo 
"<input type=\"hidden\" name=\"id\" value=\"".$id."\" />";
        echo 
"<p align=\"center\">"._btpasswordquery."</p>";
        echo 
"<p align=\"center\">"._btpassword." <input type=\"password\" name=\"password\" value=\"\" /> <input type=\"submit\" value=\""._btsend."\" /></p>";

        if (
$password != "") { //Means that password is wrong
                
echo "<p>&nbsp</p>";
                echo 
"<p align=\"center\">"._btpasswordwrong."</p>";
        }
        echo 
"</form>\n";
        
CloseTable();
        break;
}
        if (
$torrent["tracker"] == ""$width "20%";
        else 
$width "33%";
        if (
$torrent["tracker"] == "") {
                
$complsql "SELECT SUM(T.size-P.to_go)/(COUNT(P.id)*T.size) as complete FROM ".$db_prefix."_torrents T, ".$db_prefix."_peers P WHERE T.id = '".$_GET['torrent']."' AND P.torrent = '".$_GET['torrent']."';";
                
$complres $db->sql_query($complsql) or bterror($complsql);
                list (
$completepercent) = $db->sql_fetchrow($complres);
                
$db->sql_freeresult($complres);
                if (
$torrent["leechers"] > AND $torrent["speed"] > 0) {
                        
$ro $torrent["seeders"]/$torrent["leechers"];
                        
$speed_leech = ($ro == 0) ? round($torrent["speed"]/$torrent["leechers"]) : min($torrent["speed"],round($torrent["speed"]*$ro));
                        
$edt_m = ($torrent["size"] / $speed_leech)/60//to minutes
                        
$edt = ($edt_m 60)."m"//minutes
                        
$edt_h floor($edt_m 60);
                        if (
$edt_h>0$edt $edt_h."h ".$edt;
                        
$speed_leech mksize($speed_leech)."/s";
                } else {
                        
$speed_leech "--";
                        
$edt "--";
                }
        }
#Torrent Name
echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"details\">\n";
echo 
"<tr><td><HR SIZE=1 NOSHADE></td></tr>\n";
echo 
"<tr><td class=\"torrentname\" align=\"center\">".htmlspecialchars(str_replace(Array(".","_"),Array(" "," "),stripslashes($torrent["name"])))."</td>";
echo 
"</tr>\n";
echo 
"<tr><td><HR SIZE=1 NOSHADE></td></tr>\n";
echo 
"</table>\n";
echo 
"<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\" class=\"details\">\n";
#Actions
$flag getauthstatus($torrent);
echo 
"<tr><td><p>"._btactions."</p></td><td><p>";
if (
$torrent["filename"] != "" AND $torrent["type"] != "link") {
        
$passlink "";
        if (
$torrent["password"] != ""$passlink "&amp;password=".urlencode($torrent["password"]);
        if (
$can_access) {
                echo 
pic("download.gif","download.php?id=".$_GET['torrent'].$passlink,_btalt_download);
                if (
$user->passkey != "")
                        
help(pic("export.gif","download.php?id=".$_GET['torrent'].$passlink."&amp;export=1"),_btexportexplain,_btexport);
        } elseif (
$user->user AND $torrent_global_privacy AND $torrent["owner"] != $user->id AND $torrent["ownertype"] != 2) {
                if (
$flag == AUTH_NONE) echo pic("lock_request.gif","details.php?op=authorization&amp;id=".$_GET['torrent'].$passlink,_btalt_lock_request);
                else echo 
pic("lock.gif",null,_btalt_lock);
        } elseif (
$download_level "user") {
                
help(pic("download.gif","",null),_btregistereddownload);
        } elseif (
$download_level "premium") {
                
help(pic("download.gif","",null),_btpremiumdownload);
        }
}
if (
$torrent["exeem"] != "" AND $can_access) echo pic("exeem.gif",$torrent["exeem"],_btalt_exeem);

if (
$torrent["dht"] == "yes") {
        echo 
pic("magnet.gif","magnet:?xt=urn:btih:".hex_to_base32($infohash_hex),_btalt_magnet);
}
if (
$user->moderator OR ($torrent["owner"] == $user->id AND $torrent["owner"] != "0")) echo pic("edit.gif","edit.php?id=".$torrent["id"],_btalt_edit).pic("drop.gif","edit.php?op=delete&amp;id=".$torrent["id"],_btalt_drop);
    
#Ban button
        
if ($user->moderator AND $torrent["banned"] != "yes"){
            echo 
pic("ban.png","edit.php?op=ban&amp;id=".$torrent["id"],_btban);
        }
    
#Scrape button
        
if ($user->moderator AND $torrent["tracker"] != ""){
             echo 
pic("refresh.png","scrape-external.php?id=".$torrent["id"]."&amp;tracker=".$torrent["tracker"]."&amp;back=yes",_btalt_scrape);
                   }

if (
$torrent["owner"] == $user->id AND $torrent_global_privacy AND $torrent["tracker"] == "") {
        if (
$torrent["auths"] > 0) echo pic("auth_pending.gif","mytorrents.php?op=displaytorrent&amp;id=".$torrent["id"],_btalt_auth_pending);
        else echo 
pic("auth_none.gif","mytorrents.php?op=displaytorrent&amp;id=".$torrent["id"],_btalt_auth_none);
}
echo 
"</p></td></tr>\n";

#Download As
#if ($torrent["save_as"] != "") {
#        echo "<tr><td><p>"._btdownloadas."</p></td><td><p>".$torrent["save_as"];
#        if ($torrent["md5sum"] != "") echo "<br />md5sum: ".$torrent["md5sum"];
#        echo "</p></td></tr>\n";
#}

#Download Authorization
if ($torrent_global_privacy AND $user->user AND !$user->premium AND $torrent_global_privacy AND $download_level=="user" AND $torrent["owner"] != $user->id AND $torrent["private"] == "true" AND $torrent["owner"] != 0) {
        echo 
"<tr><td><p>"._btauthstatus."</p></td>";
        switch (
$flag) {
                case 
AUTH_PENDING: {
                        echo 
"<td><p class=\"pending\">"._btdwauthpending."</p></td>";
                        break;
                }
                case 
AUTH_GRANTED: {
                        echo 
"<td><p class =\"granted\">"._btdwauthgranted."</p></td>";
                        break;
                }
                case 
AUTH_DENIED: {
                        echo 
"<td><p class =\"denied\">"._btdwauthdenied."<p></td>";
                        break;
                }
                case 
AUTH_NONE: {
                        echo 
"<td><p class =\"pending\">"._btdwauthnorequest."<p></td>";
                        break;
                }
        }
        echo 
"</tr>\n";
}

#Size
echo "<tr><td><p>"._btdim."</p></td><td><p>".mksize($torrent["size"])."</p></td></tr>\n";
#Pieces
#if ($torrent["type"] != "link") echo "<tr><td><p>"._btpieces."</p></td><td><p>".str_replace(Array("**n**","**l**"),Array(intval(($torrent["size"]/$torrent["plen"])),mksize($torrent["plen"])),_btpiecesstring)."</p></td></tr>\n";
#Minimum Ratio
if ($torrent["private"] == "true" AND $torrent["min_ratio"] > "0.00" AND ($user->moderator OR $torrent["owner"] == $user->id))
        echo 
"<tr><td><p>"._btminratio."</p></td><td><p>".number_format($torrent["min_ratio"],2)."</p></td></tr>\n";
#Separator
echo "<tr><td><HR SIZE=1 NOSHADE></td><td></td></tr>\n";
$descript format_comment($torrent["descr"],false,true);
parse_smiles($descript);
#Description
if (!empty($torrent["descr"])) {//Sometimes massive upload Torrents do not have description
        
echo "<tr><td><p>"._btdescription."</p></td><td id=\"descrTD".$torrent['id']."\">".($user->admin "<a ondblclick=\"sndReq('op=edit_torrent_descr&torrent=".$torrent['id']."', 'descrTD".$torrent['id']."')\">" pic("edit.gif","",_btalt_edit) ."</a>" "");
        if (
$descript != strip_tags($descript)) //Means it is written in HTML
                
echo $descript;
        else
                echo 
"<p>".str_replace("\n","<br>",descript)."</p>";
        echo 
"</td></tr>\n";
}












if (
$torrent["tube"]=='') { 
print (
"<tr><td><p>Youtube:</p</td><td><img src=/images/novideo3.jpg border=\"0\" width=\"200\" height=\"164\" ></td></tr>");
}else{
print (
"<tr><td><p>Youtube:</p></td><td><object type=\"application/x-shockwave-flash\" data="str_replace("watch?v=""v/"htmlspecialchars($torrent["tube"])) ." width=\"400\" height=\"326\"><param name=\"movie\" value='"str_replace("watch?v=""v/"htmlspecialchars($torrent["tube"])) ."' /><param name=\"FlashVars\" value=\"playerMode=embedded\" /></object></td></tr>"); 
}











#Info Hash & Tracker
if ($torrent["type"] != "link") {
        
#Separator
        
echo "<tr><td><HR SIZE=1 NOSHADE></td><td></td></tr>\n";

        echo 
"<tr><td><p>";
        
help(pic("help.gif"),_btinfohashhelp,_btinfohash);
        echo 
_btinfohash."</p></td>";
        echo 
"<td><p>".$infohash_hex."</p></td></tr>\n";
echo 
"<tr><td><HR SIZE=1 NOSHADE></td><td></td></tr>\n";
        
##Single Tracker
        
echo "<tr><td><p>"._bttracker."</p></td><td><p>";
        if (
$torrent["tracker"] == "") {
                echo 
$siteurl;
        } else {
                echo 
"<a href=\"".preg_replace('/announce.*$/'''$torrent["tracker"])."\">".$torrent["tracker"]."</a>";
        }
        echo 
"</p></td></tr>\n";
        if (
$torrent["tracker_list"] != "") {
                echo 
"<tr><td><HR SIZE=1 NOSHADE></td><td></td></tr>\n";
        echo 
"<tr><td><p>"._bttrackers."</p></td><td>\n";
                
$trackers explode("\n\n",$torrent["tracker_list"]);
                for (
$i 0$i count($trackers); $i++) {
                        
$trackers[$i] = explode("\n",$trackers[$i]);

                        echo 
"<p>".str_replace("*",$i,_bttrackergroup)."\n";
                        echo 
"<ul>\n";
                        for (
$j 0$j count($trackers[$i]); $j++) {
                                echo 
"<li>";
                                
$pos strpos($trackers[$i][$j], $announce_url);
                                if (
$pos !== false) echo "<p>".$siteurl."</p>\n";
                                else echo 
"<p><a href=\"".preg_replace('/announce.*$/'''$trackers[$i][$j])."\">".$trackers[$i][$j]."</a></p>";
                                echo 
"</li>\n";
                        }
                        echo 
"</ul>\n";
                        echo 
"<br />\n";

                }
                unset(
$trackers);
                echo 
"</td></tr>\n";
        }

}

#Separator
echo "<tr><td><HR SIZE=1 NOSHADE></td><td></td></tr>\n";


#Category
echo "<tr><td><p>"._bttype."</p></td><td id=\"catTD\"><p ondblclick=\"sndReq('op=change_type_torrent&torrent=".$_GET['torrent']."', 'catTD')\">".$torrent["cat_name"]."</p></td></tr>\n";

#File number
echo "<tr><td><p>"._btnfile."</p></td><td><p>".$torrent["numfiles"]."</p></td></tr>\n";

#Uploaded by
echo "<tr><td><p>"._btuppedby."</p></td><td><p>";
switch (
$torrent["ownertype"]) {
        case 
0: {
                echo 
"<a href=\"user.php?op=profile&amp;id=".$torrent["owner"]."\">".htmlspecialchars($torrent["ownername"])."</a>";
                if (
$user->admin) echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[".htmlspecialchars($torrent["user_host"])."]";
                break;
        }
        case 
1: {
                if (
$user->moderator) echo "<a href=\"user.php?op=profile&amp;id=".$torrent["owner"]."\">".htmlspecialchars($torrent["ownername"])."</a>";
                else echo 
"<i>"._btunknown."</i>";
                if (
$user->admin) echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[".htmlspecialchars($torrent["user_host"])."]";
        }
        case 
2: {
                if (
$user->admin) echo "[".htmlspecialchars($torrent["user_host"])."]";
                else echo 
"<i>"._btunknown."</i>";
        }
}
echo 
"</p></td></tr>\n";

#Last Seed
if($torrent["type"]!="link" AND $torrent["tracker"] == ""){
        echo 
"<tr><td><p>"._btlastseeder."</p></td><td><p>".mkprettytime($torrent["lastseed"]) ." "._btago."</p></td></tr>\n";
#Separator
echo "<tr><td><HR SIZE=1 NOSHADE></td><td></td></tr>\n";
#snatched
if ($user->user) echo "<tr><td><p>ΠληÏοφοÏίες Î›Î®ÏˆÎ·Ï‚/Αποστολής: </font></p></td><td><p><a href=\"viewsnatches.php?id=" $_GET['torrent'] . "\"><font ><h3>           Î Ïοβολή!</h3></font></a>";
                  
}
print(
"<tr><td><p>Καμμένο Torrent:</p></td><td><p>".$torrent["nuked"]."</p></td></tr>\n");
if (
$torrent["nuked"] == "Îαί")print("<tr><td><p>Λόγος:</td><td><p>".$torrent["nukereason"]."</p></td></tr>\n");
if (
$torrent["nuked"] == "Όχι")print("<tr><td><p>Λόγος:</td><td><p>".$torrent["nukereason"]."</p></td></tr>\n");
echo 
"<tr><td><HR SIZE=1 NOSHADE></td><td></td></tr>\n";
#reseed
if ($user->user)echo "<tr><td><p>ΠαÏάκληση Î•Ï€Î±Î½Î±Ï„Ïοφοδοσίας:</p></td><td><p><a href=\"re-seed.php?id=" $_GET['torrent'] . "\"><font ><h3>           Î•Ï€Î±Î½Î±Ï„Ïοφοδοσία Î¤ÏŽÏα!</h3></font></a>";

#Separator
echo "<tr><td><HR SIZE=1 NOSHADE></td><td></td></tr>\n";


#Views
echo "<tr><td><p>"._btview."</p></td><td><p>".$torrent["views"]."</p></td></tr>\n";

#Downloads
echo "<tr><td><p>"._btdownloaded."</p></td><td><p>".$torrent["downloaded"]."</p></td></tr>\n";

#Completed
echo "<tr><td><p>"._btsnatch."</p></td><td><p>".$torrent["completed"]."</p></td></tr>\n";

if (
$user->user AND $torrent["password"] != "" AND ($user->id == $torrent["owner"] OR $user->premium)) {
        
#Separator
        
echo "<tr><td><HR SIZE=1 NOSHADE></td><td></td></tr>\n";

        echo 
"<tr><td><p>"._btpassword."</p></td><td><p>".htmlspecialchars($torrent["password"])."</p></td></tr>\n";
        echo 
"<tr><td><p>"._btdirectlink."</p></td><td><p>".$siteurl."/details.php?id=".$_GET['torrent']."&amp;password=".urlencode($password)."</p></td></tr>\n";
}

$sql "SELECT C.user AS id, IF(U.name IS NULL, U.username, U.name) AS username, U.level FROM torrent_download_completed C, torrent_users U WHERE C.user = U.id AND C.torrent = '".$_GET['torrent']."';";
$comres $db->sql_query($sql);

if (
$db->sql_numrows($comres) > 0) {
        
#Separator
        
echo "<tr><td><HR SIZE=1 NOSHADE></td><td></td></tr>\n";

        
$lst = Array();
        while (
$comrow $db->sql_fetchrow($comres)) {
                
$img = ($comrow["level"] != "user") ? pic("icon_".$comrow["level"].".gif") : "";
                
$lst[] = "<a href=\"user.php?op=profile&amp;id=".$comrow["id"]."\">".$comrow["username"].$img."</a>";
        }

        echo 
"<tr><td><p>"._btcompletedby."</p></td><td><p>".implode(", ",$lst)."</p></td></tr>\n";
}

$db->sql_freeresult($comres);
echo 
"</table></span>";
        
ob_end_flush();
$db->sql_close();
die();

        }
        case 
'archivedeleteshout':{
        
$sql "SELECT `text`, `user` FROM `".$db_prefix."_shouts` WHERE `id` = '".$_GET['shout']."'";
        
$res $db->sql_query($sql) or btsqlerror($sql);
        
$shout $db->sql_fetchrow$res );
        
// make sure user is owner of torrent
        
if ($shout['user'] != $user->id AND !$user->moderator){
        
error("Invalid permissions!");
        }

        
$db->sql_query("DELETE FROM `".$db_prefix."_shouts` WHERE `".$db_prefix."_shouts`.`id`='".$_GET['shout']."' LIMIT 1");
        echo 
"";
        
ob_end_flush();
$db->sql_close();
die();

        }
        case 
'get_imdb':{
        require (
"imdb/imdb.class.php");
        
$sql "SELECT A.id as id, A.exeem, A.seeders, A.leechers, A.tot_peer, A.speed, A.info_hash, A.filename, A.banned, A.nuked, A.nukereason, A.password, A.imdb, UNIX_TIMESTAMP() - UNIX_TIMESTAMP(A.last_action) AS lastseed, A.numratings, A.name, IF(A.numratings < '".$minvotes."', NULL, ROUND(A.ratingsum / A.numratings, 1)) AS rating, A.save_as, A.descr, A.visible, A.size, A.plen, A.added, A.views, A.downloaded, A.completed, A.type, A.private, A.min_ratio, A.numfiles, A.owner, A.ownertype, A.complaints, A.evidence, A.tracker, A.tracker_list, A.dht as dht, A.md5sum as md5sum, A.uploader_host as user_host, B.name AS cat_name, IF(C.name IS NULL, C.username, C.name) as ownername, A.tracker_update, COUNT(S.status) as auths FROM ".$db_prefix."_torrents A LEFT JOIN ".$db_prefix."_categories B ON A.category = B.id LEFT JOIN ".$db_prefix."_users C ON A.owner = C.id LEFT JOIN ".$db_prefix."_privacy_file S ON S.torrent = A.id AND S.status = 'pending' WHERE A.id = '".$_GET['torrent']."' GROUP BY A.id LIMIT 1;";
        
$res $db->sql_query($sql) or btsqlerror($sql);
        
$torrent $db->sql_fetchrow($res);
        
$db->sql_freeresult($res);
        if (
can_download($user,$torrent)) {
        
$can_access true;
        } else {
        
$can_access false;
        }
        
OpenTable('IMDB INFO');
                echo 
"<script type=\"text/javascript\" src=\"imdb/swfobject.js\"></script>";
                

          
//auto imdb mod
                
$thenumbers ltrim(strrchr($torrent["imdb"],'tt'),'tt');
                
$thenumbers ereg_replace("[^A-Za-z0-9]"""$thenumbers);
                
$movie = new imdb ($thenumbers);
                
$movieid $thenumbers;
                
$movie->setid ($movieid);
                
$country $movie->country ();
                
$director $movie->director();
                
$write $movie->writing();
                
$produce $movie->producer();
                
$cast $movie->cast();
                
$plot $movie->plot ();
                
$compose $movie->composer();
                
$gen $movie->genres();
                
$trailers $movie->trailers();
                
$mvlang $movie->language();
                
$mvrating $movie->rating();                
                if ((
$photo_url $movie->photo_localurl() ) != FALSE) {
                
$smallth '<img src="'.$photo_url.'">';
                }
                
$autodata "<strong><HR SIZE=1 NOSHADE><br />\n";
                
$autodata .= "<font color=\"darkred\" size=\"3\">Information:</font><br />\n";
                
$autodata .= "<HR SIZE=1 NOSHADE></strong><br />\n";
                
$autodata .= "<strong><font color=\"DarkRed\"> Title: </font></strong>".$movie->title ()."<br />\n";
                
$autodata .= "<strong><font color=\"DarkRed\"> Also known as: </font></strong>";

                foreach ( 
$movie->alsoknow() as $ak){
                
$autodata .= "".$ak["title"]."".$ak["year"]."".$ak["country"]." (".$ak["comment"].")" ", ";
                }
                
$autodata .= "<br />\n<strong><font color=\"DarkRed\"> Year: </font></strong>".$movie->year ()."<br />\n";
                
$autodata .= "<strong><font color=\"DarkRed\"> Runtime: </font></strong>".$movie->runtime ()." mins<br />\n";
                
$autodata .= "<strong><font color=\"DarkRed\"> Votes: </font></strong>".$movie->votes ()."<br />\n";
                
$autodata .= "<strong><font color=\"DarkRed\"> Rating: </font></strong>".$movie->rating ()."<br />\n";
                
$autodata .= "<strong><font color=\"DarkRed\"> Language: </font></strong>".$movie->language ()."<br />\n";
                
$autodata .= "<strong><font color=\"DarkRed\"> Country: </font></strong>";
                    
                for (
$i 0$i count ($country); $i++) {
                
$autodata .="$country[$i], ";
                }
                
$autodata .= "$country[$i]";
                
$autodata .= "<br />\n<strong><font color=\"DarkRed\"> All Genres: </font></strong>";
                for (
$i 0$i count($gen); $i++) {
                
$autodata .= "$gen[$i], ";
                }
                
$autodata .= "$gen[$i]";
                
$autodata .= "<br />\n<strong><font color=\"DarkRed\"> Tagline: </font></strong>".$movie->tagline ()."<br />\n";
                
$autodata .= "<strong><font color=\"DarkRed\"> Director: </font></strong>";

                for (
$i 0$i count ($director); $i++) {
                
$autodata .= "<a target=\"_blank\" href=\"http://us.imdb.com/Name?".$director[$i]["imdb"]."\">".$director[$i]["name"]."</a> ";
                }
          
                
$autodata .= "<br />\n<strong><font color=\"DarkRed\"> Writing By: </font></strong>";
                for (
$i 0$i count ($write); $i++) {
                
$autodata .= "<a target=\"_blank\" href=\"http://us.imdb.com/Name?".$write[$i]["imdb"]."\">".$write[$i]["name"]."</a> ";
               }
          
               
$autodata .= "<br />\n<strong><font color=\"DarkRed\"> Produced By: </font></strong>";
               for (
$i 0$i count ($produce); $i++) {
               
$autodata .= "<a target=\"_blank\" href=\"http://us.imdb.com/Name?".$produce[$i]["imdb"]." \">".$produce[$i]["name"]."</a> ";
              }
              
               
$autodata .= "<br />\n<strong><font color=\"DarkRed\"> Music: </font></strong>";          
               for (
$i 0$i count($compose); $i++) {
               
$autodata .= "<a target=\"_blank\" href=\"http://us.imdb.com/Name?".$compose[$i]["imdb"]." \">".$compose[$i]["name"]."</a> ";    
               }

               
$autodata .= "<br /><br />\n\n<strong><HR SIZE=1 NOSHADE><br />\n";
               
$autodata .= "<font color=\"darkred\" size=\"3\"> Description:</font><br />\n";
               
$autodata .= "<HR SIZE=1 NOSHADE></strong>";
               for (
$i 0$i count ($plot); $i++) {
               
$autodata .= "<br />\n<font color=\"DarkRed\"></font> ";
               
$autodata .= "$plot[$i]";
               }      
       
               
$autodata .= "<br /><br />\n\n<strong><HR SIZE=1 NOSHADE><br />\n";
               
$autodata .= "<font color=\"darkred\" size=\"3\"> Cast:</font><br />\n";
               
$autodata .= "<HR SIZE=1 NOSHADE></strong><br />\n";

               for (
$i 0$i count ($cast); $i++) {
               if (
$i 9) {
                break;
               }
               
$autodata .= "<font color=\"DarkRed\"></font><a target=\"_blank\" href=\"http://us.imdb.com/Name?".$cast[$i]["imdb"]."\">".$cast[$i]["name"]."</a> " " as <strong><font color=\"DarkRed\">".$cast[$i]["role"]." </font></strong><br />\n";
                
                }
               
$autodata .= "<br /><br />\n\n<strong><HR SIZE=1 NOSHADE><br />\n";
                
$autodata .= "<font color=\"darkred\" size=\"3\">Comments:</font><br />\n";
                
$autodata .= "<HR SIZE=1 NOSHADE></strong><br />\n";
                
$autodata .= "".$movie->comment ()."<br />\n";
if (!empty(
$trailers)) {
$autodata .= "<strong><HR SIZE=1 NOSHADE><br />\n";
$autodata .= "<font color=\"darkred\" size=\"3\"> Trailers:</font><br />\n";
$autodata .= "<strong><HR SIZE=1 NOSHADE><br />\n";

    for (
$i=0;$i<count($trailers);++$i) {
    if (
$i 14) {
        break;
    }
      
$autodata .= "<a target=\"_blank\" href='".$trailers[$i]."'>".$trailers[$i]."</a><br />\n";
    }
    }
                print(
"<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" align=\"center\"><div><tr><td class=\"heading\" valign=\"top\" align=\"right\">$smallth</td><td valign=\"top\" align=left>$autodata</td></tr></div></table>\n");

               
CloseTable();
             
ob_end_flush();
            
$db->sql_close();
         die();
        }
        case 
'member_search':{
        if( !isset( 
$_GET['search'] ) || empty( $_GET['search'] ) ){
        
error("Empty queries not allowed!");
        
ob_end_flush();
$db->sql_close();
die();

        }
        
$search trim($_GET['search']);
        
$class '';
        if ( isset( 
$_GET['search'] ) && !empty( $_GET['search'] ) ){
        
$query "username LIKE ('%$search%') AND active='1'";
        if (
$search){
        
$q "search=" htmlspecialchars($search);
        }
        } else{
        
$letter trim($_GET["letter"]);
        if (
strlen($letter) > 1){
        die;
        }
        if (
$letter == "" || strpos("abcdefghijklmnopqrstuvwxyz"$letter) === false){
        
$letter "a";
        }
        
$query "username LIKE '$letter%' AND active='1'";
        
$q "letter=$letter";
        }
        if (
$class){
        
$query .= " AND level=$class";
        
$q .= ($q "&amp;" "") . "level=$class";
        }
        print(
"<p>\n");
        for (
$i 97$i 123; ++$i){
        
$l chr($i);
        
$L chr($i 32);
        if (
$l == $letter){
        print(
"<b>$L</b>\n");
        } else{
        print(
"<a href=?letter=$l><b>$L</b></a>\n");
        }
        }
        print(
"</p>\n");
        
$page $_GET['page'];
        
$perpage 100;
        
$res mysql_query("SELECT COUNT(*) FROM ".$db_prefix."_users WHERE $query") or sqlerr();
        
$arr mysql_fetch_row($res);
        
$pages floor($arr[0] / $perpage);
        if (
$pages $perpage $arr[0]){
        ++
$pages;
        }
        if (
$page 1){
        
$page 1;
        } else{
        if (
$page $pages){
        
$page $pages;
        }
        }
        for (
$i 1$i <= $pages; ++$i){
        if (
$i == $page){
        
$pagemenu .= "<b>$i</b>\n";
        } else{
        
$pagemenu .= "<a href=?$q&page=$i><b>$i</b></a>\n";
        }
        }
        if (
$page == 1){
        
$browsemenu .= "<b>&lt;&lt; Prev</b>";
        } else{
        
$browsemenu .= "<a href=?$q&page=" . ($page 1) . "><b>&lt;&lt; Prev</b></a>";
        }
        
$browsemenu .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
        if (
$page == $pages){
        
$browsemenu .= "<b>Next &gt;&gt;</b>";
        } else{
        
$browsemenu .= "<a href=?$q&page=" . ($page 1) . "><b>Next &gt;&gt;</b></a>";
        }
        print(
"<p>$browsemenu<br>$pagemenu</p>");
        
$offset = ($page $perpage) - $perpage;
        
$res mysql_query("SELECT * FROM ".$db_prefix."_users WHERE $query ORDER BY username LIMIT $offset,$perpage") or sqlerr();
        
$num mysql_num_rows($res);
        print(
"<table border=1 cellspacing=0 cellpadding=5>\n");
        print(
"<tr><td class=colhead align=left>User name</td><td class=colhead>Registered</td><td class=colhead>Last access</td><td class=colhead align=left>Level</td></tr>\n");
        for (
$i 0$i $num; ++$i){
        
$arr mysql_fetch_assoc($res);
        if (
$arr['added'] == '0000-00-00 00:00:00'){
        
$arr['added'] = '-';
        }
        if (
$arr['last_access'] == '0000-00-00 00:00:00'){
        
$arr['last_access'] = '-';
        }
        print(
"<tr><td align=left><a href=user.php?op=profile&id=$arr[id]><b>$arr[username]</b></a></td>" .
        
"<td>$arr[regdate]</td><td>$arr[lastlogin]</td>".
        
"<td align=left>" $arr["level"] . "</td></tr>\n");
        }
        print(
"</table>\n");
        
ob_end_flush();
$db->sql_close();
die();

        }
}

ob_end_flush();
$db->sql_close();
die();
?>
Attached Thumbnails
10.jpg   10k5.jpg  

Last edited by Giorgatzelos; 6th September 2012 at 04:29.
Reply With Quote
  #2  
Old 7th September 2012, 15:17
joeroberts's Avatar
joeroberts joeroberts is offline
BT.Manager Owner
 
Join Date: Jan 2008
United States
Posts: 2,113
Default
here is a updated IMDB
replace imdb/imdb.class.php
PHP Code:
<?php
 
#############################################################################
 # IMDBPHP                              (c) Giorgos Giagas & Itzchak Rehberg #
 # written by Giorgos Giagas                                                 #
 # extended & maintained by Itzchak Rehberg <izzysoft AT qumran DOT org>     #
 # http://www.izzysoft.de/                                                   #
 # ------------------------------------------------------------------------- #
 # This program is free software; you can redistribute and/or modify it      #
 # under the terms of the GNU General Public License (see doc/LICENSE)       #
 #############################################################################

 /* $Id: imdb.class.php,v 1.1 2008/09/21 02:34:43 joerobe Exp $ */

 
require_once (dirname(__FILE__)."/browseremulator.class.php");
 require_once (
dirname(__FILE__)."/imdb_config.php");
 require_once (
dirname(__FILE__)."/imdb_request.class.php");

 
#=================================================[ The IMDB class itself ]===
 /** Accessing IMDB information
  * @package Api
  * @class imdb
  * @extends imdb_config
  * @author Georgos Giagas
  * @author Izzy (izzysoft AT qumran DOT org)
  * @copyright (c) 2002-2004 by Giorgos Giagas and (c) 2004-2008 by Itzchak Rehberg and IzzySoft
  * @version $Revision: 1.1 $ $Date: 2008/09/21 02:34:43 $
  */
 
class imdb extends imdb_config {

 
#---------------------------------------------------------[ Debug helpers ]---
  
function debug_scalar($scalar) {
    if (
$this->debug) echo "<b><font color='#ff0000'>$scalar</font></b><br>";
  }
  function 
debug_object($object) {
    if (
$this->debug) {
      echo 
"<font color='#ff0000'><pre>";
      
print_r($object);
      echo 
"</pre></font>";
    }
  }
  function 
debug_html($html) {
    if (
$this->debug) echo "<b><font color='#ff0000'>".htmlentities($html)."</font></b><br>";
  }

 
#-------------------------------------------------------------[ Open Page ]---
  /** Load an IMDB page into the corresponding property (variable)
   * @method private openpage
   * @param string wt
   */
  
function openpage ($wt) {
   if (
strlen($this->imdbID) != 7){
   echo 
$this->imdbID;
    
$this->debug_scalar("not valid imdbID: ".$this->imdbID."<BR>".strlen($this->imdbID));
    
$this->page[$wt] = "cannot open page";
    return;
   }
   switch (
$wt){
    case 
"Title"       $urlname="/"; break;
    case 
"Credits"     $urlname="/fullcredits"; break;
    case 
"CrazyCredits"$urlname="/crazycredits"; break;
    case 
"Plot"        $urlname="/plotsummary"; break;
    case 
"Taglines"    $urlname="/taglines"; break;
    case 
"Episodes"    $urlname="/episodes"; break;
    case 
"Quotes"      $urlname="/quotes"; break;
    case 
"Trailers"    $urlname="/trailers"; break;
    case 
"Trailer"    $urlname="/video/screenplay"; break;
    case 
"Goofs"       $urlname="/goofs"; break;
    case 
"Trivia"      $urlname="/trivia"; break;
    case 
"Soundtrack"  $urlname="/soundtrack"; break;
    case 
"MovieConnections" $urlname="/movieconnections"; break;
    case 
"ExtReviews"  $urlname="/externalreviews"; break;
    default            :
      
$this->page[$wt] = "unknown page identifier";
      
$this->debug_scalar("Unknown page identifier: $wt");
      return;
   }
   if (
$this->usecache) {
    
$fname "$this->cachedir/$this->imdbID.$wt";
    if ( 
$this->usezip ) {
     if ( (
$this->page[$wt] = @join("",@gzfile($fname))) ) {
      if ( 
$this->converttozip ) {
       @
$fp fopen ($fname,"r");
       
$zipchk fread($fp,2);
       
fclose($fp);
       if ( !(
$zipchk[0] == chr(31) && $zipchk[1] == chr(139)) ) { //checking for zip header
         /* converting on access */
         
$fp = @gzopen ($fname"w");
         @
gzputs ($fp$this->page[$wt]);
         @
gzclose ($fp);
       }
      }
      return;
     }
    } else { 
// no zip
     
@$fp fopen ($fname"r");
     if (
$fp) {
      
$temp="";
      while (!
feof ($fp)) {
     
$temp .= fread ($fp1024);
     
$this->page[$wt] = $temp;
      }
      return;
     }
    }
   } 
// end cache

   
$req = new IMDB_Request("");
   
$url "http://".$this->imdbsite."/title/tt".$this->imdbID.$urlname;
   
$req->setURL($url);
   
$req->sendRequest();
   
$this->page[$wt]=$req->getResponseBody();
   if( 
$this->page[$wt] ){ //storecache
    
if ($this->storecache) {
     
$fname "$this->cachedir/$this->imdbID.$wt";
     if ( 
$this->usezip ) {
      
$fp gzopen ($fname"w");
      
gzputs ($fp$this->page[$wt]);
      
gzclose ($fp);
     } else { 
// no zip
      
$fp fopen ($fname"w");
      
fputs ($fp$this->page[$wt]);
      
fclose ($fp);
     }
    }
    return;
   }
   
$this->page[$wt] = "cannot open page";
   
$this->debug_scalar("cannot open page: $url");
  }

 
#-------------------------------------------------------[ Get current MID ]---
  /** Retrieve the IMDB ID
   * @method imdbid
   * @return string id
   */
  
function imdbid () {
   return 
$this->imdbID;
  }

 
#--------------------------------------------------[ Start (over) / Reset ]---
  /** Setup class for a new IMDB id
   * @method setid
   * @param string id
   */
  
function setid ($id) {
   
$this->imdbID $id;

   
$this->page["Title"] = "";
   
$this->page["Credits"] = "";
   
$this->page["CrazyCredits"] = "";
   
$this->page["Amazon"] = "";
   
$this->page["Goofs"] = "";
   
$this->page["Trivia"] = "";
   
$this->page["Plot"] = "";
   
$this->page["Comments"] = "";
   
$this->page["Quotes"] = "";
   
$this->page["Taglines"] = "";
   
$this->page["Plotoutline"] = "";
   
$this->page["Trivia"] = "";
   
$this->page["Directed"] = "";
   
$this->page["Episodes"] = "";
   
$this->page["Quotes"] = "";
   
$this->page["Trailers"] = "";
   
$this->page["Trailer"] = "";
   
$this->page["MovieConnections"] = "";
   
$this->page["ExtReviews"] = "";

   
$this->akas = array();
   
$this->countries = array();
   
$this->crazy_credits = array();
   
$this->credits_cast = array();
   
$this->credits_composer = array();
   
$this->credits_director = array();
   
$this->credits_producer = array();
   
$this->credits_writing = array();
   
$this->extreviews = array();
   
$this->goofs = array();
   
$this->langs = array();
   
$this->main_comment "";
   
$this->main_genre "";
   
$this->main_language "";
   
$this->main_photo "";
   
$this->main_plotoutline "";
   
$this->main_rating = -1;
   
$this->main_runtime "";
   
$this->main_title "";
   
$this->main_votes = -1;
   
$this->main_year = -1;
   
$this->main_tagline "";
   
$this->moviecolors = array();
   
$this->movieconnections = array();
   
$this->moviegenres = array();
   
$this->moviequotes = array();
   
$this->movieruntimes = array();
   
$this->mpaas = array();
   
$this->plot_plot = array();
   
$this->seasoncount = -1;
   
$this->season_episodes = array();
   
$this->sound = array();
   
$this->soundtracks = array();
   
$this->split_comment = array();
   
$this->split_plot = array();
   
$this->taglines = array();
   
$this->trailers = array();
   
$this->trivia = array();
   
$this->main_trailer "";
  }

 
#-----------------------------------------------------------[ Constructor ]---
  /** Initialize class
   * @constructor imdb
   * @param string id
   */
  
function imdb ($id) {
   
$this->imdb_config();
   
$this->setid($id);
   if (
$this->storecache && ($this->cache_expire 0)) $this->purge();
  }

 
#---------------------------------------------------------[ Cache Purging ]---
  /** Check cache and purge outdated files
   *  This method looks for files older than the cache_expire set in the
   *  imdb_config and removes them
   * @method purge
   */
  
function purge() {
    if (
is_dir($this->cachedir))  {
      
$thisdir dir($this->cachedir);
      
$now time();
      while( 
$file=$thisdir->read() ) {
        if (
$file!="." && $file!="..") {
          
$fname $this->cachedir $file;
      if (
is_dir($fname)) continue;
          
$mod filemtime($fname);
          if (
$mod && ($now $mod $this->cache_expire)) unlink($fname);
        }
      }
    } elseif (!empty(
$this->cachedir)) {
      
$this->debug_scalar("Cache directory (".$this->cachedir.") does not exist - purge aborted.");
    }
  }

 
#-----------------------------------------------[ URL to movies main page ]---
  /** Set up the URL to the movie title page
   * @method main_url
   * @return string url
   */
  
function main_url(){
   return 
"http://".$this->imdbsite."/title/tt".$this->imdbid()."/";
  }

 
#-------------------------------------------[ Movie title (name) and year ]---
  /** Setup title and year properties
   * @method private title_year
   */
  
function title_year() {
    if (
$this->page["Title"] == ""$this->openpage ("Title");
    echo 
$this->openpage ("Title");
    if (@
preg_match("/\<title\>(.*)\((.*)\) - IMDb<\/title\>/",$this->page["Title"],$match)) {
      
$this->main_title $match[1];
      
$this->main_year  $match[2];
    }
  }

  
/** Get movie title
   * @method title
   * @return string title
   */
  
function title () {
    if (
$this->main_title == ""$this->title_year();
    return 
$this->main_title;
  }

  
/** Get year
   * @method year
   * @return string year
   */
  
function year () {
    if (
$this->main_year == -1$this->title_year();
    return 
$this->main_year;
  }

 
#---------------------------------------------------------------[ Runtime ]---
  /** Get general runtime
   * @method private runtime_all
   * @return string runtime complete runtime string, e.g. "150 min / USA:153 min (director's cut)"
   */
  
function runtime_all() {
    if (
$this->main_runtime == "") {
      if (
$this->page["Title"] == ""$this->openpage ("Title");
      if (@
preg_match("/Runtime:\<\/h4\> \n\n(.*?)\n/m",$this->page["Title"],$match))
        
$this->main_runtime $match[1];
    }
    return 
$this->main_runtime;
  }

  
/** Get overall runtime (first one mentioned on title page)
   * @method runtime
   * @return mixed string runtime in minutes (if set), NULL otherwise
   */
  
function runtime() {
    if (empty(
$this->movieruntimes)) $runarr $this->runtimes();
    else 
$runarr $this->movieruntimes;
    if (isset(
$runarr[0]["time"])) return $runarr[0]["time"];
    return 
NULL;
  }

  
/** Retrieve language specific runtimes
   * @method runtimes
   * @return array runtimes (array[0..n] of array[time,country,comment])
   */
  
function runtimes(){
    if (empty(
$this->movieruntimes)) {
      if (
$this->runtime_all() == "") return array();
      if (
preg_match_all("/[\/ ]*((\D*?):|)([\d]+?) min( \((.*?)\)|)/",$this->main_runtime,$matches))
        for (
$i=0;$i<count($matches[0]);++$i$this->movieruntimes[] = array("time"=>$matches[3][$i],"country"=>$matches[2][$i],"comment"=>$matches[5][$i]);
    }
    return 
$this->movieruntimes;
  }

 
#----------------------------------------------------------[ Movie Rating ]---
  /** Setup votes
   * @method private rate_vote
   */
  
function rate_vote() {
    if (
$this->page["Title"] == ""$this->openpage ("Title");
    if(
preg_match("/\<span itemprop=\"ratingValue\">(.*?)\<\/span\>/m",$this->page["Title"],$match)){
      
$this->main_rating $match[1];
    }
    if(
preg_match("/title=\"Users rated this(.*?)\((.*?) votes/ms",$this->page["Title"],$match)){
      
$this->main_votes $match[2];
    }
  }

  
/** Get movie rating
   * @method rating
   * @return string rating
   */
  
function rating () {
    if (
$this->main_rating == -1$this->rate_vote();
    return 
$this->main_rating;
  }

  
/** Return votes for this movie
   * @method votes
   * @return string votes
   */
  
function votes () {
    if (
$this->main_votes == -1$this->rate_vote();
    return 
$this->main_votes;
  }

 
#------------------------------------------------------[ Movie Comment(s) ]---
  /** Get movie main comment (from title page)
   * @method comment
   * @return string comment
   */
  
function comment () {
    if (
$this->main_comment == "") {
      if (
$this->page["Title"] == ""$this->openpage ("Title");
      if (@
preg_match("/\<div class\=\"comment\"(.*?)(\<b\>.*?)\<div class\=\"yn\"/ms",$this->page["Title"],$match))
        
$this->main_comment preg_replace("/a href\=\"\//i","a href=\"http://".$this->imdbsite."/",$match[2]);
    }
    return 
$this->main_comment;
  }

  
/** Get movie main comment (from title page - split-up variant)
   * @method comment_split
   * @return array comment array[string title, string date, array author, string comment]; author: array[string url, string name]
   */
  
function comment_split() {
    if (empty(
$this->split_comment)) {
      if (
$this->main_comment == ""$comm $this->comment();
      if (@
preg_match("/<b>(.*?)<\/b>, (.*)<br>.*?<a href=\"(.*)\">(.*?)<\/a>.*<p>(.*?)<\/p>/ms",$this->main_comment,$match))
        
$this->split_comment = array("title"=>$match[1],"date"=>$match[2],"author"=>array("url"=>$match[3],"name"=>$match[4]),"comment"=>trim($match[5]));
    }
    return 
$this->split_comment;
  }

 
#--------------------------------------------------------[ Language Stuff ]---
  /** Get movies original language
   * @method language
   * @return string language
   * @brief There is not really a main language on the IMDB sites (yet), so this
   *  simply returns the first one
   */
  
function language () {
   if (
$this->main_language == "") {
    if (empty(
$this->langs)) $langs $this->languages();
    
$this->main_language $this->langs[0];
   }
   return 
$this->main_language;
  }

  
/** Get all langauges this movie is available in
   * @method languages
   * @return array languages (array[0..n] of strings)
   */
  
function languages () {
   if (empty(
$this->langs)) {
    if (
$this->page["Title"] == ""$this->openpage ("Title");
    if (
preg_match_all("/itemprop=\"inLanguage\"\n    >(.*)<\/a>/",str_replace('&gt;','>',$this->page["Title"]),$matches))
      
$this->langs $matches[1];
   }
   return 
$this->langs;
  }

 
#--------------------------------------------------------------[ Genre(s) ]---
  /** Get the movies main genre
   *  Since IMDB.COM does not really now a "Main Genre", this simply means the
   *  first mentioned genre will be returned.
   * @method genre
   * @return string genre
   * @brief There is not really a main genre on the IMDB sites (yet), so this
   *  simply returns the first one
   */
  
function genre () {
   if (empty(
$this->main_genre)) {
    if (empty(
$this->moviegenres)) $genres $this->genres();
    if (!empty(
$genres)) $this->main_genre $this->moviegenres[0];
   }
   return 
$this->main_genre;
  }

  
/** Get all genres the movie is registered for
   * @method genres
   * @return array genres (array[0..n] of strings)
   */
  
function genres () {
    if (empty(
$this->moviegenres)) {
      if (
$this->page["Title"] == ""$this->openpage ("Title");
      if (
preg_match_all("/itemprop=\"genre\"\n    >(.*?)<\/a>/",str_replace('&gt;','>',$this->page["Title"]),$matches))
        
$this->moviegenres $matches[1];
    }
    return 
$this->moviegenres;
  }

 
#----------------------------------------------------------[ Color format ]---
  /** Get colors
   * @method colors
   * @return array colors (array[0..1] of strings)
   */
  
function colors () {
    if (empty(
$this->moviecolors)) {
      if (
$this->page["Title"] == ""$this->openpage ("Title");
      if (
preg_match_all("/\/List\?color-info.*?>(.*?)</",$this->page["Title"],$matches))
        
$this->moviecolors $matches[1];
    }
    return 
$this->moviecolors;
  }

 
#---------------------------------------------------------------[ Tagline ]---
  /** Get the main tagline for the movie
   * @method tagline
   * @return string tagline
   */
  
function tagline () {
    if (
$this->main_tagline == "") {
      if (
$this->page["Title"] == ""$this->openpage ("Title");
      if (@
preg_match("/Tagline:\<\/h5\>\s*\n(.*?)\<\/div/ms",$this->page["Title"],$match)) {
        if(@
preg_match("/^(.*?)\<a class\=\"tn15more/ms",$match[1],$match2)) $this->main_tagline $match2[1];
        else 
$this->main_tagline $match[1];
      }
    }
    return 
$this->main_tagline;
  }

 
#---------------------------------------------------------------[ Seasons ]---
  /** Get the number of seasons or 0 if not a series
   * @method seasons
   * @return int seasons
   */
  
function seasons() {
    if ( 
$this->seasoncount == -) {
      if ( 
$this->page["Title"] == "" $this->openpage("Title");
      if ( 
preg_match_all('|<a href="episodes#season-\d+">(\d+)</a>|Ui',$this->page["Title"],$matches) ) {
        
$this->seasoncount count($matches[0]);
      } else {
        
$this->seasoncount 0;
      }
    }
    return 
$this->seasoncount;
  }

 
#--------------------------------------------------------[ Plot (Outline) ]---
  /** Get the main Plot outline for the movie
   * @method plotoutline
   * @return string plotoutline
   */
  
function plotoutline () {
    if (
$this->main_plotoutline == "") {
      if (
$this->page["Title"] == ""$this->openpage ("Title");
      if (@
preg_match("/Plot Outline:\<\/h5\>\s*\n(.*?)\</ms",$this->page["Title"],$match))
        
$this->main_plotoutline $match[1];
    }
    return 
$this->main_plotoutline;
  }

 
#--------------------------------------------------------[ Photo specific ]---
  /** Get cover photo
   * @method photo
   * @return mixed photo (string url if found, FALSE otherwise)
   */
  
function photo () {
    if (empty(
$this->main_photo)) {
      if (
$this->page["Title"] == ""$this->openpage ("Title");
      
preg_match("/id=\"img_primary(.*?)>\n    \n\n(.*?)<img src=\"(.*?)\"/",str_replace('&gt;','>',$this->page["Title"]),$match);
      if (empty(
$match[3])) return FALSE;
      
$this->main_photo $match[3];
    }
    return 
$this->main_photo;
  }

  
/** Save the photo to disk
   * @method savephoto
   * @param string path
   * @return boolean success
   */
  
function savephoto ($path) {
    
$req = new IMDB_Request("");
    
$photo_url $this->photo ();
    if (!
$photo_url) return FALSE;
    
$req->setURL($photo_url);
    
$req->sendRequest();
    if (
strpos($req->getResponseHeader("Content-Type"),'image/jpeg') === 0
      
|| strpos($req->getResponseHeader("Content-Type"),'image/gif') === 0
      
|| strpos($req->getResponseHeader("Content-Type"), 'image/bmp') === ){
    
$fp $req->getResponseBody();
    }else{
    
$this->debug_scalar("<BR>*photoerror* ".$photo_url.": Content Type is '".$req->getResponseHeader("Content-Type")."'<BR>");
    return 
false;
    }
    
$fp2 fopen ($path"w");
    if ((!
$fp) || (!$fp2)){
      
$this->debug_scalar("image error...<BR>");
      return 
false;
    }
    
fputs ($fp2$fp);
    return 
TRUE;
  }

  
/** Get the URL for the movies cover photo
   * @method photo_localurl
   * @return mixed url (string URL or FALSE if none)
   */
  
function photo_localurl(){
    
$path $this->photodir.$this->imdbid().".jpg";
    if ( @
fopen($path,"r"))      return $this->photoroot.$this->imdbid().'.jpg';
    if (
$this->savephoto($path)) return $this->photoroot.$this->imdbid().'.jpg';
    return 
false;
  }

 
#-------------------------------------------------[ Country of Production ]---
  /** Get country of production
   * @method country
   * @return array country (array[0..n] of string)
   */
  
function country () {
   if (empty(
$this->countries)) {
    if (
$this->page["Title"] == ""$this->openpage ("Title");
    
$this->countries = array();
    if (
preg_match_all("/\/Sections\/Countries\/\w+\/\"\>(.*?)<\/a/",$this->page["Title"],$matches))
      for (
$i=0;$i<count($matches[0]);++$i$this->countries[$i] = $matches[1][$i];
   }
   return 
$this->countries;
  }

 
#------------------------------------------------------------[ Movie AKAs ]---
  /** Get movies alternative names
   * @method alsoknow
   * @return array aka array[0..n] of array[title,year,country,comment]; searching
   *         on akas.imdb.com will add "lang" to the array for localized names,
   *         "comment" will hold additional countries listed along
   */
  
function alsoknow () {
   if (empty(
$this->akas)) {
    if (
$this->page["Title"] == ""$this->openpage ("Title");
    
$ak_s strpos ($this->page["Title"], "Also Known As:</h4>");
    if (
$ak_s>0$ak_s += 19;
    if (
$ak_s == 0$ak_s strpos ($this->page["Title"], "Also Known As:</h4>");
    if (
$ak_s == 0) return array();
    
$alsoknow_end strpos ($this->page["Title"], "</div>"$ak_s);
    
$alsoknow_all substr($this->page["Title"], $ak_s$alsoknow_end $ak_s);
    if (
preg_match_all("/(.*?) (\(\d{4}\) |)\((.*?)\).*?\((.*?)\) <br>/",$alsoknow_all,$matches))
      for (
$i=0;$i<count($matches[0]);++$i$this->akas[] = array("title"=>$matches[1][$i],"year"=>$matches[2][$i],"country"=>$matches[3][$i],"comment"=>$matches[4][$i]);
    if (
preg_match_all("/<i class=\"transl\">([^\[\(]+?) (\(\d{4}\) |)(\([^\[]+)\s*\[(.*?)\]<\/i><br>/",$alsoknow_all,$matches)) { // localized variants on akas.imdb.com
      
for ($i=0;$i<count($matches[0]);++$i) {
        
$country ""$comment "";
        if (
preg_match_all("/\((.*?)\)/",$matches[3][$i],$countries)) {
          
$country $countries[1][0];
          for (
$k=1;$k<count($countries[0]);++$k$comment .= ", ".$countries[1][$k];
        }
        
$this->akas[] = array("title"=>$matches[1][$i],"year"=>$matches[2][$i],"country"=>$country,"comment"=>@substr($comment,2),"lang"=>$matches[4][$i],"orig"=>$matches[0][$i]);
      }
    }
   }
   return 
$this->akas;
  }

 
#---------------------------------------------------------[ Sound formats ]---
  /** Get sound formats
   * @method sound
   * @return array sound (array[0..n] of strings)
   */
  
function sound () {
   if (empty(
$this->sound)) {
    if (
$this->page["Title"] == ""$this->openpage ("Title");
    if (
preg_match_all("/\/List\?sound.*?>(.*?)</",$this->page["Title"],$matches))
      
$this->sound $matches[1];
   }
   return 
$this->sound;
  }

 
#-------------------------------------------------------[ MPAA / PG / FSK ]---
  /** Get the MPAA data (also known as PG or FSK)
   * @method mpaa
   * @return array mpaa (array[country]=rating)
   */
  
function mpaa () {
   if (empty(
$this->mpaas)) {
    if (
$this->page["Title"] == ""$this->openpage ("Title");
    if (
preg_match_all("/\/List\?certificates.*?>(.*?):(.*?)</",$this->page["Title"],$matches)) {
      
$cc count($matches[0]);
      for (
$i=0;$i<$cc;++$i$this->mpaas[$matches[1][$i]] = $matches[2][$i];
    }
   }
   return 
$this->mpaas;
  }

 
#-----------------------------------------------------[ /plotsummary page ]---
  /** Get the movies plot(s)
   * @method plot
   * @return array plot (array[0..n] of strings)
   */
  
function plot () {
   if (empty(
$this->plot_plot)) {
    if ( 
$this->page["Plot"] == "" $this->openpage ("Plot");
    if ( 
$this->page["Plot"] == "cannot open page" ) return array(); // no such page
    
if (preg_match_all("/p class=\"plotpar\">(.*?)<\/p>/",str_replace("\n"," ",$this->page["Plot"]),$matches))
      for (
$i=0;$i<count($matches[0]);++$i)
        
$this->plot_plot[$i] = preg_replace('/<a href=\"\/SearchPlotWriters/i','<a href="http://'.$this->imdbsite.'/SearchPlotWriters/',$matches[1][$i]);
   }
   return 
$this->plot_plot;
  }

  
/** Get the movie plot(s) - split-up variant
   * @method plot_split
   * @return array array[0..n] of array[string plot,array author] - where author consists of string name and string url
   */
  
function plot_split() {
    if (empty(
$this->split_plot)) {
      if (empty(
$this->plot_plot)) $plots $this->plot();
      for (
$i=0;$i<count($this->plot_plot);++$i) {
        if (
preg_match("/(.*?)<i>.*<a href=\"(.*?)\">(.*?)<\/a>/",$this->plot_plot[$i],$match))
          
$this->split_plot[] = array("plot"=>$match[1],"author"=>array("name"=>$match[3],"url"=>$match[2]));
      }
    }
    return 
$this->split_plot;
  }

 
#--------------------------------------------------------[ /taglines page ]---
  /** Get all available taglines for the movie
   * @method taglines
   * @return array taglines (array[0..n] of strings)
   */
  
function taglines () {
   if (empty(
$this->taglines)) {
    if ( 
$this->page["Taglines"] == "" $this->openpage ("Taglines");
    if ( 
$this->page["Taglines"] == "cannot open page" ) return array(); // no such page
    
if (preg_match_all("/<p>(.*?)<\/p><hr/",$this->page["Taglines"],$matches))
      
$this->taglines $matches[1];
   }
   return 
$this->taglines;
  }

 
#-----------------------------------------------------[ /fullcredits page ]---
  /** Get rows for a given table on the page
   * @method private get_table_rows
   * @param string html
   * @param string table_start
   * @return mixed rows (FALSE if table not found, array[0..n] of strings otherwise)
   * @see used by the methods director, cast, writing, producer, composer
   */
  
function get_table_rows $html$table_start ){
   
$row_s strpos $html">".$table_start."<");
   
$row_e $row_s;
   if ( 
$row_s == )  return FALSE;
   
$endtable strpos($html"</table>"$row_s);
   if (
preg_match_all("/<tr>(.*?)<\/tr>/",substr($html,$row_s,$endtable $row_s),$matches)) {
     
$mc count($matches[1]);
     for (
$i=0;$i<$mc;++$i) if ( strncmptrim($matches[1][$i]), "<td valign=",10) == $rows[] = $matches[1][$i];
   }
   return 
$rows;
  }

  
/** Get rows for the cast table on the page
   * @method private get_table_rows_cast
   * @param string html
   * @param string table_start
   * @return mixed rows (FALSE if table not found, array[0..n] of strings otherwise)
   * @see used by the method cast
   */
  
function get_table_rows_cast $html$table_start ){
   
$row_s strpos $html'<table class="cast">');
   
$row_e $row_s;
   if ( 
$row_s == )  return FALSE;
   
$endtable strpos($html"</table>"$row_s);
   if (
preg_match_all("/<tr.*?(<td class=\"nm\".*?)<\/tr>/",substr($html,$row_s,$endtable $row_s),$matches))
     return 
$matches[1];
   return array();
  }

  
/** Get content of table row cells
   * @method private get_row_cels
   * @param string row (as returned by imdb::get_table_rows)
   * @return array cells (array[0..n] of strings)
   * @see used by the methods director, cast, writing, producer, composer
   */
  
function get_row_cels $row ){
   if (
preg_match_all("/<td.*?>(.*?)<\/td>/",$row,$matches)) return $matches[1];
   return array();
  }

  
/** Get the IMDB ID from a names URL
   * @method private get_imdbname
   * @param string href
   * @return string
   * @see used by the methods director, cast, writing, producer, composer
   */
  
function get_imdbname$href){
   if ( 
strlen$href) == 0) return $href;
   
$name_s 15;
   
$name_e strpos $href'"'$name_s);
   if ( 
$name_e != 0) return substr$href$name_s$name_e -$name_s);
   else    return 
$href;
  }

  
/** Get the director(s) of the movie
   * @method director
   * @return array director (array[0..n] of arrays[imdb,name,role])
   */
  
function director () {
   if (empty(
$this->credits_director)) {
    if ( 
$this->page["Credits"] == "" $this->openpage ("Credits");
    if ( 
$this->page["Credits"] == "cannot open page" ) return array(); // no such page
   
}
   
$director_rows $this->get_table_rows($this->page["Credits"], "Directed by");
   for ( 
$i 0$i count ($director_rows); $i++){
    
$cels $this->get_row_cels ($director_rows[$i]);
    if (!isset (
$cels[0])) return array();
    
$dir["imdb"] = $this->get_imdbname($cels[0]);
    
$dir["name"] = strip_tags($cels[0]);
    
$role trim(strip_tags($cels[2]));
    if ( 
$role == ""$dir["role"] = NULL;
    else 
$dir["role"] = $role;
    
$this->credits_director[$i] = $dir;
   }
   return 
$this->credits_director;
  }

  
/** Get the actors
   * @method cast
   * @return array cast (array[0..n] of arrays[imdb,name,role])
   */
  
function cast () {
   if (empty(
$this->credits_cast)) {
    if ( 
$this->page["Credits"] == "" $this->openpage ("Credits");
    if ( 
$this->page["Credits"] == "cannot open page" ) return array(); // no such page
   
}
   
$cast_rows $this->get_table_rows_cast($this->page["Credits"], "Cast");
   for ( 
$i 0$i count ($cast_rows); $i++){
    
$cels $this->get_row_cels ($cast_rows[$i]);
    if (!isset (
$cels[0])) return array();
    
$dir["imdb"] = $this->get_imdbname($cels[0]);
    
$dir["name"] = strip_tags($cels[0]);
    
$role strip_tags($cels[2]);
    if ( 
$role == ""$dir["role"] = NULL;
    else 
$dir["role"] = $role;
    
$this->credits_cast[$i] = $dir;
   }
   return 
$this->credits_cast;
  }

  
/** Get the writer(s)
   * @method writing
   * @return array writers (array[0..n] of arrays[imdb,name,role])
   */
  
function writing () {
   if (empty(
$this->credits_writing)) {
    if ( 
$this->page["Credits"] == "" $this->openpage ("Credits");
    if ( 
$this->page["Credits"] == "cannot open page" ) return array(); // no such page
   
}
   
$this->credits_writing = array();
   
$writing_rows $this->get_table_rows($this->page["Credits"], "Writing credits");
   for ( 
$i 0$i count ($writing_rows); $i++){
     
$cels $this->get_row_cels ($writing_rows[$i]);
     if ( 
count $cels) > 2){
       
$wrt["imdb"] = $this->get_imdbname($cels[0]);
       
$wrt["name"] = strip_tags($cels[0]);
       
$role strip_tags($cels[2]);
       if ( 
$role == ""$wrt["role"] = NULL;
       else 
$wrt["role"] = $role;
       
$this->credits_writing[$i] = $wrt;
     }
   }
   return 
$this->credits_writing;
  }

  
/** Obtain the producer(s)
   * @method producer
   * @return array producer (array[0..n] of arrays[imdb,name,role])
   */
  
function producer () {
   if (empty(
$this->credits_producer)) {
    if ( 
$this->page["Credits"] == "" $this->openpage ("Credits");
    if ( 
$this->page["Credits"] == "cannot open page" ) return array(); // no such page
   
}
   
$this->credits_producer = array();
   
$producer_rows $this->get_table_rows($this->page["Credits"], "Produced by");
   for ( 
$i 0$i count ($producer_rows); $i++){
    
$cels $this->get_row_cels ($producer_rows[$i]);
    if ( 
count $cels) > 2){
     
$wrt["imdb"] = $this->get_imdbname($cels[0]);
     
$wrt["name"] = strip_tags($cels[0]);
     
$role strip_tags($cels[2]);
     if ( 
$role == ""$wrt["role"] = NULL;
     else 
$wrt["role"] = $role;
     
$this->credits_producer[$i] = $wrt;
    }
   }
   return 
$this->credits_producer;
  }

  
/** Obtain the composer(s) ("Original Music by...")
   * @method composer
   * @return array composer (array[0..n] of arrays[imdb,name,role])
   */
  
function composer () {
   if (empty(
$this->credits_composer)) {
    if ( 
$this->page["Credits"] == "" $this->openpage ("Credits");
    if ( 
$this->page["Credits"] == "cannot open page" ) return array(); // no such page
   
}
   
$this->credits_composer = array();
   
$composer_rows $this->get_table_rows($this->page["Credits"], "Original Music by");
   for ( 
$i 0$i count ($composer_rows); $i++){
    
$cels $this->get_row_cels ($composer_rows[$i]);
    if ( 
count $cels) > 2){
     
$wrt["imdb"] = $this->get_imdbname($cels[0]);
     
$wrt["name"] = strip_tags($cels[0]);
     
$role strip_tags($cels[2]);
     if ( 
$role == ""$wrt["role"] = NULL;
     else 
$wrt["role"] = $role;
     
$this->credits_composer[$i] = $wrt;
    }
   }
   return 
$this->credits_composer;
  }

 
#----------------------------------------------------[ /crazycredits page ]---
  /** Get the Crazy Credits
   * @method crazy_credits
   * @return array crazy_credits (array[0..n] of string)
   */
  
function crazy_credits() {
    if (empty(
$this->crazy_credits)) {
      if (empty(
$this->page["CrazyCredits"])) $this->openpage("CrazyCredits");
      if ( 
$this->page["CrazyCredits"] == "cannot open page" ) return array(); // no such page
      
$tag_s strpos ($this->page["CrazyCredits"],"<li><tt>");
      
$tag_e strpos ($this->page["CrazyCredits"],"</ul>",$tag_s);
      
$cred  str_replace ("<br>"," ",substr ($this->page["CrazyCredits"],$tag_s$tag_e $tag_s));
      
$cred  str_replace ("  "," ",str_replace ("\n"," ",$cred));
      if (
preg_match_all("/<li><tt>(.*?)<\/tt><\/li>/",$cred,$matches))
        
$this->crazy_credits $matches[1];
    }
    return 
$this->crazy_credits;
  }

 
#--------------------------------------------------------[ /episodes page ]---
  /** Get the series episode(s)
   * @method episodes
   * @return array episodes (array[0..n] of array[0..m] of array[imdbid,title,airdate,plot])
   */
  
function episodes() {
    if ( 
$this->seasons() == ) return null;
    if ( empty(
$this->season_episodes) ) {
      if ( 
$this->page["Episodes"] == "" $this->openpage("Episodes");
      if ( 
$this->page["Episodes"] == "cannot open page" ) return array(); // no such page
      
if ( preg_match_all('|<h4>Season (\d+), Episode (\d+): <a href="/title/tt(\d{7})/">(.*)</a></h4><b>Original Air Date: (.*)</b><br>(.*)<br/><br/>|Ui',$this->page["Episodes"],$matches) ) {
    for ( 
$i $i count($matches[0]); $i++ ) {
          
$this->season_episodes[$matches[1][$i]][$matches[2][$i]] = array("imdbid" => $matches[3][$i],"title" => $matches[4][$i], "airdate" => $matches[5][$i], "plot" => $matches[6][$i]);
        }
      }
    }
    return 
$this->season_episodes;
  }

 
#-----------------------------------------------------------[ /goofs page ]---
  /** Get the goofs
   * @method goofs
   * @return array goofs (array[0..n] of array[type,content]
   */
  
function goofs() {
    if (empty(
$this->goofs)) {
      if (empty(
$this->page["Goofs"])) $this->openpage("Goofs");
      if (
$this->page["Goofs"] == "cannot open page") return array(); // no such page
      
$tag_s strpos($this->page["Goofs"],'<ul class="trivia">');
      
$tag_e strrpos($this->page["Goofs"],'<ul class="trivia">'); // maybe more than one
      
$tag_e strrpos($this->page["Goofs"],"</ul>");
      
$goofs substr($this->page["Goofs"],$tag_s,$tag_e $tag_s);
      if (
preg_match_all("/<li><b>(.*?)<\/b>(.*?)<br><br><\/li>/",$goofs,$matches)) {
        
$gc count($matches[1]);
        for (
$i=0;$i<$gc;++$i$this->goofs[] = array("type"=>$matches[1][$i],"content"=>$matches[2][$i]);
      }
    }
    return 
$this->goofs;
  }

 
#----------------------------------------------------------[ /quotes page ]---
  /** Get the quotes for a given movie
   * @method quotes
   * @return array quotes (array[0..n] of string)
   */
  
function quotes() {
    if ( empty(
$this->moviequotes) ) {
      if ( 
$this->page["Quotes"] == "" $this->openpage("Quotes");
      if ( 
$this->page["Quotes"] == "cannot open page" ) return array(); // no such page
      
if (preg_match_all("/<a name=\"qt.*?<\/a>\s*(.*?)<hr/",str_replace("\n"," ",$this->page["Quotes"]),$matches))
        
$this->moviequotes $matches[1];
    }
    return 
$this->moviequotes;
  }

 
#--------------------------------------------------------[ /trailers page ]---
  /** Get the trailer URLs for a given movie
   * @method trailers
   * @return array trailers (array[0..n] of string)
   */
  
function trailers() {
    if ( empty(
$this->trailers) ) {
      if ( 
$this->page["Trailers"] == "" $this->openpage("Trailers");
      if ( 
$this->page["Trailers"] == "cannot open page" ) return array(); // no such page
      
$tag_s strpos($this->page["Trailers"], '<div class="slate">');
      if (!empty(
$tag_s)) { // trailers on the IMDB site itself
        
$tag_e strpos($this->page["Trailers"],"</a>\n</div",$tag_s);
        
$trail substr($this->page["Trailers"], $tag_s$tag_e $tag_s +1);
        if (
preg_match_all("/href=\"\/video\/imdb\/(.*?)\/\"/",$trail,$matches))
          for (
$i=0;$i<count($matches[0]);++$i$this->trailers[] = "http://".$this->imdbsite.'/video/imdb/'.$matches[1][$i].'/';
          
$this->trailers array_unique($this->trailers);
      }
      
$tag_s strpos($this->page["Trailers"], " Videos</div>");
      if (empty(
$tag_s)) return FALSE;
      
$tag_e strpos($this->page["Trailers"], "<h3>Related Links</h3>"$tag_s);
      
$trail substr($this->page["Trailers"], $tag_s$tag_e $tag_s);
        if (
preg_match_all("/href=\"\/video\/imdblink\/(.*?)\/\"/",$trail,$matches))
        {
        
$a=0;
        foreach (
$matches[1] as $matt)
        {
        
$matches[1][$a] = "http://".$this->imdbsite.'/video/imdblink/'.$matt.'/';
        
$a++;
        }
        
$this->trailers array_merge($this->trailers,array_unique($matches[1]));
        }
    }
    return 
$this->trailers;
  }
function 
trailer () {
   if (
$this->main_trailer == "") {
      if (
$this->page["Title"] == ""$this->openpage ("Title");
         
$trailer_s strpos ($this->page["Title"], "strip toplinks");
            if ( 
$trailer_s == 0) return false;
               
$trailer_s strpos ($this->page["Title"], "trailers-"$trailer_s);
               
$trailer_e strpos ($this->page["Title"], "\""$trailer_s);
               
$this->main_trailer substr ($this->page["Title"], $trailer_s+9$trailer_e $trailer_s-9);
            if (
substr($this->main_trailer02) != "me")
              
$this->main_trailer "notrailer";
   }
   return 
$this->main_trailer;
   }
 
#----------------------------------------------------------[ /trivia page ]---
  /** Get the trivia info
   * @method trivia
   * @return array trivia (array[0..n] string
   */
  
function trivia() {
    if (empty(
$this->trivia)) {
      if (empty(
$this->page["Trivia"])) $this->openpage("Trivia");
      if (
$this->page["Trivia"] == "cannot open page") return array(); // no such page
      
$tag_s strpos($this->page["Trivia"],'<ul class="trivia">');
      
$tag_e strrpos($this->page["Trivia"],'<ul class="trivia">'); // maybe more than one
      
$tag_e strrpos($this->page["Trivia"],"</ul>");
      
$goofs substr($this->page["Trivia"],$tag_s,$tag_e $tag_s);
      if (
preg_match_all("/<li>(.*?)<br><br><\/li>/",$goofs,$matches)) {
        
$gc count($matches[1]);
        for (
$i=0;$i<$gc;++$i$this->trivia[] = str_replace('href="/','href="http://'.$this->imdbsite."/",$matches[1][$i]);
      }
    }
    return 
$this->trivia;
  }

 
#------------------------------------------------------[ /soundtrack page ]---
  /** Get the soundtrack listing
   * @method soundtrack
   * @return array soundtracks (array[0..n] of array(soundtrack,array[0..n] of credits)
   * @brief Usually, the credits array should hold [0] written by, [1] performed by.
   *  But IMDB does not always stick to that - so in many cases it holds
   *  [0] performed by, [1] courtesy of
   */
  
function soundtrack() {
   if (empty(
$this->soundtracks)) {
    if (empty(
$this->page["Soundtrack"])) $this->openpage("Soundtrack");
    if (
$this->page["Soundtrack"] == "cannot open page") return array(); // no such page
    
if (preg_match_all("/<li>(.*?)<\/b><br>(.*?)<br>(.*?)<br>.*?<\/li>/",str_replace("\n"," ",$this->page["Soundtrack"]),$matches)) {
      
$mc count($matches[0]);
      for (
$i=0;$i<$mc;++$i$this->soundtracks[] = array("soundtrack"=>$matches[1][$i],"credits"=>array(
                                                           
str_replace('href="/','href="http://'.$this->imdbsite.'/',$matches[2][$i]),
                                                           
str_replace('href="/','href="http://'.$this->imdbsite.'/',$matches[3][$i])));
    }
   }
   return 
$this->soundtracks;
  }

 
#-------------------------------------------------[ /movieconnection page ]---
  /** Parse connection block (used by method movieconnection only)
   * @method private parseConnection
   * @param string conn connection type
   * @return array [0..n] of array mid,name,year,comment - or empty array if not found
   */
  
function parseConnection($conn) {
    
$tag_s strpos($this->page["MovieConnections"],"<h5>$conn</h5>");
    if (empty(
$tag_s)) return array(); // no such feature
    
$tag_e strpos($this->page["MovieConnections"],"<h5>",$tag_s+4);
    if (empty(
$tag_e)) $tag_e strpos($this->page["MovieConnections"],"<hr/><h3>",$tag_s);
    
$block substr($this->page["MovieConnections"],$tag_s,$tag_e-$tag_s);
    if (
preg_match_all("/\<a href=\"(.*?)\"\>(.*?)\<\/a\> \((\d{4})\)(.*\<br\/\>\&nbsp;-\&nbsp;(.*))?/",$block,$matches)) {
      
$mc count($matches[0]);
      for (
$i=0;$i<$mc;++$i) {
        
$mid substr($matches[1][$i],9,strlen($matches[1][$i])-10); // isolate imdb id from url
        
$arr[] = array("mid"=>$mid"name"=>$matches[2][$i], "year"=>$matches[3][$i], "comment"=>$matches[5][$i]);
      }
    }
    return 
$arr;
  }

  
/** Get connected movie information
   * @method movieconnection
   * @return array connections (versionOf, editedInto, followedBy, spinOff,
   *         spinOffFrom, references, referenced, features, featured, spoofs,
   *         spoofed - each an array of mid, name, year, comment or an empty
   *         array if no connections of that type)
   */
  
function movieconnection() {
    if (empty(
$this->movieconnections)) {
      if (empty(
$this->page["MovieConnections"])) $this->openpage("MovieConnections");
      if (
$this->page["MovieConnections"] == "cannot open page") return array(); // no such page
      
$this->movieconnections["versionOf"]  = $this->parseConnection("Version of");
      
$this->movieconnections["editedInto"] = $this->parseConnection("Edited into");
      
$this->movieconnections["followedBy"] = $this->parseConnection("Followed By");
      
$this->movieconnections["spinOffFrom"] = $this->parseConnection("Spin off from");
      
$this->movieconnections["spinOff"] = $this->parseConnection("Spin off");
      
$this->movieconnections["references"] = $this->parseConnection("References");
      
$this->movieconnections["referenced"] = $this->parseConnection("Referenced in");
      
$this->movieconnections["features"] = $this->parseConnection("Features");
      
$this->movieconnections["featured"] = $this->parseConnection("Featured in");
      
$this->movieconnections["spoofs"] = $this->parseConnection("Spoofs");
      
$this->movieconnections["spoofed"] = $this->parseConnection("Spoofed in");
    }
    return 
$this->movieconnections;
  }

 
#------------------------------------------------[ /externalreviews page ]---
  /** Get list of external reviews (if any)
   * @method extReviews
   * @return array [0..n] of array [url, desc] (or empty array if no data)
   */
  
function extReviews() {
    if (empty(
$this->extreviews)) {
      if (empty(
$this->page["ExtReviews"])) $this->openpage("ExtReviews");
      if (
$this->page["ExtReviews"] == "cannot open page") return array(); // no such page
      
if (preg_match_all("/\<li\>\<a href=\"(.*?)\"\>(.*?)\<\/a\>/",$this->page["ExtReviews"],$matches)) {
        
$mc count($matches[0]);
        for (
$i=0;$i<$mc;++$i) {
          
$this->extreviews[$i] = array("url"=>$matches[1][$i], "desc"=>$matches[2][$i]);
        }
      }
    }
    return 
$this->extreviews;
  }

 } 
// end class imdb

 #====================================================[ IMDB Search class ]===
 /** Search the IMDB for a title and obtain the movies IMDB ID
  * @package Api
  * @class imdbsearch
  * @extends imdb_config
  */
 
class imdbsearch extends imdb_config{
  var 
$page "";
  var 
$name NULL;
  var 
$resu = array();
  var 
$url "http://www.imdb.com/";
  var 
$main_trailer "";

  
/** Read the config
   * @constructor imdbsearch
   */
  
function imdbsearch() {
    
$this->imdb_config();
    
$this->search_episodes(FALSE);
  }

  
/** Search for episodes or movies
   * @method search_episodes
   * @param boolean enabled TRUE: Search for episodes; FALSE: Search for movies (default)
   */
  
function search_episodes($enable) {
    
$this->episode_search $enable;
  }

  
/** Set the name (title) to search for
   * @method setsearchname
   * @param string searchstring what to search for - (part of) the movie name
   */
  
function setsearchname ($name) {
   
$this->name $name;
   
$this->page "";
   
$this->url NULL;
  }

  
/** Set the URL (overwrite default search URL and run your own)
   *  This URL will be reset if you call the setsearchname() method
   * @method seturl
   * @param string URL to use
   */
  
function seturl($url){
   
$this->url $url;
  }

  
/** Create the IMDB URL for the movie search
   * @method private mkurl
   * @return string url
   */
  
function mkurl () {
   if (
$this->url !== NULL){
    
$url $this->url;
   }else{
     if (!isset(
$this->maxresults)) $this->maxresults 20;
     if (
$this->maxresults 0$query ";mx=20";
     if (
$this->episode_search$url "http://".$this->imdbsite."/find?q=".urlencode($this->name).$query.";s=ep";
     else {
       switch (
$this->searchvariant) {
         case 
"moonface" $query ";more=tt;nr=1"// @moonface variant (untested)
         
case "sevec"    $query "&restrict=Movies+only&GO.x=0&GO.y=0&GO=search;tt=1"// Sevec ori
         
default         : $query ";tt=on"// Izzy
       
}
       
$url "http://".$this->imdbsite."/find?q=".urlencode($this->name).$query;
     }
   }
   return 
$url;
  }

  
/** Setup search results
   * @method results
   * @param optional string URL Replace search URL by your own
   * @return array results
   */
  
function results ($url="") {
   if (
$this->page == "") {
     if (empty(
$url)) $url $this->mkurl();
     
$be = new IMDB_Request($url);
     
$be->sendrequest();
     
$fp $be->getResponseBody();
     if ( !
$fp ){
       if (
$header $be->getResponseHeader("Location")){
        if (
strpos($header,$this->imdbsite."/find?")) {
          return 
$this->results($header);
          break(
4);
        }
        
$url explode("/",$header);
        
$id  substr($url[count($url)-2],2);
        
$this->resu[0] = new imdb($id);
        return 
$this->resu;
       }else{
        return 
NULL;
       }
     }
     
$this->page $fp;
   } 
// end (page="")

   
$searchstring = array( '<A HREF="/title/tt''<A href="/title/tt''<a href="/Title?''<a href="/title/tt');
   
$i 0;
   foreach(
$searchstring as $srch){
    
$res_e 0;
    
$res_s 0;
    
$mids_checked = array();
    
$len strlen($srch);
    while (((
$res_s strpos ($this->page$srch$res_e)) > 10)) {
      if (
$i == $this->maxresults) break(2); // limit result count
      
$res_e strpos ($this->page"("$res_s);
      
$imdb_id substr($this->page$res_s $len7);
      
$ts strpos($this->page">",$res_s) +1// >movie title</a>
      
$te strpos($this->page,"<",$ts);
      
$title substr($this->page,$ts,$te-$ts);
      if ((
$title == "") || (in_array($imdb_id,$mids_checked))) continue; // empty titles just come from the images
      
$mids_checked[] = $imdb_id;
      
$tmpres = new imdb ($imdb_id); // make a new imdb object by id
      
$tmpres->main_title $title;
      
$ts strpos($this->page,"(",$te) +1;
      
$te strpos($this->page,")",$ts);
      
$tmpres->main_year=substr($this->page,$ts,$te-$ts);
      
$i++;
      
$this->resu[$i] = $tmpres;
    }
   }
   return 
$this->resu;
  }
// end class imdbsearch

?>
__________________
Do not ask me to help you work on your site that is not phpMyBitTorrent
Do not ask me to make a mod for any other source
Do not Ask me to setup your site.
I will no longer help you setup your site, there is a setup script if you have trouble with it post in the forum here or in BT.Manager™ forum
My Current Demo is here http://demo.btmanager.org/
Reply With Quote
The Following User Says Thank You to joeroberts For This Useful Post:
Giorgatzelos (7th September 2012)
  #3  
Old 7th September 2012, 15:49
Giorgatzelos's Avatar
Giorgatzelos Giorgatzelos is offline
Senior Member
 
Join Date: Nov 2009
Greece
Posts: 300
Default
Thanx...i do not know if it is working properly auto receive imdb data...i have to test with a torrent...It gives error no more and i thank you for that !

Reply With Quote
Reply

Tags
error , imdb , link

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT +2. The time now is 21:32. vBulletin skin by ForumMonkeys. Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.