-
Notifications
You must be signed in to change notification settings - Fork 29
/
makepoll.php
204 lines (191 loc) · 10.4 KB
/
makepoll.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
<?
/*
// +--------------------------------------------------------------------------+
// | Project: TBDevYSE - TBDev Yuna Scatari Edition |
// +--------------------------------------------------------------------------+
// | This file is part of TBDevYSE. TBDevYSE is based on TBDev, |
// | originally by RedBeard of TorrentBits, extensively modified by |
// | Gartenzwerg. |
// | |
// | TBDevYSE 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. |
// | |
// | TBDevYSE 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 TBDevYSE; if not, write to the Free Software Foundation, |
// | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +--------------------------------------------------------------------------+
// | Do not remove above lines! |
// +--------------------------------------------------------------------------+
*/
require_once("include/bittorrent.php");
dbconn();
loggedinorreturn();
if (get_user_class() < UC_MODERATOR)
stderr($tracker_lang['error'],$tracker_lang['access_denied']);
$action = $_GET["action"];
$pollid = (int)$_GET["pollid"];
if ($action == "edit")
{
if (!is_valid_id($pollid))
stderr($tracker_lang['error'],$tracker_lang['invalid_id']);
$res = sql_query("SELECT * FROM polls WHERE id = $pollid")
or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($res) == 0)
stderr($tracker_lang['error'],"No poll found with ID.");
$poll = mysql_fetch_array($res);
}
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
if ($action=='edit' && !is_valid_id($pollid))
stderr($tracker_lang['error'],$tracker_lang['invalid_id']);
$question = htmlspecialchars_uni($_POST["question"]);
$option0 = htmlspecialchars_uni($_POST["option0"]);
$option1 = htmlspecialchars_uni($_POST["option1"]);
$option2 = htmlspecialchars_uni($_POST["option2"]);
$option3 = htmlspecialchars_uni($_POST["option3"]);
$option4 = htmlspecialchars_uni($_POST["option4"]);
$option5 = htmlspecialchars_uni($_POST["option5"]);
$option6 = htmlspecialchars_uni($_POST["option6"]);
$option7 = htmlspecialchars_uni($_POST["option7"]);
$option8 = htmlspecialchars_uni($_POST["option8"]);
$option9 = htmlspecialchars_uni($_POST["option9"]);
$option10 = htmlspecialchars_uni($_POST["option10"]);
$option11 = htmlspecialchars_uni($_POST["option11"]);
$option12 = htmlspecialchars_uni($_POST["option12"]);
$option13 = htmlspecialchars_uni($_POST["option13"]);
$option14 = htmlspecialchars_uni($_POST["option14"]);
$option15 = htmlspecialchars_uni($_POST["option15"]);
$option16 = htmlspecialchars_uni($_POST["option16"]);
$option17 = htmlspecialchars_uni($_POST["option17"]);
$option18 = htmlspecialchars_uni($_POST["option18"]);
$option19 = htmlspecialchars_uni($_POST["option19"]);
$sort = (int) $_POST["sort"];
$returnto = htmlentities($_POST["returnto"]);
if (!$question || !$option0 || !$option1)
stderr($tracker_lang['error'], "Çàïîëíèòå âñå ïîëÿ ôîðìû!");
if ($pollid)
sql_query("UPDATE polls SET " .
"question = " . sqlesc($question) . ", " .
"option0 = " . sqlesc($option0) . ", " .
"option1 = " . sqlesc($option1) . ", " .
"option2 = " . sqlesc($option2) . ", " .
"option3 = " . sqlesc($option3) . ", " .
"option4 = " . sqlesc($option4) . ", " .
"option5 = " . sqlesc($option5) . ", " .
"option6 = " . sqlesc($option6) . ", " .
"option7 = " . sqlesc($option7) . ", " .
"option8 = " . sqlesc($option8) . ", " .
"option9 = " . sqlesc($option9) . ", " .
"option10 = " . sqlesc($option10) . ", " .
"option11 = " . sqlesc($option11) . ", " .
"option12 = " . sqlesc($option12) . ", " .
"option13 = " . sqlesc($option13) . ", " .
"option14 = " . sqlesc($option14) . ", " .
"option15 = " . sqlesc($option15) . ", " .
"option16 = " . sqlesc($option16) . ", " .
"option17 = " . sqlesc($option17) . ", " .
"option18 = " . sqlesc($option18) . ", " .
"option19 = " . sqlesc($option19) . ", " .
"sort = " . sqlesc($sort) . " " .
"WHERE id = $pollid") or sqlerr(__FILE__, __LINE__);
else
sql_query("INSERT INTO polls VALUES(0" .
", '" . get_date_time() . "'" .
", " . sqlesc($question) .
", " . sqlesc($option0) .
", " . sqlesc($option1) .
", " . sqlesc($option2) .
", " . sqlesc($option3) .
", " . sqlesc($option4) .
", " . sqlesc($option5) .
", " . sqlesc($option6) .
", " . sqlesc($option7) .
", " . sqlesc($option8) .
", " . sqlesc($option9) .
", " . sqlesc($option10) .
", " . sqlesc($option11) .
", " . sqlesc($option12) .
", " . sqlesc($option13) .
", " . sqlesc($option14) .
", " . sqlesc($option15) .
", " . sqlesc($option16) .
", " . sqlesc($option17) .
", " . sqlesc($option18) .
", " . sqlesc($option19) .
", " . sqlesc($sort) .
")") or sqlerr(__FILE__, __LINE__);
if ($returnto == "main")
header("Location: $DEFAULTBASEURL");
elseif ($pollid)
header("Location: $DEFAULTBASEURL/polls.php#$pollid");
else
header("Location: $DEFAULTBASEURL");
die;
}
stdhead();
if ($pollid)
print("<h1>Ðåäàêòèðîâàòü îïðîñ</h1>");
else
{
// Warn if current poll is less than 3 days old
$res = sql_query("SELECT question,added FROM polls ORDER BY added DESC LIMIT 1") or sqlerr(__FILE__, __LINE__);
$arr = mysql_fetch_assoc($res);
if ($arr)
{
$hours = floor((gmtime() - sql_timestamp_to_unix_timestamp($arr["added"])) / 3600);
$days = floor($hours / 24);
if ($days < 3)
{
$hours -= $days * 24;
if ($days)
$t = "$days day" . ($days > 1 ? "s" : "");
else
$t = "$hours hour" . ($hours > 1 ? "s" : "");
print("<p><font color=red><b>Note: The current poll (<i>" . $arr["question"] . "</i>) is only $t old.</b></font></p>");
}
}
print("<h1>Ñîçäàòü îïðîñ</h1>");
}
?>
<table border=1 cellspacing=0 cellpadding=5>
<form method=post action=makepoll.php>
<tr><td class=rowhead>Âîïðîñ <font color=red>*</font></td><td align=left><input name=question size=80 maxlength=255 value="<?=$poll['question']?>"></td></tr>
<tr><td class=rowhead>Âîïðîñ 1 <font color=red>*</font></td><td align=left><input name=option0 size=80 maxlength=40 value="<?=$poll['option0']?>"><br /></td></tr>
<tr><td class=rowhead>Âîïðîñ 2 <font color=red>*</font></td><td align=left><input name=option1 size=80 maxlength=40 value="<?=$poll['option1']?>"><br /></td></tr>
<tr><td class=rowhead>Âîïðîñ 3</td><td align=left><input name=option2 size=80 maxlength=40 value="<?=$poll['option2']?>"><br /></td></tr>
<tr><td class=rowhead>Âîïðîñ 4</td><td align=left><input name=option3 size=80 maxlength=40 value="<?=$poll['option3']?>"><br /></td></tr>
<tr><td class=rowhead>Âîïðîñ 5</td><td align=left><input name=option4 size=80 maxlength=40 value="<?=$poll['option4']?>"><br /></td></tr>
<tr><td class=rowhead>Âîïðîñ 6</td><td align=left><input name=option5 size=80 maxlength=40 value="<?=$poll['option5']?>"><br /></td></tr>
<tr><td class=rowhead>Âîïðîñ 7</td><td align=left><input name=option6 size=80 maxlength=40 value="<?=$poll['option6']?>"><br /></td></tr>
<tr><td class=rowhead>Âîïðîñ 8</td><td align=left><input name=option7 size=80 maxlength=40 value="<?=$poll['option7']?>"><br /></td></tr>
<tr><td class=rowhead>Âîïðîñ 9</td><td align=left><input name=option8 size=80 maxlength=40 value="<?=$poll['option8']?>"><br /></td></tr>
<tr><td class=rowhead>Âîïðîñ 10</td><td align=left><input name=option9 size=80 maxlength=40 value="<?=$poll['option9']?>"><br /></td></tr>
<tr><td class=rowhead>Âîïðîñ 11</td><td align=left><input name=option10 size=80 maxlength=40 value="<?=$poll['option10']?>"><br /></td></tr>
<tr><td class=rowhead>Âîïðîñ 12</td><td align=left><input name=option11 size=80 maxlength=40 value="<?=$poll['option11']?>"><br /></td></tr>
<tr><td class=rowhead>Âîïðîñ 13</td><td align=left><input name=option12 size=80 maxlength=40 value="<?=$poll['option12']?>"><br /></td></tr>
<tr><td class=rowhead>Âîïðîñ 14</td><td align=left><input name=option13 size=80 maxlength=40 value="<?=$poll['option13']?>"><br /></td></tr>
<tr><td class=rowhead>Âîïðîñ 15</td><td align=left><input name=option14 size=80 maxlength=40 value="<?=$poll['option14']?>"><br /></td></tr>
<tr><td class=rowhead>Âîïðîñ 16</td><td align=left><input name=option15 size=80 maxlength=40 value="<?=$poll['option15']?>"><br /></td></tr>
<tr><td class=rowhead>Âîïðîñ 17</td><td align=left><input name=option16 size=80 maxlength=40 value="<?=$poll['option16']?>"><br /></td></tr>
<tr><td class=rowhead>Âîïðîñ 18</td><td align=left><input name=option17 size=80 maxlength=40 value="<?=$poll['option17']?>"><br /></td></tr>
<tr><td class=rowhead>Âîïðîñ 19</td><td align=left><input name=option18 size=80 maxlength=40 value="<?=$poll['option18']?>"><br /></td></tr>
<tr><td class=rowhead>Âîïðîñ 20</td><td align=left><input name=option19 size=80 maxlength=40 value="<?=$poll['option19']?>"><br /></td></tr>
<tr><td class=rowhead>Ñîðòèðîâàòü</td><td>
<input type=radio name=sort value=yes <?=$poll["sort"] != "no" ? " checked" : "" ?>>Äà
<input type=radio name=sort value=no <?=$poll["sort"] == "no" ? " checked" : "" ?>> Íåò
</td></tr>
<tr><td colspan=2 align=center><input type=submit value=<?=$pollid?"'Ðåäàêòèðîâàòü'":"'Ñîçäàòü'"?> style='height: 20pt'></td></tr>
</table>
<p><font color=red>*</font> îáÿçàòåëüíî</p>
<input type=hidden name=pollid value=<?=$poll["id"]?>>
<input type=hidden name=action value=<?=$pollid?'edit':'create'?>
<input type=hidden name=returnto value=<?=htmlspecialchars_uni($_GET["returnto"]);?>>
</form>
<? stdfoot(); ?>