PageRenderTime 34ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/php/Sources/ManageSmileys.php

https://github.com/dekoza/openshift-smf-2.0.7
PHP | 1776 lines | 1424 code | 189 blank | 163 comment | 186 complexity | f6249aed6f39303267143f78802aa8f9 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines http://www.simplemachines.org
  7. * @copyright 2011 Simple Machines
  8. * @license http://www.simplemachines.org/about/smf/license.php BSD
  9. *
  10. * @version 2.0
  11. */
  12. if (!defined('SMF'))
  13. die('Hacking attempt...');
  14. /* // !!!
  15. void ManageSmileys()
  16. // !!!
  17. void EditSmileySettings()
  18. // !!!
  19. void EditSmileySets()
  20. // !!!
  21. void AddSmiley()
  22. // !!!
  23. void EditSmileys()
  24. // !!!
  25. void EditSmileyOrder()
  26. // !!!
  27. void InstallSmileySet()
  28. // !!!
  29. void ImportSmileys($smileyPath)
  30. // !!!
  31. void sortSmileyTable()
  32. // !!!
  33. */
  34. function ManageSmileys()
  35. {
  36. global $context, $txt, $scripturl, $modSettings;
  37. isAllowedTo('manage_smileys');
  38. loadLanguage('ManageSmileys');
  39. loadTemplate('ManageSmileys');
  40. $subActions = array(
  41. 'addsmiley' => 'AddSmiley',
  42. 'editicon' => 'EditMessageIcons',
  43. 'editicons' => 'EditMessageIcons',
  44. 'editsets' => 'EditSmileySets',
  45. 'editsmileys' => 'EditSmileys',
  46. 'import' => 'EditSmileySets',
  47. 'modifyset' => 'EditSmileySets',
  48. 'modifysmiley' => 'EditSmileys',
  49. 'setorder' => 'EditSmileyOrder',
  50. 'settings' => 'EditSmileySettings',
  51. 'install' => 'InstallSmileySet'
  52. );
  53. // Default the sub-action to 'edit smiley settings'.
  54. $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'editsets';
  55. $context['page_title'] = $txt['smileys_manage'];
  56. $context['sub_action'] = $_REQUEST['sa'];
  57. $context['sub_template'] = $context['sub_action'];
  58. // Load up all the tabs...
  59. $context[$context['admin_menu_name']]['tab_data'] = array(
  60. 'title' => $txt['smileys_manage'],
  61. 'help' => 'smileys',
  62. 'description' => $txt['smiley_settings_explain'],
  63. 'tabs' => array(
  64. 'editsets' => array(
  65. 'description' => $txt['smiley_editsets_explain'],
  66. ),
  67. 'addsmiley' => array(
  68. 'description' => $txt['smiley_addsmiley_explain'],
  69. ),
  70. 'editsmileys' => array(
  71. 'description' => $txt['smiley_editsmileys_explain'],
  72. ),
  73. 'setorder' => array(
  74. 'description' => $txt['smiley_setorder_explain'],
  75. ),
  76. 'editicons' => array(
  77. 'description' => $txt['icons_edit_icons_explain'],
  78. ),
  79. 'settings' => array(
  80. 'description' => $txt['smiley_settings_explain'],
  81. ),
  82. ),
  83. );
  84. // Some settings may not be enabled, disallow these from the tabs as appropriate.
  85. if (empty($modSettings['messageIcons_enable']))
  86. $context[$context['admin_menu_name']]['tab_data']['tabs']['editicons']['disabled'] = true;
  87. if (empty($modSettings['smiley_enable']))
  88. {
  89. $context[$context['admin_menu_name']]['tab_data']['tabs']['addsmiley']['disabled'] = true;
  90. $context[$context['admin_menu_name']]['tab_data']['tabs']['editsmileys']['disabled'] = true;
  91. $context[$context['admin_menu_name']]['tab_data']['tabs']['setorder']['disabled'] = true;
  92. }
  93. // Call the right function for this sub-acton.
  94. $subActions[$_REQUEST['sa']]();
  95. }
  96. function EditSmileySettings($return_config = false)
  97. {
  98. global $modSettings, $context, $settings, $txt, $boarddir, $sourcedir, $scripturl;
  99. // The directories...
  100. $context['smileys_dir'] = empty($modSettings['smileys_dir']) ? $boarddir . '/Smileys' : $modSettings['smileys_dir'];
  101. $context['smileys_dir_found'] = is_dir($context['smileys_dir']);
  102. // Get the names of the smiley sets.
  103. $smiley_sets = explode(',', $modSettings['smiley_sets_known']);
  104. $set_names = explode("\n", $modSettings['smiley_sets_names']);
  105. $smiley_context = array();
  106. foreach ($smiley_sets as $i => $set)
  107. $smiley_context[$set] = $set_names[$i];
  108. // All the settings for the page...
  109. $config_vars = array(
  110. array('title', 'settings'),
  111. // Inline permissions.
  112. array('permissions', 'manage_smileys'),
  113. '',
  114. array('select', 'smiley_sets_default', $smiley_context),
  115. array('check', 'smiley_sets_enable'),
  116. array('check', 'smiley_enable', 'subtext' => $txt['smileys_enable_note']),
  117. array('text', 'smileys_url'),
  118. array('text', 'smileys_dir', 'invalid' => !$context['smileys_dir_found']),
  119. '',
  120. // Message icons.
  121. array('check', 'messageIcons_enable', 'subtext' => $txt['setting_messageIcons_enable_note']),
  122. );
  123. if ($return_config)
  124. return $config_vars;
  125. // Setup the basics of the settings template.
  126. require_once($sourcedir . '/ManageServer.php');
  127. $context['sub_template'] = 'show_settings';
  128. // Finish up the form...
  129. $context['post_url'] = $scripturl . '?action=admin;area=smileys;save;sa=settings';
  130. $context['permissions_excluded'] = array(-1);
  131. // Saving the settings?
  132. if (isset($_GET['save']))
  133. {
  134. checkSession();
  135. // Validate the smiley set name.
  136. $_POST['smiley_sets_default'] = empty($smiley_context[$_POST['smiley_sets_default']]) ? 'default' : $_POST['smiley_sets_default'];
  137. // Make sure that the smileys are in the right order after enabling them.
  138. if (isset($_POST['smiley_enable']))
  139. sortSmileyTable();
  140. saveDBSettings($config_vars);
  141. cache_put_data('parsing_smileys', null, 480);
  142. cache_put_data('posting_smileys', null, 480);
  143. redirectexit('action=admin;area=smileys;sa=settings');
  144. }
  145. prepareDBSettingContext($config_vars);
  146. }
  147. function EditSmileySets()
  148. {
  149. global $modSettings, $context, $settings, $txt, $boarddir;
  150. global $smcFunc, $scripturl, $sourcedir;
  151. // Set the right tab to be selected.
  152. $context[$context['admin_menu_name']]['current_subsection'] = 'editsets';
  153. // They must've been submitted a form.
  154. if (isset($_POST[$context['session_var']]))
  155. {
  156. checkSession();
  157. // Delete selected smiley sets.
  158. if (!empty($_POST['delete']) && !empty($_POST['smiley_set']))
  159. {
  160. $set_paths = explode(',', $modSettings['smiley_sets_known']);
  161. $set_names = explode("\n", $modSettings['smiley_sets_names']);
  162. foreach ($_POST['smiley_set'] as $id => $val)
  163. if (isset($set_paths[$id], $set_names[$id]) && !empty($id))
  164. unset($set_paths[$id], $set_names[$id]);
  165. updateSettings(array(
  166. 'smiley_sets_known' => implode(',', $set_paths),
  167. 'smiley_sets_names' => implode("\n", $set_names),
  168. 'smiley_sets_default' => in_array($modSettings['smiley_sets_default'], $set_paths) ? $modSettings['smiley_sets_default'] : $set_paths[0],
  169. ));
  170. cache_put_data('parsing_smileys', null, 480);
  171. cache_put_data('posting_smileys', null, 480);
  172. }
  173. // Add a new smiley set.
  174. elseif (!empty($_POST['add']))
  175. $context['sub_action'] = 'modifyset';
  176. // Create or modify a smiley set.
  177. elseif (isset($_POST['set']))
  178. {
  179. $set_paths = explode(',', $modSettings['smiley_sets_known']);
  180. $set_names = explode("\n", $modSettings['smiley_sets_names']);
  181. // Create a new smiley set.
  182. if ($_POST['set'] == -1 && isset($_POST['smiley_sets_path']))
  183. {
  184. if (in_array($_POST['smiley_sets_path'], $set_paths))
  185. fatal_lang_error('smiley_set_already_exists');
  186. updateSettings(array(
  187. 'smiley_sets_known' => $modSettings['smiley_sets_known'] . ',' . $_POST['smiley_sets_path'],
  188. 'smiley_sets_names' => $modSettings['smiley_sets_names'] . "\n" . $_POST['smiley_sets_name'],
  189. 'smiley_sets_default' => empty($_POST['smiley_sets_default']) ? $modSettings['smiley_sets_default'] : $_POST['smiley_sets_path'],
  190. ));
  191. }
  192. // Modify an existing smiley set.
  193. else
  194. {
  195. // Make sure the smiley set exists.
  196. if (!isset($set_paths[$_POST['set']]) || !isset($set_names[$_POST['set']]))
  197. fatal_lang_error('smiley_set_not_found');
  198. // Make sure the path is not yet used by another smileyset.
  199. if (in_array($_POST['smiley_sets_path'], $set_paths) && $_POST['smiley_sets_path'] != $set_paths[$_POST['set']])
  200. fatal_lang_error('smiley_set_path_already_used');
  201. $set_paths[$_POST['set']] = $_POST['smiley_sets_path'];
  202. $set_names[$_POST['set']] = $_POST['smiley_sets_name'];
  203. updateSettings(array(
  204. 'smiley_sets_known' => implode(',', $set_paths),
  205. 'smiley_sets_names' => implode("\n", $set_names),
  206. 'smiley_sets_default' => empty($_POST['smiley_sets_default']) ? $modSettings['smiley_sets_default'] : $_POST['smiley_sets_path']
  207. ));
  208. }
  209. // The user might have checked to also import smileys.
  210. if (!empty($_POST['smiley_sets_import']))
  211. ImportSmileys($_POST['smiley_sets_path']);
  212. cache_put_data('parsing_smileys', null, 480);
  213. cache_put_data('posting_smileys', null, 480);
  214. }
  215. }
  216. // Load all available smileysets...
  217. $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']);
  218. $set_names = explode("\n", $modSettings['smiley_sets_names']);
  219. foreach ($context['smiley_sets'] as $i => $set)
  220. $context['smiley_sets'][$i] = array(
  221. 'id' => $i,
  222. 'path' => htmlspecialchars($set),
  223. 'name' => htmlspecialchars($set_names[$i]),
  224. 'selected' => $set == $modSettings['smiley_sets_default']
  225. );
  226. // Importing any smileys from an existing set?
  227. if ($context['sub_action'] == 'import')
  228. {
  229. checkSession('get');
  230. $_GET['set'] = (int) $_GET['set'];
  231. // Sanity check - then import.
  232. if (isset($context['smiley_sets'][$_GET['set']]))
  233. ImportSmileys(un_htmlspecialchars($context['smiley_sets'][$_GET['set']]['path']));
  234. // Force the process to continue.
  235. $context['sub_action'] = 'modifyset';
  236. $context['sub_template'] = 'modifyset';
  237. }
  238. // If we're modifying or adding a smileyset, some context info needs to be set.
  239. if ($context['sub_action'] == 'modifyset')
  240. {
  241. $_GET['set'] = !isset($_GET['set']) ? -1 : (int) $_GET['set'];
  242. if ($_GET['set'] == -1 || !isset($context['smiley_sets'][$_GET['set']]))
  243. $context['current_set'] = array(
  244. 'id' => '-1',
  245. 'path' => '',
  246. 'name' => '',
  247. 'selected' => false,
  248. 'is_new' => true,
  249. );
  250. else
  251. {
  252. $context['current_set'] = &$context['smiley_sets'][$_GET['set']];
  253. $context['current_set']['is_new'] = false;
  254. // Calculate whether there are any smileys in the directory that can be imported.
  255. if (!empty($modSettings['smiley_enable']) && !empty($modSettings['smileys_dir']) && is_dir($modSettings['smileys_dir'] . '/' . $context['current_set']['path']))
  256. {
  257. $smileys = array();
  258. $dir = dir($modSettings['smileys_dir'] . '/' . $context['current_set']['path']);
  259. while ($entry = $dir->read())
  260. {
  261. if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png')))
  262. $smileys[strtolower($entry)] = $entry;
  263. }
  264. $dir->close();
  265. // Exclude the smileys that are already in the database.
  266. $request = $smcFunc['db_query']('', '
  267. SELECT filename
  268. FROM {db_prefix}smileys
  269. WHERE filename IN ({array_string:smiley_list})',
  270. array(
  271. 'smiley_list' => $smileys,
  272. )
  273. );
  274. while ($row = $smcFunc['db_fetch_assoc']($request))
  275. if (isset($smileys[strtolower($row['filename'])]))
  276. unset($smileys[strtolower($row['filename'])]);
  277. $smcFunc['db_free_result']($request);
  278. $context['current_set']['can_import'] = count($smileys);
  279. // Setup this string to look nice.
  280. $txt['smiley_set_import_multiple'] = sprintf($txt['smiley_set_import_multiple'], $context['current_set']['can_import']);
  281. }
  282. }
  283. // Retrieve all potential smiley set directories.
  284. $context['smiley_set_dirs'] = array();
  285. if (!empty($modSettings['smileys_dir']) && is_dir($modSettings['smileys_dir']))
  286. {
  287. $dir = dir($modSettings['smileys_dir']);
  288. while ($entry = $dir->read())
  289. {
  290. if (!in_array($entry, array('.', '..')) && is_dir($modSettings['smileys_dir'] . '/' . $entry))
  291. $context['smiley_set_dirs'][] = array(
  292. 'id' => $entry,
  293. 'path' => $modSettings['smileys_dir'] . '/' . $entry,
  294. 'selectable' => $entry == $context['current_set']['path'] || !in_array($entry, explode(',', $modSettings['smiley_sets_known'])),
  295. 'current' => $entry == $context['current_set']['path'],
  296. );
  297. }
  298. $dir->close();
  299. }
  300. }
  301. $listOptions = array(
  302. 'id' => 'smiley_set_list',
  303. 'base_href' => $scripturl . '?action=admin;area=smileys;sa=editsets',
  304. 'default_sort_col' => 'default',
  305. 'get_items' => array(
  306. 'function' => 'list_getSmileySets',
  307. ),
  308. 'get_count' => array(
  309. 'function' => 'list_getNumSmileySets',
  310. ),
  311. 'columns' => array(
  312. 'default' => array(
  313. 'header' => array(
  314. 'value' => $txt['smiley_sets_default'],
  315. ),
  316. 'data' => array(
  317. 'function' => create_function('$rowData', '
  318. return $rowData[\'selected\'] ? \'<strong>*</strong>\' : \'\';
  319. '),
  320. 'style' => 'text-align: center;',
  321. ),
  322. 'sort' => array(
  323. 'default' => 'selected DESC',
  324. ),
  325. ),
  326. 'name' => array(
  327. 'header' => array(
  328. 'value' => $txt['smiley_sets_name'],
  329. ),
  330. 'data' => array(
  331. 'db_htmlsafe' => 'name',
  332. 'class' => 'windowbg',
  333. ),
  334. 'sort' => array(
  335. 'default' => 'name',
  336. 'reverse' => 'name DESC',
  337. ),
  338. ),
  339. 'url' => array(
  340. 'header' => array(
  341. 'value' => $txt['smiley_sets_url'],
  342. ),
  343. 'data' => array(
  344. 'sprintf' => array(
  345. 'format' => $modSettings['smileys_url'] . '/<strong>%1$s</strong>/...',
  346. 'params' => array(
  347. 'path' => true,
  348. ),
  349. ),
  350. 'class' => 'windowbg',
  351. ),
  352. 'sort' => array(
  353. 'default' => 'path',
  354. 'reverse' => 'path DESC',
  355. ),
  356. ),
  357. 'modify' => array(
  358. 'header' => array(
  359. 'value' => $txt['smiley_set_modify'],
  360. ),
  361. 'data' => array(
  362. 'sprintf' => array(
  363. 'format' => '<a href="' . $scripturl . '?action=admin;area=smileys;sa=modifyset;set=%1$d">' . $txt['smiley_set_modify'] . '</a>',
  364. 'params' => array(
  365. 'id' => true,
  366. ),
  367. ),
  368. 'style' => 'text-align: center;',
  369. ),
  370. ),
  371. 'check' => array(
  372. 'header' => array(
  373. 'value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />',
  374. ),
  375. 'data' => array(
  376. 'function' => create_function('$rowData', '
  377. return $rowData[\'id\'] == 0 ? \'\' : sprintf(\'<input type="checkbox" name="smiley_set[%1$d]" class="input_check" />\', $rowData[\'id\']);
  378. '),
  379. 'style' => 'text-align: center',
  380. ),
  381. ),
  382. ),
  383. 'form' => array(
  384. 'href' => $scripturl . '?action=admin;area=smileys;sa=editsets',
  385. ),
  386. 'additional_rows' => array(
  387. array(
  388. 'position' => 'below_table_data',
  389. 'value' => '<input type="submit" name="delete" value="' . $txt['smiley_sets_delete'] . '" onclick="return confirm(\'' . $txt['smiley_sets_confirm'] . '\');" style="float: right;" class="button_submit" /> [<a href="' . $scripturl . '?action=admin;area=smileys;sa=modifyset' . '">' . $txt['smiley_sets_add'] . '</a>]',
  390. ),
  391. ),
  392. );
  393. require_once($sourcedir . '/Subs-List.php');
  394. createList($listOptions);
  395. }
  396. // !!! to be moved to Subs-Smileys.
  397. function list_getSmileySets($start, $items_per_page, $sort)
  398. {
  399. global $modSettings;
  400. $known_sets = explode(',', $modSettings['smiley_sets_known']);
  401. $set_names = explode("\n", $modSettings['smiley_sets_names']);
  402. $cols = array(
  403. 'id' => array(),
  404. 'selected' => array(),
  405. 'path' => array(),
  406. 'name' => array(),
  407. );
  408. foreach ($known_sets as $i => $set)
  409. {
  410. $cols['id'][] = $i;
  411. $cols['selected'][] = $i;
  412. $cols['path'][] = $set;
  413. $cols['name'][] = $set_names[$i];
  414. }
  415. $sort_flag = strpos($sort, 'DESC') === false ? SORT_ASC : SORT_DESC;
  416. if (substr($sort, 0, 4) === 'name')
  417. array_multisort($cols['name'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['selected'], $cols['id']);
  418. elseif (substr($sort, 0, 4) === 'path')
  419. array_multisort($cols['path'], $sort_flag, SORT_REGULAR, $cols['name'], $cols['selected'], $cols['id']);
  420. else
  421. array_multisort($cols['selected'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['name'], $cols['id']);
  422. $smiley_sets = array();
  423. foreach ($cols['id'] as $i => $id)
  424. $smiley_sets[] = array(
  425. 'id' => $id,
  426. 'path' => $cols['path'][$i],
  427. 'name' => $cols['name'][$i],
  428. 'selected' => $cols['path'][$i] == $modSettings['smiley_sets_default']
  429. );
  430. return $smiley_sets;
  431. }
  432. // !!! to be moved to Subs-Smileys.
  433. function list_getNumSmileySets()
  434. {
  435. global $modSettings;
  436. return count(explode(',', $modSettings['smiley_sets_known']));
  437. }
  438. function AddSmiley()
  439. {
  440. global $modSettings, $context, $settings, $txt, $boarddir, $smcFunc;
  441. // Get a list of all known smiley sets.
  442. $context['smileys_dir'] = empty($modSettings['smileys_dir']) ? $boarddir . '/Smileys' : $modSettings['smileys_dir'];
  443. $context['smileys_dir_found'] = is_dir($context['smileys_dir']);
  444. $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']);
  445. $set_names = explode("\n", $modSettings['smiley_sets_names']);
  446. foreach ($context['smiley_sets'] as $i => $set)
  447. $context['smiley_sets'][$i] = array(
  448. 'id' => $i,
  449. 'path' => htmlspecialchars($set),
  450. 'name' => htmlspecialchars($set_names[$i]),
  451. 'selected' => $set == $modSettings['smiley_sets_default']
  452. );
  453. // Submitting a form?
  454. if (isset($_POST[$context['session_var']], $_POST['smiley_code']))
  455. {
  456. checkSession();
  457. // Some useful arrays... types we allow - and ports we don't!
  458. $allowedTypes = array('jpeg', 'jpg', 'gif', 'png', 'bmp');
  459. $disabledFiles = array('con', 'com1', 'com2', 'com3', 'com4', 'prn', 'aux', 'lpt1', '.htaccess', 'index.php');
  460. $_POST['smiley_code'] = htmltrim__recursive($_POST['smiley_code']);
  461. $_POST['smiley_location'] = empty($_POST['smiley_location']) || $_POST['smiley_location'] > 2 || $_POST['smiley_location'] < 0 ? 0 : (int) $_POST['smiley_location'];
  462. $_POST['smiley_filename'] = htmltrim__recursive($_POST['smiley_filename']);
  463. // Make sure some code was entered.
  464. if (empty($_POST['smiley_code']))
  465. fatal_lang_error('smiley_has_no_code');
  466. // Check whether the new code has duplicates. It should be unique.
  467. $request = $smcFunc['db_query']('', '
  468. SELECT id_smiley
  469. FROM {db_prefix}smileys
  470. WHERE code = {raw:mysql_binary_statement} {string:smiley_code}',
  471. array(
  472. 'mysql_binary_statement' => $smcFunc['db_title'] == 'MySQL' ? 'BINARY' : '',
  473. 'smiley_code' => $_POST['smiley_code'],
  474. )
  475. );
  476. if ($smcFunc['db_num_rows']($request) > 0)
  477. fatal_lang_error('smiley_not_unique');
  478. $smcFunc['db_free_result']($request);
  479. // If we are uploading - check all the smiley sets are writable!
  480. if ($_POST['method'] != 'existing')
  481. {
  482. $writeErrors = array();
  483. foreach ($context['smiley_sets'] as $set)
  484. {
  485. if (!is_writable($context['smileys_dir'] . '/' . un_htmlspecialchars($set['path'])))
  486. $writeErrors[] = $set['path'];
  487. }
  488. if (!empty($writeErrors))
  489. fatal_lang_error('smileys_upload_error_notwritable', true, array(implode(', ', $writeErrors)));
  490. }
  491. // Uploading just one smiley for all of them?
  492. if (isset($_POST['sameall']) && isset($_FILES['uploadSmiley']['name']) && $_FILES['uploadSmiley']['name'] != '')
  493. {
  494. if (!is_uploaded_file($_FILES['uploadSmiley']['tmp_name']) || (@ini_get('open_basedir') == '' && !file_exists($_FILES['uploadSmiley']['tmp_name'])))
  495. fatal_lang_error('smileys_upload_error');
  496. // Sorry, no spaces, dots, or anything else but letters allowed.
  497. $_FILES['uploadSmiley']['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['uploadSmiley']['name']);
  498. // We only allow image files - it's THAT simple - no messing around here...
  499. if (!in_array(strtolower(substr(strrchr($_FILES['uploadSmiley']['name'], '.'), 1)), $allowedTypes))
  500. fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes)));
  501. // We only need the filename...
  502. $destName = basename($_FILES['uploadSmiley']['name']);
  503. // Make sure they aren't trying to upload a nasty file - for their own good here!
  504. if (in_array(strtolower($destName), $disabledFiles))
  505. fatal_lang_error('smileys_upload_error_illegal');
  506. // Check if the file already exists... and if not move it to EVERY smiley set directory.
  507. $i = 0;
  508. // Keep going until we find a set the file doesn't exist in. (or maybe it exists in all of them?)
  509. while (isset($context['smiley_sets'][$i]) && file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName))
  510. $i++;
  511. // Okay, we're going to put the smiley right here, since it's not there yet!
  512. if (isset($context['smiley_sets'][$i]['path']))
  513. {
  514. $smileyLocation = $context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName;
  515. move_uploaded_file($_FILES['uploadSmiley']['tmp_name'], $smileyLocation);
  516. @chmod($smileyLocation, 0644);
  517. // Now, we want to move it from there to all the other sets.
  518. for ($n = count($context['smiley_sets']); $i < $n; $i++)
  519. {
  520. $currentPath = $context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName;
  521. // The file is already there! Don't overwrite it!
  522. if (file_exists($currentPath))
  523. continue;
  524. // Okay, so copy the first one we made to here.
  525. copy($smileyLocation, $currentPath);
  526. @chmod($currentPath, 0644);
  527. }
  528. }
  529. // Finally make sure it's saved correctly!
  530. $_POST['smiley_filename'] = $destName;
  531. }
  532. // What about uploading several files?
  533. elseif ($_POST['method'] != 'existing')
  534. {
  535. foreach ($_FILES as $name => $data)
  536. {
  537. if ($_FILES[$name]['name'] == '')
  538. fatal_lang_error('smileys_upload_error_blank');
  539. if (empty($newName))
  540. $newName = basename($_FILES[$name]['name']);
  541. elseif (basename($_FILES[$name]['name']) != $newName)
  542. fatal_lang_error('smileys_upload_error_name');
  543. }
  544. foreach ($context['smiley_sets'] as $i => $set)
  545. {
  546. $set['name'] = un_htmlspecialchars($set['name']);
  547. $set['path'] = un_htmlspecialchars($set['path']);
  548. if (!isset($_FILES['individual_' . $set['name']]['name']) || $_FILES['individual_' . $set['name']]['name'] == '')
  549. continue;
  550. // Got one...
  551. if (!is_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name']) || (@ini_get('open_basedir') == '' && !file_exists($_FILES['individual_' . $set['name']]['tmp_name'])))
  552. fatal_lang_error('smileys_upload_error');
  553. // Sorry, no spaces, dots, or anything else but letters allowed.
  554. $_FILES['individual_' . $set['name']]['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['individual_' . $set['name']]['name']);
  555. // We only allow image files - it's THAT simple - no messing around here...
  556. if (!in_array(strtolower(substr(strrchr($_FILES['individual_' . $set['name']]['name'], '.'), 1)), $allowedTypes))
  557. fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes)));
  558. // We only need the filename...
  559. $destName = basename($_FILES['individual_' . $set['name']]['name']);
  560. // Make sure they aren't trying to upload a nasty file - for their own good here!
  561. if (in_array(strtolower($destName), $disabledFiles))
  562. fatal_lang_error('smileys_upload_error_illegal');
  563. // If the file exists - ignore it.
  564. $smileyLocation = $context['smileys_dir'] . '/' . $set['path'] . '/' . $destName;
  565. if (file_exists($smileyLocation))
  566. continue;
  567. // Finally - move the image!
  568. move_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name'], $smileyLocation);
  569. @chmod($smileyLocation, 0644);
  570. // Should always be saved correctly!
  571. $_POST['smiley_filename'] = $destName;
  572. }
  573. }
  574. // Also make sure a filename was given.
  575. if (empty($_POST['smiley_filename']))
  576. fatal_lang_error('smiley_has_no_filename');
  577. // Find the position on the right.
  578. $smiley_order = '0';
  579. if ($_POST['smiley_location'] != 1)
  580. {
  581. $request = $smcFunc['db_query']('', '
  582. SELECT MAX(smiley_order) + 1
  583. FROM {db_prefix}smileys
  584. WHERE hidden = {int:smiley_location}
  585. AND smiley_row = {int:first_row}',
  586. array(
  587. 'smiley_location' => $_POST['smiley_location'],
  588. 'first_row' => 0,
  589. )
  590. );
  591. list ($smiley_order) = $smcFunc['db_fetch_row']($request);
  592. $smcFunc['db_free_result']($request);
  593. if (empty($smiley_order))
  594. $smiley_order = '0';
  595. }
  596. $smcFunc['db_insert']('',
  597. '{db_prefix}smileys',
  598. array(
  599. 'code' => 'string-30', 'filename' => 'string-48', 'description' => 'string-80', 'hidden' => 'int', 'smiley_order' => 'int',
  600. ),
  601. array(
  602. $_POST['smiley_code'], $_POST['smiley_filename'], $_POST['smiley_description'], $_POST['smiley_location'], $smiley_order,
  603. ),
  604. array('id_smiley')
  605. );
  606. cache_put_data('parsing_smileys', null, 480);
  607. cache_put_data('posting_smileys', null, 480);
  608. // No errors? Out of here!
  609. redirectexit('action=admin;area=smileys;sa=editsmileys');
  610. }
  611. $context['selected_set'] = $modSettings['smiley_sets_default'];
  612. // Get all possible filenames for the smileys.
  613. $context['filenames'] = array();
  614. if ($context['smileys_dir_found'])
  615. {
  616. foreach ($context['smiley_sets'] as $smiley_set)
  617. {
  618. if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path'])))
  619. continue;
  620. $dir = dir($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']));
  621. while ($entry = $dir->read())
  622. {
  623. if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png')))
  624. $context['filenames'][strtolower($entry)] = array(
  625. 'id' => htmlspecialchars($entry),
  626. 'selected' => false,
  627. );
  628. }
  629. $dir->close();
  630. }
  631. ksort($context['filenames']);
  632. }
  633. // Create a new smiley from scratch.
  634. $context['filenames'] = array_values($context['filenames']);
  635. $context['current_smiley'] = array(
  636. 'id' => 0,
  637. 'code' => '',
  638. 'filename' => $context['filenames'][0]['id'],
  639. 'description' => $txt['smileys_default_description'],
  640. 'location' => 0,
  641. 'is_new' => true,
  642. );
  643. }
  644. function EditSmileys()
  645. {
  646. global $modSettings, $context, $settings, $txt, $boarddir;
  647. global $smcFunc, $scripturl, $sourcedir;
  648. // Force the correct tab to be displayed.
  649. $context[$context['admin_menu_name']]['current_subsection'] = 'editsmileys';
  650. // Submitting a form?
  651. if (isset($_POST[$context['session_var']]))
  652. {
  653. checkSession();
  654. // Changing the selected smileys?
  655. if (isset($_POST['smiley_action']) && !empty($_POST['checked_smileys']))
  656. {
  657. foreach ($_POST['checked_smileys'] as $id => $smiley_id)
  658. $_POST['checked_smileys'][$id] = (int) $smiley_id;
  659. if ($_POST['smiley_action'] == 'delete')
  660. $smcFunc['db_query']('', '
  661. DELETE FROM {db_prefix}smileys
  662. WHERE id_smiley IN ({array_int:checked_smileys})',
  663. array(
  664. 'checked_smileys' => $_POST['checked_smileys'],
  665. )
  666. );
  667. // Changing the status of the smiley?
  668. else
  669. {
  670. // Check it's a valid type.
  671. $displayTypes = array(
  672. 'post' => 0,
  673. 'hidden' => 1,
  674. 'popup' => 2
  675. );
  676. if (isset($displayTypes[$_POST['smiley_action']]))
  677. $smcFunc['db_query']('', '
  678. UPDATE {db_prefix}smileys
  679. SET hidden = {int:display_type}
  680. WHERE id_smiley IN ({array_int:checked_smileys})',
  681. array(
  682. 'checked_smileys' => $_POST['checked_smileys'],
  683. 'display_type' => $displayTypes[$_POST['smiley_action']],
  684. )
  685. );
  686. }
  687. }
  688. // Create/modify a smiley.
  689. elseif (isset($_POST['smiley']))
  690. {
  691. // Is it a delete?
  692. if (!empty($_POST['deletesmiley']))
  693. {
  694. $smcFunc['db_query']('', '
  695. DELETE FROM {db_prefix}smileys
  696. WHERE id_smiley = {int:current_smiley}',
  697. array(
  698. 'current_smiley' => $_POST['smiley'],
  699. )
  700. );
  701. }
  702. // Otherwise an edit.
  703. else
  704. {
  705. $_POST['smiley'] = (int) $_POST['smiley'];
  706. $_POST['smiley_code'] = htmltrim__recursive($_POST['smiley_code']);
  707. $_POST['smiley_filename'] = htmltrim__recursive($_POST['smiley_filename']);
  708. $_POST['smiley_location'] = empty($_POST['smiley_location']) || $_POST['smiley_location'] > 2 || $_POST['smiley_location'] < 0 ? 0 : (int) $_POST['smiley_location'];
  709. // Make sure some code was entered.
  710. if (empty($_POST['smiley_code']))
  711. fatal_lang_error('smiley_has_no_code');
  712. // Also make sure a filename was given.
  713. if (empty($_POST['smiley_filename']))
  714. fatal_lang_error('smiley_has_no_filename');
  715. // Check whether the new code has duplicates. It should be unique.
  716. $request = $smcFunc['db_query']('', '
  717. SELECT id_smiley
  718. FROM {db_prefix}smileys
  719. WHERE code = {raw:mysql_binary_type} {string:smiley_code}' . (empty($_POST['smiley']) ? '' : '
  720. AND id_smiley != {int:current_smiley}'),
  721. array(
  722. 'current_smiley' => $_POST['smiley'],
  723. 'mysql_binary_type' => $smcFunc['db_title'] == 'MySQL' ? 'BINARY' : '',
  724. 'smiley_code' => $_POST['smiley_code'],
  725. )
  726. );
  727. if ($smcFunc['db_num_rows']($request) > 0)
  728. fatal_lang_error('smiley_not_unique');
  729. $smcFunc['db_free_result']($request);
  730. $smcFunc['db_query']('', '
  731. UPDATE {db_prefix}smileys
  732. SET
  733. code = {string:smiley_code},
  734. filename = {string:smiley_filename},
  735. description = {string:smiley_description},
  736. hidden = {int:smiley_location}
  737. WHERE id_smiley = {int:current_smiley}',
  738. array(
  739. 'smiley_location' => $_POST['smiley_location'],
  740. 'current_smiley' => $_POST['smiley'],
  741. 'smiley_code' => $_POST['smiley_code'],
  742. 'smiley_filename' => $_POST['smiley_filename'],
  743. 'smiley_description' => $_POST['smiley_description'],
  744. )
  745. );
  746. }
  747. // Sort all smiley codes for more accurate parsing (longest code first).
  748. sortSmileyTable();
  749. }
  750. cache_put_data('parsing_smileys', null, 480);
  751. cache_put_data('posting_smileys', null, 480);
  752. }
  753. // Load all known smiley sets.
  754. $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']);
  755. $set_names = explode("\n", $modSettings['smiley_sets_names']);
  756. foreach ($context['smiley_sets'] as $i => $set)
  757. $context['smiley_sets'][$i] = array(
  758. 'id' => $i,
  759. 'path' => htmlspecialchars($set),
  760. 'name' => htmlspecialchars($set_names[$i]),
  761. 'selected' => $set == $modSettings['smiley_sets_default']
  762. );
  763. // Prepare overview of all (custom) smileys.
  764. if ($context['sub_action'] == 'editsmileys')
  765. {
  766. // Determine the language specific sort order of smiley locations.
  767. $smiley_locations = array(
  768. $txt['smileys_location_form'],
  769. $txt['smileys_location_hidden'],
  770. $txt['smileys_location_popup'],
  771. );
  772. asort($smiley_locations);
  773. // Create a list of options for selecting smiley sets.
  774. $smileyset_option_list = '
  775. <select name="set" onchange="changeSet(this.options[this.selectedIndex].value);">';
  776. foreach ($context['smiley_sets'] as $smiley_set)
  777. $smileyset_option_list .= '
  778. <option value="' . $smiley_set['path'] . '"' . ($modSettings['smiley_sets_default'] == $smiley_set['path'] ? ' selected="selected"' : '') . '>' . $smiley_set['name'] . '</option>';
  779. $smileyset_option_list .= '
  780. </select>';
  781. $listOptions = array(
  782. 'id' => 'smiley_list',
  783. 'items_per_page' => 40,
  784. 'base_href' => $scripturl . '?action=admin;area=smileys;sa=editsmileys',
  785. 'default_sort_col' => 'filename',
  786. 'get_items' => array(
  787. 'function' => 'list_getSmileys',
  788. ),
  789. 'get_count' => array(
  790. 'function' => 'list_getNumSmileys',
  791. ),
  792. 'no_items_label' => $txt['smileys_no_entries'],
  793. 'columns' => array(
  794. 'picture' => array(
  795. 'data' => array(
  796. 'sprintf' => array(
  797. 'format' => '<a href="' . $scripturl . '?action=admin;area=smileys;sa=modifysmiley;smiley=%1$d"><img src="' . $modSettings['smileys_url'] . '/' . $modSettings['smiley_sets_default'] . '/%2$s" alt="%3$s" style="padding: 2px;" id="smiley%1$d" /><input type="hidden" name="smileys[%1$d][filename]" value="%2$s" /></a>',
  798. 'params' => array(
  799. 'id_smiley' => false,
  800. 'filename' => true,
  801. 'description' => true,
  802. ),
  803. ),
  804. 'style' => 'text-align: center;',
  805. ),
  806. ),
  807. 'code' => array(
  808. 'header' => array(
  809. 'value' => $txt['smileys_code'],
  810. ),
  811. 'data' => array(
  812. 'db_htmlsafe' => 'code',
  813. ),
  814. 'sort' => array(
  815. 'default' => 'code',
  816. 'reverse' => 'code DESC',
  817. ),
  818. ),
  819. 'filename' => array(
  820. 'header' => array(
  821. 'value' => $txt['smileys_filename'],
  822. ),
  823. 'data' => array(
  824. 'db_htmlsafe' => 'filename',
  825. 'class' => 'windowbg',
  826. ),
  827. 'sort' => array(
  828. 'default' => 'filename',
  829. 'reverse' => 'filename DESC',
  830. ),
  831. ),
  832. 'location' => array(
  833. 'header' => array(
  834. 'value' => $txt['smileys_location'],
  835. ),
  836. 'data' => array(
  837. 'function' => create_function('$rowData', '
  838. global $txt;
  839. if (empty($rowData[\'hidden\']))
  840. return $txt[\'smileys_location_form\'];
  841. elseif ($rowData[\'hidden\'] == 1)
  842. return $txt[\'smileys_location_hidden\'];
  843. else
  844. return $txt[\'smileys_location_popup\'];
  845. '),
  846. 'class' => 'windowbg',
  847. ),
  848. 'sort' => array(
  849. 'default' => 'FIND_IN_SET(hidden, \'' . implode(',', array_keys($smiley_locations)) . '\')',
  850. 'reverse' => 'FIND_IN_SET(hidden, \'' . implode(',', array_keys($smiley_locations)) . '\') DESC',
  851. ),
  852. ),
  853. 'tooltip' => array(
  854. 'header' => array(
  855. 'value' => $txt['smileys_description'],
  856. ),
  857. 'data' => array(
  858. 'function' => create_function('$rowData', empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir']) ? '
  859. return htmlspecialchars($rowData[\'description\']);
  860. ' : '
  861. global $context, $txt, $modSettings;
  862. // Check if there are smileys missing in some sets.
  863. $missing_sets = array();
  864. foreach ($context[\'smiley_sets\'] as $smiley_set)
  865. if (!file_exists(sprintf(\'%1$s/%2$s/%3$s\', $modSettings[\'smileys_dir\'], $smiley_set[\'path\'], $rowData[\'filename\'])))
  866. $missing_sets[] = $smiley_set[\'path\'];
  867. $description = htmlspecialchars($rowData[\'description\']);
  868. if (!empty($missing_sets))
  869. $description .= sprintf(\'<br /><span class="smalltext"><strong>%1$s:</strong> %2$s</span>\', $txt[\'smileys_not_found_in_set\'], implode(\', \', $missing_sets));
  870. return $description;
  871. '),
  872. 'class' => 'windowbg',
  873. ),
  874. 'sort' => array(
  875. 'default' => 'description',
  876. 'reverse' => 'description DESC',
  877. ),
  878. ),
  879. 'modify' => array(
  880. 'header' => array(
  881. 'value' => $txt['smileys_modify'],
  882. ),
  883. 'data' => array(
  884. 'sprintf' => array(
  885. 'format' => '<a href="' . $scripturl . '?action=admin;area=smileys;sa=modifysmiley;smiley=%1$d">' . $txt['smileys_modify'] . '</a>',
  886. 'params' => array(
  887. 'id_smiley' => false,
  888. ),
  889. ),
  890. 'style' => 'text-align: center;',
  891. ),
  892. ),
  893. 'check' => array(
  894. 'header' => array(
  895. 'value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />',
  896. ),
  897. 'data' => array(
  898. 'sprintf' => array(
  899. 'format' => '<input type="checkbox" name="checked_smileys[]" value="%1$d" class="input_check" />',
  900. 'params' => array(
  901. 'id_smiley' => false,
  902. ),
  903. ),
  904. 'style' => 'text-align: center',
  905. ),
  906. ),
  907. ),
  908. 'form' => array(
  909. 'href' => $scripturl . '?action=admin;area=smileys;sa=editsmileys',
  910. 'name' => 'smileyForm',
  911. ),
  912. 'additional_rows' => array(
  913. array(
  914. 'position' => 'above_column_headers',
  915. 'value' => $smileyset_option_list,
  916. 'style' => 'text-align: right;',
  917. ),
  918. array(
  919. 'position' => 'below_table_data',
  920. 'value' => '
  921. <select name="smiley_action" onchange="makeChanges(this.value);">
  922. <option value="-1">' . $txt['smileys_with_selected'] . ':</option>
  923. <option value="-1">--------------</option>
  924. <option value="hidden">' . $txt['smileys_make_hidden'] . '</option>
  925. <option value="post">' . $txt['smileys_show_on_post'] . '</option>
  926. <option value="popup">' . $txt['smileys_show_on_popup'] . '</option>
  927. <option value="delete">' . $txt['smileys_remove'] . '</option>
  928. </select>
  929. <noscript><input type="submit" name="perform_action" value="' . $txt['go'] . '" class="button_submit" /></noscript>',
  930. 'style' => 'text-align: right;',
  931. ),
  932. ),
  933. 'javascript' => '
  934. function makeChanges(action)
  935. {
  936. if (action == \'-1\')
  937. return false;
  938. else if (action == \'delete\')
  939. {
  940. if (confirm(\'' . $txt['smileys_confirm'] . '\'))
  941. document.forms.smileyForm.submit();
  942. }
  943. else
  944. document.forms.smileyForm.submit();
  945. return true;
  946. }
  947. function changeSet(newSet)
  948. {
  949. var currentImage, i, knownSmileys = [];
  950. if (knownSmileys.length == 0)
  951. {
  952. for (var i = 0, n = document.images.length; i < n; i++)
  953. if (document.images[i].id.substr(0, 6) == \'smiley\')
  954. knownSmileys[knownSmileys.length] = document.images[i].id.substr(6);
  955. }
  956. for (i = 0; i < knownSmileys.length; i++)
  957. {
  958. currentImage = document.getElementById("smiley" + knownSmileys[i]);
  959. currentImage.src = "' . $modSettings['smileys_url'] . '/" + newSet + "/" + document.forms.smileyForm["smileys[" + knownSmileys[i] + "][filename]"].value;
  960. }
  961. }',
  962. );
  963. require_once($sourcedir . '/Subs-List.php');
  964. createList($listOptions);
  965. // The list is the only thing to show, so make it the main template.
  966. $context['default_list'] = 'smiley_list';
  967. $context['sub_template'] = 'show_list';
  968. }
  969. // Modifying smileys.
  970. elseif ($context['sub_action'] == 'modifysmiley')
  971. {
  972. // Get a list of all known smiley sets.
  973. $context['smileys_dir'] = empty($modSettings['smileys_dir']) ? $boarddir . '/Smileys' : $modSettings['smileys_dir'];
  974. $context['smileys_dir_found'] = is_dir($context['smileys_dir']);
  975. $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']);
  976. $set_names = explode("\n", $modSettings['smiley_sets_names']);
  977. foreach ($context['smiley_sets'] as $i => $set)
  978. $context['smiley_sets'][$i] = array(
  979. 'id' => $i,
  980. 'path' => htmlspecialchars($set),
  981. 'name' => htmlspecialchars($set_names[$i]),
  982. 'selected' => $set == $modSettings['smiley_sets_default']
  983. );
  984. $context['selected_set'] = $modSettings['smiley_sets_default'];
  985. // Get all possible filenames for the smileys.
  986. $context['filenames'] = array();
  987. if ($context['smileys_dir_found'])
  988. {
  989. foreach ($context['smiley_sets'] as $smiley_set)
  990. {
  991. if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path'])))
  992. continue;
  993. $dir = dir($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']));
  994. while ($entry = $dir->read())
  995. {
  996. if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png')))
  997. $context['filenames'][strtolower($entry)] = array(
  998. 'id' => htmlspecialchars($entry),
  999. 'selected' => false,
  1000. );
  1001. }
  1002. $dir->close();
  1003. }
  1004. ksort($context['filenames']);
  1005. }
  1006. $request = $smcFunc['db_query']('', '
  1007. SELECT id_smiley AS id, code, filename, description, hidden AS location, 0 AS is_new
  1008. FROM {db_prefix}smileys
  1009. WHERE id_smiley = {int:current_smiley}',
  1010. array(
  1011. 'current_smiley' => (int) $_REQUEST['smiley'],
  1012. )
  1013. );
  1014. if ($smcFunc['db_num_rows']($request) != 1)
  1015. fatal_lang_error('smiley_not_found');
  1016. $context['current_smiley'] = $smcFunc['db_fetch_assoc']($request);
  1017. $smcFunc['db_free_result']($request);
  1018. $context['current_smiley']['code'] = htmlspecialchars($context['current_smiley']['code']);
  1019. $context['current_smiley']['filename'] = htmlspecialchars($context['current_smiley']['filename']);
  1020. $context['current_smiley']['description'] = htmlspecialchars($context['current_smiley']['description']);
  1021. if (isset($context['filenames'][strtolower($context['current_smiley']['filename'])]))
  1022. $context['filenames'][strtolower($context['current_smiley']['filename'])]['selected'] = true;
  1023. }
  1024. }
  1025. function list_getSmileys($start, $items_per_page, $sort)
  1026. {
  1027. global $smcFunc;
  1028. $request = $smcFunc['db_query']('', '
  1029. SELECT id_smiley, code, filename, description, smiley_row, smiley_order, hidden
  1030. FROM {db_prefix}smileys
  1031. ORDER BY ' . $sort,
  1032. array(
  1033. )
  1034. );
  1035. $smileys = array();
  1036. while ($row = $smcFunc['db_fetch_assoc']($request))
  1037. $smileys[] = $row;
  1038. $smcFunc['db_free_result']($request);
  1039. return $smileys;
  1040. }
  1041. function list_getNumSmileys()
  1042. {
  1043. global $smcFunc;
  1044. $request = $smcFunc['db_query']('', '
  1045. SELECT COUNT(*)
  1046. FROM {db_prefix}smileys',
  1047. array(
  1048. )
  1049. );
  1050. list($numSmileys) = $smcFunc['db_fetch_row'];
  1051. $smcFunc['db_free_result']($request);
  1052. return $numSmileys;
  1053. }
  1054. function EditSmileyOrder()
  1055. {
  1056. global $modSettings, $context, $settings, $txt, $boarddir, $smcFunc;
  1057. // Move smileys to another position.
  1058. if (isset($_REQUEST['reorder']))
  1059. {
  1060. checkSession('get');
  1061. $_GET['location'] = empty($_GET['location']) || $_GET['location'] != 'popup' ? 0 : 2;
  1062. $_GET['source'] = empty($_GET['source']) ? 0 : (int) $_GET['source'];
  1063. if (empty($_GET['source']))
  1064. fatal_lang_error('smiley_not_found');
  1065. if (!empty($_GET['after']))
  1066. {
  1067. $_GET['after'] = (int) $_GET['after'];
  1068. $request = $smcFunc['db_query']('', '
  1069. SELECT smiley_row, smiley_order, hidden
  1070. FROM {db_prefix}smileys
  1071. WHERE hidden = {int:location}
  1072. AND id_smiley = {int:after_smiley}',
  1073. array(
  1074. 'location' => $_GET['location'],
  1075. 'after_smiley' => $_GET['after'],
  1076. )
  1077. );
  1078. if ($smcFunc['db_num_rows']($request) != 1)
  1079. fatal_lang_error('smiley_not_found');
  1080. list ($smiley_row, $smiley_order, $smileyLocation) = $smcFunc['db_fetch_row']($request);
  1081. $smcFunc['db_free_result']($request);
  1082. }
  1083. else
  1084. {
  1085. $smiley_row = (int) $_GET['row'];
  1086. $smiley_order = -1;
  1087. $smileyLocation = (int) $_GET['location'];
  1088. }
  1089. $smcFunc['db_query']('', '
  1090. UPDATE {db_prefix}smileys
  1091. SET smiley_order = smiley_order + 1
  1092. WHERE hidden = {int:new_location}
  1093. AND smiley_row = {int:smiley_row}
  1094. AND smiley_order > {int:smiley_order}',
  1095. array(
  1096. 'new_location' => $_GET['location'],
  1097. 'smiley_row' => $smiley_row,
  1098. 'smiley_order' => $smiley_order,
  1099. )
  1100. );
  1101. $smcFunc['db_query']('', '
  1102. UPDATE {db_prefix}smileys
  1103. SET
  1104. smiley_order = {int:smiley_order} + 1,
  1105. smiley_row = {int:smiley_row},
  1106. hidden = {int:new_location}
  1107. WHERE id_smiley = {int:current_smiley}',
  1108. array(
  1109. 'smiley_order' => $smiley_order,
  1110. 'smiley_row' => $smiley_row,
  1111. 'new_location' => $smileyLocation,
  1112. 'current_smiley' => $_GET['source'],
  1113. )
  1114. );
  1115. cache_put_data('parsing_smileys', null, 480);
  1116. cache_put_data('posting_smileys', null, 480);
  1117. }
  1118. $request = $smcFunc['db_query']('', '
  1119. SELECT id_smiley, code, filename, description, smiley_row, smiley_order, hidden
  1120. FROM {db_prefix}smileys
  1121. WHERE hidden != {int:popup}
  1122. ORDER BY smiley_order, smiley_row',
  1123. array(
  1124. 'popup' => 1,
  1125. )
  1126. );
  1127. $context['smileys'] = array(
  1128. 'postform' => array(
  1129. 'rows' => array(),
  1130. ),
  1131. 'popup' => array(
  1132. 'rows' => array(),
  1133. ),
  1134. );
  1135. while ($row = $smcFunc['db_fetch_assoc']($request))
  1136. {
  1137. $location = empty($row['hidden']) ? 'postform' : 'popup';
  1138. $context['smileys'][$location]['rows'][$row['smiley_row']][] = array(
  1139. 'id' => $row['id_smiley'],
  1140. 'code' => htmlspecialchars($row['code']),
  1141. 'filename' => htmlspecialchars($row['filename']),
  1142. 'description' => htmlspecialchars($row['description']),
  1143. 'row' => $row['smiley_row'],
  1144. 'order' => $row['smiley_order'],
  1145. 'selected' => !empty($_REQUEST['move']) && $_REQUEST['move'] == $row['id_smiley'],
  1146. );
  1147. }
  1148. $smcFunc['db_free_result']($request);
  1149. $context['move_smiley'] = empty($_REQUEST['move']) ? 0 : (int) $_REQUEST['move'];
  1150. // Make sure all rows are sequential.
  1151. foreach (array_keys($context['smileys']) as $location)
  1152. $context['smileys'][$location] = array(
  1153. 'id' => $location,
  1154. 'title' => $location == 'postform' ? $txt['smileys_location_form'] : $txt['smileys_location_popup'],
  1155. 'description' => $location == 'postform' ? $txt['smileys_location_form_description'] : $txt['smileys_location_popup_description'],
  1156. 'last_row' => count($context['smileys'][$location]['rows']),
  1157. 'rows' => array_values($context['smileys'][$location]['rows']),
  1158. );
  1159. // Check & fix smileys that are not ordered properly in the database.
  1160. foreach (array_keys($context['smileys']) as $location)
  1161. {
  1162. foreach ($context['smileys'][$location]['rows'] as $id => $smiley_row)
  1163. {
  1164. // Fix empty rows if any.
  1165. if ($id != $smiley_row[0]['row'])
  1166. {
  1167. $smcFunc['db_query']('', '
  1168. UPDATE {db_prefix}smileys
  1169. SET smiley_row = {int:new_row}
  1170. WHERE smiley_row = {int:current_row}
  1171. AND hidden = {int:location}',
  1172. array(
  1173. 'new_row' => $id,
  1174. 'current_row' => $smiley_row[0]['row'],
  1175. 'location' => $location == 'postform' ? '0' : '2',
  1176. )
  1177. );
  1178. // Only change the first row value of the first smiley (we don't need the others :P).
  1179. $context['smileys'][$location]['rows'][$id][0]['row'] = $id;
  1180. }
  1181. // Make sure the smiley order is always sequential.
  1182. foreach ($smiley_row as $order_id => $smiley)
  1183. if ($order_id != $smiley['order'])
  1184. $smcFunc['db_query']('', '
  1185. UPDATE {db_prefix}smileys
  1186. SET smiley_order = {int:new_order}
  1187. WHERE id_smiley = {int:current_smiley}',
  1188. array(
  1189. 'new_order' => $order_id,
  1190. 'current_smiley' => $smiley['id'],
  1191. )
  1192. );
  1193. }
  1194. }
  1195. cache_put_data('parsing_smileys', null, 480);
  1196. cache_put_data('posting_smileys', null, 480);
  1197. }
  1198. function InstallSmileySet()
  1199. {
  1200. global $sourcedir, $boarddir, $modSettings, $smcFunc;
  1201. isAllowedTo('manage_smileys');
  1202. checkSession('request');
  1203. require_once($sourcedir . '/Subs-Package.php');
  1204. $name = strtok(basename(isset($_FILES['set_gz']) ? $_FILES['set_gz']['name'] : $_REQUEST['set_gz']), '.');
  1205. $name = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $name);
  1206. // !!! Decide: overwrite or not?
  1207. if (isset($_FILES['set_gz']) && is_uploaded_file($_FILES['set_gz']['tmp_name']) && (@ini_get('open_basedir') != '' || file_exists($_FILES['set_gz']['tmp_name'])))
  1208. $extracted = read_tgz_file($_FILES['set_gz']['tmp_name'], $boarddir . '/Smileys/' . $name);
  1209. elseif (isset($_REQUEST['set_gz']))
  1210. {
  1211. // Check that the smiley is from simplemachines.org, for now... maybe add mirroring later.
  1212. if (preg_match('~^http://[\w_\-]+\.simplemachines\.org/~', $_REQUEST['set_gz']) == 0 || strpos($_REQUEST['set_gz'], 'dlattach') !== false)
  1213. fatal_lang_error('not_on_simplemachines');
  1214. $extracted = read_tgz_file($_REQUEST['set_gz'], $boarddir . '/Smileys/' . $name);
  1215. }
  1216. else
  1217. redirectexit('action=admin;area=smileys');
  1218. updateSettings(array(
  1219. 'smiley_sets_known' => $modSettings['smiley_sets_known'] . ',' . $name,
  1220. 'smiley_sets_names' => $modSettings['smiley_sets_names'] . "\n" . strtok(basename(isset($_FILES['set_gz']) ? $_FILES['set_gz']['name'] : $_REQUEST['set_gz']), '.'),
  1221. ));
  1222. cache_put_data('parsing_smileys', null, 480);
  1223. cache_put_data('posting_smileys', null, 480);
  1224. // !!! Add some confirmation?
  1225. redirectexit('action=admin;area=smileys');
  1226. }
  1227. // A function to import new smileys from an existing directory into the database.
  1228. function ImportSmileys($smileyPath)
  1229. {
  1230. global $modSettings, $smcFunc;
  1231. if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'] . '/' . $smileyPath))
  1232. fatal_lang_error('smiley_set_unable_to_import');
  1233. $smileys = array();
  1234. $dir = dir($modSettings['smileys_dir'] . '/' . $smileyPath);
  1235. while ($entry = $dir->read())
  1236. {
  1237. if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png')))
  1238. $smileys[strtolower($entry)] = $entry;
  1239. }
  1240. $dir->close();
  1241. // Exclude the smileys that are already in the database.
  1242. $request = $smcFunc['db_query']('', '
  1243. SELECT filename
  1244. FROM {db_prefix}smileys
  1245. WHERE filename IN ({array_string:smiley_list})',
  1246. array(
  1247. 'smiley_list' => $smileys,
  1248. )
  1249. );
  1250. while ($row = $smcFunc['db_fetch_assoc']($request))
  1251. if (isset($smileys[strtolower($row['filename'])]))
  1252. unset($smileys[strtolower($row['filename'])]);
  1253. $smcFunc['db_free_result']($request);
  1254. $request = $smcFunc['db_query']('', '
  1255. SELECT MAX(smiley_order)
  1256. FROM {db_prefix}smileys
  1257. WHERE hidden = {int:postform}
  1258. AND smiley_row = {int:first_row}',
  1259. array(
  1260. 'postform' => 0,
  1261. 'first_row' => 0,
  1262. )
  1263. );
  1264. list ($smiley_order) = $smcFunc['db_fetch_row']($request);
  1265. $smcFunc['db_free_result']($request);
  1266. $new_smileys = array();
  1267. foreach ($smileys as $smiley)
  1268. if (strlen($smiley) <= 48)
  1269. $new_smileys[] = array(':' . strtok($smiley, '.') . ':', $smiley, strtok($smiley, '.'), 0, ++$smiley_order);
  1270. if (!empty($new_smileys))
  1271. {
  1272. $smcFunc['db_insert']('',
  1273. '{db_prefix}smileys',
  1274. array(
  1275. 'code' => 'string-30', 'filename' => 'string-48', 'description' => 'string-80', 'smiley_row' => 'int', 'smiley_order' => 'int',
  1276. ),
  1277. $new_smileys,
  1278. array('id_smiley')
  1279. );
  1280. // Make sure the smiley codes are still in the right order.
  1281. sortSmileyTable();
  1282. cache_put_data('parsing_smileys', null, 480);
  1283. cache_put_data('posting_smileys', null, 480);
  1284. }
  1285. }
  1286. function EditMessageIcons()
  1287. {
  1288. global $user_info, $modSettings, $context, $settings, $txt;
  1289. global $boarddir, $smcFunc, $scripturl, $sourcedir;
  1290. // Get a list of icons.
  1291. $context['icons'] = array();
  1292. $request = $smcFunc['db_query']('', '
  1293. SELECT m.id_icon, m.title, m.filename, m.icon_order, m.id_board, b.name AS board_name
  1294. FROM {db_prefix}message_icons AS m
  1295. LEFT JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
  1296. WHERE ({query_see_board} OR b.id_board IS NULL)',
  1297. array(
  1298. )
  1299. );
  1300. $last_icon = 0;
  1301. $trueOrder = 0;
  1302. while ($row = $smcFunc['db_fetch_assoc']($request))
  1303. {
  1304. $context['icons'][$row['id_icon']] = array(
  1305. 'id' => $row['id_icon'],
  1306. 'title' => $row['title'],
  1307. 'filename' => $row['filename'],
  1308. 'image_url' => $settings[file_exists($settings['theme_dir'] . '/images/post/' . $row['filename'] . '.gif') ? 'actual_images_url' : 'default_images_url'] . '/post/' . $row['filename'] . '.gif',
  1309. 'board_id' => $row['id_board'],
  1310. 'board' => empty($row['board_name']) ? $txt['icons_edit_icons_all_boards'] : $row['board_name'],
  1311. 'order' => $row['icon_order'],
  1312. 'true_order' => $trueOrder++,
  1313. 'after' => $last_icon,
  1314. );
  1315. $last_icon = $row['id_icon'];
  1316. }
  1317. $smcFunc['db_free_result']($request);
  1318. // Submitting a form?
  1319. if (isset($_POST[$context['session_var']]))
  1320. {
  1321. checkSession();
  1322. // Deleting icons?
  1323. if (isset($_POST['delete']) && !empty($_POST['checked_icons']))
  1324. {
  1325. $deleteIcons = array();
  1326. foreach ($_POST['checked_icons'] as $icon)
  1327. $deleteIcons[] = (int) $icon;
  1328. // Do the actual delete!
  1329. $smcFunc['db_query']('', '
  1330. DELETE FROM {db_prefix}message_icons
  1331. WHERE id_icon IN ({array_int:icon_list})',
  1332. array(
  1333. 'icon_list' => $deleteIcons,
  1334. )
  1335. );
  1336. }
  1337. // Editing/Adding an icon?
  1338. elseif ($context['sub_action'] == 'editicon' && isset($_GET['icon']))
  1339. {
  1340. $_GET['icon'] = (int) $_GET['icon'];
  1341. // Do some preperation with the data... like check the icon exists *somewhere*
  1342. if (strpos($_POST['icon_filename'], '.gif') !== false)
  1343. $_POST['icon_filename'] = substr($_POST['icon_filename'], 0, -4);
  1344. if (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon_filename'] . '.gif'))
  1345. fatal_lang_error('icon_not_found');
  1346. // There is a 16 character limit on message icons...
  1347. elseif (strlen($_POST['icon_filename']) > 16)
  1348. fatal_lang_error('icon_name_too_long');
  1349. elseif ($_POST['icon_location'] == $_GET['icon'] && !empty($_GET['icon']))
  1350. fatal_lang_error('icon_after_itself');
  1351. // First do the sorting... if this is an edit reduce the order of everything after it by one ;)
  1352. if ($_GET['icon'] != 0)
  1353. {
  1354. $oldOrder = $context['icons'][$_GET['icon']]['true_order'];
  1355. foreach ($context['icons'] as $id => $data)
  1356. if ($data['true_order'] > $oldOrder)
  1357. $context['icons'][$id]['true_order']--;
  1358. }
  1359. // If there are no existing icons and this is a new one, set the id to 1 (mainly for non-mysql)
  1360. if (empty($_GET['icon']) && empty($context['icons']))
  1361. $_GET['icon'] = 1;
  1362. // Get the new order.
  1363. $newOrder = $_POST['icon_location'] == 0 ? 0 : $context['icons'][$_POST['icon_location']]['true_order'] + 1;
  1364. // Do the same, but with the one that used to be after this icon, done to avoid conflict.
  1365. foreach ($context['icons'] as $id => $data)
  1366. if ($data['true_order'] >= $newOrder)
  1367. $context['icons'][$id]['true_order']++;
  1368. // Finally set the current icon's position!
  1369. $context['icons'][$_GET['icon']]['true_order'] = $newOrder;
  1370. // Simply replace the existing data for the other bits.
  1371. $context['icons'][$_GET['icon']]['title'] = $_POST['icon_description'];
  1372. $context['icons'][$_GET['icon']]['filename'] = $_POST['icon_filename'];
  1373. $context['icons'][$_GET['icon']]['board_id'] = (int) $_POST['icon_board'];
  1374. // Do a huge replace ;)
  1375. $iconInsert = array();
  1376. $iconInsert_new = array();
  1377. foreach ($context['icons'] as $id => $icon)
  1378. {
  1379. if ($id != 0)
  1380. {
  1381. $iconInsert[] = array($id, $icon['board_id'], $icon['title'], $icon['filename'], $icon['true_order']);
  1382. }
  1383. else
  1384. {
  1385. $iconInsert_new[] = array($icon['board_id'], $icon['title'], $icon['filename'], $icon['true_order']);
  1386. }
  1387. }
  1388. $smcFunc['db_insert']('replace',
  1389. '{db_prefix}message_icons',
  1390. array('id_icon' => 'int', 'id_board' => 'int', 'title' => 'string-80', 'filename' => 'string-80', 'icon_order' => 'int'),
  1391. $iconInsert,
  1392. array('id_icon')
  1393. );
  1394. if (!empty($iconInsert_new))
  1395. {
  1396. $smcFunc['db_insert']('replace',
  1397. '{db_prefix}message_icons',
  1398. array('id_board' => 'int', 'title' => 'string-80', 'filename' => 'string-80', 'icon_order' => 'int'),
  1399. $iconInsert_new,
  1400. array('id_icon')
  1401. );
  1402. }
  1403. }
  1404. // Sort by order, so it is quicker :)
  1405. $smcFunc['db_query']('alter_table_icons', '
  1406. ALTER TABLE {db_prefix}message_icons
  1407. ORDER BY icon_order',
  1408. array(
  1409. 'db_error_skip' => true,
  1410. )
  1411. );
  1412. // Unless we're adding a new thing, we'll escape
  1413. if (!isset($_POST['add']))
  1414. redirectexit('action=admin;area=smileys;sa=editicons');
  1415. }
  1416. $context[$context['admin_menu_name']]['current_subsection'] = 'editicons';
  1417. $listOptions = array(
  1418. 'id' => 'message_icon_list',
  1419. 'base_href' => $scripturl . '?action=admin;area=smileys;sa=editicons',
  1420. 'get_items' => array(
  1421. 'function' => 'list_getMessageIcons',
  1422. ),
  1423. 'no_items_label' => $txt['icons_no_entries'],
  1424. 'columns' => array(
  1425. 'icon' => array(
  1426. 'data' => array(
  1427. 'function' => create_function('$rowData', '
  1428. global $settings;
  1429. $images_url = $settings[file_exists(sprintf(\'%1$s/images/post/%2$s.gif\', $settings[\'theme_dir\'], $rowData[\'filename\'])) ? \'actual_images_url\' : \'default_images_url\'];
  1430. return sprintf(\'<img src="%1$s/post/%2$s.gif" alt="%3$s" />\', $images_url, $rowData[\'filename\'], htmlspecialchars($rowData[\'title\']));
  1431. '),
  1432. ),
  1433. 'style' => 'text-align: center;',
  1434. ),
  1435. 'filename' => array(
  1436. 'header' => array(
  1437. 'value' => $txt['smileys_filename'],
  1438. ),
  1439. 'data' => array(
  1440. 'sprintf' => array(
  1441. 'format' => '%1$s.gif',
  1442. 'params' => array(
  1443. 'filename' => true,
  1444. ),
  1445. ),
  1446. ),
  1447. ),
  1448. 'tooltip' => array(
  1449. 'header' => array(
  1450. 'value' => $txt['smileys_description'],
  1451. ),
  1452. 'data' => array(
  1453. 'db_htmlsafe' => 'title',
  1454. 'class' => 'windowbg',
  1455. ),
  1456. ),
  1457. 'board' => array(
  1458. 'header' => array(
  1459. 'value' => $txt['icons_board'],
  1460. ),
  1461. 'data' => array(
  1462. 'function' => create_function('$rowData', '
  1463. global $txt;
  1464. return empty($rowData[\'board_name\']) ? $txt[\'icons_edit_icons_all_boards\'] : $rowData[\'board_name\'];
  1465. '),
  1466. ),
  1467. ),
  1468. 'modify' => array(
  1469. 'header' => array(
  1470. 'value' => $txt['smileys_modify'],
  1471. ),
  1472. 'data' => array(
  1473. 'sprintf' => array(
  1474. 'format' => '<a href="' . $scripturl . '?action=admin;area=smileys;sa=editicon;icon=%1$s">' . $txt['smileys_modify'] . '</a>',
  1475. 'params' => array(
  1476. 'id_icon' => false,
  1477. ),
  1478. ),
  1479. 'style' => 'text-align: center',
  1480. ),
  1481. ),
  1482. 'check' => array(
  1483. 'header' => array(
  1484. 'value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />',
  1485. ),
  1486. 'data' => array(
  1487. 'sprintf' => array(
  1488. 'format' => '<input type="checkbox" name="checked_icons[]" value="%1$d" class="input_check" />',
  1489. 'params' => array(
  1490. 'id_icon' => false,
  1491. ),
  1492. ),
  1493. 'style' => 'text-align: center',
  1494. ),
  1495. ),
  1496. ),
  1497. 'form' => array(
  1498. 'href' => $scripturl . '?action=admin;area=smileys;sa=editicons',
  1499. ),
  1500. 'additional_rows' => array(
  1501. array(
  1502. 'position' => 'below_table_data',
  1503. 'value' => '<input type="submit" name="delete" value="' . $txt['quickmod_delete_selected'] . '" style="float: right" class="button_submit" />[<a href="' . $scripturl . '?action=admin;area=smileys;sa=editicon">' . $txt['icons_add_new'] . '</a>]',
  1504. ),
  1505. ),
  1506. );
  1507. require_once($sourcedir . '/Subs-List.php');
  1508. createList($listOptions);
  1509. // If we're adding/editing an icon we'll need a list of boards
  1510. if ($context['sub_action'] == 'editicon' || isset($_POST['add']))
  1511. {
  1512. // Force the sub_template just in case.
  1513. $context['sub_template'] = 'editicon';
  1514. $context['new_icon'] = !isset($_GET['icon']);
  1515. // Get the properties of the current icon from the icon list.
  1516. if (!$context['new_icon'])
  1517. $context['icon'] = $context['icons'][$_GET['icon']];
  1518. // Get a list of boards needed for assigning this icon to a specific board.
  1519. $boardListOptions = array(
  1520. 'use_permissions' => true,
  1521. 'selected_board' => isset($context['icon']['board_id']) ? $context['icon']['board_id'] : 0,
  1522. );
  1523. require_once($sourcedir . '/Subs-MessageIndex.php');
  1524. $context['categories'] = getBoardList($boardListOptions);
  1525. }
  1526. }
  1527. function list_getMessageIcons($start, $items_per_page, $sort)
  1528. {
  1529. global $smcFunc, $user_info;
  1530. $request = $smcFunc['db_query']('', '
  1531. SELECT m.id_icon, m.title, m.filename, m.icon_order, m.id_board, b.name AS board_name
  1532. FROM {db_prefix}message_icons AS m
  1533. LEFT JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
  1534. WHERE ({query_see_board} OR b.id_board IS NULL)',
  1535. array(
  1536. )
  1537. );
  1538. $message_icons = array();
  1539. while ($row = $smcFunc['db_fetch_assoc']($request))
  1540. $message_icons[] = $row;
  1541. $smcFunc['db_free_result']($request);
  1542. return $message_icons;
  1543. }
  1544. // This function sorts the smiley table by code length, it is needed as MySQL withdrew support for functions in order by.
  1545. function sortSmileyTable()
  1546. {
  1547. global $smcFunc;
  1548. db_extend('packages');
  1549. // Add a sorting column.
  1550. $smcFunc['db_add_column']('{db_prefix}smileys', array('name' => 'temp_order', 'size' => 8, 'type' => 'mediumint', 'null' => false));
  1551. // Set the contents of this column.
  1552. $smcFunc['db_query']('set_smiley_order', '
  1553. UPDATE {db_prefix}smileys
  1554. SET temp_order = LENGTH(code)',
  1555. array(
  1556. )
  1557. );
  1558. // Order the table by this column.
  1559. $smcFunc['db_query']('alter_table_smileys', '
  1560. ALTER TABLE {db_prefix}smileys
  1561. ORDER BY temp_order DESC',
  1562. array(
  1563. 'db_error_skip' => true,
  1564. )
  1565. );
  1566. // Remove the sorting column.
  1567. $smcFunc['db_remove_column']('{db_prefix}smileys', 'temp_order');
  1568. }
  1569. ?>