<?php
//
// TorrentTrader v2.x
// $LastChangedDate: 2011-11-11 16:48:38 +0000 (Fri, 11 Nov 2011) $
// $LastChangedBy: dj-howarth1 $
//
// [url="http://www.torrenttrader.org"]http://www.torrenttrader.org[/url]
//
//
require_once("backend/functions.php");
dbconn();
loggedinonly();
$id = (int) $_REQUEST["id"];
if (!is_valid_id($id)) show_error_msg(T_("ERROR"), T_("INVALID_ID"), 1);
$action = $_REQUEST["action"];
$row = mysql_fetch_assoc(SQL_Query_exec("SELECT `owner` FROM `torrents` WHERE id=$id"));
if($CURUSER["edit_torrents"]=="no" && $CURUSER['id'] != $row['owner'])
show_error_msg(T_("ERROR"), T_("NO_TORRENT_EDIT_PERMISSION"), 1);
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 func
//GET DATA FROM DB
$res = SQL_Query_exec("SELECT * FROM torrents WHERE id = $id");
$row = mysql_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 (!$delreason){
show_error_msg(T_("ERROR"), T_("MISSING_FORM_DATA"), 1);
}
deletetorrent($torrentid);
write_log($CURUSER['username']." has deleted torrent: ID:$torrentid - ".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']."nnReason: $delreason").", 'yes', 'in')");
}
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();
$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'";
}//success
}
if (!empty($_POST["name"]))
$updateset[] = "name = " . sqlesc($_POST["name"]);
$updateset[] = "descr = " . sqlesc($_POST["descr"]);
$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 ($CURUSER["edit_torrents"] == "yes")
$updateset[] = "freeleech = '".$_POST["freeleech"]."'";
$updateset[] = "anon = '" . ($_POST["anon"] ? "yes" : "no") . "'";
//webseed
if ($CURUSER["edit_torrents"] == "yes")
$updateset[] = "webseed = '".$_POST["webseed"]."'";
//
//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 $id (".htmlspecialchars($_POST["name"]).") was edited by $CURUSER[username]");
header("Location: $returl");
die();
}//END SAVE TO DB
//UPDATE CATEGORY DROPDOWN
$catdropdown = "<select name="type">n";
$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";
$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
$char1 = 55;
$shortname = CutName(htmlspecialchars($row["name"]), $char1);
if ($_GET["edited"]){
show_error_msg("Edited OK", T_("TORRENT_EDITED_OK"), 1);
}
stdhead(T_("EDIT_TORRENT")." "$shortname"");
begin_frame(T_("EDIT_TORRENT")." "$shortname"");
print("<br /><br /><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 border='0' cellspacing='4' cellpadding='2' width='95%'>n");
echo "<tr><td align='right' width='60'><b>".T_("NAME").": </b></td><td><input type="text" name="name" value="" . htmlspecialchars($row["name"]) . "" size="60" /></td></tr>";
echo "<tr><td align='right'><b>".T_("IMAGE").": </b></td><td><b>".T_("IMAGE")." 1:</b> <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")."<br /><input type='file' name='image0' size='60' /> <br /><br /> <b>".T_("IMAGE")." 2:</b> <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")."<br /><input type='file' name='image1' size='60' /></td></tr>";
echo "<tr><td align='right'><b>".T_("NFO").": </b><br /></td><td><input type='radio' name='nfoaction' value='keep' checked='checked' />Keep NFO <input type='radio' name='nfoaction' value='update' />Update NFO:";
if ($row["nfo"] == "yes"){
echo " <a href='nfo-view.php?id=".$row["id"]."' target='_blank'>[".T_("VIEW_CURRENT_NFO")."]</a>";
} else{
echo " <font color='#ff0000'>".T_("NO_NFO_UPLOADED")."</font>";
}
echo "<br /><input type='file' name='nfofile' size='60' /></td></tr>";
echo "<tr><td align='right'><b>".T_("CATEGORIES").": </b></td><td>".$catdropdown."</td></tr>";
echo "<tr><td align='right'><b>".T_("LANG").": </b></td><td>".$langdropdown."</td></tr>";
if ($CURUSER["edit_torrents"] == "yes")
echo "<tr><td align='right'><b>".T_("BANNED").": </b></td><td><input type="checkbox" name="banned"" . (($row["banned"] == "yes") ? " checked="checked"" : "" ) . " value="1" /> ".T_("BANNED")."?<br /></td></tr>";
echo "<tr><td align='right'><b>".T_("VISIBLE").": </b></td><td><input type="checkbox" name="visible"" . (($row["visible"] == "yes") ? " checked="checked"" : "" ) . " value="1" /> " .T_("VISIBLEONMAIN"). "<br /></td></tr>";
if ($row["external"] != "yes" && $CURUSER["edit_torrents"] == "yes"){
echo "<tr><td align='right'><b>".T_("FREE_LEECH").": </b></td><td><input type="checkbox" name="freeleech"" . (($row["freeleech"] == "1") ? " checked="checked"" : "" ) . " value="1" />".T_("FREE_LEECH_MSG")."<br /></td></tr>";
}
//webseed
if ($row["external"] != "yes" && $CURUSER["edit_torrents"] == "yes"){
echo "<tr><td align=right><B>Webseed: </b></TD><TD><input type="checkbox" name="webseed"" . (($row["webseed"] == "1") ? " checked="checked"" : "" ) . " value="1" />Torrent with Webseed<br>";
}
//
if ($site_config['ANONYMOUSUPLOAD']) {
echo "<tr><td align='right'><b>".T_("ANONYMOUS_UPLOAD").": </b></td><td><input type="checkbox" name="anon"" . (($row["anon"] == "yes") ? " checked="checked"" : "" ) . " value="1" />(".T_("ANONYMOUS_UPLOAD_MSG").")<br /></td></tr>";
}
print ("<tr><td align='center' colspan='2'><b>" .T_("DESCRIPTION"). ":</b></td></tr></table>");
require_once("backend/bbcode.php");
print textbbcode("bbform","descr", htmlspecialchars($row["descr"]));
print("<br /><center><input type="submit" value='".T_("SUBMIT")."' /> <input type='reset' value='".T_("UNDO")."' /></center>n");
print("</form>n");
end_frame();
begin_frame(T_("DELETE_TORRENT"));
print("<center><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='torrentname' value='".htmlspecialchars($row["name"])."' />n");
echo "<b>".T_("REASON_FOR_DELETE")."</b><input type='text' size='30' name='delreason' />";
echo " <input type='submit' value='".T_("DELETE_TORRENT")."' /></form></center>";
end_frame();
stdfoot();
?>
#======================================================================#
# Add Users
#======================================================================#
if ($action == "adduser") {
if ($CURUSER["class"] < "9") {
show_error_msg("Error", "Sorry you do not have the rights to view this page!", 1);
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if ($_POST["username"] == "" || $_POST["password"] == "" || $_POST["email"] == "")
show_error_msg(T_("ERROR"), T_("DONT_LEAVE_ANY_FIELD_BLANK"),1);
if ($_POST["password"] != $_POST["password2"])
show_error_msg(T_("ERROR"), T_("PASSWORDS_NOT_MATCH"),1);
$username = sqlesc($_POST["username"]);
$password = $_POST["password"];
$email = sqlesc($_POST["email"]);
$secret = mksecret();
$passhash = sqlesc(passhash($password)); // hash the password
$secret = sqlesc($secret);
SQL_Query_exec("INSERT INTO users (added, last_access, secret, username, password, status, email, stylesheet, language, uploaded) VALUES(NOW(), NOW(), $secret, $username, $passhash, 'confirmed', $email, $site_config["default_theme"], $site_config["default_language"], 5368709120)") or die(mysql_error());
$id = mysql_insert_id();
//send pm to new user
if ($site_config["WELCOMEPMON"]){
$dt = sqlesc(get_date_time());
$msg = sqlesc($site_config["WELCOMEPMMSG"]);
SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $id, $dt, $msg, 0)");
}
$res = SQL_Query_exec("SELECT id FROM users WHERE username=$username");
$arr = mysql_fetch_row($res);
if (!$arr)
show_error_msg(T_("ERROR"), "Unable to create the account. The user name is possibly already taken.",1);
header("Location: account-details.php?id=$arr[0]");
die;
}
stdhead("Add user");
navmenu();
begin_frame("Add User");
?>
<div align=center>
<CENTER><form method=get action=?>
<input type=hidden name=action value=users> Search Users: <input type=text size=30 name=search> <input type=submit value='Search'>
</form></CENTER><br />
<div align=center>
<h1>Add user</h1>
<form method=post action=admincp.php?action=adduser>
<table border=1 cellspacing=0 cellpadding=5>
<tr><td class=rowhead>Username</td><td><input type=text name=username size=40></td></tr>
<tr><td class=rowhead>Password</td><td><input type=password name=password size=40></td></tr>
<tr><td class=rowhead>Re-type password</td><td><input type=password name=password2 size=40></td></tr>
<tr><td class=rowhead>E-mail</td><td><input type=text name=email size=40></td></tr>
<tr><td colspan=2 align=center><input type=submit value="Okay" class=btn></td></tr>
</table>
</form>
</div>
<?
end_frame();
stdfoot();
}
#======================================================================#
# END Add Users
#======================================================================#
<td align="center"><a href="admincp.php?action=nick_change"><img src="images/admin/nick.png" border="0" width="32" height="32" alt="" /><br /><?php echo T_("CHANGE_NICKNAME"); ?><br /></a></td>

