
Kod
<?
require_once("include/bittorrent.inc.php");
dbconn();
loggedinorreturn();
stdhead("Upload");
?>
<script LANGUAGE="JavaScript">
var max=1500; // 1500 caractčres maximum
function compter(f) {
var txt=f.descr.value;
var nb=txt.length;
if (nb>max) {
alert("You are limited to "+max+" characters for comments !");
f.zone.value=txt.substring(0,max);
nb=max;
}
f.nbcar.value=nb;
}
function timer() {
compter(document.forms["form1"]);
setTimeout("timer()",100);
}
</SCRIPT>
<body onload="setTimeout('timer()',100)">
<form enctype="multipart/form-data" action="takeupload.php" method="post" name="form1">
<input type="hidden" name="MAX_FILE_SIZE" value="<?=$max_torrent_size?>" />
<p>The tracker's announce url are : <li><b><?= $announce_urls[0] ?></b></li>
<li><b><?= $announce_urls[1] ?></b></li>
</p>
<p>You can upload torrents from external trackers , but please do so only if you are seeding them !</p>
<p><b>Only upload torrents you're going to seed!</b> Uploaded torrents won't be visible on the main page until you start seeding them.</p>
<table class="table1" border="2" cellspacing="0" cellpadding="5">
<?
tr("Upload file", "<input class=\"input\" type=\"file\" name=\"file\" size=\"60\" />\n", 1);
tr("Torrent name", "<input class=\"input\" type=\"text\" name=\"name\" size=\"80\" /><br />(Taken from filename if not specified. <b>Please use descriptive names.</b>)\n", 1);
tr("Image URL", "<input class=\"input\" type=\"text\" name=\"image\" size=\"80\" /><br />(Ignored if not specified. <b>Please enter the URL of the image to display.</b>)\n", 1);
tr("Description<br />(no html allowed)", "<textarea class=\"input\" name=\"descr\" rows=\"10\" cols=\"80\" onkeypress=\"compter(this.form)\"></textarea><br/>You are currently using : <INPUT type=\"text\" name=\"nbcar\" size=3> characters out of 1500 authorized !", 1);
$s = "<select class=\"input\" name=\"type\">\n<option value=\"0\">(choose one)</option>\n";
$cats = genrelist();
foreach ($cats as $row)
$s .= "<option value=\"" . $row["id"] . "\">" . htmlspecialchars($row["name"]) . "</option>\n";
$s .= "</select>\n";
tr("Type", $s, 1);
?>
<tr><td align="center" colspan="2"><input class="input" type="submit" value="Do it!" /></td></tr>
</table>
</form>
<?
stdfoot();
?>
require_once("include/bittorrent.inc.php");
dbconn();
loggedinorreturn();
stdhead("Upload");
?>
<script LANGUAGE="JavaScript">
var max=1500; // 1500 caractčres maximum
function compter(f) {
var txt=f.descr.value;
var nb=txt.length;
if (nb>max) {
alert("You are limited to "+max+" characters for comments !");
f.zone.value=txt.substring(0,max);
nb=max;
}
f.nbcar.value=nb;
}
function timer() {
compter(document.forms["form1"]);
setTimeout("timer()",100);
}
</SCRIPT>
<body onload="setTimeout('timer()',100)">
<form enctype="multipart/form-data" action="takeupload.php" method="post" name="form1">
<input type="hidden" name="MAX_FILE_SIZE" value="<?=$max_torrent_size?>" />
<p>The tracker's announce url are : <li><b><?= $announce_urls[0] ?></b></li>
<li><b><?= $announce_urls[1] ?></b></li>
</p>
<p>You can upload torrents from external trackers , but please do so only if you are seeding them !</p>
<p><b>Only upload torrents you're going to seed!</b> Uploaded torrents won't be visible on the main page until you start seeding them.</p>
<table class="table1" border="2" cellspacing="0" cellpadding="5">
<?
tr("Upload file", "<input class=\"input\" type=\"file\" name=\"file\" size=\"60\" />\n", 1);
tr("Torrent name", "<input class=\"input\" type=\"text\" name=\"name\" size=\"80\" /><br />(Taken from filename if not specified. <b>Please use descriptive names.</b>)\n", 1);
tr("Image URL", "<input class=\"input\" type=\"text\" name=\"image\" size=\"80\" /><br />(Ignored if not specified. <b>Please enter the URL of the image to display.</b>)\n", 1);
tr("Description<br />(no html allowed)", "<textarea class=\"input\" name=\"descr\" rows=\"10\" cols=\"80\" onkeypress=\"compter(this.form)\"></textarea><br/>You are currently using : <INPUT type=\"text\" name=\"nbcar\" size=3> characters out of 1500 authorized !", 1);
$s = "<select class=\"input\" name=\"type\">\n<option value=\"0\">(choose one)</option>\n";
$cats = genrelist();
foreach ($cats as $row)
$s .= "<option value=\"" . $row["id"] . "\">" . htmlspecialchars($row["name"]) . "</option>\n";
$s .= "</select>\n";
tr("Type", $s, 1);
?>
<tr><td align="center" colspan="2"><input class="input" type="submit" value="Do it!" /></td></tr>
</table>
</form>
<?
stdfoot();
?>
Admin serwera na ktorej mam strone powiedzal mi ze mam zmienic w kodzie na
Kod
<?
if(is_uploaded_file($zmienna))
{
if(!move_uploaded_file($zmienna, "katalog_docelowy/nazwa_pliku"))
echo "nie udalo sie zamiescic pliku na stronie!";
else
echo "plik zostal poprawnie zamieszczony na stronie";
}
?>
if(is_uploaded_file($zmienna))
{
if(!move_uploaded_file($zmienna, "katalog_docelowy/nazwa_pliku"))
echo "nie udalo sie zamiescic pliku na stronie!";
else
echo "plik zostal poprawnie zamieszczony na stronie";
}
?>
ale nie wiem co i jak jestem ciemny w php jak jagoda wlesie

