PageRenderTime 65ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 1ms

/wp-content/plugins/simple-forum/admin/panel-components/support/sfa-components-save.php

https://bitbucket.org/crypticrod/sr_wp_code
PHP | 735 lines | 549 code | 131 blank | 55 comment | 161 complexity | 24a9ef640d117ed20830769a5137c2fd MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.1, GPL-3.0, LGPL-2.0, AGPL-3.0
  1. <?php
  2. /*
  3. Simple:Press
  4. Admin Options Save Options Support Functions
  5. $LastChangedDate: 2011-04-16 10:18:49 -0700 (Sat, 16 Apr 2011) $
  6. $Rev: 5903 $
  7. */
  8. if (preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF']))
  9. {
  10. die('Access Denied');
  11. }
  12. #= Save Toolbar Settings ===============================
  13. function sfa_save_toolbar_data()
  14. {
  15. # Toolbar
  16. if ($_POST['saveform'] == 'tbrestore')
  17. {
  18. return sfa_restore_toolbar_defaults();
  19. }
  20. check_admin_referer('forum-adminform_toolbar', 'forum-adminform_toolbar');
  21. if (!empty($_POST['delbuttons']))
  22. {
  23. return sfa_remove_toolbar_buttons($_POST['delbuttons']);
  24. }
  25. if ((!empty($_POST['stan_buttons']) || !empty($_POST['plug_buttons'])))
  26. {
  27. return sfa_reorder_toolbar_buttons($_POST['stan_buttons'], $_POST['plug_buttons']);
  28. }
  29. sf_update_option('sftbextras', sf_filter_text_save(trim($_POST['sftbextras'])));
  30. }
  31. #= Save Editor Options ===============================
  32. function sfa_save_editor_data()
  33. {
  34. check_admin_referer('forum-adminform_editor', 'forum-adminform_editor');
  35. $sfeditor = '';
  36. $sfeditor['sfeditor'] = sf_esc_int($_POST['editor']);
  37. if (isset($_POST['sfusereditor'])) { $sfeditor['sfusereditor'] = true; } else { $sfeditor['sfusereditor']=false; }
  38. if (isset($_POST['sfrejectformat'])) { $sfeditor['sfrejectformat'] = true; } else { $sfeditor['sfrejectformat']=false; }
  39. $sfeditor['sftmcontentCSS'] = sf_filter_filename_save($_POST['sftmcontentCSS']);
  40. $sfeditor['sftmuiCSS'] = sf_filter_filename_save($_POST['sftmuiCSS']);
  41. $sfeditor['sftmdialogCSS'] = sf_filter_filename_save($_POST['sftmdialogCSS']);
  42. $sfeditor['SFhtmlCSS'] = sf_filter_filename_save($_POST['SFhtmlCSS']);
  43. $sfeditor['SFbbCSS'] = sf_filter_filename_save($_POST['SFbbCSS']);
  44. $sfeditor['sflang'] = sf_esc_str($_POST['sflang']);
  45. if (isset($_POST['sfrtl'])) { $sfeditor['sfrtl'] = true; } else { $sfeditor['sfrtl'] = false; }
  46. if (isset($_POST['sfrelative'])) { $sfeditor['sfrelative'] = true; } else { $sfeditor['sfrelative'] = false; }
  47. sf_update_option('sfeditor', $sfeditor);
  48. $mess = __('Post Editor Options Updated', "sforum");
  49. return $mess;
  50. }
  51. #= Save and Upload Smmileys ===============================
  52. function sfa_save_smileys_data()
  53. {
  54. global $wpdb, $SFPATHS;
  55. check_admin_referer('forum-adminform_smileys', 'forum-adminform_smileys');
  56. $mess = '';
  57. # save Smiley options -------------------
  58. $sfsmileys = '';
  59. if (isset($_POST['sfsmallow'])) { $sfsmileys['sfsmallow'] = true; } else { $sfsmileys['sfsmallow'] = false; }
  60. $sfsmileys['sfsmtype'] = sf_esc_int($_POST['smileytype']);
  61. sf_update_option('sfsmileys', $sfsmileys);
  62. # now for the actual smileys
  63. $sfsmileys = array();
  64. $path = SF_STORE_DIR . '/'.$SFPATHS['smileys'].'/';
  65. $smileyname=array();
  66. $smileyname = $_POST['smname'];
  67. for ($x=0; $x < count($smileyname); $x++)
  68. {
  69. if((!empty($smileyname[$x])) && (!empty($_POST['smcode'][$x])))
  70. {
  71. $file = $_POST['smfile'][$x];
  72. $thisname = sf_create_slug($smileyname[$x], '');
  73. if(file_exists($path.$file))
  74. {
  75. $sfsmileys[$thisname][] = sf_filter_title_save($_POST['smfile'][$x]);
  76. $sfsmileys[$thisname][] = sf_filter_name_save($_POST['smcode'][$x]);
  77. }
  78. }
  79. }
  80. # load current saved smileys to get meta id
  81. $meta = sf_get_sfmeta('smileys', 'smileys');
  82. # now serialise and save
  83. $smeta = serialize($sfsmileys);
  84. sf_update_sfmeta('smileys', 'smileys', $smeta, $meta[0]['meta_id']);
  85. $mess .= __('Smileys Component Updated', "sforum");
  86. return $mess;
  87. }
  88. #= Save Login Options ===============================
  89. function sfa_save_login_data()
  90. {
  91. check_admin_referer('forum-adminform_login', 'forum-adminform_login');
  92. # login
  93. $sflogin = sf_get_option('sflogin');
  94. if (isset($_POST['sfshowlogin'])) { $sflogin['sfshowlogin'] = true; } else { $sflogin['sfshowlogin'] = false; }
  95. if (isset($_POST['sfshowreg'])) { $sflogin['sfshowreg'] = true; } else { $sflogin['sfshowreg'] = false; }
  96. if (isset($_POST['sfshowavatar'])) { $sflogin['sfshowavatar'] = true; } else { $sflogin['sfshowavatar'] = false; }
  97. if (isset($_POST['sfregmath'])) { $sflogin['sfregmath'] = true; } else { $sflogin['sfregmath'] = false; }
  98. if (isset($_POST['sfinlogin'])) { $sflogin['sfinlogin'] = true; } else { $sflogin['sfinlogin'] = false; }
  99. if (isset($_POST['sfloginskin'])) { $sflogin['sfloginskin'] = true; } else { $sflogin['sfloginskin'] = false; }
  100. if (!empty($_POST['sfloginurl'])) {
  101. $sflogin['sfloginurl'] = sf_filter_save_cleanurl($_POST['sfloginurl']);
  102. } else $sflogin['sfloginurl'] = SFSITEURL.'wp-login.php?action=login&amp;view=forum';
  103. if (!empty($_POST['sfloginemailurl'])) {
  104. $sflogin['sfloginemailurl'] = sf_filter_save_cleanurl($_POST['sfloginemailurl']);
  105. } else $sflogin['sfloginemailurl'] = SFSITEURL.'wp-login.php?action=login&view=forum';
  106. if (!empty($_POST['sflogouturl'])) {
  107. $sflogin['sflogouturl'] = sf_filter_save_cleanurl($_POST['sflogouturl']);
  108. } else $sflogin['sflogouturl'] = SFSITEURL.'wp-login.php?action=logout&amp;redirect_to='.SFURL;
  109. if (!empty($_POST['sfregisterurl'])) {
  110. $sflogin['sfregisterurl'] = sf_filter_save_cleanurl($_POST['sfregisterurl']);
  111. } else $sflogin['sfregisterurl'] = SFSITEURL.'wp-login.php?action=register&amp;view=forum';
  112. if (!empty($_POST['sflostpassurl'])) {
  113. $sflogin['sflostpassurl'] = sf_filter_save_cleanurl($_POST['sflostpassurl']);
  114. } else $sflogin['sflostpassurl'] = SFSITEURL.'wp-login.php?action=lostpassword&amp;view=forum';
  115. sf_update_option('sflogin', $sflogin);
  116. # RPX support
  117. $sfrpx = sf_get_option('sfrpx');
  118. $oldrpx = $sfrpx['sfrpxenable'];
  119. if (isset($_POST['sfrpxenable'])) { $sfrpx['sfrpxenable'] = true; } else { $sfrpx['sfrpxenable'] = false; }
  120. $sfrpx['sfrpxkey'] = sf_esc_str($_POST['sfrpxkey']);
  121. $sfrpx['sfrpxredirect'] = sf_filter_save_cleanurl($_POST['sfrpxredirect']);
  122. # change in RPX support?
  123. if (!$oldrpx && $sfrpx['sfrpxenable'])
  124. {
  125. require_once(SF_PLUGIN_DIR.'/library/sf-rpx.php');
  126. $post_data = array('apiKey' => $_POST[sfrpxkey], 'format' => 'json');
  127. $raw = spf_rpx_http_post('https://rpxnow.com/plugin/lookup_rp', $post_data);
  128. $r = spf_rpx_parse_lookup_rp($raw);
  129. if ($r)
  130. {
  131. $sfrpx['sfrpxrealm'] = $r['realm'];
  132. } else {
  133. $mess = __('Error in RPX API data!', 'sforum');
  134. return $mess;
  135. }
  136. }
  137. sf_update_option('sfrpx', $sfrpx);
  138. # if set update, otherwise its empty, so remove
  139. if ($_POST['sfsneakpeek'] != '')
  140. {
  141. sf_add_sfmeta('sneakpeek', 'message', sf_filter_text_save(trim($_POST['sfsneakpeek'])));
  142. } else {
  143. $msg = sf_get_sfmeta('sneakpeek', 'message');
  144. if (!empty($msg)) sf_delete_sfmeta($msg[0]['meta_id']);
  145. }
  146. # if set update, otherwise its empty, so remove
  147. if ($_POST['sfadminview'] != '')
  148. {
  149. sf_add_sfmeta('adminview', 'message', sf_filter_text_save(trim($_POST['sfadminview'])));
  150. } else {
  151. $msg = sf_get_sfmeta('adminview', 'message');
  152. if (!empty($msg)) sf_delete_sfmeta($msg[0]['meta_id']);
  153. }
  154. $mess = __('Login/Registration Component Updated', "sforum");
  155. return $mess;
  156. }
  157. #= Save Eextensions Options ===============================
  158. function sfa_save_seo_data()
  159. {
  160. global $wpdb;
  161. check_admin_referer('forum-adminform_seo', 'forum-adminform_seo');
  162. $mess= '';
  163. # browser title
  164. $sfseo = array();
  165. if (isset($_POST['sfseo_topic'])) { $sfseo['sfseo_topic'] = true; } else { $sfseo['sfseo_topic'] = false; }
  166. if (isset($_POST['sfseo_forum'])) { $sfseo['sfseo_forum'] = true; } else { $sfseo['sfseo_forum'] = false; }
  167. if (isset($_POST['sfseo_page'])) { $sfseo['sfseo_page'] = true; } else { $sfseo['sfseo_page'] = false; }
  168. $sfseo['sfseo_sep'] = sf_filter_title_save(trim($_POST['sfseo_sep']));
  169. sf_update_option('sfseo', $sfseo);
  170. # meta tags
  171. $sfmetatags= array();
  172. $sfmetatags['sfdescr'] = sf_filter_title_save(trim($_POST['sfdescr']));
  173. $sfmetatags['sfdescruse'] = $_POST['sfdescruse'];
  174. if (isset($_POST['sfusekeywords'])) { $sfmetatags['sfusekeywords'] = true; } else { $sfmetatags['sfusekeywords'] = false; }
  175. if (isset($_POST['sftagwords'])) { $sfmetatags['sftagwords'] = true; } else { $sfmetatags['sftagwords'] = false; }
  176. $sfmetatags['sfkeywords'] = sf_filter_title_save(trim($_POST['sfkeywords']));
  177. sf_update_option('sfmetatags', $sfmetatags);
  178. $sfbuildsitemap = sf_esc_int($_POST['sfbuildsitemap']);
  179. sf_update_option('sfbuildsitemap', $sfbuildsitemap);
  180. # schedule cron if rebuilding daily
  181. wp_clear_scheduled_hook('spf_cron_sitemap');
  182. if ($sfbuildsitemap == 3) # rebuild once per day
  183. {
  184. wp_schedule_event(time(), 'daily', 'spf_cron_sitemap');
  185. }
  186. # auto removal cron job
  187. if (isset($_POST['sfuserremove']))
  188. {
  189. $sfuser['sfuserremove'] = true;
  190. } else {
  191. $sfuser['sfuserremove'] = false;
  192. }
  193. $mess .= '<br />'.__('SEO Components Updated', "sforum").$mess;
  194. return $mess;
  195. }
  196. #= Save PM Options ===============================
  197. function sfa_save_pm_data()
  198. {
  199. global $wpdb;
  200. check_admin_referer('forum-adminform_pm', 'forum-adminform_pm');
  201. sfa_update_check_option('sfprivatemessaging');
  202. # Save Private Message options
  203. $sfpm = '';
  204. if (isset($_POST['sfpmemail'])) { $sfpm['sfpmemail'] = true; } else { $sfpm['sfpmemail'] = false; }
  205. if (isset($_POST['sfpmcc'])) { $sfpm['sfpmcc'] = true; } else { $sfpm['sfpmcc'] = false; }
  206. if (isset($_POST['sfpmbcc'])) { $sfpm['sfpmbcc'] = true; } else { $sfpm['sfpmbcc'] = false; }
  207. if (isset($_POST['sfpmlimitedsend'])) { $sfpm['sfpmlimitedsend'] = true; } else { $sfpm['sfpmlimitedsend'] = false; }
  208. $sfpm['sfpmmax'] = sf_esc_int($_POST['sfpmmax']);
  209. $sfpm['sfpmmaxrecipients'] = sf_esc_int($_POST['sfpmmaxrecipients']);
  210. # auto removal period
  211. if (isset($_POST['sfpmkeep']) && $_POST['sfpmkeep'] > 0)
  212. {
  213. $sfpm['sfpmkeep'] = intval($_POST['sfpmkeep']);
  214. } else {
  215. $sfpm['sfpmkeep'] = 365; # if not filled in make it one year
  216. }
  217. # auto removal cron job
  218. wp_clear_scheduled_hook('spf_cron_pm');
  219. if (isset($_POST['sfpmremove']))
  220. {
  221. $sfpm['sfpmremove'] = true;
  222. wp_schedule_event(time(), 'daily', 'spf_cron_pm');
  223. } else {
  224. $sfpm['sfpmremove'] = false;
  225. }
  226. sf_update_option('sfpm', $sfpm);
  227. $mess = __('Private Messaging Components Updated', "sforum");
  228. return $mess;
  229. }
  230. function sfa_save_links_data()
  231. {
  232. check_admin_referer('forum-adminform_links', 'forum-adminform_links');
  233. $mess = __('Options Updated', "sforum");
  234. $sfpostlinking = array();
  235. if (isset($_POST['sflinkabove'])) { $sfpostlinking['sflinkabove'] = true; } else { $sfpostlinking['sflinkabove'] = false; }
  236. if (isset($_POST['sflinksingle'])) { $sfpostlinking['sflinksingle'] = true; } else { $sfpostlinking['sflinksingle'] = false; }
  237. if (isset($_POST['sfuseautolabel'])) { $sfpostlinking['sfuseautolabel'] = true; } else { $sfpostlinking['sfuseautolabel'] = false; }
  238. if (isset($_POST['sfautoupdate'])) { $sfpostlinking['sfautoupdate'] = true; } else { $sfpostlinking['sfautoupdate'] = false; }
  239. if (isset($_POST['sfautocreate'])) { $sfpostlinking['sfautocreate'] = true; } else { $sfpostlinking['sfautocreate'] = false; }
  240. if (isset($_POST['sfpostcomment'])) { $sfpostlinking['sfpostcomment'] = true; } else { $sfpostlinking['sfpostcomment'] = false; }
  241. if (isset($_POST['sfkillcomment'])) { $sfpostlinking['sfkillcomment'] = true; } else { $sfpostlinking['sfkillcomment'] = false; }
  242. if (isset($_POST['sfeditcomment'])) { $sfpostlinking['sfeditcomment'] = true; } else { $sfpostlinking['sfeditcomment'] = false; }
  243. if (isset($_POST['sfhideduplicate'])) { $sfpostlinking['sfhideduplicate'] = true; } else { $sfpostlinking['sfhideduplicate'] = false; }
  244. $sfpostlinking['sflinkexcerpt'] = sf_esc_int($_POST['sflinkexcerpt']);
  245. $sfpostlinking['sflinkcomments'] = sf_esc_int($_POST['sflinkcomments']);
  246. $sfpostlinking['sflinkwords'] = sf_esc_int($_POST['sflinkwords']);
  247. $sfpostlinking['sflinkblogtext'] = sf_filter_text_save(trim($_POST['sflinkblogtext']));
  248. $sfpostlinking['sflinkforumtext'] = sf_filter_text_save(trim($_POST['sflinkforumtext']));
  249. $sfpostlinking['sfautoforum'] = sf_esc_int($_POST['sfautoforum']);
  250. $sfpostlinking['sflinkurls'] = sf_esc_int($_POST['sflinkurls']);
  251. sf_update_option('sfpostlinking', $sfpostlinking);
  252. $sflinkposttype = array();
  253. $post_types=get_post_types();
  254. foreach($post_types as $key=>$value)
  255. {
  256. if($key != 'attachment' && $key != 'revision' && $key != 'nav_menu_item')
  257. {
  258. $type = 'posttype_'.$key;
  259. if (isset($_POST[$type])) { $sflinkposttype[$key] = true; } else { $sflinkposttype[$key] = false; }
  260. }
  261. }
  262. sf_update_option('sflinkposttype', $sflinkposttype);
  263. return $mess;
  264. }
  265. #= Save Upload Options ===============================
  266. function sfa_save_uploads_data()
  267. {
  268. check_admin_referer('forum-adminform_uploads', 'forum-adminform_uploads');
  269. $sfuploads = '';
  270. if (isset($_POST['privatefolder'])) { $sfuploads['privatefolder'] = true; } else { $sfuploads['privatefolder'] = false; }
  271. if (isset($_POST['showmode'])) { $sfuploads['showmode'] = true; } else { $sfuploads['showmode'] = false; }
  272. $sfuploads['thumbsize'] = sf_esc_int($_POST['thumbsize']);
  273. $sfuploads['pagecount'] = sf_esc_int($_POST['pagecount']);
  274. $sfuploads['imagetypes'] = sf_filter_title_save(trim($_POST['imagetypes']));
  275. $sfuploads['imagemaxsize'] = sf_esc_int($_POST['imagemaxsize']);
  276. $sfuploads['mediatypes'] = sf_filter_title_save(trim($_POST['mediatypes']));
  277. $sfuploads['mediamaxsize'] = sf_esc_int($_POST['mediamaxsize']);
  278. $sfuploads['filetypes'] = sf_filter_title_save(trim($_POST['filetypes']));
  279. $sfuploads['filemaxsize'] = sf_esc_int($_POST['filemaxsize']);
  280. $sfuploads['prohibited'] = sf_filter_title_save(trim($_POST['prohibited']));
  281. $sfuploads['deftab'] = sf_esc_int(trim($_POST['sfdeftab']));
  282. sf_update_option('sfuploads', $sfuploads);
  283. $mess = __('Upload Options Updated', "sforum");
  284. return $mess;
  285. }
  286. #= Save Topic Status Sets ===============================
  287. function sfa_save_topicstatus_data()
  288. {
  289. check_admin_referer('forum-adminform_topicstatus', 'forum-adminform_topicstatus');
  290. # Topic Status Sets ---------------------
  291. if (isset($_POST['sftopstatname'][0]))
  292. {
  293. for ($x=0; $x<count($_POST['sftopstatid']); $x++)
  294. {
  295. $type = 'topic-status';
  296. $key = sf_filter_title_save(trim($_POST['sftopstatname'][$x]));
  297. $value = sf_filter_title_save(trim($_POST['sftopstatwords'][$x]));
  298. if(!empty($_POST['sftopstatid'][$x]))
  299. {
  300. if(isset($_POST['sftopstatdel'][$x]) && $_POST['sftopstatdel'][$x] == 'on')
  301. {
  302. sf_delete_sfmeta(sf_esc_int($_POST['sftopstatid'][$x]));
  303. } else {
  304. sf_update_sfmeta($type, $key, $value, sf_esc_int($_POST['sftopstatid'][$x]));
  305. }
  306. } else {
  307. sf_add_sfmeta($type, $key, $value);
  308. }
  309. }
  310. }
  311. $mess = __('Topic Status Component Updated', "sforum");
  312. return $mess;
  313. }
  314. #= Save Forum Rankings ===============================
  315. function sfa_save_forumranks_data()
  316. {
  317. # save forum ranks
  318. for ($x=0; $x<count($_POST['rankdesc']); $x++)
  319. {
  320. if (!empty($_POST['rankdesc'][$x]))
  321. {
  322. $rankdata = array();
  323. $rankdata['posts'] = sf_esc_int($_POST['rankpost'][$x]);
  324. $rankdata['usergroup'] = $_POST['rankug'][$x];
  325. $rankdata['badge'] = $_POST['rankbadge'][$x];
  326. if ($_POST['rankid'][$x] == -1) {
  327. sf_add_sfmeta('forum_rank', sf_filter_title_save(trim($_POST['rankdesc'][$x])), serialize($rankdata));
  328. } else {
  329. sf_update_sfmeta('forum_rank', sf_filter_title_save(trim($_POST['rankdesc'][$x])), serialize($rankdata), sf_esc_int($_POST['rankid'][$x]));
  330. }
  331. }
  332. }
  333. $mess = __('Forum Ranks Updated', "sforum");
  334. return $mess;
  335. }
  336. #= Save Special Rankins ===============================
  337. function sfa_add_specialrank()
  338. {
  339. check_admin_referer('special-rank-new', 'special-rank-new');
  340. # save special forum ranks
  341. if (!empty($_POST['specialrank']))
  342. {
  343. $rankdata = array();
  344. $rankdata['badge'] = '';
  345. sf_add_sfmeta('special_rank', sf_filter_title_save(trim($_POST['specialrank'])), serialize($rankdata));
  346. }
  347. $mess = __('Special Rank Added', "sforum");
  348. return $mess;
  349. }
  350. #= Save Special Rankins ===============================
  351. function sfa_update_specialrank($id)
  352. {
  353. check_admin_referer('special-rank-update', 'special-rank-update');
  354. # save special forum ranks
  355. if (!empty($_POST['specialrankdesc']))
  356. {
  357. $desc = $_POST['specialrankdesc'];
  358. $badge = $_POST['specialrankbadge'];
  359. $rank = sf_get_sfmeta('special_rank', false, $id);
  360. $rankdata = unserialize($rank[0]['meta_value']);
  361. $rankdata['badge'] = $badge[$id];
  362. sf_update_sfmeta('special_rank', sf_filter_title_save(trim($desc[$id])), serialize($rankdata), $id);
  363. }
  364. $mess = __('Special Rank Updated', "sforum");
  365. return $mess;
  366. }
  367. function sfa_add_special_rank_member($id)
  368. {
  369. check_admin_referer('special-rank-add', 'special-rank-add');
  370. $user_id_list = array_unique($_POST['amember_id']);
  371. if (empty($user_id_list)) return;
  372. # set up the users with special rank
  373. $rank = sf_get_sfmeta('special_rank', false, $id);
  374. $rankdata = unserialize($rank[0]['meta_value']);
  375. $ranks['badge'] = $rankdata['badge'];
  376. $ranks['users'] = $rankdata['users'];
  377. # add the new users
  378. for ($x=0; $x<count($user_id_list); $x++)
  379. {
  380. $ranks['users'][] = sf_esc_int($user_id_list[$x]);
  381. }
  382. sf_update_sfmeta('special_rank', sf_filter_title_save($rank[0]['meta_key']), serialize($ranks), $id);
  383. $mess = __("User(s) Added to Special Forum Rank", "sforum");
  384. return $mess;
  385. }
  386. function sfa_del_special_rank_member($id)
  387. {
  388. check_admin_referer('special-rank-del', 'special-rank-del');
  389. $user_id_list = array_unique($_POST['dmember_id']);
  390. if (empty($user_id_list)) return;
  391. # remove the users from the special rank
  392. $rank = sf_get_sfmeta('special_rank', false, $id);
  393. $rankdata = unserialize($rank[0]['meta_value']);
  394. $ranks['badge'] = $rankdata['badge'];
  395. $ranks['users'] = $rankdata['users'];
  396. for( $x=0; $x<count($user_id_list); $x++)
  397. {
  398. $newlist = '';
  399. $user_id = sf_esc_int($user_id_list[$x]);
  400. foreach ($ranks['users'] as $userid)
  401. {
  402. if ($user_id != $userid)
  403. {
  404. $newlist[] = $userid;
  405. }
  406. }
  407. $ranks['users'] = $newlist;
  408. }
  409. sf_update_sfmeta('special_rank', sf_filter_title_save($rank[0]['meta_key']), serialize($ranks), $id);
  410. $mess = __("User(s) Deleted From Special Forum Rank", "sforum");
  411. return $mess;
  412. }
  413. #= Save Custom Messages ===============================
  414. function sfa_save_messages_data()
  415. {
  416. check_admin_referer('forum-adminform_messages', 'forum-adminform_messages');
  417. # custom message for editor
  418. $sfpostmsg = array();
  419. $sfpostmsg['sfpostmsgtext'] = sf_filter_text_save(trim($_POST['sfpostmsgtext']));
  420. $sfpostmsg['sfpostmsgtopic'] = $_POST['sfpostmsgtopic'];
  421. $sfpostmsg['sfpostmsgpost'] = $_POST['sfpostmsgpost'];
  422. sf_update_option('sfpostmsg', $sfpostmsg);
  423. sf_update_option('sfeditormsg', sf_filter_text_save(trim($_POST['sfeditormsg'])));
  424. $mess = __('Custom Messages Updated', "sforum");
  425. return $mess;
  426. }
  427. #= Save Custom Icons ===============================
  428. function sfa_save_icons_data()
  429. {
  430. check_admin_referer('forum-adminform_icons', 'forum-adminform_icons');
  431. $mess='';
  432. for ($x=0; $x<3; $x++)
  433. {
  434. $custom='cusicon'.$x;
  435. if (!empty($_POST[$custom]))
  436. {
  437. $icon = $_POST[$custom];
  438. $path = SFCUSTOM.$icon;
  439. if(!file_exists($path))
  440. {
  441. $mess.= "* ".sprintf(__("Custom Icon '%s' does not exist", "sforum"), $icon).'<br />';
  442. }
  443. }
  444. }
  445. # Save Custom Icons (3)
  446. $sfcustom = array();
  447. $sfcustom[0]['custext'] = sf_filter_title_save(trim($_POST['custext0']));
  448. $sfcustom[0]['cuslink'] = sf_filter_save_cleanurl($_POST['cuslink0']);
  449. $sfcustom[0]['cusicon'] = sf_filter_title_save(trim($_POST['cusicon0']));
  450. $sfcustom[1]['custext'] = sf_filter_title_save(trim($_POST['custext1']));
  451. $sfcustom[1]['cuslink'] = sf_filter_save_cleanurl($_POST['cuslink1']);
  452. $sfcustom[1]['cusicon'] = sf_filter_title_save(trim($_POST['cusicon1']));
  453. $sfcustom[2]['custext'] = sf_filter_title_save(trim($_POST['custext2']));
  454. $sfcustom[2]['cuslink'] = sf_filter_save_cleanurl($_POST['cuslink2']);
  455. $sfcustom[2]['cusicon'] = sf_filter_title_save(trim($_POST['cusicon2']));
  456. sf_update_option('sfcustom', $sfcustom);
  457. $mess = __('Custom Icons Updated', "sforum");
  458. return $mess;
  459. }
  460. function sfa_save_tags_data()
  461. {
  462. check_admin_referer('forum-adminform_tags', 'forum-adminform_tags');
  463. $mess = __('Options Updated', "sforum");
  464. sfa_update_check_option('sfuseannounce');
  465. sfa_update_check_option('sfannouncelist');
  466. sf_update_option('sfannouncecount', sf_esc_int($_POST['sfannouncecount']));
  467. sf_update_option('sfannouncehead', sf_filter_text_save(trim($_POST['sfannouncehead'])));
  468. sf_update_option('sfannouncetext', sf_filter_text_save(trim($_POST['sfannouncetext'])));
  469. sfa_update_check_option('sfannounceauto');
  470. sf_update_option('sfannouncetime', sf_esc_int($_POST['sfannouncetime']));
  471. return $mess;
  472. }
  473. function sfa_save_policies_data()
  474. {
  475. check_admin_referer('forum-adminform_policies', 'forum-adminform_policies');
  476. # set up some more allowed tags for the textareas.
  477. # login
  478. $sfpolicy = sf_get_option('sfpolicy');
  479. if (isset($_POST['sfregtext'])) { $sfpolicy['sfregtext'] = true; } else { $sfpolicy['sfregtext'] = false; }
  480. if (isset($_POST['sfregcheck'])) { $sfpolicy['sfregcheck'] = true; } else { $sfpolicy['sfregcheck'] = false; }
  481. if (isset($_POST['sfreglink'])) { $sfpolicy['sfreglink'] = true; } else { $sfpolicy['sfreglink'] = false; }
  482. if (isset($_POST['sfprivlink'])) { $sfpolicy['sfprivlink'] = true; } else { $sfpolicy['sfprivlink'] = false; }
  483. $sfpolicy['sfregfile'] = sf_filter_filename_save(trim($_POST['sfregfile']));
  484. $sfpolicy['sfprivfile'] = sf_filter_filename_save(trim($_POST['sfprivfile']));
  485. sf_update_option('sfpolicy', $sfpolicy);
  486. # Registration text - if set update, otherwise its empty, so remove
  487. if ($_POST['sfregpolicy'] != '')
  488. {
  489. sf_add_sfmeta('registration', 'policy', sf_filter_text_save(trim($_POST['sfregpolicy'])));
  490. } else {
  491. $msg = sf_get_sfmeta('registration', 'policy');
  492. if (!empty($msg)) sf_delete_sfmeta($msg[0]['meta_id']);
  493. }
  494. # Prvacy text - if set update, otherwise its empty, so remove
  495. if ($_POST['sfprivpolicy'] != '')
  496. {
  497. sf_add_sfmeta('privacy', 'policy', sf_filter_text_save(trim($_POST['sfprivpolicy'])));
  498. } else {
  499. $msg = sf_get_sfmeta('privacy', 'policy');
  500. if (!empty($msg)) sf_delete_sfmeta($msg[0]['meta_id']);
  501. }
  502. $mess = __('Policy Documents Updated', "sforum");
  503. return $mess;
  504. }
  505. function sfa_save_mobile_data()
  506. {
  507. check_admin_referer('forum-adminform_mobile', 'forum-adminform_mobile');
  508. $sfmobile = array();
  509. $sfmobile['browsers'] = sf_filter_text_save(trim($_POST['sfbrowsers']));
  510. $sfmobile['touch'] = sf_filter_text_save(trim($_POST['sftouch']));
  511. sf_update_option('sfmobile', $sfmobile);
  512. $mess = __('Mobile Support Updated', "sforum");
  513. return $mess;
  514. }
  515. #= Components Save Support Routines =================
  516. # restore the full TM toolbar as supplied
  517. function sfa_restore_toolbar_defaults()
  518. {
  519. # Load up current from sfmeta (User)
  520. $tbmetauser = sf_get_sfmeta('tinymce_toolbar', 'user');
  521. $tbmetadefault = sf_get_sfmeta('tinymce_toolbar', 'default');
  522. sf_update_sfmeta('tinymce_toolbar', 'user', $tbmetadefault[0]['meta_value'], $tbmetauser[0]['meta_id']);
  523. $mess = __('Toolbar Restored', "sforum");
  524. return $mess;
  525. }
  526. function sfa_remove_toolbar_buttons($tblist)
  527. {
  528. # Load up current from sfmeta
  529. $tbmeta = sf_get_sfmeta('tinymce_toolbar', 'user');
  530. $current = unserialize($tbmeta[0]['meta_value']);
  531. $tblist = explode("&", $tblist);
  532. $buttons = array();
  533. $plugins = array();
  534. foreach($tblist as $item)
  535. {
  536. $thisone = explode("_", $item);
  537. if($thisone[0]=="button")
  538. {
  539. $buttons[] = $thisone[1];
  540. } else {
  541. $plugins[] = $thisone[1];
  542. }
  543. }
  544. if($buttons) sort($buttons, SORT_NUMERIC);
  545. $index = 0;
  546. $newarray = array();
  547. foreach($current['tbar_buttons'] as $btn)
  548. {
  549. if(!in_array($index, $buttons))
  550. {
  551. $newarray[] = $btn;
  552. }
  553. $index++;
  554. }
  555. $current['tbar_buttons'] = $newarray;
  556. if($plugins) sort($plugins, SORT_NUMERIC);
  557. $index = 0;
  558. $newarray = array();
  559. foreach($current['tbar_buttons_add'] as $btn)
  560. {
  561. if(!in_array($index, $plugins))
  562. {
  563. $newarray[] = $btn;
  564. }
  565. $index++;
  566. }
  567. $current['tbar_buttons_add'] = $newarray;
  568. sf_update_sfmeta('tinymce_toolbar', 'user', serialize($current), $tbmeta[0]['meta_id']);
  569. $mess = __('Toolbar Updated', "sforum");
  570. return $mess;
  571. }
  572. # Save toolbar changes - re-ordering of buttons
  573. function sfa_reorder_toolbar_buttons($stanlist, $pluglist)
  574. {
  575. # Load up current from sfmeta
  576. $tbmeta = sf_get_sfmeta('tinymce_toolbar', 'user');
  577. $current = unserialize($tbmeta[0]['meta_value']);
  578. if($stanlist)
  579. {
  580. $stanlist = explode("&", $stanlist);
  581. $newarray = array();
  582. foreach($stanlist as $btn)
  583. {
  584. $thisone = explode("=", $btn);
  585. $newarray[] = $current['tbar_buttons'][$thisone[1]];
  586. }
  587. $current['tbar_buttons'] = $newarray;
  588. }
  589. if($pluglist)
  590. {
  591. $pluglist = explode("&", $pluglist);
  592. $newarray = array();
  593. foreach($pluglist as $btn)
  594. {
  595. $thisone = explode("=", $btn);
  596. $newarray[] = $current['tbar_buttons_add'][$thisone[1]];
  597. }
  598. $current['tbar_buttons_add'] = $newarray;
  599. }
  600. sf_update_sfmeta('tinymce_toolbar', 'user', serialize($current), $tbmeta[0]['meta_id']);
  601. $mess = __('Toolbar Updated', "sforum").$mess;
  602. return $mess;
  603. }
  604. ?>