ManageSettings.php 76 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247
  1. <?php
  2. /**
  3. * This file is here to make it easier for installed mods to have
  4. * settings and options.
  5. *
  6. * Simple Machines Forum (SMF)
  7. *
  8. * @package SMF
  9. * @author Simple Machines http://www.simplemachines.org
  10. * @copyright 2013 Simple Machines and individual contributors
  11. * @license http://www.simplemachines.org/about/smf/license.php BSD
  12. *
  13. * @version 2.1 Alpha 1
  14. */
  15. if (!defined('SMF'))
  16. die('No direct access...');
  17. /**
  18. * This function makes sure the requested subaction does exists, if it doesn't, it sets a default action or.
  19. *
  20. * @param array $subActions = array() An array containing all possible subactions.
  21. * @param string $defaultAction = '' the default action to be called if no valid subaction was found.
  22. */
  23. function loadGeneralSettingParameters($subActions = array(), $defaultAction = '')
  24. {
  25. global $context, $txt, $sourcedir;
  26. // You need to be an admin to edit settings!
  27. isAllowedTo('admin_forum');
  28. loadLanguage('Help');
  29. loadLanguage('ManageSettings');
  30. // Will need the utility functions from here.
  31. require_once($sourcedir . '/ManageServer.php');
  32. $context['sub_template'] = 'show_settings';
  33. // By default do the basic settings.
  34. $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (!empty($defaultAction) ? $defaultAction : array_pop($temp = array_keys($subActions)));
  35. $context['sub_action'] = $_REQUEST['sa'];
  36. }
  37. /**
  38. * This function passes control through to the relevant tab.
  39. */
  40. function ModifyFeatureSettings()
  41. {
  42. global $context, $txt, $scripturl, $modSettings, $settings;
  43. $context['page_title'] = $txt['modSettings_title'];
  44. $subActions = array(
  45. 'basic' => 'ModifyBasicSettings',
  46. 'layout' => 'ModifyLayoutSettings',
  47. 'karma' => 'ModifyKarmaSettings',
  48. 'sig' => 'ModifySignatureSettings',
  49. 'profile' => 'ShowCustomProfiles',
  50. 'profileedit' => 'EditCustomProfiles',
  51. );
  52. call_integration_hook('integrate_modify_features', array(&$subActions));
  53. // If karma is disabled don't show the setting page.
  54. if (!in_array('k', $context['admin_features']))
  55. unset($subActions['karma']);
  56. loadGeneralSettingParameters($subActions, 'basic');
  57. // Load up all the tabs...
  58. $context[$context['admin_menu_name']]['tab_data'] = array(
  59. 'title' => $txt['modSettings_title'],
  60. 'help' => 'featuresettings',
  61. 'description' => sprintf($txt['modSettings_desc'], $settings['theme_id'], $context['session_id'], $context['session_var']),
  62. 'tabs' => array(
  63. 'basic' => array(
  64. ),
  65. 'layout' => array(
  66. ),
  67. 'karma' => array(
  68. ),
  69. 'sig' => array(
  70. 'description' => $txt['signature_settings_desc'],
  71. ),
  72. 'profile' => array(
  73. 'description' => $txt['custom_profile_desc'],
  74. ),
  75. ),
  76. );
  77. // Call the right function for this sub-action.
  78. $subActions[$_REQUEST['sa']]();
  79. }
  80. /**
  81. * This function passes control through to the relevant security tab.
  82. */
  83. function ModifySecuritySettings()
  84. {
  85. global $context, $txt, $scripturl, $modSettings, $settings;
  86. $context['page_title'] = $txt['admin_security_moderation'];
  87. $subActions = array(
  88. 'general' => 'ModifyGeneralSecuritySettings',
  89. 'spam' => 'ModifySpamSettings',
  90. 'moderation' => 'ModifyModerationSettings',
  91. );
  92. call_integration_hook('integrate_modify_security', array(&$subActions));
  93. // If Warning System is disabled don't show the setting page
  94. if (!in_array('w', $context['admin_features']))
  95. unset($subActions['moderation']);
  96. loadGeneralSettingParameters($subActions, 'general');
  97. // Load up all the tabs...
  98. $context[$context['admin_menu_name']]['tab_data'] = array(
  99. 'title' => $txt['admin_security_moderation'],
  100. 'help' => 'securitysettings',
  101. 'description' => $txt['security_settings_desc'],
  102. 'tabs' => array(
  103. 'general' => array(
  104. ),
  105. 'spam' => array(
  106. 'description' => $txt['antispam_Settings_desc'] ,
  107. ),
  108. 'moderation' => array(
  109. ),
  110. ),
  111. );
  112. // Call the right function for this sub-action.
  113. $subActions[$_REQUEST['sa']]();
  114. }
  115. /**
  116. * This my friend, is for all the mod authors out there.
  117. */
  118. function ModifyModSettings()
  119. {
  120. global $context, $txt, $scripturl, $modSettings, $settings;
  121. $context['page_title'] = $txt['admin_modifications'];
  122. $subActions = array(
  123. 'general' => 'ModifyGeneralModSettings',
  124. // Mod authors, once again, if you have a whole section to add do it AFTER this line, and keep a comma at the end.
  125. );
  126. // Make it easier for mods to add new areas.
  127. call_integration_hook('integrate_modify_modifications', array(&$subActions));
  128. loadGeneralSettingParameters($subActions, 'general');
  129. // Load up all the tabs...
  130. $context[$context['admin_menu_name']]['tab_data'] = array(
  131. 'title' => $txt['admin_modifications'],
  132. 'help' => 'modsettings',
  133. 'description' => $txt['modification_settings_desc'],
  134. 'tabs' => array(
  135. 'general' => array(
  136. ),
  137. ),
  138. );
  139. // Call the right function for this sub-action.
  140. $subActions[$_REQUEST['sa']]();
  141. }
  142. /**
  143. * This is an overall control panel enabling/disabling lots of SMF's key feature components.
  144. *
  145. * @param $return_config
  146. */
  147. function ModifyCoreFeatures($return_config = false)
  148. {
  149. global $txt, $scripturl, $context, $settings, $sc, $modSettings;
  150. /* This is an array of all the features that can be enabled/disabled - each option can have the following:
  151. title - Text title of this item (If standard string does not exist).
  152. desc - Description of this feature (If standard string does not exist).
  153. settings - Array of settings to change (For each name => value) on enable - reverse is done for disable. If > 1 will not change value if set.
  154. setting_callback- Function that returns an array of settings to save - takes one parameter which is value for this feature.
  155. save_callback - Function called on save, takes state as parameter.
  156. */
  157. $core_features = array(
  158. // cd = calendar.
  159. 'cd' => array(
  160. 'url' => 'action=admin;area=managecalendar',
  161. 'settings' => array(
  162. 'cal_enabled' => 1,
  163. ),
  164. ),
  165. // k = karma.
  166. 'k' => array(
  167. 'url' => 'action=admin;area=featuresettings;sa=karma',
  168. 'settings' => array(
  169. 'karmaMode' => 2,
  170. ),
  171. ),
  172. // pm = post moderation.
  173. 'pm' => array(
  174. 'url' => 'action=admin;area=permissions;sa=postmod',
  175. 'setting_callback' => create_function('$value', '
  176. global $sourcedir;
  177. // Cant use warning post moderation if disabled!
  178. if (!$value)
  179. {
  180. require_once($sourcedir . \'/PostModeration.php\');
  181. approveAllData();
  182. return array(\'warning_moderate\' => 0);
  183. }
  184. else
  185. return array();
  186. '),
  187. ),
  188. // ps = Paid Subscriptions.
  189. 'ps' => array(
  190. 'url' => 'action=admin;area=paidsubscribe',
  191. 'settings' => array(
  192. 'paid_enabled' => 1,
  193. ),
  194. 'setting_callback' => create_function('$value', '
  195. global $smcFunc, $sourcedir;
  196. // Set the correct disabled value for scheduled task.
  197. $smcFunc[\'db_query\'](\'\', \'
  198. UPDATE {db_prefix}scheduled_tasks
  199. SET disabled = {int:disabled}
  200. WHERE task = {string:task}\',
  201. array(
  202. \'disabled\' => $value ? 0 : 1,
  203. \'task\' => \'paid_subscriptions\',
  204. )
  205. );
  206. // Should we calculate next trigger?
  207. if ($value)
  208. {
  209. require_once($sourcedir . \'/ScheduledTasks.php\');
  210. CalculateNextTrigger(\'paid_subscriptions\');
  211. }
  212. '),
  213. ),
  214. // w = warning.
  215. 'w' => array(
  216. 'url' => 'action=admin;area=securitysettings;sa=moderation',
  217. 'setting_callback' => create_function('$value', '
  218. global $modSettings;
  219. list ($modSettings[\'warning_enable\'], $modSettings[\'user_limit\'], $modSettings[\'warning_decrement\']) = explode(\',\', $modSettings[\'warning_settings\']);
  220. $warning_settings = ($value ? 1 : 0) . \',\' . $modSettings[\'user_limit\'] . \',\' . $modSettings[\'warning_decrement\'];
  221. if (!$value)
  222. {
  223. $returnSettings = array(
  224. \'warning_watch\' => 0,
  225. \'warning_moderate\' => 0,
  226. \'warning_mute\' => 0,
  227. );
  228. }
  229. elseif (empty($modSettings[\'warning_enable\']) && $value)
  230. {
  231. $returnSettings = array(
  232. \'warning_watch\' => 10,
  233. \'warning_moderate\' => 35,
  234. \'warning_mute\' => 60,
  235. );
  236. }
  237. else
  238. $returnSettings = array();
  239. $returnSettings[\'warning_settings\'] = $warning_settings;
  240. return $returnSettings;
  241. '),
  242. ),
  243. // Search engines
  244. 'sp' => array(
  245. 'url' => 'action=admin;area=sengines',
  246. 'settings' => array(
  247. 'spider_mode' => 1,
  248. ),
  249. 'setting_callback' => create_function('$value', '
  250. // Turn off the spider group if disabling.
  251. if (!$value)
  252. return array(\'spider_group\' => 0, \'show_spider_online\' => 0);
  253. '),
  254. 'on_save' => create_function('', '
  255. global $sourcedir, $modSettings;
  256. require_once($sourcedir . \'/ManageSearchEngines.php\');
  257. recacheSpiderNames();
  258. '),
  259. ),
  260. );
  261. // Anyone who would like to add a core feature?
  262. call_integration_hook('integrate_core_features', array(&$core_features));
  263. // Are we getting info for the help section.
  264. if ($return_config)
  265. {
  266. $return_data = array();
  267. foreach ($core_features as $id => $data)
  268. $return_data[] = array('switch', isset($data['title']) ? $data['title'] : $txt['core_settings_item_' . $id]);
  269. return $return_data;
  270. }
  271. loadGeneralSettingParameters();
  272. // Are we saving?
  273. if (isset($_POST['save']))
  274. {
  275. checkSession();
  276. if (isset($_GET['xml']))
  277. {
  278. $tokenValidation = validateToken('admin-core', 'post', false);
  279. if (empty($tokenValidation))
  280. return 'token_verify_fail';
  281. }
  282. else
  283. validateToken('admin-core');
  284. $setting_changes = array('admin_features' => array());
  285. // Cycle each feature and change things as required!
  286. foreach ($core_features as $id => $feature)
  287. {
  288. // Enabled?
  289. if (!empty($_POST['feature_' . $id]))
  290. $setting_changes['admin_features'][] = $id;
  291. // Setting values to change?
  292. if (isset($feature['settings']))
  293. {
  294. foreach ($feature['settings'] as $key => $value)
  295. {
  296. if (empty($_POST['feature_' . $id]) || (!empty($_POST['feature_' . $id]) && ($value < 2 || empty($modSettings[$key]))))
  297. $setting_changes[$key] = !empty($_POST['feature_' . $id]) ? $value : !$value;
  298. }
  299. }
  300. // Is there a call back for settings?
  301. if (isset($feature['setting_callback']))
  302. {
  303. $returned_settings = $feature['setting_callback'](!empty($_POST['feature_' . $id]));
  304. if (!empty($returned_settings))
  305. $setting_changes = array_merge($setting_changes, $returned_settings);
  306. }
  307. // Standard save callback?
  308. if (isset($feature['on_save']))
  309. $feature['on_save']();
  310. }
  311. // Make sure this one setting is a string!
  312. $setting_changes['admin_features'] = implode(',', $setting_changes['admin_features']);
  313. // Make any setting changes!
  314. updateSettings($setting_changes);
  315. // This is needed to let menus appear if cache > 2
  316. clean_cache('data');
  317. // Any post save things?
  318. foreach ($core_features as $id => $feature)
  319. {
  320. // Standard save callback?
  321. if (isset($feature['save_callback']))
  322. $feature['save_callback'](!empty($_POST['feature_' . $id]));
  323. }
  324. if (!isset($_REQUEST['xml']))
  325. redirectexit('action=admin;area=corefeatures;' . $context['session_var'] . '=' . $context['session_id']);
  326. }
  327. // Put them in context.
  328. $context['features'] = array();
  329. foreach ($core_features as $id => $feature)
  330. $context['features'][$id] = array(
  331. 'title' => isset($feature['title']) ? $feature['title'] : $txt['core_settings_item_' . $id],
  332. 'desc' => isset($feature['desc']) ? $feature['desc'] : $txt['core_settings_item_' . $id . '_desc'],
  333. 'enabled' => in_array($id, $context['admin_features']),
  334. 'state' => in_array($id, $context['admin_features']) ? 'on' : 'off',
  335. 'url' => !empty($feature['url']) ? $scripturl . '?' . $feature['url'] . ';' . $context['session_var'] . '=' . $context['session_id'] : '',
  336. 'image' => (file_exists($settings['theme_dir'] . '/images/admin/feature_' . $id . '.png') ? $settings['images_url'] : $settings['default_images_url']) . '/admin/feature_' . $id . '.png',
  337. );
  338. // Are they a new user?
  339. $context['is_new_install'] = !isset($modSettings['admin_features']);
  340. $context['force_disable_tabs'] = $context['is_new_install'];
  341. // Don't show them this twice!
  342. if ($context['is_new_install'])
  343. updateSettings(array('admin_features' => ''));
  344. // sub_template is already generic_xml and the token is created somewhere else
  345. if (isset($_REQUEST['xml']))
  346. return;
  347. $context['sub_template'] = 'core_features';
  348. $context['page_title'] = $txt['core_settings_title'];
  349. $context[$context['admin_menu_name']]['tab_data'] = array(
  350. 'title' => $txt['core_settings_title'],
  351. 'help' => '',
  352. 'description' => $txt['core_settings_desc'],
  353. );
  354. // We love our tokens.
  355. createToken('admin-core');
  356. }
  357. /**
  358. * Config array for chaning the basic forum settings
  359. * Accessed from ?action=admin;area=featuresettings;sa=basic;
  360. *
  361. * @param $return_config
  362. */
  363. function ModifyBasicSettings($return_config = false)
  364. {
  365. global $txt, $scripturl, $context, $settings, $sc, $modSettings;
  366. // We need to know if personal text is enabled, and if it's in the registration fields option.
  367. // If admins have set it up as an on-registration thing, they can't set a default value (because it'll never be used)
  368. $disabled_fields = isset($modSettings['disabled_profile_fields']) ? explode(',', $modSettings['disabled_profile_fields']) : array();
  369. $reg_fields = isset($modSettings['registration_fields']) ? explode(',', $modSettings['registration_fields']) : array();
  370. $can_personal_text = !in_array('personal_text', $disabled_fields) && !in_array('personal_text', $reg_fields);
  371. $config_vars = array(
  372. // Big Options... polls, sticky, bbc....
  373. array('select', 'pollMode', array($txt['disable_polls'], $txt['enable_polls'], $txt['polls_as_topics'])),
  374. '',
  375. // Basic stuff, titles, flash, permissions...
  376. array('check', 'allow_guestAccess'),
  377. array('check', 'enable_buddylist'),
  378. array('check', 'enable_unwatch'),
  379. array('check', 'allow_editDisplayName'),
  380. array('check', 'allow_hideOnline'),
  381. array('check', 'titlesEnable'),
  382. array('text', 'default_personal_text', 'subtext' => $txt['default_personal_text_note'], 'disabled' => !$can_personal_text),
  383. '',
  384. // Jquery source
  385. array('select', 'jquery_source', array('auto' => $txt['jquery_auto'], 'local' => $txt['jquery_local'], 'cdn' => $txt['jquery_cdn'], 'custom' => $txt['jquery_custom']), 'onchange' => 'if (this.value == \'custom\'){document.getElementById(\'jquery_custom\').disabled = false; } else {document.getElementById(\'jquery_custom\').disabled = true;}'),
  386. array('text', 'jquery_custom', 'javascript' => 'disabled', 'size' => 75),
  387. '',
  388. // SEO stuff
  389. array('check', 'queryless_urls', 'subtext' => '<strong>' . $txt['queryless_urls_note'] . '</strong>'),
  390. array('text', 'meta_keywords', 'subtext' => $txt['meta_keywords_note'], 'size' => 50),
  391. '',
  392. // Number formatting, timezones.
  393. array('text', 'time_format'),
  394. array('float', 'time_offset', 'subtext' => $txt['setting_time_offset_note'], 6, 'postinput' => $txt['hours']),
  395. 'default_timezone' => array('select', 'default_timezone', array()),
  396. '',
  397. // Who's online?
  398. array('check', 'who_enabled'),
  399. array('int', 'lastActive', 6, 'postinput' => $txt['minutes']),
  400. '',
  401. // Statistics.
  402. array('check', 'trackStats'),
  403. array('check', 'hitStats'),
  404. '',
  405. // Option-ish things... miscellaneous sorta.
  406. array('check', 'allow_disableAnnounce'),
  407. array('check', 'disallow_sendBody'),
  408. );
  409. // Get all the time zones.
  410. if (function_exists('timezone_identifiers_list') && function_exists('date_default_timezone_set'))
  411. {
  412. $all_zones = timezone_identifiers_list();
  413. // Make sure we set the value to the same as the printed value.
  414. foreach ($all_zones as $zone)
  415. $config_vars['default_timezone'][2][$zone] = $zone;
  416. }
  417. else
  418. unset($config_vars['default_timezone']);
  419. call_integration_hook('integrate_modify_basic_settings', array(&$config_vars));
  420. if ($return_config)
  421. return $config_vars;
  422. // Saving?
  423. if (isset($_GET['save']))
  424. {
  425. checkSession();
  426. // Prevent absurd boundaries here - make it a day tops.
  427. if (isset($_POST['lastActive']))
  428. $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440);
  429. call_integration_hook('integrate_save_basic_settings');
  430. saveDBSettings($config_vars);
  431. writeLog();
  432. redirectexit('action=admin;area=featuresettings;sa=basic');
  433. }
  434. $context['post_url'] = $scripturl . '?action=admin;area=featuresettings;save;sa=basic';
  435. $context['settings_title'] = $txt['mods_cat_features'];
  436. prepareDBSettingContext($config_vars);
  437. }
  438. /**
  439. * Settings really associated with general security aspects.
  440. *
  441. * @param $return_config
  442. */
  443. function ModifyGeneralSecuritySettings($return_config = false)
  444. {
  445. global $txt, $scripturl, $context, $settings, $sc, $modSettings;
  446. $config_vars = array(
  447. array('check', 'guest_hideContacts'),
  448. array('check', 'make_email_viewable'),
  449. '',
  450. array('int', 'failed_login_threshold'),
  451. array('int', 'loginHistoryDays'),
  452. '',
  453. array('check', 'securityDisable'),
  454. array('check', 'securityDisable_moderate'),
  455. '',
  456. // Reactive on email, and approve on delete
  457. array('check', 'send_validation_onChange'),
  458. array('check', 'approveAccountDeletion'),
  459. '',
  460. // Password strength.
  461. array('select', 'password_strength', array($txt['setting_password_strength_low'], $txt['setting_password_strength_medium'], $txt['setting_password_strength_high'])),
  462. array('check', 'enable_password_conversion'),
  463. '',
  464. // Reporting of personal messages?
  465. array('check', 'enableReportPM'),
  466. '',
  467. array('select', 'frame_security', array('SAMEORIGIN' => $txt['setting_frame_security_SAMEORIGIN'], 'DENY' => $txt['setting_frame_security_DENY'], 'DISABLE' => $txt['setting_frame_security_DISABLE'])),
  468. );
  469. call_integration_hook('integrate_general_security_settings', array(&$config_vars));
  470. if ($return_config)
  471. return $config_vars;
  472. // Saving?
  473. if (isset($_GET['save']))
  474. {
  475. checkSession();
  476. saveDBSettings($config_vars);
  477. call_integration_hook('integrate_save_general_security_settings');
  478. writeLog();
  479. redirectexit('action=admin;area=securitysettings;sa=general');
  480. }
  481. $context['post_url'] = $scripturl . '?action=admin;area=securitysettings;save;sa=general';
  482. $context['settings_title'] = $txt['mods_cat_security_general'];
  483. prepareDBSettingContext($config_vars);
  484. }
  485. /**
  486. * Allows modifying the global layout settings in the forum
  487. * Accessed through ?action=admin;area=featuresettings;sa=layout;
  488. *
  489. * @param $return_config
  490. */
  491. function ModifyLayoutSettings($return_config = false)
  492. {
  493. global $txt, $scripturl, $context, $settings, $sc;
  494. $config_vars = array(
  495. // Pagination stuff.
  496. array('check', 'compactTopicPagesEnable'),
  497. array('int', 'compactTopicPagesContiguous', null, $txt['contiguous_page_display'] . '<div class="smalltext">' . str_replace(' ', '&nbsp;', '"3" ' . $txt['to_display'] . ': <strong>1 ... 4 [5] 6 ... 9</strong>') . '<br />' . str_replace(' ', '&nbsp;', '"5" ' . $txt['to_display'] . ': <strong>1 ... 3 4 [5] 6 7 ... 9</strong>') . '</div>'),
  498. array('int', 'defaultMaxMembers'),
  499. '',
  500. // Stuff that just is everywhere - today, search, online, etc.
  501. array('select', 'todayMod', array($txt['today_disabled'], $txt['today_only'], $txt['yesterday_today'])),
  502. array('check', 'topbottomEnable'),
  503. array('check', 'onlineEnable'),
  504. array('check', 'enableVBStyleLogin'),
  505. '',
  506. // Automagic image resizing.
  507. array('int', 'max_image_width', 'subtext' => $txt['zero_for_no_limit']),
  508. array('int', 'max_image_height', 'subtext' => $txt['zero_for_no_limit']),
  509. '',
  510. // This is like debugging sorta.
  511. array('check', 'timeLoadPageEnable'),
  512. );
  513. call_integration_hook('integrate_layout_settings', array(&$config_vars));
  514. if ($return_config)
  515. return $config_vars;
  516. // Saving?
  517. if (isset($_GET['save']))
  518. {
  519. checkSession();
  520. call_integration_hook('integrate_save_layout_settings');
  521. saveDBSettings($config_vars);
  522. writeLog();
  523. redirectexit('action=admin;area=featuresettings;sa=layout');
  524. }
  525. $context['post_url'] = $scripturl . '?action=admin;area=featuresettings;save;sa=layout';
  526. $context['settings_title'] = $txt['mods_cat_layout'];
  527. prepareDBSettingContext($config_vars);
  528. }
  529. /**
  530. * Config array for chaning the karma settings
  531. * Accessed from ?action=admin;area=featuresettings;sa=karma;
  532. *
  533. * @param $return_config
  534. */
  535. function ModifyKarmaSettings($return_config = false)
  536. {
  537. global $txt, $scripturl, $context, $settings, $sc;
  538. $config_vars = array(
  539. // Karma - On or off?
  540. array('select', 'karmaMode', explode('|', $txt['karma_options'])),
  541. '',
  542. // Who can do it.... and who is restricted by time limits?
  543. array('int', 'karmaMinPosts', 6, 'postinput' => strtolower($txt['posts'])),
  544. array('float', 'karmaWaitTime', 6, 'postinput' => $txt['hours']),
  545. array('check', 'karmaTimeRestrictAdmins'),
  546. '',
  547. // What does it look like? [smite]?
  548. array('text', 'karmaLabel'),
  549. array('text', 'karmaApplaudLabel'),
  550. array('text', 'karmaSmiteLabel'),
  551. );
  552. call_integration_hook('integrate_karma_settings', array(&$config_vars));
  553. if ($return_config)
  554. return $config_vars;
  555. // Saving?
  556. if (isset($_GET['save']))
  557. {
  558. checkSession();
  559. call_integration_hook('integrate_save_karma_settings');
  560. saveDBSettings($config_vars);
  561. redirectexit('action=admin;area=featuresettings;sa=karma');
  562. }
  563. $context['post_url'] = $scripturl . '?action=admin;area=featuresettings;save;sa=karma';
  564. $context['settings_title'] = $txt['karma'];
  565. prepareDBSettingContext($config_vars);
  566. }
  567. /**
  568. * Moderation type settings - although there are fewer than we have you believe ;)
  569. *
  570. * @param bool $return_config = false
  571. */
  572. function ModifyModerationSettings($return_config = false)
  573. {
  574. global $txt, $scripturl, $context, $settings, $sc, $modSettings;
  575. $config_vars = array(
  576. // Warning system?
  577. array('int', 'warning_watch', 'subtext' => $txt['setting_warning_watch_note'], 'help' => 'warning_enable'),
  578. 'moderate' => array('int', 'warning_moderate', 'subtext' => $txt['setting_warning_moderate_note']),
  579. array('int', 'warning_mute', 'subtext' => $txt['setting_warning_mute_note']),
  580. 'rem1' => array('int', 'user_limit', 'subtext' => $txt['setting_user_limit_note']),
  581. 'rem2' => array('int', 'warning_decrement', 'subtext' => $txt['setting_warning_decrement_note']),
  582. array('select', 'warning_show', 'subtext' => $txt['setting_warning_show_note'], array($txt['setting_warning_show_mods'], $txt['setting_warning_show_user'], $txt['setting_warning_show_all'])),
  583. );
  584. call_integration_hook('integrate_moderation_settings', array(&$config_vars));
  585. if ($return_config)
  586. return $config_vars;
  587. // Cannot use moderation if post moderation is not enabled.
  588. if (!$modSettings['postmod_active'])
  589. unset($config_vars['moderate']);
  590. // Saving?
  591. if (isset($_GET['save']))
  592. {
  593. checkSession();
  594. // Make sure these don't have an effect.
  595. if (substr($modSettings['warning_settings'], 0, 1) != 1)
  596. {
  597. $_POST['warning_watch'] = 0;
  598. $_POST['warning_moderate'] = 0;
  599. $_POST['warning_mute'] = 0;
  600. }
  601. else
  602. {
  603. $_POST['warning_watch'] = min($_POST['warning_watch'], 100);
  604. $_POST['warning_moderate'] = $modSettings['postmod_active'] ? min($_POST['warning_moderate'], 100) : 0;
  605. $_POST['warning_mute'] = min($_POST['warning_mute'], 100);
  606. }
  607. // Fix the warning setting array!
  608. $_POST['warning_settings'] = '1,' . min(100, (int) $_POST['user_limit']) . ',' . min(100, (int) $_POST['warning_decrement']);
  609. $save_vars = $config_vars;
  610. $save_vars[] = array('text', 'warning_settings');
  611. unset($save_vars['rem1'], $save_vars['rem2']);
  612. call_integration_hook('integrate_save_karma_settings', array(&$save_vars));
  613. saveDBSettings($save_vars);
  614. redirectexit('action=admin;area=securitysettings;sa=moderation');
  615. }
  616. // We actually store lots of these together - for efficiency.
  617. list ($modSettings['warning_enable'], $modSettings['user_limit'], $modSettings['warning_decrement']) = explode(',', $modSettings['warning_settings']);
  618. $context['post_url'] = $scripturl . '?action=admin;area=securitysettings;save;sa=moderation';
  619. $context['settings_title'] = $txt['moderation_settings'];
  620. prepareDBSettingContext($config_vars);
  621. }
  622. /**
  623. * Let's try keep the spam to a minimum ah Thantos?
  624. * @param bool $return_config = false
  625. */
  626. function ModifySpamSettings($return_config = false)
  627. {
  628. global $txt, $scripturl, $context, $settings, $sc, $modSettings, $smcFunc, $language;
  629. // Generate a sample registration image.
  630. $context['use_graphic_library'] = in_array('gd', get_loaded_extensions());
  631. $context['verification_image_href'] = $scripturl . '?action=verificationcode;rand=' . md5(mt_rand());
  632. $config_vars = array(
  633. array('check', 'reg_verification'),
  634. array('check', 'search_enable_captcha'),
  635. // This, my friend, is a cheat :p
  636. 'guest_verify' => array('check', 'guests_require_captcha', 'subtext' => $txt['setting_guests_require_captcha_desc']),
  637. array('int', 'posts_require_captcha', 'subtext' => $txt['posts_require_captcha_desc'], 'onchange' => 'if (this.value > 0){ document.getElementById(\'guests_require_captcha\').checked = true; document.getElementById(\'guests_require_captcha\').disabled = true;} else {document.getElementById(\'guests_require_captcha\').disabled = false;}'),
  638. '',
  639. // PM Settings
  640. 'pm1' => array('int', 'max_pm_recipients', 'subtext' => $txt['max_pm_recipients_note']),
  641. 'pm2' => array('int', 'pm_posts_verification', 'subtext' => $txt['pm_posts_verification_note']),
  642. 'pm3' => array('int', 'pm_posts_per_hour', 'subtext' => $txt['pm_posts_per_hour_note']),
  643. // Visual verification.
  644. array('title', 'configure_verification_means'),
  645. array('desc', 'configure_verification_means_desc'),
  646. 'vv' => array('select', 'visual_verification_type', array($txt['setting_image_verification_off'], $txt['setting_image_verification_vsimple'], $txt['setting_image_verification_simple'], $txt['setting_image_verification_medium'], $txt['setting_image_verification_high'], $txt['setting_image_verification_extreme']), 'subtext'=> $txt['setting_visual_verification_type_desc'], 'onchange' => $context['use_graphic_library'] ? 'refreshImages();' : ''),
  647. // Clever Thomas, who is looking sheepy now? Not I, the mighty sword swinger did say.
  648. array('title', 'setup_verification_questions'),
  649. array('desc', 'setup_verification_questions_desc'),
  650. array('int', 'qa_verification_number', 'subtext' => $txt['setting_qa_verification_number_desc']),
  651. array('callback', 'question_answer_list'),
  652. );
  653. call_integration_hook('integrate_spam_settings', array(&$config_vars));
  654. if ($return_config)
  655. return $config_vars;
  656. // Firstly, figure out what languages we're dealing with, and do a little processing for the form's benefit.
  657. getLanguages();
  658. $context['qa_languages'] = array();
  659. foreach ($context['languages'] as $lang_id => $lang)
  660. {
  661. $lang_id = strtr($lang_id, array('-utf8' => ''));
  662. $lang['name'] = strtr($lang['name'], array('-utf8' => ''));
  663. $context['qa_languages'][$lang_id] = $lang;
  664. }
  665. // Secondly, load any questions we currently have.
  666. $context['question_answers'] = array();
  667. $request = $smcFunc['db_query']('', '
  668. SELECT id_question, lngfile, question, answers
  669. FROM {db_prefix}qanda'
  670. );
  671. while ($row = $smcFunc['db_fetch_assoc']($request))
  672. {
  673. $lang = strtr($row['lngfile'], array('-utf8' => ''));
  674. $context['question_answers'][$row['id_question']] = array(
  675. 'lngfile' => $lang,
  676. 'question' => $row['question'],
  677. 'answers' => unserialize($row['answers']),
  678. );
  679. $context['qa_by_lang'][$lang][] = $row['id_question'];
  680. }
  681. // Thirdly, push some JavaScript for the form to make it work.
  682. addInlineJavascript('
  683. var nextrow = ' . (!empty($context['question_answers']) ? max(array_keys($context['question_answers'])) + 1 : 1) . ';
  684. $(".qa_link a").click(function() {
  685. var id = $(this).parent().attr("id").substring(6);
  686. $("#qa_fs_" + id).show();
  687. $(this).parent().hide();
  688. });
  689. $(".qa_fieldset legend a").click(function() {
  690. var id = $(this).closest("fieldset").attr("id").substring(6);
  691. $("#qa_dt_" + id).show();
  692. $(this).closest("fieldset").hide();
  693. });
  694. $(".qa_add_question a").click(function() {
  695. var id = $(this).closest("fieldset").attr("id").substring(6);
  696. $(\'<dt><input type="text" name="question[\' + id + \'][\' + nextrow + \']" value="" size="50" class="input_text verification_question" /></dt><dd><input type="text" name="answer[\' + id + \'][\' + nextrow + \'][]" value="" size="50" class="input_text verification_answer" / ><div class="qa_add_answer"><a href="javascript:void(0);" onclick="return addAnswer(this);">[ \' + ' . JavaScriptEscape($txt['setup_verification_add_answer']) . ' + \' ]</a></div></dd>\').insertBefore($(this).parent());
  697. nextrow++;
  698. });
  699. function addAnswer(obj)
  700. {
  701. var attr = $(obj).closest("dd").find(".verification_answer:last").attr("name");
  702. $(\'<input type="text" name="\' + attr + \'" value="" size="50" class="input_text verification_answer" />\').insertBefore($(obj).closest("div"));
  703. return false;
  704. }
  705. $("#qa_dt_' . $language . ' a").click();', true);
  706. // Saving?
  707. if (isset($_GET['save']))
  708. {
  709. checkSession();
  710. // Fix PM settings.
  711. $_POST['pm_spam_settings'] = (int) $_POST['max_pm_recipients'] . ',' . (int) $_POST['pm_posts_verification'] . ',' . (int) $_POST['pm_posts_per_hour'];
  712. // Hack in guest requiring verification!
  713. if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha']))
  714. $_POST['posts_require_captcha'] = -1;
  715. $save_vars = $config_vars;
  716. unset($save_vars['pm1'], $save_vars['pm2'], $save_vars['pm3'], $save_vars['guest_verify']);
  717. $save_vars[] = array('text', 'pm_spam_settings');
  718. // Handle verification questions.
  719. $changes = array(
  720. 'insert' => array(),
  721. 'replace' => array(),
  722. 'delete' => array(),
  723. );
  724. $qs_per_lang = array();
  725. foreach ($context['qa_languages'] as $lang_id => $dummy)
  726. {
  727. // If we had some questions for this language before, but don't now, delete everything from that language.
  728. if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id]))
  729. $changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]);
  730. // Now step through and see if any existing questions no longer exist.
  731. if (!empty($context['qa_by_lang'][$lang_id]))
  732. foreach ($context['qa_by_lang'][$lang_id] as $q_id)
  733. if (empty($_POST['question'][$lang_id][$q_id]))
  734. $changes['delete'][] = $q_id;
  735. // Now let's see if there are new questions or ones that need updating.
  736. foreach ($_POST['question'][$lang_id] as $q_id => $question)
  737. {
  738. // Ignore junky ids.
  739. $q_id = (int) $q_id;
  740. if ($q_id <= 0)
  741. continue;
  742. // Check the question isn't empty (because they want to delete it?)
  743. if (empty($question) || trim($question) == '')
  744. {
  745. if (isset($context['question_answers'][$q_id]))
  746. $changes['delete'][] = $q_id;
  747. continue;
  748. }
  749. $question = $smcFunc['htmlspecialchars'](trim($question));
  750. // Get the answers. Firstly check there actually might be some.
  751. if (!isset($_POST['answer'][$lang_id][$q_id]) || !is_array($_POST['answer'][$lang_id][$q_id]))
  752. {
  753. if (isset($context['question_answers'][$q_id]))
  754. $changes['delete'][] = $q_id;
  755. continue;
  756. }
  757. // Now get them and check that they might be viable.
  758. $answers = array();
  759. foreach ($_POST['answer'][$lang_id][$q_id] as $answer)
  760. if (!empty($answer) && trim($answer) !== '')
  761. $answers[] = $smcFunc['htmlspecialchars'](trim($answer));
  762. if (empty($answers))
  763. {
  764. if (isset($context['question_answers'][$q_id]))
  765. $changes['delete'][] = $q_id;
  766. continue;
  767. }
  768. $answers = serialize($answers);
  769. // At this point we know we have a question and some answers. What are we doing with it?
  770. if (!isset($context['question_answers'][$q_id]))
  771. {
  772. // New question. Now, we don't want to randomly consume ids, so we'll set those, rather than trusting the browser's supplied ids.
  773. $changes['insert'][] = array($lang_id, $question, $answers);
  774. }
  775. else
  776. {
  777. // It's an existing question. Let's see what's changed, if anything.
  778. if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers'])
  779. $changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers);
  780. }
  781. if (!isset($qs_per_lang[$lang_id]))
  782. $qs_per_lang[$lang_id] = 0;
  783. $qs_per_lang[$lang_id]++;
  784. }
  785. }
  786. // OK, so changes?
  787. if (!empty($changes['delete']))
  788. {
  789. $smcFunc['db_query']('', '
  790. DELETE FROM {db_prefix}qanda
  791. WHERE id_question IN ({array_int:questions})',
  792. array(
  793. 'questions' => $changes['delete'],
  794. )
  795. );
  796. }
  797. if (!empty($changes['replace']))
  798. {
  799. foreach ($changes['replace'] as $q_id => $question)
  800. {
  801. $smcFunc['db_query']('', '
  802. UPDATE {db_prefix}qanda
  803. SET lngfile = {string:lngfile},
  804. question = {string:question},
  805. answers = {string:answers}
  806. WHERE id_question = {int:id_question}',
  807. array(
  808. 'id_question' => $q_id,
  809. 'lngfile' => $question['lngfile'],
  810. 'question' => $question['question'],
  811. 'answers' => $question['answers'],
  812. )
  813. );
  814. }
  815. }
  816. if (!empty($changes['insert']))
  817. {
  818. $smcFunc['db_insert']('insert',
  819. '{db_prefix}qanda',
  820. array('lngfile' => 'string-50', 'question' => 'string-255', 'answers' => 'string-65534'),
  821. $changes['insert'],
  822. array('id_question')
  823. );
  824. }
  825. // Lastly, the count of messages needs to be no more than the lowest number of questions for any one language.
  826. $count_questions = empty($qs_per_lang) ? 0 : min($qs_per_lang);
  827. if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions)
  828. $_POST['qa_verification_number'] = $count_questions;
  829. call_integration_hook('integrate_save_spam_settings', array(&$save_vars));
  830. // Now save.
  831. saveDBSettings($save_vars);
  832. cache_put_data('verificationQuestions', null, 300);
  833. redirectexit('action=admin;area=securitysettings;sa=spam');
  834. }
  835. $character_range = array_merge(range('A', 'H'), array('K', 'M', 'N', 'P', 'R'), range('T', 'Y'));
  836. $_SESSION['visual_verification_code'] = '';
  837. for ($i = 0; $i < 6; $i++)
  838. $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)];
  839. // Some javascript for CAPTCHA.
  840. $context['settings_post_javascript'] = '';
  841. if ($context['use_graphic_library'])
  842. $context['settings_post_javascript'] .= '
  843. function refreshImages()
  844. {
  845. var imageType = document.getElementById(\'visual_verification_type\').value;
  846. document.getElementById(\'verification_image\').src = \'' . $context['verification_image_href'] . ';type=\' + imageType;
  847. }';
  848. // Show the image itself, or text saying we can't.
  849. if ($context['use_graphic_library'])
  850. $config_vars['vv']['postinput'] = '<br /><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image" /><br />';
  851. else
  852. $config_vars['vv']['postinput'] = '<br /><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>';
  853. // Hack for PM spam settings.
  854. list ($modSettings['max_pm_recipients'], $modSettings['pm_posts_verification'], $modSettings['pm_posts_per_hour']) = explode(',', $modSettings['pm_spam_settings']);
  855. // Hack for guests requiring verification.
  856. $modSettings['guests_require_captcha'] = !empty($modSettings['posts_require_captcha']);
  857. $modSettings['posts_require_captcha'] = !isset($modSettings['posts_require_captcha']) || $modSettings['posts_require_captcha'] == -1 ? 0 : $modSettings['posts_require_captcha'];
  858. // Some minor javascript for the guest post setting.
  859. if ($modSettings['posts_require_captcha'])
  860. $context['settings_post_javascript'] .= '
  861. document.getElementById(\'guests_require_captcha\').disabled = true;';
  862. $context['post_url'] = $scripturl . '?action=admin;area=securitysettings;save;sa=spam';
  863. $context['settings_title'] = $txt['antispam_Settings'];
  864. prepareDBSettingContext($config_vars);
  865. }
  866. /**
  867. * You'll never guess what this function does...
  868. *
  869. * @param $return_config
  870. */
  871. function ModifySignatureSettings($return_config = false)
  872. {
  873. global $context, $txt, $modSettings, $sig_start, $smcFunc, $helptxt, $scripturl;
  874. $config_vars = array(
  875. // Are signatures even enabled?
  876. array('check', 'signature_enable'),
  877. '',
  878. // Tweaking settings!
  879. array('int', 'signature_max_length', 'subtext' => $txt['zero_for_no_limit']),
  880. array('int', 'signature_max_lines', 'subtext' => $txt['zero_for_no_limit']),
  881. array('int', 'signature_max_font_size', 'subtext' => $txt['zero_for_no_limit']),
  882. array('check', 'signature_allow_smileys', 'onclick' => 'document.getElementById(\'signature_max_smileys\').disabled = !this.checked;'),
  883. array('int', 'signature_max_smileys', 'subtext' => $txt['zero_for_no_limit']),
  884. '',
  885. // Image settings.
  886. array('int', 'signature_max_images', 'subtext' => $txt['signature_max_images_note']),
  887. array('int', 'signature_max_image_width', 'subtext' => $txt['zero_for_no_limit']),
  888. array('int', 'signature_max_image_height', 'subtext' => $txt['zero_for_no_limit']),
  889. '',
  890. array('bbc', 'signature_bbc'),
  891. );
  892. call_integration_hook('integrate_signature_settings', array(&$config_vars));
  893. if ($return_config)
  894. return $config_vars;
  895. // Setup the template.
  896. $context['page_title'] = $txt['signature_settings'];
  897. $context['sub_template'] = 'show_settings';
  898. // Disable the max smileys option if we don't allow smileys at all!
  899. $context['settings_post_javascript'] = 'document.getElementById(\'signature_max_smileys\').disabled = !document.getElementById(\'signature_allow_smileys\').checked;';
  900. // Load all the signature settings.
  901. list ($sig_limits, $sig_bbc) = explode(':', $modSettings['signature_settings']);
  902. $sig_limits = explode(',', $sig_limits);
  903. $disabledTags = !empty($sig_bbc) ? explode(',', $sig_bbc) : array();
  904. // Applying to ALL signatures?!!
  905. if (isset($_GET['apply']))
  906. {
  907. // Security!
  908. checkSession('get');
  909. $sig_start = time();
  910. // This is horrid - but I suppose some people will want the option to do it.
  911. $_GET['step'] = isset($_GET['step']) ? (int) $_GET['step'] : 0;
  912. $done = false;
  913. $request = $smcFunc['db_query']('', '
  914. SELECT MAX(id_member)
  915. FROM {db_prefix}members',
  916. array(
  917. )
  918. );
  919. list ($context['max_member']) = $smcFunc['db_fetch_row']($request);
  920. $smcFunc['db_free_result']($request);
  921. while (!$done)
  922. {
  923. $changes = array();
  924. $request = $smcFunc['db_query']('', '
  925. SELECT id_member, signature
  926. FROM {db_prefix}members
  927. WHERE id_member BETWEEN ' . $_GET['step'] . ' AND ' . $_GET['step'] . ' + 49
  928. AND id_group != {int:admin_group}
  929. AND FIND_IN_SET({int:admin_group}, additional_groups) = 0',
  930. array(
  931. 'admin_group' => 1,
  932. )
  933. );
  934. while ($row = $smcFunc['db_fetch_assoc']($request))
  935. {
  936. // Apply all the rules we can realistically do.
  937. $sig = strtr($row['signature'], array('<br />' => "\n"));
  938. // Max characters...
  939. if (!empty($sig_limits[1]))
  940. $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]);
  941. // Max lines...
  942. if (!empty($sig_limits[2]))
  943. {
  944. $count = 0;
  945. for ($i = 0; $i < strlen($sig); $i++)
  946. {
  947. if ($sig[$i] == "\n")
  948. {
  949. $count++;
  950. if ($count >= $sig_limits[2])
  951. $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' '));
  952. }
  953. }
  954. }
  955. if (!empty($sig_limits[7]) && preg_match_all('~\[size=([\d\.]+)?(px|pt|em|x-large|larger)~i', $sig, $matches) !== false && isset($matches[2]))
  956. {
  957. foreach ($matches[1] as $ind => $size)
  958. {
  959. $limit_broke = 0;
  960. // Attempt to allow all sizes of abuse, so to speak.
  961. if ($matches[2][$ind] == 'px' && $size > $sig_limits[7])
  962. $limit_broke = $sig_limits[7] . 'px';
  963. elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75))
  964. $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt';
  965. elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16))
  966. $limit_broke = ((float) $sig_limits[7] / 16) . 'em';
  967. elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18)
  968. $limit_broke = 'large';
  969. if ($limit_broke)
  970. $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig);
  971. }
  972. }
  973. // Stupid images - this is stupidly, stupidly challenging.
  974. if ((!empty($sig_limits[3]) || !empty($sig_limits[5]) || !empty($sig_limits[6])))
  975. {
  976. $replaces = array();
  977. $img_count = 0;
  978. // Get all BBC tags...
  979. preg_match_all('~\[img(\s+width=([\d]+))?(\s+height=([\d]+))?(\s+width=([\d]+))?\s*\](?:<br />)*([^<">]+?)(?:<br />)*\[/img\]~i', $sig, $matches);
  980. // ... and all HTML ones.
  981. preg_match_all('~&lt;img\s+src=(?:&quot;)?((?:http://|ftp://|https://|ftps://).+?)(?:&quot;)?(?:\s+alt=(?:&quot;)?(.*?)(?:&quot;)?)?(?:\s?/)?&gt;~i', $sig, $matches2, PREG_PATTERN_ORDER);
  982. // And stick the HTML in the BBC.
  983. if (!empty($matches2))
  984. {
  985. foreach ($matches2[0] as $ind => $dummy)
  986. {
  987. $matches[0][] = $matches2[0][$ind];
  988. $matches[1][] = '';
  989. $matches[2][] = '';
  990. $matches[3][] = '';
  991. $matches[4][] = '';
  992. $matches[5][] = '';
  993. $matches[6][] = '';
  994. $matches[7][] = $matches2[1][$ind];
  995. }
  996. }
  997. // Try to find all the images!
  998. if (!empty($matches))
  999. {
  1000. $image_count_holder = array();
  1001. foreach ($matches[0] as $key => $image)
  1002. {
  1003. $width = -1; $height = -1;
  1004. $img_count++;
  1005. // Too many images?
  1006. if (!empty($sig_limits[3]) && $img_count > $sig_limits[3])
  1007. {
  1008. // If we've already had this before we only want to remove the excess.
  1009. if (isset($image_count_holder[$image]))
  1010. {
  1011. $img_offset = -1;
  1012. $rep_img_count = 0;
  1013. while ($img_offset !== false)
  1014. {
  1015. $img_offset = strpos($sig, $image, $img_offset + 1);
  1016. $rep_img_count++;
  1017. if ($rep_img_count > $image_count_holder[$image])
  1018. {
  1019. // Only replace the excess.
  1020. $sig = substr($sig, 0, $img_offset) . str_replace($image, '', substr($sig, $img_offset));
  1021. // Stop looping.
  1022. $img_offset = false;
  1023. }
  1024. }
  1025. }
  1026. else
  1027. $replaces[$image] = '';
  1028. continue;
  1029. }
  1030. // Does it have predefined restraints? Width first.
  1031. if ($matches[6][$key])
  1032. $matches[2][$key] = $matches[6][$key];
  1033. if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5])
  1034. {
  1035. $width = $sig_limits[5];
  1036. $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]);
  1037. }
  1038. elseif ($matches[2][$key])
  1039. $width = $matches[2][$key];
  1040. // ... and height.
  1041. if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6])
  1042. {
  1043. $height = $sig_limits[6];
  1044. if ($width != -1)
  1045. $width = $width * ($height / $matches[4][$key]);
  1046. }
  1047. elseif ($matches[4][$key])
  1048. $height = $matches[4][$key];
  1049. // If the dimensions are still not fixed - we need to check the actual image.
  1050. if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6]))
  1051. {
  1052. $sizes = url_image_size($matches[7][$key]);
  1053. if (is_array($sizes))
  1054. {
  1055. // Too wide?
  1056. if ($sizes[0] > $sig_limits[5] && $sig_limits[5])
  1057. {
  1058. $width = $sig_limits[5];
  1059. $sizes[1] = $sizes[1] * ($width / $sizes[0]);
  1060. }
  1061. // Too high?
  1062. if ($sizes[1] > $sig_limits[6] && $sig_limits[6])
  1063. {
  1064. $height = $sig_limits[6];
  1065. if ($width == -1)
  1066. $width = $sizes[0];
  1067. $width = $width * ($height / $sizes[1]);
  1068. }
  1069. elseif ($width != -1)
  1070. $height = $sizes[1];
  1071. }
  1072. }
  1073. // Did we come up with some changes? If so remake the string.
  1074. if ($width != -1 || $height != -1)
  1075. {
  1076. $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]';
  1077. }
  1078. // Record that we got one.
  1079. $image_count_holder[$image] = isset($image_count_holder[$image]) ? $image_count_holder[$image] + 1 : 1;
  1080. }
  1081. if (!empty($replaces))
  1082. $sig = str_replace(array_keys($replaces), array_values($replaces), $sig);
  1083. }
  1084. }
  1085. // Try to fix disabled tags.
  1086. if (!empty($disabledTags))
  1087. {
  1088. $sig = preg_replace('~\[(?:' . implode('|', $disabledTags) . ').+?\]~i', '', $sig);
  1089. $sig = preg_replace('~\[/(?:' . implode('|', $disabledTags) . ')\]~i', '', $sig);
  1090. }
  1091. $sig = strtr($sig, array("\n" => '<br />'));
  1092. call_integration_hook('integrate_apply_signature_settings', array(&$sig, $sig_limits, $disabledTags));
  1093. if ($sig != $row['signature'])
  1094. $changes[$row['id_member']] = $sig;
  1095. }
  1096. if ($smcFunc['db_num_rows']($request) == 0)
  1097. $done = true;
  1098. $smcFunc['db_free_result']($request);
  1099. // Do we need to delete what we have?
  1100. if (!empty($changes))
  1101. {
  1102. foreach ($changes as $id => $sig)
  1103. $smcFunc['db_query']('', '
  1104. UPDATE {db_prefix}members
  1105. SET signature = {string:signature}
  1106. WHERE id_member = {int:id_member}',
  1107. array(
  1108. 'id_member' => $id,
  1109. 'signature' => $sig,
  1110. )
  1111. );
  1112. }
  1113. $_GET['step'] += 50;
  1114. if (!$done)
  1115. pauseSignatureApplySettings();
  1116. }
  1117. $settings_applied = true;
  1118. }
  1119. $context['signature_settings'] = array(
  1120. 'enable' => isset($sig_limits[0]) ? $sig_limits[0] : 0,
  1121. 'max_length' => isset($sig_limits[1]) ? $sig_limits[1] : 0,
  1122. 'max_lines' => isset($sig_limits[2]) ? $sig_limits[2] : 0,
  1123. 'max_images' => isset($sig_limits[3]) ? $sig_limits[3] : 0,
  1124. 'allow_smileys' => isset($sig_limits[4]) && $sig_limits[4] == -1 ? 0 : 1,
  1125. 'max_smileys' => isset($sig_limits[4]) && $sig_limits[4] != -1 ? $sig_limits[4] : 0,
  1126. 'max_image_width' => isset($sig_limits[5]) ? $sig_limits[5] : 0,
  1127. 'max_image_height' => isset($sig_limits[6]) ? $sig_limits[6] : 0,
  1128. 'max_font_size' => isset($sig_limits[7]) ? $sig_limits[7] : 0,
  1129. );
  1130. // Temporarily make each setting a modSetting!
  1131. foreach ($context['signature_settings'] as $key => $value)
  1132. $modSettings['signature_' . $key] = $value;
  1133. // Make sure we check the right tags!
  1134. $modSettings['bbc_disabled_signature_bbc'] = $disabledTags;
  1135. // Saving?
  1136. if (isset($_GET['save']))
  1137. {
  1138. checkSession();
  1139. // Clean up the tag stuff!
  1140. $bbcTags = array();
  1141. foreach (parse_bbc(false) as $tag)
  1142. $bbcTags[] = $tag['tag'];
  1143. if (!isset($_POST['signature_bbc_enabledTags']))
  1144. $_POST['signature_bbc_enabledTags'] = array();
  1145. elseif (!is_array($_POST['signature_bbc_enabledTags']))
  1146. $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']);
  1147. $sig_limits = array();
  1148. foreach ($context['signature_settings'] as $key => $value)
  1149. {
  1150. if ($key == 'allow_smileys')
  1151. continue;
  1152. elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys']))
  1153. $sig_limits[] = -1;
  1154. else
  1155. $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0;
  1156. }
  1157. call_integration_hook('integrate_save_signature_settings', array(&$sig_limits, &$bbcTags));
  1158. $_POST['signature_settings'] = implode(',', $sig_limits) . ':' . implode(',', array_diff($bbcTags, $_POST['signature_bbc_enabledTags']));
  1159. // Even though we have practically no settings let's keep the convention going!
  1160. $save_vars = array();
  1161. $save_vars[] = array('text', 'signature_settings');
  1162. saveDBSettings($save_vars);
  1163. redirectexit('action=admin;area=featuresettings;sa=sig');
  1164. }
  1165. $context['post_url'] = $scripturl . '?action=admin;area=featuresettings;save;sa=sig';
  1166. $context['settings_title'] = $txt['signature_settings'];
  1167. $context['settings_message'] = !empty($settings_applied) ? '<div class="infobox">' . $txt['signature_settings_applied'] . '</div>' : '<p class="centertext">' . sprintf($txt['signature_settings_warning'], $context['session_id'], $context['session_var']) . '</p>';
  1168. prepareDBSettingContext($config_vars);
  1169. }
  1170. /**
  1171. * Just pause the signature applying thing.
  1172. */
  1173. function pauseSignatureApplySettings()
  1174. {
  1175. global $context, $txt, $sig_start;
  1176. // Try get more time...
  1177. @set_time_limit(600);
  1178. if (function_exists('apache_reset_timeout'))
  1179. @apache_reset_timeout();
  1180. // Have we exhausted all the time we allowed?
  1181. if (time() - array_sum(explode(' ', $sig_start)) < 3)
  1182. return;
  1183. $context['continue_get_data'] = '?action=admin;area=featuresettings;sa=sig;apply;step=' . $_GET['step'] . ';' . $context['session_var'] . '=' . $context['session_id'];
  1184. $context['page_title'] = $txt['not_done_title'];
  1185. $context['continue_post_data'] = '';
  1186. $context['continue_countdown'] = '2';
  1187. $context['sub_template'] = 'not_done';
  1188. // Specific stuff to not break this template!
  1189. $context[$context['admin_menu_name']]['current_subsection'] = 'sig';
  1190. // Get the right percent.
  1191. $context['continue_percent'] = round(($_GET['step'] / $context['max_member']) * 100);
  1192. // Never more than 100%!
  1193. $context['continue_percent'] = min($context['continue_percent'], 100);
  1194. obExit();
  1195. }
  1196. /**
  1197. * Show all the custom profile fields available to the user.
  1198. */
  1199. function ShowCustomProfiles()
  1200. {
  1201. global $txt, $scripturl, $context, $settings, $sc, $smcFunc;
  1202. global $modSettings, $sourcedir;
  1203. $context['page_title'] = $txt['custom_profile_title'];
  1204. $context['sub_template'] = 'show_custom_profile';
  1205. // What about standard fields they can tweak?
  1206. $standard_fields = array('icq', 'aim', 'yim', 'skype', 'location', 'gender', 'website', 'personal_text', 'posts', 'warning_status');
  1207. // What fields can't you put on the registration page?
  1208. $context['fields_no_registration'] = array('posts', 'warning_status');
  1209. // Are we saving any standard field changes?
  1210. if (isset($_POST['save']))
  1211. {
  1212. checkSession();
  1213. validateToken('admin-scp');
  1214. // Do the active ones first.
  1215. $disable_fields = array_flip($standard_fields);
  1216. if (!empty($_POST['active']))
  1217. {
  1218. foreach ($_POST['active'] as $value)
  1219. if (isset($disable_fields[$value]))
  1220. unset($disable_fields[$value]);
  1221. }
  1222. // What we have left!
  1223. $changes['disabled_profile_fields'] = empty($disable_fields) ? '' : implode(',', array_keys($disable_fields));
  1224. // Things we want to show on registration?
  1225. $reg_fields = array();
  1226. if (!empty($_POST['reg']))
  1227. {
  1228. foreach ($_POST['reg'] as $value)
  1229. if (in_array($value, $standard_fields) && !isset($disable_fields[$value]))
  1230. $reg_fields[] = $value;
  1231. }
  1232. // What we have left!
  1233. $changes['registration_fields'] = empty($reg_fields) ? '' : implode(',', $reg_fields);
  1234. if (!empty($changes))
  1235. updateSettings($changes);
  1236. }
  1237. createToken('admin-scp');
  1238. require_once($sourcedir . '/Subs-List.php');
  1239. $listOptions = array(
  1240. 'id' => 'standard_profile_fields',
  1241. 'title' => $txt['standard_profile_title'],
  1242. 'base_href' => $scripturl . '?action=admin;area=featuresettings;sa=profile',
  1243. 'get_items' => array(
  1244. 'function' => 'list_getProfileFields',
  1245. 'params' => array(
  1246. true,
  1247. ),
  1248. ),
  1249. 'columns' => array(
  1250. 'field' => array(
  1251. 'header' => array(
  1252. 'value' => $txt['standard_profile_field'],
  1253. ),
  1254. 'data' => array(
  1255. 'db' => 'label',
  1256. 'style' => 'width: 60%;',
  1257. ),
  1258. ),
  1259. 'active' => array(
  1260. 'header' => array(
  1261. 'value' => $txt['custom_edit_active'],
  1262. 'class' => 'centercol',
  1263. ),
  1264. 'data' => array(
  1265. 'function' => create_function('$rowData', '
  1266. $isChecked = $rowData[\'disabled\'] ? \'\' : \' checked="checked"\';
  1267. $onClickHandler = $rowData[\'can_show_register\'] ? sprintf(\'onclick="document.getElementById(\\\'reg_%1$s\\\').disabled = !this.checked;"\', $rowData[\'id\']) : \'\';
  1268. return sprintf(\'<input type="checkbox" name="active[]" id="active_%1$s" value="%1$s" class="input_check"%2$s%3$s />\', $rowData[\'id\'], $isChecked, $onClickHandler);
  1269. '),
  1270. 'style' => 'width: 20%;',
  1271. 'class' => 'centercol',
  1272. ),
  1273. ),
  1274. 'show_on_registration' => array(
  1275. 'header' => array(
  1276. 'value' => $txt['custom_edit_registration'],
  1277. 'class' => 'centercol',
  1278. ),
  1279. 'data' => array(
  1280. 'function' => create_function('$rowData', '
  1281. $isChecked = $rowData[\'on_register\'] && !$rowData[\'disabled\'] ? \' checked="checked"\' : \'\';
  1282. $isDisabled = $rowData[\'can_show_register\'] ? \'\' : \' disabled="disabled"\';
  1283. return sprintf(\'<input type="checkbox" name="reg[]" id="reg_%1$s" value="%1$s" class="input_check"%2$s%3$s />\', $rowData[\'id\'], $isChecked, $isDisabled);
  1284. '),
  1285. 'style' => 'width: 20%;',
  1286. 'class' => 'centercol',
  1287. ),
  1288. ),
  1289. ),
  1290. 'form' => array(
  1291. 'href' => $scripturl . '?action=admin;area=featuresettings;sa=profile',
  1292. 'name' => 'standardProfileFields',
  1293. 'token' => 'admin-scp',
  1294. ),
  1295. 'additional_rows' => array(
  1296. array(
  1297. 'position' => 'below_table_data',
  1298. 'value' => '<input type="submit" name="save" value="' . $txt['save'] . '" class="button_submit" />',
  1299. ),
  1300. ),
  1301. );
  1302. createList($listOptions);
  1303. $listOptions = array(
  1304. 'id' => 'custom_profile_fields',
  1305. 'title' => $txt['custom_profile_title'],
  1306. 'base_href' => $scripturl . '?action=admin;area=featuresettings;sa=profile',
  1307. 'default_sort_col' => 'field_name',
  1308. 'no_items_label' => $txt['custom_profile_none'],
  1309. 'items_per_page' => 25,
  1310. 'get_items' => array(
  1311. 'function' => 'list_getProfileFields',
  1312. 'params' => array(
  1313. false,
  1314. ),
  1315. ),
  1316. 'get_count' => array(
  1317. 'function' => 'list_getProfileFieldSize',
  1318. ),
  1319. 'columns' => array(
  1320. 'field_name' => array(
  1321. 'header' => array(
  1322. 'value' => $txt['custom_profile_fieldname'],
  1323. ),
  1324. 'data' => array(
  1325. 'function' => create_function('$rowData', '
  1326. global $scripturl;
  1327. return sprintf(\'<a href="%1$s?action=admin;area=featuresettings;sa=profileedit;fid=%2$d">%3$s</a><div class="smalltext">%4$s</div>\', $scripturl, $rowData[\'id_field\'], $rowData[\'field_name\'], $rowData[\'field_desc\']);
  1328. '),
  1329. 'style' => 'width: 62%;',
  1330. ),
  1331. 'sort' => array(
  1332. 'default' => 'field_name',
  1333. 'reverse' => 'field_name DESC',
  1334. ),
  1335. ),
  1336. 'field_type' => array(
  1337. 'header' => array(
  1338. 'value' => $txt['custom_profile_fieldtype'],
  1339. ),
  1340. 'data' => array(
  1341. 'function' => create_function('$rowData', '
  1342. global $txt;
  1343. $textKey = sprintf(\'custom_profile_type_%1$s\', $rowData[\'field_type\']);
  1344. return isset($txt[$textKey]) ? $txt[$textKey] : $textKey;
  1345. '),
  1346. 'style' => 'width: 15%;',
  1347. ),
  1348. 'sort' => array(
  1349. 'default' => 'field_type',
  1350. 'reverse' => 'field_type DESC',
  1351. ),
  1352. ),
  1353. 'active' => array(
  1354. 'header' => array(
  1355. 'value' => $txt['custom_profile_active'],
  1356. ),
  1357. 'data' => array(
  1358. 'function' => create_function('$rowData', '
  1359. global $txt;
  1360. return $rowData[\'active\'] ? $txt[\'yes\'] : $txt[\'no\'];
  1361. '),
  1362. 'style' => 'width: 8%;',
  1363. ),
  1364. 'sort' => array(
  1365. 'default' => 'active DESC',
  1366. 'reverse' => 'active',
  1367. ),
  1368. ),
  1369. 'placement' => array(
  1370. 'header' => array(
  1371. 'value' => $txt['custom_profile_placement'],
  1372. ),
  1373. 'data' => array(
  1374. 'function' => create_function('$rowData', '
  1375. global $txt;
  1376. return $txt[\'custom_profile_placement_\' . (empty($rowData[\'placement\']) ? \'standard\' : ($rowData[\'placement\'] == 1 ? \'withicons\' : \'abovesignature\'))];
  1377. '),
  1378. 'style' => 'width: 8%;',
  1379. ),
  1380. 'sort' => array(
  1381. 'default' => 'placement DESC',
  1382. 'reverse' => 'placement',
  1383. ),
  1384. ),
  1385. 'show_on_registration' => array(
  1386. 'data' => array(
  1387. 'sprintf' => array(
  1388. 'format' => '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=%1$s">' . $txt['modify'] . '</a>',
  1389. 'params' => array(
  1390. 'id_field' => false,
  1391. ),
  1392. ),
  1393. 'style' => 'width: 15%;',
  1394. ),
  1395. ),
  1396. ),
  1397. 'form' => array(
  1398. 'href' => $scripturl . '?action=admin;area=featuresettings;sa=profileedit',
  1399. 'name' => 'customProfileFields',
  1400. ),
  1401. 'additional_rows' => array(
  1402. array(
  1403. 'position' => 'below_table_data',
  1404. 'value' => '<input type="submit" name="new" value="' . $txt['custom_profile_make_new'] . '" class="button_submit" />',
  1405. ),
  1406. ),
  1407. );
  1408. createList($listOptions);
  1409. }
  1410. /**
  1411. * Callback for createList().
  1412. *
  1413. * @param $start
  1414. * @param $items_per_page
  1415. * @param $sort
  1416. * @param $standardFields
  1417. */
  1418. function list_getProfileFields($start, $items_per_page, $sort, $standardFields)
  1419. {
  1420. global $txt, $modSettings, $smcFunc;
  1421. $list = array();
  1422. if ($standardFields)
  1423. {
  1424. $standard_fields = array('icq', 'aim', 'yim', 'skype', 'location', 'gender', 'website', 'personal_text', 'posts', 'warning_status');
  1425. $fields_no_registration = array('posts', 'warning_status');
  1426. $disabled_fields = isset($modSettings['disabled_profile_fields']) ? explode(',', $modSettings['disabled_profile_fields']) : array();
  1427. $registration_fields = isset($modSettings['registration_fields']) ? explode(',', $modSettings['registration_fields']) : array();
  1428. foreach ($standard_fields as $field)
  1429. $list[] = array(
  1430. 'id' => $field,
  1431. 'label' => isset($txt['standard_profile_field_' . $field]) ? $txt['standard_profile_field_' . $field] : (isset($txt[$field]) ? $txt[$field] : $field),
  1432. 'disabled' => in_array($field, $disabled_fields),
  1433. 'on_register' => in_array($field, $registration_fields) && !in_array($field, $fields_no_registration),
  1434. 'can_show_register' => !in_array($field, $fields_no_registration),
  1435. );
  1436. }
  1437. else
  1438. {
  1439. // Load all the fields.
  1440. $request = $smcFunc['db_query']('', '
  1441. SELECT id_field, col_name, field_name, field_desc, field_type, active, placement
  1442. FROM {db_prefix}custom_fields
  1443. ORDER BY {raw:sort}
  1444. LIMIT {int:start}, {int:items_per_page}',
  1445. array(
  1446. 'sort' => $sort,
  1447. 'start' => $start,
  1448. 'items_per_page' => $items_per_page,
  1449. )
  1450. );
  1451. while ($row = $smcFunc['db_fetch_assoc']($request))
  1452. $list[] = $row;
  1453. $smcFunc['db_free_result']($request);
  1454. }
  1455. return $list;
  1456. }
  1457. /**
  1458. * Callback for createList().
  1459. */
  1460. function list_getProfileFieldSize()
  1461. {
  1462. global $smcFunc;
  1463. $request = $smcFunc['db_query']('', '
  1464. SELECT COUNT(*)
  1465. FROM {db_prefix}custom_fields',
  1466. array(
  1467. )
  1468. );
  1469. list ($numProfileFields) = $smcFunc['db_fetch_row']($request);
  1470. $smcFunc['db_free_result']($request);
  1471. return $numProfileFields;
  1472. }
  1473. /**
  1474. * Edit some profile fields?
  1475. */
  1476. function EditCustomProfiles()
  1477. {
  1478. global $txt, $scripturl, $context, $settings, $sc, $smcFunc;
  1479. // Sort out the context!
  1480. $context['fid'] = isset($_GET['fid']) ? (int) $_GET['fid'] : 0;
  1481. $context[$context['admin_menu_name']]['current_subsection'] = 'profile';
  1482. $context['page_title'] = $context['fid'] ? $txt['custom_edit_title'] : $txt['custom_add_title'];
  1483. $context['sub_template'] = 'edit_profile_field';
  1484. // Load the profile language for section names.
  1485. loadLanguage('Profile');
  1486. if ($context['fid'])
  1487. {
  1488. $request = $smcFunc['db_query']('', '
  1489. SELECT
  1490. id_field, col_name, field_name, field_desc, field_type, field_length, field_options,
  1491. show_reg, show_display, show_profile, private, active, default_value, can_search,
  1492. bbc, mask, enclose, placement
  1493. FROM {db_prefix}custom_fields
  1494. WHERE id_field = {int:current_field}',
  1495. array(
  1496. 'current_field' => $context['fid'],
  1497. )
  1498. );
  1499. $context['field'] = array();
  1500. while ($row = $smcFunc['db_fetch_assoc']($request))
  1501. {
  1502. if ($row['field_type'] == 'textarea')
  1503. @list ($rows, $cols) = @explode(',', $row['default_value']);
  1504. else
  1505. {
  1506. $rows = 3;
  1507. $cols = 30;
  1508. }
  1509. $context['field'] = array(
  1510. 'name' => $row['field_name'],
  1511. 'desc' => $row['field_desc'],
  1512. 'colname' => $row['col_name'],
  1513. 'profile_area' => $row['show_profile'],
  1514. 'reg' => $row['show_reg'],
  1515. 'display' => $row['show_display'],
  1516. 'type' => $row['field_type'],
  1517. 'max_length' => $row['field_length'],
  1518. 'rows' => $rows,
  1519. 'cols' => $cols,
  1520. 'bbc' => $row['bbc'] ? true : false,
  1521. 'default_check' => $row['field_type'] == 'check' && $row['default_value'] ? true : false,
  1522. 'default_select' => $row['field_type'] == 'select' || $row['field_type'] == 'radio' ? $row['default_value'] : '',
  1523. 'options' => strlen($row['field_options']) > 1 ? explode(',', $row['field_options']) : array('', '', ''),
  1524. 'active' => $row['active'],
  1525. 'private' => $row['private'],
  1526. 'can_search' => $row['can_search'],
  1527. 'mask' => $row['mask'],
  1528. 'regex' => substr($row['mask'], 0, 5) == 'regex' ? substr($row['mask'], 5) : '',
  1529. 'enclose' => $row['enclose'],
  1530. 'placement' => $row['placement'],
  1531. );
  1532. }
  1533. $smcFunc['db_free_result']($request);
  1534. }
  1535. // Setup the default values as needed.
  1536. if (empty($context['field']))
  1537. $context['field'] = array(
  1538. 'name' => '',
  1539. 'colname' => '???',
  1540. 'desc' => '',
  1541. 'profile_area' => 'forumprofile',
  1542. 'reg' => false,
  1543. 'display' => false,
  1544. 'type' => 'text',
  1545. 'max_length' => 255,
  1546. 'rows' => 4,
  1547. 'cols' => 30,
  1548. 'bbc' => false,
  1549. 'default_check' => false,
  1550. 'default_select' => '',
  1551. 'options' => array('', '', ''),
  1552. 'active' => true,
  1553. 'private' => false,
  1554. 'can_search' => false,
  1555. 'mask' => 'nohtml',
  1556. 'regex' => '',
  1557. 'enclose' => '',
  1558. 'placement' => 0,
  1559. );
  1560. // Are we saving?
  1561. if (isset($_POST['save']))
  1562. {
  1563. checkSession();
  1564. validateToken('admin-ecp');
  1565. // Everyone needs a name - even the (bracket) unknown...
  1566. if (trim($_POST['field_name']) == '')
  1567. redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name');
  1568. // Regex you say? Do a very basic test to see if the pattern is valid
  1569. if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false)
  1570. redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error');
  1571. $_POST['field_name'] = $smcFunc['htmlspecialchars']($_POST['field_name']);
  1572. $_POST['field_desc'] = $smcFunc['htmlspecialchars']($_POST['field_desc']);
  1573. // Checkboxes...
  1574. $show_reg = isset($_POST['reg']) ? (int) $_POST['reg'] : 0;
  1575. $show_display = isset($_POST['display']) ? 1 : 0;
  1576. $bbc = isset($_POST['bbc']) ? 1 : 0;
  1577. $show_profile = $_POST['profile_area'];
  1578. $active = isset($_POST['active']) ? 1 : 0;
  1579. $private = isset($_POST['private']) ? (int) $_POST['private'] : 0;
  1580. $can_search = isset($_POST['can_search']) ? 1 : 0;
  1581. // Some masking stuff...
  1582. $mask = isset($_POST['mask']) ? $_POST['mask'] : '';
  1583. if ($mask == 'regex' && isset($_POST['regex']))
  1584. $mask .= $_POST['regex'];
  1585. $field_length = isset($_POST['max_length']) ? (int) $_POST['max_length'] : 255;
  1586. $enclose = isset($_POST['enclose']) ? $_POST['enclose'] : '';
  1587. $placement = isset($_POST['placement']) ? (int) $_POST['placement'] : 0;
  1588. // Select options?
  1589. $field_options = '';
  1590. $newOptions = array();
  1591. $default = isset($_POST['default_check']) && $_POST['field_type'] == 'check' ? 1 : '';
  1592. if (!empty($_POST['select_option']) && ($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio'))
  1593. {
  1594. foreach ($_POST['select_option'] as $k => $v)
  1595. {
  1596. // Clean, clean, clean...
  1597. $v = $smcFunc['htmlspecialchars']($v);
  1598. $v = strtr($v, array(',' => ''));
  1599. // Nada, zip, etc...
  1600. if (trim($v) == '')
  1601. continue;
  1602. // Otherwise, save it boy.
  1603. $field_options .= $v . ',';
  1604. // This is just for working out what happened with old options...
  1605. $newOptions[$k] = $v;
  1606. // Is it default?
  1607. if (isset($_POST['default_select']) && $_POST['default_select'] == $k)
  1608. $default = $v;
  1609. }
  1610. $field_options = substr($field_options, 0, -1);
  1611. }
  1612. // Text area has default has dimensions
  1613. if ($_POST['field_type'] == 'textarea')
  1614. $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols'];
  1615. // Come up with the unique name?
  1616. if (empty($context['fid']))
  1617. {
  1618. $colname = $smcFunc['substr'](strtr($_POST['field_name'], array(' ' => '')), 0, 6);
  1619. preg_match('~([\w\d_-]+)~', $colname, $matches);
  1620. // If there is nothing to the name, then let's start out own - for foreign languages etc.
  1621. if (isset($matches[1]))
  1622. $colname = $initial_colname = 'cust_' . strtolower($matches[1]);
  1623. else
  1624. $colname = $initial_colname = 'cust_' . mt_rand(1, 999);
  1625. // Make sure this is unique.
  1626. // @todo This may not be the most efficient way to do this.
  1627. $unique = false;
  1628. for ($i = 0; !$unique && $i < 9; $i ++)
  1629. {
  1630. $request = $smcFunc['db_query']('', '
  1631. SELECT id_field
  1632. FROM {db_prefix}custom_fields
  1633. WHERE col_name = {string:current_column}',
  1634. array(
  1635. 'current_column' => $colname,
  1636. )
  1637. );
  1638. if ($smcFunc['db_num_rows']($request) == 0)
  1639. $unique = true;
  1640. else
  1641. $colname = $initial_colname . $i;
  1642. $smcFunc['db_free_result']($request);
  1643. }
  1644. // Still not a unique colum name? Leave it up to the user, then.
  1645. if (!$unique)
  1646. fatal_lang_error('custom_option_not_unique');
  1647. }
  1648. // Work out what to do with the user data otherwise...
  1649. else
  1650. {
  1651. // Anything going to check or select is pointless keeping - as is anything coming from check!
  1652. if (($_POST['field_type'] == 'check' && $context['field']['type'] != 'check')
  1653. || (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && $context['field']['type'] != 'select' && $context['field']['type'] != 'radio')
  1654. || ($context['field']['type'] == 'check' && $_POST['field_type'] != 'check'))
  1655. {
  1656. $smcFunc['db_query']('', '
  1657. DELETE FROM {db_prefix}themes
  1658. WHERE variable = {string:current_column}
  1659. AND id_member > {int:no_member}',
  1660. array(
  1661. 'no_member' => 0,
  1662. 'current_column' => $context['field']['colname'],
  1663. )
  1664. );
  1665. }
  1666. // Otherwise - if the select is edited may need to adjust!
  1667. elseif ($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio')
  1668. {
  1669. $optionChanges = array();
  1670. $takenKeys = array();
  1671. // Work out what's changed!
  1672. foreach ($context['field']['options'] as $k => $option)
  1673. {
  1674. if (trim($option) == '')
  1675. continue;
  1676. // Still exists?
  1677. if (in_array($option, $newOptions))
  1678. {
  1679. $takenKeys[] = $k;
  1680. continue;
  1681. }
  1682. }
  1683. // Finally - have we renamed it - or is it really gone?
  1684. foreach ($optionChanges as $k => $option)
  1685. {
  1686. // Just been renamed?
  1687. if (!in_array($k, $takenKeys) && !empty($newOptions[$k]))
  1688. $smcFunc['db_query']('', '
  1689. UPDATE {db_prefix}themes
  1690. SET value = {string:new_value}
  1691. WHERE variable = {string:current_column}
  1692. AND value = {string:old_value}
  1693. AND id_member > {int:no_member}',
  1694. array(
  1695. 'no_member' => 0,
  1696. 'new_value' => $newOptions[$k],
  1697. 'current_column' => $context['field']['colname'],
  1698. 'old_value' => $option,
  1699. )
  1700. );
  1701. }
  1702. }
  1703. // @todo Maybe we should adjust based on new text length limits?
  1704. }
  1705. // Do the insertion/updates.
  1706. if ($context['fid'])
  1707. {
  1708. $smcFunc['db_query']('', '
  1709. UPDATE {db_prefix}custom_fields
  1710. SET
  1711. field_name = {string:field_name}, field_desc = {string:field_desc},
  1712. field_type = {string:field_type}, field_length = {int:field_length},
  1713. field_options = {string:field_options}, show_reg = {int:show_reg},
  1714. show_display = {int:show_display}, show_profile = {string:show_profile},
  1715. private = {int:private}, active = {int:active}, default_value = {string:default_value},
  1716. can_search = {int:can_search}, bbc = {int:bbc}, mask = {string:mask},
  1717. enclose = {string:enclose}, placement = {int:placement}
  1718. WHERE id_field = {int:current_field}',
  1719. array(
  1720. 'field_length' => $field_length,
  1721. 'show_reg' => $show_reg,
  1722. 'show_display' => $show_display,
  1723. 'private' => $private,
  1724. 'active' => $active,
  1725. 'can_search' => $can_search,
  1726. 'bbc' => $bbc,
  1727. 'current_field' => $context['fid'],
  1728. 'field_name' => $_POST['field_name'],
  1729. 'field_desc' => $_POST['field_desc'],
  1730. 'field_type' => $_POST['field_type'],
  1731. 'field_options' => $field_options,
  1732. 'show_profile' => $show_profile,
  1733. 'default_value' => $default,
  1734. 'mask' => $mask,
  1735. 'enclose' => $enclose,
  1736. 'placement' => $placement,
  1737. )
  1738. );
  1739. // Just clean up any old selects - these are a pain!
  1740. if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions))
  1741. $smcFunc['db_query']('', '
  1742. DELETE FROM {db_prefix}themes
  1743. WHERE variable = {string:current_column}
  1744. AND value NOT IN ({array_string:new_option_values})
  1745. AND id_member > {int:no_member}',
  1746. array(
  1747. 'no_member' => 0,
  1748. 'new_option_values' => $newOptions,
  1749. 'current_column' => $context['field']['colname'],
  1750. )
  1751. );
  1752. }
  1753. else
  1754. {
  1755. $smcFunc['db_insert']('',
  1756. '{db_prefix}custom_fields',
  1757. array(
  1758. 'col_name' => 'string', 'field_name' => 'string', 'field_desc' => 'string',
  1759. 'field_type' => 'string', 'field_length' => 'string', 'field_options' => 'string',
  1760. 'show_reg' => 'int', 'show_display' => 'int', 'show_profile' => 'string',
  1761. 'private' => 'int', 'active' => 'int', 'default_value' => 'string', 'can_search' => 'int',
  1762. 'bbc' => 'int', 'mask' => 'string', 'enclose' => 'string', 'placement' => 'int',
  1763. ),
  1764. array(
  1765. $colname, $_POST['field_name'], $_POST['field_desc'],
  1766. $_POST['field_type'], $field_length, $field_options,
  1767. $show_reg, $show_display, $show_profile,
  1768. $private, $active, $default, $can_search,
  1769. $bbc, $mask, $enclose, $placement,
  1770. ),
  1771. array('id_field')
  1772. );
  1773. }
  1774. // As there's currently no option to priorize certain fields over others, let's order them alphabetically.
  1775. $smcFunc['db_query']('alter_table_boards', '
  1776. ALTER TABLE {db_prefix}custom_fields
  1777. ORDER BY field_name',
  1778. array(
  1779. 'db_error_skip' => true,
  1780. )
  1781. );
  1782. }
  1783. // Deleting?
  1784. elseif (isset($_POST['delete']) && $context['field']['colname'])
  1785. {
  1786. checkSession();
  1787. validateToken('admin-ecp');
  1788. // Delete the user data first.
  1789. $smcFunc['db_query']('', '
  1790. DELETE FROM {db_prefix}themes
  1791. WHERE variable = {string:current_column}
  1792. AND id_member > {int:no_member}',
  1793. array(
  1794. 'no_member' => 0,
  1795. 'current_column' => $context['field']['colname'],
  1796. )
  1797. );
  1798. // Finally - the field itself is gone!
  1799. $smcFunc['db_query']('', '
  1800. DELETE FROM {db_prefix}custom_fields
  1801. WHERE id_field = {int:current_field}',
  1802. array(
  1803. 'current_field' => $context['fid'],
  1804. )
  1805. );
  1806. }
  1807. // Rebuild display cache etc.
  1808. if (isset($_POST['delete']) || isset($_POST['save']))
  1809. {
  1810. checkSession();
  1811. $request = $smcFunc['db_query']('', '
  1812. SELECT col_name, field_name, field_type, bbc, enclose, placement
  1813. FROM {db_prefix}custom_fields
  1814. WHERE show_display = {int:is_displayed}
  1815. AND active = {int:active}
  1816. AND private != {int:not_owner_only}
  1817. AND private != {int:not_admin_only}',
  1818. array(
  1819. 'is_displayed' => 1,
  1820. 'active' => 1,
  1821. 'not_owner_only' => 2,
  1822. 'not_admin_only' => 3,
  1823. )
  1824. );
  1825. $fields = array();
  1826. while ($row = $smcFunc['db_fetch_assoc']($request))
  1827. {
  1828. $fields[] = array(
  1829. 'colname' => strtr($row['col_name'], array('|' => '', ';' => '')),
  1830. 'title' => strtr($row['field_name'], array('|' => '', ';' => '')),
  1831. 'type' => $row['field_type'],
  1832. 'bbc' => $row['bbc'] ? '1' : '0',
  1833. 'placement' => !empty($row['placement']) ? $row['placement'] : '0',
  1834. 'enclose' => !empty($row['enclose']) ? $row['enclose'] : '',
  1835. );
  1836. }
  1837. $smcFunc['db_free_result']($request);
  1838. updateSettings(array('displayFields' => serialize($fields)));
  1839. redirectexit('action=admin;area=featuresettings;sa=profile');
  1840. }
  1841. createToken('admin-ecp');
  1842. }
  1843. /**
  1844. * Allow to edit the settings on the pruning screen.
  1845. * @param $return_config
  1846. */
  1847. function ModifyLogSettings($return_config = false)
  1848. {
  1849. global $txt, $scripturl, $sourcedir, $context, $settings, $sc, $modSettings;
  1850. // Make sure we understand what's going on.
  1851. loadLanguage('ManageSettings');
  1852. $context['page_title'] = $txt['log_settings'];
  1853. $config_vars = array(
  1854. array('check', 'enableErrorLogging'),
  1855. array('check', 'enableErrorQueryLogging'),
  1856. array('check', 'log_ban_hits'),
  1857. // Even do the pruning?
  1858. array('title', 'pruning_title'),
  1859. array('desc', 'pruning_desc'),
  1860. // The array indexes are there so we can remove/change them before saving.
  1861. 'pruningOptions' => array('check', 'pruningOptions'),
  1862. '',
  1863. // Various logs that could be pruned.
  1864. array('int', 'pruneErrorLog', 'postinput' => $txt['days_word'], 'subtext' => $txt['zero_to_disable']), // Error log.
  1865. array('int', 'pruneModLog', 'postinput' => $txt['days_word'], 'subtext' => $txt['zero_to_disable']), // Moderation log.
  1866. array('int', 'pruneBanLog', 'postinput' => $txt['days_word'], 'subtext' => $txt['zero_to_disable']), // Ban hit log.
  1867. array('int', 'pruneReportLog', 'postinput' => $txt['days_word'], 'subtext' => $txt['zero_to_disable']), // Report to moderator log.
  1868. array('int', 'pruneScheduledTaskLog', 'postinput' => $txt['days_word'], 'subtext' => $txt['zero_to_disable']), // Log of the scheduled tasks and how long they ran.
  1869. array('int', 'pruneSpiderHitLog', 'postinput' => $txt['days_word'], 'subtext' => $txt['zero_to_disable']), // Log of the scheduled tasks and how long they ran.
  1870. // If you add any additional logs make sure to add them after this point. Additionally, make sure you add them to the weekly scheduled task.
  1871. // Mod Developers: Do NOT use the pruningOptions master variable for this as SMF Core may overwrite your setting in the future!
  1872. );
  1873. // We want to be toggling some of these for a nice user experience. If you want to add yours to the list of those magically hidden when the 'pruning' option is off, add to this.
  1874. $prune_toggle = array('pruneErrorLog', 'pruneModLog', 'pruneBanLog', 'pruneReportLog', 'pruneScheduledTaskLog', 'pruneSpiderHitLog');
  1875. call_integration_hook('integrate_prune_settings', array(&$config_vars, &$prune_toggle));
  1876. $prune_toggle_dt = array();
  1877. foreach ($prune_toggle as $item)
  1878. $prune_toggle_dt[] = 'setting_' . $item;
  1879. if ($return_config)
  1880. return $config_vars;
  1881. addInlineJavascript('
  1882. function togglePruned()
  1883. {
  1884. var newval = $("#pruningOptions").prop("checked");
  1885. $("#' . implode(', #', $prune_toggle) . '").closest("dd").toggle(newval);
  1886. $("#' . implode(', #', $prune_toggle_dt) . '").closest("dt").toggle(newval);
  1887. };
  1888. togglePruned();
  1889. $("#pruningOptions").click(function() { togglePruned(); });', true);
  1890. // We'll need this in a bit.
  1891. require_once($sourcedir . '/ManageServer.php');
  1892. // Saving?
  1893. if (isset($_GET['save']))
  1894. {
  1895. checkSession();
  1896. $savevar = array(
  1897. array('text', 'pruningOptions')
  1898. );
  1899. if (!empty($_POST['pruningOptions']))
  1900. {
  1901. $vals = array();
  1902. foreach ($config_vars as $index => $dummy)
  1903. {
  1904. if (!is_array($dummy) || $index == 'pruningOptions')
  1905. continue;
  1906. $vals[] = empty($_POST[$dummy[1]]) || $_POST[$dummy[1]] < 0 ? 0 : (int) $_POST[$dummy[1]];
  1907. }
  1908. $_POST['pruningOptions'] = implode(',', $vals);
  1909. }
  1910. else
  1911. $_POST['pruningOptions'] = '';
  1912. saveDBSettings($savevar);
  1913. redirectexit('action=admin;area=logs;sa=settings');
  1914. }
  1915. $context['post_url'] = $scripturl . '?action=admin;area=logs;save;sa=settings';
  1916. $context['settings_title'] = $txt['log_settings'];
  1917. $context['sub_template'] = 'show_settings';
  1918. // Get the actual values
  1919. if (!empty($modSettings['pruningOptions']))
  1920. @list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']);
  1921. else
  1922. $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0;
  1923. prepareDBSettingContext($config_vars);
  1924. }
  1925. /**
  1926. * If you have a general mod setting to add stick it here.
  1927. *
  1928. * @param $return_config
  1929. */
  1930. function ModifyGeneralModSettings($return_config = false)
  1931. {
  1932. global $txt, $scripturl, $context, $settings, $sc, $modSettings;
  1933. $config_vars = array(
  1934. // Mod authors, add any settings UNDER this line. Include a comma at the end of the line and don't remove this statement!!
  1935. );
  1936. // Make it even easier to add new settings.
  1937. call_integration_hook('integrate_general_mod_settings', array(&$config_vars));
  1938. if ($return_config)
  1939. return $config_vars;
  1940. $context['post_url'] = $scripturl . '?action=admin;area=modsettings;save;sa=general';
  1941. $context['settings_title'] = $txt['mods_cat_modifications_misc'];
  1942. // No removing this line you, dirty unwashed mod authors. :p
  1943. if (empty($config_vars))
  1944. {
  1945. $context['settings_save_dont_show'] = true;
  1946. $context['settings_message'] = '<div class="centertext">' . $txt['modification_no_misc_settings'] . '</div>';
  1947. return prepareDBSettingContext($config_vars);
  1948. }
  1949. // Saving?
  1950. if (isset($_GET['save']))
  1951. {
  1952. checkSession();
  1953. $save_vars = $config_vars;
  1954. call_integration_hook('integrate_save_general_mod_settings', array(&$save_vars));
  1955. // This line is to help mod authors do a search/add after if you want to add something here. Keyword: FOOT TAPPING SUCKS!
  1956. saveDBSettings($save_vars);
  1957. // This line is to help mod authors do a search/add after if you want to add something here. Keyword: I LOVE TEA!
  1958. redirectexit('action=admin;area=modsettings;sa=general');
  1959. }
  1960. // This line is to help mod authors do a search/add after if you want to add something here. Keyword: RED INK IS FOR TEACHERS AND THOSE WHO LIKE PAIN!
  1961. prepareDBSettingContext($config_vars);
  1962. }
  1963. ?>