Hi all,
First off hope the festive period was great and relaxing for all.. but now I think it's time for the snow to go bye bye lol
I am helping sal2azz where and how i can, however a member asked tonight why they cant edit their own .torrent field, i know its missing but anyone able to help please?
here is the torrents-edit.php - running TT 2.0.8 BIGMAX version
thanks
First off hope the festive period was great and relaxing for all.. but now I think it's time for the snow to go bye bye lol
I am helping sal2azz where and how i can, however a member asked tonight why they cant edit their own .torrent field, i know its missing but anyone able to help please?
here is the torrents-edit.php - running TT 2.0.8 BIGMAX version
<?php
#================================#
# TorrentTrader 2.08 #
# http://www.torrenttrader.org #
#--------------------------------#
# Modified by BigMax #
#================================#
require_once("backend/functions.php");
dbconn();
security();
loggedinonly();
$id = (int) $_REQUEST["id"];
if (!is_valid_id($id)) show_error_msg(T_("ERROR"), T_("INVALID_ID"), 1);
$action = $_REQUEST["action"];
$row = mysqli_fetch_assoc(SQL_Query_exec("SELECT `owner` FROM `torrents` WHERE id=$id"));
//if($CURUSER["edit_torrents"]=="no" && $CURUSER['id'] != $row['owner'])
if($CURUSER["edit_torrents"]=="no" && $CURUSER['id'] != $row['owner'] || $CURUSER["can_upload"] != "yes") //===| BigMax |===//
show_error_msg(T_("ERROR"), T_("NO_TORRENT_EDIT_PERMISSION"), 1);
$ownertor = $row['owner'];
$row2 = mysqli_fetch_assoc(SQL_Query_exec("SELECT `points` FROM `motm` WHERE id=$ownertor"));
$actpoints = $row2['points'];
function uploadimage($x, $imgname, $tid) {
global $site_config;
$imagesdir = $site_config["torrent_dir"]."/images";
$allowed_types = &$site_config["allowed_image_types"];
if ( !( $_FILES["image$x"]["name"] == "" ) ) {
if ($imgname != "") {
$img = "$imagesdir/$imgname";
$del = unlink($img);
}
$y = $x + 1;
$im = getimagesize($_FILES["image$x"]["tmp_name"]);
if (!$im[2])
show_error_msg("Error", "Invalid Image $y.", 1);
if (!array_key_exists($im['mime'], $allowed_types))
show_error_msg(T_("ERROR"), T_("INVALID_FILETYPE_IMAGE"), 1);
if ($_FILES["image$x"]["size"] > $site_config['image_max_filesize'])
show_error_msg(T_("ERROR"), sprintf(T_("INVAILD_FILE_SIZE_IMAGE"), $y), 1);
$uploaddir = "$imagesdir/";
$ifilename = $tid . $x . $allowed_types[$im['mime']];
$copy = copy($_FILES["image$x"]["tmp_name"], $uploaddir.$ifilename);
if (!$copy)
show_error_msg(T_("ERROR"), sprintf(T_("ERROR_UPLOADING_IMAGE"), $y), 1);
return $ifilename;
}
} // end function
// GET DATA FROM DB
$res = SQL_Query_exec("SELECT * FROM torrents WHERE id = $id");
$row = mysqli_fetch_array($res);
if (!$row) {
show_error_msg(T_("ERROR"), T_("TORRENT_ID_GONE"), 1);
}
$torrent_dir = $site_config["torrent_dir"];
$nfo_dir = $site_config["nfo_dir"];
// DELETE TORRENT
if ($action=="deleteit") {
$torrentid = (int) $_POST["torrentid"];
$delreason = sqlesc($_POST["delreason"]);
$torrentname = $_POST["torrentname"];
if (!is_valid_id($torrentid))
show_error_msg(T_("FAILED"), T_("INVALID_TORRENT_ID"), 1);
If ($_POST["delreason"] == '') {
show_error_msg(T_("ERROR"), "You must write a reason for deletion!", 1);
}
deletetorrent($torrentid);
write_log("<a href=account-details.php?id=".$CURUSER['id']."><b>".$CURUSER['username']."</b></a> has deleted torrent ID: [<b>$torrentid</b>] - ".htmlspecialchars($torrentname)." - Reason: ".htmlspecialchars($delreason));
if ($CURUSER['id'] != $row['owner']) {
$delreason = $_POST["delreason"];
SQL_Query_exec("INSERT INTO messages (sender, receiver, added, subject, msg, unread, location) VALUES(0, ".$row['owner'].", '".get_date_time()."', 'Your torrent \'$torrentname\' has been deleted by ".$CURUSER['username']."', ".sqlesc("'$torrentname' was deleted by ".$CURUSER['username']."\n\nReason: $delreason").", 'yes', 'in')");
}
$owner = $_POST["ownerid"];
$points = $_POST["points"];
SQL_Query_exec("UPDATE motm SET points = $points-25 WHERE id = $owner");
show_error_msg(T_("COMPLETED"), htmlspecialchars($torrentname)." ".T_("HAS_BEEN_DEL_DB"),1);
die;
}
// DO THE SAVE TO DB HERE
if ($action=="doedit")
{
$updateset = array();
// NFO Action
$nfoaction = $_POST['nfoaction'];
if ($nfoaction == "update")
{
$nfofile = $_FILES['nfofile'];
if (!$nfofile) die("No data " . var_dump($_FILES));
if ($nfofile['size'] > 65535)
show_error_msg("NFO is too big!", "Max 65,535 bytes.",1);
$nfofilename = $nfofile['tmp_name'];
if (@is_uploaded_file($nfofilename) && @filesize($nfofilename) > 0)
{
@move_uploaded_file($nfofilename, "$nfo_dir/$id.nfo");
$updateset[] = "nfo = 'yes'";
}
}
// End NFO Action
if (!empty($_POST["name"]))
$updateset[] = "name = " . sqlesc($_POST["name"]);
if ( $_POST['imdb'] != $row['imdb'] )
{
$updateset[] = "imdb = " . sqlesc($_POST["imdb"]);
$TTCache->Delete("imdb/$id");
}
$updateset[] = "descr = " . sqlesc($_POST["descr"]);
$updateset[] = "genre = " . sqlesc($_POST["genre"]);
$updateset[] = "category = " . (int) $_POST["type"];
$updateset[] = "torrentlang = " . (int) $_POST["language"];
if ($CURUSER["edit_torrents"] == "yes") {
if ($_POST["banned"]) {
$updateset[] = "banned = 'yes'";
$_POST["visible"] = 0;
} else {
$updateset[] = "banned = 'no'";
}
}
$updateset[] = "visible = '" . ($_POST["visible"] ? "yes" : "no") . "'";
if (!empty($_POST['video']))
$video = unesc($_POST['video']);
$updateset[] = "video = " . sqlesc($video);
//==| check if cover image ia a valid URL
if ($_POST['poster']) { $cover = $_POST['poster']; }
if(!isValidURL($cover) && $_POST['poster'] != "") { show_error_msg(T_("UPLOAD_FAILED"), T_("INVALID_COVER_URL"), 1); }
//==| Cover Image Link
if (!empty($_POST['poster']))
$poster = unesc($_POST['poster']);
$updateset[] = "poster = " . sqlesc($poster);
if ($CURUSER["edit_torrents"] == "yes") {
if ($_POST["sticky"] == "yes") {
$updateset[] = "sticky = 'yes'";
} else {
$updateset[] = "sticky = 'no'";
}
if ($_POST["recommended"] == "yes") {
$updateset[] = "recommended = 'yes'";
} else {
$updateset[] = "recommended = 'no'";
}
if ($_POST["recommended2"] == "yes") {
$updateset[] = "recommended2 = 'yes'";
} else {
$updateset[] = "recommended2 = 'no'";
}
if ($_POST["recommended3"] == "yes") {
$updateset[] = "recommended3 = 'yes'";
} else {
$updateset[] = "recommended3 = 'no'";
}
}
if(get_user_class($CURUSER) > 1){
if ($_POST["rosub"] == "yes"){
$updateset[] = "rosub = 'yes'";
}else{
$updateset[] = "rosub = 'no'";
}
}
if(get_user_class($CURUSER) > 1){
if ($_POST["ensub"] == "yes"){
$updateset[] = "ensub = 'yes'";
}else{
$updateset[] = "ensub = 'no'";
}
}
if(get_user_class($CURUSER) > 1){
if ($_POST["roeng"] == "yes"){
$updateset[] = "roeng = 'yes'";
}else{
$updateset[] = "roeng = 'no'";
}
}
//$updateset[] = "freeleech = '".$_POST["freeleech"]."'"; //--| Original
$updateset[] = "freeleech = '".($_POST["freeleech"] ? "1" : "0")."'"; //--| Added by BigMax
$updateset[] = "anon = '" . ($_POST["anon"] ? "yes" : "no") . "'";
//update images
$img1action = $_POST['img1action'];
if ($img1action == "update")
$updateset[] = "image1 = " .sqlesc(uploadimage(0, $row["image1"], $id));
if ($img1action == "delete") {
if ($row[image1]) {
$del = unlink($site_config["torrent_dir"]."/images/$row[image1]");
$updateset[] = "image1 = ''";
}
}
$img2action = $_POST['img2action'];
if ($img2action == "update")
$updateset[] = "image2 = " .sqlesc(uploadimage(1, $row["image2"], $id));
if ($img2action == "delete") {
if ($row[image2]) {
$del = unlink($site_config["torrent_dir"]."/images/$row[image2]");
$updateset[] = "image2 = ''";
}
}
SQL_Query_exec("UPDATE torrents SET " . join(",", $updateset) . " WHERE id = $id");
$returl = "torrents-edit.php?id=$id&edited=1";
if (isset($_POST["returnto"])){
$returl = $_POST["returnto"];
}
write_log("Torrent <a href='torrents-details.php?id=$id'><b>".htmlspecialchars($_POST["name"])."</b></a> was edited by <a href=account-details.php?id=$CURUSER[id]><b>".$CURUSER['username']."</b></a>");
header("Location: $returl");
die();
} // END SAVE TO DB
// UPDATE CATEGORY DROPDOWN
$catdropdown = "<select name=\"type\">\n";
if ($CURUSER["language"] == 2) { $cats = genrelistro(); } else { $cats = genrelist(); }
foreach ($cats as $catdropdownubrow) {
$catdropdown .= "<option value=\"" . $catdropdownubrow["id"] . "\"";
if ($catdropdownubrow["id"] == $row["category"])
$catdropdown .= " selected=\"selected\"";
$catdropdown .= ">" . htmlspecialchars($catdropdownubrow["parent_cat"]) . ": " . htmlspecialchars($catdropdownubrow["name"]) . "</option>\n";
}
$catdropdown .= "</select>\n";
// END CATDROPDOWN
// UPDATE TORRENTLANG DROPDOWN
$langdropdown = "<select name=\"language\"><option value='0'>Unknown</option>\n";
if ($CURUSER["language"] == 2) { $lang = langlistro(); } else { $lang = langlist(); }
foreach ($lang as $lang) {
$langdropdown .= "<option value=\"" . $lang["id"] . "\"";
if ($lang["id"] == $row["torrentlang"])
$langdropdown .= " selected=\"selected\"";
$langdropdown .= ">" . htmlspecialchars($lang["name"]) . "</option>\n";
}
$langdropdown .= "</select>\n";
// END TORRENTLANG
////////////////////////////////////////////////////////////////////////////////////////////
if ($_GET["edited"]) { show_error_msg("Edited OK", T_("TORRENT_EDITED_OK"), 1); }
$char1 = 90; //==|Cut name length
$shortname = CutName(htmlspecialchars($row["name"]), $char1);
stdhead("".T_("EDIT_TORRENT").": ".$shortname."");
begin_frame("".T_("EDIT_TORRENT").": ".$shortname."");
//==| Get action
print("<form method='post' name=\"bbform\" enctype=\"multipart/form-data\" action=\"torrents-edit.php?action=doedit\">\n");
print("<input type=\"hidden\" name=\"id\" value=\"$id\" />\n");
if (isset($_GET["returnto"]))
print("<input type=\"hidden\" name=\"returnto\" value=\"" . htmlspecialchars($_GET["returnto"]) . "\" />\n");
print("<table width='99%' border='0' cellspacing='0' cellpadding='5' align='center'>\n");
echo "<tr><td></td></tr>"; //==| Vertical space
//==| Name
echo "<tr><td align='right'>".T_("NAME").":</td>
<td><input type=\"text\" name=\"name\" value=\"" . htmlspecialchars($row["name"]) . "\" class=\"btnHuge2\" /></td></tr>";
//==| Genre
echo "<tr><td align='right' valign='top'><div style='margin-top:5px'>".T_("GENRE").":</div></td>
<td><input type=\"text\" name=\"genre\" value=\"" . htmlspecialchars($row["genre"]) . "\" class=\"btnHuge2\" maxlength=\"300\" />
<div style='margin-top:2px'> ".T_("GENRE_EXAMPLE")."</div></td></tr>";
echo "<tr><td></td></tr>"; //==| Vertical space
//==| Cover Image Link
$poster = ("" . htmlspecialchars($row["poster"]) . "");
echo "<tr><td align='right' valign='top'><div style='margin-top:5px'>".T_("COVER_IMAGE_LINK").":</div></td>
<td><input type=\"text\" name=\"poster\" value=\"" . $poster . "\" class=\"btnHuge2\" /></td></tr>";
echo "<tr><td height='5'></td></tr>"; //==| Vertical space
//==| Cover image Upload
echo "<tr><td align='right' valign='bottom'><div style='margin-bottom:5px'>".T_("COVER_IMAGE_UPLOAD").":</div></td>
<td><div style='margin-bottom:5px'><input type='radio' name='img1action' value='keep' checked='checked' />
".T_("KEEP_IMAGE")." "."<input type='radio' name='img1action' value='delete' />
".T_("DELETE_IMAGE")." "."<input type='radio' name='img1action' value='update' />
".T_("UPDATE_IMAGE")."</div><input type='file' name='image0' class='btnHuge2' /></td></tr>";
echo "<tr><td height='5'></td></tr>"; //==| Vertical space
/*/==| Poster Image Upload
If ($CURUSER["class"] > 9) {
echo "<tr class='table_col1'><td align='right' valign='bottom'><div style='margin-bottom:5px'>".T_("POSTER_IMAGE_UPLOAD").":</div></td>
<td><div style='margin-bottom:5px'><input type='radio' name='img2action' value='keep' checked='checked' />
".T_("KEEP_IMAGE")." "."<input type='radio' name='img2action' value='delete' />
".T_("DELETE_IMAGE")." "."<input type='radio' name='img2action' value='update' />
".T_("UPDATE_IMAGE")."</div><input type='file' name='image1' class='btnHuge3' /></td></tr>";
echo "<tr><td height='5'></td></tr>"; //==| Vertical space
} //*/
//==| NFO
echo "<tr><td align='right' valign='bottom'><div style='margin-bottom:5px'>".T_("NFO_FILE").":</div></td>
<td><div style='margin-bottom:5px'><input type='radio' name='nfoaction' value='keep' checked='checked' />
".T_("KEEP_NFO")." <input type='radio' name='nfoaction' value='update' /> ".T_("UPDATE_NFO")." ";
if ($row["nfo"] == "yes") {
//echo " [<a href='nfoview.php?id=".$row["id"]."' target='_blank'><b>".T_("VIEW_CURRENT_NFO")."</b></a>]";
echo " [<a href=\"javascript:void(0);\" onclick=\"window.open('/nfoview.php?id=".$row["id"]."', 'mywindow5', 'width=800, height=900, menubar=no, toolbar=no, scrollbars=yes');\"><b>".T_("VIEW_CURRENT_NFO")."</b></a>]";
} else {
echo " <font color='#ff0000'><b>".T_("NO_NFO_UPLOADED")."</b></font>";
}
echo "</div><input type='file' name='nfofile' class='btnHuge2' /></td></tr>";
//==| IMDb
echo("<tr><td align='right' valign='top'><div style='margin-top:10px'>".T_("IMDB_LINK").":</div></td>
<td><div style='margin-top:5px'><input type='text' name='imdb' class='btnHuge2' value='" . htmlspecialchars($row['imdb']) . "' /></div>
<div style=\"margin-top:2px; margin-bottom:5px\"> ".T_("IMDB_LINK_MESSAGE")."</div></td></tr>");
//==| YouTube
$video = ("" . htmlspecialchars($row["video"]) . "");
echo "<tr><td align='right' valign='top'><div style='margin-top:10px'>".T_("YOUTUBE_TRAILER").":</div></td>
<td><div style='margin-top:7px'><input type=\"text\" name=\"video\" value=\"" . $video . "\" class=\"btnHuge2\" /></div>
<div style=\"margin-top:2px; margin-bottom:5px\"> ".T_("PUT_YOUTUBE_LINK")."</div></td></tr>";
//==| Category
echo "<tr><td align='right'>".T_("CATEGORY").":</td><td>".$catdropdown." </td></tr>";
//==| Language
echo "<tr><td align='right'>".T_("LANGUAGE").":</td><td>".$langdropdown."</td></tr>";
//==| Banned
if ($CURUSER["edit_torrents"] == "yes") {
echo "<tr><td align='right'>".T_("BANNED").":</td>
<td><input type=\"checkbox\" name=\"banned\"" . (($row["banned"] == "yes") ? " checked=\"checked\"" : "" ) . " value=\"1\" />
".T_("BANNED_TORRENT_MESSAGE")."</td></tr>";
}
echo "<tr><td></td></tr>"; //==| Vertical space
//==| Visible
echo "<tr><td align='right' valign='top'><div style='margin-top:2px'>".T_("VISIBLE").":</div></td>
<td><input type=\"checkbox\" name=\"visible\"" . (($row["visible"] == "yes") ? " checked=\"checked\"" : "" ) . " value=\"1\" />
".T_("VISIBLEONMAIN")."</td></tr>";
echo "<tr><td></td></tr>"; //==| Vertical space
//==| Freeleech
if ($CURUSER["edit_torrents"] == "yes" || $CURUSER['id'] == $row['owner']) {
echo "<tr><td align='right'>".T_("FREE_LEECH").":</td>
<td><input type=\"checkbox\" name=\"freeleech\"" . (($row["freeleech"] == "1") ? " checked=\"checked\"" : "" ) . " value=\"1\" />
".T_("FREE_LEECH_MSG")."</td></tr>";
} //*/
//==| Sticky
//if ($row["external"] != "yes" && $CURUSER["control_panel"] == "yes") {
if ($CURUSER["delete_torrents"] == "yes") {
echo "<tr><td align=right>".T_("T_STICKY").":</td>
<td><input type='checkbox' name='sticky'" . (($row["sticky"] == "yes") ? " checked='checked'" : "" ) . " value='yes' />
".T_("STICKY_MSG")."</td></tr>";
}
//==| En Subbed
echo "<tr><td align=right>".T_("ENSUBBED").":</td>
<td><input type='checkbox' name='ensub'" . (($row["ensub"] == "yes") ? " checked='checked'" : "" ) . " value='yes' />
<img src='images/flag.eng.gif' border='0' title='".T_("ENSUBBED")."'> ".T_("ENSUBBED_MSG")."</td></tr>";
//==| Ro-En Subbed
echo "<tr><td align=right>".T_("ROENGSUBBED").":</td>
<td><input type='checkbox' name='roeng'" . (($row["roeng"] == "yes") ? " checked='checked'" : "" ) . " value='yes' />
<img src='images/ro-eng-flag.png' border='0' title='".T_("ROENGSUBBED")."'> ".T_("ROENGSUBBED_MSG")."</td></tr>";
//==| Recommended torrents
if(get_user_class($CURUSER) >= 5 && $site_config['REC_TOR']) {
echo "<tr><td align=right>".T_("REC_TORRENT").":</b></td>
<td><input type='checkbox' name='recommended3'" . (($row["recommended3"] == "yes") ? " checked='checked'" : "" ) . " value='yes' />
".T_("WILL_BE_SHOWN_AT")." ".T_("RECOMMENDED_TORRENTS")."</td></tr>";
}
//==| Anonymous
if ($site_config['ANONYMOUSUPLOAD']) {
echo "<tr><td align='right'>".T_("ANONYMOUS_UPLOAD").":</td>
<td><input type=\"checkbox\" name=\"anon\"" . (($row["anon"] == "yes") ? " checked=\"checked\"" : "" ) . " value=\"1\" />";
if($CURUSER['id'] == $row['owner']) { echo " ".T_("ANONYMOUS_UPLOAD_MSG").""; }
else { echo " ".T_("ANONYMOUS_UPLOAD_MSG2").""; }
echo "</td></tr>";
}
print("</table>\n");
//==| Dascription
print("<div style='margin-top:20px; font:bold 12px Verdana' align='center'>" . T_("DESCRIPTION") . "</div>");
require_once("backend/bbupload.php");
print textbbupload("bbform","descr", htmlspecialchars($row["descr"]));
//==| Submit
print("<div style='margin-top:10px; margin-bottom:10px' align='center'>
<input type=\"submit\" value='".T_("SUBMIT")."' />
<input type='reset' value='".T_("UNDO")."' />
</div>\n");
print("</form>\n");
end_frame();
//==| Delete
//if($CURUSER["delete_torrents"] == "yes" || $CURUSER['id'] == $row['owner']) {
if($CURUSER["delete_torrents"] == "yes") {
begin_frame(T_("DELETE_TORRENT"));
print("<div style='margin-top:15px; margin-bottom:15px' align='center'>");
print("<form method='post' action='torrents-edit.php?action=deleteit&id=$id'>\n");
print("<input type='hidden' name='torrentid' value='$id' />\n");
print("<input type='hidden' name='ownerid' value='$ownertor' />\n");
print("<input type='hidden' name='points' value='$actpoints' />\n");
print("<input type='hidden' name='torrentname' value='".htmlspecialchars($row["name"])."' />\n");
echo "".T_("REASON").": <input type='text' class='btnHuge3' name='delreason' />";
echo " <input type='submit' value='".T_("DELETE")."' /></form>";
print("</div>");
end_frame();
}
stdfoot();
?>thanks

