-
Notifications
You must be signed in to change notification settings - Fork 0
/
editsmilies.php
121 lines (106 loc) · 2.94 KB
/
editsmilies.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
<?php
// AcmlmBoard XD - Smiley editing tool
// Access: administrators only
include("lib/common.php");
AssertForbidden("editSmilies");
if($loguser['powerlevel'] < 3)
Kill("You must be an administrator to edit the smiley table.");
$key = hash('sha256', "{$loguserid},{$loguser['pss']},{$salt}");
if (isset($_POST['action']) && $key != $_POST['key'])
Kill(__("No."));
if($_POST['action'] == "Apply")
{
$qSmilies = "select * from smilies";
$rSmilies = Query($qSmilies);
$numSmilies = NumRows($rSmilies);
for($i = 0; $i <= $numSmilies; $i++)
{
if($_POST['code_'.$i] != $_POST['oldcode_'.$i] || $_POST['image_'.$i] != $_POST['oldimage_'.$i])
{
if($_POST['code_'.$i] == "")
{
$act = "deleted";
$qSmiley = "delete from smilies where code='".$_POST['oldcode_'.$i]."'";
} else
{
$act = "edited to \"".$_POST['image_'.$i]."\"";
$qSmiley = "update smilies set code='".$_POST['code_'.$i]."', image='".$_POST['image_'.$i]."' where code='".$_POST['oldcode_'.$i]."'";
}
$rSmiley = Query($qSmiley);
$log .= "Smiley \"".$_POST['oldcode_'.$i]."\" ".$act.".<br />";
}
}
if($_POST['code_add'] && $_POST['image_add'])
{
$qSmiley = "insert into smilies (code,image) value ('".$_POST['code_add']."', '".$_POST['image_add']."')";
$rSmiley = Query($qSmiley);
$log .= "Smiley \"".$_POST['code_add']."\" added.<br />";
}
if($log)
Alert($log,"Log");
}
$smileyList = "";
$qSmilies = "select * from smilies";
$rSmilies = Query($qSmilies);
while($smiley = Fetch($rSmilies))
{
$cellClass = ($cellClass+1) % 2;
$i++;
$smileyList .= format(
"
<tr class=\"cell{0}\">
<td>
<input type=\"text\" name=\"code_{1}\" value=\"{2}\" />
<input type=\"hidden\" name=\"oldcode_{1}\" value=\"{2}\" />
</td>
<td>
<input type=\"text\" name=\"image_{1}\" value=\"{3}\" />
<input type=\"hidden\" name=\"oldimage_{1}\" value=\"{3}\" />
<img src=\"img/smilies/{4}\" alt=\"{5}\" title=\"{5}\">
</td>
</tr>
", $cellClass, $i, htmlentities2($smiley['code']), htmlentities2($smiley['image']),
$smiley['image'], $smiley['code']);
}
write(
"
<div class=\"outline margin width25 faq\">
To add, fill in both bottom fields and apply.<br />
To edit, change either code or image fields to <em>not</em> match their hidden counterparts.
</div>
<form method=\"post\" action=\"editsmilies.php\">
<table class=\"outline margin\" style=\"width: 30%;\">
<tr class=\"header1\">
<th>
Code
</th>
<th>
Image
</th>
</tr>
{0}
<tr class=\"header0\">
<th colspan=\"2\">
Add
</th>
</tr>
<tr class=\"cell2\">
<td>
<input type=\"text\" name=\"code_add\" />
</td>
<td>
<input type=\"text\" name=\"image_add\" />
</td>
</tr>
<tr class=\"cell2\">
<td>
</td>
<td>
<input type=\"submit\" name=\"action\" value=\"Apply\" />
<input type=\"hidden\" name=\"key\" value=\"{1}\" />
</td>
</tr>
</table>
</form>
", $smileyList, $key);
?>