forked from joeroberts234/phpMyBitTorrent
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcredits.php
333 lines (279 loc) · 10.6 KB
/
credits.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
<?php
/*
*------------------------------phpMyBitTorrent V 2.0.4-------------------------*
*--- The Ultimate BitTorrent Tracker and BMS (Bittorrent Management System) ---*
*-------------- Created By Antonio Anzivino (aka DJ Echelon) --------------*
*------------- http://www.p2pmania.it -------------*
*------------ Based on the Bit Torrent Protocol made by Bram Cohen ------------*
*------------- http://www.bittorrent.com -------------*
*------------------------------------------------------------------------------*
*------------------------------------------------------------------------------*
*-- This program is free software; you can redistribute it and/or modify --*
*-- it under the terms of the GNU General Public License as published by --*
*-- the Free Software Foundation; either version 2 of the License, or --*
*-- (at your option) any later version. --*
*-- --*
*-- This program is distributed in the hope that it will be useful, --*
*-- but WITHOUT ANY WARRANTY; without even the implied warranty of --*
*-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --*
*-- GNU General Public License for more details. --*
*-- --*
*-- You should have received a copy of the GNU General Public License --*
*-- along with this program; if not, write to the Free Software --*
*-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --*
*-- --*
*------------------------------------------------------------------------------*
*------ ©2009 phpMyBitTorrent Development Team ------*
*----------- http://phpmybittorrent.com -----------*
*------------------------------------------------------------------------------*
*----------------- Sunday, September 14, 2008 9:05 PM ---------------------*
*/
if (!eregi("credits.php",$_SERVER["PHP_SELF"])) die ("You cannot include this file");
include("header.php");
$action = isset($_GET["action"]) ? htmlspecialchars(trim($_GET["action"])) : '';
$act_validation = array('', 'add', 'edit', 'delete', 'update');
$id = 0 + $_GET['id'];
if(!in_array($action, $act_validation))
bterror("Unknown action.","Error");
/*Check if CutName function exists, if not declare it */
if (!function_exists('CutName'))
{
function CutName ($txt, $len)
{
return (strlen($txt)>$len ? substr($txt,0,$len-4) .'[...]':$txt);
}
}
if ($_POST['action'] == 'add' && $user->admin){
$name = ($_POST['name']);
$description = ($_POST['description']);
$category = ($_POST['category']);
$link = ($_POST['link']);
$status = ($_POST['status']);
$credit = ($_POST['credit']);
mysql_query("INSERT INTO ".$db_prefix."_modscredits (
name,
description,
category,
PMBT,
status,
credit
)
VALUES(
'" . $name . "', '" . $description . "', '" . $category . "', '" . $link . "', '" . $status . "', '" . $credit . "')") or sqlerr(__FILE__, __LINE__);
header("Location: credits.php");
die();
}
if ($_GET['action'] == "delete") {
if (!$id) { bterror("No Id");}
mysql_query("DELETE FROM ".$db_prefix."_modscredits where id = '$id'") or sqlerr(__FILE__, __LINE__);
header("Location: credits.php");
die();
}
if ($action == "edit" && $user->admin)
{
$id = (int)$_GET["id"];
$res = mysql_query("SELECT name, description, category, PMBT, status, credit FROM ".$db_prefix."_modscredits WHERE id = $id") or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($res) == 0)
echo('Error No credit mod found with that ID!');
while($mod = mysql_fetch_assoc($res)){
echo "<table width=850 cellpadding=10 cellspacing=1 border=1>";
print("<form method=post action=".$_SERVER['PHP_SELF']."?action=update&id=$id>\n");
print("<tr><td class=rowhead>Mod name</td>" .
"<td align=left style='padding: 0px'><input type=text size=60 maxlength=120 name=name " .
"value=\"".htmlspecialchars($mod['name'])."\"></td></tr>\n".
"<tr><td class=rowhead>Description</td>" .
"<td align=left style='padding: 0px'><input type=text size=60 maxlength=120 name=description value=\"".htmlspecialchars($mod['description'])."\"></td></tr>\n".
"<tr><td class=rowhead>Category</td>");
?>
<td align="left" style='padding: 0px'>
<select name="category">
<?
$result=mysql_query('SHOW COLUMNS FROM '.$db_prefix.'_modscredits WHERE field=\'category\'');
while ($row=mysql_fetch_row($result))
{
foreach(explode("','",substr($row[1],6,-2)) as $v)
{
print("<option value=$v". ($mod["category"] == $v ? " selected" : "") . ">$v</option>");
}
}
?>
</select>
</td>
</tr>
<?
print("<tr><td class=rowhead>Link</td>" .
"<td align=left style='padding: 0px'><input type=text size=60 maxlength=120 name=link " .
"value=\"".htmlspecialchars($mod['PMBT'])."\"></td></tr>\n");
print("<tr><td class=rowhead>Status</td>");
?>
<td align="left" style='padding: 0px'>
<select name="modstatus">
<?
$result=mysql_query('SHOW COLUMNS FROM '.$db_prefix.'_modscredits WHERE field=\'status\'');
while ($row=mysql_fetch_row($result))
{
foreach(explode("','",substr($row[1],6,-2)) as $y)
{
print("<option value=$y". ($mod["status"] == $y ? " selected" : "") . ">$y</option>");
}
}
?>
</select>
</td>
</tr>
<?
print("<tr><td class=rowhead>Credits</td><td align=left style='padding: 0px'><input type=text size=60 maxlength=120 name=credits value=\"".htmlspecialchars($mod['credit'])."\"></td></tr>\n");
print("<tr><td colspan=2 align=center><input type=submit value='Submit'></td></tr>\n");
print("</form></table>");
}
CloseTable();
}else if ($action == "update" && $user->admin)
{
$id = (int)$_GET["id"];
//if (!is_valid_id($id))
//bterror('Error', 'Invalid ID!');
$res = mysql_query('SELECT id FROM '.$db_prefix.'_modscredits WHERE id = '.$id);
if (mysql_num_rows($res) == 0)
bterror('No mod credit with that ID!');
$name = $_POST['name'];
$description = $_POST['description'];
$category = $_POST['category'];
$link = $_POST['link'];
$modstatus = $_POST['modstatus'];
$credit = $_POST['credits'];
function sqlesc($esc)
{
return "'".$esc."'";
}
if (empty($name))
bterror("You must specify a name for this credit.");
if (empty($description))
bterror("You must provide a description for this credit.");
//if (empty($link))
//bterror("Error", "You must provide a link to TBDev for this credit.");
if (empty($credit))
bterror("You must provide a credit for the author(s) of this credit.");
mysql_query("UPDATE ".$db_prefix."_modscredits SET name = ".sqlesc($name).", category = ".sqlesc($category).", status = ".sqlesc($modstatus).", PMBT = ".sqlesc($link).", credit = ".sqlesc($credit).", description = ".sqlesc($description)." WHERE id = ".sqlesc($id)) or sqlerr(__FILE__, __LINE__);
header("Location: {$_SERVER['PHP_SELF']}");
exit();
}else if ($action == ""){
OpenTable("Credits");
?>
<script language="JavaScript">
<!--
function confirm_delete(id)
{
ht = document.getElementsByTagName("html");
ht[0].style.filter = "progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)";
if (confirm('Are you sure you want to delete this mod credit?'))
{
return true;
}
else
{
ht[0].style.filter = "";
return false;
}
}
//-->
</script>
<?
/*
Begin displaying the mods
*/
/*Query the db*/
$res = mysql_query("SELECT * FROM ".$db_prefix."_modscredits") or sqlerr(__FILE__, __LINE__);
//Begin displaying the table
echo "<table width=850 cellpadding=10 cellspacing=1 border=1>";
echo "<tr>";
echo "<td align=center class=colhead>Name</td>";
echo "<td align=center class=colhead>Category</td>";
echo "<td align=center class=colhead>Status</td>";
echo "<td align=center class=colhead>Credits</td>";
echo "</tr>";
if($row = mysql_fetch_array($res)){
do{
$id = $row["id"];
$name = $row["name"];
$category =$row["category"];
if($row["status"]=="In-Progress"){
$status = "[b][color=#ff0000]".$row["status"]."[/color][/b]";
}else{
$status = "[b][color=#018316]".$row["status"]."[/color][/b]";
}
$link = $row["PMBT"];
$credit = $row["credit"];
$descr = $row["description"];
echo "<tr><td><p><a target=_blank class=altlink href=".$link.">".htmlspecialchars(CutName($name,60)) ."</a>";
if ($user->admin){
echo " <a class=altlink_blue href=?action=edit&id=".$id.">[Edit]</a> <a class=altlink_blue href=\"credits.php?action=delete&id=".$id."\" onclick=\"return confirm_delete('".$id."')\">[Delete]</a>";
}
echo "<br/>".htmlspecialchars($descr)."</p></td>";
echo "<td><b>".htmlspecialchars($category)."</b></td>";
echo "<td><b>".format_comment($status)."<b></td>";
echo "<td>".htmlspecialchars($credit)."</td></tr>";
}while($row = mysql_fetch_array($res));
}else{
echo "<tr><td colspan=4>No mods credits so far...</td></tr>";
}
echo "</table>";
CloseTable();
if ($user->admin) //I recommend a higher class like UC_CODER
{
OpenTable("Add New Credit");
?>
<br/>
<table width="100%" cellpadding="8" border="1" cellspacing="0">
<tr>
<td colspan="2" class="colhead">
Add Mods Credits
</td>
</tr>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="hidden" name="action" value="add" />
<tr>
<td>Name:</td><td><input name="name" type="text" size="120"></td>
</tr>
<tr>
<td>Description:</td><td><input name="description" type="text" size="120" length="120"></td>
</tr>
<tr>
<td>Category:</td><td>
<select name="category">
<option value="Addon">Addon</option>
<option value="Forum">Forum</option>
<option value="Message/Email">Message/Email</option>
<option value="Display/Style">Display/Style</option>
<option value="Staff/Tools">Staff/Tools</option>
<option value="Browse/Torrent/Details">Browse/Torrent/Details</option>
<option value="Misc">Misc</option>
</select>
</td>
</tr>
<tr>
<td>Link:</td><td><input name="link" type="text" size="50"></td>
</tr>
<tr>
<td>Status:</td><td>
<select name="status">
<option value="In-Progress">In-Progress</option>
<option value="Complete">Complete</option>
</select>
</td>
</tr>
<tr>
<td>Credits:</td><td><input name="credit" type="text" size="120" length="120"><br><font class="small">Values separated by commas</font></td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Add Credit" />
</td>
</tr>
</form>
</table>
<?
CloseTable();
}
}
include("footer.php");
?>