PageRenderTime 51ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://bitbucket.org/openfarmtech/weblog-content
PHP | 717 lines | 534 code | 128 blank | 55 comment | 150 complexity | 0a13885bc2250a1ad1f23f0c313d4c0c MD5 | raw file
Possible License(s): GPL-2.0, AGPL-1.0, LGPL-2.0, LGPL-3.0, BSD-3-Clause, GPL-3.0, LGPL-2.1, AGPL-3.0, CC-BY-SA-3.0
  1. <?php
  2. /*
  3. Simple:Press
  4. Admin Options Save Options Support Functions
  5. $LastChangedDate: 2010-05-21 08:26:36 -0700 (Fri, 21 May 2010) $
  6. $Rev: 4044 $
  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. return $mess;
  253. }
  254. #= Save Upload Options ===============================
  255. function sfa_save_uploads_data()
  256. {
  257. check_admin_referer('forum-adminform_uploads', 'forum-adminform_uploads');
  258. $sfuploads = '';
  259. if (isset($_POST['privatefolder'])) { $sfuploads['privatefolder'] = true; } else { $sfuploads['privatefolder'] = false; }
  260. if (isset($_POST['showmode'])) { $sfuploads['showmode'] = true; } else { $sfuploads['showmode'] = false; }
  261. $sfuploads['thumbsize'] = sf_esc_int($_POST['thumbsize']);
  262. $sfuploads['pagecount'] = sf_esc_int($_POST['pagecount']);
  263. $sfuploads['imagetypes'] = sf_filter_title_save(trim($_POST['imagetypes']));
  264. $sfuploads['imagemaxsize'] = sf_esc_int($_POST['imagemaxsize']);
  265. $sfuploads['mediatypes'] = sf_filter_title_save(trim($_POST['mediatypes']));
  266. $sfuploads['mediamaxsize'] = sf_esc_int($_POST['mediamaxsize']);
  267. $sfuploads['filetypes'] = sf_filter_title_save(trim($_POST['filetypes']));
  268. $sfuploads['filemaxsize'] = sf_esc_int($_POST['filemaxsize']);
  269. $sfuploads['prohibited'] = sf_filter_title_save(trim($_POST['prohibited']));
  270. $sfuploads['deftab'] = sf_esc_int(trim($_POST['sfdeftab']));
  271. sf_update_option('sfuploads', $sfuploads);
  272. $mess = __('Upload Options Updated', "sforum");
  273. return $mess;
  274. }
  275. #= Save Topic Status Sets ===============================
  276. function sfa_save_topicstatus_data()
  277. {
  278. check_admin_referer('forum-adminform_topicstatus', 'forum-adminform_topicstatus');
  279. # Topic Status Sets ---------------------
  280. if (isset($_POST['sftopstatname'][0]))
  281. {
  282. for ($x=0; $x<count($_POST['sftopstatid']); $x++)
  283. {
  284. $type = 'topic-status';
  285. $key = sf_filter_title_save(trim($_POST['sftopstatname'][$x]));
  286. $value = sf_filter_title_save(trim($_POST['sftopstatwords'][$x]));
  287. if(!empty($_POST['sftopstatid'][$x]))
  288. {
  289. if(isset($_POST['sftopstatdel'][$x]) && $_POST['sftopstatdel'][$x] == 'on')
  290. {
  291. sf_delete_sfmeta(sf_esc_int($_POST['sftopstatid'][$x]));
  292. } else {
  293. sf_update_sfmeta($type, $key, $value, sf_esc_int($_POST['sftopstatid'][$x]));
  294. }
  295. } else {
  296. sf_add_sfmeta($type, $key, $value);
  297. }
  298. }
  299. }
  300. $mess = __('Topic Status Component Updated', "sforum");
  301. return $mess;
  302. }
  303. #= Save Forum Rankings ===============================
  304. function sfa_save_forumranks_data()
  305. {
  306. # save forum ranks
  307. for ($x=0; $x<count($_POST['rankdesc']); $x++)
  308. {
  309. if (!empty($_POST['rankdesc'][$x]))
  310. {
  311. $rankdata = array();
  312. $rankdata['posts'] = sf_esc_int($_POST['rankpost'][$x]);
  313. $rankdata['usergroup'] = $_POST['rankug'][$x];
  314. $rankdata['badge'] = $_POST['rankbadge'][$x];
  315. sf_add_sfmeta('forum_rank', sf_filter_title_save(trim($_POST['rankdesc'][$x])), serialize($rankdata));
  316. }
  317. }
  318. $mess = __('Forum Ranks Updated', "sforum");
  319. return $mess;
  320. }
  321. #= Save Special Rankins ===============================
  322. function sfa_add_specialrank()
  323. {
  324. check_admin_referer('special-rank-new', 'special-rank-new');
  325. # save special forum ranks
  326. if (!empty($_POST['specialrank']))
  327. {
  328. $rankdata = array();
  329. $rankdata['badge'] = '';
  330. sf_add_sfmeta('special_rank', sf_filter_title_save(trim($_POST['specialrank'])), serialize($rankdata));
  331. }
  332. $mess = __('Special Rank Added', "sforum");
  333. return $mess;
  334. }
  335. #= Save Special Rankins ===============================
  336. function sfa_update_specialrank($id)
  337. {
  338. check_admin_referer('special-rank-update', 'special-rank-update');
  339. # save special forum ranks
  340. if (!empty($_POST['specialrankdesc']))
  341. {
  342. $desc = $_POST['specialrankdesc'];
  343. $badge = $_POST['specialrankbadge'];
  344. $rank = sf_get_sfmeta('special_rank', false, $id);
  345. $rankdata = unserialize($rank[0]['meta_value']);
  346. $rankdata['badge'] = $badge[$id];
  347. sf_update_sfmeta('special_rank', sf_filter_title_save(trim($desc[$id])), serialize($rankdata), $id);
  348. }
  349. $mess = __('Special Rank Updated', "sforum");
  350. return $mess;
  351. }
  352. function sfa_add_special_rank_member($id)
  353. {
  354. check_admin_referer('special-rank-add', 'special-rank-add');
  355. $user_id_list = array_unique($_POST['amember_id']);
  356. if (empty($user_id_list)) return;
  357. # set up the users with special rank
  358. $rank = sf_get_sfmeta('special_rank', false, $id);
  359. $rankdata = unserialize($rank[0]['meta_value']);
  360. $ranks['badge'] = $rankdata['badge'];
  361. $ranks['users'] = $rankdata['users'];
  362. # add the new users
  363. for ($x=0; $x<count($user_id_list); $x++)
  364. {
  365. $ranks['users'][] = sf_esc_int($user_id_list[$x]);
  366. }
  367. sf_update_sfmeta('special_rank', sf_filter_title_save($rank[0]['meta_key']), serialize($ranks), $id);
  368. $mess = __("User(s) Added to Special Forum Rank", "sforum");
  369. return $mess;
  370. }
  371. function sfa_del_special_rank_member($id)
  372. {
  373. check_admin_referer('special-rank-del', 'special-rank-del');
  374. $user_id_list = array_unique($_POST['dmember_id']);
  375. if (empty($user_id_list)) return;
  376. # remove the users from the special rank
  377. $rank = sf_get_sfmeta('special_rank', false, $id);
  378. $rankdata = unserialize($rank[0]['meta_value']);
  379. $ranks['badge'] = $rankdata['badge'];
  380. $ranks['users'] = $rankdata['users'];
  381. for( $x=0; $x<count($user_id_list); $x++)
  382. {
  383. $newlist = '';
  384. $user_id = sf_esc_int($user_id_list[$x]);
  385. foreach ($ranks['users'] as $userid)
  386. {
  387. if ($user_id != $userid)
  388. {
  389. $newlist[] = $userid;
  390. }
  391. }
  392. $ranks['users'] = $newlist;
  393. }
  394. sf_update_sfmeta('special_rank', sf_filter_title_save($rank[0]['meta_key']), serialize($ranks), $id);
  395. $mess = __("User(s) Deleted From Special Forum Rank", "sforum");
  396. return $mess;
  397. }
  398. #= Save Custom Messages ===============================
  399. function sfa_save_messages_data()
  400. {
  401. check_admin_referer('forum-adminform_messages', 'forum-adminform_messages');
  402. # custom message for editor
  403. $sfpostmsg = array();
  404. $sfpostmsg['sfpostmsgtext'] = sf_filter_text_save(trim($_POST['sfpostmsgtext']));
  405. $sfpostmsg['sfpostmsgtopic'] = $_POST['sfpostmsgtopic'];
  406. $sfpostmsg['sfpostmsgpost'] = $_POST['sfpostmsgpost'];
  407. sf_update_option('sfpostmsg', $sfpostmsg);
  408. sf_update_option('sfeditormsg', sf_filter_text_save(trim($_POST['sfeditormsg'])));
  409. $mess = __('Custom Messages Updated', "sforum");
  410. return $mess;
  411. }
  412. #= Save Custom Icons ===============================
  413. function sfa_save_icons_data()
  414. {
  415. check_admin_referer('forum-adminform_icons', 'forum-adminform_icons');
  416. $mess='';
  417. for ($x=0; $x<3; $x++)
  418. {
  419. $custom='cusicon'.$x;
  420. if (!empty($_POST[$custom]))
  421. {
  422. $icon = $_POST[$custom];
  423. $path = SFCUSTOM.$icon;
  424. if(!file_exists($path))
  425. {
  426. $mess.= "* ".sprintf(__("Custom Icon '%s' does not exist", "sforum"), $icon).'<br />';
  427. }
  428. }
  429. }
  430. # Save Custom Icons (3)
  431. $sfcustom = array();
  432. $sfcustom[0]['custext'] = sf_filter_title_save(trim($_POST['custext0']));
  433. $sfcustom[0]['cuslink'] = sf_filter_save_cleanurl($_POST['cuslink0']);
  434. $sfcustom[0]['cusicon'] = sf_filter_title_save(trim($_POST['cusicon0']));
  435. $sfcustom[1]['custext'] = sf_filter_title_save(trim($_POST['custext1']));
  436. $sfcustom[1]['cuslink'] = sf_filter_save_cleanurl($_POST['cuslink1']);
  437. $sfcustom[1]['cusicon'] = sf_filter_title_save(trim($_POST['cusicon1']));
  438. $sfcustom[2]['custext'] = sf_filter_title_save(trim($_POST['custext2']));
  439. $sfcustom[2]['cuslink'] = sf_filter_save_cleanurl($_POST['cuslink2']);
  440. $sfcustom[2]['cusicon'] = sf_filter_title_save(trim($_POST['cusicon2']));
  441. sf_update_option('sfcustom', $sfcustom);
  442. $mess = __('Custom Icons Updated', "sforum");
  443. return $mess;
  444. }
  445. function sfa_save_tags_data()
  446. {
  447. check_admin_referer('forum-adminform_tags', 'forum-adminform_tags');
  448. $mess = __('Options Updated', "sforum");
  449. sfa_update_check_option('sfuseannounce');
  450. sfa_update_check_option('sfannouncelist');
  451. sf_update_option('sfannouncecount', sf_esc_int($_POST['sfannouncecount']));
  452. sf_update_option('sfannouncehead', sf_filter_text_save(trim($_POST['sfannouncehead'])));
  453. sf_update_option('sfannouncetext', sf_filter_text_save(trim($_POST['sfannouncetext'])));
  454. sfa_update_check_option('sfannounceauto');
  455. sf_update_option('sfannouncetime', sf_esc_int($_POST['sfannouncetime']));
  456. return $mess;
  457. }
  458. function sfa_save_policies_data()
  459. {
  460. check_admin_referer('forum-adminform_policies', 'forum-adminform_policies');
  461. # set up some more allowed tags for the textareas.
  462. # login
  463. $sfpolicy = sf_get_option('sfpolicy');
  464. if (isset($_POST['sfregtext'])) { $sfpolicy['sfregtext'] = true; } else { $sfpolicy['sfregtext'] = false; }
  465. if (isset($_POST['sfregcheck'])) { $sfpolicy['sfregcheck'] = true; } else { $sfpolicy['sfregcheck'] = false; }
  466. if (isset($_POST['sfreglink'])) { $sfpolicy['sfreglink'] = true; } else { $sfpolicy['sfreglink'] = false; }
  467. if (isset($_POST['sfprivlink'])) { $sfpolicy['sfprivlink'] = true; } else { $sfpolicy['sfprivlink'] = false; }
  468. $sfpolicy['sfregfile'] = sf_filter_filename_save(trim($_POST['sfregfile']));
  469. $sfpolicy['sfprivfile'] = sf_filter_filename_save(trim($_POST['sfprivfile']));
  470. sf_update_option('sfpolicy', $sfpolicy);
  471. # Registration text - if set update, otherwise its empty, so remove
  472. if ($_POST['sfregpolicy'] != '')
  473. {
  474. sf_add_sfmeta('registration', 'policy', sf_filter_text_save(trim($_POST['sfregpolicy'])));
  475. } else {
  476. $msg = sf_get_sfmeta('registration', 'policy');
  477. if (!empty($msg)) sf_delete_sfmeta($msg[0]['meta_id']);
  478. }
  479. # Prvacy text - if set update, otherwise its empty, so remove
  480. if ($_POST['sfprivpolicy'] != '')
  481. {
  482. sf_add_sfmeta('privacy', 'policy', sf_filter_text_save(trim($_POST['sfprivpolicy'])));
  483. } else {
  484. $msg = sf_get_sfmeta('privacy', 'policy');
  485. if (!empty($msg)) sf_delete_sfmeta($msg[0]['meta_id']);
  486. }
  487. $mess = __('Policy Documents Updated', "sforum");
  488. return $mess;
  489. }
  490. function sfa_save_mobile_data()
  491. {
  492. check_admin_referer('forum-adminform_mobile', 'forum-adminform_mobile');
  493. $sfmobile = array();
  494. $sfmobile['browsers'] = sf_filter_text_save(trim($_POST['sfbrowsers']));
  495. $sfmobile['touch'] = sf_filter_text_save(trim($_POST['sftouch']));
  496. sf_update_option('sfmobile', $sfmobile);
  497. $mess = __('Mobile Support Updated', "sforum");
  498. return $mess;
  499. }
  500. #= Components Save Support Routines =================
  501. # restore the full TM toolbar as supplied
  502. function sfa_restore_toolbar_defaults()
  503. {
  504. # Load up current from sfmeta (User)
  505. $tbmetauser = sf_get_sfmeta('tinymce_toolbar', 'user');
  506. $tbmetadefault = sf_get_sfmeta('tinymce_toolbar', 'default');
  507. sf_update_sfmeta('tinymce_toolbar', 'user', $tbmetadefault[0]['meta_value'], $tbmetauser[0]['meta_id']);
  508. $mess = __('Toolbar Restored', "sforum");
  509. return $mess;
  510. }
  511. function sfa_remove_toolbar_buttons($tblist)
  512. {
  513. # Load up current from sfmeta
  514. $tbmeta = sf_get_sfmeta('tinymce_toolbar', 'user');
  515. $current = unserialize($tbmeta[0]['meta_value']);
  516. $tblist = explode("&", $tblist);
  517. $buttons = array();
  518. $plugins = array();
  519. foreach($tblist as $item)
  520. {
  521. $thisone = explode("_", $item);
  522. if($thisone[0]=="button")
  523. {
  524. $buttons[] = $thisone[1];
  525. } else {
  526. $plugins[] = $thisone[1];
  527. }
  528. }
  529. if($buttons) sort($buttons, SORT_NUMERIC);
  530. $index = 0;
  531. $newarray = array();
  532. foreach($current['tbar_buttons'] as $btn)
  533. {
  534. if(!in_array($index, $buttons))
  535. {
  536. $newarray[] = $btn;
  537. }
  538. $index++;
  539. }
  540. $current['tbar_buttons'] = $newarray;
  541. if($plugins) sort($plugins, SORT_NUMERIC);
  542. $index = 0;
  543. $newarray = array();
  544. foreach($current['tbar_buttons_add'] as $btn)
  545. {
  546. if(!in_array($index, $plugins))
  547. {
  548. $newarray[] = $btn;
  549. }
  550. $index++;
  551. }
  552. $current['tbar_buttons_add'] = $newarray;
  553. sf_update_sfmeta('tinymce_toolbar', 'user', serialize($current), $tbmeta[0]['meta_id']);
  554. $mess = __('Toolbar Updated', "sforum");
  555. return $mess;
  556. }
  557. # Save toolbar changes - re-ordering of buttons
  558. function sfa_reorder_toolbar_buttons($stanlist, $pluglist)
  559. {
  560. # Load up current from sfmeta
  561. $tbmeta = sf_get_sfmeta('tinymce_toolbar', 'user');
  562. $current = unserialize($tbmeta[0]['meta_value']);
  563. if($stanlist)
  564. {
  565. $stanlist = explode("&", $stanlist);
  566. $newarray = array();
  567. foreach($stanlist as $btn)
  568. {
  569. $thisone = explode("=", $btn);
  570. $newarray[] = $current['tbar_buttons'][$thisone[1]];
  571. }
  572. $current['tbar_buttons'] = $newarray;
  573. }
  574. if($pluglist)
  575. {
  576. $pluglist = explode("&", $pluglist);
  577. $newarray = array();
  578. foreach($pluglist as $btn)
  579. {
  580. $thisone = explode("=", $btn);
  581. $newarray[] = $current['tbar_buttons_add'][$thisone[1]];
  582. }
  583. $current['tbar_buttons_add'] = $newarray;
  584. }
  585. sf_update_sfmeta('tinymce_toolbar', 'user', serialize($current), $tbmeta[0]['meta_id']);
  586. $mess = __('Toolbar Updated', "sforum").$mess;
  587. return $mess;
  588. }
  589. ?>