function sp_rebuild_table_list() { global $tables; sp_delete_option('installed_tables'); $t = array(); foreach ($tables as $table => $data) { $found = spdb_select('var', "SHOW TABLES LIKE '{$table}'"); if ($found) { $t[] = $table; } } sp_add_option('installed_tables', $t); }
function sp_admin_bar_do_install() { global $spThisUser; $oldOptions = sp_get_option('sfadminsettings'); $newOptions = sp_get_option('spAdminBar'); if (!isset($oldOptions['sfqueue']) && empty($newOptions)) { $newOptions = array(); $newOptions['dashboardposts'] = false; $newOptions['dbversion'] = SPABDBVERSION; sp_add_option('spAdminBar', $newOptions); $options = sp_get_member_item($spThisUser->ID, 'admin_options'); $options['sfadminbar'] = true; sp_update_member_item($spThisUser->ID, 'admin_options', $options); } else { if (empty($newOptions)) { $newOptions = array(); $newOptions['dashboardposts'] = $oldOptions['sfdashboardposts']; $newOptions['dbversion'] = SPABDBVERSION; sp_add_option('spAdminBar', $newOptions); $options = sp_get_member_item($spThisUser->ID, 'admin_options'); $options['sfadminbar'] = true; sp_update_member_item($spThisUser->ID, 'admin_options', $options); unset($oldOptions['sfqueue']); unset($oldOptions['sfmodasadmin']); unset($oldOptions['sfshowmodposts']); unset($oldOptions['sfbaronly']); unset($oldOptions['sfdashboardposts']); sp_update_option('sfadminsettings', $oldOptions); } } # permission for bypassing akismet checks sp_add_auth('bypass_akismet', __('Can bypass akismet check on posts', 'spab'), 1, 0, 0, 0, 3); sp_activate_auth('bypass_akismet'); # create new Akismet setting $akismet = sp_get_option('spAkismet'); if (empty($akismet)) { sp_add_option('spAkismet', 1); } # get auto update running $autoup = array('spabupdate', 'sp_ahah=admin-bar-update&target=newposts'); sp_add_sfmeta('autoupdate', 'admin', $autoup, 1); }
function sp_rebuild_topic_cache() { $size = sp_get_option('topic_cache'); if (!isset($size) || $size == 0) { sp_add_option('topic_cache', 200); } $sql = "SELECT DISTINCTROW forum_id, topic_id, post_id, post_status\n\t\t\tFROM " . SFPOSTS . "\n\t\t\tORDER BY post_id DESC\n\t\t\tLIMIT {$size}"; $topics = spdb_select('set', $sql, ARRAY_N); if ($topics) { sp_add_sfmeta('topic_cache', 'new', $topics, true); } # Delete group level cache for good measure spdb_query("DELETE FROM " . SFCACHE . " WHERE cache_id LIKE '%*group'"); return $topics; }
function sp_create_installed_tables() { # create an array for holding tables $tables = array(); # core tables $tables[] = SFGROUPS; $tables[] = SFFORUMS; $tables[] = SFTOPICS; $tables[] = SFPOSTS; $tables[] = SFWAITING; $tables[] = SFTRACK; $tables[] = SFUSERGROUPS; $tables[] = SFPERMISSIONS; $tables[] = SFROLES; $tables[] = SFMEMBERS; $tables[] = SFMEMBERSHIPS; $tables[] = SFMETA; $tables[] = SFDEFPERMISSIONS; $tables[] = SFLOG; $tables[] = SFOPTIONS; $tables[] = SFERRORLOG; $tables[] = SFAUTHS; $tables[] = SFAUTHCATS; $tables[] = SFNOTICES; # add in known plugin tables that might exist if (!defined('SFMESSAGES')) { define('SPPMMESSAGES', SF_PREFIX . 'sfmessages'); } if (!defined('SPPMADVERSARIES')) { define('SPPMADVERSARIES', SF_PREFIX . 'sfadversaries'); } if (!defined('SPPMATTACHMENTS')) { define('SPPMATTACHMENTS', SF_PREFIX . 'sfpmattachments'); } if (!defined('SPDIGEST')) { define('SPDIGEST', SF_PREFIX . 'sfdigest'); } if (!defined('SFMAILLOG')) { define('SFMAILLOG', SF_PREFIX . 'sfmaillog'); } if (!defined('SPPOLLS')) { define('SPPOLLS', SF_PREFIX . 'sfpolls'); } if (!defined('SPPOLLSANSWERS')) { define('SPPOLLSANSWERS', SF_PREFIX . 'sfpollsanswers'); } if (!defined('SPPOLLSVOTERS')) { define('SPPOLLSVOTERS', SF_PREFIX . 'sfpollsvoters'); } if (!defined('SFPOSTRATINGS')) { define('SFPOSTRATINGS', SF_PREFIX . 'sfpostratings'); } if (!defined('SFTAGS')) { define('SFTAGS', SF_PREFIX . 'sftags'); } if (!defined('SFTAGMETA')) { define('SFTAGMETA', SF_PREFIX . 'sftagmeta'); } if (!defined('SFLINKS')) { define('SFLINKS', SF_PREFIX . 'sflinks'); } $tables[] = SFMESSAGES; $tables[] = SPPMADVERSARIES; $tables[] = SPPMATTACHMENTS; $tables[] = SPDIGEST; $tables[] = SFMAILLOG; $tables[] = SPPOLLS; $tables[] = SPPOLLSANSWERS; $tables[] = SPPOLLSVOTERS; $tables[] = SFPOSTRATINGS; $tables[] = SFTAGS; $tables[] = SFTAGMETA; $tables[] = SFLINKS; # now save off installed tables sp_add_option('installed_tables', $tables); }
function sp_update_option($option_name, $newvalue) { global $wpdb, $spAllOptions; $oldvalue = sp_get_option($option_name); if ($newvalue === $oldvalue) { return false; } if (!isset($spAllOptions[$option_name])) { $result = sp_add_option($option_name, $newvalue); return $result; } $newvalue = maybe_serialize($newvalue); $result = $wpdb->update(SFOPTIONS, array('option_value' => $newvalue), array('option_name' => $option_name)); if ($result) { $spAllOptions[$option_name] = $newvalue; return true; } else { return false; } }
function sp_perform_install($phase, $subphase = 0) { global $current_user, $spVars; switch ($phase) { case 1: # create an array of installed tables to save for uninstall. plugins will add theirs to be sure we get good cleanup $tables = array(); # sfauthcats table def $sql = ' CREATE TABLE IF NOT EXISTS ' . SFAUTHCATS . ' ( authcat_id tinyint(4) NOT NULL auto_increment, authcat_name varchar(50) NOT NULL, authcat_slug varchar(50) NOT NULL, authcat_desc tinytext, PRIMARY KEY (authcat_id), KEY authcat_slug_idx (authcat_slug) ) ' . spdb_charset(); spdb_query($sql); $tables[] = SFAUTHCATS; # sfauths table def $sql = ' CREATE TABLE IF NOT EXISTS ' . SFAUTHS . " (\n\t\t\t\t\tauth_id bigint(20) NOT NULL auto_increment,\n\t\t\t\t\tauth_name varchar(50) NOT NULL,\n\t\t\t\t\tauth_desc text,\n\t\t\t\t\tactive smallint(1) NOT NULL default '0',\n\t\t\t\t\tignored smallint(1) NOT NULL default '0',\n\t\t\t\t\tenabling smallint(1) NOT NULL default '0',\n\t\t\t\t\tadmin_negate smallint(1) NOT NULL default '0',\n\t\t\t\t\tauth_cat bigint(20) NOT NULL default '1',\n\t\t\t\t\twarning tinytext,\n\t\t\t\t\tPRIMARY KEY\t (auth_id),\n\t\t\t\t\tKEY auth_name_idx (auth_name)\n\t\t\t\t) " . spdb_charset(); spdb_query($sql); $tables[] = SFAUTHS; # the cache table (5.4.2) $sql = ' CREATE TABLE IF NOT EXISTS ' . SFCACHE . " (\n\t\t\t\t\tcache_id varchar(40) NOT NULL DEFAULT '',\n\t\t\t\t\tcache_out bigint(6) DEFAULT NULL,\n\t\t\t\t\tcache mediumtext,\n\t\t\t\t\tPRIMARY KEY (cache_id)\n\t\t\t\t) " . spdb_charset(); spdb_query($sql); $tables[] = SFCACHE; # sfdefpermissions table def $sql = ' CREATE TABLE IF NOT EXISTS ' . SFDEFPERMISSIONS . " (\n\t\t\t\t\tpermission_id bigint(20) NOT NULL auto_increment,\n\t\t\t\t\tgroup_id bigint(20) NOT NULL default '0',\n\t\t\t\t\tusergroup_id bigint(20) NOT NULL default '0',\n\t\t\t\t\tpermission_role bigint(20) NOT NULL default '0',\n\t\t\t\t\tPRIMARY KEY\t (permission_id),\n\t\t\t\t\tKEY group_id_idx (group_id),\n\t\t\t\t\tKEY usergroup_id_idx (usergroup_id),\n\t\t\t\t\tKEY permission_role_idx (permission_role)\n\t\t\t\t) " . spdb_charset(); spdb_query($sql); $tables[] = SFDEFPERMISSIONS; # error log table $sql = ' CREATE TABLE IF NOT EXISTS ' . SFERRORLOG . " (\n\t\t\t\t\tid bigint(20) NOT NULL auto_increment,\n\t\t\t\t\terror_date datetime NOT NULL,\n\t\t\t\t\terror_type varchar(10) NOT NULL,\n\t\t\t\t\terror_cat varchar(13) NOT NULL default 'spaErrOther',\n\t\t\t\t\tkeycheck varchar(45),\n\t\t\t\t\terror_count smallint(6),\n\t\t\t\t\terror_text text,\n\t\t\t\t\tPRIMARY KEY (id)\n\t\t\t\t) " . spdb_charset(); spdb_query($sql); $tables[] = SFERRORLOG; # sfforums table def $sql = ' CREATE TABLE IF NOT EXISTS ' . SFFORUMS . " (\n\t\t\t\t\tforum_id bigint(20) NOT NULL auto_increment,\n\t\t\t\t\tforum_name varchar(200) NOT NULL,\n\t\t\t\t\tgroup_id bigint(20) NOT NULL,\n\t\t\t\t\tforum_seq int(4) default NULL,\n\t\t\t\t\tforum_desc text default NULL,\n\t\t\t\t\tforum_status int(4) NOT NULL default '0',\n\t\t\t\t\tforum_disabled smallint(1) NOT NULL default '0',\n\t\t\t\t\tforum_slug varchar(200) NOT NULL,\n\t\t\t\t\tforum_rss text default NULL,\n\t\t\t\t\tforum_icon varchar(50) default NULL,\n\t\t\t\t\tforum_icon_new varchar(50) default NULL,\n\t\t\t\t\tforum_icon_locked varchar(50) default NULL,\n\t\t\t\t\ttopic_icon varchar(50) default NULL,\n\t\t\t\t\ttopic_icon_new varchar(50) default NULL,\n\t\t\t\t\ttopic_icon_locked varchar(50) default NULL,\n\t\t\t\t\ttopic_icon_pinned varchar(50) default NULL,\n\t\t\t\t\tpost_id bigint(20) default NULL,\n\t\t\t\t\tpost_id_held bigint(20) default NULL,\n\t\t\t\t\ttopic_count mediumint(8) default '0',\n\t\t\t\t\tpost_count mediumint(8) default '0',\n\t\t\t\t\tpost_count_held mediumint(8) default '0',\n\t\t\t\t\tforum_rss_private smallint(1) NOT NULL default '0',\n\t\t\t\t\tparent bigint(20) NOT NULL default '0',\n\t\t\t\t\tchildren text default NULL,\n\t\t\t\t\tforum_message text,\n\t\t\t\t\tkeywords varchar(256) default NULL,\n\t\t\t\t\tPRIMARY KEY\t (forum_id),\n\t\t\t\t\tKEY group_id_idx (group_id),\n\t\t\t\t\tKEY forum_slug_idx (forum_slug),\n\t\t\t\t\tKEY post_id_idx (post_id)\n\t\t\t\t) " . spdb_charset(); spdb_query($sql); $tables[] = SFFORUMS; # sfgroups table def $sql = ' CREATE TABLE IF NOT EXISTS ' . SFGROUPS . ' ( group_id bigint(20) NOT NULL auto_increment, group_name text, group_seq int(4) default NULL, group_desc text, group_rss text, group_icon varchar(50) default NULL, group_message text, PRIMARY KEY (group_id) ) ' . spdb_charset(); spdb_query($sql); $tables[] = SFGROUPS; # install log table def $sql = ' CREATE TABLE IF NOT EXISTS ' . SFLOG . ' ( id bigint(20) NOT NULL auto_increment, user_id bigint(20) NOT NULL, install_date date NOT NULL, release_type varchar(20), version varchar(10) NOT NULL, build int(6) NOT NULL, PRIMARY KEY (id) ) ' . spdb_charset(); spdb_query($sql); $tables[] = SFLOG; # install log section table def $sql = ' CREATE TABLE IF NOT EXISTS ' . SFLOGMETA . ' ( id int(11) unsigned NOT NULL AUTO_INCREMENT, version varchar(10) DEFAULT NULL, log_data tinytext, PRIMARY KEY (id) ) ' . spdb_charset(); spdb_query($sql); $tables[] = SFLOGMETA; # sfmembers table def $sql = ' CREATE TABLE IF NOT EXISTS ' . SFMEMBERS . " (\n\t\t\t\t\tuser_id bigint(20) NOT NULL default '0',\n\t\t\t\t\tdisplay_name varchar(100) default NULL,\n\t\t\t\t\tmoderator smallint(1) NOT NULL default '0',\n\t\t\t\t\tavatar longtext default NULL,\n\t\t\t\t\tsignature text default NULL,\n\t\t\t\t\tposts int(4) default NULL,\n\t\t\t\t\tlastvisit datetime default NULL,\n\t\t\t\t\tnewposts longtext,\n\t\t\t\t\tchecktime datetime default NULL,\n\t\t\t\t\tadmin smallint(1) NOT NULL default '0',\n\t\t\t\t\tfeedkey varchar(36) default NULL,\n\t\t\t\t\tadmin_options longtext default NULL,\n\t\t\t\t\tuser_options longtext default NULL,\n\t\t\t\t\tauths longtext default NULL,\n\t\t\t\t\tmemberships longtext default NULL,\n\t\t\t\t\tplugin_data longtext default NULL,\n\t\t\t\t\tPRIMARY KEY\t (user_id),\n\t\t\t\t\tKEY admin_idx (admin),\n\t\t\t\t\tKEY moderator_idx (moderator)\n\t\t\t\t) " . spdb_charset(); spdb_query($sql); $tables[] = SFMEMBERS; # sfmemberships table def $sql = ' CREATE TABLE IF NOT EXISTS ' . SFMEMBERSHIPS . " (\n\t\t\t\t\tmembership_id bigint(20) NOT NULL auto_increment,\n\t\t\t\t\tuser_id bigint(20) unsigned NOT NULL default '0',\n\t\t\t\t\tusergroup_id bigint(20) unsigned NOT NULL default '0',\n\t\t\t\t\tPRIMARY KEY\t (membership_id),\n\t\t\t\t\tKEY user_id_idx (user_id),\n\t\t\t\t\tKEY usergroup_id_idx (usergroup_id)\n\t\t\t\t) " . spdb_charset(); spdb_query($sql); $tables[] = SFMEMBERSHIPS; # sfmeta table def $sql = ' CREATE TABLE IF NOT EXISTS ' . SFMETA . " (\n\t\t\t\t\tmeta_id bigint(20) NOT NULL auto_increment,\n\t\t\t\t\tmeta_type varchar(20) NOT NULL,\n\t\t\t\t\tmeta_key varchar(100) default NULL,\n\t\t\t\t\tmeta_value longtext,\n\t\t\t\t\tautoload tinyint(2) NOT NULL default '0',\n\t\t\t\t\tPRIMARY KEY (meta_id),\n\t\t\t\t\tKEY meta_type_idx (meta_type),\n\t\t\t\t\tKEY autoload_idx (autoload)\n\t\t\t\t) " . spdb_charset(); spdb_query($sql); $tables[] = SFMETA; # user notices table $sql = ' CREATE TABLE IF NOT EXISTS ' . SFNOTICES . " (\n\t\t\t\t\tnotice_id bigint(20) NOT NULL auto_increment,\n\t\t\t\t\tuser_id bigint(20) default NULL,\n\t\t\t\t\tguest_email varchar(75) default NULL,\n\t\t\t\t\tpost_id bigint(20) default NULL,\n\t\t\t\t\tlink varchar(255) default NULL,\n\t\t\t\t\tlink_text varchar(200) default NULL,\n\t\t\t\t\tmessage varchar(255) NOT NULL default '',\n\t\t\t\t\texpires int(4) default NULL,\n\t\t\t\t\tPRIMARY KEY (notice_id),\n\t\t\t\t\tKEY user_id_idx (user_id)\n\t\t\t\t) " . spdb_charset(); spdb_query($sql); $tables[] = SFNOTICES; $sql = ' CREATE TABLE IF NOT EXISTS ' . SFOPTIONS . " (\n\t\t\t\t\toption_id bigint(20) unsigned NOT NULL auto_increment,\n\t\t\t\t\toption_name varchar(64) NOT NULL default '',\n\t\t\t\t\toption_value longtext NOT NULL,\n\t\t\t\t\tPRIMARY KEY (option_name),\n\t\t\t\t\tKEY option_id_idx (option_id)\n\t\t\t\t) " . spdb_charset(); spdb_query($sql); $tables[] = SFOPTIONS; # sfpermissions table def $sql = ' CREATE TABLE IF NOT EXISTS ' . SFPERMISSIONS . " (\n\t\t\t\t\tpermission_id bigint(20) NOT NULL auto_increment,\n\t\t\t\t\tforum_id bigint(20) NOT NULL default '0',\n\t\t\t\t\tusergroup_id bigint(20) unsigned NOT NULL default '0',\n\t\t\t\t\tpermission_role bigint(20) NOT NULL default '0',\n\t\t\t\t\tPRIMARY KEY\t (permission_id),\n\t\t\t\t\tKEY forum_id_idx (forum_id),\n\t\t\t\t\tKEY usergroup_id_idx (usergroup_id),\n\t\t\t\t\tKEY permission_role_idx (permission_role)\n\t\t\t\t) " . spdb_charset(); spdb_query($sql); $tables[] = SFPERMISSIONS; # sfposts table def $sql = ' CREATE TABLE IF NOT EXISTS ' . SFPOSTS . " (\n\t\t\t\t\tpost_id bigint(20) NOT NULL auto_increment,\n\t\t\t\t\tpost_content longtext,\n\t\t\t\t\tpost_date datetime NOT NULL,\n\t\t\t\t\ttopic_id bigint(20) NOT NULL,\n\t\t\t\t\tuser_id bigint(20) default NULL,\n\t\t\t\t\tforum_id bigint(20) NOT NULL,\n\t\t\t\t\tguest_name varchar(50) default NULL,\n\t\t\t\t\tguest_email varchar(75) default NULL,\n\t\t\t\t\tpost_status int(4) NOT NULL default '0',\n\t\t\t\t\tpost_pinned smallint(1) NOT NULL default '0',\n\t\t\t\t\tpost_index mediumint(8) default '0',\n\t\t\t\t\tpost_edit mediumtext,\n\t\t\t\t\tposter_ip varchar(39) NOT NULL default '0.0.0.0',\n\t\t\t\t\tcomment_id bigint(20) default NULL,\n\t\t\t\t\tsource smallint(1) NOT NULL default '0',\n\t\t\t\t\tPRIMARY KEY\t (post_id),\n\t\t\t\t\tKEY topic_id_idx (topic_id),\n\t\t\t\t\tKEY forum_id_idx (forum_id),\n\t\t\t\t\tKEY user_id_idx (user_id),\n\t\t\t\t\tKEY guest_name_idx (guest_name),\n\t\t\t\t\tKEY comment_id_idx (comment_id),\n\t\t\t\t\tKEY post_date_idx (post_date)\n\t\t\t\t) " . spdb_charset(); spdb_query($sql); $tables[] = SFPOSTS; # sfroles table def $sql = ' CREATE TABLE IF NOT EXISTS ' . SFROLES . " (\n\t\t\t\t\trole_id mediumint(8) unsigned NOT NULL auto_increment,\n\t\t\t\t\trole_name varchar(50) NOT NULL default '',\n\t\t\t\t\trole_desc varchar(150) NOT NULL default '',\n\t\t\t\t\trole_auths longtext NOT NULL,\n\t\t\t\t\tPRIMARY KEY\t (role_id)\n\t\t\t\t) " . spdb_charset(); spdb_query($sql); $tables[] = SFROLES; # special ranks (5.3.2) $sql = ' CREATE TABLE IF NOT EXISTS ' . SFSPECIALRANKS . ' ( id int(11) unsigned NOT NULL AUTO_INCREMENT, user_id bigint(20) default NULL, special_rank varchar(100), PRIMARY KEY (id), KEY user_id_idx (user_id), KEY special_rank_idx (special_rank) ) ' . spdb_charset(); spdb_query($sql); $tables[] = SFSPECIALRANKS; # sftopics table def $sql = ' CREATE TABLE IF NOT EXISTS ' . SFTOPICS . " (\n\t\t\t\t\ttopic_id bigint(20) NOT NULL auto_increment,\n\t\t\t\t\ttopic_name varchar(200) NOT NULL,\n\t\t\t\t\ttopic_date datetime NOT NULL,\n\t\t\t\t\ttopic_status int(4) NOT NULL default '0',\n\t\t\t\t\tforum_id bigint(20) NOT NULL,\n\t\t\t\t\tuser_id bigint(20) default NULL,\n\t\t\t\t\ttopic_pinned smallint(1) NOT NULL default '0',\n\t\t\t\t\ttopic_opened bigint(20) NOT NULL default '0',\n\t\t\t\t\ttopic_slug varchar(200) NOT NULL,\n\t\t\t\t\tpost_id bigint(20) default NULL,\n\t\t\t\t\tpost_id_held bigint(20) default NULL,\n\t\t\t\t\tpost_count mediumint(8) default '0',\n\t\t\t\t\tpost_count_held mediumint(8) default '0',\n\t\t\t\t\tPRIMARY KEY\t(topic_id),\n\t\t\t\t\tKEY forum_id_idx (forum_id),\n\t\t\t\t\tKEY topic_slug_idx (topic_slug),\n\t\t\t\t\tKEY user_id_idx (user_id),\n\t\t\t\t\tKEY post_id_idx (post_id)\n\t\t\t\t) " . spdb_charset(); spdb_query($sql); $tables[] = SFTOPICS; # sftrack table def $sql = ' CREATE TABLE IF NOT EXISTS ' . SFTRACK . " (\n\t\t\t\t\tid bigint(20) NOT NULL auto_increment,\n\t\t\t\t\ttrackuserid bigint(20) default '0',\n\t\t\t\t\ttrackname varchar(50) NOT NULL,\n\t\t\t\t\ttrackdate datetime NOT NULL,\n\t\t\t\t\tforum_id bigint(20) default NULL,\n\t\t\t\t\ttopic_id bigint(20) default NULL,\n\t\t\t\t\tpageview varchar(50) NOT NULL,\n\t\t\t\t\tnotification varchar(1024) default NULL,\n\t\t\t\t\tdevice char(1) default 'D',\n\t\t\t\t\tdisplay varchar(255) default NULL,\n\t\t\t\t\tPRIMARY KEY\t (id),\n\t\t\t\t\tKEY trackuserid_idx (trackuserid),\n\t\t\t\t\tKEY forum_id_idx (forum_id),\n\t\t\t\t\tKEY topic_id_idx (topic_id)\n\t\t\t\t) " . spdb_charset(); spdb_query($sql); $tables[] = SFTRACK; # user activity (5.3.2 - in preparation) $sql = ' CREATE TABLE IF NOT EXISTS ' . SFUSERACTIVITY . ' ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, user_id bigint(20) NOT NULL, type_id smallint(4) NOT NULL, item_id bigint(20) NOT NULL, meta_id bigint(20) DEFAULT NULL, PRIMARY KEY (id), KEY type_id_idx (type_id), KEY user_id_idx (user_id) ) ' . spdb_charset(); spdb_query($sql); $tables[] = SFUSERACTIVITY; # sfusergroups table def $sql = ' CREATE TABLE IF NOT EXISTS ' . SFUSERGROUPS . " (\n\t\t\t\t\tusergroup_id bigint(20) NOT NULL auto_increment,\n\t\t\t\t\tusergroup_name text NOT NULL,\n\t\t\t\t\tusergroup_desc text default NULL,\n\t\t\t\t\tusergroup_badge varchar(50) default NULL,\n\t\t\t\t\tusergroup_join tinyint(4) unsigned NOT NULL default '0',\n\t\t\t\t\tusergroup_is_moderator tinyint(4) unsigned NOT NULL default '0',\n\t\t\t\t\tPRIMARY KEY\t (usergroup_id)\n\t\t\t\t) " . spdb_charset(); spdb_query($sql); $tables[] = SFUSERGROUPS; # sfwaiting table def $sql = ' CREATE TABLE IF NOT EXISTS ' . SFWAITING . " (\n\t\t\t\t\ttopic_id bigint(20) NOT NULL,\n\t\t\t\t\tforum_id bigint(20) NOT NULL,\n\t\t\t\t\tpost_count int(4) NOT NULL,\n\t\t\t\t\tpost_id bigint(20) NOT NULL default '0',\n\t\t\t\t\tuser_id bigint(20) unsigned default '0',\n\t\t\t\t\tPRIMARY KEY\t (topic_id)\n\t\t\t\t) " . spdb_charset(); spdb_query($sql); $tables[] = SFWAITING; # now save off installed tables sp_add_option('installed_tables', $tables); echo '<h5>' . spa_text('Phase') . ' - ' . $phase . ' - '; spa_etext('Tables created') . '</h5>'; break; case 2: # populate auths spa_setup_auth_cats(); spa_setup_auths(); # set up the default permissions/roles spa_setup_permissions(); echo '<h5>' . spa_text('Phase') . ' - ' . $phase . ' - '; spa_etext('Permission data built') . '</h5>'; break; case 3: # Create default 'Guest' user group data $guests = spa_create_usergroup_row('Guests', 'Default Usergroup for guests of the forum', '', '0', '0', false); # Create default 'Members' user group data $members = spa_create_usergroup_row('Members', 'Default Usergroup for registered users of the forum', '', '0', '0', false); # Create default 'Moderators' user group data $moderators = spa_create_usergroup_row('Moderators', 'Default Usergroup for moderators of the forum', '', '0', '1', false); # Create default user groups sp_add_sfmeta('default usergroup', 'sfguests', $guests); # default usergroup for guests sp_add_sfmeta('default usergroup', 'sfmembers', $members); # default usergroup for members sp_create_usergroup_meta($members); # create default usergroups for existing wp roles echo '<h5>' . spa_text('Phase') . ' - ' . $phase . ' - '; spa_etext('Usergroup data built') . '</h5>'; break; case 4: $page_args = array('post_status' => 'publish', 'post_type' => 'page', 'post_author' => $current_user->ID, 'ping_status' => 'closed', 'comment_status' => 'closed', 'post_parent' => 0, 'menu_order' => 0, 'to_ping' => '', 'pinged' => '', 'post_password' => '', 'post_content' => '', 'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '', 'import_id' => 0, 'post_title' => 'Forum', 'page_template' => 'default'); $page_id = wp_insert_post($page_args); $page = spdb_table(SFWPPOSTS, "ID={$page_id}", 'row'); sp_add_option('sfslug', $page->post_name); # Update the guid for the new page $guid = get_permalink($page_id); spdb_query('UPDATE ' . SFWPPOSTS . " SET guid='{$guid}' WHERE ID={$page_id}"); sp_add_option('sfpage', $page_id); echo '<h5>' . spa_text('Phase') . ' - ' . $phase . ' - '; spa_etext('Forum page created') . '</h5>'; break; case 5: # Create Base Option Records (V1) sp_add_option('sfuninstall', false); sp_add_option('sfdates', get_option('date_format')); sp_add_option('sftimes', get_option('time_format')); sp_add_option('sfpermalink', get_permalink(sp_get_option('sfpage'))); sp_add_option('sflockdown', false); $rankdata['posts'] = 2; $rankdata['usergroup'] = 'none'; $rankdata['image'] = 'none'; sp_add_sfmeta('forum_rank', 'New Member', $rankdata, 1); $rankdata['posts'] = 1000; $rankdata['usergroup'] = 'none'; $rankdata['image'] = 'none'; sp_add_sfmeta('forum_rank', 'Member', $rankdata, 1); $sfimage = array(); $sfimage['enlarge'] = true; $sfimage['process'] = true; $sfimage['thumbsize'] = 100; $sfimage['style'] = 'left'; $sfimage['constrain'] = true; $sfimage['forceclear'] = false; sp_add_option('sfimage', $sfimage); sp_add_option('sfbadwords', ''); sp_add_option('sfreplacementwords', ''); sp_add_option('sfeditormsg', ''); $sfmail = array(); $sfmail['sfmailsender'] = get_bloginfo('name'); $admin_email = get_bloginfo('admin_email'); $comp = explode('@', $admin_email); $sfmail['sfmailfrom'] = $comp[0]; $sfmail['sfmaildomain'] = $comp[1]; $sfmail['sfmailuse'] = true; sp_add_option('sfmail', $sfmail); $sfmail = array(); $sfmail['sfusespfreg'] = true; $sfmail['sfnewusersubject'] = 'Welcome to %BLOGNAME%'; $sfmail['sfnewusertext'] = 'Welcome %USERNAME% to %BLOGNAME% %NEWLINE%Please find below your login details: %NEWLINE%Username: %USERNAME% %NEWLINE%Password: %PASSWORD% %NEWLINE%%LOGINURL%'; sp_add_option('sfnewusermail', $sfmail); $sfpostmsg = array(); $sfpostmsg['sfpostmsgtext'] = ''; $sfpostmsg['sfpostmsgtopic'] = false; $sfpostmsg['sfpostmsgpost'] = false; sp_add_option('sfpostmsg', $sfpostmsg); $sflogin = array(); $sflogin['sfregmath'] = true; $sflogin['sfloginurl'] = sp_url(); $sflogin['sflogouturl'] = sp_url(); $sflogin['sfregisterurl'] = ''; $sflogin['sfloginemailurl'] = esc_url(wp_login_url()); $sflogin['sptimeout'] = 20; sp_add_option('sflogin', $sflogin); $sfadminsettings = array(); $sfadminsettings['sfdashboardstats'] = true; $sfadminsettings['sfadminapprove'] = false; $sfadminsettings['sfmoderapprove'] = false; $sfadminsettings['editnotice'] = true; $sfadminsettings['movenotice'] = true; sp_add_option('sfadminsettings', $sfadminsettings); $sfauto = array(); $sfauto['sfautoupdate'] = false; $sfauto['sfautotime'] = 300; sp_add_option('sfauto', $sfauto); $sffilters = array(); $sffilters['sfnofollow'] = false; $sffilters['sftarget'] = true; $sffilters['sfurlchars'] = 40; $sffilters['sffilterpre'] = false; $sffilters['sfmaxlinks'] = 0; $sffilters['sfnolinksmsg'] = "<b>** you do not have permission to see this link **</b>"; $sffilters['sfdupemember'] = 0; $sffilters['sfdupeguest'] = 0; $sffilters['sfmaxsmileys'] = 0; sp_add_option('sffilters', $sffilters); $sfseo = array(); $sfseo['sfseo_overwrite'] = false; $sfseo['sfseo_blogname'] = false; $sfseo['sfseo_pagename'] = false; $sfseo['sfseo_homepage'] = true; $sfseo['sfseo_topic'] = true; $sfseo['sfseo_forum'] = true; $sfseo['sfseo_noforum'] = false; $sfseo['sfseo_page'] = true; $sfseo['sfseo_sep'] = '|'; sp_add_option('sfseo', $sfseo); $sfsigimagesize = array(); $sfsigimagesize['sfsigwidth'] = 0; $sfsigimagesize['sfsigheight'] = 0; sp_add_option('sfsigimagesize', $sfsigimagesize); # (V4.1.0) $sfmembersopt = array(); $sfmembersopt['sfcheckformember'] = true; $sfmembersopt['sfsinglemembership'] = false; $sfmembersopt['sfhidestatus'] = true; sp_add_option('sfmemberopts', $sfmembersopt); $sfcontrols = array(); $sfcontrols['showtopcount'] = 10; $sfcontrols['shownewcount'] = 10; $sfcontrols['sfdefunreadposts'] = 50; $sfcontrols['sfusersunread'] = false; $sfcontrols['sfmaxunreadposts'] = 50; sp_add_option('sfcontrols', $sfcontrols); $sfblock = array(); $sfblock['blockadmin'] = false; $sfblock['blockprofile'] = false; $sfblock['blockroles'] = 'administrator'; $sfblock['blockredirect'] = get_permalink(sp_get_option('sfpage')); sp_add_option('sfblockadmin', $sfblock); $sfmetatags = array(); $sfmetatags['sfdescr'] = ''; $sfmetatags['sfdescruse'] = 1; $sfmetatags['sfusekeywords'] = 2; $sfmetatags['sfkeywords'] = 'forum'; sp_add_option('sfmetatags', $sfmetatags); # display array $sfdisplay = array(); $sfdisplay['pagetitle']['notitle'] = false; $sfdisplay['pagetitle']['banner'] = ''; $sfdisplay['forums']['singleforum'] = false; $sfdisplay['topics']['perpage'] = 12; $sfdisplay['topics']['sortnewtop'] = true; $sfdisplay['posts']['perpage'] = 20; $sfdisplay['posts']['sortdesc'] = false; sp_add_option('sfdisplay', $sfdisplay); sp_add_sfmeta('sort_order', 'forum', '', 1); sp_add_sfmeta('sort_order', 'topic', '', 1); # guest settings $sfguests = array(); $sfguests['reqemail'] = true; $sfguests['storecookie'] = true; sp_add_option('sfguests', $sfguests); # profile management $sfprofile = array(); $sfprofile['nameformat'] = true; $sfprofile['fixeddisplayformat'] = 0; $sfprofile['namelink'] = 2; $sfprofile['displaymode'] = 1; $sfprofile['displaypage'] = ''; $sfprofile['displayquery'] = ''; $sfprofile['formmode'] = 1; $sfprofile['formpage'] = ''; $sfprofile['formquery'] = ''; $sfprofile['photosmax'] = 0; $sfprofile['photoswidth'] = 0; $sfprofile['photosheight'] = 0; $sfprofile['firstvisit'] = true; $sfprofile['forcepw'] = false; sp_add_option('sfprofile', $sfprofile); # avatar options $sfavatars = array(); $sfavatars['sfshowavatars'] = true; $sfavatars['sfavataruploads'] = true; $sfavatars['sfavatarpool'] = false; $sfavatars['sfavatarremote'] = false; $sfavatars['sfgmaxrating'] = 1; $sfavatars['sfavatarsize'] = 50; $sfavatars['sfavatarresize'] = true; $sfavatars['sfavatarresizequality'] = 90; $sfavatars['sfavatarfilesize'] = 10240; $sfavatars['sfavatarpriority'] = array(0, 2, 3, 1, 4, 5); # gravatar, upload, spf, wp, pool, remote sp_add_option('sfavatars', $sfavatars); # RSS stuff $sfrss = array(); $sfrss['sfrsscount'] = 15; $sfrss['sfrsswords'] = 0; $sfrss['sfrsstopicname'] = false; $sfrss['sfrssfeedkey'] = true; sp_add_option('sfrss', $sfrss); sp_add_option('sffiltershortcodes', true); sp_add_option('sfwplistpages', true); # Script in footer sp_add_option('sfscriptfoot', false); # the_content filter options sp_add_option('sfinloop', false); sp_add_option('sfmultiplecontent', true); sp_add_option('sfwpheadbypass', false); sp_add_option('spwptexturize', false); sp_add_option('spheaderspace', 0); # auto update stuff in sfmeta $autoup = array('spjUserUpdate', 'sp_ahah=autoupdate&sfnonce=' . wp_create_nonce('forum-ahah')); sp_add_sfmeta('autoupdate', 'user', $autoup, 1); # Set up unique key $uKey = substr(chr(rand(97, 122)) . md5(time()), 0, 10); sp_add_option('spukey', $uKey); # default theme $theme = array(); $theme['theme'] = 'default'; $theme['style'] = 'default.php'; $theme['color'] = 'silver'; sp_add_option('sp_current_theme', $theme); $theme = array(); $theme['active'] = false; $theme['theme'] = 'default'; $theme['style'] = 'default.php'; $theme['color'] = 'silver'; $theme['usetemplate'] = false; $theme['pagetemplate'] = ''; $theme['notitle'] = true; sp_add_option('sp_mobile_theme', $theme); sp_add_option('sp_tablet_theme', $theme); sp_add_option('account-name', ''); sp_add_option('display-name', ''); sp_add_option('guest-name', ''); # Create smileys Record sp_build_base_smileys(); # set up daily transient clean up cron wp_schedule_event(time(), 'daily', 'sph_transient_cleanup_cron'); # profile tabs spa_new_profile_setup(); # build the list of moderators per forum sp_update_forum_moderators(); # set up hourly stats generation sp_add_option('sp_stats_interval', 3600); wp_schedule_event(time(), 'hourly', 'sph_stats_cron'); # set up weekly news processing wp_schedule_event(time(), 'sp_news_interval', 'sph_news_cron'); sp_add_sfmeta('news', 'news', array('id' => -999.999, 'show' => 0, 'news' => esc_sql(spa_text('Latest Simple Press News will be shown here')))); # create initial last post time stamp sp_add_option('poststamp', current_time('mysql')); # setup mysql search sfmeta values (5.2.0) $s = array(); $v = spdb_select('row', "SHOW VARIABLES LIKE 'ft_min_word_len'"); empty($v->Value) ? $s['min'] = 4 : ($s['min'] = $v->Value); $v = spdb_select('row', "SHOW VARIABLES LIKE 'ft_max_word_len'"); empty($v->Value) ? $s['max'] = 84 : ($s['max'] = $v->Value); sp_add_sfmeta('mysql', 'search', $s, true); # combined css and js cache fles sp_add_option('combinecss', false); sp_add_option('combinejs', false); sp_add_option('post_count_delete', false); $spError = array(); $spError['spErrorLogOff'] = false; $spError['spNoticesOff'] = false; sp_update_option('spErrorOptions', $spError); # new posts/topic cached array sp_add_sfmeta('topic_cache', 'new', '', true); sp_add_option('topic_cache', 200); sp_add_option('floodcontrol', 10); sp_add_option('captcha-value', time()); sp_add_option('editpostdays', 7); sp_create_inspectors(); echo '<h5>' . spa_text('Phase') . ' - ' . $phase . ' - '; spa_etext('Default forum options created') . '</h5>'; break; case 6: # Create sp-resources folder for the current install - does not include themes, plugins or languages $perms = fileperms(SF_STORE_DIR); $owners = stat(SF_STORE_DIR); if ($perms === false) { $perms = 0755; } $basepath = ''; if (is_multisite()) { # construct multisite storage directory structure and create if necessary $basepath .= 'blogs.dir/' . SFBLOGID; if (!file_exists(SF_STORE_DIR . '/' . $basepath)) { @mkdir(SF_STORE_DIR . '/' . $basepath, $perms); } $basepath .= '/files'; if (!file_exists(SF_STORE_DIR . '/' . $basepath)) { @mkdir(SF_STORE_DIR . '/' . $basepath, $perms); } $basepath .= '/'; } $basepath .= 'sp-resources'; if (!file_exists(SF_STORE_DIR . '/' . $basepath)) { @mkdir(SF_STORE_DIR . '/' . $basepath, $perms); } # hive off the basepath for later use - use wp options add_option('sp_storage1', SF_STORE_DIR . '/' . $basepath); # Did it get created? $success = true; if (!file_exists(SF_STORE_DIR . '/' . $basepath)) { $success = false; } sp_add_option('spStorageInstall1', $success); # Is the ownership correct? $ownersgood = false; if ($success) { $newowners = stat(SF_STORE_DIR . '/' . $basepath); if ($newowners['uid'] == $owners['uid'] && $newowners['gid'] == $owners['gid']) { $ownersgood = true; } else { @chown(SF_STORE_DIR . '/' . $basepath, $owners['uid']); @chgrp(SF_STORE_DIR . '/' . $basepath, $owners['gid']); $newowners = stat(SF_STORE_DIR . '/' . $basepath); if ($newowners['uid'] == $owners['uid'] && $newowners['gid'] == $owners['gid']) { $ownersgood = true; } } } sp_add_option('spOwnersInstall1', $ownersgood); $basepath .= '/'; $sfconfig = array(); $sfconfig['avatars'] = $basepath . 'forum-avatars'; $sfconfig['avatar-pool'] = $basepath . 'forum-avatar-pool'; $sfconfig['smileys'] = $basepath . 'forum-smileys'; $sfconfig['ranks'] = $basepath . 'forum-badges'; $sfconfig['custom-icons'] = $basepath . 'forum-custom-icons'; $sfconfig['cache'] = $basepath . 'forum-cache'; # Create sp-resources folder and themes, plugins and languages folders # if not multisite, just add to sp-resource created above # if multisite try to use set up of main blog (id 1) or create in wp-content if main blog does not have SP installed global $wpdb; if (is_multisite()) { $basepath = 'sp-resources'; if (!file_exists(SF_STORE_DIR . '/' . $basepath)) { @mkdir(SF_STORE_DIR . '/' . $basepath, $perms); } # Did it get created? $success = true; if (!file_exists(SF_STORE_DIR . '/' . $basepath)) { $success = false; } sp_add_option('spStorageInstall2', $success); # Is the ownership correct? $ownersgood = false; if ($success) { $newowners = stat(SF_STORE_DIR . '/' . $basepath); if ($newowners['uid'] == $owners['uid'] && $newowners['gid'] == $owners['gid']) { $ownersgood = true; } else { @chown(SF_STORE_DIR . '/' . $basepath, $owners['uid']); @chgrp(SF_STORE_DIR . '/' . $basepath, $owners['gid']); $newowners = stat(SF_STORE_DIR . '/' . $basepath); if ($newowners['uid'] == $owners['uid'] && $newowners['gid'] == $owners['gid']) { $ownersgood = true; } } } sp_add_option('spOwnersInstall2', $ownersgood); add_option('sp_storage2', SF_STORE_DIR . '/' . $basepath); $basepath .= '/'; if ($wpdb->blogid == 1) { $sfconfig['language-sp'] = $basepath . 'forum-language/simple-press'; $sfconfig['language-sp-plugins'] = $basepath . 'forum-language/sp-plugins'; $sfconfig['language-sp-themes'] = $basepath . 'forum-language/sp-themes'; $sfconfig['plugins'] = $basepath . 'forum-plugins'; $sfconfig['themes'] = $basepath . 'forum-themes'; } else { $blog_prefix = $wpdb->get_blog_prefix(1); $row = $wpdb->get_row("SELECT * FROM {$blog_prefix}sfoptions WHERE option_name 'sfconfig'"); if (is_object($row)) { $mainConfig = unserialize($row->option_value); $sfconfig['language-sp'] = $mainConfig['language-sp']; $sfconfig['language-sp-plugins'] = $mainConfig['language-sp-plugins']; $sfconfig['language-sp-themes'] = $mainConfig['language-sp-themes']; $sfconfig['plugins'] = $mainConfig['plugins']; $sfconfig['themes'] = $mainConfig['themes']; } else { $sfconfig['language-sp'] = $basepath . 'forum-language/simple-press'; $sfconfig['language-sp-plugins'] = $basepath . 'forum-language/sp-plugins'; $sfconfig['language-sp-themes'] = $basepath . 'forum-language/sp-themes'; $sfconfig['plugins'] = $basepath . 'forum-plugins'; $sfconfig['themes'] = $basepath . 'forum-themes'; } } } else { add_option('sp_storage2', get_option('sp_storage1')); sp_add_option('spStorageInstall2', true); sp_add_option('spOwnersInstall2', true); $sfconfig['language-sp'] = $basepath . 'forum-language/simple-press'; $sfconfig['language-sp-plugins'] = $basepath . 'forum-language/sp-plugins'; $sfconfig['language-sp-themes'] = $basepath . 'forum-language/sp-themes'; $sfconfig['plugins'] = $basepath . 'forum-plugins'; $sfconfig['themes'] = $basepath . 'forum-themes'; } sp_add_option('sfconfig', $sfconfig); echo '<h5>' . spa_text('Phase') . ' - ' . $phase . ' - '; if ($success) { spa_etext('Storage location created') . '</h5>'; } else { spa_etext('Storage location creation failed') . '</h5>'; } break; case 7: # Move and extract zip install archives # first do stuff that could be in blogs.dir for multisite $successCopy1 = false; $successExtract1 = false; $zipfile = SF_PLUGIN_DIR . '/sp-startup/install/sp-resources-install-part1.zip'; $extract_to = get_option('sp_storage1'); # Copy the zip file if (@copy($zipfile, $extract_to . '/sp-resources-install-part1.zip')) { $successCopy1 = true; # Now try and unzip it require_once ABSPATH . 'wp-admin/includes/class-pclzip.php'; $zipfile = $extract_to . '/sp-resources-install-part1.zip'; $zipfile = str_replace('\\', '/', $zipfile); # sanitize for Win32 installs $zipfile = preg_replace('|/+|', '/', $zipfile); # remove any duplicate slash $extract_to = str_replace('\\', '/', $extract_to); # sanitize for Win32 installs $extract_to = preg_replace('|/+|', '/', $extract_to); # remove any duplicate slash $archive = new PclZip($zipfile); $archive->extract($extract_to); if ($archive->error_code == 0) { $successExtract1 = true; # Lets try and remove the zip as it seems to have worked @unlink($zipfile); } } sp_add_option('spCopyZip1', $successCopy1); sp_add_option('spUnZip1', $successExtract1); # now do stuff that could should not be blogs.dir for multisite $successCopy2 = false; $successExtract2 = false; $zipfile = SF_PLUGIN_DIR . '/sp-startup/install/sp-resources-install-part2.zip'; $extract_to = get_option('sp_storage2'); # Copy the zip file if (@copy($zipfile, $extract_to . '/sp-resources-install-part2.zip')) { $successCopy2 = true; # Now try and unzip it require_once ABSPATH . 'wp-admin/includes/class-pclzip.php'; $zipfile = $extract_to . '/sp-resources-install-part2.zip'; $zipfile = str_replace('\\', '/', $zipfile); # sanitize for Win32 installs $zipfile = preg_replace('|/+|', '/', $zipfile); # remove any duplicate slash $extract_to = str_replace('\\', '/', $extract_to); # sanitize for Win32 installs $extract_to = preg_replace('|/+|', '/', $extract_to); # remove any duplicate slash $archive = new PclZip($zipfile); $archive->extract($extract_to); if ($archive->error_code == 0) { $successExtract2 = true; # Lets try and remove the zip as it seems to have worked @unlink($zipfile); } } sp_add_option('spCopyZip2', $successCopy2); sp_add_option('spUnZip2', $successExtract2); echo '<h5>' . spa_text('Phase') . ' - ' . $phase . ' - '; if ($successCopy1 && $successExtract1 && $successCopy2 && $successExtract2) { spa_etext('Resources created') . '</h5>'; } elseif (!$successCopy1 || !$successCopy2) { spa_etext('Resources file failed to copy') . '</h5>'; } elseif (!$successExtract1 || !$successExtract2) { spa_etext('Resources file failed to unzip'); echo ' - ' . $archive->error_string . '</h5>'; } break; case 8: # CREATE MEMBERS TABLE --------------------------- sp_install_members_table($subphase); echo '<h5>' . spa_text('Phase') . ' - ' . $phase . ' - '; echo spa_text('Members data created for existing users') . ' ' . (($subphase - 1) * 200 + 1) . ' - ' . $subphase * 200 . '</h5>'; break; case 9: # add our caps sp_add_caps(); # grant spf capabilities to installer $user = new WP_User($current_user->ID); $user->add_cap('SPF Manage Options'); $user->add_cap('SPF Manage Forums'); $user->add_cap('SPF Manage User Groups'); $user->add_cap('SPF Manage Permissions'); $user->add_cap('SPF Manage Components'); $user->add_cap('SPF Manage Admins'); $user->add_cap('SPF Manage Users'); $user->add_cap('SPF Manage Profiles'); $user->add_cap('SPF Manage Toolbox'); $user->add_cap('SPF Manage Plugins'); $user->add_cap('SPF Manage Themes'); $user->add_cap('SPF Manage Integration'); sp_update_member_item($current_user->ID, 'admin', 1); # admin your option defaults $sfadminoptions = array(); $sfadminoptions['sfnotify'] = false; $sfadminoptions['notify-edited'] = true; sp_update_member_item($current_user->ID, 'admin_options', $sfadminoptions); echo '<h5>' . spa_text('Phase') . ' - ' . $phase . ' - '; spa_etext('Admin permission data built') . '</h5>'; break; case 10: # UPDATE VERSION/BUILD NUMBERS ------------------------- sp_log_event(SPRELEASE, SPVERSION, SPBUILD); # Lets update permalink and force a rewrite rules flush sp_update_permalink(true); echo '<h5>' . spa_text('Phase') . ' - ' . $phase . ' - '; spa_etext('Version number updated') . '</h5>'; break; case 11: # REPORTS ERRORS IF COPY OR UNZIP FAILED --------------- $sCreate1 = sp_get_option('spStorageInstall1'); $sCreate2 = sp_get_option('spStorageInstall2'); $sOwners1 = sp_get_option('spOwnersInstall1'); $sOwners2 = sp_get_option('spOwnersInstall2'); $sCopy1 = sp_get_option('spCopyZip1'); $sUnzip1 = sp_get_option('spUnZip1'); $sCopy2 = sp_get_option('spCopyZip2'); $sUnzip2 = sp_get_option('spUnZip2'); if ($sCreate1 && $sCreate2 && $sCopy1 && $sUnzip1 && $sCopy2 && $sUnzip2 && $sOwners1 && $sOwners2) { echo '<h5>' . spa_text('The installation has been completed') . '</h5>'; } else { $image = "<img src='" . SF_PLUGIN_URL . "/sp-startup/install/resources/images/important.png' alt='' style='float:left;padding: 5px 5px 20px 0;' />"; echo '<h5>'; spa_etext('YOU WILL NEED TO PERFORM THE FOLLOWING TASKS TO ALLOW SIMPLE:PRESS TO WORK CORRECTLY'); echo '</h5><br />'; if (!$sCreate1) { echo $image . '<p style="margin-top:0">['; spa_etext('Storage location part 1 creation failed'); echo '] - '; echo spa_text('You will need to manually create a required a folder named') . ': ' . get_option('sp_storage1'); echo '</p>'; } else { if (!$sOwners1) { echo $image . '<p>['; spa_etext('Storage location part 1 ownership failed'); echo '] - '; echo spa_text('We were unable to create your folders with the correct server ownership and these will need to be manually changed') . ': ' . get_option('sp_storage1'); echo '</p>'; } } if (!$sCreate2) { echo $image . '<p>['; spa_etext('Storage location part 2 creation failed'); echo '] - '; echo spa_text('You will need to manually create a required a folder named') . ': ' . get_option('sp_storage2'); echo '</p>'; } elseif (!$sOwners2) { echo $image . '<p>['; spa_etext('Storage location part 2 ownership failed'); echo '] - '; echo spa_text('We were unable to create your folders with the correct server ownership and these will need to be manually changed') . ': ' . get_option('sp_storage2'); echo '</p>'; } if (!$sCopy1) { echo $image . '<p>['; spa_etext('Resources part 1 file failed to copy'); echo '] - '; echo spa_text("You will need to manually copy and extract the file '/simple-press/sp-startup/install/sp-resources-install-part1.zip' to the new folder") . ': ' . get_option('sp_storage1'); echo '</p>'; } if (!$sCopy2) { echo $image . '<p>['; spa_etext('Resources part 2 file failed to copy'); echo '] - '; echo spa_text("You will need to manually copy and extract the file '/simple-press/sp-startup/install/sp-resources-install-part2.zip' to the new folder") . ': ' . get_option('sp_storage2'); echo '</p>'; } if (!$sUnzip1) { echo $image . '<p>['; spa_etext('Resources part 2 file failed to unzip'); echo '] - '; echo spa_text("You will need to manually unzip the file 'sp-resources-install-part1.zip' in the new folder") . ': ' . get_option('sp_storage1'); echo '</p>'; } if (!$sUnzip2) { echo $image . '<p>['; spa_etext('Resources part 2 file failed to unzip'); echo '] - '; echo spa_text("You will need to manually unzip the file 'sp-resources-install-part2.zip' in the new folder") . ': ' . get_option('sp_storage2'); echo '</p>'; } } delete_option('sfInstallID'); delete_option('sp_storage1'); delete_option('sp_storage2'); sp_delete_option('spStorageInstall1'); sp_delete_option('spStorageInstall2'); sp_delete_option('spOwnersInstall1'); sp_delete_option('spOwnersInstall2'); sp_delete_option('spCopyZip1'); sp_delete_option('spCopyZip2'); sp_delete_option('spUnZip1'); sp_delete_option('spUnZip2'); break; } }
function sp_go_upgrade($current_version, $current_build) { global $current_user; if (SPVERSION == '5.0.0') { $dostorage = false; if (isset($_POST['dostorage'])) { $dostorage = true; } sp_add_option('V5DoStorage', $dostorage); } update_option('sfInstallID', $current_user->ID); # use wp option table sp_update_option('sfStartUpgrade', $current_build); $phpfile = SFHOMEURL . 'index.php?sp_ahah=upgrade&sfnonce=' . wp_create_nonce('forum-ahah'); $image = SFCOMMONIMAGES . 'working.gif'; $targetbuild = SPBUILD; ?> <div class="wrap"><br /> <div class="updated"> <img class="stayleft" src="<?php echo SFCOMMONIMAGES; ?> sp-mini-logo.png" alt="" title="" /> <h3><?php spa_etext('Simple:Press is being upgraded'); ?> </h3> </div><br /> <div class="wrap sfatag"> <div class="imessage" id="imagezone"></div> </div><br /> <div class="pbar" id="progressbar"></div><br /> <div class="wrap sfatag"> <div class="zmessage" id="errorzone"></div> <div id="finishzone"></div><br /> </div><br /> <div id="debug"> </p><b>Please copy the details below and include them on any support forum question you may have:</b><br /><br /></p> </div> <?php $messages = esc_js(spa_text('Go to Forum Admin')) . '@' . esc_js(spa_text('Upgrade is in progress - please wait')) . '@' . esc_js(spa_text('Upgrade Completed')) . '@' . esc_js(spa_text('Upgrade Aborted')) . '@' . esc_js(spa_text('Go to Forum')); $out = '<script type="text/javascript">' . "\n"; $out .= 'spjPerformUpgrade("' . $phpfile . '", "' . $current_build . '", "' . $targetbuild . '", "' . $current_build . '", "' . $image . '", "' . $messages . '", "' . sp_url() . '");' . "\n"; $out .= '</script>' . "\n"; echo $out; ?> </div> <?php # clear any combined css/js cached files sp_clear_combined_css('all'); sp_clear_combined_css('mobile'); sp_clear_combined_css('tablet'); sp_clear_combined_scripts('desktop'); sp_clear_combined_scripts('mobile'); sp_clear_combined_scripts('tablet'); }
$section = 12446; if ($build < $section) { spdb_query('ALTER TABLE ' . SFFORUMS . ' ADD (topic_icon_pinned varchar(50) default NULL)'); sp_response($section); } $section = 12479; if ($build < $section) { # add starting captcha value sp_add_option('captcha-value', time()); sp_response($section); } $section = 12487; if ($build < $section) { # create a new permission for using smileys sp_add_auth('edit_own_posts_for_time', spa_text('Can edit own posts for time period'), 1, 1, 0, 0, 4); sp_add_option('editpostdays', 7); sp_response($section); } $section = 12493; if ($build < $section) { # Clean out the spInspect array as it has some new members sp_create_inspectors(); sp_response($section); } $section = 12581; if ($build < $section) { # Correct users auths records in case they are incorrect spdb_query("UPDATE " . SFAUTHS . "\n\t\t\t\tSET ignored = 1\n\t\t\t\tWHERE auth_name IN\n\t\t\t\t('can_use_iframes','moderate_posts','delete_any_post','delete_own_posts','delete_topics','view_email','view_own_admin_posts','edit_own_topic_titles','edit_any_topic_titles','edit_own_posts_for_time','edit_own_posts_forever','edit_own_posts_reply','edit_any_post','upload_images','upload_media','upload_files','use_signatures','upload_signatures','upload_avatars','subscribe','watch','rate_posts','use_pm','create_linked_topics','break_linked_topics','reply_own_topics','thank_posts','manage_attachments','hide_posters','post_anonymous','post_as_user','post_multiple','set_topic_expire','create_topic_redirects','change_topic_status');"); spdb_query("UPDATE " . SFAUTHS . "\n\t\t\t\tSET enabling = 1\n\t\t\t\tWHERE auth_name IN\n\t\t\t\t('upload_avatars','use_pm','create_linked_topics','break_linked_topics','change_topic_status');"); spdb_query("UPDATE " . SFAUTHS . "\n\t\t\t\tSET admin_negate = 1\n\t\t\t\tWHERE auth_name IN\n\t\t\t\t('reply_own_topics','view_own_admin_posts');"); spdb_query('UPDATE ' . SFAUTHS . " SET warning='" . spa_text('*** WARNING *** The use of iframes is dangerous. Allowing users to create iframes enables them to launch a potential security threat against your website. Enabling iframes requires your trust in your users. Turn on with care.') . "' WHERE auth_name='can_use_iframes'");
$path = explode($match . '/', $attachment['path']); spdb_query('INSERT INTO ' . SPPOSTATTACHMENTS . " (post_id, topic_id, type, path, filename, size) VALUES ({$post->post_id}, {$post->topic_id}, '" . $attachment['type'] . "', '{$path['1']}', '" . $attachment['file'] . "', " . $attachment['size'] . ")"); } } } } # drop old column in posts spdb_query('ALTER TABLE ' . SFPOSTS . ' DROP attachments'); } # restore cpu time @ini_set($time); sp_response($section); } $section = 11662; if ($build < $section) { sp_add_option('spwptexturize', false); sp_response($section); } $section = 11850; if ($build < $section) { spdb_query('ALTER TABLE ' . SFPOSTS . ' MODIFY guest_name varchar(50) default NULL'); spdb_query('ALTER TABLE ' . SFPOSTS . ' MODIFY guest_email varchar(75) default NULL'); spdb_query('ALTER TABLE ' . SFNOTICES . ' MODIFY guest_email varchar(75) default NULL'); sp_response($section); } $section = 11877; if ($build < $section) { # change post width option setting sp_delete_option('sfpostwidth'); $sfp = array(); $sfp = sp_get_option('sfpostwrap');