130 |
kaklik |
1 |
<?php |
|
|
2 |
/*************************************************************************** |
|
|
3 |
* admin_smilies.php |
|
|
4 |
* ------------------- |
|
|
5 |
* begin : Thu May 31, 2001 |
|
|
6 |
* copyright : (C) 2001 The phpBB Group |
|
|
7 |
* email : support@phpbb.com |
|
|
8 |
* |
|
|
9 |
* $Id: admin_smilies.php,v 1.22.2.18 2006/04/13 09:56:48 grahamje Exp $ |
|
|
10 |
* |
|
|
11 |
****************************************************************************/ |
|
|
12 |
|
|
|
13 |
/*************************************************************************** |
|
|
14 |
* |
|
|
15 |
* This program is free software; you can redistribute it and/or modify |
|
|
16 |
* it under the terms of the GNU General Public License as published by |
|
|
17 |
* the Free Software Foundation; either version 2 of the License, or |
|
|
18 |
* (at your option) any later version. |
|
|
19 |
* |
|
|
20 |
***************************************************************************/ |
|
|
21 |
|
|
|
22 |
/************************************************************************** |
|
|
23 |
* This file will be used for modifying the smiley settings for a board. |
|
|
24 |
**************************************************************************/ |
|
|
25 |
|
|
|
26 |
define('IN_PHPBB', 1); |
|
|
27 |
|
|
|
28 |
// |
|
|
29 |
// First we do the setmodules stuff for the admin cp. |
|
|
30 |
// |
|
|
31 |
if( !empty($setmodules) ) |
|
|
32 |
{ |
|
|
33 |
$filename = basename(__FILE__); |
|
|
34 |
$module['General']['Smilies'] = $filename; |
|
|
35 |
|
|
|
36 |
return; |
|
|
37 |
} |
|
|
38 |
|
|
|
39 |
// |
|
|
40 |
// Load default header |
|
|
41 |
// |
|
|
42 |
if( isset($HTTP_GET_VARS['export_pack']) ) |
|
|
43 |
{ |
|
|
44 |
if ( $HTTP_GET_VARS['export_pack'] == "send" ) |
|
|
45 |
{ |
|
|
46 |
$no_page_header = true; |
|
|
47 |
} |
|
|
48 |
} |
|
|
49 |
|
|
|
50 |
$phpbb_root_path = "./../"; |
|
|
51 |
require($phpbb_root_path . 'extension.inc'); |
|
|
52 |
|
|
|
53 |
$cancel = ( isset($HTTP_POST_VARS['cancel']) ) ? true : false; |
|
|
54 |
$no_page_header = $cancel; |
|
|
55 |
|
|
|
56 |
require('./pagestart.' . $phpEx); |
|
|
57 |
|
|
|
58 |
if ($cancel) |
|
|
59 |
{ |
|
|
60 |
redirect('admin/' . append_sid("admin_smilies.$phpEx", true)); |
|
|
61 |
} |
|
|
62 |
|
|
|
63 |
// |
|
|
64 |
// Check to see what mode we should operate in. |
|
|
65 |
// |
|
|
66 |
if( isset($HTTP_POST_VARS['mode']) || isset($HTTP_GET_VARS['mode']) ) |
|
|
67 |
{ |
|
|
68 |
$mode = ( isset($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode']; |
|
|
69 |
$mode = htmlspecialchars($mode); |
|
|
70 |
} |
|
|
71 |
else |
|
|
72 |
{ |
|
|
73 |
$mode = ""; |
|
|
74 |
} |
|
|
75 |
|
|
|
76 |
$delimeter = '=+:'; |
|
|
77 |
|
|
|
78 |
// |
|
|
79 |
// Read a listing of uploaded smilies for use in the add or edit smliey code... |
|
|
80 |
// |
|
|
81 |
$dir = @opendir($phpbb_root_path . $board_config['smilies_path']); |
|
|
82 |
|
|
|
83 |
while($file = @readdir($dir)) |
|
|
84 |
{ |
|
|
85 |
if( !@is_dir(phpbb_realpath($phpbb_root_path . $board_config['smilies_path'] . '/' . $file)) ) |
|
|
86 |
{ |
|
|
87 |
$img_size = @getimagesize($phpbb_root_path . $board_config['smilies_path'] . '/' . $file); |
|
|
88 |
|
|
|
89 |
if( $img_size[0] && $img_size[1] ) |
|
|
90 |
{ |
|
|
91 |
$smiley_images[] = $file; |
|
|
92 |
} |
|
|
93 |
else if( eregi('.pak$', $file) ) |
|
|
94 |
{ |
|
|
95 |
$smiley_paks[] = $file; |
|
|
96 |
} |
|
|
97 |
} |
|
|
98 |
} |
|
|
99 |
|
|
|
100 |
@closedir($dir); |
|
|
101 |
|
|
|
102 |
// |
|
|
103 |
// Select main mode |
|
|
104 |
// |
|
|
105 |
if( isset($HTTP_GET_VARS['import_pack']) || isset($HTTP_POST_VARS['import_pack']) ) |
|
|
106 |
{ |
|
|
107 |
// |
|
|
108 |
// Import a list a "Smiley Pack" |
|
|
109 |
// |
|
|
110 |
$smile_pak = ( isset($HTTP_POST_VARS['smile_pak']) ) ? $HTTP_POST_VARS['smile_pak'] : $HTTP_GET_VARS['smile_pak']; |
|
|
111 |
$clear_current = ( isset($HTTP_POST_VARS['clear_current']) ) ? $HTTP_POST_VARS['clear_current'] : $HTTP_GET_VARS['clear_current']; |
|
|
112 |
$replace_existing = ( isset($HTTP_POST_VARS['replace']) ) ? $HTTP_POST_VARS['replace'] : $HTTP_GET_VARS['replace']; |
|
|
113 |
|
|
|
114 |
if ( !empty($smile_pak) ) |
|
|
115 |
{ |
|
|
116 |
// |
|
|
117 |
// The user has already selected a smile_pak file.. Import it. |
|
|
118 |
// |
|
|
119 |
if( !empty($clear_current) ) |
|
|
120 |
{ |
|
|
121 |
$sql = "DELETE |
|
|
122 |
FROM " . SMILIES_TABLE; |
|
|
123 |
if( !$result = $db->sql_query($sql) ) |
|
|
124 |
{ |
|
|
125 |
message_die(GENERAL_ERROR, "Couldn't delete current smilies", "", __LINE__, __FILE__, $sql); |
|
|
126 |
} |
|
|
127 |
} |
|
|
128 |
else |
|
|
129 |
{ |
|
|
130 |
$sql = "SELECT code |
|
|
131 |
FROM ". SMILIES_TABLE; |
|
|
132 |
if( !$result = $db->sql_query($sql) ) |
|
|
133 |
{ |
|
|
134 |
message_die(GENERAL_ERROR, "Couldn't get current smilies", "", __LINE__, __FILE__, $sql); |
|
|
135 |
} |
|
|
136 |
|
|
|
137 |
$cur_smilies = $db->sql_fetchrowset($result); |
|
|
138 |
|
|
|
139 |
for( $i = 0; $i < count($cur_smilies); $i++ ) |
|
|
140 |
{ |
|
|
141 |
$k = $cur_smilies[$i]['code']; |
|
|
142 |
$smiles[$k] = 1; |
|
|
143 |
} |
|
|
144 |
} |
|
|
145 |
|
|
|
146 |
$fcontents = @file($phpbb_root_path . $board_config['smilies_path'] . '/'. $smile_pak); |
|
|
147 |
|
|
|
148 |
if( empty($fcontents) ) |
|
|
149 |
{ |
|
|
150 |
message_die(GENERAL_ERROR, "Couldn't read smiley pak file", "", __LINE__, __FILE__, $sql); |
|
|
151 |
} |
|
|
152 |
|
|
|
153 |
for( $i = 0; $i < count($fcontents); $i++ ) |
|
|
154 |
{ |
|
|
155 |
$smile_data = explode($delimeter, trim(addslashes($fcontents[$i]))); |
|
|
156 |
|
|
|
157 |
for( $j = 2; $j < count($smile_data); $j++) |
|
|
158 |
{ |
|
|
159 |
// |
|
|
160 |
// Replace > and < with the proper html_entities for matching. |
|
|
161 |
// |
|
|
162 |
$smile_data[$j] = str_replace("<", "<", $smile_data[$j]); |
|
|
163 |
$smile_data[$j] = str_replace(">", ">", $smile_data[$j]); |
|
|
164 |
$k = $smile_data[$j]; |
|
|
165 |
|
|
|
166 |
if( $smiles[$k] == 1 ) |
|
|
167 |
{ |
|
|
168 |
if( !empty($replace_existing) ) |
|
|
169 |
{ |
|
|
170 |
$sql = "UPDATE " . SMILIES_TABLE . " |
|
|
171 |
SET smile_url = '" . str_replace("\'", "''", $smile_data[0]) . "', emoticon = '" . str_replace("\'", "''", $smile_data[1]) . "' |
|
|
172 |
WHERE code = '" . str_replace("\'", "''", $smile_data[$j]) . "'"; |
|
|
173 |
} |
|
|
174 |
else |
|
|
175 |
{ |
|
|
176 |
$sql = ''; |
|
|
177 |
} |
|
|
178 |
} |
|
|
179 |
else |
|
|
180 |
{ |
|
|
181 |
$sql = "INSERT INTO " . SMILIES_TABLE . " (code, smile_url, emoticon) |
|
|
182 |
VALUES('" . str_replace("\'", "''", $smile_data[$j]) . "', '" . str_replace("\'", "''", $smile_data[0]) . "', '" . str_replace("\'", "''", $smile_data[1]) . "')"; |
|
|
183 |
} |
|
|
184 |
|
|
|
185 |
if( $sql != '' ) |
|
|
186 |
{ |
|
|
187 |
$result = $db->sql_query($sql); |
|
|
188 |
if( !$result ) |
|
|
189 |
{ |
|
|
190 |
message_die(GENERAL_ERROR, "Couldn't update smilies!", "", __LINE__, __FILE__, $sql); |
|
|
191 |
} |
|
|
192 |
} |
|
|
193 |
} |
|
|
194 |
} |
|
|
195 |
|
|
|
196 |
$message = $lang['smiley_import_success'] . "<br /><br />" . sprintf($lang['Click_return_smileadmin'], "<a href=\"" . append_sid("admin_smilies.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); |
|
|
197 |
|
|
|
198 |
message_die(GENERAL_MESSAGE, $message); |
|
|
199 |
|
|
|
200 |
} |
|
|
201 |
else |
|
|
202 |
{ |
|
|
203 |
// |
|
|
204 |
// Display the script to get the smile_pak cfg file... |
|
|
205 |
// |
|
|
206 |
$smile_paks_select = "<select name='smile_pak'><option value=''>" . $lang['Select_pak'] . "</option>"; |
|
|
207 |
while( list($key, $value) = @each($smiley_paks) ) |
|
|
208 |
{ |
|
|
209 |
if ( !empty($value) ) |
|
|
210 |
{ |
|
|
211 |
$smile_paks_select .= "<option>" . $value . "</option>"; |
|
|
212 |
} |
|
|
213 |
} |
|
|
214 |
$smile_paks_select .= "</select>"; |
|
|
215 |
|
|
|
216 |
$hidden_vars = "<input type='hidden' name='mode' value='import'>"; |
|
|
217 |
|
|
|
218 |
$template->set_filenames(array( |
|
|
219 |
"body" => "admin/smile_import_body.tpl") |
|
|
220 |
); |
|
|
221 |
|
|
|
222 |
$template->assign_vars(array( |
|
|
223 |
"L_SMILEY_TITLE" => $lang['smiley_title'], |
|
|
224 |
"L_SMILEY_EXPLAIN" => $lang['smiley_import_inst'], |
|
|
225 |
"L_SMILEY_IMPORT" => $lang['smiley_import'], |
|
|
226 |
"L_SELECT_LBL" => $lang['choose_smile_pak'], |
|
|
227 |
"L_IMPORT" => $lang['import'], |
|
|
228 |
"L_CONFLICTS" => $lang['smile_conflicts'], |
|
|
229 |
"L_DEL_EXISTING" => $lang['del_existing_smileys'], |
|
|
230 |
"L_REPLACE_EXISTING" => $lang['replace_existing'], |
|
|
231 |
"L_KEEP_EXISTING" => $lang['keep_existing'], |
|
|
232 |
|
|
|
233 |
"S_SMILEY_ACTION" => append_sid("admin_smilies.$phpEx"), |
|
|
234 |
"S_SMILE_SELECT" => $smile_paks_select, |
|
|
235 |
"S_HIDDEN_FIELDS" => $hidden_vars) |
|
|
236 |
); |
|
|
237 |
|
|
|
238 |
$template->pparse("body"); |
|
|
239 |
} |
|
|
240 |
} |
|
|
241 |
else if( isset($HTTP_POST_VARS['export_pack']) || isset($HTTP_GET_VARS['export_pack']) ) |
|
|
242 |
{ |
|
|
243 |
// |
|
|
244 |
// Export our smiley config as a smiley pak... |
|
|
245 |
// |
|
|
246 |
if ( $HTTP_GET_VARS['export_pack'] == "send" ) |
|
|
247 |
{ |
|
|
248 |
$sql = "SELECT * |
|
|
249 |
FROM " . SMILIES_TABLE; |
|
|
250 |
if( !$result = $db->sql_query($sql) ) |
|
|
251 |
{ |
|
|
252 |
message_die(GENERAL_ERROR, "Could not get smiley list", "", __LINE__, __FILE__, $sql); |
|
|
253 |
} |
|
|
254 |
|
|
|
255 |
$resultset = $db->sql_fetchrowset($result); |
|
|
256 |
|
|
|
257 |
$smile_pak = ""; |
|
|
258 |
for($i = 0; $i < count($resultset); $i++ ) |
|
|
259 |
{ |
|
|
260 |
$smile_pak .= $resultset[$i]['smile_url'] . $delimeter; |
|
|
261 |
$smile_pak .= $resultset[$i]['emoticon'] . $delimeter; |
|
|
262 |
$smile_pak .= $resultset[$i]['code'] . "\n"; |
|
|
263 |
} |
|
|
264 |
|
|
|
265 |
header("Content-Type: text/x-delimtext; name=\"smiles.pak\""); |
|
|
266 |
header("Content-disposition: attachment; filename=smiles.pak"); |
|
|
267 |
|
|
|
268 |
echo $smile_pak; |
|
|
269 |
|
|
|
270 |
exit; |
|
|
271 |
} |
|
|
272 |
|
|
|
273 |
$message = sprintf($lang['export_smiles'], "<a href=\"" . append_sid("admin_smilies.$phpEx?export_pack=send", true) . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_smileadmin'], "<a href=\"" . append_sid("admin_smilies.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); |
|
|
274 |
|
|
|
275 |
message_die(GENERAL_MESSAGE, $message); |
|
|
276 |
|
|
|
277 |
} |
|
|
278 |
else if( isset($HTTP_POST_VARS['add']) || isset($HTTP_GET_VARS['add']) ) |
|
|
279 |
{ |
|
|
280 |
// |
|
|
281 |
// Admin has selected to add a smiley. |
|
|
282 |
// |
|
|
283 |
|
|
|
284 |
$template->set_filenames(array( |
|
|
285 |
"body" => "admin/smile_edit_body.tpl") |
|
|
286 |
); |
|
|
287 |
|
|
|
288 |
$filename_list = ""; |
|
|
289 |
for( $i = 0; $i < count($smiley_images); $i++ ) |
|
|
290 |
{ |
|
|
291 |
$filename_list .= '<option value="' . $smiley_images[$i] . '">' . $smiley_images[$i] . '</option>'; |
|
|
292 |
} |
|
|
293 |
|
|
|
294 |
$s_hidden_fields = '<input type="hidden" name="mode" value="savenew" />'; |
|
|
295 |
|
|
|
296 |
$template->assign_vars(array( |
|
|
297 |
"L_SMILEY_TITLE" => $lang['smiley_title'], |
|
|
298 |
"L_SMILEY_CONFIG" => $lang['smiley_config'], |
|
|
299 |
"L_SMILEY_EXPLAIN" => $lang['smile_desc'], |
|
|
300 |
"L_SMILEY_CODE" => $lang['smiley_code'], |
|
|
301 |
"L_SMILEY_URL" => $lang['smiley_url'], |
|
|
302 |
"L_SMILEY_EMOTION" => $lang['smiley_emot'], |
|
|
303 |
"L_SUBMIT" => $lang['Submit'], |
|
|
304 |
"L_RESET" => $lang['Reset'], |
|
|
305 |
|
|
|
306 |
"SMILEY_IMG" => $phpbb_root_path . $board_config['smilies_path'] . '/' . $smiley_images[0], |
|
|
307 |
|
|
|
308 |
"S_SMILEY_ACTION" => append_sid("admin_smilies.$phpEx"), |
|
|
309 |
"S_HIDDEN_FIELDS" => $s_hidden_fields, |
|
|
310 |
"S_FILENAME_OPTIONS" => $filename_list, |
|
|
311 |
"S_SMILEY_BASEDIR" => $phpbb_root_path . $board_config['smilies_path']) |
|
|
312 |
); |
|
|
313 |
|
|
|
314 |
$template->pparse("body"); |
|
|
315 |
} |
|
|
316 |
else if ( $mode != "" ) |
|
|
317 |
{ |
|
|
318 |
switch( $mode ) |
|
|
319 |
{ |
|
|
320 |
case 'delete': |
|
|
321 |
// |
|
|
322 |
// Admin has selected to delete a smiley. |
|
|
323 |
// |
|
|
324 |
|
|
|
325 |
$smiley_id = ( !empty($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : $HTTP_GET_VARS['id']; |
|
|
326 |
$smiley_id = intval($smiley_id); |
|
|
327 |
|
|
|
328 |
$confirm = isset($HTTP_POST_VARS['confirm']); |
|
|
329 |
|
|
|
330 |
if( $confirm ) |
|
|
331 |
{ |
|
|
332 |
$sql = "DELETE FROM " . SMILIES_TABLE . " |
|
|
333 |
WHERE smilies_id = " . $smiley_id; |
|
|
334 |
$result = $db->sql_query($sql); |
|
|
335 |
if( !$result ) |
|
|
336 |
{ |
|
|
337 |
message_die(GENERAL_ERROR, "Couldn't delete smiley", "", __LINE__, __FILE__, $sql); |
|
|
338 |
} |
|
|
339 |
|
|
|
340 |
$message = $lang['smiley_del_success'] . "<br /><br />" . sprintf($lang['Click_return_smileadmin'], "<a href=\"" . append_sid("admin_smilies.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); |
|
|
341 |
|
|
|
342 |
message_die(GENERAL_MESSAGE, $message); |
|
|
343 |
} |
|
|
344 |
else |
|
|
345 |
{ |
|
|
346 |
// Present the confirmation screen to the user |
|
|
347 |
$template->set_filenames(array( |
|
|
348 |
'body' => 'admin/confirm_body.tpl') |
|
|
349 |
); |
|
|
350 |
|
|
|
351 |
$hidden_fields = '<input type="hidden" name="mode" value="delete" /><input type="hidden" name="id" value="' . $smiley_id . '" />'; |
|
|
352 |
|
|
|
353 |
$template->assign_vars(array( |
|
|
354 |
'MESSAGE_TITLE' => $lang['Confirm'], |
|
|
355 |
'MESSAGE_TEXT' => $lang['Confirm_delete_smiley'], |
|
|
356 |
|
|
|
357 |
'L_YES' => $lang['Yes'], |
|
|
358 |
'L_NO' => $lang['No'], |
|
|
359 |
|
|
|
360 |
'S_CONFIRM_ACTION' => append_sid("admin_smilies.$phpEx"), |
|
|
361 |
'S_HIDDEN_FIELDS' => $hidden_fields) |
|
|
362 |
); |
|
|
363 |
$template->pparse('body'); |
|
|
364 |
} |
|
|
365 |
break; |
|
|
366 |
|
|
|
367 |
case 'edit': |
|
|
368 |
// |
|
|
369 |
// Admin has selected to edit a smiley. |
|
|
370 |
// |
|
|
371 |
|
|
|
372 |
$smiley_id = ( !empty($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : $HTTP_GET_VARS['id']; |
|
|
373 |
$smiley_id = intval($smiley_id); |
|
|
374 |
|
|
|
375 |
$sql = "SELECT * |
|
|
376 |
FROM " . SMILIES_TABLE . " |
|
|
377 |
WHERE smilies_id = " . $smiley_id; |
|
|
378 |
$result = $db->sql_query($sql); |
|
|
379 |
if( !$result ) |
|
|
380 |
{ |
|
|
381 |
message_die(GENERAL_ERROR, 'Could not obtain emoticon information', "", __LINE__, __FILE__, $sql); |
|
|
382 |
} |
|
|
383 |
$smile_data = $db->sql_fetchrow($result); |
|
|
384 |
|
|
|
385 |
$filename_list = ""; |
|
|
386 |
for( $i = 0; $i < count($smiley_images); $i++ ) |
|
|
387 |
{ |
|
|
388 |
if( $smiley_images[$i] == $smile_data['smile_url'] ) |
|
|
389 |
{ |
|
|
390 |
$smiley_selected = "selected=\"selected\""; |
|
|
391 |
$smiley_edit_img = $smiley_images[$i]; |
|
|
392 |
} |
|
|
393 |
else |
|
|
394 |
{ |
|
|
395 |
$smiley_selected = ""; |
|
|
396 |
} |
|
|
397 |
|
|
|
398 |
$filename_list .= '<option value="' . $smiley_images[$i] . '"' . $smiley_selected . '>' . $smiley_images[$i] . '</option>'; |
|
|
399 |
} |
|
|
400 |
|
|
|
401 |
$template->set_filenames(array( |
|
|
402 |
"body" => "admin/smile_edit_body.tpl") |
|
|
403 |
); |
|
|
404 |
|
|
|
405 |
$s_hidden_fields = '<input type="hidden" name="mode" value="save" /><input type="hidden" name="smile_id" value="' . $smile_data['smilies_id'] . '" />'; |
|
|
406 |
|
|
|
407 |
$template->assign_vars(array( |
|
|
408 |
"SMILEY_CODE" => $smile_data['code'], |
|
|
409 |
"SMILEY_EMOTICON" => $smile_data['emoticon'], |
|
|
410 |
|
|
|
411 |
"L_SMILEY_TITLE" => $lang['smiley_title'], |
|
|
412 |
"L_SMILEY_CONFIG" => $lang['smiley_config'], |
|
|
413 |
"L_SMILEY_EXPLAIN" => $lang['smile_desc'], |
|
|
414 |
"L_SMILEY_CODE" => $lang['smiley_code'], |
|
|
415 |
"L_SMILEY_URL" => $lang['smiley_url'], |
|
|
416 |
"L_SMILEY_EMOTION" => $lang['smiley_emot'], |
|
|
417 |
"L_SUBMIT" => $lang['Submit'], |
|
|
418 |
"L_RESET" => $lang['Reset'], |
|
|
419 |
|
|
|
420 |
"SMILEY_IMG" => $phpbb_root_path . $board_config['smilies_path'] . '/' . $smiley_edit_img, |
|
|
421 |
|
|
|
422 |
"S_SMILEY_ACTION" => append_sid("admin_smilies.$phpEx"), |
|
|
423 |
"S_HIDDEN_FIELDS" => $s_hidden_fields, |
|
|
424 |
"S_FILENAME_OPTIONS" => $filename_list, |
|
|
425 |
"S_SMILEY_BASEDIR" => $phpbb_root_path . $board_config['smilies_path']) |
|
|
426 |
); |
|
|
427 |
|
|
|
428 |
$template->pparse("body"); |
|
|
429 |
break; |
|
|
430 |
|
|
|
431 |
case "save": |
|
|
432 |
// |
|
|
433 |
// Admin has submitted changes while editing a smiley. |
|
|
434 |
// |
|
|
435 |
|
|
|
436 |
// |
|
|
437 |
// Get the submitted data, being careful to ensure that we only |
|
|
438 |
// accept the data we are looking for. |
|
|
439 |
// |
|
|
440 |
$smile_code = ( isset($HTTP_POST_VARS['smile_code']) ) ? trim($HTTP_POST_VARS['smile_code']) : ''; |
|
|
441 |
$smile_url = ( isset($HTTP_POST_VARS['smile_url']) ) ? trim($HTTP_POST_VARS['smile_url']) : ''; |
|
|
442 |
$smile_url = phpbb_ltrim(basename($smile_url), "'"); |
|
|
443 |
$smile_emotion = ( isset($HTTP_POST_VARS['smile_emotion']) ) ? htmlspecialchars(trim($HTTP_POST_VARS['smile_emotion'])) : ''; |
|
|
444 |
$smile_id = ( isset($HTTP_POST_VARS['smile_id']) ) ? intval($HTTP_POST_VARS['smile_id']) : 0; |
|
|
445 |
$smile_code = trim($smile_code); |
|
|
446 |
$smile_url = trim($smile_url); |
|
|
447 |
|
|
|
448 |
// If no code was entered complain ... |
|
|
449 |
if ($smile_code == '' || $smile_url == '') |
|
|
450 |
{ |
|
|
451 |
message_die(GENERAL_MESSAGE, $lang['Fields_empty']); |
|
|
452 |
} |
|
|
453 |
|
|
|
454 |
// |
|
|
455 |
// Convert < and > to proper htmlentities for parsing. |
|
|
456 |
// |
|
|
457 |
$smile_code = str_replace('<', '<', $smile_code); |
|
|
458 |
$smile_code = str_replace('>', '>', $smile_code); |
|
|
459 |
|
|
|
460 |
// |
|
|
461 |
// Proceed with updating the smiley table. |
|
|
462 |
// |
|
|
463 |
$sql = "UPDATE " . SMILIES_TABLE . " |
|
|
464 |
SET code = '" . str_replace("\'", "''", $smile_code) . "', smile_url = '" . str_replace("\'", "''", $smile_url) . "', emoticon = '" . str_replace("\'", "''", $smile_emotion) . "' |
|
|
465 |
WHERE smilies_id = $smile_id"; |
|
|
466 |
if( !($result = $db->sql_query($sql)) ) |
|
|
467 |
{ |
|
|
468 |
message_die(GENERAL_ERROR, "Couldn't update smilies info", "", __LINE__, __FILE__, $sql); |
|
|
469 |
} |
|
|
470 |
|
|
|
471 |
$message = $lang['smiley_edit_success'] . "<br /><br />" . sprintf($lang['Click_return_smileadmin'], "<a href=\"" . append_sid("admin_smilies.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); |
|
|
472 |
|
|
|
473 |
message_die(GENERAL_MESSAGE, $message); |
|
|
474 |
break; |
|
|
475 |
|
|
|
476 |
case "savenew": |
|
|
477 |
// |
|
|
478 |
// Admin has submitted changes while adding a new smiley. |
|
|
479 |
// |
|
|
480 |
|
|
|
481 |
// |
|
|
482 |
// Get the submitted data being careful to ensure the the data |
|
|
483 |
// we recieve and process is only the data we are looking for. |
|
|
484 |
// |
|
|
485 |
$smile_code = ( isset($HTTP_POST_VARS['smile_code']) ) ? $HTTP_POST_VARS['smile_code'] : ''; |
|
|
486 |
$smile_url = ( isset($HTTP_POST_VARS['smile_url']) ) ? $HTTP_POST_VARS['smile_url'] : ''; |
|
|
487 |
$smile_url = phpbb_ltrim(basename($smile_url), "'"); |
|
|
488 |
$smile_emotion = ( isset($HTTP_POST_VARS['smile_emotion']) ) ? htmlspecialchars(trim($HTTP_POST_VARS['smile_emotion'])) : ''; |
|
|
489 |
$smile_code = trim($smile_code); |
|
|
490 |
$smile_url = trim($smile_url); |
|
|
491 |
|
|
|
492 |
// If no code was entered complain ... |
|
|
493 |
if ($smile_code == '' || $smile_url == '') |
|
|
494 |
{ |
|
|
495 |
message_die(GENERAL_MESSAGE, $lang['Fields_empty']); |
|
|
496 |
} |
|
|
497 |
|
|
|
498 |
// |
|
|
499 |
// Convert < and > to proper htmlentities for parsing. |
|
|
500 |
// |
|
|
501 |
$smile_code = str_replace('<', '<', $smile_code); |
|
|
502 |
$smile_code = str_replace('>', '>', $smile_code); |
|
|
503 |
|
|
|
504 |
// |
|
|
505 |
// Save the data to the smiley table. |
|
|
506 |
// |
|
|
507 |
$sql = "INSERT INTO " . SMILIES_TABLE . " (code, smile_url, emoticon) |
|
|
508 |
VALUES ('" . str_replace("\'", "''", $smile_code) . "', '" . str_replace("\'", "''", $smile_url) . "', '" . str_replace("\'", "''", $smile_emotion) . "')"; |
|
|
509 |
$result = $db->sql_query($sql); |
|
|
510 |
if( !$result ) |
|
|
511 |
{ |
|
|
512 |
message_die(GENERAL_ERROR, "Couldn't insert new smiley", "", __LINE__, __FILE__, $sql); |
|
|
513 |
} |
|
|
514 |
|
|
|
515 |
$message = $lang['smiley_add_success'] . "<br /><br />" . sprintf($lang['Click_return_smileadmin'], "<a href=\"" . append_sid("admin_smilies.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); |
|
|
516 |
|
|
|
517 |
message_die(GENERAL_MESSAGE, $message); |
|
|
518 |
break; |
|
|
519 |
} |
|
|
520 |
} |
|
|
521 |
else |
|
|
522 |
{ |
|
|
523 |
|
|
|
524 |
// |
|
|
525 |
// This is the main display of the page before the admin has selected |
|
|
526 |
// any options. |
|
|
527 |
// |
|
|
528 |
$sql = "SELECT * |
|
|
529 |
FROM " . SMILIES_TABLE; |
|
|
530 |
$result = $db->sql_query($sql); |
|
|
531 |
if( !$result ) |
|
|
532 |
{ |
|
|
533 |
message_die(GENERAL_ERROR, "Couldn't obtain smileys from database", "", __LINE__, __FILE__, $sql); |
|
|
534 |
} |
|
|
535 |
|
|
|
536 |
$smilies = $db->sql_fetchrowset($result); |
|
|
537 |
|
|
|
538 |
$template->set_filenames(array( |
|
|
539 |
"body" => "admin/smile_list_body.tpl") |
|
|
540 |
); |
|
|
541 |
|
|
|
542 |
$template->assign_vars(array( |
|
|
543 |
"L_ACTION" => $lang['Action'], |
|
|
544 |
"L_SMILEY_TITLE" => $lang['smiley_title'], |
|
|
545 |
"L_SMILEY_TEXT" => $lang['smile_desc'], |
|
|
546 |
"L_DELETE" => $lang['Delete'], |
|
|
547 |
"L_EDIT" => $lang['Edit'], |
|
|
548 |
"L_SMILEY_ADD" => $lang['smile_add'], |
|
|
549 |
"L_CODE" => $lang['Code'], |
|
|
550 |
"L_EMOT" => $lang['Emotion'], |
|
|
551 |
"L_SMILE" => $lang['Smile'], |
|
|
552 |
"L_IMPORT_PACK" => $lang['import_smile_pack'], |
|
|
553 |
"L_EXPORT_PACK" => $lang['export_smile_pack'], |
|
|
554 |
|
|
|
555 |
"S_HIDDEN_FIELDS" => $s_hidden_fields, |
|
|
556 |
"S_SMILEY_ACTION" => append_sid("admin_smilies.$phpEx")) |
|
|
557 |
); |
|
|
558 |
|
|
|
559 |
// |
|
|
560 |
// Loop throuh the rows of smilies setting block vars for the template. |
|
|
561 |
// |
|
|
562 |
for($i = 0; $i < count($smilies); $i++) |
|
|
563 |
{ |
|
|
564 |
// |
|
|
565 |
// Replace htmlentites for < and > with actual character. |
|
|
566 |
// |
|
|
567 |
$smilies[$i]['code'] = str_replace('<', '<', $smilies[$i]['code']); |
|
|
568 |
$smilies[$i]['code'] = str_replace('>', '>', $smilies[$i]['code']); |
|
|
569 |
|
|
|
570 |
$row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2']; |
|
|
571 |
$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; |
|
|
572 |
|
|
|
573 |
$template->assign_block_vars("smiles", array( |
|
|
574 |
"ROW_COLOR" => "#" . $row_color, |
|
|
575 |
"ROW_CLASS" => $row_class, |
|
|
576 |
|
|
|
577 |
"SMILEY_IMG" => $phpbb_root_path . $board_config['smilies_path'] . '/' . $smilies[$i]['smile_url'], |
|
|
578 |
"CODE" => $smilies[$i]['code'], |
|
|
579 |
"EMOT" => $smilies[$i]['emoticon'], |
|
|
580 |
|
|
|
581 |
"U_SMILEY_EDIT" => append_sid("admin_smilies.$phpEx?mode=edit&id=" . $smilies[$i]['smilies_id']), |
|
|
582 |
"U_SMILEY_DELETE" => append_sid("admin_smilies.$phpEx?mode=delete&id=" . $smilies[$i]['smilies_id'])) |
|
|
583 |
); |
|
|
584 |
} |
|
|
585 |
|
|
|
586 |
// |
|
|
587 |
// Spit out the page. |
|
|
588 |
// |
|
|
589 |
$template->pparse("body"); |
|
|
590 |
} |
|
|
591 |
|
|
|
592 |
// |
|
|
593 |
// Page Footer |
|
|
594 |
// |
|
|
595 |
include('./page_footer_admin.'.$phpEx); |
|
|
596 |
|
|
|
597 |
?> |