-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnfo-edit.php
87 lines (67 loc) · 2.38 KB
/
nfo-edit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
//
// TorrentTrader v2.x
// $LastChangedDate: 2011-11-12 01:48:15 +0000 (Sat, 12 Nov 2011) $
// $LastChangedBy: dj-howarth1 $
//
// http://www.torrenttrader.org
//
//
require_once("backend/functions.php");
dbconn();
loggedinonly();
error_reporting(0);
if ($CURUSER["edit_torrents"] == "no")
show_error_msg(T_("ERROR"), T_("NFO_PERMISSION"), 1);
$id = (int)$_GET["id"]?$_GET["id"]:$_POST["id"];
$do = $_POST["do"];
$nfo = $site_config["nfo_dir"] . "/$id.nfo";
if ($do == "update") {
if (file_put_contents($nfo, $_POST["content"]))
{
write_log("NFO ($id) was updated by $CURUSER[username].");
show_error_msg(T_("NFO_UPDATED"), T_("NFO_UPDATED"), 1);
}
}
if ($do == "delete") {
$reason = htmlspecialchars($_POST["reason"]);
if (get_row_count("torrents", "WHERE `nfo` = 'yes' AND `id` = $id"))
{
unlink($nfo);
write_log("NFO ($id) was deleted by $CURUSER[username] $reason");
SQL_Query_exec("UPDATE `torrents` SET `nfo` = 'no' WHERE `id` = $id");
show_error_msg(T_("NFO_DELETED"), T_("NFO_DELETED"), 1);
}
show_error_msg(T_("ERROR"), sprintf(T_("NFO_NOT_EXIST"), $id), 1);
}
if ((!is_valid_id($id)) || (!$contents = file_get_contents($nfo))) {
show_error_msg(T_("ERROR"), T_("NFO_NOT_FOUND"), 1);
}
stdhead(T_("NFO_EDITOR"));
begin_frame(T_("EDIT_NFO"));
?>
<center>
<form method="post" action="nfo-edit.php">
<input type="hidden" name="id" value="<?php echo $id; ?>" />
<input type="hidden" name="do" value="update" />
<textarea class="nfo" name="content" cols="100%" rows="80"><?php echo htmlspecialchars(stripslashes($contents)); ?></textarea><br />
<input type="reset" value="<?php echo T_("RESET"); ?>" />
<input type="submit" value="<?php echo T_("SAVE"); ?>" />
</form>
</center>
<?php
end_frame();
begin_frame(T_("NFO_DELETE"));
?>
<center>
<form method="post" action="nfo-edit.php">
<input type="hidden" name="id" value="<?php echo $id; ?>" />
<input type="hidden" name="do" value="delete" />
<b><?php echo T_("NFO_REASON"); ?>:</b> <input type="text" name="reason" size="40" />
<input type="submit" value="<?php echo T_("DELETE"); ?>" />
</form>
</center>
<?php
end_frame();
stdfoot();
?>