本文整理汇总了PHP中DataHandler::save方法的典型用法代码示例。如果您正苦于以下问题:PHP DataHandler::save方法的具体用法?PHP DataHandler::save怎么用?PHP DataHandler::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataHandler
的用法示例。
在下文中一共展示了DataHandler::save方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: lilina_version_check
/**
* Checks to see if a new version of Lilina is available
* @author WordPress
*/
function lilina_version_check()
{
if (strpos($_SERVER['REQUEST_URI'], 'install.php') !== false || defined('LILINA_INSTALLING') || !is_admin()) {
return;
}
$lilina_version = LILINA_CORE_VERSION;
$php_version = phpversion();
// We need this for unique identification of installations, but we take the hash of it
$id = sha1(get_option('baseurl'));
$data = new DataHandler();
$current = $data->load('core-update-check.data');
if ($current !== null) {
$current = unserialize($current);
}
$locale = get_option('locale');
if (isset($current->last_checked) && 43200 > time() - $current->last_checked && $current->version_checked == $lilina_version) {
return false;
}
$new_option = '';
$new_option->last_checked = time();
// this gets set whether we get a response or not, so if something is down or misconfigured it won't delay the page load for more than 3 seconds, twice a day
$new_option->version_checked = $lilina_version;
try {
$headers = apply_filters('update_http_headers', array('X-Install-ID' => $id));
$request = new HTTPRequest('', 2);
$response = $request->get("http://api.getlilina.org/core/version-check/1.2/?version={$lilina_version}&php={$php_version}&locale={$locale}", $headers);
} catch (Exception $e) {
$response = (object) array('success' => false);
}
if (!$response->success) {
// Save it anyway
$data->save('core-update-check.data', serialize($new_option));
return false;
}
$body = trim($response->body);
$body = str_replace(array("\r\n", "\r"), "\n", $body);
$returns = explode("\n", $body);
$new_option->response = $returns[0];
if (isset($returns[1])) {
$new_option->url = $returns[1];
}
if (isset($returns[2])) {
$new_option->download = $returns[2];
}
if (isset($returns[3])) {
$new_option->version = $returns[3];
}
$data->save('core-update-check.data', serialize($new_option));
return $new_option;
}
示例2: lilina_version_check
/**
* Checks to see if a new version of Lilina is available
* @author WordPress
*/
function lilina_version_check()
{
if (strpos($_SERVER['PHP_SELF'], 'install.php') !== false || defined('LILINA_INSTALLING') || !is_admin()) {
return;
}
global $lilina;
//Just to make sure
require_once LILINA_INCPATH . '/core/version.php';
require_once LILINA_INCPATH . '/core/conf.php';
$lilina_version = $lilina['core-sys']['version'];
$php_version = phpversion();
$data = new DataHandler();
$current = $data->load('core-update-check.data');
if ($current !== null) {
$current = unserialize($current);
}
$locale = get_option('locale');
if (isset($current->last_checked) && 43200 > time() - $current->last_checked && $current->version_checked == $lilina_version) {
return false;
}
$new_option = '';
$new_option->last_checked = time();
// this gets set whether we get a response or not, so if something is down or misconfigured it won't delay the page load for more than 3 seconds, twice a day
$new_option->version_checked = $lilina_version;
$headers = apply_filters('update_http_headers', array());
require_once LILINA_INCPATH . '/contrib/simplepie/simplepie.inc';
$request = new SimplePie_File("http://api.getlilina.org/version-check/1.1/lilina-core/?version={$lilina_version}&php={$php_version}&locale={$locale}", 2, 0, $headers, "Lilina/{$lilina_version}; " . get_option('baseurl'));
if (!$request->success) {
// Save it anyway
$data->save('core-update-check.data', serialize($new_option));
return false;
}
$body = trim($request->body);
$body = str_replace(array("\r\n", "\r"), "\n", $body);
$returns = explode("\n", $body);
$new_option->response = $returns[0];
if (isset($returns[1])) {
$new_option->url = $returns[1];
}
if (isset($returns[2])) {
$new_option->version = $returns[2];
}
if (isset($returns[3])) {
$new_option->download = $returns[3];
}
$data->save('core-update-check.data', serialize($new_option));
return $new_option;
}
示例3: deactivate_plugin
/**
* Deactivate a plugin
*
* @since 1.0
*
* @param string $plugin_file Relative path to plugin
* @return bool Whether plugin was deactivated
*/
function deactivate_plugin($plugin_file)
{
global $current_plugins;
if (!isset($current_plugins[md5($plugin_file)])) {
return false;
}
if (!validate_plugin($plugin_file)) {
return false;
}
unset($current_plugins[md5($plugin_file)]);
$data = new DataHandler();
$data->save('plugins.data', serialize($current_plugins));
return true;
}
示例4: save_feeds
/**
* Save feeds to a config file
*
* Serializes, then base 64 encodes.
* @param array $feeds Data to save to config. If not specified, taken from global $data variable.
* @return bool True if feeds were successfully saved, false otherwise
*/
function save_feeds($feeds = null)
{
if (empty($feeds)) {
global $data;
$feeds = $data;
}
$file = new DataHandler(LILINA_CONTENT_DIR . '/system/config/');
return $file->save('feeds.data', base64_encode(serialize($feeds)));
}
示例5: discover_favicon
/**
* Find the feed's icon
*
* @param SimplePie $feed SimplePie object to retrieve logo for
* @return string URL to feed icon
*/
protected static function discover_favicon($feed, $id)
{
if ($return = $feed->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon')) {
$favicon = SimplePie_Misc::absolutize_url($return[0]['data'], $feed->get_base($return[0]));
} elseif (($url = $feed->get_link()) !== null && preg_match('/^http(s)?:\\/\\//i', $url)) {
$filename = $id . '.ico';
$favicon = SimplePie_Misc::absolutize_url('/favicon.ico', $url);
} else {
return false;
}
$cache = new DataHandler(get_option('cachedir'));
$request = new HTTPRequest();
$file = $request->get($favicon, array('X-Forwarded-For' => $_SERVER['REMOTE_ADDR']));
if ($file->success && strlen($file->body) > 0) {
$sniffer = new $feed->content_type_sniffer_class($file);
if (substr($sniffer->get_type(), 0, 6) === 'image/') {
$body = array('type' => $sniffer->get_type(), 'body' => $file->body);
return $cache->save($filename, serialize($body));
} else {
return false;
}
}
return false;
}
示例6: save_options
/**
* Save options to options.data
*/
function save_options()
{
global $options;
$data = new DataHandler(LILINA_CONTENT_DIR . '/system/config/');
return $data->save('options.data', serialize($options));
}