Thread: IMDB Mod
View Single Post
  #35  
Old 14th January 2014, 16:26
fodbrothers fodbrothers is offline
Member
 
Join Date: Dec 2013
United Kingdom
Posts: 13
Default IMDB Rating help
hi all in the browse i have the imdb rating but it doesnt show the rating can someone help i have posted the details.php followed by the takeupload.php
if someone could help i would be greatful

PHP Code:
<?php
/***************************************************************************
 *  NZB Details Page
 *  ========================================
 *  NZB Mod - Public v.TS-1.0b
 *  TorrentStrike version
 *  ========================================
 *  created by dodgy
 *  http://www.webdeviation.com
 *  Special thanks to all who have had a hand in TBDev/TorrentStrike
 ***************************************************************************/

ob_start("ob_gzhandler");
?>
<script LANGUAGE="JavaScript">
<!-- Begin
var checkflag = "false";
function check(field) {
    if (checkflag == "false") {
        for (i = 0; i < field.length; i++) {
            field[i].checked = true;}
        checkflag = "true";
        return "Uncheck All"; }
    else {
        for (i = 0; i < field.length; i++) {
            field[i].checked = false; }
        checkflag = "false";
    return "Check All"; }
}
//  End -->
</script>
<?
require_once("include/bittorrent.php");
include_once(
"imdb.class.php");
dbconn();

