Location: PHPKode > scripts > SelectaPix Image Gallery > install/install.php
<?php
/* +----------------------------------------------------------------------+
   |SelectaPix Open Source Gallery	                                      |
   +----------------------------------------------------------------------+
   | Copyright (c) 2004 OutOfTheTrees			                          |
   |                                                                      |
   | http://www.outofthetrees.co.uk/index.php                             |
   | 												                      |
   +----------------------------------------------------------------------+
   | This source file is subject to version 2.0 of the GPL license,       |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
   | http://www.outofthetrees.co.uk/license/2_0.txt.                      |
   | If you did not receive a copy of the SelectaPix license and are 	  |
   | unable to obtain it through the world-wide-web, please send a note   |
   | to hide@address.com so we can mail you a copy immediately.|
   +----------------------------------------------------------------------+ */
define("ACCESS",1);
require_once('terms.php');
session_start();
$page = @$_GET['page'];

// START INCLUDE VALIDATION
$missing = "";
if (file_exists("../includes/inc_global_fns.php")) {
    // FILE INCLUDES - main site
    if (!file_exists("../classes/db.php"))
    	$missing .= "<div class=\"outcome_warning\">classes/db.php</p>";
    if (!file_exists("../classes/pager.php"))
    	$missing .= "<div class=\"outcome_warning\">classes/pager.php</p>";
    if (!file_exists("../classes/sub_cat.php"))
    	$missing .= "<div class=\"outcome_warning\">classes/sub_cat.php</p>";
    if (!file_exists("../classes/top_cat.php"))
    	$missing .= "<div class=\"outcome_warning\">classes/top_cat.php</p>";
    if (!file_exists("terms.php"))
    	$missing .= "<div class=\"outcome_warning\">install/terms.php</p>";
}
else {
    $missing .= "<div class=\"outcome_warning\">inc_global_fns.php</p>";
}
if (file_exists("../admin/includes/inc_global_fns.php")) {
	// FILE INCLUDES - admin site
    if (!file_exists("../classes/admin_page.php"))
    	$missing .= "<div class=\"outcome_warning\">classes/admin_page.php</p>";
    if (!file_exists("../classes/admin_user.php"))
    	$missing .= "<div class=\"outcome_warning\">classes/admin_user.php</p>";
    if (!file_exists("../classes/album.php"))
    	$missing .= "<div class=\"outcome_warning\">classes/album.php</p>";
    if (!file_exists("../classes/cat.php"))
    	$missing .= "<div class=\"outcome_warning\">classes/cat.php</p>";
    if (!file_exists("../classes/image.php"))
    	$missing .= "<div class=\"outcome_warning\">classes/image.php</p>";
    if (!file_exists("../classes/upload.php"))
    	$missing .= "<div class=\"outcome_warning\">classes/upload.php</p>";
    if (!file_exists("../admin/includes/inc_output_fns.php"))
    	$missing .= "<div class=\"outcome_warning\">/admin/includes/inc_output_fns.php</p>";
}
else {
    $missing .= "<div class=\"outcome_warning\">/admin/includes/inc_global_fns.php</p>";
}
if (!include_once("../includes/config.php"))
    	$missing .= "<div class=\"outcome_warning\">config.php</p>";

if ($missing != "") {
    show_header();
    show_menu(1);
    echo "<div class=\"outcome_fatal\">The following file(s) could not be found:</p>";
    echo $missing;
    echo "<p>Please read the installation instructions and upload all components of this script.</p>";
    show_footer();
    exit;
}
// END INCLUDES

// IF THEY'VE NOT AGREED TO THE T's&C's KEEP LOOPING UNTIL THEY DO
if ((!isset($page)) || ($_SESSION['agree_terms'] == 0) || (!isset($_SESSION['agree_terms']))) {
    $page = 1;
}
require ("../classes/db.php");
include('../includes/config.php');
$conn = new mySQL();
/*	----------------------------------------------
			PAGE ONE
	----------------------------------------------*/

