Ejemplo n.º 1
0
/**
 * upgrade() - Run upgrade processes on supplied data
 *
 * {{@internal Missing Long Description}}}
 */
function upgrade()
{
    global $lilina;
    //require_once(LILINA_INCPATH . '/core/plugin-functions.php');
    require_once LILINA_INCPATH . '/core/feed-functions.php';
    require_once LILINA_INCPATH . '/core/version.php';
    require_once LILINA_INCPATH . '/core/misc-functions.php';
    /** Rename possible old files */
    if (@file_exists(LILINA_PATH . '/.myfeeds.data')) {
        rename(LILINA_PATH . '/.myfeeds.data', LILINA_PATH . '/content/system/config/feeds.data');
    } elseif (@file_exists(LILINA_PATH . '/conf/.myfeeds.data')) {
        rename(LILINA_PATH . '/conf/.myfeeds.data', LILINA_PATH . '/content/system/config/feeds.data');
    } elseif (@file_exists(LILINA_PATH . '/conf/.feeds.data')) {
        rename(LILINA_PATH . '/conf/.feeds.data', LILINA_PATH . '/content/system/config/feeds.data');
    } elseif (@file_exists(LILINA_PATH . '/conf/feeds.data')) {
        rename(LILINA_PATH . '/conf/feeds.data', LILINA_PATH . '/content/system/config/feeds.data');
    }
    if (@file_exists(LILINA_PATH . '/conf/settings.php')) {
        rename(LILINA_PATH . '/conf/settings.php', LILINA_PATH . '/content/system/config/settings.php');
    }
    require_once LILINA_PATH . '/inc/core/conf.php';
    /*
    if(@file_exists(LILINA_PATH . '/content/system/config/feeds.data')) {
    	$feeds = file_get_contents(LILINA_PATH . '/content/system/config/feeds.data');
    	$feeds = unserialize( base64_decode($feeds) );
    
    	/** Are we pre-versioned? * /
    	if(!isset($feeds['version'])){
    
    		/** Is this 0.7? * /
    		if(!is_array($feeds['feeds'][0])) {
    			/** 1 dimensional array, each value is a feed URL string * /
    			foreach($feeds['feeds'] as $new_feed) {
    				Feeds::get_instance()->add($new_feed);
    			}
    		}
    
    		/** We must be in between 0.7 and r147, when we started versioning * /
    		elseif(!isset($feeds['feeds'][0]['url'])) {
    			foreach($feeds['feeds'] as $new_feed) {
    				Feeds::get_instance()->add($new_feed['feed'], $new_feed['name']);
    			}
    		}
    
    		/** The feeds are up to date, but we don't have a version * /
    		else {
    		}
    
    	}
    	elseif($feeds['version'] != $lilina['feed-storage']['version']) {
    		/** Note the lack of breaks here, this means the cases cascade * /
    		switch(true) {
    			case $feeds['version'] < 147:
    				/** We had a b0rked upgrader, so we need to make sure everything is okay * /
    				foreach($feeds['feeds'] as $this_feed) {
    					
    				}
    			case $feeds['version'] < 237:
    				/** We moved stuff around this version, but we've handled that above. * /
    		}
    	}
    	else {
    	}
    	global $data;
    	$data = $feeds;
    	$data['version'] = $lilina['feed-storage']['version'];
    	save_feeds();
    } //end file_exists()
    */
    /** Just in case... */
    unset($BASEURL);
    require LILINA_PATH . '/content/system/config/settings.php';
    if (isset($BASEURL) && !empty($BASEURL)) {
        // 0.7 or below
        $raw_php = "<?php\n// What you want to call your Lilina installation\n\$settings['sitename'] = '{$SITETITLE}';\n\n// The URL to your server\n\$settings['baseurl'] = '{$BASEURL}';\n\n// Username and password to log into the administration panel\n// 'pass' is MD5ed\n\$settings['auth'] = array(\n\t\t\t\t\t\t\t'user' => '{$USERNAME}',\n\t\t\t\t\t\t\t'pass' => '" . md5($PASSWORD) . "'\n\t\t\t\t\t\t\t);\n\n// All the enabled plugins, stored in a serialized string\n\$settings['enabled_plugins'] = '';\n\n// Version of these settings; don't change this\n\$settings['settings_version'] = " . $lilina['settings-storage']['version'] . ";\n?>";
        if (!($settings_file = @fopen(LILINA_PATH . '/content/system/config/settings.php', 'w+')) || !is_resource($settings_file)) {
            lilina_nice_die('<p>Failed to upgrade settings: Saving content/system/config/settings.php failed</p>', 'Upgrade failed');
        }
        fputs($settings_file, $raw_php);
        fclose($settings_file);
    } elseif (!isset($settings['settings_version'])) {
        // Between 0.7 and r147
        // Fine to just use existing settings
        $raw_php = file_get_contents(LILINA_PATH . '/content/system/config/settings.php');
        $raw_php = str_replace('?>', "// Version of these settings; don't change this\n" . "\$settings['settings_version'] = " . $lilina['settings-storage']['version'] . ";\n?>", $raw_php);
        if (!($settings_file = @fopen(LILINA_PATH . '/conf/settings.php', 'w+')) || !is_resource($settings_file)) {
            lilina_nice_die('<p>Failed to upgrade settings: Saving content/system/config/settings.php failed</p>', 'Upgrade failed');
        }
        fputs($settings_file, $raw_php);
        fclose($settings_file);
    } elseif ($settings['settings_version'] != $lilina['settings-storage']['version']) {
        /** Note the lack of breaks here, this means the cases cascade */
        switch (true) {
            case $settings['settings_version'] < 237:
                /** We moved stuff around this version, but we've handled that above. */
            /** We moved stuff around this version, but we've handled that above. */
            case $settings['settings_version'] < 297:
                new_options_297();
            case $settings['settings_version'] < 302:
                new_options_302();
            case $settings['settings_version'] < 339:
                new_options_339();
            case $settings['settings_version'] < 368:
                new_options_368();
            case $settings['settings_version'] < 480:
                new_options_368();
        }
        $raw_php = file_get_contents(LILINA_PATH . '/content/system/config/settings.php');
        $raw_php = str_replace("\$settings['settings_version'] = " . $settings['settings_version'] . ";", "\$settings['settings_version'] = " . $lilina['settings-storage']['version'] . ";", $raw_php);
        if (!($settings_file = @fopen(LILINA_PATH . '/content/system/config/settings.php', 'w+')) || !is_resource($settings_file)) {
            lilina_nice_die('<p>Failed to upgrade settings: Saving content/system/config/settings.php failed</p>', 'Upgrade failed');
        }
        fputs($settings_file, $raw_php);
        fclose($settings_file);
        require_once LILINA_INCPATH . '/core/class-datahandler.php';
        if (!save_options()) {
            lilina_nice_die('<p>Failed to upgrade settings: Saving content/system/config/options.data failed</p>', 'Upgrade failed');
        }
    }
    $string = '';
    if (count(MessageHandler::get()) === 0) {
        lilina_nice_die('<p>Your installation has been upgraded successfully. Now, <a href="index.php">get back to reading!</a></p>', 'Upgrade Successful');
        return;
    } else {
        $string .= '<p>Your installation has <strong>not</strong> been upgraded successfully. Here\'s the error:</p><ul><li>';
    }
    lilina_nice_die($string . implode('</li><li>', MessageHandler::get()) . '</li></ul>', 'Upgrade failed');
}
Ejemplo n.º 2
0
function default_options()
{
    new_options_297();
    new_options_302();
    new_options_339();
    new_options_368();
}