PageRenderTime 39ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/plugins/simple-forum/install/sf-upgrade.php

https://bitbucket.org/crypticrod/sr_wp_code
PHP | 3019 lines | 2392 code | 417 blank | 210 comment | 107 complexity | 99d82506a6870d7ad8bd853de4a9f79e MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.1, GPL-3.0, LGPL-2.0, AGPL-3.0
  1. <?php
  2. /*
  3. Simple:Press
  4. Upgrade Path Routines
  5. $LastChangedDate: 2011-06-05 09:16:54 -0700 (Sun, 05 Jun 2011) $
  6. $Rev: 6253 $
  7. */
  8. if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) {
  9. die('Access Denied');
  10. }
  11. global $wpdb, $current_user;
  12. $InstallID = get_option('sfInstallID'); # use wp option table
  13. wp_set_current_user($InstallID);
  14. # use WP check here since SPF stuff may not be set up
  15. if(!current_user_can('activate_plugins'))
  16. {
  17. echo (__('Access Denied - Only Users who can Activate Plugins may perform this upgrade', 'sforum'));
  18. die();
  19. }
  20. sf_setup_sitewide_constants();
  21. sf_setup_global_constants();
  22. require_once (dirname(__FILE__).'/sf-upgrade-support.php');
  23. require_once (dirname(__FILE__).'/../admin/library/sfa-support.php');
  24. if(!isset($_GET['start'])) die();
  25. $checkval = $_GET['start'];
  26. $build = intval($checkval);
  27. # Start of Upgrade Routines =============
  28. $section = 200;
  29. if($build < $section)
  30. {
  31. # 1.2 =====================================================================================
  32. add_option('sfsortdesc', false);
  33. # 1.3 =====================================================================================
  34. add_option('sfavatars', true);
  35. add_option('sfshownewadmin', true);
  36. add_option('sfshownewuser', true);
  37. add_option('sfshownewcount', 6);
  38. add_option('sfdates', get_option('date_format'));
  39. add_option('sftimes', get_option('time_format'));
  40. add_option('sfzone', 0);
  41. $create_ddl = "ALTER TABLE ".SFFORUMS. " ADD (forum_desc varchar(150) default NULL)";
  42. sf_upgrade_database(SFFORUMS, 'forum_desc', $create_ddl);
  43. # 1.4 =====================================================================================
  44. add_option('sfshowavatars', true);
  45. add_option('sfuserabove', false);
  46. add_option('sfrte', true);
  47. add_option('sfskin', 'default');
  48. add_option('sficon', 'default');
  49. # 1.6 =====================================================================================
  50. $create_ddl = "ALTER TABLE ".SFFORUMS. " ADD (forum_status int(4) NOT NULL default '0')";
  51. sf_upgrade_database(SFFORUMS, 'forum_status', $create_ddl);
  52. $create_ddl = "ALTER TABLE ".SFPOSTS. " ADD (post_pinned smallint(1) NOT NULL default '0')";
  53. sf_upgrade_database(SFPOSTS, 'post_pinned', $create_ddl);
  54. $postusers = $wpdb->get_results("SELECT user_id, COUNT(post_id) AS numposts FROM ".SFPOSTS." WHERE user_id IS NOT NULL GROUP BY user_id");
  55. if($postusers)
  56. {
  57. foreach($postusers as $postuser)
  58. {
  59. update_user_option($postuser->user_id, 'sfposts', $postuser->numposts);
  60. }
  61. }
  62. add_option('sfstopedit', true);
  63. add_option('sfmodmembers', false);
  64. add_option('sfmodusers', '');
  65. add_option('sftopicsort', false);
  66. sf_check_data_integrity();
  67. # 1.7 =====================================================================================
  68. $create_ddl = "ALTER TABLE ".SFTOPICS. " ADD (topic_subs longtext)";
  69. sf_upgrade_database(SFTOPICS, 'topic_subs', $create_ddl);
  70. sf_rebuild_subscriptions();
  71. add_option('sfavatarsize', 50);
  72. delete_option('sffilters');
  73. delete_option('sfrte');
  74. $create_ddl = "ALTER TABLE ".SFGROUPS. " ADD (group_desc varchar(150) default NULL)";
  75. sf_upgrade_database(SFGROUPS, 'group_desc', $create_ddl);
  76. $create_ddl = "ALTER TABLE ".SFGROUPS. " ADD (group_view varchar(20) default 'public')";
  77. sf_upgrade_database(SFGROUPS, 'group_view', $create_ddl);
  78. $create_ddl = "ALTER TABLE ".SFFORUMS. " ADD (forum_view varchar(20) default 'public')";
  79. sf_upgrade_database(SFFORUMS, 'forum_view', $create_ddl);
  80. # 1.8 =====================================================================================
  81. $create_ddl = "ALTER TABLE ".SFTOPICS. " ADD (topic_sort varchar(4) default NULL)";
  82. sf_upgrade_database(SFTOPICS, 'topic_sort', $create_ddl);
  83. add_option('sfspam', true);
  84. add_option('sfpermalink', get_permalink(get_option('sfpage')));
  85. add_option('sfextprofile', true);
  86. add_option('sfusersig', true);
  87. add_option('sfhome', SFHOMEURL);
  88. # 1.9 =====================================================================================
  89. $create_ddl = "ALTER TABLE ".SFTOPICS. " ADD (topic_opened bigint(20) NOT NULL default '0')";
  90. sf_upgrade_database(SFTOPICS, 'topic_opened', $create_ddl);
  91. $icons='Login;1@Register;1@Logout;1@Profile;1@Add a New Topic;1@Forum Locked;1@Reply to Post;1@Topic Locked;1@Quote and Reply;1@Edit Your Post;1@Return to Search Results;1@Subscribe;1@Forum RSS;1@Topic RSS;1';
  92. update_option('sfshowicon', $icons);
  93. add_option('sfrss', true);
  94. add_option('sfrsscount', 15);
  95. add_option('sfrsswords', 0);
  96. add_option('sfpagedposts', 20);
  97. add_option('sfgravatar', false);
  98. add_option('sfmodonce', false);
  99. add_option('sftitle', true);
  100. add_option('sflang', 'en');
  101. $fcols['topics']=true;
  102. $fcols['posts']=true;
  103. add_option('sfforumcols', $fcols);
  104. $tcols['first']=true;
  105. $tcols['last']=true;
  106. $tcols['posts']=true;
  107. $tcols['views']=true;
  108. add_option('sftopiccols', $tcols);
  109. $sql = "
  110. CREATE TABLE IF NOT EXISTS ".SFTRACK." (
  111. id bigint(20) NOT NULL auto_increment,
  112. trackuserid bigint(20) default 0,
  113. trackname varchar(25) NOT NULL,
  114. trackdate datetime NOT NULL,
  115. PRIMARY KEY (id)
  116. ) ENGINE=MyISAM ".sf_charset().";";
  117. $wpdb->query($sql);
  118. update_option('sfbuild', $section);
  119. echo $section;
  120. die();
  121. }
  122. $section = 220;
  123. if($build < $section)
  124. {
  125. # 2.0 =====================================================================================
  126. $create_ddl = "ALTER TABLE ".SFWAITING. " ADD (post_id bigint(20) NOT NULL default '0')";
  127. sf_upgrade_database(SFWAITING, 'post_id', $create_ddl);
  128. $sql = "ALTER TABLE ".SFTRACK." MODIFY trackname VARCHAR(50) NOT NULL;";
  129. $wpdb->query($sql);
  130. sf_clean_topic_subs();
  131. $icons=sf_opcheck(get_option('sfshowicon'));
  132. if(strpos($icons, '@New Posts;') === false)
  133. {
  134. $icons.= '@All RSS;1@Search;1@New Posts;1';
  135. update_option('sfshowicon', $icons);
  136. }
  137. $sql = "
  138. CREATE TABLE IF NOT EXISTS ".SFSETTINGS." (
  139. setting_id bigint(20) NOT NULL auto_increment,
  140. setting_name varchar(20) NOT NULL,
  141. setting_value longtext,
  142. PRIMARY KEY (setting_id)
  143. ) ENGINE=MyISAM ".sf_charset().";";
  144. $wpdb->query($sql);
  145. $sql = "
  146. CREATE TABLE IF NOT EXISTS ".SFNOTICE." (
  147. id varchar(30) NOT NULL,
  148. item varchar(15),
  149. message longtext,
  150. PRIMARY KEY (id)
  151. ) ENGINE=MyISAM ".sf_charset().";";
  152. $wpdb->query($sql);
  153. delete_option('sfsearch');
  154. delete_option('sfaction');
  155. delete_option('sfppage');
  156. delete_option('sftpage');
  157. delete_option('sfmessage');
  158. add_option('sfstats', true);
  159. add_option('sfshownewabove', false);
  160. add_option('sfshowlogin', true);
  161. $avatar = sf_relocate_avatars();
  162. if($avatar != 0)
  163. {
  164. add_option('sfinstallav', $avatar);
  165. }
  166. update_option('sfbuild', $section);
  167. echo $section;
  168. die();
  169. }
  170. $section = 228;
  171. if($build < $section)
  172. {
  173. # 2.1 =====================================================================================
  174. sf_correct_sflast();
  175. $wpdb->query("DELETE FROM ".SFSETTINGS." WHERE setting_name <> 'maxonline';");
  176. $wpdb->query("ALTER TABLE ".SFSETTINGS." MODIFY setting_name VARCHAR(50) NOT NULL;");
  177. $create_ddl = "ALTER TABLE ".SFSETTINGS." ADD (setting_date datetime NOT NULL);";
  178. sf_upgrade_database(SFSETTINGS, 'setting_date', $create_ddl);
  179. $create_ddl = "ALTER TABLE ".SFNOTICE." ADD (ndate datetime NOT NULL);";
  180. sf_upgrade_database(SFNOTICE, 'ndate', $create_ddl);
  181. $create_ddl = "ALTER TABLE ".SFWAITING." ADD (user_id bigint(20) default 0);";
  182. sf_upgrade_database(SFWAITING, 'user_id', $create_ddl);
  183. $wpdb->query("ALTER TABLE ".SFFORUMS." ADD INDEX groupf_idx (group_id);");
  184. $wpdb->query("ALTER TABLE ".SFPOSTS." ADD INDEX topicp_idx (topic_id);");
  185. $wpdb->query("ALTER TABLE ".SFPOSTS." ADD INDEX forump_idx (forum_id);");
  186. $wpdb->query("ALTER TABLE ".SFTOPICS." ADD INDEX forumt_idx (forum_id);");
  187. add_option('sfregmath', true);
  188. add_option('sfsearchbar', true);
  189. add_option('sfadminspam', true);
  190. add_option('sfshowhome', true);
  191. add_option('sflockdown', false);
  192. add_option('sfshowmodposts', true);
  193. # Links
  194. $create_ddl = "ALTER TABLE ".SFTOPICS. " ADD (blog_post_id bigint(20) NOT NULL default '0')";
  195. sf_upgrade_database(SFTOPICS, 'blog_post_id', $create_ddl);
  196. add_option('sflinkuse', false);
  197. add_option('sflinkexcerpt', false);
  198. add_option('sflinkwords', 100);
  199. add_option('sflinkblogtext', '%ICON% Join the forum discussion on this post');
  200. add_option('sflinkforumtext', '%ICON% Read original blog post');
  201. add_option('sflinkabove', false);
  202. # Announce Tag
  203. add_option('sfuseannounce', false);
  204. add_option('sfannouncecount', 8);
  205. add_option('sfannouncehead', 'Most Recent Forum Posts');
  206. add_option('sfannounceauto', false);
  207. add_option('sfannouncetime', 60);
  208. add_option('sfannouncetext', '%TOPICNAME% posted by %POSTER% in %FORUMNAME% on %DATETIME%');
  209. add_option('sfannouncelist', false);
  210. # Rankings
  211. $ranks=array('New Member' => 2, 'Member' => 1000);
  212. add_option('sfrankings', $ranks);
  213. $icons=sf_opcheck(get_option('sfshowicon'));
  214. if(strpos($icons, '@Group RSS;') === false)
  215. {
  216. $icons.= '@Group RSS;1';
  217. update_option('sfshowicon', $icons);
  218. }
  219. # New since build 225
  220. $cols=sf_opcheck(get_option('sfforumcols'));
  221. $cols['last'] = false;
  222. update_option('sfforumcols', $cols);
  223. update_option('sfbuild', $section);
  224. echo $section;
  225. die();
  226. }
  227. $section = 250;
  228. if($build < $section)
  229. {
  230. # 3.0 =====================================================================================
  231. # Pre-create last visit dates for all existing users who don't have one
  232. sf_precreate_sflast();
  233. $sql = "
  234. CREATE TABLE IF NOT EXISTS ".SFMESSAGES." (
  235. message_id bigint(20) NOT NULL auto_increment,
  236. sent_date datetime NOT NULL,
  237. from_id bigint(20) default NULL,
  238. to_id bigint(20) default NULL,
  239. title text,
  240. message text,
  241. message_status smallint(1) NOT NULL default '0',
  242. inbox smallint(1) NOT NULL default '1',
  243. sentbox smallint(1) NOT NULL default '1',
  244. is_reply smallint(1) NOT NULL default '0',
  245. PRIMARY KEY (message_id)
  246. ) ENGINE=MyISAM ".sf_charset().";";
  247. $wpdb->query($sql);
  248. # Slugs
  249. $create_ddl = "ALTER TABLE ".SFFORUMS. " ADD (forum_slug varchar(85) NOT NULL)";
  250. sf_upgrade_database(SFFORUMS, 'forum_slug', $create_ddl);
  251. $create_ddl = "ALTER TABLE ".SFTOPICS. " ADD (topic_slug varchar(110) NOT NULL)";
  252. sf_upgrade_database(SFTOPICS, 'topic_slug', $create_ddl);
  253. sf_create_slugs();
  254. add_option('sfimgenlarge', false);
  255. add_option('sfthumbsize', 100);
  256. add_option('sfmodasadmin', false);
  257. add_option('sfmemberspam', true);
  258. add_option('sfuppath', '');
  259. # email option array
  260. $adminname = sf_opcheck(get_user_meta($current_user->ID, 'first_name', true));
  261. $sfmail = array();
  262. $sfmail['sfmailsender'] = get_bloginfo('name');
  263. $sfmail['sfmailfrom'] = str_replace(' ', '', $adminname);
  264. $sfmail['sfmaildomain'] = preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME']));
  265. add_option('sfmail', $sfmail);
  266. # new user email array
  267. $sfmail = array();
  268. $sfmail['sfnewusersubject'] = 'Welcome to %BLOGNAME%';
  269. $sfmail['sfnewusertext'] = 'Welcome %USERNAME% to %BLOGNAME% %NEWLINE%Please find below your login details: %NEWLINE%Username: %USERNAME% %NEWLINE%Password: %PASSWORD% %NEWLINE%%LOGINURL%';
  270. add_option('sfnewusermail', $sfmail);
  271. $icons=sf_opcheck(get_option('sfshowicon'));
  272. if(strpos($icons, '@Send PM;') === false)
  273. {
  274. $icons.= '@Send PM;1@Return to forum;1@Compose PM;1@Go To Inbox;1@Go To Sentbox;1@Report Post;1';
  275. update_option('sfshowicon', $icons);
  276. }
  277. update_option('sfbuild', $section);
  278. echo $section;
  279. die();
  280. }
  281. $section = 255;
  282. if($build < $section)
  283. {
  284. # Change usermeta values that previously used table prefix
  285. $oldkeys[0] = $wpdb->prefix.'sfavatar';
  286. $oldkeys[1] = $wpdb->prefix.'sfposts';
  287. $oldkeys[2] = $wpdb->prefix.'sflast';
  288. $oldkeys[3] = $wpdb->prefix.'sfsubscribe';
  289. $oldkeys[4] = $wpdb->prefix.'sfadmin';
  290. $newkeys[0] = 'sfavatar';
  291. $newkeys[1] = 'sfposts';
  292. $newkeys[2] = 'sflast';
  293. $newkeys[3] = 'sfsubscribe';
  294. $newkeys[4] = 'sfadmin';
  295. for($x=0; $x<count($oldkeys); $x++)
  296. {
  297. $sql = "UPDATE ".SFUSERMETA." SET meta_key = '".$newkeys[$x]."' WHERE meta_key = '".$oldkeys[$x]."'";
  298. $wpdb->query($sql);
  299. }
  300. # Create User Groups table
  301. $sql = "
  302. CREATE TABLE IF NOT EXISTS ".SFUSERGROUPS." (
  303. usergroup_id mediumint(8) unsigned NOT NULL auto_increment,
  304. usergroup_name varchar(50) NOT NULL default '',
  305. usergroup_desc varchar(150) NOT NULL default '',
  306. usergroup_locked tinyint(4) unsigned NOT NULL default '0',
  307. usergroup_is_moderator tinyint(4) unsigned NOT NULL default '0',
  308. PRIMARY KEY (usergroup_id)
  309. ) ENGINE=MyISAM ".sf_charset().";";
  310. $wpdb->query($sql);
  311. # Create the Permissions table
  312. $sql = "
  313. CREATE TABLE IF NOT EXISTS ".SFPERMISSIONS." (
  314. permission_id mediumint(8) unsigned NOT NULL auto_increment,
  315. forum_id mediumint(8) unsigned NOT NULL default '0',
  316. usergroup_id mediumint(8) unsigned NOT NULL default '0',
  317. permission_role mediumint(8) unsigned NOT NULL default '0',
  318. PRIMARY KEY (permission_id)
  319. ) ENGINE=MyISAM ".sf_charset().";";
  320. $wpdb->query($sql);
  321. # Create the Roles table
  322. $sql = "
  323. CREATE TABLE IF NOT EXISTS ".SFROLES." (
  324. role_id mediumint(8) unsigned NOT NULL auto_increment,
  325. role_name varchar(50) NOT NULL default '',
  326. role_desc varchar(150) NOT NULL default '',
  327. role_actions longtext NOT NULL,
  328. PRIMARY KEY (role_id)
  329. ) ENGINE=MyISAM ".sf_charset().";";
  330. $wpdb->query($sql);
  331. # setup an array of info for the data upgrades
  332. $keys = array();
  333. # Create default role data
  334. $actions = array();
  335. $actions['Can view forum'] = 0;
  336. $actions['Can start new topics'] = 0;
  337. $actions['Can reply to topics'] = 0;
  338. $actions['Can create linked topics'] = 0;
  339. $actions['Can break linked topics'] = 0;
  340. $actions['Can edit topic titles'] = 0;
  341. $actions['Can pin topics'] = 0;
  342. $actions['Can move topics'] = 0;
  343. $actions['Can move posts'] = 0;
  344. $actions['Can lock topics'] = 0;
  345. $actions['Can delete topics'] = 0;
  346. $actions['Can edit own posts forever'] = 0;
  347. $actions['Can edit own posts until reply'] = 0;
  348. $actions['Can edit any posts'] = 0;
  349. $actions['Can delete any posts'] = 0;
  350. $actions['Can pin posts'] = 0;
  351. $actions['Can view users email addresses'] = 0;
  352. $actions['Can view members profiles'] = 0;
  353. $actions['Can report posts'] = 0;
  354. $actions['Can sort most recent posts'] = 0;
  355. $actions['Can bypass spam control'] = 0;
  356. $actions['Can bypass post moderation'] = 0;
  357. $actions['Can bypass post moderation once'] = 0;
  358. $actions['Can upload images'] = 0;
  359. $actions['Can upload media'] = 0;
  360. $actions['Can upload files'] = 0;
  361. $actions['Can use signatures'] = 0;
  362. $actions['Can use images in signatures'] = 0;
  363. $actions['Can upload avatars'] = 0;
  364. $actions['Can use private messaging'] = 0;
  365. $actions['Can subscribe'] = 0;
  366. $actions['Can moderate pending posts'] = 0;
  367. $role_name = 'No Access';
  368. $role_desc = 'Permission with no access to any Forum features.';
  369. sfa_create_role_row($role_name, $role_desc, serialize($actions));
  370. $actions = array();
  371. $actions['Can view forum'] = 1;
  372. $actions['Can start new topics'] = 0;
  373. $actions['Can reply to topics'] = 0;
  374. $actions['Can create linked topics'] = 0;
  375. $actions['Can break linked topics'] = 0;
  376. $actions['Can edit topic titles'] = 0;
  377. $actions['Can pin topics'] = 0;
  378. $actions['Can move topics'] = 0;
  379. $actions['Can move posts'] = 0;
  380. $actions['Can lock topics'] = 0;
  381. $actions['Can delete topics'] = 0;
  382. $actions['Can edit own posts forever'] = 0;
  383. $actions['Can edit own posts until reply'] = 0;
  384. $actions['Can edit any posts'] = 0;
  385. $actions['Can delete any posts'] = 0;
  386. $actions['Can pin posts'] = 0;
  387. $actions['Can view users email addresses'] = 0;
  388. $actions['Can view members profiles'] = 0;
  389. $actions['Can report posts'] = 0;
  390. $actions['Can sort most recent posts'] = 0;
  391. $actions['Can bypass spam control'] = 0;
  392. $actions['Can bypass post moderation'] = 0;
  393. $actions['Can bypass post moderation once'] = 0;
  394. $actions['Can upload images'] = 0;
  395. $actions['Can upload media'] = 0;
  396. $actions['Can upload files'] = 0;
  397. $actions['Can use signatures'] = 0;
  398. $actions['Can use images in signatures'] = 0;
  399. $actions['Can upload avatars'] = 0;
  400. $actions['Can use private messaging'] = 0;
  401. $actions['Can subscribe'] = 0;
  402. $actions['Can moderate pending posts'] = 0;
  403. $role_name = 'Read Only Access';
  404. $role_desc = 'Permission with access to only view the Forum.';
  405. sfa_create_role_row($role_name, $role_desc, serialize($actions));
  406. $actions = array();
  407. $actions['Can view forum'] = 1;
  408. $actions['Can start new topics'] = 1;
  409. $actions['Can reply to topics'] = 1;
  410. $actions['Can create linked topics'] = 0;
  411. $actions['Can break linked topics'] = 0;
  412. $actions['Can edit topic titles'] = 0;
  413. $actions['Can pin topics'] = 0;
  414. $actions['Can move topics'] = 0;
  415. $actions['Can move posts'] = 0;
  416. $actions['Can lock topics'] = 0;
  417. $actions['Can delete topics'] = 0;
  418. $actions['Can edit own posts forever'] = 0;
  419. $actions['Can edit own posts until reply'] = 1;
  420. $actions['Can edit any posts'] = 0;
  421. $actions['Can delete any posts'] = 0;
  422. $actions['Can pin posts'] = 0;
  423. $actions['Can view users email addresses'] = 0;
  424. $actions['Can view members profiles'] = 1;
  425. $actions['Can report posts'] = 1;
  426. $actions['Can sort most recent posts'] = 0;
  427. $actions['Can bypass spam control'] = 0;
  428. $actions['Can bypass post moderation'] = 0;
  429. $actions['Can bypass post moderation once'] = 0;
  430. $actions['Can upload images'] = 0;
  431. $actions['Can upload media'] = 0;
  432. $actions['Can upload files'] = 0;
  433. $actions['Can use signatures'] = 0;
  434. $actions['Can use images in signatures'] = 0;
  435. $actions['Can upload avatars'] = 1;
  436. $actions['Can use private messaging'] = 0;
  437. $actions['Can subscribe'] = 1;
  438. $actions['Can moderate pending posts'] = 0;
  439. $role_name = 'Limited Access';
  440. $role_desc = 'Permission with access to reply and start topics but with limited features.';
  441. sfa_create_role_row($role_name, $role_desc, serialize($actions));
  442. if(sf_opcheck(get_option('sfallowguests'))) $roleid = $wpdb->insert_id;
  443. # Create default 'Guest' user group data
  444. $guests = sfa_create_usergroup_row('Guests', 'Default Usergroup for guests of the forum.', '0', false);
  445. $keys[0]['usergroup'] = $wpdb->insert_id;
  446. $keys[0]['permission'] = $roleid;
  447. $actions = array();
  448. $actions['Can view forum'] = 1;
  449. $actions['Can start new topics'] = 1;
  450. $actions['Can reply to topics'] = 1;
  451. $actions['Can create linked topics'] = 0;
  452. $actions['Can break linked topics'] = 0;
  453. $actions['Can edit topic titles'] = 0;
  454. $actions['Can pin topics'] = 0;
  455. $actions['Can move topics'] = 0;
  456. $actions['Can move posts'] = 0;
  457. $actions['Can lock topics'] = 0;
  458. $actions['Can delete topics'] = 0;
  459. $actions['Can edit own posts forever'] = 0;
  460. $actions['Can edit own posts until reply'] = 1;
  461. $actions['Can edit any posts'] = 0;
  462. $actions['Can delete any posts'] = 0;
  463. $actions['Can pin posts'] = 0;
  464. $actions['Can view users email addresses'] = 0;
  465. $actions['Can view members profiles'] = 1;
  466. $actions['Can report posts'] = 1;
  467. $actions['Can sort most recent posts'] = 0;
  468. $actions['Can bypass spam control'] = 0;
  469. $actions['Can bypass post moderation'] = 1;
  470. $actions['Can bypass post moderation once'] = 1;
  471. $actions['Can upload images'] = 0;
  472. $actions['Can upload media'] = 0;
  473. $actions['Can upload files'] = 0;
  474. $actions['Can use signatures'] = 1;
  475. $actions['Can use images in signatures'] = 1;
  476. $actions['Can upload avatars'] = 1;
  477. $actions['Can use private messaging'] = 1;
  478. $actions['Can subscribe'] = 1;
  479. $actions['Can moderate pending posts'] = 0;
  480. $role_name = 'Standard Access';
  481. $role_desc = 'Permission with access to reply and start topics with advanced features such as signatures and private messaging.';
  482. sfa_create_role_row($role_name, $role_desc, serialize($actions));
  483. $roleid = $wpdb->insert_id;
  484. # Create default 'Members' user group data
  485. $members = sfa_create_usergroup_row('Members', 'Default Usergroup for registered users of the forum.', '0', false);
  486. $keys[1]['usergroup'] = $members;
  487. $keys[1]['permission'] = $roleid;
  488. $actions = array();
  489. $actions['Can view forum'] = 1;
  490. $actions['Can start new topics'] = 1;
  491. $actions['Can reply to topics'] = 1;
  492. $actions['Can create linked topics'] = 0;
  493. $actions['Can break linked topics'] = 0;
  494. $actions['Can edit topic titles'] = 0;
  495. $actions['Can pin topics'] = 0;
  496. $actions['Can move topics'] = 0;
  497. $actions['Can move posts'] = 0;
  498. $actions['Can lock topics'] = 0;
  499. $actions['Can delete topics'] = 0;
  500. $actions['Can edit own posts forever'] = 1;
  501. $actions['Can edit own posts until reply'] = 1;
  502. $actions['Can edit any posts'] = 0;
  503. $actions['Can delete any posts'] = 0;
  504. $actions['Can pin posts'] = 0;
  505. $actions['Can view users email addresses'] = 0;
  506. $actions['Can view members profiles'] = 1;
  507. $actions['Can report posts'] = 1;
  508. $actions['Can sort most recent posts'] = 0;
  509. $actions['Can bypass spam control'] = 1;
  510. $actions['Can bypass post moderation'] = 1;
  511. $actions['Can bypass post moderation once'] = 1;
  512. $actions['Can upload images'] = 1;
  513. $actions['Can upload media'] = 1;
  514. $actions['Can upload files'] = 1;
  515. $actions['Can use signatures'] = 1;
  516. $actions['Can use images in signatures'] = 1;
  517. $actions['Can upload avatars'] = 1;
  518. $actions['Can use private messaging'] = 1;
  519. $actions['Can subscribe'] = 1;
  520. $actions['Can moderate pending posts'] = 0;
  521. $role_name = 'Full Access';
  522. $role_desc = 'Permission with Standard Access features plus image uploading and spam control bypass.';
  523. sfa_create_role_row($role_name, $role_desc, serialize($actions));
  524. $actions = array();
  525. $actions['Can view forum'] = 1;
  526. $actions['Can start new topics'] = 1;
  527. $actions['Can reply to topics'] = 1;
  528. $actions['Can create linked topics'] = 1;
  529. $actions['Can break linked topics'] = 1;
  530. $actions['Can edit topic titles'] = 1;
  531. $actions['Can pin topics'] = 1;
  532. $actions['Can move topics'] = 1;
  533. $actions['Can move posts'] = 1;
  534. $actions['Can lock topics'] = 1;
  535. $actions['Can delete topics'] = 1;
  536. $actions['Can edit own posts forever'] = 1;
  537. $actions['Can edit own posts until reply'] = 1;
  538. $actions['Can edit any posts'] = 1;
  539. $actions['Can delete any posts'] = 1;
  540. $actions['Can pin posts'] = 1;
  541. $actions['Can view users email addresses'] = 1;
  542. $actions['Can view members profiles'] = 1;
  543. $actions['Can report posts'] = 1;
  544. $actions['Can sort most recent posts'] = 1;
  545. $actions['Can bypass spam control'] = 1;
  546. $actions['Can bypass post moderation'] = 1;
  547. $actions['Can bypass post moderation once'] = 1;
  548. $actions['Can upload images'] = 1;
  549. $actions['Can upload media'] = 1;
  550. $actions['Can upload files'] = 1;
  551. $actions['Can use signatures'] = 1;
  552. $actions['Can use images in signatures'] = 1;
  553. $actions['Can upload avatars'] = 1;
  554. $actions['Can use private messaging'] = 1;
  555. $actions['Can subscribe'] = 1;
  556. $actions['Can moderate pending posts'] = 1;
  557. $role_name = 'Moderator Access';
  558. $role_desc = 'Permission with access to all Forum features.';
  559. sfa_create_role_row($role_name, $role_desc, serialize($actions));
  560. $roleid = $wpdb->insert_id;
  561. # Create default 'Moderators' user group data
  562. $moderators = sfa_create_usergroup_row('Moderators', 'Default Usergroup for moderators of the forum.', '1', false);
  563. $keys[2]['usergroup'] = $moderators;
  564. $keys[2]['permission'] = $roleid;
  565. # ensure all users have a display name set
  566. sf_check_all_display_names();
  567. # set up the current userbase into default groups etc
  568. sf_setup_usergroup_data($members, $moderators, true, $keys);
  569. update_option('sfbuild', $section);
  570. echo $section;
  571. die();
  572. }
  573. $section = 300;
  574. if($build < $section)
  575. {
  576. $wpdb->query("ALTER TABLE ".SFGROUPS." DROP group_view;");
  577. $wpdb->query("ALTER TABLE ".SFFORUMS." DROP forum_view;");
  578. add_option('sfdefgroup', $members);
  579. add_option('sfbadwords', '');
  580. add_option('sfreplacementwords', '');
  581. add_option('sfpaging', 4);
  582. add_option('sfadminbar', true);
  583. # change sftitle
  584. $sftitle = array();
  585. $sftitle['sfinclude'] = sf_opcheck(get_option('sftitle'));
  586. $sftitle['sfnotitle'] = false;
  587. $sftitle['sfbanner'] = '';
  588. update_option('sftitle', $sftitle);
  589. $pm = array();
  590. $pm['sfpmemail'] = false;
  591. $pm['sfpmmax'] = 0;
  592. add_option('sfpm', $pm);
  593. $sfquicklinks = array();
  594. $sfquicklinks['sfqlshow'] = true;
  595. $sfquicklinks['sfqlcount'] = 15;
  596. add_option('sfquicklinks', $sfquicklinks);
  597. $sfcustom = array();
  598. $sfcustom[0]['custext']='';
  599. $sfcustom[0]['cuslink']='';
  600. $sfcustom[0]['cusicon']='';
  601. $sfcustom[1]['custext']='';
  602. $sfcustom[1]['cuslink']='';
  603. $sfcustom[1]['cusicon']='';
  604. $sfcustom[2]['custext']='';
  605. $sfcustom[2]['cuslink']='';
  606. $sfcustom[2]['cusicon']='';
  607. add_option('sfcustom', $sfcustom);
  608. # remove unwanted options
  609. delete_option('sfmodusers');
  610. delete_option('sfsubscriptions');
  611. delete_option('sfusersig');
  612. delete_option('sfstopedit');
  613. delete_option('sfmoderate');
  614. delete_option('sfmodonce');
  615. delete_option('sfavatars');
  616. delete_option('sfspam');
  617. delete_option('sflinkuse');
  618. delete_option('sfmodmembers');
  619. delete_option('sfadminspam');
  620. delete_option('sfmemberspam');
  621. $icons=sf_opcheck(get_option('sfshowicon'));
  622. if(strpos($icons, '@Moderation Queue') === false)
  623. {
  624. $icons.= '@Moderation Queue;1';
  625. update_option('sfshowicon', $icons);
  626. }
  627. # RSS feed urls
  628. $create_ddl = "ALTER TABLE ".SFFORUMS. " ADD (forum_rss text)";
  629. sf_upgrade_database(SFFORUMS, 'forum_rss', $create_ddl);
  630. $create_ddl = "ALTER TABLE ".SFGROUPS. " ADD (group_rss text)";
  631. sf_upgrade_database(SFGROUPS, 'group_rss', $create_ddl);
  632. # RSS feed urls
  633. $create_ddl = "ALTER TABLE ".SFFORUMS. " ADD (forum_icon varchar(25) default NULL)";
  634. sf_upgrade_database(SFFORUMS, 'forum_icon', $create_ddl);
  635. $create_ddl = "ALTER TABLE ".SFGROUPS. " ADD (group_icon varchar(25) default NULL)";
  636. sf_upgrade_database(SFGROUPS, 'group_icon', $create_ddl);
  637. # custom message for editor
  638. $sfpostmsg = array();
  639. $sfpostmsg['sfpostmsgtext'] = '';
  640. $sfpostmsg['sfpostmsgtopic'] = false;
  641. $sfpostmsg['sfpostmsgpost'] = false;
  642. update_option('sfpostmsg', $sfpostmsg);
  643. add_option('sfeditormsg','');
  644. add_option('sfautoupdate');
  645. add_option('sfcheck', true);
  646. update_option('sfbuild', $section);
  647. echo $section;
  648. die();
  649. }
  650. $section = 320;
  651. if($build < $section)
  652. {
  653. # 3.0.3 =====================================================================================
  654. # extra icons
  655. $icons=sf_opcheck(get_option('sfshowicon'));
  656. if(strpos($icons, '@Lock this Topic;') === false)
  657. {
  658. $icons.= '@Lock this Topic;1@Pin this Topic;1@Create Linked Post;1@Pin this Post;1@Edit Timestamp;1';
  659. update_option('sfshowicon', $icons);
  660. }
  661. update_option('sfbuild', $section);
  662. echo $section;
  663. die();
  664. }
  665. $section = 321;
  666. if($build < $section)
  667. {
  668. # 3.1 =====================================================================================
  669. # post id added to forum and topic tables
  670. $create_ddl = "ALTER TABLE ".SFFORUMS. " ADD (post_id bigint(20) default NULL)";
  671. sf_upgrade_database(SFFORUMS, 'post_id', $create_ddl);
  672. $create_ddl = "ALTER TABLE ".SFFORUMS. " ADD (topic_count mediumint(8) default '0')";
  673. sf_upgrade_database(SFFORUMS, 'topic_count', $create_ddl);
  674. $create_ddl = "ALTER TABLE ".SFTOPICS. " ADD (post_id bigint(20) default NULL)";
  675. sf_upgrade_database(SFTOPICS, 'post_id', $create_ddl);
  676. $create_ddl = "ALTER TABLE ".SFTOPICS. " ADD (post_count mediumint(8) default '0')";
  677. sf_upgrade_database(SFTOPICS, 'post_count', $create_ddl);
  678. $create_ddl = "ALTER TABLE ".SFPOSTS. " ADD (post_index mediumint(8) default '0')";
  679. sf_upgrade_database(SFPOSTS, 'post_index', $create_ddl);
  680. sf_build_lastposts();
  681. # new style array
  682. $sfstyle = array();
  683. $sfstyle['sfskin'] = sf_opcheck(get_option('sfskin'));
  684. $sfstyle['sficon'] = sf_opcheck(get_option('sficon'));
  685. $sfstyle['sflang'] = sf_opcheck(get_option('sflang'));
  686. $sfstyle['sfrtl'] = false;
  687. add_option('sfstyle', $sfstyle);
  688. delete_option('sfskin');
  689. delete_option('sficon');
  690. delete_option('sflang');
  691. # new login array
  692. $sflogin = array();
  693. $sflogin['sfshowlogin'] = sf_opcheck(get_option('sfshowlogin'));
  694. $sflogin['sfshowreg'] = sf_opcheck(get_option('sfshowlogin'));
  695. add_option('sflogin', $sflogin);
  696. delete_option('sfshowlogin');
  697. $sfadminsettings=array();
  698. $sfadminsettings['sfnotify']=sf_opcheck(get_option('sfnotify'));
  699. $sfadminsettings['sfadminbar']=sf_opcheck(get_option('sfadminbar'));
  700. $sfadminsettings['sfshownewadmin']=sf_opcheck(get_option('sfshownewadmin'));
  701. $sfadminsettings['sfmodasadmin']=sf_opcheck(get_option('sfmodasadmin'));
  702. $sfadminsettings['sfshowmodposts']=sf_opcheck(get_option('sfshowmodposts'));
  703. $sfadminsettings['sftools']=sf_opcheck(get_option('sfedit'));
  704. $sfadminsettings['sfqueue']=true;
  705. add_option('sfadminsettings', $sfadminsettings);
  706. delete_option('sfnotify');
  707. delete_option('sfadminbar');
  708. delete_option('sfshownewadmin');
  709. delete_option('sfmodasadmin');
  710. delete_option('sfshowmodposts');
  711. delete_option('sfedit');
  712. $sfauto=array();
  713. $sfauto['sfautoupdate']=sf_opcheck(get_option('sfautoupdate'));
  714. $sfauto['sfautotime']=300;
  715. add_option('sfauto', $sfauto);
  716. delete_option('sfautoupdate');
  717. $sffilters=array();
  718. $sffilters['sfnofollow']=false;
  719. $sffilters['sftarget']=true;
  720. add_option('sffilters', $sffilters);
  721. add_option('sfshowbreadcrumbs', true);
  722. update_option('sfbuild', $section);
  723. echo $section;
  724. die();
  725. }
  726. $section = 340;
  727. if($build < $section)
  728. {
  729. # sfmembers table def
  730. $sql = "
  731. CREATE TABLE IF NOT EXISTS ".SFMEMBERS." (
  732. user_id bigint(20) NOT NULL default '0',
  733. display_name varchar(100) default NULL,
  734. pm smallint(1) NOT NULL default '0',
  735. moderator smallint(1) NOT NULL default '0',
  736. quicktags smallint(1) NOT NULL default '0',
  737. usergroups longtext default NULL,
  738. avatar varchar(50) default NULL,
  739. signature tinytext default NULL,
  740. sigimage tinytext default NULL,
  741. posts int(4) NOT NULL default '0',
  742. lastvisit datetime default NULL,
  743. subscribe longtext,
  744. buddies longtext,
  745. newposts longtext,
  746. checktime datetime default NULL,
  747. PRIMARY KEY (user_id)
  748. ) ENGINE=MyISAM ".sf_charset().";";
  749. $wpdb->query($sql);
  750. sf_build_members_table('quicktags', 'upgrade');
  751. update_option('sfbuild', $section);
  752. echo $section;
  753. die();
  754. }
  755. $section = 356;
  756. if($build < $section)
  757. {
  758. # 3.1.3 ===================================================================================
  759. $sql = "UPDATE ".SFUSERGROUPS." SET usergroup_locked = '0'";
  760. $wpdb->query($sql);
  761. update_option('sfbuild', $section);
  762. echo $section;
  763. die();
  764. }
  765. $section = 360;
  766. if($build < $section)
  767. {
  768. # 4.0 =====================================================================================
  769. # add new Can view members profiles permission
  770. sf_upgrade_add_new_role('Can view members profiles', 0, true);
  771. $create_ddl = "ALTER TABLE ".SFFORUMS. " ADD (forum_rss_private smallint(1) NOT NULL default '0')";
  772. sf_upgrade_database(SFFORUMS, 'forum_rss_private', $create_ddl);
  773. $icons=sf_opcheck(get_option('sfshowicon'));
  774. if(strpos($icons, '@Subscribe to this Topic;') === false)
  775. {
  776. $icons.= '@Subscribe to this Topic;1';
  777. update_option('sfshowicon', $icons);
  778. }
  779. if (sf_opcheck(get_option('sfrss')))
  780. {
  781. $wpdb->query("UPDATE ".SFFORUMS." SET forum_rss_private=0");
  782. } else {
  783. $wpdb->query("UPDATE ".SFFORUMS." SET forum_rss_private=1");
  784. }
  785. delete_option('sfrss');
  786. update_option('sfbuild', $section);
  787. echo $section;
  788. die();
  789. }
  790. $section = 365;
  791. if($build < $section)
  792. {
  793. # take existing forum admin and grant all new spf capabilities
  794. $adminid = sf_opcheck(get_option('sfadmin'));
  795. $user = new WP_User($adminid);
  796. $user->add_cap('SPF Manage Options');
  797. $user->add_cap('SPF Manage Forums');
  798. $user->add_cap('SPF Manage User Groups');
  799. $user->add_cap('SPF Manage Permissions');
  800. $user->add_cap('SPF Manage Database');
  801. $user->add_cap('SPF Manage Components');
  802. $user->add_cap('SPF Manage Admins');
  803. $user->add_cap('SPF Manage Users');
  804. $create_ddl = "ALTER TABLE ".SFMEMBERS. " ADD (admin smallint(1) NOT NULL default '0')";
  805. sf_upgrade_database(SFMEMBERS, 'admin', $create_ddl);
  806. sf_update_member_item($adminid, 'admin', 1);
  807. delete_option('sfadmin');
  808. # sfmeta table def
  809. $sql = "
  810. CREATE TABLE IF NOT EXISTS ".SFMETA." (
  811. meta_id bigint(20) NOT NULL auto_increment,
  812. meta_type varchar(20) NOT NULL,
  813. meta_key varchar(100) default NULL,
  814. meta_value longtext,
  815. PRIMARY KEY (meta_id)
  816. ) ENGINE=MyISAM ".sf_charset().";";
  817. $wpdb->query($sql);
  818. $create_ddl = "ALTER TABLE ".SFFORUMS. " ADD (topic_status_set bigint(20) default '0')";
  819. sf_upgrade_database(SFFORUMS, 'topic_status_set', $create_ddl);
  820. $create_ddl = "ALTER TABLE ".SFTOPICS. " ADD (topic_status_flag bigint(20) default '0')";
  821. sf_upgrade_database(SFTOPICS, 'topic_status_flag', $create_ddl);
  822. # admin bar fixed
  823. $sfadminsettings=array();
  824. $sfadminsettings=sf_opcheck(get_option('sfadminsettings'));
  825. $sfadminsettings['sfbarfix']=false;
  826. update_option('sfadminsettings', $sfadminsettings);
  827. $icons=sf_opcheck(get_option('sfshowicon'));
  828. if(strpos($icons, '@Close New Post List;') === false)
  829. {
  830. $icons.= '@Close New Post List;1';
  831. update_option('sfshowicon', $icons);
  832. }
  833. update_option('sfbuild', $section);
  834. echo $section;
  835. die();
  836. }
  837. $section = 380;
  838. if($build < $section)
  839. {
  840. # add new columns for tracking watched topics
  841. $create_ddl = "ALTER TABLE ".SFMEMBERS. " ADD (watches longtext)";
  842. sf_upgrade_database(SFMEMBERS, 'watches', $create_ddl);
  843. # add new Can follow topics permission
  844. sf_upgrade_add_new_role('Can watch topics', 0, true);
  845. # add new Can change topic status permission
  846. sf_upgrade_add_new_role('Can change topic status', 0, false, true);
  847. $icons=sf_opcheck(get_option('sfshowicon'));
  848. if(strpos($icons, '@Review Watched Topics;') === false)
  849. {
  850. $icons.= '@Review Watched Topics;1@End Topic Watch;1@Watch Topic;1';
  851. }
  852. update_option('sfshowicon', $icons);
  853. # remove usergroup locked column that is no longer used
  854. $wpdb->query("ALTER TABLE ".SFUSERGROUPS." DROP usergroup_locked;");
  855. # add new columns for tracking watched topics
  856. $create_ddl = "ALTER TABLE ".SFTOPICS. " ADD (topic_watches longtext)";
  857. sf_upgrade_database(SFTOPICS, 'topic_watches', $create_ddl);
  858. add_option('sfpostpaging', 4);
  859. $qt = sf_opcheck(get_option('sfquicktags'));
  860. $sfeditor = array();
  861. if($qt ? $c = 2 : $c = 1);
  862. $sfeditor['sfeditor'] = $c;
  863. $sfeditor['sfusereditor'] = false;
  864. add_option('sfeditor', $sfeditor);
  865. delete_option('sfquicktags');
  866. $sfpostratings = array();
  867. $sfpostratings['sfpostratings'] = false;
  868. $sfpostratings['sfratingsstyle'] = 1;
  869. add_option('sfpostratings', $sfpostratings);
  870. # add new Can rate post permission
  871. sf_upgrade_add_new_role('Can rate posts', 0, true);
  872. # change members 'quicktags' to 'editor'
  873. $sql = "ALTER TABLE ".SFMEMBERS." CHANGE quicktags editor SMALLINT(1) NOT NULL DEFAULT '1'";
  874. $wpdb->query($sql);
  875. $sql = "UPDATE ".SFMEMBERS." SET editor=2 WHERE editor=1";
  876. $wpdb->query($sql);
  877. $sql = "UPDATE ".SFMEMBERS." SET editor=1 WHERE editor=0";
  878. $wpdb->query($sql);
  879. update_option('sfbuild', $section);
  880. echo $section;
  881. die();
  882. }
  883. $section = 400;
  884. if($build < $section)
  885. {
  886. # sfpostratings table def
  887. $sql = "
  888. CREATE TABLE IF NOT EXISTS ".SFPOSTRATINGS." (
  889. rating_id bigint(20) NOT NULL auto_increment,
  890. post_id bigint(20) NOT NULL,
  891. vote_count bigint(20) NOT NULL,
  892. ratings_sum bigint(20) NOT NULL,
  893. ips longtext,
  894. members longtext,
  895. PRIMARY KEY (rating_id)
  896. ) ENGINE=MyISAM ".sf_charset().";";
  897. $wpdb->query($sql);
  898. # add new columns for posts users have voted in
  899. $create_ddl = "ALTER TABLE ".SFMEMBERS." ADD (posts_rated longtext)";
  900. sf_upgrade_database(SFMEMBERS, 'posts_rated', $create_ddl);
  901. # sfdefpermissions table def
  902. $sql = "
  903. CREATE TABLE IF NOT EXISTS ".SFDEFPERMISSIONS." (
  904. permission_id mediumint(8) unsigned NOT NULL auto_increment,
  905. group_id mediumint(8) unsigned NOT NULL default '0',
  906. usergroup_id mediumint(8) unsigned NOT NULL default '0',
  907. permission_role mediumint(8) unsigned NOT NULL default '0',
  908. PRIMARY KEY (permission_id)
  909. ) ENGINE=MyISAM ".sf_charset().";";
  910. $wpdb->query($sql);
  911. # fill in the default permissions for existing groups
  912. sf_group_def_perms();
  913. update_option('sfbuild', $section);
  914. echo $section;
  915. die();
  916. }
  917. $section = 480;
  918. if($build < $section)
  919. {
  920. # create new base smiley folder
  921. $smiley = sf_relocate_smileys();
  922. if($smiley != 0)
  923. {
  924. add_option('sfinstallsm', $smiley);
  925. }
  926. sf_build_base_smileys();
  927. # smileys control options
  928. $sfsmileys = array();
  929. $sfsmileys['sfsmallow'] = true;
  930. $sfsmileys['sfsmtype'] = 1;
  931. update_option('sfsmileys', $sfsmileys);
  932. update_option('sfbuild', $section);
  933. echo $section;
  934. die();
  935. }
  936. $section = 620;
  937. if($build < $section)
  938. {
  939. # if default Guests user group exists use it as default for guests - otherwise leave blank
  940. $guests = $wpdb->get_var("SELECT usergroup_id FROM ".SFUSERGROUPS." WHERE usergroup_name='Guests'");
  941. add_option('sfguestsgroup', $guests);
  942. $sfusersnewposts = array();
  943. $sfusersnewposts['sfshownewuser'] = sf_opcheck(get_option('sfshownewuser'));
  944. $sfusersnewposts['sfshownewcount'] = sf_opcheck(get_option('sfshownewcount'));
  945. $sfusersnewposts['sfshownewabove'] = sf_opcheck(get_option('sfshownewabove'));
  946. $sfusersnewposts['sfsortinforum'] = true;
  947. add_option('sfusersnewposts', $sfusersnewposts);
  948. delete_option('sfshownewuser');
  949. delete_option('sfshownewcount');
  950. delete_option('sfshownewabove');
  951. delete_option('sfallowguests');
  952. sf_build_tinymce_toolbar_arrays();
  953. # add new columns for options for users that are admins
  954. $create_ddl = "ALTER TABLE ".SFMEMBERS." ADD (admin_options longtext)";
  955. sf_upgrade_database(SFMEMBERS, 'admin_options', $create_ddl);
  956. $sfadminsettings = array();
  957. $sfadminsettings = sf_opcheck(get_option('sfadminsettings'));
  958. $sfnewadminsettings = array();
  959. $sfnewadminsettings['sftools'] = sf_opcheck($sfadminsettings['sftools']);
  960. $sfnewadminsettings['sfmodasadmin'] = sf_opcheck($sfadminsettings['sfmodasadmin']);
  961. $sfnewadminsettings['sfshowmodposts'] = sf_opcheck($sfadminsettings['sfshowmodposts']);
  962. $sfnewadminsettings['sfqueue'] = sf_opcheck($sfadminsettings['sfqueue']);
  963. update_option('sfadminsettings', $sfnewadminsettings);
  964. $sfadminoptions = array();
  965. $sfadminoptions['sfadminbar'] = sf_opcheck($sfadminsettings['sfadminbar']);
  966. $sfadminoptions['sfbarfix'] = sf_opcheck($sfadminsettings['sfbarfix']);
  967. if (isset($sfadminsettings['sfqueue']))
  968. {
  969. $sfadminoptions['sfnotify'] = sf_opcheck($sfadminsettings['sfnotify']);
  970. $sfadminoptions['sfshownewadmin'] = sf_opcheck($sfadminsettings['sfshownewadmin']);
  971. }
  972. sf_update_member_item($current_user->ID, 'admin_options', $sfadminoptions);
  973. # Style and Editor array changes
  974. $sfstyle = array();
  975. $sfrepstyle = array();
  976. $sfstyle = sf_opcheck(get_option('sfstyle'));
  977. $sfrepstyle['sfskin'] = sf_opcheck($sfstyle['sfskin']);
  978. $sfrepstyle['sficon'] = sf_opcheck($sfstyle['sficon']);
  979. $sfrepstyle['sfsize'] = '';
  980. update_option('sfstyle', $sfrepstyle);
  981. $sfeditor = array();
  982. $sfeditor = sf_opcheck(get_option('sfeditor'));
  983. $sfeditor['sfrejectformat'] = false;
  984. $sfeditor['sftmcontentCSS'] = 'content.css';
  985. $sfeditor['sftmuiCSS'] = 'ui.css';
  986. $sfeditor['sftmdialogCSS'] = 'dialog.css';
  987. $sfeditor['SFhtmlCSS'] = 'htmlEditor.css';
  988. $sfeditor['SFbbCSS'] = 'bbcodeEditor.css';
  989. $sfeditor['sflang'] = sf_opcheck($sfstyle['sflang']);
  990. if(get_bloginfo('text_direction') == 'rtl' ? $sfeditor['sfrtl'] = true : $sfeditor['sfrtl'] = false);
  991. update_option('sfeditor', $sfeditor);
  992. # Login array changes
  993. $sflogin = array();
  994. $sflogin = sf_opcheck(get_option('sflogin'));
  995. $sflogin['sfregmath'] = sf_opcheck(get_option('sfregmath'));
  996. $sflogin['sfinlogin'] = true;
  997. $sflogin['sfregtext'] = false;
  998. $sflogin['sfregcheck'] = false;
  999. $sflogin['sfloginskin'] = true;
  1000. update_option('sflogin', $sflogin);
  1001. delete_option('sfregmath');
  1002. add_option('sflinkcomments', false);
  1003. add_option('sfshoweditdata', true);
  1004. add_option('sfshoweditlast', false);
  1005. update_option('sfbuild', $section);
  1006. echo $section;
  1007. die();
  1008. }
  1009. $section = 693;
  1010. if($build < $section)
  1011. {
  1012. # add new columns for storing post-post edits
  1013. $create_ddl = "ALTER TABLE ".SFPOSTS." ADD (post_edit mediumtext)";
  1014. sf_upgrade_database(SFPOSTS, 'post_edit', $create_ddl);
  1015. add_option('sfavataruploads', true);
  1016. add_option('sfprivatemessaging', true);
  1017. add_option('sfsingleforum', false);
  1018. add_option('sftaggedforum', '');
  1019. # transfer forum rankins from options table to our sf meta table
  1020. $rankings = sf_opcheck(get_option('sfrankings'));
  1021. foreach ($rankings as $rank=>$posts)
  1022. {
  1023. $rankdata['posts'] = $posts;
  1024. $rankdata['usergroup'] = 'none';
  1025. $rankdata['image'] = 'none';
  1026. sf_add_sfmeta('forum_rank', $rank, serialize($rankdata));
  1027. }
  1028. delete_option('sfrankings');
  1029. # create new table for user group memberships
  1030. $sql = "
  1031. CREATE TABLE IF NOT EXISTS ".SFMEMBERSHIPS." (
  1032. membership_id mediumint(8) unsigned NOT NULL auto_increment,
  1033. user_id mediumint(8) unsigned NOT NULL default '0',
  1034. usergroup_id mediumint(8) unsigned NOT NULL default '0',
  1035. PRIMARY KEY (membership_id)
  1036. ) ENGINE=MyISAM ".sf_charset().";";
  1037. $wpdb->query($sql);
  1038. # Build the Memberships from the usergroup column in the members table
  1039. sf_build_memberships_table();
  1040. update_option('sfbuild', $section);
  1041. echo $section;
  1042. die();
  1043. }
  1044. $section = 820;
  1045. if($build < $section)
  1046. {
  1047. # remove usergroups column from members table
  1048. $wpdb->query("ALTER TABLE ".SFMEMBERS." DROP usergroups;");
  1049. $sfeditor = array();
  1050. $sfeditor = sf_opcheck(get_option('sfeditor'));
  1051. $sfeditor['sfrelative'] = true;
  1052. update_option('sfeditor', $sfeditor);
  1053. $sfaiosp = array();
  1054. $sfaiosp['sfaiosp_topic'] = true;
  1055. $sfaiosp['sfaiosp_forum'] = true;
  1056. $sfaiosp['sfaiosp_sep'] = '|';
  1057. add_option('sfaiosp', $sfaiosp);
  1058. $sfsigimagesize = array();
  1059. $sfsigimagesize['sfsigwidth'] = 0;
  1060. $sfsigimagesize['sfsigheight'] = 0;
  1061. add_option('sfsigimagesize', $sfsigimagesize);
  1062. add_option('sfmemberlistperms', true);
  1063. # correct id in sfmembers possible problem
  1064. $found = false;
  1065. $found = false;
  1066. foreach ($wpdb->get_col("DESC ".SFMEMBERS, 0) as $column )
  1067. {
  1068. if ($column == 'id')
  1069. {
  1070. $found = true;
  1071. }
  1072. }
  1073. if($found)
  1074. {
  1075. $wpdb->query("ALTER TABLE ".SFMEMBERS." DROP id;");
  1076. $wpdb->query("ALTER TABLE ".SFMEMBERS." ADD PRIMARY KEY (user_id);");
  1077. }
  1078. # gravatar rating of G by default
  1079. add_option('sfgmaxrating', 1);
  1080. update_option('sfbuild', $section);
  1081. echo $section;
  1082. die();
  1083. }
  1084. $section = 828;
  1085. if($build < $section)
  1086. {
  1087. # pm message slugs
  1088. $create_ddl = "ALTER TABLE ".SFMESSAGES. " ADD (message_slug text NOT NULL)";
  1089. sf_upgrade_database(SFMESSAGES, 'message_slug', $create_ddl);
  1090. $wpdb->query("ALTER TABLE ".SFMESSAGES." ADD UNIQUE mslug (message_slug);");
  1091. sf_create_message_slugs();
  1092. update_option('sfbuild', $section);
  1093. echo $section;
  1094. die();
  1095. }
  1096. $section = 873;
  1097. if($build < $section)
  1098. {
  1099. add_option('sfcbexclusions', '');
  1100. add_option('sfshowmemberlist', true);
  1101. # store ip for posts
  1102. $create_ddl = "ALTER TABLE ".SFPOSTS. " ADD (poster_ip varchar(15) NOT NULL)";
  1103. sf_upgrade_database(SFPOSTS, 'poster_ip', $create_ddl);
  1104. update_option('sfbuild', $section);
  1105. echo $section;
  1106. die();
  1107. }
  1108. $section = 945;
  1109. if($build < $section)
  1110. {
  1111. # members icon text
  1112. $icons=sf_opcheck(get_option('sfshowicon'));
  1113. if(strpos($icons, '@Members;') === false)
  1114. {
  1115. $icons.= '@Members;1';
  1116. update_option('sfshowicon', $icons);
  1117. }
  1118. # remove name/title and description length limits from groups and forums
  1119. $wpdb->query("ALTER TABLE ".SFFORUMS." DROP INDEX fslug");
  1120. $wpdb->query("ALTER TABLE ".SFTOPICS." DROP INDEX tslug");
  1121. $wpdb->query("ALTER TABLE ".SFGROUPS." CHANGE group_name group_name TEXT NOT NULL");
  1122. $wpdb->query("ALTER TABLE ".SFGROUPS." CHANGE group_desc group_desc TEXT NULL DEFAULT NULL");
  1123. $wpdb->query("ALTER TABLE ".SFFORUMS." CHANGE forum_name forum_name TEXT NOT NULL");
  1124. $wpdb->query("ALTER TABLE ".SFFORUMS." CHANGE forum_desc forum_desc TEXT NULL DEFAULT NULL");
  1125. $wpdb->query("ALTER TABLE ".SFFORUMS." CHANGE forum_slug forum_slug TEXT NOT NULL");
  1126. $wpdb->query("ALTER TABLE ".SFTOPICS." CHANGE topic_name topic_name TEXT NOT NULL");
  1127. $wpdb->query("ALTER TABLE ".SFTOPICS." CHANGE topic_slug topic_slug TEXT NOT NULL");
  1128. # admin bar - force removal from bar only
  1129. $sfadminsettings=array();
  1130. $sfadminsettings=sf_opcheck(get_option('sfadminsettings'));
  1131. $sfadminsettings['sfbaronly']=false;
  1132. update_option('sfadminsettings', $sfadminsettings);
  1133. # add ability to turn off email settings
  1134. $sfmail = array();
  1135. $sfmail = sf_opcheck(get_option('sfmail'));
  1136. $sfmail['sfmailuse']=true;
  1137. update_option('sfmail', $sfmail);
  1138. add_option('sfwpavatar', false);
  1139. update_option('sfbuild', $section);
  1140. echo $section;
  1141. die();
  1142. }
  1143. # 4.0.1 =====================================================================================
  1144. $section = 1030;
  1145. if($build < $section)
  1146. {
  1147. # remove name/title and description length limits from user groups
  1148. $wpdb->query("ALTER TABLE ".SFUSERGROUPS." CHANGE usergroup_name usergroup_name TEXT NOT NULL");
  1149. $wpdb->query("ALTER TABLE ".SFUSERGROUPS." CHANGE usergroup_desc usergroup_desc TEXT NULL DEFAULT NULL");
  1150. update_option('sfbuild', $section);
  1151. echo $section;
  1152. die();
  1153. }
  1154. # 4.0.2 =====================================================================================
  1155. $section = 1360;
  1156. if($build < $section)
  1157. {
  1158. # Add blockquote to tm toolbar
  1159. sf_update_tmtoolbar_blockquote();
  1160. add_option('sfcheckformember', true);
  1161. # housekeeping routine to clean up duplicate memberships and members
  1162. sf_update_membership_cleanup();
  1163. update_option('sfbuild', $section);
  1164. echo $section;
  1165. die();
  1166. }
  1167. # 4.0.3 =====================================================================================
  1168. $section = 1373;
  1169. if($build < $section)
  1170. {
  1171. # dashboard settngs
  1172. $sfadminsettings=array();
  1173. $sfadminsettings=sf_opcheck(get_option('sfadminsettings'));
  1174. $sfadminsettings['sfdashboardposts']=true;
  1175. $sfadminsettings['sfdashboardstats']=true;
  1176. update_option('sfadminsettings', $sfadminsettings);
  1177. # Optional SPF New User Email
  1178. $sfmail = sf_opcheck(get_option('sfnewusermail'));
  1179. $sfmail['sfusespfreg'] = true;
  1180. update_option('sfnewusermail', $sfmail);
  1181. update_option('sfbuild', $section);
  1182. echo $section;
  1183. die();
  1184. }
  1185. # 4.1 =====================================================================================
  1186. $section = 1382;
  1187. if($build < $section)
  1188. {
  1189. # post linking excerpt options (1=full post, 2=full post excerpt, 3=WP Excerpt)
  1190. $sfpostlinking = array();
  1191. $excerpt = sf_opcheck(get_option('sflinkexcerpt'));
  1192. if ($excerpt ? $excerpt = 2 : $excerpt = 1);
  1193. $sfpostlinking['sflinkexcerpt'] = $excerpt;
  1194. $sfpostlinking['sflinksingle'] = false;
  1195. # combine all the post linking options into single array
  1196. $sfpostlinking['sflinkwords'] = sf_opcheck(get_option('sflinkwords'));
  1197. $sfpostlinking['sflinkblogtext'] = sf_opcheck(get_option('sflinkblogtext'));
  1198. $sfpostlinking['sflinkforumtext'] = sf_opcheck(get_option('sflinkforumtext'));
  1199. $sfpostlinking['sflinkabove'] = sf_opcheck(get_option('sflinkabove'));
  1200. $sfpostlinking['sflinkcomments'] = sf_opcheck(get_option('sflinkcomments'));
  1201. add_option('sfpostlinking', $sfpostlinking);
  1202. # remove old singular options
  1203. delete_option('sflinkexcerpt');
  1204. delete_option('sflinkwords');
  1205. delete_option('sflinkblogtext');
  1206. delete_option('sflinkforumtext');
  1207. delete_option('sflinkabove');
  1208. delete_option('sflinkcomments');
  1209. # add new columns for user options
  1210. $create_ddl = "ALTER TABLE ".SFMEMBERS." ADD (user_options longtext)";
  1211. sf_upgrade_database(SFMEMBERS, 'user_options', $create_ddl);
  1212. # build user options table with editor option
  1213. sf_create_user_options();
  1214. # drop the old editor column
  1215. $wpdb->query("ALTER TABLE ".SFMEMBERS." DROP editor;");
  1216. $icons=sf_opcheck(get_option('sfshowicon'));
  1217. if(strpos($icons, '@Unsubscribe;') === false)
  1218. {
  1219. $icons.= '@Unsubscribe;1';
  1220. update_option('sfshowicon', $icons);
  1221. }
  1222. # Add full text index for topic title search
  1223. $wpdb->query("ALTER TABLE ".SFTOPICS." ADD FULLTEXT topic_name_idx (topic_name)");
  1224. update_option('sfbuild', $section);
  1225. echo $section;
  1226. die();
  1227. }
  1228. $section = 1470;
  1229. if($build < $section)
  1230. {
  1231. # change name of current edit topic title role
  1232. sf_modify_rolename('Can edit topic titles', 'Can edit any topic titles');
  1233. # add new Can edit own topic titles permission
  1234. sf_upgrade_add_new_role('Can edit own topic titles', 0, false, true);
  1235. # code exclusions
  1236. $sfsupport = array();
  1237. $sfsupport['sfusinglinking'] = true;
  1238. $sfsupport['sfusingtags'] = true;
  1239. $sfsupport['sfusingwidgets'] = true;
  1240. $sfsupport['sfusingavatars'] = true;
  1241. add_option('sfsupport', $sfsupport);
  1242. $icons=sf_opcheck(get_option('sfshowicon'));
  1243. if (strpos($icons, '@Watch this Topic;') === false)
  1244. {
  1245. $icons.= '@Watch this Topic;1@Stop Watching this Topic;1@Unsubscribe from this Topic;1';
  1246. update_option('sfshowicon', $icons);
  1247. }
  1248. # get current members default group
  1249. $members = sf_opcheck(get_option('sfdefgroup'));
  1250. $guests = sf_opcheck(get_option('sfguestsgroup'));
  1251. # remove default usergroups from options
  1252. delete_option('sfguestsgroup');
  1253. delete_option('sfdefgroup');
  1254. # create new default usergroups in sfmeta
  1255. sf_add_sfmeta('default usergroup', 'sfguests', $guests); # default usergroup for guests
  1256. sf_add_sfmeta('default usergroup', 'sfmembers', $members); # default usergroup for members
  1257. sf_create_usergroup_meta($members); # create default usergroups for existing wp roles
  1258. # re-assert s/ug indices and name.title length restrictions in database
  1259. $wpdb->query("ALTER TABLE ".SFFORUMS." CHANGE forum_name forum_name VARCHAR(200) NOT NULL;");
  1260. $wpdb->query("ALTER TABLE ".SFFORUMS." CHANGE forum_slug forum_slug VARCHAR(200) NOT NULL;");
  1261. $wpdb->query("ALTER TABLE ".SFFORUMS." ADD INDEX fslug_idx (forum_slug);");
  1262. $wpdb->query("ALTER TABLE ".SFTOPICS." CHANGE topic_name topic_name VARCHAR(200) NOT NULL;");
  1263. $wpdb->query("ALTER TABLE ".SFTOPICS." CHANGE topic_slug topic_slug VARCHAR(200) NOT NULL;");
  1264. $wpdb->query("ALTER TABLE ".SFTOPICS." ADD INDEX tslug_idx (topic_slug);");
  1265. $wpdb->query("ALTER TABLE ".SFMESSAGES." CHANGE title title VARCHAR(200) NULL DEFAULT NULL;");
  1266. $wpdb->query("ALTER TABLE ".SFMESSAGES." CHANGE message_slug message_slug VARCHAR(200) NOT NULL;");
  1267. $wpdb->query("ALTER TABLE ".SFMESSAGES." ADD INDEX mslug_idx (message_slug);");
  1268. update_option('sfbuild', $section);
  1269. echo $section;
  1270. die();
  1271. }
  1272. $section = 1720;
  1273. if($build < $section)
  1274. {
  1275. add_option('sfsinglemembership', false);
  1276. $sql = "ALTER TABLE ".SFMEMBERS." MODIFY posts int(4) default NULL";
  1277. $wpdb->query($sql);
  1278. # New controls option array
  1279. $max = get_sfsetting('maxonline');
  1280. if(empty($max)) $max = 0;
  1281. delete_sfsetting('maxonline');
  1282. $sfcontrols = array();
  1283. $sfcontrols['dayflag'] = '0';
  1284. $sfcontrols['hourflag'] = '0';
  1285. $sfcontrols['maxonline'] = $max;
  1286. $sfcontrols['membercount'] = 0;
  1287. $sfcontrols['guestcount'] = 0;
  1288. $sfcontrols['fourofour'] = false;
  1289. add_option('sfcontrols', $sfcontrols);
  1290. # New count and info fields
  1291. $create_ddl = "ALTER TABLE ".SFFORUMS. " ADD (post_count mediumint(8) default '0')";
  1292. sf_upgrade_database(SFFORUMS, 'post_count', $create_ddl);
  1293. sf_build_41_counts();
  1294. # change over to topic subscriptions and watches being stored in serialized arrays
  1295. sf_serialize_subs_watches_ratings();
  1296. # allow post ratings on forum by forum basis
  1297. $wpdb->query("ALTER TABLE ".SFFORUMS." ADD (post_ratings smallint(1) NOT NULL default '0')");
  1298. # enablef or all forums if currently enabled
  1299. $sfpostratings = sf_opcheck(get_option('sfpostratings'));
  1300. if ($sfpostratings['sfpostratings']) $wpdb->query("UPDATE ".SFFORUMS." SET post_ratings=1");
  1301. # add spoiler tinymce plugin
  1302. sf_update_tmtoolbar_spoiler();
  1303. # SPF Manage Toolbox caps
  1304. sf_update_admin_toolbox();
  1305. $icons = sf_opcheck(get_option('sfshowicon'));
  1306. if (strpos($icons, '@Manage;') === false)
  1307. {
  1308. $icons.= '@Manage;1';
  1309. update_option('sfshowicon', $icons);
  1310. }
  1311. update_option('sfbuild', $section);
  1312. echo $section;
  1313. die();
  1314. }
  1315. $section = 1795;
  1316. if($build < $section)
  1317. {
  1318. # New option to not allow users access to wp admin
  1319. add_option('sfblockadmin', false);
  1320. # sftags table def
  1321. $sql = "
  1322. CREATE TABLE IF NOT EXISTS ".SFTAGS." (
  1323. tag_id bigint(20) NOT NULL auto_increment,
  1324. tag_name varchar(50) default NULL,
  1325. tag_slug varchar(50) default NULL,
  1326. tag_count bigint(20) default '0',
  1327. PRIMARY KEY (tag_id),
  1328. FULLTEXT KEY tag_name (tag_name)
  1329. ) ENGINE=MyISAM ".sf_charset().";";
  1330. $wpdb->query($sql);
  1331. # sftagmeta table def
  1332. $sql = "
  1333. CREATE TABLE IF NOT EXISTS ".SFTAGMETA." (
  1334. meta_id bigint(20) NOT NULL auto_increment,
  1335. tag_id bigint(20) default '0',
  1336. topic_id bigint(20) default '0',
  1337. forum_id bigint(20) default '0',
  1338. PRIMARY KEY (meta_id),
  1339. KEY tag_idx (tag_id),
  1340. KEY topic_idx (topic_id),
  1341. KEY forum_idx (forum_id)
  1342. ) ENGINE=MyISAM ".sf_charset().";";
  1343. $wpdb->query($sql);
  1344. # allow enabling tags on forum by forum basis
  1345. $wpdb->query("ALTER TABLE ".SFFORUMS." ADD (use_tags smallint(1) NOT NULL default '0')");
  1346. #max tags allowed and combine topics options
  1347. $sftopics = array();
  1348. $sftopics['sfpagedtopics'] = sf_opcheck(get_option('sfpagedtopics'));
  1349. $sftopics['sftopicsort'] = sf_opcheck(get_option('sftopicsort'));
  1350. $sftopics['sfpaging'] = sf_opcheck(get_option('sfpaging'));
  1351. $sftopics['sftagsabove'] = true;
  1352. $sftopics['sftagsbelow'] = true;
  1353. $sftopics['sfmaxtags'] = 0;
  1354. add_option('sftopics', $sftopics);
  1355. delete_option('sfpagedtopics');
  1356. delete_option('sftopicsort');
  1357. delete_option('sfpaging');
  1358. # New indexing to aid SQL Joins
  1359. $wpdb->query("ALTER TABLE ".SFMEMBERSHIPS." ADD INDEX user_id_idx ( user_id );");
  1360. $wpdb->query("ALTER TABLE ".SFMEMBERSHIPS." ADD INDEX usergroup_id_idx ( usergroup_id );");
  1361. $wpdb->query("ALTER TABLE ".SFDEFPERMISSIONS." ADD INDEX usergroup_id_idx ( usergroup_id );");
  1362. $wpdb->query("ALTER TABLE ".SFMESSAGES." ADD INDEX from_id_idx ( from_id );");
  1363. $wpdb->query("ALTER TABLE ".SFMESSAGES." ADD INDEX to_id_idx ( to_id );");
  1364. $wpdb->query("ALTER TABLE ".SFPOSTS." ADD INDEX user_id_idx ( user_id );");
  1365. $wpdb->query("ALTER TABLE ".SFPERMISSIONS." ADD INDEX usergroup_id_idx ( usergroup_id );");
  1366. $wpdb->query("ALTER TABLE ".SFPOSTRATINGS." ADD INDEX post_id_idx ( post_id );");
  1367. $wpdb->query("ALTER TABLE ".SFWAITING." ADD INDEX forum_id_idx ( forum_id );");
  1368. update_option('sfbuild', $section);
  1369. echo $section;
  1370. die();
  1371. }
  1372. $section = 1835;
  1373. if($build < $section)
  1374. {
  1375. # New configuration record
  1376. $basepath='';
  1377. if (is_multisite())
  1378. {
  1379. # construct multisite storage directory structure and create if necessary
  1380. $basepath .= 'blogs.dir/' . $wpdb->blogid;
  1381. if (!file_exists(SF_STORE_DIR . '/' . $basepath)) @mkdir(SF_STORE_DIR . '/' . $basepath, 0755);
  1382. $basepath .= '/files';
  1383. if (!file_exists(SF_STORE_DIR . '/' . $basepath)) @mkdir(SF_STORE_DIR . '/' . $basepath, 0755);
  1384. $basepath .= '/';
  1385. }
  1386. $sfconfig = array();
  1387. $sfconfig['styles'] = 'plugins/simple-forum/styles';
  1388. $sfconfig['avatars'] = $basepath . 'forum-avatars';
  1389. $sfconfig['smileys'] = $basepath . 'forum-smileys';
  1390. $sfconfig['ranks'] = $basepath . 'forum-badges';
  1391. $uploadpath = sf_opcheck(get_option('sfuppath'));
  1392. if(empty($uploadpath))
  1393. {
  1394. $sfconfig['image-uploads'] = $basepath . 'forum-image-uploads';
  1395. $newpath = SF_STORE_DIR . '/' . $sfconfig['image-uploads'];
  1396. @mkdir($newpath, 0777);
  1397. } else {
  1398. $sfconfig['image-uploads'] = $uploadpath;
  1399. }
  1400. $sfconfig['media-uploads'] = $basepath . 'forum-media-uploads';
  1401. $sfconfig['file-uploads'] = $basepath . 'forum-file-uploads';
  1402. $sfconfig['hooks'] = $basepath . 'plugins/simple-forum/forum/hooks';
  1403. $sfconfig['pluggable'] = 'plugins/simple-forum/forum';
  1404. $sfconfig['help'] = 'plugins/simple-forum/help';
  1405. $sfstyle = sf_opcheck(get_option('sfstyle'));
  1406. $curiconset = $sfstyle['sficon'];
  1407. $sfconfig['custom-icons'] = 'plugins/simple-forum/styles/icons/'.$curiconset.'/custom/';
  1408. add_option('sfconfig', $sfconfig);
  1409. $newpath = SF_STORE_DIR . '/' . $sfconfig['media-uploads'];
  1410. @mkdir($newpath, 0777);
  1411. $newpath = SF_STORE_DIR . '/' . $sfconfig['file-uploads'];
  1412. @mkdir($newpath, 0777);
  1413. $newpath = SF_STORE_DIR . '/' . $sfconfig['ranks'];
  1414. @mkdir($newpath, 0777);
  1415. delete_option('sfuppath');
  1416. $sfuploads = array();
  1417. $sfuploads['privatefolder'] = true;
  1418. $sfuploads['thumbsize'] = 80;
  1419. $sfuploads['pagecount'] = 25;
  1420. $sfuploads['imagetypes'] = 'jpg, jpeg, gif, png';
  1421. $sfuploads['imagemaxsize'] = 51200;
  1422. $sfuploads['mediatypes'] = 'swf, dcr, mov, qt, mpg, mp3, mp4, mpeg, avi, wmv, wm, asf, asx, wmx, wvx, rm, ra, ram';
  1423. $sfuploads['mediamaxsize'] = 0;
  1424. $sfuploads['filetypes'] = 'txt, rtf, doc, pdf';
  1425. $sfuploads['filemaxsize'] = 51200;
  1426. $sfuploads['prohibited'] = 'php, php3, php5, js, html, htm, phtml, asp, aspx, ascx, jsp, cfm, cfc, pl, bat, exe, dll, reg, cgi, sh, py';
  1427. add_option('sfuploads', $sfuploads);
  1428. update_option('sfbuild', $section);
  1429. echo $section;
  1430. die();
  1431. }
  1432. $section = 1963;
  1433. if($build < $section)
  1434. {
  1435. $sfmetatags = array();
  1436. $sfmetatags['sfdescr'] = '';
  1437. $sfmetatags['sfdescruse'] = 1;
  1438. $sfmetatags['sfusekeywords'] = true;
  1439. $sfmetatags['keywords'] = '';
  1440. $sfmetatags['sftagwords'] = true;
  1441. add_option('sfmetatags', $sfmetatags);
  1442. # admin colours
  1443. $sfacolours = array();
  1444. $sfacolours['bbarbg']='0066CC';
  1445. $sfacolours['bbarbgt']='FFFFFF';
  1446. $sfacolours['formbg']='0066CC';
  1447. $sfacolours['formbgt']='FFFFFF';
  1448. $sfacolours['panelbg']='78A1FF';
  1449. $sfacolours['panelbgt']='000000';
  1450. $sfacolours['panelsubbg']='A7C1FF';
  1451. $sfacolours['panelsubbgt']='000000';
  1452. $sfacolours['formtabhead']='464646';
  1453. $sfacolours['formtabheadt']='D7D7D7';
  1454. $sfacolours['tabhead']='0066CC';
  1455. $sfacolours['tabheadt']='D7D7D7';
  1456. $sfacolours['tabrowmain']='EAF3FA';
  1457. $sfacolours['tabrowmaint']='000000';
  1458. $sfacolours['tabrowsub']='78A1FF';
  1459. $sfacolours['tabrowsubt']='000000';
  1460. add_option('sfacolours', $sfacolours);
  1461. $sfdisplay = array();
  1462. $sftitle = sf_opcheck(get_option('sftitle'));
  1463. $sfquicklinks = sf_opcheck(get_option('sfquicklinks'));
  1464. $sfusersnewposts = sf_opcheck(get_option('sfusersnewposts'));
  1465. $sfforumcols = sf_opcheck(get_option('sfforumcols'));
  1466. $sftopics = sf_opcheck(get_option('sftopics'));
  1467. $sftopiccols = sf_opcheck(get_option('sftopiccols'));
  1468. $sfdisplay['pagetitle']['include'] = sf_opcheck($sftitle['sfinclude']);
  1469. $sfdisplay['pagetitle']['notitle'] = sf_opcheck($sftitle['sfnotitle']);
  1470. $sfdisplay['pagetitle']['banner'] = sf_opcheck($sftitle['sfbanner']);
  1471. $sfdisplay['breadcrumbs']['showcrumbs'] = sf_opcheck(get_option('sfshowbreadcrumbs'));
  1472. $sfdisplay['breadcrumbs']['showhome'] = sf_opcheck(get_option('sfshowhome'));
  1473. $sfdisplay['breadcrumbs']['homepath'] = sf_opcheck(get_option('sfhome'));
  1474. $sfdisplay['breadcrumbs']['tree'] = false;
  1475. $sfdisplay['search']['searchtop'] = sf_opcheck(get_option('sfsearchbar'));
  1476. $sfdisplay['search']['searchbottom'] = sf_opcheck(get_option('sfsearchbar'));
  1477. $sfdisplay['quicklinks']['qltop'] = sf_opcheck($sfquicklinks['sfqlshow']);
  1478. $sfdisplay['quicklinks']['qlbottom'] = sf_opcheck($sfquicklinks['sfqlshow']);
  1479. $sfdisplay['quicklinks']['qlcount'] = sf_opcheck($sfquicklinks['sfqlcount']);
  1480. $sfdisplay['stats']['showstats'] = sf_opcheck(get_option('sfstats'));
  1481. $sfdisplay['stats']['mostusers'] = sf_opcheck(get_option('sfstats'));
  1482. $sfdisplay['stats']['online'] = sf_opcheck(get_option('sfstats'));
  1483. $sfdisplay['stats']['forumstats'] = sf_opcheck(get_option('sfstats'));
  1484. $sfdisplay['stats']['memberstats'] = sf_opcheck(get_option('sfstats'));
  1485. $sfdisplay['stats']['topsix'] = sf_opcheck(get_option('sfstats'));
  1486. $sfdisplay['stats']['admins'] = sf_opcheck(get_option('sfstats'));
  1487. $sfdisplay['firstlast']['date'] = true;
  1488. $sfdisplay['firstlast']['time'] = true;
  1489. $sfdisplay['firstlast']['user'] = true;
  1490. $sfdisplay['groups']['description'] = true;
  1491. $sfdisplay['forums']['description'] = true;
  1492. $sfdisplay['forums']['newposticon'] = true;
  1493. $sfdisplay['forums']['pagelinks'] = true;
  1494. $sfdisplay['forums']['newpposts'] = sf_opcheck($sfusersnewposts['sfshownewuser']);
  1495. $sfdisplay['forums']['newcount'] = sf_opcheck($sfusersnewposts['sfshownewcount']);
  1496. $sfdisplay['forums']['newabove'] = sf_opcheck($sfusersnewposts['sfshownewabove']);
  1497. $sfdisplay['forums']['sortinforum'] = sf_opcheck($sfusersnewposts['sfsortinforum']);
  1498. $sfdisplay['forums']['singleforum'] = sf_opcheck(get_option('sfsingleforum'));
  1499. $sfdisplay['forums']['topiccol'] = sf_opcheck($sfforumcols['topics']);
  1500. $sfdisplay['forums']['postcol'] = sf_opcheck($sfforumcols['posts']);
  1501. $sfdisplay['forums']['lastcol'] = sf_opcheck($sfforumcols['last']);
  1502. $sfdisplay['topics']['perpage'] = sf_opcheck($sftopics['sfpagedtopics']);
  1503. $sfdisplay['topics']['numpagelinks'] = sf_opcheck($sftopics['sfpaging']);
  1504. $sfdisplay['topics']['sortnewtop'] = sf_opcheck($sftopics['sftopicsort']);
  1505. $sfdisplay['topics']['maxtags'] = sf_opcheck($sftopics['sfmaxtags']);
  1506. $sfdisplay['topics']['firstcol'] = sf_opcheck($sftopiccols['first']);
  1507. $sfdisplay['topics']['lastcol'] = sf_opcheck($sftopiccols['last']);
  1508. $sfdisplay['topics']['postcol'] = sf_opcheck($sftopiccols['posts']);
  1509. $sfdisplay['topics']['viewcol'] = sf_opcheck($sftopiccols['views']);
  1510. $sfdisplay['topics']['pagelinks'] = true;
  1511. $sfdisplay['topics']['statusicons'] = true;
  1512. $sfdisplay['topics']['postrating'] = true;
  1513. $sfdisplay['topics']['topicstatus'] = true;
  1514. $sfdisplay['topics']['topictags'] = true;
  1515. $sfdisplay['posts']['perpage'] = sf_opcheck(get_option('sfpagedposts'));
  1516. $sfdisplay['posts']['numpagelinks'] = sf_opcheck(get_option('sfpostpaging'));
  1517. $sfdisplay['posts']['userabove'] = sf_opcheck(get_option('sfuserabove'));
  1518. $sfdisplay['posts']['sortdesc'] = sf_opcheck(get_option('sfsortdesc'));
  1519. $sfdisplay['posts']['showedits'] = sf_opcheck(get_option('sfshoweditdata'));
  1520. $sfdisplay['posts']['showlastedit'] = sf_opcheck(get_option('sfshoweditlast'));
  1521. $sfdisplay['posts']['tagstop'] = sf_opcheck($sftopics['sftagsabove']);
  1522. $sfdisplay['posts']['tagsbottom'] = sf_opcheck($sftopics['sftagsbelow']);
  1523. $sfdisplay['posts']['topicstatushead'] = true;
  1524. $sfdisplay['posts']['topicstatuschanger'] = true;
  1525. $sfdisplay['posts']['online'] = true;
  1526. $sfdisplay['posts']['time'] = true;
  1527. $sfdisplay['posts']['date'] = true;
  1528. $sfdisplay['posts']['usertype'] = true;
  1529. $sfdisplay['posts']['rankdisplay'] = true;
  1530. $sfdisplay['posts']['location'] = true;
  1531. $sfdisplay['posts']['postcount'] = true;
  1532. $sfdisplay['posts']['permalink'] = true;
  1533. $sfdisplay['posts']['print'] = true;
  1534. add_option('sfdisplay', $sfdisplay);
  1535. delete_option('sftitle');
  1536. delete_option('sfusersnewposts');
  1537. delete_option('sfforumcols');
  1538. delete_option('sftopics');
  1539. delete_option('sftopiccols');
  1540. delete_option('sfshowbreadcrumbs');
  1541. delete_option('sfshowhome');
  1542. delete_option('sfhome');
  1543. delete_option('sfsearchbar');
  1544. delete_option('sfquicklinks');
  1545. delete_option('sfstats');
  1546. delete_option('sfsingleforum');
  1547. delete_option('sfpagedposts');
  1548. delete_option('sfpostpaging');
  1549. delete_option('sfuserabove');
  1550. delete_option('sfsortdesc');
  1551. delete_option('sfshoweditdata');
  1552. delete_option('sfshoweditlast');
  1553. delete_option('sftagsabove');
  1554. delete_option('sftagsbelow');
  1555. update_option('sfbuild', $section);
  1556. echo $section;
  1557. die();
  1558. }
  1559. $section = 2040;
  1560. if ($build < $section)
  1561. {
  1562. $icons=sf_opcheck(get_option('sfshowicon'));
  1563. if (strpos($icons, '@Print this Post') === false)
  1564. {
  1565. $icons.= '@Print this Post;1';
  1566. update_option('sfshowicon', $icons);
  1567. }
  1568. $icons=sf_opcheck(get_option('sfshowicon'));
  1569. if (strpos($icons, '@Related Topics') === false)
  1570. {
  1571. $icons.= '@Related Topics;1';
  1572. update_option('sfshowicon', $icons);
  1573. }
  1574. # add new Can edit own topic titles permission
  1575. sf_upgrade_add_new_role('Can delete own posts', 0);
  1576. # add new Can edit own topic titles permission
  1577. sf_upgrade_add_new_role('Can view forum and topic lists only', 0);
  1578. # sub-forum support
  1579. $create_ddl = "ALTER TABLE ".SFFORUMS." ADD (parent bigint(20) NOT NULL default '0');";
  1580. sf_upgrade_database(SFFORUMS, 'parent', $create_ddl);
  1581. $create_ddl = "ALTER TABLE ".SFFORUMS." ADD (children varchar(255) default NULL);";
  1582. sf_upgrade_database(SFFORUMS, 'children', $create_ddl);
  1583. # code exclusions
  1584. $sfsupport = sf_opcheck(get_option('sfsupport'));
  1585. $sfsupport_new['sfusinglinking'] = sf_opcheck($sfsupport['sfusinglinking']);
  1586. $sfsupport_new['sfusingwidgets'] = sf_opcheck($sfsupport['sfusingwidgets']);
  1587. $sfsupport_new['sfusinggeneraltags'] = sf_opcheck($sfsupport['sfusingtags']);
  1588. $sfsupport_new['sfusingavatartags'] = sf_opcheck($sfsupport['sfusingavatars']);
  1589. $sfsupport_new['sfusinglinkstags'] = true;
  1590. $sfsupport_new['sfusingtagstags'] = true;
  1591. $sfsupport_new['sfusingpagestags'] = true;
  1592. $sfsupport_new['sfusingliststags'] = true;
  1593. $sfsupport_new['sfusingstatstags'] = true;
  1594. $sfsupport_new['sfusingpmtags'] = true;
  1595. update_option('sfsupport', $sfsupport_new);
  1596. # convert icons to serialized and clean up
  1597. sf_upgrade_icontext();
  1598. update_option('sfbuild', $section);
  1599. echo $section;
  1600. die();
  1601. }
  1602. $section = 2095;
  1603. if($build < $section)
  1604. {
  1605. # avatar options updating and single option
  1606. sf_upgrade_avatar_options();
  1607. # guest settings
  1608. $sfguests = array();
  1609. $sfguests['reqemail'] = true;
  1610. $sfguests['storecookie'] = true;
  1611. add_option('sfguests', $sfguests);
  1612. #redirect url for block admin
  1613. add_option('sfblockredirect', SFURL); #default to forum
  1614. # new Manage Profiles - give to upgrading admin only
  1615. $user = new WP_User($current_user->ID);
  1616. $user->add_cap('SPF Manage Profiles');
  1617. # need to convert how custom profile data is stored to allow more options
  1618. sf_update_custom_fields();
  1619. # convert users custom profile field data
  1620. sf_convert_custom_profile_fields();
  1621. $sffilters = array();
  1622. $sffilters = sf_opcheck(get_option('sffilters'));
  1623. $sffilters['sfurlchars'] = 40;
  1624. $sffilters['sffilterpre'] = false;
  1625. $sffilters['sfmaxlinks'] = 0;
  1626. update_option('sffilters', $sffilters);
  1627. $sfblock = array();
  1628. $sfblock['blockadmin'] = sf_opcheck(get_option('sfblockadmin'));
  1629. $sfblock['blockredirect'] = sf_opcheck(get_option('sfblockredirect'));
  1630. $sfblock['blockrole'] = 'administrator';
  1631. delete_option('sfblockadmin');
  1632. delete_option('sfblockredirect');
  1633. update_option('sfblockadmin', $sfblock);
  1634. update_option('sfbuild', $section);
  1635. echo $section;
  1636. die();
  1637. }
  1638. $section = 2200;
  1639. if ($build < $section)
  1640. {
  1641. # profile management
  1642. $sfprofile = array();
  1643. # data control
  1644. $sfprofile['require']['first_name'] = true;
  1645. $sfprofile['require']['last_name'] = true;
  1646. $sfprofile['require']['user_url'] = false;
  1647. $sfprofile['require']['location'] = false;
  1648. $sfprofile['require']['description'] = false;
  1649. $sfprofile['require']['aim'] = false;
  1650. $sfprofile['require']['yahoo'] = false;
  1651. $sfprofile['require']['jabber'] = false;
  1652. $sfprofile['require']['icq'] = false;
  1653. $sfprofile['require']['msn'] = false;
  1654. $sfprofile['require']['skype'] = false;
  1655. $sfprofile['require']['facebook'] = false;
  1656. $sfprofile['require']['myspace'] = false;
  1657. $sfprofile['require']['twitter'] = false;
  1658. $sfprofile['include']['first_name'] = true;
  1659. $sfprofile['include']['last_name'] = true;
  1660. $sfprofile['include']['user_url'] = true;
  1661. $sfprofile['include']['location'] = true;
  1662. $sfprofile['include']['description'] = true;
  1663. $sfprofile['include']['aim'] = true;
  1664. $sfprofile['include']['yahoo'] = true;
  1665. $sfprofile['include']['jabber'] = true;
  1666. $sfprofile['include']['icq'] = true;
  1667. $sfprofile['include']['msn'] = true;
  1668. $sfprofile['include']['skype'] = true;
  1669. $sfprofile['include']['facebook'] = true;
  1670. $sfprofile['include']['myspace'] = true;
  1671. $sfprofile['include']['twitter'] = true;
  1672. $sfprofile['display']['first_name'] = true;
  1673. $sfprofile['display']['last_name'] = true;
  1674. $sfprofile['display']['user_url'] = true;
  1675. $sfprofile['display']['location'] = true;
  1676. $sfprofile['display']['description'] = true;
  1677. $sfprofile['display']['aim'] = true;
  1678. $sfprofile['display']['yahoo'] = true;
  1679. $sfprofile['display']['jabber'] = true;
  1680. $sfprofile['display']['icq'] = true;
  1681. $sfprofile['display']['msn'] = true;
  1682. $sfprofile['display']['skype'] = true;
  1683. $sfprofile['display']['facebook'] = true;
  1684. $sfprofile['display']['myspace'] = true;
  1685. $sfprofile['display']['twitter'] = true;
  1686. # derived data display only
  1687. $sfprofile['system']['forumrank'] = true;
  1688. $sfprofile['system']['specialrank'] = true;
  1689. $sfprofile['system']['badge'] = true;
  1690. $sfprofile['system']['memberships'] = true;
  1691. # display labels
  1692. $sfprofile['label']['first_name'] = 'First Name';
  1693. $sfprofile['label']['last_name'] = 'Last Name';
  1694. $sfprofile['label']['user_url'] = 'Website';
  1695. $sfprofile['label']['location'] = 'Location';
  1696. $sfprofile['label']['description'] = 'Short Biography';
  1697. $sfprofile['label']['aim'] = 'AIM';
  1698. $sfprofile['label']['yahoo'] = 'Yahoo IM';
  1699. $sfprofile['label']['jabber'] = 'Jabber-Google Talk';
  1700. $sfprofile['label']['icq'] = 'ICQ';
  1701. $sfprofile['label']['msn'] = 'MSN';
  1702. $sfprofile['label']['skype'] = 'Skype';
  1703. $sfprofile['label']['facebook'] = 'Facebook';
  1704. $sfprofile['label']['myspace'] = 'MySpace';
  1705. $sfprofile['label']['twitter'] = 'Twitter';
  1706. $sfprofile['label']['forumrank'] = 'Forum Rank';
  1707. $sfprofile['label']['specialrank'] = 'Special Rank';
  1708. $sfprofile['label']['badge'] = 'Badge';
  1709. $sfprofile['label']['memberships'] = 'User Group Memberships';
  1710. # add custom fields already defined
  1711. $custom = sf_get_sfmeta('custom_field');
  1712. if($custom)
  1713. {
  1714. foreach ($custom as $x => $cf)
  1715. {
  1716. $sfprofile['require'][$cf['meta_key']] = true;
  1717. $sfprofile['include'][$cf['meta_key']] = true;
  1718. $sfprofile['display'][$cf['meta_key']] = true;
  1719. $sfprofile['label'][$cf['meta_key']] = $cf['meta_key'];
  1720. }
  1721. }
  1722. # profile options
  1723. $sfprofile['nameformat'] = 1;
  1724. $sfprofile['profilelink'] = 3;
  1725. $sfprofile['weblink'] = 3;
  1726. $sfprofile['displaymode'] = 1;
  1727. $sfprofile['displaypage'] = '';
  1728. $sfprofile['displayquery'] = '';
  1729. $sfprofile['displayinforum'] = 0;
  1730. $sfprofile['formmode'] = 1;
  1731. $sfprofile['formpage'] = '';
  1732. $sfprofile['formquery'] = '';
  1733. $sfprofile['forminforum'] = 0;
  1734. $sfprofile['photosmax'] = 0;
  1735. $sfprofile['photoswidth'] = 0;
  1736. $sfprofile['firstvisit'] = true;
  1737. $sfprofile['forcepw'] = false;
  1738. add_option('sfprofile', $sfprofile);
  1739. delete_option('sfextprofile');
  1740. update_option('sfbuild', $section);
  1741. echo $section;
  1742. die();
  1743. }
  1744. $section = 2236;
  1745. if ($build < $section)
  1746. {
  1747. # Login url collection
  1748. $sflogin = sf_opcheck(get_option('sflogin'));
  1749. $sflogin['sfloginurl'] = SFSITEURL.'wp-login.php?action=login&amp;view=forum';
  1750. $sflogin['sfloginemailurl'] = SFSITEURL.'wp-login.php?action=login&view=forum';
  1751. $sflogin['sflogouturl'] = SFSITEURL.'wp-login.php?action=logout&amp;redirect_to='.SFURL;
  1752. $sflogin['sfregisterurl'] = SFSITEURL.'wp-login.php?action=register&amp;view=forum';
  1753. $sflogin['sflostpassurl'] = SFSITEURL.'wp-login.php?action=lostpassword&amp;view=forum';
  1754. update_option('sflogin', $sflogin);
  1755. # install log table def
  1756. $sql = "
  1757. CREATE TABLE IF NOT EXISTS ".SFLOG." (
  1758. id int(4) NOT NULL auto_increment,
  1759. user_id bigint(20) NOT NULL,
  1760. install_date date NOT NULL,
  1761. release_type varchar(15),
  1762. version varchar(10) NOT NULL,
  1763. build int(4) NOT NULL,
  1764. PRIMARY KEY (id)
  1765. ) ENGINE=MyISAM ".sf_charset().";";
  1766. $wpdb->query($sql);
  1767. update_option('sfbuild', $section);
  1768. echo $section;
  1769. die();
  1770. }
  1771. $section = 2280;
  1772. if($build < $section)
  1773. {
  1774. # forum message
  1775. $create_ddl = "ALTER TABLE ".SFFORUMS." ADD (forum_message text);";
  1776. sf_upgrade_database(SFFORUMS, 'forum_message', $create_ddl);
  1777. update_option('sfbuild', $section);
  1778. echo $section;
  1779. die();
  1780. }
  1781. $section = 2337;
  1782. if($build < $section)
  1783. {
  1784. # forum message
  1785. $create_ddl = "ALTER TABLE ".SFGROUPS." ADD (group_message text);";
  1786. sf_upgrade_database(SFGROUPS, 'group_message', $create_ddl);
  1787. update_option('sfbuild', $section);
  1788. echo $section;
  1789. die();
  1790. }
  1791. $section = 2352;
  1792. if($build < $section)
  1793. {
  1794. # fix avatar error for 4.1 b1 users with fresh install
  1795. $sfavatars = sf_opcheck(get_option('sfavatars'));
  1796. if (empty($sfavatars))
  1797. {
  1798. sf_upgrade_avatar_options();
  1799. }
  1800. # clean up old avatar options
  1801. delete_option('sfshowavatars');
  1802. delete_option('sfavatarsize');
  1803. delete_option('sfgravatar');
  1804. delete_option('sfgmaxrating');
  1805. delete_option('sfwpavatar');
  1806. delete_option('sfavataruploads');
  1807. # remove option for add topic template tag since it can now be passed as argument
  1808. delete_option('sftaggedforum');
  1809. update_option('sfbuild', $section);
  1810. echo $section;
  1811. die();
  1812. }
  1813. $section = 2425;
  1814. if($build < $section)
  1815. {
  1816. # Make signature field larger
  1817. $sql = "ALTER TABLE ".SFMEMBERS." CHANGE signature signature TEXT NULL DEFAULT NULL";
  1818. $wpdb->query($sql);
  1819. update_option('sfbuild', $section);
  1820. echo $section;
  1821. die();
  1822. }
  1823. # 4.1.1 =====================================================================================
  1824. $section = 2500;
  1825. if($build < $section)
  1826. {
  1827. update_option('sfzone', '0');
  1828. # Fix up smileys if the data has been lost
  1829. $s = sf_get_sfmeta('smileys');
  1830. $sm = unserialize($s[0]['meta_value']);
  1831. if(empty($sm))
  1832. {
  1833. sf_build_base_smileys();
  1834. }
  1835. update_option('sfbuild', $section);
  1836. echo $section;
  1837. die();
  1838. }
  1839. # 4.2 =====================================================================================
  1840. # == Note: sfoptions table introduced (4.2) ==
  1841. $section = 2720;
  1842. if($build < $section)
  1843. {
  1844. ###### move options to their own spf table ######
  1845. sf_move_options();
  1846. ###### move options to their own spf table ######
  1847. # add new can view forum lists only permission
  1848. sf_upgrade_add_new_role('Can view forum lists only', 0);
  1849. # add new can view forum lists only permission
  1850. sf_upgrade_add_new_role('Can view admin posts', 0, false, false, true);
  1851. # add new column for pm type to pm table
  1852. $create_ddl = "ALTER TABLE ".SFMESSAGES. " ADD (type smallint(2) NOT NULL default '1')";
  1853. sf_upgrade_database(SFMESSAGES, 'type', $create_ddl);
  1854. # pm options
  1855. $sfpm = array();
  1856. $sfpm = sf_opcheck(sf_get_option('sfpm'));
  1857. $pm['sfpmcc'] = true;
  1858. $pm['sfpmbcc'] = true;
  1859. $pm['sfpmmaxrecipients'] = 0;
  1860. sf_update_option('sfpm', $pm);
  1861. sf_upgrade_members_pm();
  1862. sf_modify_admin_cap('SPF Manage Database', 'SPF Manage Tags');
  1863. sf_delete_option('sfdemocracy');
  1864. $sfaiosp = sf_opcheck(sf_get_option('sfaiosp'));
  1865. $sfseo = array();
  1866. $sfseo['sfseo_topic'] = sf_opcheck($sfaiosp['sfaiosp_topic']);
  1867. $sfseo['sfseo_forum'] = sf_opcheck($sfaiosp['sfaiosp_forum']);
  1868. $sfseo['sfseo_sep'] = sf_opcheck($sfaiosp['sfaiosp_sep']);
  1869. sf_update_option('sfseo', $sfseo);
  1870. sf_delete_option('sfaiosp');
  1871. $sfcontrols = sf_opcheck(sf_get_option('sfcontrols'));
  1872. $sfcontrols['dayflag'] = '0';
  1873. $sfcontrols['hourflag'] = '0';
  1874. $sfcontrols['showtopcount'] = 6;
  1875. $sfcontrols['shownewcount'] = 6;
  1876. sf_update_option('sfcontrols', $sfcontrols);
  1877. $sfdisplay = sf_opcheck(sf_get_option('sfdisplay'));
  1878. $sfdisplay['stats']['topposters'] = sf_opcheck($sfdisplay['stats']['topsix']);
  1879. $sfdisplay['stats']['newusers'] = true;
  1880. sf_update_option('sfdisplay', $sfdisplay);
  1881. sf_update_option('sfbuild', $section);
  1882. echo $section;
  1883. die();
  1884. }
  1885. $section = 2797;
  1886. if($build < $section)
  1887. {
  1888. # update column
  1889. $wpdb->query("ALTER TABLE ".SFMEMBERS." CHANGE avatar avatar LONGTEXT NULL DEFAULT NULL");
  1890. $sfconfig = sf_opcheck(sf_get_option('sfconfig'));
  1891. $basepath='';
  1892. if (is_multisite())
  1893. {
  1894. # construct multisite storage directory structure and create if necessary
  1895. $basepath .= 'blogs.dir/' . $wpdb->blogid;
  1896. if (!file_exists(SF_STORE_DIR . '/' . $basepath)) @mkdir(SF_STORE_DIR . '/' . $basepath, 0755);
  1897. $basepath .= '/files';
  1898. if (!file_exists(SF_STORE_DIR . '/' . $basepath)) @mkdir(SF_STORE_DIR . '/' . $basepath, 0755);
  1899. $basepath .= '/';
  1900. }
  1901. $sfconfig['avatar-pool'] = $basepath . 'forum-avatar-pool';
  1902. sf_update_option('sfconfig', $sfconfig);
  1903. $newpath = SF_STORE_DIR . '/' . $sfconfig['avatar-pool'];
  1904. @mkdir($newpath, 0777);
  1905. $sfavatars = sf_opcheck(sf_get_option('sfavatars'));
  1906. if (empty($sfavatars))
  1907. {
  1908. # handle case where corrupted avatar priorities in db from old upgrade
  1909. $sfavatars['sfavatarpriority'] = array(0, 2, 3, 1, 4, 5); # gravatar, upload, spf, wp, pool, remote
  1910. } else {
  1911. # just add the new priorities
  1912. $sfavatars['sfavatarpriority'][] = 4; # add the avatar pool at end of avatar priorities
  1913. $sfavatars['sfavatarpriority'][] = 5; # add the remote avatar at end of avatar priorities
  1914. }
  1915. sf_update_option('sfavatars', $sfavatars);
  1916. # change avatar column to be serialized array of avatar files (uploaded, pool and remote)
  1917. $users = $wpdb->get_results("SELECT user_id, avatar FROM ".SFMEMBERS);
  1918. foreach ($users as $user)
  1919. {
  1920. # see if the avatar is already serialized which means the upgrade script was already run once
  1921. if (!is_serialized($user->avatar))
  1922. {
  1923. $data = array();
  1924. $data['uploaded'] = $user->avatar;
  1925. $wpdb->query("UPDATE ".SFMEMBERS." SET avatar='".serialize($data)."' WHERE user_id=".$user->user_id);
  1926. }
  1927. }
  1928. # update column
  1929. $wpdb->query("ALTER TABLE ".SFFORUMS." CHANGE children children TEXT NULL DEFAULT NULL");
  1930. sf_update_option('sfbuild', $section);
  1931. echo $section;
  1932. die();
  1933. }
  1934. $section = 2903;
  1935. if($build < $section)
  1936. {
  1937. # new permission for viewing member lists
  1938. sf_upgrade_add_new_role('Can view members lists', 0, true);
  1939. sf_delete_option('sfshowmemberlist');
  1940. # avatar filesize limit
  1941. $sfavatars=array();
  1942. $sfavatars = sf_opcheck(sf_get_option('sfavatars'));
  1943. $sfavatars['sfavatarfilesize'] = 10240; # 10k filesize limit
  1944. sf_update_option('sfavatars', $sfavatars);
  1945. # option to show subforums on group view
  1946. $sfdisplay = array();
  1947. $sfdisplay = sf_opcheck(sf_get_option('sfdisplay'));
  1948. $sfdisplay['groups']['showsubforums'] = true;
  1949. $sfdisplay['pagelinks']['ptop'] = true;
  1950. $sfdisplay['pagelinks']['pbottom'] = true;
  1951. sf_update_option('sfdisplay', $sfdisplay);
  1952. # new permission for re-assigning posts
  1953. sf_upgrade_add_new_role('Can reassign posts', 0, false, true);
  1954. # combine member opts and add option for hiding online status
  1955. $sfmembersopt = array();
  1956. $sfmembersopt['sfcheckformember'] = sf_opcheck(sf_get_option('sfcheckformember'));
  1957. $sfmembersopt['sfshowmemberlist'] = sf_opcheck(sf_get_option('sfshowmemberlist'));
  1958. $sfmembersopt['sflimitmemberlist'] = sf_opcheck(sf_get_option('sflimitmemberlist'));
  1959. $sfmembersopt['sfsinglemembership'] = sf_opcheck(sf_get_option('sfsinglemembership'));
  1960. $sfmembersopt['sfhidestatus'] = true;
  1961. sf_add_option('sfmemberopts', $sfmembersopt);
  1962. # remove the old options
  1963. sf_delete_option('sfcheckformember');
  1964. sf_delete_option('sfshowmemberlist');
  1965. sf_delete_option('sflimitmemberlist');
  1966. sf_delete_option('sfsinglemembership');
  1967. # add feedkey column for members and generate for existing users
  1968. $create_ddl = "ALTER TABLE ".SFMEMBERS. " ADD (feedkey varchar(36) default NULL)";
  1969. sf_upgrade_database(SFMEMBERS, 'feedkey', $create_ddl);
  1970. sf_generate_member_feedkeys();
  1971. # change sftrack for added stats
  1972. $create_ddl = "ALTER TABLE ".SFTRACK. " ADD (forum_id bigint(20) default NULL)";
  1973. sf_upgrade_database(SFTRACK, 'forum_id', $create_ddl);
  1974. $create_ddl = "ALTER TABLE ".SFTRACK. " ADD (topic_id bigint(20) default NULL)";
  1975. sf_upgrade_database(SFTRACK, 'topic_id', $create_ddl);
  1976. sf_update_option('sfbuild', $section);
  1977. echo $section;
  1978. die();
  1979. }
  1980. $section = 2945;
  1981. if($build < $section)
  1982. {
  1983. # Change slugs to text columns to allow for encoding
  1984. $wpdb->query("ALTER TABLE ".SFFORUMS." DROP INDEX fslug_idx;");
  1985. $wpdb->query("ALTER TABLE ".SFFORUMS." MODIFY forum_slug TEXT NOT NULL;");
  1986. $wpdb->query("ALTER TABLE ".SFTOPICS." DROP INDEX tslug_idx;");
  1987. $wpdb->query("ALTER TABLE ".SFTOPICS." MODIFY topic_slug TEXT NOT NULL;");
  1988. $wpdb->query("ALTER TABLE ".SFMESSAGES." DROP INDEX mslug_idx;");
  1989. $wpdb->query("ALTER TABLE ".SFMESSAGES." MODIFY message_slug TEXT NOT NULL;");
  1990. $wpdb->query("ALTER TABLE ".SFTAGS." MODIFY tag_slug varchar(200) NOT NULL;");
  1991. # Add new profile option for profile in stats names
  1992. $sfprofile = array();
  1993. $sfprofile = sf_opcheck(sf_get_option('sfprofile'));
  1994. $sfprofile['profileinstats'] = true;
  1995. sf_update_option('sfprofile', $sfprofile);
  1996. # new blog link table
  1997. $sql = "
  1998. CREATE TABLE IF NOT EXISTS ".SFLINKS." (
  1999. id int(4) NOT NULL auto_increment,
  2000. post_id int(20) default '0',
  2001. forum_id int(20) default '0',
  2002. topic_id int(20) default '0',
  2003. syncedit smallint(1) default '0',
  2004. PRIMARY KEY (id)
  2005. ) ENGINE=MyISAM ".sf_charset().";";
  2006. $wpdb->query($sql);
  2007. sf_upgrade_bloglinks_table();
  2008. $sflogin = array();
  2009. $sflogin = sf_opcheck(sf_get_option('sflogin'));
  2010. $sflogin['sfshowavatar'] = true;
  2011. sf_update_option('sflogin', $sflogin);
  2012. # rss options
  2013. $sfrss = array();
  2014. $sfrss['sfrsscount'] = sf_opcheck(sf_get_option('sfrsscount'));
  2015. $sfrss['sfrsswords'] = sf_opcheck(sf_get_option('sfrsswords'));
  2016. $sfrss['sfrssfeedkey'] = true;
  2017. sf_add_option('sfrss', $sfrss);
  2018. sf_delete_option('sfrsscount');
  2019. sf_delete_option('sfrsswords');
  2020. # New blog/topic linking options
  2021. $sfpostlinking = array();
  2022. $sfpostlinking = sf_opcheck(sf_get_option('sfpostlinking'));
  2023. $sfpostlinking['sfuseautolabel']=true;
  2024. $sfpostlinking['sfautoupdate']=true;
  2025. $sfpostlinking['sfautocreate']=false;
  2026. $sfpostlinking['sfautoforum']='';
  2027. $sfpostlinking['sfpostcomment']=false;
  2028. $sfpostlinking['sfkillcomment']=false;
  2029. $sfpostlinking['sfeditcomment']=false;
  2030. sf_update_option('sfpostlinking', $sfpostlinking);
  2031. $sfsupport = array();
  2032. $sfsupport = sf_opcheck(sf_get_option('sfsupport'));
  2033. $sfsupport['sfusinglinkcomments']=true;
  2034. sf_update_option('sfsupport', $sfsupport);
  2035. sf_update_option('sfbuild', $section);
  2036. echo $section;
  2037. die();
  2038. }
  2039. $section = 3004;
  2040. if($build < $section)
  2041. {
  2042. # new display options
  2043. # option to show subforums on group view
  2044. $sfdisplay = array();
  2045. $sfdisplay = sf_opcheck(sf_get_option('sfdisplay'));
  2046. $sfdisplay['unreadcount']['unread'] = true;
  2047. $sfdisplay['unreadcount']['markall'] = true;
  2048. sf_update_option('sfdisplay', $sfdisplay);
  2049. # Comment id for linking
  2050. $create_ddl = "ALTER TABLE ".SFPOSTS. " ADD (comment_id bigint(20) default NULL)";
  2051. sf_upgrade_database(SFPOSTS, 'comment_id', $create_ddl);
  2052. # open mode of tb uploader
  2053. $sfuploads = array();
  2054. $sfuploads = sf_opcheck(sf_get_option('sfuploads'));
  2055. $sfuploads['showmode'] = false;
  2056. sf_update_option('sfuploads', $sfuploads);
  2057. # add show title to group view
  2058. $sfdisplay = sf_opcheck(sf_get_option('sfdisplay'));
  2059. $sfdisplay['forums']['showtitle'] = false;
  2060. sf_update_option('sfdisplay', $sfdisplay);
  2061. # sitemap inclusion
  2062. $create_ddl = "ALTER TABLE ".SFFORUMS." ADD (in_sitemap smallint(1) NOT NULL default '1')";
  2063. sf_upgrade_database(SFFORUMS, 'in_sitemap', $create_ddl);
  2064. # fix up topic titles
  2065. $sql = "UPDATE ".SFTOPICS." SET topic_name = REPLACE (topic_name, '\\\\\'', '\'') WHERE topic_name LIKE '%\\\\\\\\\'%'";
  2066. $wpdb->query($sql);
  2067. $sql = "UPDATE ".SFTOPICS." SET topic_name = REPLACE (topic_name, '\\\\\"', '\"') WHERE topic_name LIKE '%\\\\\\\\\"%'";
  2068. $wpdb->query($sql);
  2069. # fix up post content
  2070. $sql = "UPDATE ".SFPOSTS." SET post_content = REPLACE (post_content, '\\\\\'', '\'') WHERE post_content LIKE '%\\\\\\\\\'%'";
  2071. $wpdb->query($sql);
  2072. $sql = "UPDATE ".SFPOSTS." SET post_content = REPLACE (post_content, '\\\\\"', '\"') WHERE post_content LIKE '%\\\\\\\\\"%'";
  2073. $wpdb->query($sql);
  2074. sf_update_option('sfbuild', $section);
  2075. echo $section;
  2076. die();
  2077. }
  2078. $section = 3020;
  2079. if($build < $section)
  2080. {
  2081. # policy storage
  2082. $sfconfig = sf_opcheck(sf_get_option('sfconfig'));
  2083. $basepath='';
  2084. if (is_multisite())
  2085. {
  2086. # construct multisite storage directory structure and create if necessary
  2087. $basepath .= 'blogs.dir/' . $wpdb->blogid;
  2088. if (!file_exists(SF_STORE_DIR . '/' . $basepath)) @mkdir(SF_STORE_DIR . '/' . $basepath, 0755);
  2089. $basepath .= '/files';
  2090. if (!file_exists(SF_STORE_DIR . '/' . $basepath)) @mkdir(SF_STORE_DIR . '/' . $basepath, 0755);
  2091. $basepath .= '/';
  2092. }
  2093. $sfconfig['policies'] = $basepath . 'forum-policies';
  2094. sf_update_option('sfconfig', $sfconfig);
  2095. $newpath = SF_STORE_DIR . '/' . $sfconfig['policies'];
  2096. @mkdir($newpath, 0777);
  2097. # new policy option collection
  2098. $sflogin = array();
  2099. $sflogin = sf_opcheck(sf_get_option('sflogin'));
  2100. $sfpolicy = array();
  2101. $sfpolicy['sfregtext'] = sf_opcheck($sflogin['sfregtext']);
  2102. $sfpolicy['sfregcheck'] = sf_opcheck($sflogin['sfregcheck']);
  2103. $sfpolicy['sfregfile'] = '';
  2104. $sfpolicy['sfreglink'] = false;
  2105. $sfpolicy['sfprivfile'] = '';
  2106. $sfpolicy['sfprivlink'] = false;
  2107. sf_add_option('sfpolicy', $sfpolicy);
  2108. sf_update_option('sfbuild', $section);
  2109. echo $section;
  2110. die();
  2111. }
  2112. $section = 3022;
  2113. if($build < $section)
  2114. {
  2115. # remove topic sort column from topic table
  2116. $wpdb->query("ALTER TABLE ".SFTOPICS." DROP topic_sort;");
  2117. # New image array
  2118. $sfimage = array();
  2119. $sfimage['enlarge'] = sf_opcheck(sf_get_option('sfimgenlarge'));
  2120. $sfimage['thumbsize'] = sf_opcheck(sf_get_option('sfthumbsize'));
  2121. $sfimage['style'] = 'left';
  2122. sf_add_option('sfimage', $sfimage);
  2123. sf_delete_option('sfimgenlarge');
  2124. sf_delete_option('sfthumbsize');
  2125. # new admin colours defaults
  2126. $sfacolours = array();
  2127. $sfacolours = sf_opcheck(sf_get_option('sfacolours'));
  2128. $sfacolours['submitbg'] = '27537A';
  2129. $sfacolours['submitbgt'] = 'FFFFFF';
  2130. sf_update_option('sfacolours', $sfacolours);
  2131. # update all admin specific colors
  2132. sf_update_admin_colors();
  2133. # Dupe post filters
  2134. $sffilters = array();
  2135. $sffilters = sf_opcheck(sf_get_option('sffilters'));
  2136. $sffilters['sfdupemember'] = 0;
  2137. $sffilters['sfdupeguest'] = 0;
  2138. sf_update_option('sffilters', $sffilters);
  2139. # move admin colors from usermeta to admin options
  2140. sf_move_admin_colors();
  2141. sf_add_option('sfbuildsitemap', 2); # rebuild sitemap on new topics
  2142. # blog linking comments
  2143. $sfpostlinking = array();
  2144. $sfpostlinking = sf_opcheck(sf_get_option('sfpostlinking'));
  2145. if($sfpostlinking['sflinkcomments'])
  2146. {
  2147. $sfpostlinking['sflinkcomments'] = 2;
  2148. } else {
  2149. $sfpostlinking['sflinkcomments'] = 1;
  2150. }
  2151. sf_update_option('sfpostlinking', $sfpostlinking);
  2152. sf_update_option('sfbuild', $section);
  2153. echo $section;
  2154. die();
  2155. }
  2156. # 4.2 beta 2 =====================================================================================
  2157. $section = 3491;
  2158. if($build < $section)
  2159. {
  2160. # default filter shortcodes to on
  2161. sf_update_option('sffiltershortcodes', true);
  2162. # make room for buddypress profile display and edit modes
  2163. $profile = sf_get_option('sfprofile');
  2164. if ($profile['displaymode'] == 3) $sfprofile['displaymode'] = 4;
  2165. if ($profile['formmode'] == 3) $sfprofile['formmode'] = 4;
  2166. sf_update_option('sfprofile', $profile);
  2167. # correct pm flag set to 0 issue in 4.2 beta 1
  2168. $members = $wpdb->get_results("SELECT * FROM ".SFMEMBERS." WHERE pm=0");
  2169. sfc_rebuild_members_pm($members);
  2170. # poster ip size to handle ip6
  2171. $sql = "ALTER TABLE ".SFPOSTS." MODIFY poster_ip varchar(39) NOT NULL";
  2172. $wpdb->query($sql);
  2173. # default uploads FM tab
  2174. $sfuploads = sf_get_option('sfuploads');
  2175. $sfuploads['deftab'] = 2; # upload tab
  2176. sf_update_option('sfuploads', $sfuploads);
  2177. # force upgrade needs to be set every time
  2178. sf_delete_option('sfforceupgrade');
  2179. # custom filter storage
  2180. $sfconfig = sf_opcheck(sf_get_option('sfconfig'));
  2181. $sfconfig['filters'] = $basepath . 'plugins/simple-forum/library';
  2182. sf_update_option('sfconfig', $sfconfig);
  2183. # seo for other forum pages
  2184. $sfseo = sf_get_option('sfseo');
  2185. $sfseo['sfseo_page'] = true;
  2186. sf_update_option('sfseo', $sfseo);
  2187. sf_update_option('sfbuild', $section);
  2188. echo $section;
  2189. die();
  2190. }
  2191. # 4.3 =====================================================================================
  2192. $section = 3723;
  2193. if($build < $section)
  2194. {
  2195. # add new Can Use Spoilers permission
  2196. sf_upgrade_add_new_role('Can use spoilers', 1, true);
  2197. # add new Can View Links permission
  2198. sf_upgrade_add_new_role('Can view links', 1, false, false, true);
  2199. # init no links message
  2200. $sffilters = sf_get_option('sffilters');
  2201. $sffilters['sfnolinksmsg'] = "<b>** you don't have permission to see this link **</b>";
  2202. sf_update_option('sffilters', $sffilters);
  2203. # remove signature image permission and put sig image in sig
  2204. sf_convert_sig_images();
  2205. # remove signature image permission and put sig image in sig
  2206. sf_convert_block_admin();
  2207. # default for topic title location
  2208. $sfdisplay = sf_opcheck(sf_get_option('sfdisplay'));
  2209. $sfdisplay['forums']['showtitletop'] = false;
  2210. sf_update_option('sfdisplay', $sfdisplay);
  2211. # member view permissions
  2212. $sfmembersopt = sf_get_option('sfmemberopts');
  2213. $sfmembersopt['sfviewperm'] = true;
  2214. sf_add_option('sfmemberopts', $sfmembersopt);
  2215. sf_update_option('sfbuild', $section);
  2216. echo $section;
  2217. die();
  2218. }
  2219. $section = 3778;
  2220. if($build < $section)
  2221. {
  2222. # add user id to new user list
  2223. sf_upgrade_new_user_list();
  2224. sf_update_option('sfbuild', $section);
  2225. echo $section;
  2226. die();
  2227. }
  2228. $section = 3783;
  2229. if($build < $section)
  2230. {
  2231. # blog linking comments - hide dupes
  2232. $sfpostlinking = array();
  2233. $sfpostlinking = sf_opcheck(sf_get_option('sfpostlinking'));
  2234. $sfpostlinking['sfhideduplicate'] = true;
  2235. sf_update_option('sfpostlinking', $sfpostlinking);
  2236. # post tip on topic links
  2237. $sfdisplay = array();
  2238. $sfdisplay = sf_get_option('sfdisplay');
  2239. $sfdisplay['topics']['posttip'] = true;
  2240. sf_update_option('sfdisplay', $sfdisplay);
  2241. # second toolbar row
  2242. sf_add_option('sftbextras', '');
  2243. sf_update_option('sfbuild', $section);
  2244. echo $section;
  2245. die();
  2246. }
  2247. $section = 3856;
  2248. if($build < $section)
  2249. {
  2250. # print topic option
  2251. $sfdisplay = array();
  2252. $sfdisplay = sf_get_option('sfdisplay');
  2253. $sfdisplay['topics']['print'] = true;
  2254. sf_update_option('sfdisplay', $sfdisplay);
  2255. sf_update_option('sfbuild', $section);
  2256. echo $section;
  2257. die();
  2258. }
  2259. $section = 3907;
  2260. if($build < $section)
  2261. {
  2262. # remove the page title include option - not used anymore
  2263. $sfdisplay = array();
  2264. $sfdisplay = sf_get_option('sfdisplay');
  2265. unset($sfdisplay['pagetitle']['include']);
  2266. sf_update_option('sfdisplay', $sfdisplay);
  2267. sf_update_option('sfbuild', $section);
  2268. echo $section;
  2269. die();
  2270. }
  2271. $section = 3916;
  2272. if($build < $section)
  2273. {
  2274. # remove the page title include option - not used anymore
  2275. $sfpostlinking = array();
  2276. $sfpostlinking = sf_get_option('sfpostlinking');
  2277. $sfpostlinking['sflinkurls'] = 1; # each get their own canonical url
  2278. sf_add_option('sfpostlinking', $sfpostlinking);
  2279. sf_update_option('sfbuild', $section);
  2280. echo $section;
  2281. die();
  2282. }
  2283. $section = 3925;
  2284. if($build < $section)
  2285. {
  2286. # syntax highlighting
  2287. $syntax = array();
  2288. $syntax['sfsyntaxforum'] = false;
  2289. $syntax['sfsyntaxblog'] = false;
  2290. $syntax['sfbrushes'] = 'apache,applescript,asm,bash-script,bash,basic,clang,css,diff,html,javascript,lisp,ooc,php,python,ruby,sql';
  2291. sf_add_option('sfsyntax', $syntax);
  2292. sf_update_option('sfbuild', $section);
  2293. echo $section;
  2294. die();
  2295. }
  2296. $section = 3954;
  2297. if($build < $section)
  2298. {
  2299. $sftwitter = array();
  2300. $sftwitter['sftwitterfollow'] = true;
  2301. sf_add_option('sftwitter', $sftwitter);
  2302. $sfdisplay = array();
  2303. $sfdisplay = sf_get_option('sfdisplay');
  2304. $sfdisplay['forums']['pinned'] = false;
  2305. sf_add_option('sfdisplay', $sfdisplay);
  2306. sf_update_option('sfbuild', $section);
  2307. echo $section;
  2308. die();
  2309. }
  2310. $section = 4044;
  2311. if($build < $section)
  2312. {
  2313. $sfmobile = array();
  2314. $sfmobile['browsers'] = '2.0 MMP, 240x320, 400X240, AvantGo, BlackBerry, Blazer, Cellphone, Danger, DoCoMo, Elaine/3.0, EudoraWeb, Googlebot-Mobile, hiptop, IEMobile, KYOCERA/WX310K, LG/U990, MIDP-2., MMEF20, MOT-V, NetFront, Newt, Nintendo Wii, Nitro, Nokia, Opera Mini, Palm, PlayStation Portable, portalmmm, Proxinet, ProxiNet, SHARP-TQ-GX10, SHG-i900, Small, SonyEricsson, Symbian OS, SymbianOS, TS21i-10, UP.Browser, UP.Link, webOS, Windows CE, WinWAP, YahooSeeker/M1A1-R2D2';
  2315. $sfmobile['touch'] = 'iPhone, iPod, Android, BlackBerry9530, LG-TU915 Obigo, LGE VX, webOS, Nokia5800';
  2316. sf_add_option('sfmobile', $sfmobile);
  2317. sf_update_option('sfbuild', $section);
  2318. echo $section;
  2319. die();
  2320. }
  2321. $section = 4072;
  2322. if($build < $section)
  2323. {
  2324. $sfdisplay = array();
  2325. $sfdisplay = sf_get_option('sfdisplay');
  2326. $sfdisplay['posts']['sffbconnect'] = true;
  2327. $sfdisplay['posts']['sfmyspace'] = true;
  2328. sf_add_option('sfdisplay', $sfdisplay);
  2329. sf_update_option('sfbuild', $section);
  2330. echo $section;
  2331. die();
  2332. }
  2333. $section = 4124;
  2334. if($build < $section)
  2335. {
  2336. # remove old options still around
  2337. sf_delete_option('sfsmilies');
  2338. sf_delete_option('sfshowavatars');
  2339. sf_delete_option('sfextprofile');
  2340. sf_delete_option('sfgravatar');
  2341. sf_delete_option('sfpmemail');
  2342. sf_delete_option('sfpmmax');
  2343. sf_delete_option('sfpostpaging');
  2344. sf_delete_option('sfavataruploads');
  2345. sf_delete_option('sfgmaxrating');
  2346. sf_delete_option('sfwpavatar');
  2347. sf_update_option('sfbuild', $section);
  2348. echo $section;
  2349. die();
  2350. }
  2351. # 4.3.1 =====================================================================================
  2352. $section = 4200;
  2353. if($build < $section)
  2354. {
  2355. # post content width
  2356. $sfpostwrap = array();
  2357. $sfpostwrap['postwrap']=false;
  2358. $sfpostwrap['postwidth']=0;
  2359. sf_add_option('sfpostwrap', $sfpostwrap);
  2360. sf_update_option('sfbuild', $section);
  2361. echo $section;
  2362. die();
  2363. }
  2364. # 4.3.2 =====================================================================================
  2365. $section = 4220;
  2366. if($build < $section)
  2367. {
  2368. # filter wp_list_pages
  2369. sf_add_option('sfwplistpages', true);
  2370. # Script in footer
  2371. sf_add_option('sfscriptfoot', true);
  2372. sf_update_option('sfbuild', $section);
  2373. echo $section;
  2374. die();
  2375. }
  2376. # 4.3.3 =====================================================================================
  2377. $section = 4312;
  2378. if($build < $section)
  2379. {
  2380. # add new Can Upload Signatures permission
  2381. sf_upgrade_add_new_role('Can upload signatures', 1, true);
  2382. # add new profile display option (needs to maybe massage data)
  2383. $sfprofile = array();
  2384. $sfprofile = sf_get_option('sfprofile');
  2385. if($sfprofile['displaymode'] == 4)
  2386. {
  2387. $sfprofile['displaymode'] = 5;
  2388. sf_update_option('sfprofile', $sfprofile);
  2389. }
  2390. # add show all nested child forums
  2391. $sfdisplay = array();
  2392. $sfdisplay = sf_get_option('sfdisplay');
  2393. $sfdisplay['groups']['showallsubs'] = false;
  2394. $sfdisplay['groups']['combinesubcount'] = false;
  2395. sf_update_option('sfdisplay', $sfdisplay);
  2396. sf_update_option('sfbuild', $section);
  2397. echo $section;
  2398. die();
  2399. }
  2400. $section = 4376;
  2401. if($build < $section)
  2402. {
  2403. # add new profile field for linkedin
  2404. $sfprofile = array();
  2405. $sfprofile = sf_get_option('sfprofile');
  2406. $sfprofile['require']['linkedin'] = false;
  2407. $sfprofile['include']['linkedin'] = true;
  2408. $sfprofile['display']['linkedin'] = true;
  2409. $sfprofile['label']['linkedin'] = 'LinkedIn';
  2410. sf_update_option('sfprofile', $sfprofile);
  2411. $sfdisplay = array();
  2412. $sfdisplay = sf_get_option('sfdisplay');
  2413. $sfdisplay['posts']['sflinkedin'] = true;
  2414. sf_update_option('sfdisplay', $sfdisplay);
  2415. $sfimage = array();
  2416. $sfimage = sf_get_option('sfimage');
  2417. $sfimage['process'] = true;
  2418. sf_update_option('sfimage', $sfimage);
  2419. sf_update_option('sfbuild', $section);
  2420. echo $section;
  2421. die();
  2422. }
  2423. # 4.3.4 =====================================================================================
  2424. $section = 4646;
  2425. if($build < $section)
  2426. {
  2427. $sfmobile = array();
  2428. $sfmobile = sf_get_option('sfmobile');
  2429. $sfmobile['touch'].= ', iPad';
  2430. sf_update_option('sfmobile', $sfmobile);
  2431. sf_update_option('sfbuild', $section);
  2432. echo $section;
  2433. die();
  2434. }
  2435. $section = 4696;
  2436. if($build < $section)
  2437. {
  2438. # clean up the user transient records
  2439. sf_transient_cleanup();
  2440. sf_update_option('sfbuild', $section);
  2441. echo $section;
  2442. die();
  2443. }
  2444. # 4.4.0 =====================================================================================
  2445. $section = 5030;
  2446. if($build < $section)
  2447. {
  2448. # user id size to match wp user id
  2449. $sql = "ALTER TABLE ".SFMEMBERS." MODIFY user_id bigint(20) unsigned NOT NULL default '0'";
  2450. $wpdb->query($sql);
  2451. $sql = "ALTER TABLE ".SFMEMBERSHIPS." MODIFY user_id bigint(20) unsigned NOT NULL default '0'";
  2452. $wpdb->query($sql);
  2453. $sql = "ALTER TABLE ".SFMESSAGES." MODIFY from_id bigint(20) unsigned default NULL";
  2454. $wpdb->query($sql);
  2455. $sql = "ALTER TABLE ".SFMESSAGES." MODIFY to_id bigint(20) unsigned default NULL";
  2456. $wpdb->query($sql);
  2457. $sql = "ALTER TABLE ".SFPOSTS." MODIFY user_id bigint(20) unsigned default NULL";
  2458. $wpdb->query($sql);
  2459. $sql = "ALTER TABLE ".SFTOPICS." MODIFY user_id bigint(20) unsigned default NULL";
  2460. $wpdb->query($sql);
  2461. $sql = "ALTER TABLE ".SFTRACK." MODIFY trackuserid bigint(20) unsigned default '0'";
  2462. $wpdb->query($sql);
  2463. $sql = "ALTER TABLE ".SFWAITING." MODIFY user_id bigint(20) unsigned default '0'";
  2464. $wpdb->query($sql);
  2465. $sql = "ALTER TABLE ".SFLOG." MODIFY user_id bigint(20) unsigned NOT NULL";
  2466. $wpdb->query($sql);
  2467. # add key to trackuserid
  2468. $wpdb->query("ALTER TABLE ".SFTRACK." ADD INDEX user_idx (trackuserid);");
  2469. # blog linking for custom post types
  2470. $sflinkposttype = array();
  2471. $sflinkposttype['post'] = true;
  2472. $sflinkposttype['page'] = true;
  2473. sf_add_option('sflinkposttype', $sflinkposttype);
  2474. sf_update_option('sfbuild', $section);
  2475. echo $section;
  2476. die();
  2477. }
  2478. $section = 5098;
  2479. if($build < $section)
  2480. {
  2481. # increase icons to length 50
  2482. $sql = "ALTER TABLE ".SFGROUPS." MODIFY group_icon varchar(50) default NULL";
  2483. $wpdb->query($sql);
  2484. $sql = "ALTER TABLE ".SFFORUMS." MODIFY forum_icon varchar(50) default NULL";
  2485. $wpdb->query($sql);
  2486. sf_update_option('sfbuild', $section);
  2487. echo $section;
  2488. die();
  2489. }
  2490. $section = 5135;
  2491. if($build < $section)
  2492. {
  2493. # Add support for dispalying subforums in topic view
  2494. $sfdisplay = array();
  2495. $sfdisplay = sf_get_option('sfdisplay');
  2496. $sfdisplay['topics']['showsubforums'] = true;
  2497. sf_update_option('sfdisplay', $sfdisplay);
  2498. sf_update_option('sfbuild', $section);
  2499. echo $section;
  2500. die();
  2501. }
  2502. $section = 5336;
  2503. if($build < $section)
  2504. {
  2505. # make sure profile has default label for twitter
  2506. $sfprofile = sf_get_option('sfprofile');
  2507. if (!array_key_exists('twitter', $sfprofile['label'])) $sfprofile['label']['twitter'] = 'Twitter';
  2508. sf_update_option('sfprofile', $sfprofile);
  2509. sf_update_option('sfbuild', $section);
  2510. echo $section;
  2511. die();
  2512. }
  2513. # 4.4.5 =====================================================================================
  2514. $section = 6060;
  2515. if($build < $section)
  2516. {
  2517. # repair icon array
  2518. $icons = array();
  2519. $icons = sf_get_option('sfshowicon');
  2520. if(!array_key_exists('Mark All Read', $icons)) {
  2521. $icons['Mark All Read']=0;
  2522. }
  2523. if(!array_key_exists('Print this Topic', $icons)) {
  2524. $icons['Print this Topic']=0;
  2525. }
  2526. sf_update_option('sfshowicon', $icons);
  2527. }
  2528. # Finished Upgrades ===============================================================================
  2529. # EVERYTHING BELOW MUST BE AT THE END
  2530. sf_log_event(SFRELEASE, SFVERSION, SFBUILD);
  2531. echo SFBUILD;
  2532. delete_option('sfInstallID'); # use wp option table
  2533. die();
  2534. ?>