if ($page == 1) {
	if(@$_POST[license]) {
		if($_POST[license]=='disagree') {
			$_SESSION['agree_terms'] = 0;
			show_license_form('disagree');
		}
		else {
			$_SESSION['agree_terms'] = 1;
		}
	}
	if(($_SESSION['agree_terms'] == 0) && isset($_SESSION['agree_terms'])) {
		// THEY'VE SAID NO TO LICENSE, SO DISPLAY T's & C's AGAIN WITH WARNING
		show_license_form('disagree');
	}
	elseif(!isset($_SESSION['agree_terms'])) {
		// DISPLAY T's & C's BEFORE WE GO ANY FURTHER
		show_license_form();
	}

	show_header();
	show_menu(1);
	echo "<p>Welcome to the SelectaPix installation program.</p>\n";
	echo "<p>We have designed this installer to guide you, step by step, through the process of setting up your gallery site.</p>\n";
	echo "<p>Throughout this installer we have colour coded the results of various step as follows:</p><br />\n
			<div class=\"outcome_good\">The step completed successfully</div>\n
			<div class=\"outcome_warning\">The step completed with errors</div>\n
			<div class=\"outcome_fatal\">The step failed and the installer has quit</div>\n
			<p>In the event of errors or failures occuring you will receive an error message which details what (if anything) you can do
			to rectify the problem.</p><br />\n\n";
	$url = 'install.php?page=2';
	$name = 'Begin &gt;&gt;';
	$text = 'Next &gt;&gt;';
	display_txt_button($url, $name, $text);
}

/*	----------------------------------------------
			PAGE TWO
	----------------------------------------------*/

if ($page == 2)
{
	show_header();
	show_menu(2);
	echo "<div class=\"step\">Checking php version....</div>\n";
	$version = phpversion();
	if($version>'4.2.0')
		echo "\t<div class=\"outcome_good\">Version ".$version." found - ok</div>\n\n";
	else {
		echo "\t<div class=\"outcome_fatal\">Version ".$version." found - unable to continue. Version 4.2.0 is required as a minimum.</div>\n";
		die();
	}
	echo "<div class=\"step\">Checking mysql connection....\n</div>";
	if(!$conn->isConnected) {
		echo "\t<div class=\"outcome_fatal\">Cannot connect to mysql server - unable to continue. Please check the connection data you entered in inc_config.php.</div>\n";
		die();
	}
	else {
		echo "\t<div class=\"outcome_good\">Connected - ok</div>\n\n";
		echo "<div class=\"step\">Checking mysql version....</div>\n";
		// Get the mySQL version.
		// Adapted from phpMyAdmin
		if (!$row = $conn->query("SELECT VERSION() AS version")) {
			$row = $conn->query("SHOW VARIABLES LIKE 'version'");
		}

		$true_version = $row[0]['version'];

		$no_array = explode( '.', preg_replace( "/^(.+?)[-_]?/", "\\1", $row[0]['version']) );
		$one   = (!isset($no_array) || !isset($no_array[0])) ? 3  : $no_array[0];
		$two   = (!isset($no_array[1]))                      ? 21 : $no_array[1];
		$three = (!isset($no_array[2]))                      ? 0  : $no_array[2];

		$mysql_version = (int)sprintf('%d%02d%02d', $one, $two, intval($three));
		if($mysql_version>'32000')
			echo "\t<div class=\"outcome_good\">Version ".$true_version." found - ok</div>\n\n";
		else {
			echo "\t<div class=\"outcome_fatal\">Version ".$true_version." found - unable to continue. Version 3.20.00 is required as a minimum.</div>\n";
			die();
		}
	}
	echo "<div class=\"step\">Checking that database exists....</div>\n";
	$db_select = @mysql_select_db(SQL_DBASE, $conn);
	if($conn->selectedDb && !$conn->getMysqlError())
		echo "\t<div class=\"outcome_good\">Database exists - ok</div>\n\n";
	elseif($conn->getMysqlError()) {
		echo "\t\t<div class=\"outcome_fatal\">Cannot select database - unable to continue.<br />\n
			\t\tThe user account you have provided does not have privileges to select your database.<br />\n
			\t\tPlease contact your system admin and have them change your privileges.</div>\n";
		die();
	}
	else {
		echo "\t<div class=\"outcome_warning\">Database does not exist - attempting to create it....</div>\n";
		$conn->query("CREATE DATABASE ".SQL_DBASE, 'none');
		if(!$conn->result) {
			echo "\t\t<div class=\"outcome_fatal\">Cannot create database - unable to continue.<br />\n
					\t\tThe user account you have provided does not have privileges to create databases.<br />\n
					\t\tPlease contact your system admin and have them create the database for you.</div>\n";
			die();
		}
		echo "\t\t<div class=\"outcome_good\">Database created successfully....</div><br />\n\n";
	}

	//Check for GD

	echo "<div class=\"step\">Checking for required server extensions....</div>\n";
	echo "<div class=\"step\">Checking for GD (image library)....</div>\n";
	$extensions = get_loaded_extensions();
	foreach ($extensions as $each_ext) {
		if(strstr('gd', $each_ext))
		{
			echo "\t<div class=\"outcome_good\">GD library is installed - ok</div>\n\n";
			$result = 1;
		}
	}
	if($result != 1) {
		echo "\t<div class=\"outcome_warning\">GD library is not installed - you will not be able to upload images to your site!</div>\n\n";
		$error1 = 'true';
	}

	if(!$error1) {
		echo "\t<div class=\"outcome_good\"> -- All pre setup checks successfully completed --</div><br />\n\n";
	}
	else {
		echo "\t<div class=\"outcome_warning\"> -- All pre setup checks completed, but with the following warning(s) --</div><br />\n\n";
	}
	if($error1) {
		echo "<p>## You do not have the 'GD' image library installed. These functions are required for uploading of images for display on your website.<br />
			Please contact the administrator of your system to have the extensions added.</p>";
	}
	//Check file permissions
	echo "\t<div class=\"step\"> - Testing file permissions....</div>\n\n";
	echo "\t<div class=\"step\">".SITE_PATH.IMAGE_DIR."....</div>\n\n";
	$write = is_writable(SITE_PATH.IMAGE_DIR);
	$read = is_writable(SITE_PATH.IMAGE_DIR);
	if($read==0 || $write==0) {
		echo "<div class=\"outcome_warning\">".SITE_PATH.IMAGE_DIR." cannot be written....</div>\n
				<div class=\"step\">Attempting to change permissions....</div>\n";
		$result = @chmod($path, 0777);
		if(!$result) {
			echo "<div class=\"outcome_warning\">Cannot change permissions for ".IMAGE_DIR."</div>\n";
			$error[5] = 'true';
		}
		else {
				echo "<div class=\"outcome_good\">Permissions updated for ".IMAGE_DIR."</div>\n";
		}
	}
	else {
		echo "<div class=\"outcome_good\">Permissions OK - good</div><br />\n";
	}
	$url = 'install.php?page=3';
	$name = 'Create DB Tables &gt;&gt;';
	$text = 'Next &gt;&gt;';
	display_txt_button($url, $name, $text);
}

