for the last 2 days at about 7pm uk time for several hours it will not allow me to upload torrents to my site, i think i have narrowed it down the benc.php file but this is where im lost, my server is showing no unusual traffic problems and the upload file works normally when this problem isnt occuring, would anyone know what the problem is it will not let my uploaders upload they just get a stderr appear
this is the part that is causing problems in the take upload file but this info is from the benc.php file i assume and the fopen command
PHP Code:
$tmpname = $f["tmp_name"];
if (!is_uploaded_file($tmpname))
stderr($lang['takeupload_failed'], "test1");
if (!filesize($tmpname))
stderr("","<table align='center'><tr><td align='center'style='border:0px solid white;padding:5px'> <img src='images/upload/error.png' width='60' height='60'/></td><td style='border:0px solid white; padding:5px' align='center'>Upload Failed! You Have Supplied A Empty .Torrent File Recreate It Again</td></tr></table>");
$dict = bdec_file($tmpname, $TBDEV['max_torrent_size']);
if (!isset($dict))
stderr($lang['takeupload_failed'], $lang['takeupload_not_benc']);
the benc.php this is where im lost as to why its only happening after 7pm uk time till about 11pm ish
PHP Code:
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(-{0,1}\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);
}
?>