-
Notifications
You must be signed in to change notification settings - Fork 0
/
editfora.php
156 lines (143 loc) · 5.11 KB
/
editfora.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php
// AcmlmBoard XD - Forum list editing tool
// Access: administrators
include("lib/common.php");
AssertForbidden("editForum");
if($loguser['powerlevel'] < 3)
Kill(__("You must be an administrator to edit the forum list."));
if($_POST['action'] == __("Move"))
{
$qForum = "update forums set forder=".(int)$_POST['order'].", catid=".(int)$_POST['category']." where id=".(int)$_POST['fid']." limit 1";
$rForum = Query($qForum);
Alert(__("Forum moved."), __("Notice"));
} elseif($_POST['action'] == "Add")
{
$qForum = "insert into forums (title, description, catid, forder) values ('".justEscape($_POST['title'])."', '".justEscape($_POST['description'])."', ".(int)$_POST['category'].", ".(int)$_POST['order'].")";
$rForum = Query($qForum);
Alert(__("Forum added."), __("Notice"));
} elseif($_POST['action'] == __("Remove"))
{
$qForum = "select * from forums where id=".(int)$_POST['fid'];
$rForum = Query($qForum);
$forum = Fetch($rForum);
write(
"
<div class=\"outline margin center width50\" style=\"margin: 0px auto 16px;\">
<div class=\"errort\"><strong>".__("Confirm deletion of \"{0}\"")."</strong></div>
<div class=\"errorc cell2\">
<form action=\"editfora.php\" method=\"post\">
<input type=\"submit\" name=\"action\" value=\"".__("Yes, do as I say.")."\" />
<input type=\"hidden\" name=\"fid\" value=\"{1}\" />
</form>
</div>
</div>
", $forum['title'], (int)$forum['id']);
}
elseif($_POST['action'] == __("Yes, do as I say."))
{
$qForum = "delete from forums where id=".(int)$_POST['fid'];
$rForum = Query($qForum);
Alert(__("Forum removed."), __("Notice"));
}
elseif($_POST['action'] == __("Edit"))
{
$qForum = "update forums set title='".justEscape($_POST['title'])."', description='".justEscape($_POST['description'])."' where id=".(int)$_POST['fid']." limit 1";
$rForum = Query($qForum);
Alert(__("Forum edited."), __("Notice"));
}
$thelist = "";
$qCategories = "select * from categories";
$rCategories = Query($qCategories);
if(NumRows($rCategories))
{
while($category = Fetch($rCategories))
{
$qFora = "select * from forums where catid=".(int)$category['id']." order by forder";
$rFora = Query($qFora);
if(NumRows($rFora))
{
while($forum = Fetch($rFora))
{
$localMods = "";
$qMods = "select * from forummods where forum=".(int)$forum['id'];
$rMods = Query($qMods);
if(NumRows($rMods))
{
while($mod = Fetch($rMods))
{
$qMod = "select name, id, powerlevel, sex from users where id=".$mod['user'];
$rMod = Query($qMod);
$mod2 = Fetch($rMod);
$localMods .= UserLink($mod2).", ";
}
$localMods = __("Moderated by:")." ".substr($localMods,0,strlen($localMods)-2);
}
else
$localMods = __("No mods");
$thelist .= format(
"
<div class=\"errorc left cell1\" style=\"clear: both; overflow: auto;\">
<div style=\"float: left; width: 60%;\">
<form action=\"editfora.php\" method=\"post\">
<input type=\"text\" name=\"title\" value=\"{0}\" style=\"width: 70%;\" />
<input type=\"submit\" name=\"action\" value=\"".__("Edit")."\" /><br />
<input type=\"text\" name=\"description\" style=\"width: 90%;\" value=\"{1}\" />
<input type=\"hidden\" name=\"fid\" value=\"{2}\" /><br/>
<small>{3} (<a href=\"managemods.php\">".__("Edit")."</a>) • ".__("{4} thread(s), {5} post(s).")."</small>
</form>
</div>
<form action=\"editfora.php\" method=\"post\">
{7}
<input type=\"text\" name=\"order\" value=\"{6}\" size=\"2\" maxlength=\"2\" /><br />
<input type=\"submit\" name=\"action\" value=\"".__("Move")."\" />
<input type=\"submit\" name=\"action\" value=\"".__("Remove")."\" />
<input type=\"hidden\" name=\"fid\" value=\"{2}\" />
</form>
</div>
", htmlval($forum['title']), htmlval($forum['description']), $forum['id'], $localMods,
$forum['numthreads'], $forum['numposts'], $forum['forder'],
MakeOptions($forum['catid']));
}
}
}
write(
"
<div class=\"outline width50 margin\">
<div class=\"errort\"><strong>".__("Forum list")."</strong></div>
{0}
</div>
", $thelist);
}
write(
"
<form action=\"editfora.php\" method=\"post\">
<div class=\"outline width50 margin\">
<div class=\"errort\"><strong>".__("Add a Forum")."</strong></div>
<div class=\"errorc left cell1\" style=\"clear: both; overflow: auto;\">
<div style=\"float: left; width: 60%;\">
<input type=\"text\" name=\"title\" style=\"width: 70%;\" /><br/>
<input type=\"text\" name=\"description\" style=\"width: 90%;\" />
</div>
{0}
<input type=\"text\" name=\"order\" value=\"0\" size=\"2\" maxlength=\"2\" />
{1}
<input type=\"submit\" name=\"action\" value=\"Add\" />
</div>
</div>
</form>
<p>
".__("For more complex things, try PMA. This is just a toy-like quick access.")."
</p>
", MakeOptions(-1), $levels);
function MakeOptions($catid)
{
$sel[$catid] = " selected=\"true\"";
$qFora = "select id,name from categories";
$rFora = Query($qFora);
$result = "<select name=\"category\" size=\"1\">";
while($forum = Fetch($rFora))
$result .= "<option value=\"".$forum['id']."\"".$sel[$forum['id']]."\>".$forum['name']."</option>";
$result .= "</select>";
return $result;
}
?>