Location: PHPKode > projects > Horizon Blogging Software > install/index.php
<?php
if(!isset($_POST['i']) || empty($_POST['i'])) {
	$id = 0;
} else {
	$id = intval($_POST['i']);
}
$nid = $id;
$nid++;
function head2() {
	echo '<html>
	<head>
	<title>Install Horizon Blogging Software</title>
	<style type="text/css">
	<!--
	.style1 {
		font-family: Verdana, Arial, Helvetica, sans-serif;
		font-size: 16px;
		font-weight: bold;
	}
	.style2 {
		font-family: Verdana, Arial, Helvetica, sans-serif;
		font-size: 12px;
	}
	.style3 {
		font-family: Verdana, Arial, Helvetica, sans-serif;
		font-size: 10px;
		color: #666666;
	}
	-->
	</style>
	</head>
	<body>
	<div align="center"><div style="width:500px; padding-left:20px; padding-right:20px; background:#F5F5F5; border:1px solid #C0C0C0;">
    <center><br /><div style="text-align:justify;">
	<div style="letter-spacing:-.5px; padding-left:8px; font-size:30px; color:#0066CC;">Install...</div>
	<form action="' . $_SERVER['PHP_SELF'] . '" method="POST">
	<p align="center" class="style2">';
}
function foot() {
	if(!isset($_POST['i']) || empty($_POST['i'])) {
		$id = 0;
	} else {
		$id = intval($_POST['i']);
	}
	$nid = $id;
	$nid++;
	echo '</p><form action="' . $_SERVER['PHP_SELF'] . '" method="POST">
	  <div align="center">
	  	<input type="hidden" name="i" value="' . $nid . '">
	    ';
		if(intval($id) < 8)
			echo '<input type="submit" name="" value="Next >">';
		
		echo '
      </div>
	</form></p>
	<p align="center" class="style3">Copyright &copy; 2007 Edge Drive; All Rights Reserved.</p>
	</div></center>
		</div></div>
	</body>
	</html>';
}