/*	----------------------------------------------
			PAGE THREE
	----------------------------------------------*/

if ($page == 3) {
	show_header();
	show_menu(3);
	echo "<div class=\"step\">Starting creation of database tables....</div><br />\n";

	/* --------------------- CREATE TABLES --------------------- */

	echo "<div class=\"step\">Creating table structure for ".SQL_ABM_TBL."....</div>\n";
	$conn->query("DROP TABLE IF EXISTS ".SQL_ABM_TBL."");
	$conn->query("CREATE TABLE ".SQL_ABM_TBL." (
				  albumID int(11) NOT NULL auto_increment,
				  album_name varchar(64) NOT NULL default '',
				  album_descr text,
				  parent_albumID int(11) NOT NULL default '0',
				  active enum('yes','no') NOT NULL default 'yes',
				  PRIMARY KEY  (albumID)
				  ) TYPE=MyISAM;");
	if(!$conn->result) {
		echo "\t<div class=\"outcome_fatal\">Cannot create ".SQL_ABM_TBL." - unable to continue. Please go back and try again.</div>\n\n";
		die();
	}
	echo "\t<div class=\"outcome_good\">Table '".SQL_ABM_TBL."' created - ok</div>\n\n";

	echo "<div class=\"step\">Creating table structure for ".SQL_IMG_TBL."....</div>\n";
	$conn->query("DROP TABLE IF EXISTS ".SQL_IMG_TBL."");
	$conn->query("CREATE TABLE ".SQL_IMG_TBL." (
				  imageID int(11) NOT NULL auto_increment,
				  uploadername varchar(32) NOT NULL default '',
				  albumID int(11) NOT NULL default '0',
				  caption varchar(255) NOT NULL default '',
				  image_url varchar(255) NOT NULL default '',
				  description text,
				  upload_date date default '0000-00-00',
				  approved enum('yes','no') default 'yes',
				  active enum('yes','no') NOT NULL default 'yes',
				  PRIMARY KEY  (imageID)
				  ) TYPE=MyISAM;");
	if(!$conn->result) {
		echo "\t<div class=\"outcome_fatal\">Cannot create ".SQL_IMG_TBL." - unable to continue. Please go back and try again.</div>\n\n";
		die();
	}
	echo "\t<div class=\"outcome_good\">Table '".SQL_IMG_TBL."' created - ok</div>\n\n";

	echo "<div class=\"step\">Creating table structure for role....</div>\n";
	$conn->query("DROP TABLE IF EXISTS role");
	$conn->query("CREATE TABLE role (
				  RoleID tinyint(4) NOT NULL auto_increment,
				  RoleLevel tinyint(4) NOT NULL default '0',
				  Role varchar(255) NOT NULL default '',
				  PRIMARY KEY  (RoleID)
				  ) TYPE=MyISAM;");
	if(!$conn->result) {
		echo "\t<div class=\"outcome_fatal\">Cannot create role - unable to continue. Please go back and try again.</div>\n\n";
		die();
	}
	echo "\t<div class=\"outcome_good\">Table 'role' created - ok</div>\n\n";

	echo "<div class=\"step\">Creating table structure for user....</div>\n";
	$conn->query("DROP TABLE IF EXISTS user");
	$conn->query("CREATE TABLE user (
				  userID tinyint(4) NOT NULL auto_increment,
				  username varchar(16) NOT NULL default '',
				  passwd varchar(50) NOT NULL default '',
				  email varchar(100) NOT NULL default '',
				  change_passwd enum('yes','no') NOT NULL default 'yes',
				  barred enum('yes','no') NOT NULL default 'no',
				  RoleID tinyint(4) NOT NULL default '1',
				  PRIMARY KEY  (userID)
				  ) TYPE=MyISAM;");
	if(!$conn->result) {
		echo "\t<div class=\"outcome_fatal\">Cannot create user - unable to continue. Please go back and try again.</div>\n\n";
		die();
	}
	echo "\t<div class=\"outcome_good\">Table 'user' created - ok</div><br /><br />\n\n";

	echo "\t<div class=\"outcome_good\" style=\"color: red;\"> -- All tables successfully created --</div>\n\n";
	$url = 'install.php?page=4';
	$name = 'Insert DB data &gt;&gt;';
	$text = 'Next &gt;&gt;';
	display_txt_button($url, $name, $text);
}

