function weaver_f_open($fn, $how) { if (function_exists('weaver_fp_open')) { return weaver_fp_open($fn, $how); } global $weaver_wbuff; // 'php://output' if ($fn == 'php://output' || $fn == 'echo') { return 'echo'; } if ($weaver_wbuff != '') { return weaver_f_fail('You can only open one file to write at a time!'); } $weaver_wbuff = ''; // zap the buffer - we only allow one write open at a time. return $fn; }
function weaver_set_current_to_serialized_values($contents) { global $weaver_main_opts_list, $weaver_advanced_opts_list; if (substr($contents, 0, 10) == "TTW-V01.10") { $type = 'theme'; } else { if (substr($contents, 0, 10) == "WVB-V02.00") { $type = 'backup'; } else { return weaver_f_fail(__("Wrong theme file format version", WEAVER_TRANSADMIN)); } } /* simple check for one of ours */ $restore = array(); $restore = unserialize(substr($contents, 10)); if (!$restore) { return weaver_f_fail("Unserialize failed"); } if ($type == 'theme') { weaver_clear_theme_settings(); /* now restore defaults - saved will override changes */ /* now can set the new values from $restore */ foreach ($restore as $rkey => $rval) { if ($rval != '') { if (isset($weaver_main_opts_list[$rkey]) && !$weaver_main_opts_list[$rkey]) { weaver_setopt($rkey, $rval); } else { if (isset($weaver_advanced_opts_list[$rkey]) && !$weaver_advanced_opts_list[$rkey]) { weaver_setopt($rkey, $rval); } } } } } else { if ($type == 'backup') { weaver_clear_cache_settings(); global $weaver_opts_cache; foreach ($restore as $key => $value) { $weaver_opts_cache[$key] = $value; } } } weaver_save_opts('loading theme', true); // OK, now we've saved the options, update them in the DB return true; }