Make sure this user has INSERT,UPDATE,DELETE,CREATE,ALTER permission to the database!'); define('PASSWORD_HELP', 'The password used to connect to the database.'); define('PREFIX_HELP', 'The string to prefix the tables with. Example: A table called rss_item should have rss as the prefix.'); define('ADMIN_USERNAME_HELP', 'The administrator username to use for database creation.'); define('ADMIN_PASSWORD_HELP', 'The administrator password used to connect to the database. Make sure this user has GRANT privileges!'); define('WEBSERVER_HELP', 'The location of the webserver. If in doubt, leave the default. Default: ' . WEB_SERVER_DEFAULT . ''); global $hasWritePerm; function install_main() { $hasXML = function_exists('xml_parser_create'); $hasMySQL = function_exists('mysql_connect'); $hasSQLite = function_exists('sqlite_open'); $hasSocket = function_exists('fsockopen'); // $hasSQLite = true; // If the server is running safe mode, try writing a temp file. if(ini_get('safe_mode')) { define ('TMPINIT', DBINIT . GREGARIUS_CODENAME . "tmp"); $fp = @fopen(TMPINIT, 'w'); if ($fp) { $hasWritePerm = true; fclose($fp); unlink (TMPINIT); } else { $hasWritePerm = false; } } else { // else, just check to see if it's writable. $hasWritePerm = is_writable(dirname(__FILE__)); } if($hasMySQL && $hasSQLite) { $sql = "MySQL & SQLite"; } else if($hasMySQL) { $sql = "MySQL"; } else if($hasSQLite) { $sql = "SQLite"; } else { $sql = "None!"; } echo "" . "\n" . "\n" . "\n" . " " . " Gregarius " . GREGARIUS_RELEASE . " " . GREGARIUS_CODENAME . " Installer\n" . " \n" . " \n" . "\n" . "\n" . "\n" . "\n" . "
" . "

Gregarius Database Setup

\n" . "
\n" . "Version " . GREGARIUS_RELEASE . " - " . GREGARIUS_CODENAME . "\n" . "

\"".GREGARIUS_CODENAME."\"

\n" . "
\n" . "
" . "
\n" . "

Step 1: Verify Environment

\n" . "
\n" . "
\n" . "Diagnostics\n" . "

Below are some of the requirements to run Gregarius. If any are not found, please fix them before continuing.

\n" . "

\n" . "

\n" . "

\n" . "

\n" . "
\n" . "

Step 2: Provide Database Settings

\n" . "
\n" . "Database Settings\n" . "

The settings below are for the database Gregarius will keep its data.

\n" . "

\n" . "MySQL" . "SQLite" . "" . TYPE_HELP . "

\n" . "

\n" . "" . "" . SQL_SERVER_HELP . "

\n" . "

\n" . "" . "" . DATABASE_HELP . "

\n" . "

\n" . "" . "" . USERNAME_HELP . "

\n" . "

\n" . "" . "" . PASSWORD_HELP . "

\n" . "

\n" . "" . "" . PREFIX_HELP . "

\n" . "
\n" . "

Step 3: Provide Admin Settings (optional)

\n" . "
\n" . "Server Setup\n" . "

If you would like Gregarius to create the database and user for you, input the correct settings below.

\n" . "

\n" . "" . "" . ADMIN_USERNAME_HELP . "

\n" . "

\n" . "" . "" . ADMIN_PASSWORD_HELP . "

\n" . "

\n" . "" . "" . WEBSERVER_HELP . "

\n" . "
\n" . "

Step 4: " . ($hasWritePerm ? "Create database and write dbinit.php" : "Create database and download dbinit.php") . "

\n" . "

\n" . "

\n" . "
\n" . "
\n" . "\n" . "\n"; } if(file_exists(DBINIT)) { print("The dbinit.php file already exists in the Gregarius directory! Please remove it if you would like to use this installer."); } else if(!empty($_POST['process']) && 1 == $_POST['process']) { if(empty($_POST['server']) || empty($_POST['database']) || empty($_POST['username']) || empty($_POST['password']) || empty($_POST['type'])) { print("Not all required fields have been filled in!"); } else { // create the database and user if(!empty($_POST['admin_username'])) { if("mysql" == $_POST['type']) { $sql = @mysql_connect($_POST['server'], $_POST['admin_username'], $_POST['admin_password']); if(!$sql) { print("Unable to connect to database! Please create manually."); } else { mysql_query("CREATE DATABASE " . $_POST['database'] . "", $sql); mysql_query("GRANT ALL ON " . $_POST['database'] . ".* TO '" . $_POST['username'] . "'@'" . $_POST['web_server'] . "' IDENTIFIED BY '" . $_POST['password'] . "'", $sql); mysql_close($sql); } } else if("sqlite" == $_POST['type']) { $sql = @sqlite_open($_POST['server'], 0666); if(!$sql) { print("Unable to connect to database! Please create manually."); } } else { print("Invalid SQL Type!"); exit(); } } $out = ""; $fp = @fopen(DBINIT, 'w'); if(!$fp) { // unable to open file for writing header('Content-type: application/x-httpd-php-source'); header('Content-Disposition: attachment; filename="dbinit.php"'); echo($out); exit(); } else { // write the file fwrite($fp, $out); fclose($fp); header('Location: admin/'); exit(); } } } else { // dbinit.php does not exist and we are not asked to process // print out the form install_main(); } ?>