/*	----------------------------------------------
			PAGE FOUR
	----------------------------------------------*/

if ($page == 4) {

	show_header();
	show_menu(4);
	echo "<div class=\"step\">Starting insertion of data into database tables....</div><br /><br />\n";

	/* ------------------------ INSERT DATA ----------------------- */

	echo "<div class=\"step\">Inserting data into 'role' table ....</div>\n";
	$conn->query("DELETE FROM role");
	$conn->query("INSERT INTO role VALUES
				  ('1',1,'Guest'),
				  ('2',2,'Restricted User'),
				  ('3',4,'Full User'),
				  ('4',127,'Site Administrator')", 'none');
	if(!$conn->result) {
		echo "\t<div class=\"outcome_fatal\">Cannot insert data into 'role' table - unable to continue. Please go back and try again.</div>\n\n";
		die();
	}
	echo "\t<div class=\"outcome_good\">Data inserted into 'role' successfully - ok</div><br /><br />\n\n";

	echo "<div class=\"step\">Inserting data into '".SQL_ABM_TBL."' table ....</div>\n";
	$conn->query("DELETE FROM ".SQL_ABM_TBL);
	$conn->query("INSERT INTO ".SQL_ABM_TBL." VALUES
				  ('', 'upload_temp', 'Temporary album used by the system for image uploads. Images in this album are not visible to visitors.', '0', 'no')", 'none');
	if(!$conn->result) {
		echo "\t<div class=\"outcome_fatal\">Cannot insert data into ''".SQL_ABM_TBL."'' table - unable to continue. Please go back and try again.</div>\n\n";
		die();
	}
	echo "\t<div class=\"outcome_good\">Data inserted into ''".SQL_ABM_TBL."'' successfully - ok</div><br /><br />\n\n";

	echo "\t<div class=\"outcome_good\"> -- All data successfully inserted --</div>\n\n";
		$url = 'install.php?page=5';
		$name = 'Create an Admin User &gt;&gt;';
		$title = 'Next &gt;&gt;';
		display_txt_button($url, $name, $title);
}

/*	----------------------------------------------
			PAGE FIVE
	----------------------------------------------*/

if ($page == 5) {
	show_header();
	show_menu(5);
	echo "<div class=\"step\">The installation routine has created an admin user, <br />
			we now need to complete this account with your details.<br />
			You may add more users from your Control Panel once setup has been completed.</div><br />\n";
	display_admin_reg_form();
}

/*	----------------------------------------------
			PAGE SIX
	----------------------------------------------*/

if ($page == 6) {
	if($_POST['username']) {
	    $username   = trim(strip_tags($_POST['username']));
	    $passwd     = trim(strip_tags($_POST['passwd']));
        $passwd2	= trim(strip_tags($_POST['passwd2']));
        $email      = trim($_POST['email']);

	    if (($username == "") || ($passwd == "") || ($passwd2 == "") || ($email == "")) {
	       show_header();
	       show_menu(5);
	       echo "<br /><div class=\"outcome_warning\">You left some of the form fields empty</div>";
	       display_admin_reg_form($username, $email);
	       show_footer();
	       exit;
	    }
	    elseif (!eregi("^[[:alnum:]]+$", $username)) {

	       show_header();
	       show_menu(5);
	       echo "<br /><div class=\"outcome_warning\">Your username must be a single word, with no spaces.</div>";
	       display_admin_reg_form($username, $email);
	       show_footer();
	       exit;
	    }
	    elseif (strlen($username) < 4) {
	       show_header();
	       show_menu(5);
	       echo "<br /><div class=\"outcome_warning\">Username must be at least 4 characters.</div>";
	       display_admin_reg_form($username, $email);
	       show_footer();
	       exit;
	    }
	    elseif ($passwd != $passwd2) {
	       show_header();
	       show_menu(5);
	       echo "<br /><div class=\"outcome_warning\">The passwords you entered do not match.</div>";
	       display_admin_reg_form($username, $email);
	       show_footer();
	       exit;
	    }
	    elseif (strlen($passwd) < 4) {
	       show_header();
	       show_menu(5);
	       echo "<br /><div class=\"outcome_warning\">Password must be at least 4 characters.</div>";
	       display_admin_reg_form($username, $email);
	       show_footer();
	       exit;
	    }
	    elseif (!valid_email_address($email)) {
	       show_header();
	       show_menu(5);
	       echo "<br /><div class=\"outcome_warning\">That is not a valid email address.</div>";
	       display_admin_reg_form($username, $email);
	       show_footer();
	       exit;
	    }

		$conn->query("INSERT INTO user VALUES
					  ('', '$username', password('$passwd'), '$email', 'no', 'no', '4')", 'none');
		if(!$conn->result) {
		    show_header();
		    show_menu(5);
		    echo "<br /><div class=\"outcome_warning\">Sorry! Your information has not been updated. Please try again.</div>";
		    display_admin_reg_form($username, $email);
		    show_footer();
		    exit;
		}
		header("Location: install.php?page=7");
	}
	else {
		echo "\t<div class=\"outcome_fatal\"> -- This page was called incorrectly. Please use the 'back' button on your browser to return to the previous page --</div>\n\n";
	}
}

/*	----------------------------------------------
		PAGE SEVEN - COMPLETE
	----------------------------------------------*/

if ($page == 7) {
	show_header();
	show_menu(6);
	echo "\t<div class=\"outcome_good\"> -- Your admin information was successfully updated --</div>\n\n";
	echo "<p>Please be sure to make a note of your password and store it securely. <br />You may add more users from your Control Panel once setup has been completed.</p><br />\n";
	echo "<p>Congratulations! You have finished configuring your new gallery.<br />\n
			As a security precaution you should now delete the entire 'install' directory.<br />
			Once you have done this, your gallery should be accessible via:<br />
			<strong>http://www.yoursite.com/your_gallery_folder/</strong><br />
			and your admin area via:<br />
			<strong>http://www.yoursite.com/your_gallery_folder/admin/login.php</strong></p>\n";
}
?>
</div>
<div id="web-design">
<a href="http://www.outofthetrees.co.uk/index.php" title="Our main web design site" class="oott">Out of the Trees</a><br /><a href="http://www.outofthetrees.co.uk/index.php" title="See our full range of web development services" class="site-design">Web Site Design<br />London, UK</a>
</div>


<h5>Copyright &copy; 2003 <a href="http://www.outofthetrees.co.uk/index.php">Out of the Trees Web Design &amp; Development</a></h5>

</body>
</html>
<?php


function show_header() {
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>SelectaPix Installation</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css" media="all">@import url(general.css);</style>
</head>
<body>
<div id="header">
<h1><span>SelectaPix Gallery</span></h1>
<h2>SelectaPix Automated Installation</h2>
<div id="topmenu">
<a href="http://www.outofthetrees.co.uk/gallery/index.php" class="tm" title="SelectaPix home page">Home</a><span class="hide"> | </span>
<a href="http://www.outofthetrees.co.uk/about.php" class="tm" title="About Out of the Trees">About Us</a><span class="hide"> | </span>
<a href="http://www.outofthetrees.co.uk/support.php" class="tm" title="Support for existing customers">Support</a><span class="hide"> | </span>
<a href="http://www.outofthetrees.co.uk/contact.php" class="tm" title="How to get in touch with us">Contact Us</a>
</div>
</div>

<div id="main">

<?php
}

function show_footer()
{
?>
</div>
<div id="web-design">
<a href="http://www.outofthetrees.co.uk/index.php" title="Our main web design site" class="oott">Out of the Trees</a><br /><a href="http://www.outofthetrees.co.uk/index.php" title="See our full range of web development services" class="site-design">Web Site Design<br />London, UK</a>
</div>


<h5>Copyright &copy; 2004 <a href="http://www.selectacart.com/index.php">SelectaPix</a></h5>

</body>
</html>
<?php
}

function show_license_form($agree='') {
	show_header();
	show_menu(1);
	if($agree == '')
		echo "<p>Welcome to the SelectaPix installation program.</p>\n";
	elseif($agree == 'disagree')
	{
		echo "<div class=\"outcome_fatal\">You have not agreed to the SelectaPix Terms &amp; Conditions.<br />
				<strong>You may not install or use this software without confirming acceptance of the agreement.</strong><br />
				Please review the agreement and try again.</div>";
	}
	echo "<p>Please read the following terms and conditions carefully, before continuing:</p>\n";
	echo "<textarea rows=\"12\" cols=\"70\">";
	show_terms();
?>
	</textarea><br />
	<form method="post" action="install.php?page=1">
	  <label for="agree">I agree</label>
	  <input type="radio" name="license" id="license" value="agree" /><br />
	  <label for="disagree">I disagree</label>
	  <input type="radio" name="license" id="license" checked="checked" value="disagree" /><br />
	  <input type="submit" name="submit" class="textbutton" value="Continue" />
    </form>
<?php
	show_footer();
    exit;
}

function display_admin_reg_form($username='', $email='') {
?>
<form method="post" action="install.php?page=6" class="centreform">
<h2>Create your 'Administrator' User</h2>
<div class="formrow"><label for="email">Email address:</label></div>
<div class="formrow"><input type="text" name="email" id="email" <?php if(isset($email)) echo "value=\"".$email."\" "; ?>size="30" maxlength="100" /></div>
<div class="formrow"><label for="username">Preferred username (max 16 chars):</label></div>
<div class="formrow"><input type="text" name="username" id="username" <?php if(isset($username)) echo "value=\"".$username."\" "; ?> size="16" maxlength="16" /></div>
<div class="formrow"><label for="passwd">Password (between 6 and 16 chars):</label></div>
<div class="formrow"><input type="password" name="passwd" size="16" id="passwd" maxlength="16" /></div>
<div class="formrow"><label for="passwd2">Confirm password:</label></div>
<div class="formrow"><input type="password" name="passwd2" id="passwd2" size="16" maxlength="16" /></div>
<div class="formrow"><input type="submit" class="textbutton" value="Create User"></div>
</form>
<?php
}

function show_menu($active) {
	echo "<div id=\"menu\">";
	$nav = array('1' => 'Welcome',
				 '2' => 'Pre-Install Checks',
				 '3' => 'Create DB Tables',
				 '4' => 'Insert DB Data',
				 '5' => 'Create admin',
				 '6' => 'Finish');
	while(list($id, $data) = each($nav)) {
		if($id==$active) {
			echo "<p class=\"active\">".$data."</p><span class=\"hide\"> | </span>\n";
			$heading = "<h2>".$data."</h2>\n";
		}
		else {
			echo "<p class=\"inactive\">".$data."</p><span class=\"hide\"> | </span>\n";
		}
	}
	echo "</div>\n";
	echo $heading;
}

function display_txt_button($target, $text, $title) {
	echo "<a href=\"".$target."\" class=\"textbutton\" title=\"".$title."\">".$text."</a>\n";
}

function valid_email_address($address) {
  	// check an email address is possibly valid
  	if (ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $address)) {
    	return true;
  	}
  	else {
    	return false;
  	}
}
?>
Return current item: SelectaPix Image Gallery