/**
     * Lilina installer
     *
     * Installs Lilina after going through many complicated checks
     *
     * @param string $sitename Name of the site
     * @param string $username Initial username of the admin user
     * @param string $password Initial password of the admin user
     * @return bool True if the installer succeeded, false otherwise
     */
    public function install($sitename, $username, $password)
    {
        require_once LILINA_INCPATH . '/core/version.php';
        $settings = $this->generate_default_settings($sitename, $username, $password);
        if (!is_writable(LILINA_PATH . '/content/system/config/') || !($settings_file = @fopen(LILINA_PATH . '/content/system/config/settings.php', 'w+'))) {
            $this->file_error_notice(LILINA_PATH . '/content/system/config/settings.php', $sitename, $username, $password);
            return false;
        }
        fputs($settings_file, $settings);
        fclose($settings_file);
        if (file_exists(LILINA_PATH . '/content/system/config/feeds.data')) {
            echo "<p>Using existing feeds data</p>\n";
        } else {
            $feeds_file = new DataHandler(LILINA_CONTENT_DIR . '/system/config/');
            $feeds_file = $feeds_file->save('feeds.json', json_encode(array()));
            if (!$feeds_file) {
                $this->file_error_notice(LILINA_PATH . '/content/system/config/feeds.json', $sitename, $username, $password);
                return false;
            }
        }
        /** Make sure it's writable now */
        if (!$this->make_writable(LILINA_PATH . '/content/system/config/feeds.json')) {
            echo "<p>Couldn't make <code>content/system/config/feeds.json</code> writable. Please ensure you make it writable yourself</p>\n";
        }
        default_options();
        Options::lazy_update('sitename', $sitename);
        if (!Options::save()) {
            $this->file_error_notice(LILINA_PATH . '/content/system/config/options.data', $sitename, $username, $password);
            return false;
        }
        $user = new User($username, $password);
        $user->identify();
        ?>
	<h1 id="title">Installation Complete!</h1>
	<p>Lilina has been installed and is now ready to go. Please note your username and password below, as it <strong>won't be shown again</strong>!</p>
	<dl id="logindetails">
		<dt>Your username is</dt>
		<dd id="username"><?php 
        echo $username;
        ?>
</dd>
		<dt>and your password is</dt>
		<dd id="password"><?php 
        echo $password;
        ?>
</dd>
	</dl>
	<p><a href="admin/">Head to the admin panel</a> to get started!</p>
	<?php 
        return true;
    }
示例#2
0
function new_options_368()
{
    global $settings;
    if (!Options::get('sitename', false)) {
        if (!empty($settings['sitename'])) {
            Options::lazy_update('sitename', $settings['sitename']);
        } else {
            Options::lazy_update('sitename', 'Lilina News Aggregator');
        }
    }
}