/**
     * 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)
    {
        global $installer;
        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 = @fopen(LILINA_PATH . '/content/system/config/feeds.data', 'w+');
            if (is_resource($feeds_file)) {
                $data['version'] = LILINA_FEEDSTORAGE_VERSION;
                $sdata = base64_encode(serialize($data));
                if (!$feeds_file) {
                    $this->file_error_notice(LILINA_PATH . '/content/system/config/feeds.data', $sitename, $username, $password);
                    return false;
                }
                fputs($feeds_file, $sdata);
                fclose($feeds_file);
            } else {
                echo "<p>Couldn't create <code>content/system/config/feeds.data</code>. Please ensure you create this yourself and make it writable by the server</p>\n";
            }
        }
        /** Make sure it's writable now */
        if (!$this->make_writable(LILINA_PATH . '/content/system/config/feeds.data')) {
            echo "<p>Couldn't make <code>content/system/config/feeds.data</code> writable. Please ensure you make it writable yourself</p>\n";
        }
        default_options();
        require_once LILINA_INCPATH . '/core/class-datahandler.php';
        if (!save_options()) {
            $this->file_error_notice(LILINA_PATH . '/content/system/config/options.data', $sitename, $username, $password);
            return false;
        }
        ?>
	<h1>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>
		<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>We can <a href="admin/first-run.php">help you get started</a>, or if you know what you're doing, <a href="admin/">head straight for the admin panel</a>.</p>
	<?php 
        return true;
    }
Exemplo n.º 2
0
    /**
     * 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)
    {
        global $installer;
        require_once LILINA_INCPATH . '/core/version.php';
        require_once LILINA_INCPATH . '/core/class-datahandler.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();
        global $options;
        $options['sitename'] = $sitename;
        if (!save_options()) {
            $this->file_error_notice(LILINA_PATH . '/content/system/config/options.data', $sitename, $username, $password);
            return false;
        }
        ?>
	<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>We can <a href="admin/first-run.php">help you get started</a>, or if you know what you're doing, <a href="admin/">head straight for the admin panel</a>.</p>
	<?php 
        return true;
    }
Exemplo n.º 3
0
/**
 * Returns a radio button tag.
 * 
 * The radio button will be checked if the current value of <var>$method</var> is 
 * equal to <var>$tagValue</var>. 
 * Example :
 * <code>radio_button('post', 'title', $this->post, 'Hello World');
 *      <input id="post_title_hello_world" name="post[title]" type="radio" value="Hello World" /></code>  
 */
function radio_button($objectName, $method, $object, $tagValue, $options = array())
{
    list($name, $value, $options) = default_options($objectName, $method, $object, $options);
    $options['id'] .= '_' . SInflection::wikify($tagValue);
    if ($value == $tagValue) {
        $checked = True;
    } else {
        $checked = False;
    }
    return radio_button_tag($name, $tagValue, $checked, $options);
}
function collection_select($objectName, $method, $object, $collection, $valueProp, $textProp, $options = array(), $htmlOptions = array())
{
    list($name, $value, $htmlOptions) = default_options($objectName, $method, $object, $htmlOptions);
    $optionsBlock = add_select_options(options_from_collection_for_select($collection, $valueProp, $textProp, $value), $options, $value);
    return select_tag($name, $optionsBlock, $htmlOptions);
}