Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   Torrent Trader (http://www.bvlist.com/forumdisplay.php?f=29)
-   -   error upload (http://www.bvlist.com/showthread.php?t=4317)

alexzut 24th January 2010 12:50

error upload
 
3 Attachment(s)
I appear this error
what to do?

Attachment 2046

Phogo 24th January 2010 15:33

Don't use free hosting...

Nemerniq 3rd February 2010 03:29

Try this ... on TTv2.0 working good

Before change please make backup your torrents-upload.php and benc.php

torrents-upload.php

Code:

//
//  TorrentTrader v2.x
//    This file was last updated: 09/October/2007 by TorrentialStorm
//   
//    http://www.torrenttrader.org
//
//
require_once("backend/functions.php");
dbconn();

//ini_set("upload_max_filesize",$max_torrent_size);


// check access and rights
if ($site_config["MEMBERSONLY"]){
    loggedinonly();

    if($CURUSER["can_upload"]=="no")
        show_error_msg("Error","You do not have permission to upload. Please click here to fill out an uploader application.",1);
    if ($site_config["UPLOADERSONLY"] && $CURUSER["class"] < 4)
        show_error_msg("Error","You do not have permission to upload. Please click here to fill out an uploader application.",1);
}

$announce_urls = explode(",", strtolower($site_config["announce_list"]));  //generate announce_urls[] from config.php

if($takeupload == "yes") {
    require_once("backend/parse.php");

    //check form data
    foreach(explode(":","type:name") as $v) {
        if (!isset($_POST[$v]))
            $message = "Missing form data";
    }

    if (!isset($_FILES["torrent"]))
    $message = "Missing form data";

    $f = $_FILES["torrent"];
    $fname = unesc($f["name"]);

    if (empty($fname))
        $message = "Empty filename!";

    if ($_FILES['nfo']['size'] != 0) {
        $nfofile = $_FILES['nfo'];

        if ($nfofile['name'] == '')
            $message = "No NFO!";
           
        if (!preg_match('/^(.+)\.nfo$/si', $nfofile['name'], $fmatches))
            $message = "Invalid filename (not a .NFO).";

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

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

        $nfofilename = $nfofile['tmp_name'];

        if (@!is_uploaded_file($nfofilename))
            $message = "NFO upload failed";
            $nfo = 'no';
    }

    $descr = unesc($_POST["descr"]);

    if (!$descr)
        $descr = "No description given.";

    $langid = (0 + $_POST["lang"]);
$smalldescr = $_POST["description"];
   
    /*if (!is_valid_id($langid))
        $message = "Please be sure to select a torrent language";*/

    $catid = (0 + $_POST["type"]);

    if (!is_valid_id($catid))
        $message = "Please be sure to select a torrent category";

    if (!validfilename($fname))
        $message = "Invalid filename!";

    if (!preg_match('/^(.+)\.torrent$/si', $fname, $matches))
        $message = "Invalid filename (not a .torrent).";

        $shortfname = $torrent = $matches[1];

    if (!empty($_POST["name"]))
        $torrent = unesc($_POST["name"]);

        $tmpname = $f["tmp_name"];

    if (!is_uploaded_file($tmpname))
        $message = "The file was uploaded, but wasn't found on the temp directoy.";
    //end check form data

    if (!$message) {
    //parse torrent file
    $torrent_dir = $site_config["torrent_dir"];   
    $nfo_dir = $site_config["nfo_dir"];   

    //if(!copy($f, "$torrent_dir/$fname"))
    if(!move_uploaded_file($tmpname, "$torrent_dir/$fname"))
        show_error_msg("Error:","Error: File Could not be copied $tmpname - $torrent_dir - $fname",1);

    $TorrentInfo = array();
    $TorrentInfo = ParseTorrent("$torrent_dir/$fname");


    $announce = strtolower($TorrentInfo[0]);
    $infohash = $TorrentInfo[1];
    $creationdate = $TorrentInfo[2];
    $internalname = $TorrentInfo[3];
    $torrentsize = $TorrentInfo[4];
    $filecount = $TorrentInfo[5];
    $annlist = $TorrentInfo[6];
    $comment = $TorrentInfo[7];

/*
//for debug...
    print ("

announce: ".$announce."");
    print ("

infohash: ".$infohash."");
    print ("

creationdate: ".$creationdate."");
    print ("

internalname: ".$internalname."");
    print ("

torrentsize: ".$torrentsize."");
    print ("

filecount: ".$filecount."");
    print ("

annlist: ".$annlist."");
    print ("

comment: ".$comment."");
*/
   
    //check announce url is local or external
    if (!in_array($announce, $announce_urls, 1)){
        $external='yes';
    }else{
        $external='no';
    }

    //if externals is turned off
    if (!$site_config["ALLOWEXTERNAL"] && $external == 'yes')
        $message = "The .torrent you are trying to upload does not have this trackers announce url!";
    }
    if ($message) {
        @unlink("$torrent_dir/$fname");
        @unlink($tmpname);
        @unlink("$nfo_dir/$nfofilename");
        show_error_msg("Upload Failed", $message,1);
    }

    //release name check and adjust
    if ($name ==""){
        $name = $internalname;
    }
    $name = str_replace(".torrent","",$name);
    $name = str_replace("_", " ", $name);

    //upload images
    $maxfilesize = 512000; // 500kb

    $allowed_types = array(
        "image/gif" => "gif",
        "image/pjpeg" => "jpg",
        "image/jpeg" => "jpg",
        "image/jpg" => "jpg",
        "image/png" => "png"
    );

    for ($x=0; $x < 2; $x++) {
        if (!($_FILES[image.$x]['name'] == "")) {
            $y = $x + 1;

            if (!array_key_exists($_FILES[image.$x]['type'], $allowed_types))
                show_error_msg("Error","Invalid file type! Image $y",1);
           
            if (!preg_match('/^(.+)\.(jpg|gif|png)$/si', $_FILES[image.$x]['name']))
                show_error_msg("Invalid image", "This file TYPE is not image!",1);

            if ($_FILES[image.$x]['size'] > $maxfilesize)
                show_error_msg("Error","Invalid file size! Image $y - Must be less than 500kb",1);

            $uploaddir = "".$site_config["torrent_dir"]."/images/";
 
            $ifile = $_FILES[image.$x]['tmp_name'];
 
            $ret = mysql_query("SHOW TABLE STATUS LIKE 'torrents'");
            $row = mysql_fetch_array($ret);
            $next_id = $row['Auto_increment'];

            $ifilename = $next_id . $x . substr($_FILES[image.$x]['name'], strlen($_FILES[image.$x]['name'])-4, 4);

            $copy = copy($ifile, $uploaddir.$ifilename);

            if (!$copy)
                show_error_msg("Error","Error occured uploading image! - Image $y",1);

            $inames[] = $ifilename;

        }

    }
    //end upload images

    //anonymous upload
    $anonyupload = unesc($_POST["anonycheck"]);
    if ($anonyupload == "yes") {
        $anon = "yes";
    }else{
        $anon = "no";
    }

    $ret = mysql_query("INSERT INTO torrents (filename, owner, name, descr, description, image1, image2, category, added, info_hash, size, numfiles, save_as, announce, external, nfo, torrentlang, anon) VALUES (".sqlesc($fname).", '".$CURUSER['id']."', ".sqlesc($name).", ".sqlesc($descr).", ".sqlesc($smalldescr).", '".$inames[0]."', '".$inames[1]."', '".$type."', '" . get_date_time() . "', '".$infohash."', '".$torrentsize."', '".$filecount."', ".sqlesc($fname).", '".$announce."', '".$external."', '".$nfo."', '".$langid."','$anon')");

    $id = mysql_insert_id();
   
    if (mysql_errno() == 1062)
        show_error_msg("Upload Failed", "Torrent already uploaded.", 1);

    //Update the members uploaded torrent count
    /*if ($ret){
        mysql_query("UPDATE users SET torrents = torrents + 1 WHERE id = $userid");*/
       
    if($id == 0){
        unlink("$torrent_dir/$fname");
        $message = "No ID. Server error, please report.";
        show_error_msg("Upload Failed", $message,1);
    }
   
    rename("$torrent_dir/$fname", "$torrent_dir/$id.torrent");

    if ($nfo == 'yes') {
            move_uploaded_file($nfofilename, "$nfo_dir/$id.nfo");
    }

    //EXTERNAL SCRAPE
    if ($external=='yes'){
        $tracker=str_replace("/announce","/scrape",$announce);   
        $stats            = torrent_scrape_url($tracker, $infohash);
        $seeders        = strip_tags($stats['seeds']);
        $leechers        = strip_tags($stats['peers']);
        $downloaded    = strip_tags($stats['downloaded']);

        mysql_query("UPDATE torrents SET leechers='".$leechers."', seeders='".$seeders."',times_completed='".$downloaded."',last_action= '".get_date_time()."',visible='yes' WHERE id='".$id."'");
    }
    //END SCRAPE

    write_log("Torrent $id ($name) was Uploaded by $CURUSER[username]");

    //insert email notif, irc, req notif, etc here
   
    //Uploaded ok message (update later)
    if ($external=='no')
        $message = "Torrent Uploaded OK:

".$name." was uploaded.

  Please remember to re-download so that your passkey is added and you can seed this torrent

Download Now
View Uploaded Torrent

";
    else
        $message = "Torrent Uploadeded OK:

".$name." was uploaded.

View Uploaded Torrent

";
    show_error_msg("Upload Complete", $message,1);

    die();
}//takeupload


///////////////////// FORMAT PAGE ////////////////////////

stdhead("Upload");

begin_frame("" . UPLOAD_RULES . "");
    echo "".stripslashes($site_config["UPLOADRULES"])."";
    echo "
";
end_frame();

begin_frame("" . UPLOAD . "");
?>



print ("");

print ("");

//print ("");

print ("");

//print ("");

print ("");

$category = "\n";
print ("");


$language = "\n";
print ("");

if ($site_config['ANONYMOUSUPLOAD'] && $site_config["MEMBERSONLY"] ){ ?>
   
    }

print ("
" . ANNOUNCE . ": ");

while (list($key,$value) = each($announce_urls)) {
    echo "$value";
}

if ($site_config["ALLOWEXTERNAL"]){
    echo "
This site accepts ALL external torrents also!";
}
print ("
" . TORRENT_FILE . ": \n
" . NFO . ": \n
" . TNAME . ":
This will be taken from .torrent if left empty\n
Small Description:
Ex: Horror | +18 | HipHop | Xp | Vista | Mobile\n
Images: Max File Size: 500kbAccepted Formats: .gif, .jpg, .pngImage 1:&nbsp&nbspImage 2:&nbsp&nbsp\n
" . TTYPE . ": ".$category."
Language: ".$language."
Upload Anonymous: Yes No"); ?>  (Your userid will not be associated to this upload)
   
" . TDESC . "
");

require_once("backend/bbcode.php");
print ("".textbbcode("upload","descr","$descr")."");
?>



">

Click Once! - Uploading an image may take longer



end_frame();
stdfoot();
?>

benc.php

Code:


/*

Basic knowledge of how bencoding works is assumed. Details can be found
at .



How to use these functions:

An "object" is defined to be an associative array with at least the keys
"type" and "value" present. The "type" key contains a string which is
one of "string", "integer", "list" or "dictionary". The "value" key
contains the appropriate thing, either a string, an integer, a list which
is just a flat array, or a dictionary, which is an associative array. In
the case of "list" and "dictionary", the values of the contained array
are agaib "objects".



Description of the functions:



string benc($obj);

Takes an object as argument and returns the bencoded form of it as string.
Returns the undefined/unset value on failure.

Examples:

benc(array(type => "string", value => "spam"))        returns "4:spam".
benc(array(type => "integer", value => 3))        returns "i3e".
benc(array(type => "list", value => array(
    array(type => "string", value => "spam"),
    array(type => "string", value => "eggs")
)))
                        returns "l4:spam4:eggse"

benc(array(type => "dictionary", value => array(
    cow => array(type => "string", value => "moo"),
    spam => array(type => "string", value => "eggs"),
)))
                    returns "d3:cow3:moo4:spam4:eggse"




object bdec($str);

Returns the object that results from bdecoding the given string. Note
that those aren't real php objects, but merely "objects" as described
above. The returned objects have two additional keys: "string" and
"strlen". They represent the bencoded form of the returned objects, as
it was given in the original bencoded string. Use this to extract
certain portions of a bencoded string without having to re-encode it
(and avoiding possible re-ordering of dictionary keys). $x["strlen"]
is always equivalent to strlen($x["string"]). The "string" attribute
of the top-level returned object will be the same as the original
bencoded string, unless there's trailing garbage at the end of the
string.

This function returns the undefined/unset value on failure.

Example:

bdec("d4:spaml11:spiced pork3:hamee")
    returns this monster:

Array
(
    [type] => dictionary
    [value] => Array
        (
            [spam] => Array
                (
                    [type] => list
                    [value] => Array
                        (
                            [0] => Array
                                (
                                    [type] => string
                                    [value] => spiced pork
                                    [strlen] => 14
                                    [string] => 11:spiced pork
                                )

                            [1] => Array
                                (
                                    [type] => string
                                    [value] => ham
                                    [strlen] => 5
                                    [string] => 3:ham
                                )

                        )

                    [strlen] => 21
                    [string] => l11:spiced pork3:hame
                )

        )

    [strlen] => 29
    [string] => d4:spaml11:spiced pork3:hamee
)





object bdec_file($filename, $maxsize);

Opens the specified file, reads its contents (up to the specified length),
and returns whatever bdec() returns for those contents. This is a simple
convenience function.

*/

function benc($obj) {
    if (!is_array($obj) || !isset($obj["type"]) || !isset($obj["value"]))
        return;
    $c = $obj["value"];
    switch ($obj["type"]) {
        case "string":
            return benc_str($c);
        case "integer":
            return benc_int($c);
        case "list":
            return benc_list($c);
        case "dictionary":
            return benc_dict($c);
        default:
            return;
    }
}

function benc_str($s) {
    return strlen($s) . ":$s";
}

function benc_int($i) {
    return "i" . $i . "e";
}

function benc_list($a) {
    $s = "l";
    foreach ($a as $e) {
        $s .= benc($e);
    }
    $s .= "e";
    return $s;
}

function benc_dict($d) {
    $s = "d";
    $keys = array_keys($d);
    sort($keys);
    foreach ($keys as $k) {
        $v = $d[$k];
        $s .= benc_str($k);
        $s .= benc($v);
    }
    $s .= "e";
    return $s;
}

function bdec_file($f, $ms) {
    $fp = fopen($f, "rb");
    if (!$fp)
        return;
    $e = fread($fp, $ms);
    fclose($fp);
    return bdec($e);
}

function bdec($s) {
    if (preg_match('/^(\d+):/', $s, $m)) {
        $l = $m[1];
        $pl = strlen($l) + 1;
        $v = substr($s, $pl, $l);
        $ss = substr($s, 0, $pl + $l);
        if (strlen($v) != $l)
            return;
        return array(type => "string", value => $v, strlen => strlen($ss), string => $ss);
    }
    if (preg_match('/^i(\d+)e/', $s, $m)) {
        $v = $m[1];
        $ss = "i" . $v . "e";
        if ($v === "-0")
            return;
        if ($v[0] == "0" && strlen($v) != 1)
            return;
        return array(type => "integer", value => $v, strlen => strlen($ss), string => $ss);
    }
    switch ($s[0]) {
        case "l":
            return bdec_list($s);
        case "d":
            return bdec_dict($s);
        default:
            return;
    }
}

function bdec_list($s) {
    if ($s[0] != "l")
        return;
    $sl = strlen($s);
    $i = 1;
    $v = array();
    $ss = "l";
    for (;;) {
        if ($i >= $sl)
            return;
        if ($s[$i] == "e")
            break;
        $ret = bdec(substr($s, $i));
        if (!isset($ret) || !is_array($ret))
            return;
        $v[] = $ret;
        $i += $ret["strlen"];
        $ss .= $ret["string"];
    }
    $ss .= "e";
    return array(type => "list", value => $v, strlen => strlen($ss), string => $ss);
}

function bdec_dict($s) {
    if ($s[0] != "d")
        return;
    $sl = strlen($s);
    $i = 1;
    $v = array();
    $ss = "d";
    for (;;) {
        if ($i >= $sl)
            return;
        if ($s[$i] == "e")
            break;
        $ret = bdec(substr($s, $i));
        if (!isset($ret) || !is_array($ret) || $ret["type"] != "string")
            return;
        $k = $ret["value"];
        $i += $ret["strlen"];
        $ss .= $ret["string"];
        if ($i >= $sl)
            return;
        $ret = bdec(substr($s, $i));
        if (!isset($ret) || !is_array($ret))
            return;
        $v[$k] = $ret;
        $i += $ret["strlen"];
        $ss .= $ret["string"];
    }
    $ss .= "e";
    return array(type => "dictionary", value => $v, strlen => strlen($ss), string => $ss);
}

?>


danscarlat 21st April 2010 12:35

I have a problem
 
http://img202.imageshack.us/img202/6730/problemwg.jpg

I do not know why I can not upload



All times are GMT +2. The time now is 07:23.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.