function spa_save_global_data()
{
    global $wp_roles;
    check_admin_referer('forum-adminform_global', 'forum-adminform_global');
    $mess = spa_text('Options updated');
    spa_update_check_option('sflockdown');
    # auto update
    $sfauto = '';
    $sfauto['sfautoupdate'] = isset($_POST['sfautoupdate']);
    $sfauto['sfautotime'] = sp_esc_int($_POST['sfautotime']);
    if (empty($sfauto['sfautotime']) || $sfauto['sfautotime'] == 0) {
        $sfauto['sfautotime'] = 300;
    }
    sp_update_option('sfauto', $sfauto);
    $sfrss = array();
    $sfrss['sfrsscount'] = sp_esc_int($_POST['sfrsscount']);
    $sfrss['sfrsswords'] = sp_esc_int($_POST['sfrsswords']);
    $sfrss['sfrssfeedkey'] = isset($_POST['sfrssfeedkey']);
    $sfrss['sfrsstopicname'] = isset($_POST['sfrsstopicname']);
    sp_update_option('sfrss', $sfrss);
    $sfblock = array();
    $sfblock['blockadmin'] = isset($_POST['blockadmin']);
    $sfblock['blockprofile'] = isset($_POST['blockprofile']);
    $sfblock['blockredirect'] = sp_filter_save_cleanurl($_POST['blockredirect']);
    if ($sfblock['blockadmin']) {
        $sfblock['blockroles'] = array();
        $roles = array_keys($wp_roles->role_names);
        if ($roles) {
            foreach ($roles as $index => $role) {
                $sfblock['blockroles'][$role] = isset($_POST['role-' . $index]);
            }
            # always allow admin
            $sfblock['blockroles']['administrator'] = true;
        }
    }
    sp_update_option('sfblockadmin', $sfblock);
    sp_update_option('speditor', sp_esc_int($_POST['editor']));
    $spError = array();
    $spError['spErrorLogOff'] = isset($_POST['errorlog']);
    $spError['spNoticesOff'] = isset($_POST['notices']);
    sp_update_option('spErrorOptions', $spError);
    $old = sp_get_option('combinecss');
    sp_update_option('combinecss', isset($_POST['combinecss']));
    if (!$old && isset($_POST['combinecss'])) {
        sp_clear_combined_css('all');
        sp_clear_combined_css('mobile');
        sp_clear_combined_css('tablet');
    }
    $old = sp_get_option('combinejs');
    sp_update_option('combinejs', isset($_POST['combinejs']));
    if (!$old && isset($_POST['combinejs'])) {
        sp_clear_combined_scripts();
    }
    sp_update_option('topic_cache', sp_esc_int($_POST['topiccache']));
    sp_update_option('floodcontrol', max(sp_esc_int($_POST['floodcontrol']), 0));
    do_action('sph_option_global_save');
    return $mess;
}
function sp_response($section, $die = true, $status = 'success', $error = '')
{
    global $wpdb;
    $response = array('status' => '', 'type' => '', 'section' => '', 'response' => '', 'error' => '');
    # log the build section and status in the response
    echo "Build upgrade section {$section} executing.  Status: {$status} <br />";
    if ($status == 'error' && !empty($error)) {
        echo "Error: {$error} <br />";
    }
    # build the response
    $response['status'] = $status;
    $response['type'] = 'upgrade';
    $response['section'] = $section;
    $response['error'] = $error;
    $response['response'] = ob_get_contents();
    # save as log meta data if table exists! (Need to check if installed yet sadly)
    $go = $wpdb->get_var("SHOW TABLES LIKE '" . SFLOGMETA . "'");
    if ($go) {
        $sql = '
			INSERT INTO ' . SFLOGMETA . " (version, log_data)\n\t\t\tVALUES (\n\t\t\t'" . SPVERSION . "',\n\t\t\t'" . serialize($response) . "')";
        spdb_query($sql);
    }
    ob_end_clean();
    # send the response (mark with tags so we can extract only the response)
    echo '%%%marker%%%';
    print json_encode($response);
    echo '%%%marker%%%';
    # and if this is the last update in build finish off...
    if (SPBUILD == $section) {
        # let plugins know
        do_action('sph_upgrade_done', SPBUILD);
        # Finished Upgrades ===============================================================================
        sp_log_event(SPRELEASE, SPVERSION, SPBUILD);
        sp_update_permalink(true);
        delete_option('sfInstallID');
        # use wp option table
        # and some final cleanuop tasks
        sp_reset_auths();
        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');
        sp_flush_cache('all');
        sp_reset_member_plugindata();
    }
    if ($die) {
        die;
    }
}
Exemplo n.º 3
0
function spa_save_housekeeping_data()
{
    check_admin_referer('forum-adminform_housekeeping', 'forum-adminform_housekeeping');
    $mess = '';
    if (isset($_POST['rebuild-fidx'])) {
        $forumid = $_POST['forum_id'];
        if (is_numeric($forumid)) {
            $topics = spdb_table(SFTOPICS, "forum_id={$forumid}");
            if ($topics) {
                include_once SF_PLUGIN_DIR . '/forum/database/sp-db-management.php';
                foreach ($topics as $topic) {
                    sp_build_post_index($topic->topic_id);
                }
                # after reubuilding post indexes, rebuild the forum indexes
                sp_build_forum_index($forumid);
                do_action('sph_toolbox_housekeeping_forum_index');
                $mess = spa_text('Forum indexes rebuilt');
            } else {
                $mess = spa_text('Forum index rebuild failed - no topics in selected forum');
            }
        } else {
            $mess = spa_text('Forum index rebuild failed - no forum selected');
        }
    }
    if (isset($_POST['transient-cleanup'])) {
        include_once SF_PLUGIN_DIR . '/forum/database/sp-db-management.php';
        sp_transient_cleanup();
        do_action('sph_toolbox_housekeeping_transient');
        $mess = spa_text('WP transients cleaned');
    }
    if (isset($_POST['clean-newposts'])) {
        $days = isset($_POST['sfdays']) ? max(sp_esc_int($_POST['sfdays']), 0) : 30;
        $users = spdb_select('col', "SELECT user_id FROM " . SFMEMBERS . " WHERE lastvisit < DATE_SUB(CURDATE(), INTERVAL " . $days . " DAY)");
        if ($users) {
            foreach ($users as $user) {
                spdb_query('UPDATE ' . SFMEMBERS . " SET newposts='a:1:{i:0;i:0;}' WHERE user_id={$user}");
            }
        }
        do_action('sph_toolbox_housekeeping_newpost');
        $mess = spa_text('New posts lists cleaned');
    }
    if (isset($_POST['postcount-cleanup'])) {
        spdb_query('UPDATE ' . SFMEMBERS . ' SET posts = (SELECT COUNT(*) FROM ' . SFPOSTS . ' WHERE ' . SFPOSTS . '.user_id = ' . SFMEMBERS . '.user_id)');
        # force stats to update
        do_action('sph_stats_cron');
        do_action('sph_toolbox_housekeeping_postcount');
        $mess = spa_text('User post counts calculated');
    }
    if (isset($_POST['reset-tabs'])) {
        # clear out current tabs
        $tabs = sp_get_sfmeta('profile', 'tabs');
        sp_delete_sfmeta($tabs[0]['meta_id']);
        # start adding new ones
        spa_new_profile_setup();
        do_action('sph_toolbox_housekeeping_profile_tabs');
        $mess = spa_text('Profile tabs reset');
    }
    if (isset($_POST['reset-auths'])) {
        sp_reset_auths();
        do_action('sph_toolbox_housekeeping_auths');
        $mess = spa_text('Auths caches cleaned');
    }
    if (isset($_POST['reset-plugin-data'])) {
        sp_reset_member_plugindata();
        do_action('sph_toolbox_housekeeping_plugindata');
        $mess = spa_text('Users Plugin Data reset');
    }
    if (isset($_POST['reset-combinedcss'])) {
        sp_clear_combined_css('all');
        sp_clear_combined_css('mobile');
        sp_clear_combined_css('tablet');
        do_action('sph_toolbox_housekeeping_ccombined_css');
        $mess = spa_text('Combined CSS cache file removed');
    }
    if (isset($_POST['reset-combinedjs'])) {
        sp_clear_combined_scripts('desktop');
        sp_clear_combined_scripts('mobile');
        sp_clear_combined_scripts('tablet');
        do_action('sph_toolbox_housekeeping_combined_js');
        $mess = spa_text('Combined scripts cache files removed');
    }
    if (isset($_POST['flushcache'])) {
        sp_flush_cache('all');
        do_action('sph_toolbox_housekeeping_flush_cache');
        $mess = spa_text('General cache flushed');
    }
    do_action('sph_toolbox_housekeeping_save');
    return $mess;
}
function sp_go_network_upgrade($current_version, $current_build)
{
    global $current_user;
    ?>
	<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 upgrading the Network.');
    ?>
</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>
	</div>
<?php 
    # get list of network sites
    $sites = wp_get_sites();
    # loop through all blogs and upgrade ones with active simple:press
    foreach ($sites as $site) {
        # switch to network site and see if simple:press is active
        switch_to_blog($site['blog_id']);
        global $wpdb;
        $installed = spdb_select('set', 'SELECT option_id FROM ' . $wpdb->prefix . "sfoptions WHERE option_name='sfversion'");
        if ($installed) {
            $phpfile = SFHOMEURL . 'index.php?sp_ahah=upgrade&sfnonce=' . wp_create_nonce('forum-ahah') . '&sfnetworkid=' . $site['blog_id'];
            $image = SFCOMMONIMAGES . 'working.gif';
            $targetbuild = SPBUILD;
            update_option('sfInstallID', $current_user->ID);
            # use wp option table
            # save the build info
            $out = spa_text('Upgrading Network Site ID') . ': ' . $site['blog_id'] . '<br />';
            sp_update_option('sfStartUpgrade', $current_build);
            # upgrade the network site
            $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;
            # 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');
        }
        restore_current_blog();
    }
}
Exemplo n.º 5
0
$section = 10628;
if ($build < $section) {
    # add category of error to error log
    spdb_query('TRUNCATE ' . SFERRORLOG);
    spdb_query('ALTER TABLE ' . SFERRORLOG . " ADD (error_cat varchar(13) NOT NULL default 'spaErrOther')");
    spdb_query('ALTER TABLE ' . SFERRORLOG . ' ADD (keycheck varchar(45))');
    sp_response($section);
}
$section = 10633;
if ($build < $section) {
    # create cache storage location
    sp_create_cache_location();
    sp_clear_combined_css('all');
    sp_clear_combined_css('mobile');
    sp_clear_combined_css('tablet');
    sp_clear_combined_scripts();
    sp_response($section);
}
$section = 10693;
if ($build < $section) {
    # add count of error to error log
    spdb_query('ALTER TABLE ' . SFERRORLOG . ' ADD (error_count tinyint)');
    sp_response($section);
}
$section = 10707;
if ($build < $section) {
    # force rebuild of auths cache since users global auths may be wrong
    sp_reset_auths();
    sp_response($section);
}
$section = 10715;