From 3a8269baf374867864f5b191312ffb00e659752f Mon Sep 17 00:00:00 2001 From: Shish Date: Tue, 26 Jun 2012 23:37:29 +0100 Subject: [PATCH] lots of installer improvements --- install.php | 144 +++++++++++++++++++++++++----------------------- lib/shimmie.css | 32 +++++++++++ 2 files changed, 106 insertions(+), 70 deletions(-) diff --git a/install.php b/install.php index 07dbb32c..12e7b263 100644 --- a/install.php +++ b/install.php @@ -1,36 +1,24 @@ - - + + Shimmie Installation - + - + -
+

Install Error

Shimmie needs to be run via a web server with PHP support -- you appear to be either opening the file from your hard disk, or your @@ -112,64 +100,64 @@ function eok($name, $value) { } // }}} function do_install() { // {{{ - if(isset($_POST['database_type']) && isset($_POST['database_host']) && isset($_POST['database_user']) && isset($_POST['database_name'])) { - $database_dsn = "{$_POST['database_type']}:user={$_POST['database_user']};password={$_POST['database_password']};host={$_POST['database_host']};dbname={$_POST['database_name']}"; - define('DATABASE_DSN', $database_dsn); + if(file_exists("data/config/auto_install.conf.php")) { + require_once "data/config/auto_install.conf.php"; install_process(); } - else if(file_exists("auto_install.conf")) { - define('DATABASE_DSN', trim(file_get_contents("auto_install.conf"))); + else if(@$_POST["database_type"] == "sqlite" && isset($_POST["database_name"])) { + define('DATABASE_DSN', "sqlite:{$_POST["database_name"]}"); + install_process(); + } + else if(isset($_POST['database_type']) && isset($_POST['database_host']) && isset($_POST['database_user']) && isset($_POST['database_name'])) { + define('DATABASE_DSN', "{$_POST['database_type']}:user={$_POST['database_user']};password={$_POST['database_password']};host={$_POST['database_host']};dbname={$_POST['database_name']}"); install_process(); - unlink("auto_install.conf"); } else { - begin(); + ask_questions(); } } // }}} -function begin() { // {{{ - $err = ""; - $thumberr = ""; - $dberr = ""; +function ask_questions() { // {{{ + $warnings = array(); + $errors = array(); if(check_gd_version() == 0 && check_im_version() == 0) { - $thumberr = " -

PHP's GD extension seems to be missing, - and imagemagick's \"convert\" command cannot be found - - no thumbnailing engines are available. + $errors[] = " + No thumbnailers cound be found - install the imagemagick + tools (or the PHP-GD library, of imagemagick is unavailable). + "; + } + else if(check_im_version() == 0) { + $warnings[] = " + The 'convert' command (from the imagemagick package) + could not be found - PHP-GD can be used instead, but + the size of thumbnails will be limited. "; } - if(!function_exists("mysql_connect")) { - $dberr = " -

PHP's MySQL extension seems to be missing; you may - be able to use an unofficial alternative, checking - for libraries... + if( + !function_exists("mysql_connect") && + !function_exists("pg_connect") && + !function_exists("sqlite_open") + ) { + $errors[] = " + No database connection library could be found; shimmie needs + php-pgsql, php-mysql, or php-sqlite "; - if(!function_exists("pg_connect")) { - $dberr .= "
PgSQL is missing"; - } - else { - $dberr .= "
PgSQL is available"; - } - if(!function_exists("sqlite_open")) { - $dberr .= "
SQLite is missing"; - } - else { - $dberr .= "
SQLite is available"; - } } - if($thumberr || $dberr) { - $err = "

Error

"; - } + $db_m = function_exists("mysql_connect") ? '' : ""; + $db_p = function_exists("pg_connect") ? '' : ""; + $db_s = function_exists("sqlite_open") ? '' : ""; + + $warn_msg = $warnings ? "

Warnings

".implode("\n
", $warnings) : ""; + $err_msg = $errors ? "

Errors

".implode("\n
", $errors) : ""; print << +

Shimmie Installer

- $err - $thumberr - $dberr + $warn_msg + $err_msg

Database Install

@@ -177,37 +165,53 @@ function begin() { // {{{ - + - + - + - + - - + + - +
Type:
Host:
Username:
Password:
DB Name:
DB Name:
+

Help

-

Please make sure the database you have chosen exists and is empty.
- The username provided must have access to create tables within the database.

+

+ Please make sure the database you have chosen exists and is empty.
+ The username provided must have access to create tables within the database. +

+

+ For SQLite the database name will be a filename on disk, relative to + where shimmie was installed. +

EOD; diff --git a/lib/shimmie.css b/lib/shimmie.css index d920eaaa..411ed805 100644 --- a/lib/shimmie.css +++ b/lib/shimmie.css @@ -27,3 +27,35 @@ IMG.lazy {display: none;} border: 1px solid #882; } + +#installer { + background: #EEE; + font-family: "Arial", sans-serif; + font-size: 14px; + width: 512px; + margin: auto; + margin-top: 16px; + border: 1px solid black; + border-radius: 16px; +} +#installer A { + text-decoration: none; +} +#installer A:hover { + text-decoration: underline; +} +#installer H1, H3 { + background: #DDD; + text-align: center; + margin: 0px; + padding: 2px; +} +#installer H1 { + border-bottom: 1px solid black; + border-radius: 16px 16px 0px 0px; +} +#installer H3 { + border-bottom: 1px solid black; + border-top: 1px solid black; + margin-top: 32px; +}