예제 #1
0
function insert_defaults($dsn)
{
    // {{{
    $db = NewADOConnection($dsn);
    if (!$db) {
        die("Couldn't connect to \"{$dsn}\"");
    } else {
        if (substr($dsn, 0, 5) == "mysql") {
            $engine = new MySQL();
        } else {
            if (substr($dsn, 0, 5) == "pgsql") {
                $engine = new PostgreSQL();
            } else {
                if (substr($dsn, 0, 6) == "sqlite") {
                    $engine = new SQLite();
                } else {
                    die("Unknown database engine; Shimmie currently officially supports MySQL\n\t\t\t(mysql://), with hacks for Postgres (pgsql://) and SQLite (sqlite://)");
                }
            }
        }
        $engine->init($db);
        $config_insert = $db->Prepare("INSERT INTO config(name, value) VALUES(?, ?)");
        $user_insert = $db->Prepare("INSERT INTO users(name, pass, joindate, admin) VALUES(?, ?, now(), ?)");
        $db->Execute($user_insert, array('Anonymous', null, 'N'));
        $db->Execute($config_insert, array('anon_id', $db->Insert_ID()));
        if (check_im_version() > 0) {
            $db->Execute($config_insert, array('thumb_engine', 'convert'));
        }
        $db->Close();
    }
}
예제 #2
0
파일: install.php 프로젝트: JarJak/shimmie2
function insert_defaults()
{
    // {{{
    try {
        $db = new Database();
        $db->execute("INSERT INTO users(name, pass, joindate, class) VALUES(:name, :pass, now(), :class)", array("name" => 'Anonymous', "pass" => null, "class" => 'anonymous'));
        $db->execute("INSERT INTO config(name, value) VALUES(:name, :value)", array("name" => 'anon_id', "value" => $db->get_last_insert_id('users_id_seq')));
        if (check_im_version() > 0) {
            $db->execute("INSERT INTO config(name, value) VALUES(:name, :value)", array("name" => 'thumb_engine', "value" => 'convert'));
        }
        $db->commit();
    } catch (PDOException $e) {
        print <<<EOD
\t\t<div id="installer">
\t\t\t<h1>Shimmie Installer</h1>
\t\t\t<h3>Database Error:</h3>
\t\t\t<p>An error occured while trying to insert data into the database.</p>
\t\t\t<p>Please check and ensure that the database configuration options are all correct.</p>
\t\t\t<br/><br/>
\t\t</div>
EOD;
        exit($e->getMessage());
    } catch (Exception $e) {
        print <<<EOD
\t\t<div id="installer">
\t\t\t<h1>Shimmie Installer</h1>
\t\t\t<h3>Unknown Error:</h3>
\t\t\t<p>An unknown error occured while trying to insert data into the database.</p>
\t\t\t<p>Please check the server log files for more information.</p>
\t\t\t<br/><br/>
\t\t</div>
EOD;
        exit($e->getMessage());
    }
}
예제 #3
0
파일: install.php 프로젝트: nsuan/shimmie2
function insert_defaults()
{
    // {{{
    try {
        $db = new Database();
        $db->execute("INSERT INTO users(name, pass, joindate, admin) VALUES(:name, :pass, now(), :admin)", array("name" => 'Anonymous', "pass" => null, "admin" => 'N'));
        $db->execute("INSERT INTO config(name, value) VALUES(:name, :value)", array("name" => 'anon_id', "value" => $db->get_last_insert_id()));
        if (check_im_version() > 0) {
            $db->execute("INSERT INTO config(name, value) VALUES(:name, :value)", array("name" => 'thumb_engine', "value" => 'convert'));
        }
    } catch (PDOException $e) {
        // FIXME: Make the error message user friendly
        exit($e->getMessage());
    }
}