head2();
if($id == 0) {
	?>
	Thank you for choosing Horizon Blogging Software for your blogging purposes today. Before you start installing, it would be a good
	idea to check your MySQL settings so you have them ready when you are asked to enter them. If you are ready to continue installing
	Horizon Blogging Software, press the 'Next >' below.
	<?php
} elseif($id == 1) {
	?>
	Horizon Blogging Software is licensed under a Creative Commons License Agreement. Please review the text below.<br /><br />
	
	<textarea cols="50" rows="23" style="background-color:#FFFFCE">THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.

BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.

1. Definitions

   1. "Collective Work" means a work, such as a periodical issue, anthology or encyclopedia, in which the Work in its entirety in unmodified form, along with a number of other contributions, constituting separate and independent works in themselves, are assembled into a collective whole. A work that constitutes a Collective Work will not be considered a Derivative Work (as defined below) for the purposes of this License.
   2. "Derivative Work" means a work based upon the Work or upon the Work and other pre-existing works, such as a translation, musical arrangement, dramatization, fictionalization, motion picture version, sound recording, art reproduction, abridgment, condensation, or any other form in which the Work may be recast, transformed, or adapted, except that a work that constitutes a Collective Work will not be considered a Derivative Work for the purpose of this License. For the avoidance of doubt, where the Work is a musical composition or sound recording, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered a Derivative Work for the purpose of this License.
   3. "Licensor" means the individual or entity that offers the Work under the terms of this License.
   4. "Original Author" means the individual or entity who created the Work.
   5. "Work" means the copyrightable work of authorship offered under the terms of this License.
   6. "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation.

2. Fair Use Rights. Nothing in this license is intended to reduce, limit, or restrict any rights arising from fair use, first sale or other limitations on the exclusive rights of the copyright owner under copyright law or other applicable laws.

3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below:

   1. to reproduce the Work, to incorporate the Work into one or more Collective Works, and to reproduce the Work as incorporated in the Collective Works;
   2. to distribute copies or phonorecords of, display publicly, perform publicly, and perform publicly by means of a digital audio transmission the Work including as incorporated in Collective Works.
   3.

      For the avoidance of doubt, where the work is a musical composition:
         1. Performance Royalties Under Blanket Licenses. Licensor waives the exclusive right to collect, whether individually or via a performance rights society (e.g. ASCAP, BMI, SESAC), royalties for the public performance or public digital performance (e.g. webcast) of the Work.
         2. Mechanical Rights and Statutory Royalties. Licensor waives the exclusive right to collect, whether individually or via a music rights society or designated agent (e.g. Harry Fox Agency), royalties for any phonorecord You create from the Work ("cover version") and distribute, subject to the compulsory license created by 17 USC Section 115 of the US Copyright Act (or the equivalent in other jurisdictions).
   4. Webcasting Rights and Statutory Royalties. For the avoidance of doubt, where the Work is a sound recording, Licensor waives the exclusive right to collect, whether individually or via a performance-rights society (e.g. SoundExchange), royalties for the public digital performance (e.g. webcast) of the Work, subject to the compulsory license created by 17 USC Section 114 of the US Copyright Act (or the equivalent in other jurisdictions).

The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats, but otherwise you have no rights to make Derivative Works. All rights not expressly granted by Licensor are hereby reserved.

4. Restrictions.The license granted in Section 3 above is expressly made subject to and limited by the following restrictions:

   1. You may distribute, publicly display, publicly perform, or publicly digitally perform the Work only under the terms of this License, and You must include a copy of, or the Uniform Resource Identifier for, this License with every copy or phonorecord of the Work You distribute, publicly display, publicly perform, or publicly digitally perform. You may not offer or impose any terms on the Work that alter or restrict the terms of this License or the recipients' exercise of the rights granted hereunder. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties. You may not distribute, publicly display, publicly perform, or publicly digitally perform the Work with any technological measures that control access or use of the Work in a manner inconsistent with the terms of this License Agreement. The above applies to the Work as incorporated in a Collective Work, but this does not require the Collective Work apart from the Work itself to be made subject to the terms of this License. If You create a Collective Work, upon notice from any Licensor You must, to the extent practicable, remove from the Collective Work any credit as required by clause 4(b), as requested.
   2. If you distribute, publicly display, publicly perform, or publicly digitally perform the Work or Collective Works, You must keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or (ii) if the Original Author and/or Licensor designate another party or parties (e.g. a sponsor institute, publishing entity, journal) for attribution in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; the title of the Work if supplied; and to the extent reasonably practicable, the Uniform Resource Identifier, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work. Such credit may be implemented in any reasonable manner; provided, however, that in the case of a Collective Work, at a minimum such credit will appear where any other comparable authorship credit appears and in a manner at least as prominent as such other comparable authorship credit.

5. Representations, Warranties and Disclaimer

UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE MATERIALS, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.

6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

7. Termination

   1. This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Collective Works from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License.
   2. Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above.

8. Miscellaneous

   1. Each time You distribute or publicly digitally perform the Work, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License.
   2. If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
   3. No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent.
   4. This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You.
      </textarea>
	  <br /><br />To sum that up, you are allowed to modify Horizon Blogging Software (including skinning and editing PHP files) but you must keep all of the copyright information in the software. If you agree to the license above, please press 'Next >'.
	<?php
} elseif($id == 2) {
	?>
	This is where we need your MySQL credentials. MySQL allows Horizon Blogging Software to save your blog data to your server.</p>
	<p align="center" class="style2">For the following three fields, you must create or use an existing MySQL
	  user on your server, create a new database, and add the user with "ALL" privileges with
	  the database you just created. Then fill in the proper information below. </p>
	<center><table algin="center"><tr><td>MySQL Username:</td><td>
	  <input name="mysql_user" type="text" id="mysql_user" size="30">
      </tr></td>
	<tr><td>MySQL Password:</td><td>
    <input name="mysql_pass" type="password" id="mysql_pass" size="30">
     </tr></td>
    <tr><td>MySQL Database Name:</td><td>
    <input name="mysql_db" type="text" id="mysql_db" value="horizon" size="30">
	</tr></td>
	<tr><td>Preferred Database Prefix:</td><td>
    <input name="mysql_prefix" type="text" id="mysql_prefix" value="horizon_" size="30">
    </tr></td>
	<tr><td>MySQL Address/Host:</td><td>
    <input name="mysql_addr" type="text" id="mysql_addr" value="localhost" size="30"> 
	</tr></td></table>
    <span class="style3">(If you don't know what this is, don't change it)</span></p></center>
	<p align="center" class="style2">Press &quot;Next&quot; to perform a MySQL connection test. </p>
	<?php
} elseif($id == 3) {
	echo 'Performing connection test - ';
	$addr = $_POST['mysql_addr'];
	$user = $_POST['mysql_user'];
	$pass = $_POST['mysql_pass'];
	$db = $_POST['mysql_db'];
	$prefix = $_POST['mysql_prefix'];
	
	mysql_connect($addr, $user, $pass) or die("<font color=red>Sorry, Horizon Blogging Software couldn't connect to your MySQL.Please hit the 'back' button on your browser and review your MySQL credentials.<br /><br />MySQL said: <i>" . mysql_error() . "</i></font>");
	echo '<font color=green>Connected</font><br />Selecting database - ';
	mysql_select_db($db) or die("<font color=red>Sorry, the database you provided could not be selected by MySQL. Hit the Back button on your browser and fix your MySQL credentials.<br /><br />MySQL said: <i>" . mysql_error() . "</i></font>");
	echo '<font color=green>Selected database</font><br />Attempting to create a table for testing purposes - ';
	$res = mysql_query("CREATE TABLE `test` (
`test` TINYINT NOT NULL 
)");
	if(!$res) {
		die("<font color=red>Failed</font>");
		exit;
	}
	echo '<font color=green>Test table created</font><br />Attempting to delete test table - ';
	$res = mysql_query("DROP TABLE `test`;");
	if(!$res) {
		die("<font color=red>Failed</font>");
		exit;
	}
	echo '<font color=green>Test table deleted</font><br /><br /><b>Your database is ready for Horizon Blogging Software. Click Next to proceed.</b>';
	
	/* gotta rememebr the vars for step 5 */
	echo '<input type="hidden" name="mysql_addr" value="' . $addr . '">';
	echo '<input type="hidden" name="mysql_user" value="' . $user . '">';
	echo '<input type="hidden" name="mysql_pass" value="' . $pass . '">';
	echo '<input type="hidden" name="mysql_db" value="' . $db . '">';
	echo '<input type="hidden" name="mysql_prefix" value="' . $prefix . '">';
	
} elseif($id == 4) {

	/* gotta rememebr the vars for step 5 */
	$addr = $_POST['mysql_addr'];
	$user = $_POST['mysql_user'];
	$pass = $_POST['mysql_pass'];
	$db = $_POST['mysql_db'];
	$prefix = $_POST['mysql_prefix'];
	echo '<input type="hidden" name="mysql_addr" value="' . $addr . '">';
	echo '<input type="hidden" name="mysql_user" value="' . $user . '">';
	echo '<input type="hidden" name="mysql_pass" value="' . $pass . '">';
	echo '<input type="hidden" name="mysql_db" value="' . $db . '">';
	echo '<input type="hidden" name="mysql_prefix" value="' . $prefix . '">';


	echo 'Inserting database information<br /><br />';
	
		mysql_connect($addr, $user, $pass) or die("<font color=red>Sorry, connection failed. Hit the Back button on your browser and fix your MySQL credentials.<br /><br />MySQL said: <i>" . mysql_error() . "</i></font>");
		mysql_select_db($db) or die("<font color=red>Sorry, the database you provided could not be selected by MySQL. Hit the Back button on your browser and fix your MySQL credentials.<br /><br />MySQL said: <i>" . mysql_error() . "</i></font>");
	
	
	$sql = "CREATE TABLE " . $prefix . "main (
	  id int(20) NOT NULL auto_increment,
	  timestamp int(20) NOT NULL,
	  title varchar(255) NOT NULL,
	  entry longtext NOT NULL,
	  PRIMARY KEY  (id),
	  UNIQUE KEY id (id)
	)";
	
	$result = mysql_query($sql) or die("<font color=red>Can't create the table '" . $prefix . "main' in the database.
	  </p></font><br /><b>If you have already installed Horizon Blogging Software in this database, you must create a new database to install a fresh copy of Horizon Blogging Software.</b> <br /><br />" . $sql . " <br />" . mysql_error());
	if ($result != false) {
		echo "Table '" . $prefix . "main' was successfully created.<br />";
	}
	
	$com = "CREATE TABLE " . $prefix . "comments (
	  id int(20) NOT NULL auto_increment,
	  entry int(20) NOT NULL,
	  name varchar(255) NOT NULL,
	  email varchar(255) NOT NULL,
	  url varchar(255) NOT NULL,
	  comment longtext NOT NULL,
	  timestamp int(20) NOT NULL,
	  PRIMARY KEY  (id),
	  UNIQUE KEY id (id)
	)";
	
	$result = mysql_query($com) or die( "<br />Can't create the table '" . $prefix . "comments' in the database.<br /><br /> " . $com . "<br />" . mysql_error());
	if ($result != false) {
		echo "Table '" . $prefix . "comments' was successfully created.<br />";
	}
	
	$com = "CREATE TABLE `" . $prefix . "config` (
	`id` INT( 20 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
	`title` MEDIUMTEXT NOT NULL ,
	`subtitle` MEDIUMTEXT NOT NULL ,
	`a_user` MEDIUMTEXT NOT NULL ,
	`a_pass` VARCHAR( 128 ) NOT NULL,
	`template` VARCHAR( 100 ) NOT NULL
	)";
	
	$result = mysql_query($com) or die( "<br />Can't create the table '" . $prefix . "config' in the database.<br /><br /> " . $com . "<br />" . mysql_error());
	if ($result != false) {
		echo "Table '" . $prefix . "config' was successfully created.<br />";
	}
	
	$cal = "CREATE TABLE " . $prefix . "calendar (
	  event_id int(11) primary key auto_increment,
	  event_date date not null,
	  event_title varchar(50) not null,
	  event_desc text
	)";
	
	$result = mysql_query($cal) or die("<br />Can't create the table '" . $prefix . "calendar' in the database.<br /><br />" . $cal . "<br />" . mysql_error());
	
	if ($result != false) {
		echo "Table '" . $prefix . "calendar' was successfully created.<br /><br />";
	}

	echo '<br />You have finished the main part of the installation! Please press Next > to completly finish installing.';
	
} elseif($id == 5) {
	/* gotta rememebr the vars for step 5 */
	$addr = $_POST['mysql_addr'];
	$user = $_POST['mysql_user'];
	$pass = $_POST['mysql_pass'];
	$db = $_POST['mysql_db'];
	$prefix = $_POST['mysql_prefix'];
	echo '<input type="hidden" name="mysql_addr" value="' . $addr . '">';
	echo '<input type="hidden" name="mysql_user" value="' . $user . '">';
	echo '<input type="hidden" name="mysql_pass" value="' . $pass . '">';
	echo '<input type="hidden" name="mysql_db" value="' . $db . '">';
	echo '<input type="hidden" name="mysql_prefix" value="' . $prefix . '">';
	?>
	Before continuting the installation, please <a href="http://en.wikipedia.org/wiki/Chmod">CHMOD</a> the inc/ directory to <b>777</b> and this file, install/index.php, to <b>777</b>.
	<?php
} elseif($id == 6) {
	$addr = $_POST['mysql_addr'];
	$user = $_POST['mysql_user'];
	$pass = $_POST['mysql_pass'];
	$db = $_POST['mysql_db'];
	$prefix = $_POST['mysql_prefix'];
	echo '<input type="hidden" name="mysql_addr" value="' . $addr . '">';
	echo '<input type="hidden" name="mysql_user" value="' . $user . '">';
	echo '<input type="hidden" name="mysql_pass" value="' . $pass . '">';
	echo '<input type="hidden" name="mysql_db" value="' . $db . '">';
	echo '<input type="hidden" name="mysql_prefix" value="' . $prefix . '">';
	$base_dir = str_replace('install/index.php','',__FILE__);
	$towrite = '<?php
/**********************************\
|    HORIZON BLOGGING SOFTWARE     |
|            EDGE DRIVE            |
|    Page: cfg.php                 |
|    Author: Spike                 |
|    Dynamically Created Page,     |
|    Do Not Edit                   |
\**********************************/

// -------------------------------- \\
// CHANGE THESE VALUES TO REFLECT
// YOUR MYSQL DATABASE CREDENTIALS.
// -------------------------------- \\
$mysql = array();

// Your username, password, and database
// for your MySQL database.
$mysql["username"] = "' . $user . '";
$mysql["password"] = "' . $pass . '";
$mysql["db"] = "' . $db . '";

// Don\'t change these unless you know
// what it does or were instructed to
// by a Horizon representative.
$mysql["hostname"] = "' . $addr . '";
$mysql["db_prefix"] = "' . $prefix . '";
define(\'BASE_DIR\',\''.$base_dir.'\');
?>';
	
	echo 'Writing configuration file, "inc/cfg.php".<br />';
	if(file_exists('../inc/cfg.php')) {
		echo 'Previous cfg.php found, deleting...';
		if(!unlink('../inc/cfg.php')) {
			echo 'File deletion failed, please manually delete.';
			exit;
		}
		echo 'Deleted.<br />';
	echo 'Resuming file write...';	
	}
	$rsc = fopen("../inc/cfg.php","a");
	if(!$rsc) {
		echo 'The dynamically create page, inc/cfg.php failed to be created. Please make sure everything has been< a href="http://en.wikipedia.org/wiki/Chmod">CHMODDED</a>.';
		exit;
	}
	$rsc = fwrite($rsc, $towrite);
	@fclose($rsc);
	echo 'File inc/cfg.php written.<br /><br />Continue to the next step.';
} elseif($id == 7) {
	$addr = $_POST['mysql_addr'];
	$user = $_POST['mysql_user'];
	$pass = $_POST['mysql_pass'];
	$db = $_POST['mysql_db'];
	$prefix = $_POST['mysql_prefix'];
	echo '<input type="hidden" name="mysql_addr" value="' . $addr . '">';
	echo '<input type="hidden" name="mysql_user" value="' . $user . '">';
	echo '<input type="hidden" name="mysql_pass" value="' . $pass . '">';
	echo '<input type="hidden" name="mysql_db" value="' . $db . '">';
	echo '<input type="hidden" name="mysql_prefix" value="' . $prefix . '">';
	?>
	</p>
	<p align="center" class="style2">Please fill in your desired blog settings now. They can be edited later in your blog control panel.</p>
	<table align="center"><tr><td>Blog Title:</td><td>
	  <input name="title" type="text" id="title" value="Horizon Blog" size="30">
      </tr></td>
	<tr><td>Blog Subtitle: </td><td>
    <input name="subtitle" type="text" id="subtitle" value="The Dawn Of New Blogging Software" size="30">
    </tr></td>
	<tr>
	<td>Blog template: </td><td><input type="text" name="template" value="default"/></td>
	</tr>
     <tr><td>Admin Username:</td><td>
    <input name="admin" type="text" id="admin" value="admin" size="30">
    </tr></td>
    <tr><td>Admin Password:</td><td>
    <input name="pass" type="password" id="pass" size="30">
    </tr></td>
    <tr><td>Retype Password:</td><td>
    <input name="pass2" type="password" id="pass" size="30">
	</tr></td></table>
	<p align="center" class="style2">Press 'Next >' to save the changes.
	<?php
} elseif($id == 8) {
	$addr = $_POST['mysql_addr'];
	$db = $_POST['mysql_db'];
	$prefix = $_POST['mysql_prefix'];
	echo '<input type="hidden" name="mysql_addr" value="' . $addr . '">';
	echo '<input type="hidden" name="mysql_user" value="' . $user . '">';
	echo '<input type="hidden" name="mysql_pass" value="' . $pass . '">';
	echo '<input type="hidden" name="mysql_db" value="' . $db . '">';
	echo '<input type="hidden" name="mysql_prefix" value="' . $prefix . '">';

	$title = $_POST['title'];
	$subtitle = $_POST['subtitle'];
	$template = $_POST['template'];
	$user = $_POST['admin'];
	$pass = md5($_POST['pass']);
	$pass2 = md5($_POST['pass2']);
	if(empty($user) || empty($pass) || empty($pass2) || empty($title)) {
		echo 'You left a required field blank, Please click the back button in your browser and make sure all fields have data in them.';
		exit;
	}
	if($pass !== $pass2) {
		echo 'Passwords do not match. Please click the back button in your browser and retype the passwords.';
		exit;
	}
	echo 'Connecting to MySQL database... <br /><br />';
	include_once('../inc/cfg.php');
	mysql_connect($mysql["hostname"], $mysql["username"], $mysql["password"]) or
		die("Cannot connect to your database. MySQL gave this reason: <b>" . mysql_error() . "</b>");
	mysql_select_db($mysql["db"]) or
		die("Your database is invalid. MySQL gave this reason: <b>" . mysql_error() . "</b>");
		
	$sql = "INSERT INTO `" . $mysql["db_prefix"] . "config`
	(`title`, `subtitle`, `a_user`, `a_pass`,`template`) VALUES
	('$title', '$subtitle', '$user', '$pass','$template');";
	$res = mysql_query($sql) or die("There was an error, sorry. MySQL said: <i>" . mysql_error() . "</i>");
    $timestamp = strtotime($month . " " . $date . " " . $year . " " . $time);
	$title = 'Welcome to your blog!';
	$entry = "	
	You have successfully installed Horizon Blogging Software! You can delete this message in your administrator control panel under edit.<br />";
    $sql = "INSERT INTO " . $mysql["db_prefix"] . "main (timestamp,title,entry) VALUES ('$timestamp','$title','$entry')";
	$res = mysql_query($sql) or die("There was an error, sorry. MySQL said: <i>" . mysql_error() . "</i>");
	echo 'You have just installed Horizon Blogging Software!<br /><br /><b>PLEASE DELETE THE INSTALL DIRECTORY BEFORE USING YOUR BLOG.</b><br />(you can delete /install while viewing this page)<br /><br />You can now <a href="../">visit your blog!</a>';
}																	
foot();
// Phew, finally! The end!
?>
Return current item: Horizon Blogging Software