function weaverii_ex_set_current_to_serialized_values($contents)
{
    global $weaverii_opts_cache;
    // need to mess with the cache
    if (substr($contents, 0, 10) == 'W2T-V01.00') {
        $type = 'theme';
    } else {
        if (substr($contents, 0, 10) == 'W2B-V01.00') {
            $type = 'backup';
        } else {
            return weaverii_f_fail(weaverii_t_("Wrong theme file format version"));
        }
    }
    /* simple check for one of ours */
    $restore = array();
    $restore = unserialize(substr($contents, 10));
    if (!$restore) {
        return weaverii_f_fail("Unserialize failed - file likely corrupt.");
    }
    $version = weaverii_getopt('wii_version_id');
    // get something to force load
    if ($type == 'theme') {
        // need to clear some settings
        // first, pickup the per-site settings that aren't theme related...
        $new_cache = array();
        foreach ($weaverii_opts_cache as $key => $val) {
            if ($key[0] == '_') {
                // these are non-theme specific settings
                $new_cache[$key] = $val;
            }
            // keep
        }
        $opts = $restore['weaverii_base'];
        // fetch base opts
        weaverii_delete_all_options();
        foreach ($opts as $key => $val) {
            if ($key[0] != '_') {
                weaverii_setopt($key, $val, false);
            }
            // overwrite with saved theme values
        }
        foreach ($new_cache as $key => $val) {
            // set the values we need to keep
            weaverii_setopt($key, $val, false);
        }
    } else {
        if ($type == 'backup') {
            weaverii_delete_all_options();
            $opts = $restore['weaverii_base'];
            // fetch base opts
            foreach ($opts as $key => $val) {
                weaverii_setopt($key, $val, false);
                // overwrite with saved values
            }
            global $weaverii_pro_opts;
            $weaverii_pro_opts = false;
            $weaverii_pro_opts = $restore['weaverii_pro'];
            weaverii_wpupdate_option('weaverii_pro', $weaverii_pro_opts);
        }
    }
    weaverii_setopt('wii_version_id', $version);
    // keep version, force save of db
    weaverii_save_opts('loading theme');
    // OK, now we've saved the options, update them in the DB
    return true;
}
Exemplo n.º 2
0
function weaverii_update_options($id)
{
    global $weaverii_opts_cache;
    if (!$weaverii_opts_cache) {
        $weaverii_opts_cache = get_option(apply_filters('weaver_options', 'weaverii_settings'), array());
    }
    weaverii_wpupdate_option('weaverii_settings', $weaverii_opts_cache, 'update_options:' . $id);
}
Exemplo n.º 3
0
function weaverii_settings_db_restore($auto = '')
{
    if (!current_user_can('edit_theme_options')) {
        return;
    }
    global $weaverii_opts_cache;
    $saved = get_option(apply_filters('weaver_options', 'weaverii_settings_backup' . $auto), array());
    if (!empty($saved)) {
        $weaverii_opts_cache = $saved;
        weaverii_wpupdate_option('weaverii_settings', $weaverii_opts_cache, 'restore_mytheme');
    }
    weaveriip_restore_opts_backup($auto);
}
Exemplo n.º 4
0
function weaveriip_restore_opts_backup($auto = '')
{
    global $weaverii_pro_opts;
    $saved = get_option('weaverii_pro_backup' . $auto, array());
    if (!empty($saved)) {
        $weaver_pro_opts = $saved;
        weaverii_wpupdate_option(apply_filters('weaver_options', 'weaverii_pro'), $weaver_pro_opts, 'restore_opts_backup');
    }
}
function weaverii_process_options_admin_pro()
{
    if (weaverii_submitted('backup_settings')) {
        $name = weaverii_savebackup();
        if ($name !== false) {
            weaverii_save_msg(weaverii_t_('All current main and advanced options backed up in:') . ' "' . $name . '.w2b"');
        } else {
            weaverii_save_msg(weaverii_t_('ERROR: Saving backup failed.'));
        }
    }
    if (weaverii_submitted('filesavetheme')) {
        $base = sanitize_file_name($_POST['savethemename']);
        if (weaverii_dev_mode()) {
            weaverii_setopt('wii_hide_old_weaver', 0);
        }
        $temp_url = weaverii_write_current_theme($base);
        if ($temp_url == '') {
            weaverii_save_msg(weaverii_t_('Invalid name supplied to save theme to file.'));
        } else {
            weaverii_save_msg(weaverii_t_("All current main and advanced options saved in ") . $temp_url);
        }
    }
    if (weaverii_submitted('restoretheme')) {
        $base = $_POST['wii_restorename'];
        $valid = validate_file($base);
        // make sure an ok file name
        $fn = weaverii_f_uploads_base_dir() . 'weaverii-subthemes/' . $base;
        if ($valid < 1 && weaverii_upload_theme($fn)) {
            $t = weaverii_getopt('wii_themename');
            if ($t == '') {
                $t = weaverii_getopt('wii_subtheme');
            }
            if ($t == '') {
                $t = 'Antique Ivory';
            }
            /* did we save a theme? */
            weaverii_setopt('wii_theme_filename', 'custom');
            // we have a custom theme now...
            weaverii_save_msg(weaverii_t_("Weaver II theme restored from file: ") . $t);
        } else {
            weaverii_save_msg('<em style="color:red;">' . weaverii_t_('INVALID FILE NAME PROVIDED - Try Again') . "({$fn})" . '</em>');
        }
    }
    if (weaverii_submitted('save_mobiletheme')) {
        weaverii_save_msg(weaverii_t_("Current settings saved in alternate Mobile View database entry."));
        $weaverii_opts = get_option(apply_filters('weaver_options', 'weaverii_settings'), array());
        $weaverii_opts['_wii_mobile_alt_theme'] = 'saved_mobile';
        // force  these two
        $weaverii_opts['_wii_sim_mobile'] = false;
        $weaverii_opts['_wii_inline_style'] = 'on';
        weaverii_wpupdate_option('weaverii_settings_mobile', $weaverii_opts, 'save_mobiletheme');
        $weaverii_pro_opts = get_option(apply_filters('weaver_options', 'weaverii_pro'), array());
        weaverii_wpupdate_option('weaverii_pro_mobile', $weaverii_pro_opts, 'save_mobile_theme');
    }
    if (weaverii_submitted('renametheme')) {
        $name = isset($_POST['wii_themename']) ? $_POST['wii_themename'] : '';
        $desc = isset($_POST['wii_theme_description']) ? $_POST['wii_theme_description'] : '';
        if ($name) {
            weaverii_setopt('wii_themename', $name);
        }
        if ($desc) {
            weaverii_setopt('wii_theme_description', $desc);
        }
    }
    if (weaverii_submitted('deletetheme')) {
        $myFile = isset($_POST['selectName']) ? $_POST['selectName'] : '';
        $valid = validate_file($myFile);
        if ($valid < 1 && $myFile != "None") {
            weaverii_f_delete(weaverii_f_uploads_base_dir() . 'weaverii-subthemes/' . $myFile);
            echo '<div style="background-color: rgb(255, 251, 204);" id="message" class="updated fade"><p>File: <strong>' . $myFile . '</strong> has been deleted.</p></div>';
        } else {
            echo '<div style="background-color: rgb(255, 251, 204);" id="message" class="updated fade"><p>File: <strong>' . $myFile . '</strong> invalid file name, not deleted.</p></div>';
        }
    }
}