/** * Registers new blog url in url=>blog mapfile */ function w3_blogmap_register_new_item($blog_home_url, $config) { if (!isset($GLOBALS['current_blog'])) { return false; } $filename = w3_blogmap_filename($blog_home_url); if (!@file_exists($filename)) { $blog_ids = array(); } else { $data = @file_get_contents($filename); $blog_ids = @eval($data); if (!is_array($blog_ids)) { $blog_ids = array(); } } if (isset($blog_ids[$blog_home_url])) { return false; } $data = $config->get_boolean('common.force_master') ? 'm' : 'c'; $blog_id = $GLOBALS['current_blog']->blog_id; $blog_ids_strings[] = "'" . $blog_home_url . "' => '" . $data . $blog_id . "'"; foreach ($blog_ids as $key => $value) { $blog_ids_strings[] = "'" . $key . "' => '" . $value . "'"; } $data = sprintf('return array(%s);', implode(', ', $blog_ids_strings)); try { w3_file_put_contents_atomic($filename, $data); } catch (Exception $ex) { return false; } return true; }
/** * Saves modified config */ function write($filename) { $config = "<?php\r\n\r\nreturn array(\r\n"; foreach ($this->data as $key => $value) { $config .= $this->_write_item(1, $key, $value); } $config .= ");"; w3_require_once(W3TC_INC_DIR . '/functions/file.php'); w3_file_put_contents_atomic($filename, $config); }
/** * Saves modified config */ function write($filename, $serialize = false) { w3_require_once(W3TC_INC_DIR . '/functions/file.php'); if ($serialize) { $config = '<?php exit;?>' . serialize($this->data); } else { $config = w3tc_format_data_as_settings_file($this->data); } w3_file_put_contents_atomic($filename, $config); }