예제 #1
0
/**
 * 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
0
/**
 * 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
0
/**
 * 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
0
/**
 * 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
0
 /**
  * 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
0
/**
 * 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));
}