//update seedbox
if($CURUSER["class") > 4) {
if ($_POST["seedbox"] == "yes") {
$seedbox = 'yes';
}else{
$seedbox = 'no';
}
}
CREATE TABLE IF NOT EXISTS `shoutannounce` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(100) NOT NULL DEFAULT '',
`descr` text NOT NULL,
`added` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`active` enum('yes','no') NOT NULL DEFAULT 'yes',
`time` int(11) unsigned NOT NULL DEFAULT '0',
`last_time` int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
$res = SQL_Query_exec("SHOW TABLES");
$query = SQL_Query_exec("SELECT `id`, `descr`, `time`, `last_time` FROM `shoutannounce` WHERE `active` = 'yes'");
while ($row = mysql_fetch_array($query)) {
if ($row['last_time'] + $row['time'] > gmtime())
continue;
SQL_Query_exec("INSERT INTO ajshoutbox (uid, date, name, text) VALUES(0,NOW(), '<font color=red >BoT</font>', " . sqlesc($row['descr']) . ")");
SQL_Query_exec("UPDATE `shoutannounce` SET `last_time` = '" . gmtime() . "' WHERE `id` = " . $row['id'] . "");
}
//SQL_Query_exec("OPTIMIZE TABLE `$table[0]`;");
}
}
?>
//shoutannonce
if ($action == "shoutannounce")
{
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
if (empty($_POST['title']) || empty($_POST['descr']) || !is_valid_id($_POST['time']))
show_error_msg("Error", "Form not completed. <a href='admincp.php?action=shoutannounce'>return</a>?", 1);
SQL_Query_exec("INSERT INTO `shoutannounce` (`title`, `descr`, `added`, `time`) VALUES ('" . $_POST['title'] . "', '" . $_POST['descr'] . "', '" . get_date_time() . "', '" . $_POST['time'] . "')");
show_error_msg("Success", "Announcement Created. <a href='admincp.php?action=shoutannounce'>return</a>?", 1);
}
stdhead("Create New Announcement");
navmenu();
begin_frame("Create New Announcement");
echo("<form name='shoutannounce' method='post' action='admincp.php?action=shoutannounce'>");
echo("<table border='0' cellpadding='5' cellspacing='0' align='center'>");
echo("<tr>");
echo("<th><strong>Title:</strong></td>");
echo("<th><input type='text' name='title' size='30' /></td>");
echo("</tr>");
echo("<tr>");
echo("<th><strong>Time:</strong></td>");
echo("<th><select name='time'><option value='1800'>30 Mins</option><option value='3600'>1 Hour</option></select></td>");
echo("</tr>");
echo("</table>");
require_once("backend/bbcode.php");
echo(textbbcode("shoutannounce","descr","$descr"));
echo("<input type='reset' value='Reset' /><input type='submit' value='Submit' />");
echo("</form>");
end_frame();
stdfoot();
}
if ($action == 'shouteditannounce')
{
$id = isset($_GET['id']) ? $_GET['id'] : '';
if (!is_valid_id($id))
show_error_msg("Error", "Thats an Invalid ID O_o", 1);
$sql = SQL_Query_exec("SELECT * FROM `shoutannounce` WHERE `id` = $id");
$row = mysql_fetch_array($sql);
if (!$row)
show_error_msg("Error", "Invalid ID.", 1);
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
if (empty($_POST['title']) || empty($_POST['descr']) || !is_valid_id($_POST['time']))
show_error_msg("Error", "Form not completed. <a href='admincp.php?action=shouteditannounce&id=$id'>return</a>?", 1);
SQL_Query_exec("UPDATE `shoutannounce` SET `title` = '" . $_POST['title'] . "', `descr` = '" . $_POST['descr'] . "', `time` = '" . $_POST['time'] . "', `active` = '" . $_POST['active'] . "' WHERE `id` = $id");
show_error_msg("Success", "Announcement edited. <a href='admincp.php?action=shoutannounce'>return</a>?", 1);
}
stdhead("Edit Announcement");
navmenu();
begin_frame("Edit Announcement");
echo("<form name='shouteditcreate' method='post' action='admincp.php?action=shouteditannounce&id=$id'>");
echo("<table border='0' cellpadding='5' cellspacing='0' align='center'>");
echo("<tr>");
echo("<th><strong>Title:</strong></td>");
echo("<th><input type='text' name='title' size='30' value='" . htmlspecialchars($row['title']) . "' /></td>");
echo("</tr>");
echo("<tr>");
echo("<th><strong>Time:</strong></td>");
echo("<th><select name='time'><option value='1800' " . ($row['time'] == '1800' ? 'selected="selected"' : '' ). ">30 Mins</option><option value='3600' " . ($row['time'] == '3600' ? 'selected="selected"' : ''). ">1 Hour</option></select></td>");
echo("</tr>");
echo("<tr>");
echo("<th><strong>Enabled:</strong></td>");
echo("<th><select name='active'><option value='yes' " . ($row['active'] == 'yes' ? 'selected="selected"' : '' ). ">Yes</option><option value='no' " . ($row['active'] == 'no' ? 'selected="selected"' : ''). ">No</option></select></td>");
echo("</tr>");
echo("</table>");
require_once("backend/bbcode.php");
echo(textbbcode("shouteditcreate","descr", $row['descr']));
echo("<input type='reset' value='Reset' /><input type='submit' value='Submit' />");
echo("</form>");
end_frame();
stdfoot();
}
//End shoutannonce
<td align="center"><a href="admincp.php?action=shoutannounce"><img src="images/admin/blocked.gif" border="0" width="32" height="32"><br />Shoutbox Announce<br /></a></td>
Quote:TT2.08if ($row["freeleech"] == 1) {
$freeleech = "<img src='images/free.gif' border='0' title='Free Leech'>";
Quote:if ($row["silver"] == 2) {
$silver = " <img src='images/silver.gif' border='0' title='Silver'>";
} else {
$silver = "";
Quote:i the same message$action = $_REQUEST["action"];
Quote:modifiedALTER TABLE users ADD(parked enum ('yes','no') NOT NULL default 'no');
Quote:ALTER TABLE users ADD parked enum ('yes','no') NOT NULL default 'no';
"phoenix75, post: 90647":[url="http://devscorner.xyz/applications/core/interface/file/attachment.php?id=6762"]admincp.php[/url]
thanks you Thib good work ;)
grand Merci Thib ça fonctionne