From 44c3bc48b5db7b3dc6517d2b073a55af5d4b52db Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Wed, 10 Sep 2008 21:06:49 +0000 Subject: Series: Moved around directory structure Refs #55 --- series/trunk/install.php | 261 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 261 insertions(+) create mode 100644 series/trunk/install.php (limited to 'series/trunk/install.php') diff --git a/series/trunk/install.php b/series/trunk/install.php new file mode 100644 index 0000000..cf0d592 --- /dev/null +++ b/series/trunk/install.php @@ -0,0 +1,261 @@ + 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 ($_POST['adminUser'] == '') + { + addError($numOfErrors, $errors, 'adminUser', 'Administrator Username is a required field'); + } + + if ($_POST['adminPass'] == '') + { + addError($numOfErrors, $errors, 'adminPass', 'Administrator Password is a required field'); + } + + if ($numOfErrors > 0) + { + showHeader('2'); + showStepTwo($_POST['siteName'], $_POST['adminUser'], $_POST['adminPass'], $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']) . "\")"; + $sql[1] = "INSERT INTO config (name,value) VALUES (\"adminUser\",\"" . mysql_real_escape_string($_POST['adminUser']) . "\")"; + $sql[2] = "INSERT INTO config (name,value) VALUES (\"adminPass\",\"" . mysql_real_escape_string(md5($_POST['adminPass'])) . "\")"; + + 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'], $_POST['adminUser'], $_POST['adminPass'], $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.

+
+
Administrator User Details +
+ + +
+
+ + +
+
+
+ +
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