// ----- For display of row with missing segments:
function missing_segments($segments$subjseg) {
      if (
$segments == $subjseg)
            
$display ">($segments/$subjseg)";
      elseif (
$segments $subjseg)
            
$display " color=\"red\">($segments/$subjseg)";
      elseif (
$segments $subseg)
            
$display " color=\"green\">($segments/$subjseg)";
      return 
$display;          



// ----- Cleans NZB Subjects (not finished - add your own):
function clean_nzb_subj($string) {
      
$string str_replace("&#x22;"" "$string);
      
$string str_replace("è""e"$string);
      
$string str_replace(""""\""$string);
      
$string str_replace("_"" "$string);
      return 
$string;
}

/* ---- To retrieve piece information from dB & display it on nzb page, with form
   that will record which pieces are selected by user & therefore which pieces 
   will be retrieved. ---- */
function showpieces($id$nzbname$nzbvernum) {
      
    
$pl "<form name=\"partnzb\" action=\"partnzbdload.php\" method=\"post\" enctype=\"multipart/form-data\">\n";
    
$pl .= "<table width=\"100%\" class=\"main\" border=\"1\" cellspacing=\"0\" cellpadding=\"4\">\n";
    
$pl .= "<tr><td width=\"3%\" class=\"colhead\" align=\"right\">Dl?</td>".
        
"<td class=\"colhead\">Subject</td>".
        
"<td width=\"8%\" class=\"colhead\" align=\"right\">Size</td>".
        
"<td width=\"8%\" class=\"colhead\" align=\"right\">Date</td>".
        
"<td width=\"6%\" class=\"colhead\" align=\"right\">Parts</td></tr>\n";
        
    
$piecelist = @mysql_query("SELECT nzb_piece, piece_date, piece_subject, piece_size, piece_segments, piece_subjseg FROM nzbpiecelist WHERE nzb = $id ORDER BY nzb_piece");
    
    while (
$plist mysql_fetch_array($piecelist)) {
                    
        
// Convert date:
        
$dateunix $plist['piece_date'];
        
$dateposted date("Y-m-d G:i:s"$dateunix);
        
        
// Segment display/calculation:
        
$segments $plist['piece_segments'];
        
$subjseg $plist['piece_subjseg'];
        
        
// the rows:
        
$pl .= "<tr><td>".(getNzbPermissions("part")==&& $CURUSER["nzbstodaydl"] < getNzbPermissions("maxdlpday")?"<input type=\"checkbox\" name=\"nzbpieces[]\" ".
                    
"value=\"" $plist['nzb_piece'] .
                    
"\" />":"")."</td>".
              
"<td><font class=\"small\">" safe(clean_nzb_subj($plist['piece_subject'])) . "</font></td>".
              
"<td align=right><font class=\"small\">" mksize($plist['piece_size']) . "</font></td>".
              
"<td align=right><font class=\"small\">" $dateposted "</font></td>".
              
"<td align=right><font class=\"small\"" missing_segments($segments$subjseg) . "</font></td></tr>\n";
    }
    
    
$pl .= "</table>\n".
        
"<input type=\"hidden\" name=\"nzb\" value=\"" $id ."\" />".
        
"<input type=\"hidden\" name=\"nzb_name\" value=\"" $nzbname ."\" />".
        
"<input type=\"hidden\" name=\"nzbvernum\" value=\"" $nzbvernum ."\" />".
        
"<input type=\"button\" value=\"Check all\" onClick=\"this.value=check(partnzb)\" class=\"codebuttons\" style=\"width:90px;height:25px;\" />";
    if (
getNzbPermissions("part") == 1  && $CURUSER["nzbstodaydl"] < getNzbPermissions("maxdlpday")) {
        
$pl .= "<br /><div align=\"center\"><input type=\"submit\" name=\"dlzip\" value=\"Download Selected in Zip File\" class=\"codebuttons\" style=\"width:200px;height:25px;\" />".
        
"&nbsp;&nbsp;&nbsp;<input type=\"submit\" name=\"dlnzb\" value=\"Download Selected as NZB\" class=\"codebuttons\" style=\"width:200px;height:25px;\" /></div><br /><br />\n";
    } elseif (
getNzbPermissions("part") == 1  && $CURUSER["nzbstodaydl"] >= getNzbPermissions("maxdlpday")) {
        
$pl .= "<br /><div align=\"center\">".getNzbPermissions("maxmsg")."</div><br /><br />\n"
    } else {
        
$pl .= "<br /><div align=\"center\">".getNzbPermissions("partmsg")."</div><br /><br />\n";
    }
    
$pl .= "<a href=\"nzbdetails.php?id=$id\" class=\"sublink\">[Hide list]</a>".
            
"</form>\n";
      
    return 
$pl;      
}

loggedinorreturn();

$id $_GET["id"];

if (!isset(
$id) || !$id)
    die();
    
$res mysql_query("SELECT nzbs.owner, nzbs.name, nzbs.descr, nzbs.category, LENGTH(nzbs.nfo)AS nfosz, nzbs.filename, nzbs.size, nzbs.numfiles, nzbs.poster, nzbs.postdate, nzbs.groups, nzbs.id, nzbs.added, nzbs.views, nzbs.hits, nzbs.pars, nzbs.partotsize, nzbs.nzbvernum, nzbs.autoimdb, nzbs.url, nzbs.imdbrating, nzbs.genre, nzbs.addtext, nzbs.format, nzbcategories.name AS cat_name, users.username FROM nzbs LEFT JOIN nzbcategories ON nzbs.category = nzbcategories.id LEFT JOIN users ON nzbs.owner = users.id WHERE nzbs.id = $id")
    or 
sqlerr();
/* $res = mysql_query("SELECT nzbs.owner, nzbs.name, nzbs.descr, nzbs.category, LENGTH(nzbs.nfo)AS nfosz, nzbs.filename, nzbs.size, nzbs.numfiles, nzbs.poster, nzbs.postdate, nzbs.groups, nzbs.id, nzbs.added, nzbs.views, nzbs.hits, nzbs.pars, nzbs.partotsize, nzbs.nzbvernum, nzbs.autoimdb, nzbs.url, nzbs.imdbrating, nzbs.genre, nzbs.addtext, nzbs.format, nzbcategories.name AS cat_name, users.username, users.advertisename FROM nzbs LEFT JOIN nzbcategories ON nzbs.category = nzbcategories.id LEFT JOIN users ON nzbs.owner = users.id WHERE nzbs.id = $id")
    or sqlerr(); // USE THIS QUERY IF ANONYMOUS UPLOADER MOD PRESENT */

$row mysql_fetch_array($res);

$owned $moderator 0;
    if (
get_user_class() >= UC_MODERATOR)
        
$owned $moderator 1;
    elseif (
$CURUSER["id"] == $row["owner"])
        
$owned 1;
        
if (
$_GET["hit"]) {
    
mysql_query("UPDATE nzbs SET views = views + 1 WHERE id = $id");
    if (
$_GET["tocomm"])
        
header("Location: $BASEURL/nzbdetails.php?id=$id&page=0#startcomments");
    elseif (
$_GET["filelist"])
        
header("Location: $BASEURL/nzbdetails.php?id=$id&filelist=1#filelist");
    else
        
header("Location: $BASEURL/nzbdetails.php?id=$id");
    exit();
}

if (!isset(
$_GET["page"])) {
    
stdhead("Details for nzb \"" $row["name"] . "\"");

    
$spacer "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";

    if (
$_GET["uploaded"]) {
        print(
"<h2>Successfully uploaded!</h2>\n");
    }
    elseif (
$_GET["edited"]) {
        print(
"<h2>Successfully edited!</h2>\n");
        if (isset(
$_GET["returnto"]))
            print(
"<p><b>Go back to <a href=\"" safe($_GET["returnto"]) . "\">whence you came</a>.</b></p>\n");
    }
    elseif (isset(
$_GET["searched"])) {
        print(
"<h2>Your search for \"" safe($_GET["searched"]) . "\" gave a single result:</h2>\n");
    }


    
$addtext safe($row["addtext"])."&nbsp;";
    
$format = ($row["format"]!="na"?"&nbsp;<img src=\"".$pic_base_url."sml_".$row["format"].".gif\" alt=\"".$row["format"]."\" />":"");

    
$s=$row["name"];
    print(
"<h1>$s</h1>\n");
    print(
"<h3>.: $addtext $format :.</h3><br /><br />\n");
    print(
"<table width=\"750\" border=\"1\" cellspacing=\"0\" cellpadding=\"5\">\n");

    
$url "nzbedit.php?id=" $row["id"];
    if (isset(
$_GET["returnto"])) {
        
$addthis "&amp;returnto=" urlencode($_GET["returnto"]);
        
$url .= $addthis;
        
$keepget .= $addthis;
    }
    
$editlink "a href=\"$url\" class=\"sublink\"";
    

    
// Get permissions for download link display
    
if ((getNzbPermissions("zip") == || getNzbPermissions("nzb") == 1) && $CURUSER["nzbstodaydl"] < getNzbPermissions("maxdlpday"))
    {
        print(
"<form action=\"nzbdownload.php/$id/" rawurlencode($row["name"]) . ".nzb\" method=\"post\">");
        print(
"<tr><td class=\"rowhead\" width=\"1%\">Download</td><td width=\"99%\" align=\"center\">");
        if (
getNzbPermissions("zip") == 1)
            print(
"<input type=\"submit\" name=\"dlzip\" value=\"Download As Zip File\" class=\"codebuttons\" style=\"width:150px;height:25px;\" />");          
        if (
getNzbPermissions("nzb") == 1)
            print(
"&nbsp;&nbsp;&nbsp;<input type=\"submit\" name=\"dlnzb\" value=\"Download As NZB\" class=\"codebuttons\" style=\"width:150px;height:25px;\" />");
        print(
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
        print(
"</td></tr>");
        print(
"</form>\n");

    }
    elseif ((
getNzbPermissions("zip") == || getNzbPermissions("nzb") == 1) && $CURUSER["nzbstodaydl"] >= getNzbPermissions("maxdlpday")) {
        print(
"<tr><td class=\"rowhead\" width=\"1%\">Download</td><td width=\"99%\" align=\"center\">");
        print(
getNzbPermissions("maxmsg")."</td></tr>");
    } else {
        print(
"<tr><td class=\"rowhead\" width=\"1%\">Download</td><td width=\"99%\" align=\"center\">");
        print(
getNzbPermissions("nzbmsg")."</td></tr>");
    }



/*echo "<td width='58'>&nbsp;Download</td>
    <td width='163'><a href='/nzbdownload.php/$id/" . rawurlencode($row["name"]) . ".nzb'>download</a></td></tr>";
*/    

if (isset($row["url"])) {
    
$oIMDB = new IMDB($row["url"]);
    if (
$oIMDB -> isReady) {
        
$poster $oIMDB -> getPoster();
        
$rate $oIMDB -> getRating();
        
$dire $oIMDB -> getDirector();
        
$cast $oIMDB -> getCastAndCharacter();
        
$count $oIMDB -> getCountry();
        
$idisk $oIMDB -> getDescription();
        if (
$oIMDB->getTrailerAsUrl() != 'n/A') {
        
$vid '<iframe width="660" height="500" scrolling="no" border="0" src="' $oIMDB -> getTrailerAsUrl() . '"></iframe>';
        }else {
        
$vis $oIMDB -> getTrailerAsUrl();
        }
    }
    
$imdb '
<td width="58">&nbsp;Poster</td>
<td width="163"><img src="' 
$poster '"></td>
</tr>
<tr>
    <td>&nbsp;Rating</td>
    <td>' 
$rate '</td>
</tr>
<tr>
    <td>&nbsp;Director</td>
    <td>' 
$dire '</td>
</tr>
<tr>
    <td>&nbsp;Cast</td>
    <td>' 
$cast '</td>
</tr>
<tr>
    <td>&nbsp;County</td>
    <td>' 
$count '</td>
</tr>
<tr>
    <td>&nbsp;Description</td>
    <td>' 
$idisk '</td>
    <tr>
    <tr/>'
;

    print 
$imdb;
}

    if (!empty(
$row["descr"]))
        
$descr $row["descr"];
    else
        
$descr "";
    
$autodata = ($row["autoimdb"] == "yes"?format_comment($autodata)."":"");
    
$descri format_comment($descr);
    
tr("Description"$autodata."".$descri1);                

    if (
$row["nfosz"] > 0)
        print(
"<tr><td class=\"rowhead\" align=\"right\">NFO</td><td align=\"left\">".(getNzbPermissions("nfo") != 0?"<a href=nzbviewnfo.php?id=$row[id]><b>View NFO</b></a> (" .
            
mksize($row["nfosz"]) . ")":getNzbPermissions("nfomsg"))."</td></tr>\n");

    if (
$row["url"] != "")
        
tr("Info URL"format_urls(safe($row["url"])), 1);
     
    if (isset(
$row["cat_name"]))
        
tr("Type"$row["cat_name"]);
    else
        
tr("Type""(none selected)");
        
    if (
$row["autoimdb"] == "no" && $row["genre"] != "")
         
tr("Genre"safe($row["genre"]), 1);

    
tr("Size",mksize($row["size"]) . " (" number_format($row["size"]) . " bytes)");

    
tr("Poster"$row["poster"]);
    
    
$datenix $row["postdate"];
    
$agepost show_age($datenix);
    
$datepost date("Y-m-d H:i:s"$datenix);
    
tr("Posted"$datepost." ($agepost days ago)");
    
    
$groups unserialize($row['groups']);
    if (
is_array($groups)) {
        
$grp "";
        foreach (
$groups as $key=>$val) {
            
$grp .= "$val\n";
        }
    } else { 
        
$grp $groups;
    }     
    
tr("Groups"safe($grp));
    
    if (
$row["pars"] > 0) {
       
$percentpars sprintf"%.2f", (($row["partotsize"] / ($row["size"] - $row["partotsize"])) * 100));
    }
    
tr("par2 Files", ($row['pars'] == 0?"None":$row['pars'].", ".mksize($row["partotsize"])." in total (Can rebuild approx $percentpars% of total filesize)"));      
    
tr("NZB Added"$row["added"]);
    
tr("Views"$row["views"]);
    
tr("Grabs"$row["hits"]);
    
    
$uprow = (isset($row["username"]) ? ("<a href=userdetails.php?id=" $row["owner"] . "><b>" safe($row["username"]) . "</b></a>") : "<i>unknown</i>"); 
    
/* USE ABOVE ^^^ OR BELOW vvv DEPENDING ON WHETHER YOU HAVE THE ANONYMOUS UPLOADER MOD */
/*    $addnam = $row['advertisename'];
    $keepget = "";
    $uprow = ("<i>Anonymous</i>");
    if (get_user_class() >= UC_MODERATOR) 
        $uprow = (isset($row["username"]) ? ("<a href=userdetails.php?id=" . $row["owner"] . "><b>" . safe($row["username"]) . "</b></a>") : "<i>unknown</i>"); 
    if ($addnam == "yes") 
        $uprow = (isset($row["username"]) ? ("<a href=userdetails.php?id=" . $row["owner"] . "><b>" . safe($row["username"]) . "</b></a>") : "<i>unknown</i>"); */
    
if ($owned
        
$uprow .= $spacer<$editlink><b>[Edit this NZB]</b></a>"
    
tr("Upped by"$uprow1);

    
//tr("Report<br />NZB", "Click <a href=\"report.php?typ=nzb&id=$id\"><b><font color=\"#ff0532\">here</font></b></a> to report this NZB to staff for violation of the rules", 1);
    
    
if (!$_GET["filelist"]) {
        
tr("Num files<br /><a href=\"nzbdetails.php?id=$id&amp;filelist=1$keepget#filelist\" class=\"sublink\">[See full list]</a>"$row["numfiles"] . " files"1);
    } else {
        
tr("Num files"$row["numfiles"] . " files"1);     
        
tr("<a name=\"filelist\">File list</a><br /><a href=\"nzbdetails.php?id=$id$keepget\" class=\"sublink\">[Hide list]</a>"showpieces($id$row["name"], $row['nzbvernum']), 1);
    }
    
    print(
"</table></p>\n");
    
    
/* The comparison value of '0' with $datenix is so that failed uploads with no nzbs.datepost value can be deleted by the uploader */  
    
if (($datenix!=0) && (get_user_class() >= UC_MODERATOR)) {    
        print(
"<p>\n");
        print(
"<form method=\"post\" action=\"nzbdelete.php\">\n");
        print(
"<table border=\"1\" cellspacing=\"0\" cellpadding=\"5\">\n");
        print(
"<tr><td class=\"row2\" colspan=\"2\"><b>Delete NZB.</b> Reason:</td></tr>");
       
// print("<td><input name=\"reasontype\" type=\"radio\" value=\"1\">&nbsp;Expired </td><td>$SITENZBRETENTION days old</td></tr>\n");
        
print("<tr><td><input name=\"reasontype\" type=\"radio\" value=\"2\">&nbsp;Dupe</td><td><input type=\"text\" size=\"40\" name=\"reason[]\"></td></tr>\n");
        print(
"<tr><td><input name=\"reasontype\" type=\"radio\" value=\"3\">&nbsp;Nuked</td><td><input type=\"text\" size=\"40\" name=\"reason[]\"></td></tr>\n");
        print(
"<tr><td><input name=\"reasontype\" type=\"radio\" value=\"4\">&nbsp;Rules</td><td><input type=\"text\" size=\"40\" name=\"reason[]\">(req)</td></tr>");
        print(
"<tr><td><input name=\"reasontype\" type=\"radio\" value=\"5\" checked=\"checked\" />&nbsp;Other:</td><td><input type=\"text\" size=\"40\" name=\"reason[]\">(req)</td></tr>\n");
        print(
"<input type=\"hidden\" name=\"id\" value=\"$id\" />\n");
        if (isset(
$_GET["returnto"]))
            print(
"<input type=\"hidden\" name=\"returnto\" value=\"" safe($_GET["returnto"]) . "\" />\n");
        print(
"<td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"Delete it!\" class=\"codebuttons\" style=\"width:120px;height:25px;\" /></td></tr>\n");
        print(
"</table>");
        print(
"</form>\n");
        print(
"</p>\n");
    } elseif ((
$datenix==0) && (getNzbPermissions("ulnzb")==1)) {
        print(
"<p>\n");
        print(
"<form method=\"post\" action=\"nzbdelete.php\">\n");
        print(
"<table border=\"1\" cellspacing=\"0\" cellpadding=\"5\">\n");
        print(
"<tr><td class=\"row2\" colspan=\"2\"><b>Delete Failed NZB.</b> Reason:</td></tr>");
        print(
"<tr><td><input name=\"reasontype\" type=\"hidden\" value=\"5\"  />&nbsp;What happened?:</td><td><input type=\"text\" size=\"40\" name=\"reason[]\">(req)</td></tr>\n");
        print(
"<input type=\"hidden\" name=\"id\" value=\"$id\" />\n");
        if (isset(
$_GET["returnto"]))
            print(
"<input type=\"hidden\" name=\"returnto\" value=\"" safe($_GET["returnto"]) . "\" />\n");
        print(
"<td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"Delete it!\" class=\"codebuttons\" style=\"width:120px;height:25px;\" /></td></tr>\n");
        print(
"</table>");
        print(
"</form>\n");
        print(
"</p>\n");
    }
} else {
    
stdhead("Comments for NZB \"" $row["name"] . "\"");
    print(
"<h1>Comments for <a href=\"nzbdetails.php?id=$id\">" $row["name"] . "</a></h1>\n");
}

print(
"<p><a name=\"startcomments\"></a></p>\n");

$commentbar "<p align=\"center\"><a class=\"index\" href=\"nzbcomment.php?action=add&amp;tid=$id\">Add a comment</a></p>\n";

$subres mysql_query("SELECT COUNT(*) FROM nzbcomments WHERE nzb = $id");
$subrow mysql_fetch_array($subres);
$count $subrow[0];

if (!
$count) {
    print(
"<h2>No comments yet</h2>\n");
} else {
    list(
$pagertop$pagerbottom$limit) = pager(20$count"nzbdetails.php?id=$id&", array(lastpagedefault => 1));

    
$subres mysql_query("SELECT nzbcomments.id, text, user, nzbcomments.added, editedby, editedat, avatar, warned, ".
        
"username, title, class, donor FROM nzbcomments LEFT JOIN users ON nzbcomments.user = users.id WHERE nzb = " .
        
"$id ORDER BY nzbcomments.id $limit") or sqlerr(__FILE____LINE__);
    
/* USE ABOVE ^^^ OR BELOW vvv DEPENDING ON WHETHER YOU HAVE THE ANONYMOUS UPLOADER MOD */
 /*   $subres = mysql_query("SELECT nzbcomments.id, text, user, nzbcomments.added, editedby, editedat, avatar, warned, ".
        "username, title, class, donor, advertisename FROM nzbcomments LEFT JOIN users ON nzbcomments.user = users.id WHERE nzb = " .
        "$id ORDER BY nzbcomments.id $limit") or sqlerr(__FILE__, __LINE__); */
    
$allrows = array();
    while (
$subrow mysql_fetch_array($subres))
        
$allrows[] = $subrow;

    print(
$commentbar);
    print(
$pagertop);

    
nzbcommenttable($allrows$row["owner"]);

    print(
$pagerbottom);
}

print(
$commentbar);

stdfoot();
?>
PHP Code:
<?php
/***************************************************************************
 *  NZB Uploading Script
 *  ========================================
 *  NZB Mod - Public v.TS-1.0b
 *  TorrentStrike version
 *  ========================================
 *  created by dodgy
 *  http://www.webdeviation.com
 *  Special thanks to all who have had a hand in TBDev/TorrentStrike
 ***************************************************************************/

/* The max execution time of the script and the memory limit need to be quite high here - depending on your server you may even need to raise this a little higher. */ 
ini_set("max_execution_time""3000");
ini_set("memory_limit""32M");
ini_set("upload_max_filesize"$MAXNZBSIZE);
require_once(
"include/bittorrent.php");
include_once(
"include/zipclasses.php");

$zipped false;
dbconn();
 
 if (!empty(
$_POST['url']))
$url unesc($_POST['url']);  


// for extracting the number of segments from the subject
function subj_seg($input)
{
    for (
$i=strlen($input);$i>0;$i--) {
        if (
$input{$i} == "/") {
            break;
        }
    }

    
$segs substr($input,$i);
    
$segs str_replace("/"""$segs);
    
$segs str_replace(")"""$segs);
    return 
$segs;    
}

// Prevents simplexml utf-8 errors, forces subjects/poster to utf-8
function clean_utf8($where) {
    
$filecontent file_get_contents($where);
    
$filecontent = @mb_convert_encoding($filecontent"UTF-8");
    
file_put_contents($where$filecontent);
    unset (
$filecontent);
}

// to get nzb version number (DTD) and strip comments left by anything else
function nzb_ver_num($where) {
    global 
$SITESLOGAN;

    
$filecontent file_get_contents($where);
    
    if (
eregi("//newzBin//DTD NZB 1.0//EN"$filecontent)) {
        
$nzbvernum "1.0";
    } elseif (
eregi("//newzBin//DTD NZB 0.9//EN"$filecontent)) {
        
$nzbvernum "0.9";
    
// for some odd nzbs that are appearing with no DTD, assume they're 1.0
    
} elseif (eregi("<nzb>"$filecontent)) { 
        
$nzbvernum "1.0";
    } else {
        
bark("Invalid NZB File! See the FAQ.");
    }
        
    
$goodstring $SITESLOGAN;
    if (
eregi("<!--(.*)-->"$filecontent$matches)) {
        
$badstring $matches[1];
        
$filecontent str_replace($badstring$goodstring$filecontent);
        
file_put_contents($where$filecontent);
    }      
    
    unset (
$badstring$goodstring$filecontent$matches);
    return 
$nzbvernum;
}    

// To store each piece (<file>***</file>) in the db, includes crude dupe checker
// Regexp matches were quicker in testing for this than using simplexml
function storepieces($where$id) {
         
    
$filecontent file_get_contents($where);
    
$parts explode("</file>"$filecontent);
    
$nzbpiece 0;
    
    if (
eregi("<file (.*)"$parts[1], $matches)) {
        
$dupepiece $matches[1];
        
$dupepiece "<file ".$dupepiece."";
        
$dupepiece sqlesc($dupepiece);
        
$dupe mysql_query("SELECT nzb FROM nzbpiecelist WHERE filepiece = $dupepiece");
    
        if ((
mysql_num_rows($dupe) == 0) || !$dupe) {
            foreach(
$parts as $part){
                if (
eregi("<file (.*)"$part$matches)) {
                    
$filepiece $matches[1];
                    
$filepiece "<file ".$filepiece."";
                    
$filepiece sqlesc($filepiece);
                    
mysql_query("INSERT INTO nzbpiecelist (nzb, nzb_piece, filepiece) VALUES ($id$nzbpiece$filepiece)");
                    
$nzbpiece++;
                }
            }
        } elseif (
mysql_num_rows($dupe) > 0) {
            
mysql_query("DELETE FROM nzbs WHERE id = $id");
            
bark("This is a duplicate NZB, use search next time!");
        }
    }
    
    unset (
$parts$dupepiece$filecontent$nzbpiece$matches$dupe);


// NZB Parser - simplexml version (for php5)
// To gather info about each piece to store in db (to later retrieve and show filelist)
// This is the preferable method as it is very quick
function pieceslisting($where$id) {
      
    
$filecontent file_get_contents($where);
    
$xml simplexml_load_string($filecontent) or die ("Unable to load XML file!"); 
    
    
$nzbpiece 0;
    
    foreach(
$xml->{"file"} as $nfile) {
        
$nposter = (string) trim($nfile['poster']);
        
$nposter sqlesc($nposter);
                    
        
$ndate trim($nfile['date']);
                    
        
$nsubject = (string) trim($nfile['subject']);
        
// To find num of segments in subject:
        
$nsubjsegs subj_seg($nsubject);
        
        
// To find out if Par or not
        
$npar sqlesc(stristr($nsubject"par2")?0:1);
        
        
$nsubject sqlesc($nsubject);
                    
        
$groups = array();
        foreach(
$nfile->groups->group as $group) {
              
$groups[] = (string) trim($group);
        }
        
$ngroups sqlesc(serialize($groups));
                               
        
$nsegcount 0;
        
$nsize 0;
        foreach(
$nfile->segments->segment as $segment) {
              
$nbytes trim($segment['bytes']);
              
$nsize += $nbytes;
              
$nsegcount++; 
        }
                  
        
$query mysql_query("UPDATE nzbpiecelist SET piece_poster = $nposter, piece_date = $ndate, piece_subject = $nsubject, piece_groups = $ngroups, piece_size = $nsize, piece_segments = $nsegcount, piece_subjseg = $nsubjsegs, piece_par = $npar WHERE nzb = $id AND nzb_piece = $nzbpiece");
        if(!
$query)
              
sqlerr(__FILE____LINE__);
        
        
$nzbpiece++;
    }
    unset (
$filecontent$nzbpiece$xml$nposter$ndate$nsubject$ngroups$nsize$nsegcount$nsubjsegs$npar);
}

/*
// NZB Parser - DOM xml version (for php5)
// To gather info about each piece to store in db (to later retrieve and show filelist)
// Note that this method is supposedly very slow when handling large documents
function pieceslisting($where, $id) {

    // here we must specify the version of XML : i.e: 1.0 
    $xml = new DOMDocument('1.0');
    $xml->loadXML(file_get_contents($where));
    
    $nzbpiece = 0;
    
    foreach($xml->getElementsByTagName('file') as $nfile) {
            
        $nposter = $nfile->getAttribute('poster');
        $nposter = sqlesc($nposter);
        
        $ndate = $nfile->getAttribute('date');
        $ndate = 0 + $ndate;
        
        $nsubject = $nfile->getAttribute('subject');
        
        // To find num of segments in subject:
        $nsubjsegs = 0 + subj_seg($nsubject);
        
        // To find out if Par or not
        $npar = sqlesc(stristr($nsubject, "par2")?0:1);
        
        $nsubject = sqlesc($nsubject);
        
        // For groups:
        $groups = array();
        $xmlgroups = $nfile->getElementsByTagName('groups')->item(0);
        foreach ($xmlgroups->getElementsByTagName('group') as $groupNode) {
            $groups = $groupNode->firstChild->nodeValue;
        }
        $ngroups = sqlesc(serialize($groups));
        
        //For segments:
        $nsegcount = 0;
        $nsize = 0;
        $xmlsegments = $nfile->getElementsByTagName('segments')->item(0);
        foreach ($xmlsegments->getElementsByTagName('segment') as $segmentNode) {
            $nbytes = $segmentNode->getAttribute('bytes');
            $nsize += $nbytes;
            $nsegcount++;
        }
        
        $query = mysql_query("UPDATE nzbpiecelist SET piece_poster = $nposter, piece_date = $ndate, piece_subject = $nsubject, piece_groups = $ngroups, piece_size = $nsize, piece_segments = $nsegcount, piece_subjseg = $nsubjsegs, piece_par = $npar WHERE nzb = $id AND nzb_piece = $nzbpiece");
        if(!$query)
              sqlerr(__FILE__, __LINE__);
        
        $nzbpiece++;
    }
    unset ($xml, $nzbpiece, $nposter, $ndate, $nsubject, $ngroups, $nsize, $nsegcount, $nsubjsegs, $npar);
}
*/
/*
// NZB Parser - domxml version (for php4.3.x)
// To gather info about each piece to store in db (to later retrieve and show filelist)
// ***THIS VERSION OF THE NZB PARSER IS CURRENTLY UNTESTED! SEE THE README!***
function pieceslisting($where, $id) {

    if (!$xml = domxml_open_file($where))
        die ("Unable to load XML file!");
    
    $nzbpiece = 0;
    
    foreach($xml->get_elements_by_tagname('file') as $nfile) {
            
        $nposter = $nfile->get_attribute('poster');
        $nposter = sqlesc($nposter);
        
        $ndate = $nfile->get_attribute('date');
        $ndate = 0 + $ndate;
        
        $nsubject = $nfile->get_attribute('subject');
        
        // To find num of segments in subject:
        $nsubjsegs = 0 + subj_seg($nsubject);
        
        // To find out if Par or not
        $npar = sqlesc(stristr($nsubject, "par2")?0:1);
        
        $nsubject = sqlesc($nsubject);
        
        // For groups:
        $groups = array();
        $xmlgroups = $nfile->get_elements_by_tagname('groups');
        foreach ($xmlgroups->get_elements_by_tagname('group') as $groupNode) {
            $groups = $groupNode->first_child->node_value;
            // $groups = $groupNode->get_content(); // ??? This could possibly work instead
        }
        $ngroups = sqlesc(serialize($groups));
        
        //For segments:
        $nsegcount = 0;
        $nsize = 0;
        $xmlsegments = $nfile->get_elements_by_tagname('segments');
        foreach ($xmlsegments->get_elements_by_tagname('segment') as $segmentNode) {
            $nbytes = $segmentNode->get_attribute('bytes');
            $nsize += $nbytes;
            $nsegcount++;
        }
        
        $query = mysql_query("UPDATE nzbpiecelist SET piece_poster = $nposter, piece_date = $ndate, piece_subject = $nsubject, piece_groups = $ngroups, piece_size = $nsize, piece_segments = $nsegcount, piece_subjseg = $nsubjsegs, piece_par = $npar WHERE nzb = $id AND nzb_piece = $nzbpiece");
        if(!$query)
              sqlerr(__FILE__, __LINE__);
        
        $nzbpiece++;
    }
    unset ($xml, $nzbpiece, $nposter, $ndate, $nsubject, $ngroups, $nsize, $nsegcount, $nsubjsegs, $npar);
}
*/      

// Need to ensure that zip file is deleted when script dies
function bark($msg) {
    global 
$zipped$fname;
    if (
$zipped)
        @
unlink($fname);
    
genbark($msg"Upload failed!");
}

loggedinorreturn();

// Check upload permission
if (getNzbPermissions("ulnzb")==0)
  die;

/*// if upload disabled:  
if ($CURUSER["uploadpos"] == 'no')
die;*/

if ($_POST["nonimdb"])
    
$isimdb "nonimdb";
elseif (
$_POST["imdb"])
    
$isimdb "imdb";
else
    
bark("WTF! How'd you end up here?");      
  
if (
$isimdb == "nonimdb") {
    foreach(
explode(":","descr:type:name:format") as $v) {
        if (!isset(
$_POST[$v]))
            
bark("missing form data");
    }
} elseif (
$isimdb == "imdb") {
    foreach(
explode(":","imdburl:type:format") as $v) {
        if (!isset(
$_POST[$v]))
            
bark("missing form data");
    }
} else {
    
bark("WTF! How'd you end up here?");
}

if (!isset(
$_FILES["file"]))
    
bark("missing form data");
    
$f $_FILES["file"];
$fname unesc($f["name"]);
if (empty(
$fname))
    
bark("Empty filename!");
if (
eregi("http:"$fname) || eregi("www\."$fname))
    
bark("Filename cannot contain a URL!");
    
$nfofile $_FILES['nfo'];
if (
$nfofile['name'] != '')

{
    if (
$nfofile['size'] == 0)
        
bark("0-byte NFO");

    if (
$nfofile['size'] > 65535)
        
bark("NFO is too big! Max 65,535 bytes.");

    
$nfofilename $nfofile['tmp_name'];

    if (@!
is_uploaded_file($nfofilename))
        
bark("NFO upload failed");
}

$descr unesc($_POST["descr"]);
if (
$isimdb == "nonimdb") {
    if (!
$descr)
        
bark("You must enter a description!");
}
  
$catid = ($_POST["type"]);
if (!
is_valid_id($catid))
    
bark("You must select a category to put the NZB in!");

$tmpname $f["tmp_name"];
if (!
is_uploaded_file($tmpname))
    
bark("eek");

// zipped uploads:    
if (getNzbPermissions("ulzip")==1) {
    if (
preg_match('/^(.+)\.zip$/si'$fname$matches)) {
        
$zipname $matches[1];
        
$zip = new dUnzip2($tmpname);
        
$list $zip->getList();
        
$zpdfilecount 0;
        foreach(
$list as $fileName=>$zippedFile) {
            
$zpdnzb $fileName;
            
$zpdfilecount++;
        }
        if (
$zpdfilecount>1)
            
bark("Only upload one file at a time!");
        if (!
preg_match('/^(.+)\.nzb$/si'$zpdnzb))
            
bark("What did you just upload?!!");
        
$zip->unzip("$zpdnzb""$zpdnzb");
        if (!
file_exists("$zpdnzb")) 
            
bark("What did you just upload?!!");
        
$fname $tmpname = (string) $zpdnzb;
        
$zipped true;
    }
}

if (!
filesize($tmpname))
    
bark("Empty file!");    

if (!
validfilename($fname))
    
bark("Invalid filename!");
if (!
preg_match('/^(.+)\.nzb$/si'$fname$matches))
    
bark("Invalid filename (not an .nzb).");
$shortfname $nzbname $matches[1];
if (!empty(
$_POST["name"])) {
    
$nzbname unesc($_POST["name"]);
    if (!
validfilename($nzbname))
        
bark("Invalid name for the NZB in the Name field, please change it!");
}
    
$format sqlesc($_POST["format"]);

if (!empty(
$_POST["addtext"])) {
    
$addtext = (strlen($_POST["addtext"])>25?substr($_POST["addtext"],0,25):$_POST["addtext"]);
    
$addtext sqlesc($addtext);
} else {
    
$addtext sqlesc("");
}

if (
$isimdb == "nonimdb") { 
    if (!empty(
$_POST["genre"])) {
         
$genre = (strlen($_POST["genre"])>10?substr($_POST["genre"],0,10):$_POST["genre"]);
         
$genre sqlesc($_POST["genre"]);
    } else {
         
$genre sqlesc("");
    }
    if (!empty(
$_POST["url"]))
         
$url sqlesc($_POST["url"]);
    else
         
$url sqlesc("");
} elseif (
$isimdb == "imdb") {
    
$url $_POST["imdburl"];
    if (
$url == "")
        
bark("You must enter an IMDB url!");
    if (!
strpos($url"imdb") || !strpos($url"title") || !strpos($url"tt"))
        
bark("Invalid IMDb url!");
    
$url sqlesc($url);
    
$genre sqlesc("");
}
           
$autoimdb = ($isimdb == "nonimdb"?sqlesc("no"):sqlesc("yes"));

$imdbrating sqlesc("");       

// Replace punctuation characters with spaces    
$nzbname str_replace("_"" "$nzbname);
$nzbname str_replace("%20"" "$nzbname);

$cuser $CURUSER["id"];
$category $_POST["type"];

$nzbvernum nzb_ver_num($tmpname);

$nfo sqlesc(str_replace("\x0d\x0d\x0a""\x0d\x0a", @file_get_contents($nfofilename)));
$ret mysql_query("INSERT INTO nzbs (owner, name, descr, ori_descr, category, nfo, nzbvernum, autoimdb, url, imdbrating, genre, addtext, format) VALUES (" $cuser "," sqlesc($nzbname) . "," sqlesc($descr) . "," sqlesc($descr) . "," $category "," $nfo "," sqlesc($nzbvernum) . "," $autoimdb "," $url "," $imdbrating "," $genre "," $addtext "," $format ")");
        
if (!
$ret) {
    if (
mysql_errno() == 1062)
        
bark("nzb already uploaded!");
    
bark("mysql puked: ".mysql_error());
}

$id mysql_insert_id();

mysql_query("DELETE FROM nzbpiecelist WHERE nzb = $id");

clean_utf8($tmpname);

storepieces($tmpname$id);

// add pieces to db and return some info from them
pieceslisting($tmpname$id);

$extrainfo =  @mysql_query("SELECT piece_poster, piece_date, piece_subject, piece_groups, piece_par FROM nzbpiecelist WHERE nzb = $id AND nzb_piece = 0") or sqlerr(__FILE____LINE__);
$counting = @mysql_query("SELECT piece_size FROM nzbpiecelist WHERE nzb = $id") or sqlerr(__FILE____LINE__);
$totsize = @mysql_query("SELECT SUM(piece_size) AS tot_size FROM nzbpiecelist WHERE nzb = $id") or sqlerr(__FILE____LINE__);
$parcount = @mysql_query("SELECT piece_size FROM nzbpiecelist WHERE nzb = $id AND piece_par = 1 ") or sqlerr(__FILE____LINE__);
$partotsize = @mysql_query("SELECT SUM(piece_size) AS par_tot_size FROM nzbpiecelist WHERE nzb = $id AND piece_par = 1") or sqlerr(__FILE____LINE__); 


$numfiles mysql_num_rows($counting);
$numpars mysql_num_rows($parcount);

// find out total filesize (the size of the to-be-downloaded files)
$ptsize mysql_result($totsize0);
$parsize mysql_result($partotsize0);
if (!
$parsize)
      
$parsize 0;

$einfo mysql_fetch_array($extrainfo);
$pposter sqlesc($einfo['piece_poster']);
$pdate $einfo['piece_date'];
$psubject $einfo['piece_subject'];
// remember that groups are in a serialised array!
$pgroups sqlesc($einfo['piece_groups']);

// get 4 extra digits for filename (to stop direct downloads)
srand( (double)microtime()*1000000 );
$rand rand(10004999);

// rename nzb 
$nzbfilename $id."-".$nzbname."-".$SITENAME4FILE."-".$rand.".nzb";

// add extra details:
$updateset = array();
$updateset[] = "search_text = " sqlesc(searchfield("$shortfname $nzbname $psubject"));
$updateset[] = "filename = " sqlesc($nzbfilename);
$updateset[] = "size = " $ptsize;
$updateset[] = "numfiles = " $numfiles;
$updateset[] = "poster = " $pposter;
$updateset[] = "postdate = " $pdate;
$updateset[] = "groups = " $pgroups;
$updateset[] = "pars = " $numpars;
$updateset[] = "partotsize = " $parsize;
$updateset[] = "added = '" get_date_time() ."'";

$ret2 mysql_query("UPDATE nzbs SET " join(","$updateset) . " WHERE id = $id"); 

if (!
$ret2) {
    
bark("mysql puked: ".mysql_error());
}

$nzbfilename str_replace(" ""_"$nzbfilename);

// move nzb:
if (!$zipped) {
    
move_uploaded_file($tmpname$SITENZBDIR."/".$nzbfilename); 
} else {
    
$formove file_get_contents($tmpname);
    
file_put_contents($SITENZBDIR."/".$nzbfilename$formove);
    @
unlink($tmpname);
    unset (
$formove); 
}

// create zip file:
$createZip = new createZip;  
$fileContents file_get_contents($SITENZBDIR."/".$nzbfilename); 
$createZip -> addFile($fileContents$nzbfilename);
$fileName "$nzbfilename.zip";
$fd fopen ($fileName"wb");
fwrite ($fd$createZip -> getZippedfile());
fclose ($fd);
$formove file_get_contents($fileName);
file_put_contents($SITENZBDIR."/".$fileName$formove);
@
unlink($fileName); 

header("Location: $BASEURL/nzbdetails.php?id=$id&uploaded=1");
?>
Bump: ok so i can get the imdb rating on the details.php using the code below

PHP Code:
if (isset($row["url"])) {
    
$oIMDB = new IMDB($row["url"]);
    if (
$oIMDB -> isReady) {
        
$poster $oIMDB -> getPoster();
        
$rate $oIMDB -> getRating();
        
$dire $oIMDB -> getDirector();
        
$cast $oIMDB -> getCastAndCharacter();
        
$count $oIMDB -> getCountry();
        
$idisk $oIMDB -> getDescription();
        if (
$oIMDB->getTrailerAsUrl() != 'n/A') {
        
$vid '<iframe width="660" height="500" scrolling="no" border="0" src="' $oIMDB -> getTrailerAsUrl() . '"></iframe>';
        }else {
        
$vis $oIMDB -> getTrailerAsUrl();
        }
    }
    
$imdb '
<td width="58">&nbsp;Poster</td>
<td width="163"><img src="' 
$poster '"></td>
</tr>
<tr>
    <td>&nbsp;Rating</td>
    <td>' 
$rate '</td>
</tr>
<tr>
    <td>&nbsp;Director</td>
    <td>' 
$dire '</td>
</tr>
<tr>
    <td>&nbsp;Cast</td>
    <td>' 
$cast '</td>
</tr>
<tr>
    <td>&nbsp;County</td>
    <td>' 
$count '</td>
</tr>
<tr>
    <td>&nbsp;Description</td>
    <td>' 
$idisk '</td>
    <tr>
    <tr/>'
;

    print 
$imdb;

which works a treat. i have on the browse.php a imdb rating which i am trying to get to work. to get this to work i am trying to get the $rate above to work in takeupload.php but i dont have a clue how to send it to that php to work i know where to put it but i need the information there

Bump: I have tried to put the same code that I put in details to get the $rate into takeupload but I get a blank screen and doesnt work plz help me guys
Reply With Quote