moze ktos mi poradzi jak to zrobic aby było ok?.
A moze cos w tym 2 kodzie trzeba zmienic bo sa 2 pliki upoadu
1 to upload a 2 to tekeupload ? oto kod tego 2giego
Kod
<?
require_once("include/benc.php");
require_once("include/bittorrent.inc.php");
ini_set("upload_max_filesize",$max_torrent_size);
function bark($msg) {
genbark($msg, "Upload failed!");
}
dbconn();
loggedinorreturn();
foreach(explode(":","descr:type:name") as $v) {
if (!isset($_POST[$v]))
bark("missing form data");
}
if (!isset($_FILES["file"]))
bark("missing form data");
$f = $_FILES["file"];
$fname = unesc($f["name"]);
if (empty($fname))
bark("Empty filename!");
if (!validfilename($fname))
bark("Invalid filename!");
if (!preg_match('/^(.+)\.torrent$/si', $fname, $matches))
bark("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))
bark("eek");
if (!filesize($tmpname))
bark("Empty file!");
$dict = bdec_file($tmpname, $max_torrent_size);
if (!isset($dict))
bark("What the hell did you upload? This is not a bencoded file!");
function dict_check($d, $s) {
if ($d["type"] != "dictionary")
bark("not a dictionary");
$a = explode(":", $s);
$dd = $d["value"];
$ret = array();
foreach ($a as $k) {
unset($t);
if (preg_match('/^(.*)\((.*)\)$/', $k, $m)) {
$k = $m[1];
$t = $m[2];
}
if (!isset($dd[$k]))
bark("dictionary is missing key(s)");
if (isset($t)) {
if ($dd[$k]["type"] != $t)
bark("invalid entry in dictionary");
$ret[] = $dd[$k]["value"];
}
else
$ret[] = $dd[$k];
}
return $ret;
}
function dict_get($d, $k, $t) {
if ($d["type"] != "dictionary")
bark("not a dictionary");
$dd = $d["value"];
if (!isset($dd[$k]))
return;
$v = $dd[$k];
if ($v["type"] != $t)
bark("invalid dictionary entry type");
return $v["value"];
}
//$announcelist = array();
list($ann, $info) = dict_check($dict, "announce(string):info");
/* Still not working fine, but this is a the beginning of a multi-tracker announce processing
$annlist = dict_get($info, "announce","info");
foreach ($annlist as $fn) {
list($ann, $info) = dict_check($fn, "announce(string):info");
$announcelist[] = array($ann);
}
*/
list($dname, $plen, $pieces) = dict_check($info, "name(string):piece length(integer):pieces(string)");
//if (!in_array($ann, $announce_urls, 1))
//bark("invalid announce url! must be <b>" . $announce_urls[0] . "</b>");
$ann = str_replace('/announce','/scrape',$ann);
for ($i=0;count($announcelist);$i++) {
bark($announcelist[i]);
}
if (strlen($pieces) % 20 != 0)
bark("invalid pieces");
$filelist = array();
$totallen = dict_get($info, "length", "integer");
if (isset($totallen)) {
$filelist[] = array($dname, $totallen);
$type = "single";
}
else {
$flist = dict_get($info, "files", "list");
if (!isset($flist))
bark("missing both length and files");
if (!count($flist))
bark("no files");
$totallen = 0;
foreach ($flist as $fn) {
list($ll, $ff) = dict_check($fn, "length(integer):path(list)");
$totallen += $ll;
$ffa = array();
foreach ($ff as $ffe) {
if ($ffe["type"] != "string")
bark("filename error");
$ffa[] = $ffe["value"];
}
if (!count($ffa))
bark("filename error");
$ffe = implode("/", $ffa);
$filelist[] = array($ffe, $ll);
}
$type = "multi";
}
$infohash = pack("H*", sha1($info["string"]));
$descr = unesc($_POST["descr"]);
$image = $_POST["image"];
$ret = mysql_query("INSERT INTO torrents (search_text, filename, owner, visible, info_hash,image, scrape_url, name, size, numfiles, type, descr, ori_descr, category, save_as, added, last_action) VALUES (" .
implode(",", array_map("sqlesc", array(searchfield("$shortfname $dname $torrent"), $fname, $CURUSER["id"], "no", $infohash ,$image,$ann, $torrent, $totallen, count($filelist), $type, parsedescr($descr), $descr, 0 + $_POST["type"], $dname))) .
", NOW(), NOW())");
if (!$ret) {
if (mysql_errno() == 1062)
bark("torrent already uploaded!");
bark("mysql puked: ".mysql_error());
}
$id = mysql_insert_id();
@mysql_query("DELETE FROM files WHERE torrent = $id");
foreach ($filelist as $file) {
@mysql_query("INSERT INTO files (torrent, filename, size) VALUES ($id, ".sqlesc($file[0]).",".$file[1].")");
}
move_uploaded_file($tmpname, "$torrent_dir/$id.torrent");
header("Refresh: 0; url=details.php?id=$id&uploaded=1");
?>
require_once("include/benc.php");
require_once("include/bittorrent.inc.php");
ini_set("upload_max_filesize",$max_torrent_size);
function bark($msg) {
genbark($msg, "Upload failed!");
}
dbconn();
loggedinorreturn();
foreach(explode(":","descr:type:name") as $v) {
if (!isset($_POST[$v]))
bark("missing form data");
}
if (!isset($_FILES["file"]))
bark("missing form data");
$f = $_FILES["file"];
$fname = unesc($f["name"]);
if (empty($fname))
bark("Empty filename!");
if (!validfilename($fname))
bark("Invalid filename!");
if (!preg_match('/^(.+)\.torrent$/si', $fname, $matches))
bark("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))
bark("eek");
if (!filesize($tmpname))
bark("Empty file!");
$dict = bdec_file($tmpname, $max_torrent_size);
if (!isset($dict))
bark("What the hell did you upload? This is not a bencoded file!");
function dict_check($d, $s) {
if ($d["type"] != "dictionary")
bark("not a dictionary");
$a = explode(":", $s);
$dd = $d["value"];
$ret = array();
foreach ($a as $k) {
unset($t);
if (preg_match('/^(.*)\((.*)\)$/', $k, $m)) {
$k = $m[1];
$t = $m[2];
}
if (!isset($dd[$k]))
bark("dictionary is missing key(s)");
if (isset($t)) {
if ($dd[$k]["type"] != $t)
bark("invalid entry in dictionary");
$ret[] = $dd[$k]["value"];
}
else
$ret[] = $dd[$k];
}
return $ret;
}
function dict_get($d, $k, $t) {
if ($d["type"] != "dictionary")
bark("not a dictionary");
$dd = $d["value"];
if (!isset($dd[$k]))
return;
$v = $dd[$k];
if ($v["type"] != $t)
bark("invalid dictionary entry type");
return $v["value"];
}
//$announcelist = array();
list($ann, $info) = dict_check($dict, "announce(string):info");
/* Still not working fine, but this is a the beginning of a multi-tracker announce processing
$annlist = dict_get($info, "announce","info");
foreach ($annlist as $fn) {
list($ann, $info) = dict_check($fn, "announce(string):info");
$announcelist[] = array($ann);
}
*/
list($dname, $plen, $pieces) = dict_check($info, "name(string):piece length(integer):pieces(string)");
//if (!in_array($ann, $announce_urls, 1))
//bark("invalid announce url! must be <b>" . $announce_urls[0] . "</b>");
$ann = str_replace('/announce','/scrape',$ann);
for ($i=0;count($announcelist);$i++) {
bark($announcelist[i]);
}
if (strlen($pieces) % 20 != 0)
bark("invalid pieces");
$filelist = array();
$totallen = dict_get($info, "length", "integer");
if (isset($totallen)) {
$filelist[] = array($dname, $totallen);
$type = "single";
}
else {
$flist = dict_get($info, "files", "list");
if (!isset($flist))
bark("missing both length and files");
if (!count($flist))
bark("no files");
$totallen = 0;
foreach ($flist as $fn) {
list($ll, $ff) = dict_check($fn, "length(integer):path(list)");
$totallen += $ll;
$ffa = array();
foreach ($ff as $ffe) {
if ($ffe["type"] != "string")
bark("filename error");
$ffa[] = $ffe["value"];
}
if (!count($ffa))
bark("filename error");
$ffe = implode("/", $ffa);
$filelist[] = array($ffe, $ll);
}
$type = "multi";
}
$infohash = pack("H*", sha1($info["string"]));
$descr = unesc($_POST["descr"]);
$image = $_POST["image"];
$ret = mysql_query("INSERT INTO torrents (search_text, filename, owner, visible, info_hash,image, scrape_url, name, size, numfiles, type, descr, ori_descr, category, save_as, added, last_action) VALUES (" .
implode(",", array_map("sqlesc", array(searchfield("$shortfname $dname $torrent"), $fname, $CURUSER["id"], "no", $infohash ,$image,$ann, $torrent, $totallen, count($filelist), $type, parsedescr($descr), $descr, 0 + $_POST["type"], $dname))) .
", NOW(), NOW())");
if (!$ret) {
if (mysql_errno() == 1062)
bark("torrent already uploaded!");
bark("mysql puked: ".mysql_error());
}
$id = mysql_insert_id();
@mysql_query("DELETE FROM files WHERE torrent = $id");
foreach ($filelist as $file) {
@mysql_query("INSERT INTO files (torrent, filename, size) VALUES ($id, ".sqlesc($file[0]).",".$file[1].")");
}
move_uploaded_file($tmpname, "$torrent_dir/$id.torrent");
header("Refresh: 0; url=details.php?id=$id&uploaded=1");
?>
acha na serwerze jest właczone safe mode
