From 0c61e34109d7c69b1093463ece88e5545c6f1c16 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 7 Sep 2008 13:08:25 +0000 Subject: Series: Wrote installation script Refs #28 --- series/core/trunk/install.php | 235 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 235 insertions(+) (limited to 'series/core/trunk/install.php') diff --git a/series/core/trunk/install.php b/series/core/trunk/install.php index 3b3f202..0f7549d 100644 --- a/series/core/trunk/install.php +++ b/series/core/trunk/install.php @@ -2,4 +2,239 @@ /* InstaDisc Series - A Four Island Project */ +if (!isset($_GET['submit'])) +{ + showHeader('1'); + showStepOne('localhost', 'root', '', 'instadisc', array()); +} else { + $numOfErrors = 0; + $errors = array(); + + switch ($_GET['submit']) + { + case 1: + if ($_POST['host'] == '') + { + addError($numOfErrors, $errors, 'host', 'Hostname is a required field'); + } + + if ($_POST['username'] == '') + { + addError($numOfErrors, $errors, 'username', 'Username is a required field'); + } + + if ($_POST['password'] == '') + { + addError($numOfErrors, $errors, 'password', 'Password is a required field'); + } + + if ($_POST['dbname'] == '') + { + addError($numOfErrors, $errors, 'dbname', 'Name is a required field'); + } + + if ($numOfErrors > 0) + { + showHeader('1'); + showStepOne($_POST['host'], $_POST['username'], $_POST['password'], $_POST['dbname'], $errors); + } else { + if (!@mysql_connect($_POST['host'], $_POST['username'], $_POST['password'])) + { + addError($numOfErrors, $errors, '', 'Cannot connect to database server'); + showHeader('1'); + showStepOne($_POST['host'], $_POST['username'], $_POST['password'], $_POST['dbname'], $errors); + } else { + if (!@mysql_select_db($_POST['dbname'])) + { + addError($numOfErrors, $errors, 'dbname', 'Database does not exist'); + showHeader('1'); + showStepOne($_POST['host'], $_POST['username'], $_POST['password'], $_POST['dbname'], $errors); + } else { + $sql = file_get_contents('instadisc.sql'); + $makedb = split(';', $sql); + foreach ($makedb as $name => $value) + { + if (!trim($value) == '') + { + $makedb2 = @mysql_query($value); + if (!$makedb2) + { + addError($numOfErrors, $errors, '', "MySQL error \"" . mysql_error() . "\" while creating database"); + } + } + } + + @file_put_contents('includes/config.php', ""); + + if (!file_exists('includes/config.php')) + { + addError($numOfErrors, $errors, '', 'Could not write config.php file, please check directory permissions'); + } + + if ($numOfErrors > 0) + { + showHeader('1'); + showStepOne($_POST['host'], $_POST['username'], $_POST['password'], $_POST['dbname'], $errors); + } else { + showHeader('2'); + showStepTwo('', array()); + } + } + } + } + + break; + + case 2: + if ($_POST['siteName'] == '') + { + addError($numOfErrors, $errors, 'siteName', 'Site Name is a required field'); + } + + if ($numOfErrors > 0) + { + showHeader('2'); + showStepTwo($_POST['mailDomain'], $_POST['smtpHost'], ($_POST['smtpAuth'] == 'on' ? ' CHECKED' : ''), $_POST['smtpUser'], $_POST['smtpPass'], $_POST['siteName'], $_POST['xmlrpcURL'], $_POST['adminUser'], $_POST['adminPass'], $_POST['adminEmail'], $errors); + } else { + include_once('includes/config.php'); + + mysql_connect($dbhost, $dbuser, $dbpass); + mysql_select_db($dbname); + + $sql[0] = "INSERT INTO config (name,value) VALUES (\"siteName\",\"" . mysql_real_escape_string($_POST['siteName']) . "\")"; + + foreach ($sql as $name => $value) + { + if (!trim($value) == '') + { + $sql2 = @mysql_query($value); + if (!$sql2) + { + addError($numOfErrors, $errors, '', "MySQL error \"" . mysql_error() . "\" while filling database"); + } + } + } + + if ($numOfErrors > 0) + { + showHeader('2'); + showStepTwo($_POST['siteName'], $errors); + } else { + showHeader('3'); + showStepThree(); + } + } + + break; + } +} + +?>

InstaDisc (C) Starla Insigna 2008. InstaDisc Setup uses the UniForm form theme
InstaDisc Series Setup Step <?php echo($number); ?>

InstaDisc Installation

Welcome to the InstaDisc Series Control installation! Please input your database details below.

+

+
Uh oh! Validation errors!

+

    $value) + { +?>
+
Database Details +
+ + +
+
+ + +
+
+ + +
+
+ + +

You need to create this database before running this script.

+
+
+
+ +
Your database has been set up. All we need to do now is fill it up a little. Please answer the below questions to set up your configuration: +
+
Uh oh! Validation errors!

+

    $value) + { +?>
+
Website +
+ + +

Your website's name is required for a little personalization of emails.

+
+
+
+ +
Congradulations! You've successfully set up your InstaDisc Series Control! $value) + { + if ($value['field'] == $id) + { + echo(' error'); + return; + } + } +} + + +function doErrors($errors, $id) +{ + foreach ($errors as $name => $value) + { + if ($value['field'] == $id) + { +?>

*

$field, 'msg' => $msg); +} -- cgit 1.4.1