PageRenderTime 42ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://bitbucket.org/openfarmtech/weblog-content
PHP | 189 lines | 144 code | 33 blank | 12 comment | 51 complexity | cac2b0a3bb1ade22e4742625429ed1e1 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 Profile Update Support Functions
  5. $LastChangedDate: 2010-03-26 16:38:27 -0700 (Fri, 26 Mar 2010) $
  6. $Rev: 3818 $
  7. */
  8. if (preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF']))
  9. {
  10. die('Access Denied');
  11. }
  12. #= Save Options Data ===============================
  13. function sfa_save_options_data()
  14. {
  15. check_admin_referer('forum-adminform_options', 'forum-adminform_options');
  16. $mess = __("Profile Options Updated", "sforum");
  17. $sfprofile=sf_get_option('sfprofile');
  18. $sfprofile['nameformat'] = sf_esc_int($_POST['nameformat']);
  19. $sfprofile['displaymode'] = sf_esc_int($_POST['displaymode']);
  20. $sfprofile['displaypage'] = sf_filter_save_cleanurl($_POST['displaypage']);
  21. $sfprofile['displayquery'] = sf_filter_title_save(trim($_POST['displayquery']));
  22. $sfprofile['formmode'] = sf_esc_int($_POST['formmode']);
  23. $sfprofile['formpage'] = sf_filter_save_cleanurl($_POST['formpage']);
  24. $sfprofile['formquery'] = sf_filter_title_save(trim($_POST['formquery']));
  25. $sfprofile['photosmax'] = sf_esc_int($_POST['photosmax']);
  26. $sfprofile['photoswidth'] = sf_esc_int($_POST['photoswidth']);
  27. if($sfprofile['photosmax'] && $sfprofile['photoswidth']==0)
  28. {
  29. $sfprofile['photoswidth']=300;
  30. }
  31. $sfsigimagesize = array();
  32. $sfsigimagesize['sfsigwidth'] = sf_esc_int($_POST['sfsigwidth']);
  33. $sfsigimagesize['sfsigheight'] = sf_esc_int($_POST['sfsigheight']);
  34. sf_update_option('sfsigimagesize', $sfsigimagesize);
  35. if (isset($_POST['firstvisit'])) { $sfprofile['firstvisit'] = true; } else { $sfprofile['firstvisit'] = false; }
  36. if (isset($_POST['forcepw'])) { $sfprofile['forcepw'] = true; } else { $sfprofile['forcepw'] = false; }
  37. if (isset($_POST['displayinforum'])) { $sfprofile['displayinforum'] = true; } else { $sfprofile['displayinforum'] = false; }
  38. if (isset($_POST['forminforum'])) { $sfprofile['forminforum'] = true; } else { $sfprofile['forminforum'] = false; }
  39. if (isset($_POST['profileinstats'])) { $sfprofile['profileinstats'] = true; } else { $sfprofile['profileinstats'] = false; }
  40. $sfprofile['profilelink'] = sf_esc_int($_POST['profilelink']);
  41. $sfprofile['weblink'] = sf_esc_int($_POST['weblink']);
  42. if($_POST['profilelink'] != 3 && ($_POST['profilelink'] == $_POST['weblink']))
  43. {
  44. $mess.= '<br />'.__("Profile and Website Links can not be the same", "sforum");
  45. $sfprofile['weblink']=3;
  46. }
  47. $sfprofile['sfprofiletext'] = sf_filter_text_save(trim($_POST['sfprofiletext']));
  48. sf_update_option('sfprofile', $sfprofile);
  49. return $mess;
  50. }
  51. #= Save Manage Data ===============================
  52. function sfa_save_data_data()
  53. {
  54. check_admin_referer('forum-adminform_data', 'forum-adminform_data');
  55. $mess = __("Profile Data Items Updated", "sforum");
  56. $sfprofile = sf_get_option('sfprofile');
  57. foreach($sfprofile['require'] as $field=>$value)
  58. {
  59. if(isset($_POST['r-'.$field]) ? $sfprofile['require'][$field]=true : $sfprofile['require'][$field]=false);
  60. }
  61. foreach($sfprofile['include'] as $field=>$value)
  62. {
  63. if(isset($_POST['i-'.$field]) ? $sfprofile['include'][$field]=true : $sfprofile['include'][$field]=false);
  64. # if required then this MUST be set true
  65. if($sfprofile['require'][$field]) $sfprofile['include'][$field]=true;
  66. }
  67. foreach($sfprofile['display'] as $field=>$value)
  68. {
  69. if(isset($_POST['d-'.$field]) ? $sfprofile['display'][$field]=true : $sfprofile['display'][$field]=false);
  70. }
  71. foreach($sfprofile['system'] as $field=>$value)
  72. {
  73. if(isset($_POST[$field]) ? $sfprofile['system'][$field]=true : $sfprofile['system'][$field]=false);
  74. }
  75. foreach($sfprofile['label'] as $field=>$value)
  76. {
  77. if(!empty($_POST['l-'.$field]) ? $label=$_POST['l-'.$field] : $label=$field);
  78. $sfprofile['label'][$field] = sf_filter_title_save($label);
  79. }
  80. sf_update_option('sfprofile', $sfprofile);
  81. return $mess;
  82. }
  83. #= Save Custom Fields ===============================
  84. function sfa_save_fields_data()
  85. {
  86. check_admin_referer('forum-adminform_fields', 'forum-adminform_fields');
  87. $mess = '';
  88. $fields = array();
  89. $sfprofile = sf_get_option('sfprofile');
  90. for($x=0; $x<count(array_unique($_POST['cfieldname'])); $x++)
  91. {
  92. if (!empty($_POST['cfieldname'][$x]))
  93. {
  94. $fields = array();
  95. $fields['type'] = sf_esc_str($_POST['cfieldtype'][$x]);
  96. $fields['selectvalues'] = sf_filter_title_save(trim($_POST['cfieldvalues'][$x]));
  97. # ensure type selected
  98. if ($fields['type'] != 'none')
  99. {
  100. if (($fields['type'] == 'select' || $fields['type'] == 'radio') && empty($fields['selectvalues']))
  101. {
  102. $mess .= __('One Select/Radio Custom Field Missing Values - Not Updated!', 'sforum').'<br />';
  103. continue;
  104. }
  105. $fname = sf_create_slug(sf_filter_title_save(trim($_POST['cfieldname'][$x])),'');
  106. $fname = preg_replace('|[^a-z0-9_]|i', '', $fname);
  107. sf_add_sfmeta('custom_field', $fname, serialize($fields));
  108. # add to admins list
  109. $sfprofile['require'][$fname] = true;
  110. $sfprofile['include'][$fname] = true;
  111. $sfprofile['display'][$fname] = true;
  112. $sfprofile['label'][$fname] = sf_filter_title_save($fname);
  113. } else {
  114. $mess .= __('One Custom Field Missing Type - Not Updated!', 'sforum').'<br />';
  115. }
  116. }
  117. }
  118. sf_update_option('sfprofile', $sfprofile);
  119. $mess .= __('Custom Fields Updated!', 'sforum');
  120. return $mess;
  121. }
  122. function sfa_save_avatars_data()
  123. {
  124. check_admin_referer('forum-adminform_avatars', 'forum-adminform_avatars');
  125. $mess = '';
  126. $sfavatars = array();
  127. if (isset($_POST['sfshowavatars'])) { $sfavatars['sfshowavatars'] = true; } else { $sfavatars['sfshowavatars'] = false; }
  128. if (isset($_POST['sfavataruploads'])) { $sfavatars['sfavataruploads'] = true; } else { $sfavatars['sfavataruploads'] = false; }
  129. if (isset($_POST['sfavatarpool'])) { $sfavatars['sfavatarpool'] = true; } else { $sfavatars['sfavatarpool'] = false; }
  130. if (isset($_POST['sfavatarremote'])) { $sfavatars['sfavatarremote'] = true; } else { $sfavatars['sfavatarremote'] = false; }
  131. if (isset($_POST['sfavatarreplace'])) { $sfavatars['sfavatarreplace'] = true; } else { $sfavatars['sfavatarreplace'] = false; }
  132. $sfavatars['sfavatarsize'] = sf_esc_int($_POST['sfavatarsize']);
  133. $sfavatars['sfavatarfilesize'] = sf_esc_int($_POST['sfavatarfilesize']);
  134. if(empty($sfavatars['sfavatarsize']) || $sfavatars['sfavatarsize'] == 0) $sfavatars['sfavatarsize'] = 50;
  135. if(empty($sfavatars['sfavatarfilesize']) || $sfavatars['sfavatarfilesize'] == 0) $sfavatars['sfavatarfilesize'] = 10240;
  136. $sfavatars['sfgmaxrating'] = sf_esc_int($_POST['sfgmaxrating']);
  137. $current = array();
  138. $current = sf_get_option('sfavatars');
  139. if ($_POST['sfavataropts'])
  140. {
  141. $list = explode("&", $_POST['sfavataropts']);
  142. $newarray = array();
  143. foreach($list as $item)
  144. {
  145. $thisone = explode("=", $item);
  146. $newarray[] = $thisone[1];
  147. }
  148. $sfavatars['sfavatarpriority'] = $newarray;
  149. } else {
  150. $sfavatars['sfavatarpriority'] = $current['sfavatarpriority'];
  151. }
  152. sf_update_option('sfavatars', $sfavatars);
  153. $mess .= __('Avatars Updated!', 'sforum');
  154. return $mess;
  155. }
  156. ?>