diff --git a/install.php b/install.php index 4ac5ff1e..f2b810c8 100644 --- a/install.php +++ b/install.php @@ -1,7 +1,16 @@ - +
-Shimmie needs to be run via a web server with PHP support -- you @@ -26,23 +38,25 @@ A:hover {text-decoration: underline;} documentation wiki.
"; var_dump($sql); echo ""; + $result = $schema->ExecuteSchema(); - if(!isset($_SESSION['tables_created']) || !$_SESSION['tables_created']) { - die("Error creating tables"); + if(!$result) { + define( 'XMLS_DEBUG', TRUE ); + die("Error creating tables from XML schema"); } } $db->Close(); @@ -228,9 +212,6 @@ function write_config($dsn) { // {{{ else { $h_file_content = htmlentities($file_content); print <<
One done, Continue - - EOD; session_destroy(); exit; } } // }}} -// }}} -// install {{{ function install_process() { // {{{ if(!isset($_POST['database_dsn']) || !isset($_POST["admin_name"]) || !isset($_POST["admin_pass"])) { die("Install is missing some paramaters (database_dsn, admin_name, or admin_pass)"); @@ -294,111 +271,14 @@ function insert_defaults($dsn, $admin_name, $admin_pass) { // {{{ $admin_pass = md5(strtolower($admin_name).$admin_pass); $db->Execute($user_insert, Array($admin_name, $admin_pass, 'Y')); - if(!ini_get('safe_mode')) { - $convert_check = exec("convert"); - if(!empty($convert_check)) { - $db->Execute($config_insert, Array('thumb_engine', 'convert')); - } + if(check_im_version() > 0) { + $db->Execute($config_insert, Array('thumb_engine', 'convert')); } $db->Close(); } } // }}} // }}} - - -// table creation {{{ -/* - * Note: try and keep this as ANSI SQL compliant as possible, - * so that we can (in theory) support other databases - */ -function create_tables_common($db, $auto_incrementing_id, $boolean, $true, $false, $ip) { - $db->Execute("CREATE TABLE aliases ( - oldtag VARCHAR(255) NOT NULL PRIMARY KEY, - newtag VARCHAR(255) NOT NULL - )"); - - $db->Execute("CREATE TABLE config ( - name VARCHAR(255) NOT NULL PRIMARY KEY, - value TEXT - )"); - - $db->Execute("CREATE TABLE images ( - id $auto_incrementing_id, - owner_id INTEGER NOT NULL, - owner_ip $ip, - filename VARCHAR(64) NOT NULL DEFAULT '', - filesize INTEGER NOT NULL, - hash CHAR(32) NOT NULL UNIQUE, - ext CHAR(4) NOT NULL, - source VARCHAR(255), - width INTEGER NOT NULL, - height INTEGER NOT NULL, - posted TIMESTAMP NOT NULL - )"); - - $db->Execute("CREATE TABLE users ( - id $auto_incrementing_id, - name VARCHAR(32) NOT NULL UNIQUE, - pass CHAR(32), - joindate DATETIME NOT NULL, - enabled $boolean NOT NULL DEFAULT $true, - admin $boolean NOT NULL DEFAULT $false, - email VARCHAR(255) - )"); - - $db->Execute("CREATE TABLE layout ( - title VARCHAR(64) PRIMARY KEY NOT NULL, - section VARCHAR(32) NOT NULL DEFAULT 'left', - position INTEGER NOT NULL DEFAULT 50, - visible $boolean DEFAULT $true - )"); - - $db->Execute("CREATE TABLE tags ( - id $auto_incrementing_id, - tag VARCHAR(64) NOT NULL UNIQUE, - count INTEGER NOT NULL DEFAULT 0 - )"); - $db->Execute("CREATE INDEX tags__count ON tags(count)"); - - $db->Execute("CREATE TABLE image_tags ( - image_id INTEGER NOT NULL DEFAULT 0, - tag_id INTEGER NOT NULL DEFAULT 0, - UNIQUE (image_id, tag_id) - )"); - $db->Execute("CREATE INDEX image_tags__tag_id ON image_tags(tag_id)"); - $db->Execute("CREATE INDEX image_tags__image_id ON image_tags(image_id)"); - - - $db->Execute("INSERT INTO config(name, value) VALUES(?, ?)", Array('db_version', 5)); -} -function create_tables_mysql($db) { - $db->StartTrans(); - $db->Execute("SET NAMES utf8"); - create_tables_common($db, - "INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY", - "ENUM('Y', 'N')", "'Y'", "'N'", - "CHAR(15)" - ); - return $db->CommitTrans(); -} -function create_tables_pgsql($db) { - $db->StartTrans(); - create_tables_common($db, - "SERIAL NOT NULL PRIMARY KEY", - "BOOLEAN", "True", "False", - "INET" - ); - return $db->CommitTrans(); -} -function create_tables_sqlite($db) { - $db->StartTrans(); - create_tables_common($db, - "INTEGER AUTOINCREMENT PRIMARY KEY NOT NULL", - "CHAR(1)", "'Y'", "'N'", - "CHAR(15)" - ); - return $db->CommitTrans(); -} -// }}} ?> +