<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- design by alec gorge -->
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Installer for LemurCMS</title>
<style type="text/css">
body {
	padding:0;
	margin:0;
	color:#555555;
	font:12px/22px "Lucida Grande",Verdana,"Bitstream Vera Sans",Arial,sans-serif;
}
h1, h2, h3, h4, h5, h6 {
	font-family:Georgia, Times, sans-serif;
	font-weight:normal;
}
h2 {
	font-size:2.3em;
	margin-top:0;
	margin-bottom:7px;
}
h3 {
	font-size:1.5em;
	color:#901414;
	margin-top:18px;
	font-style:italic;
	margin-bottom:5px;
}
p {
	margin:5px 0;
}
#wrapper {
	width:940px;
	margin:30px auto;
}
#head {
	height:81px;
}
#head h1 {
	line-height:81px;
	text-transform:lowercase;
	font-size:60px;
	padding-left:55px;
	padding-top:5px;
}
#head h1 span {
	font-size:20px;
}
#content-sidebar-wrapper {
	background:transparent url('themes/titlehere/inc/middle.png') repeat-y top center;
}
#content {
	background:transparent url('themes/titlehere/inc/top.png') no-repeat top left;
}
#sidebar {
	float:right;
	background:transparent url('themes/titlehere/inc/top.png') no-repeat top right;
	width:260px;
}
#sidebar p {
	text-align:justify;
	color:#777;
}
#sidebar #nav {
	margin:0;
	padding:5px 0 12px;
	list-style:none;
}
#sidebar #nav li {
	list-style:none;
	margin:2px 0;
}
#sidebar #nav li a {
	display:block;
	text-decoration:none;
	border:1px #E5e5e5 solid;
	border-width:1px 0;
	padding:2px 10px;
	color:#666;
}
#sidebar #nav li a:hover {
	color:black;
	border-color:#ccc;
	background:#fafafa;
}
#footer {
	background:transparent url('themes/titlehere/inc/footer.png') no-repeat top center;
}
#sidebar .gutter {
	padding-left:10px;
}
#content .gutter {
}
.gutter {
	padding:30px;
}
#footer {
	clear:both;
	height:40px;
	text-align:right;
}
#footer p {
	padding:0 30px;
	margin:0;
}
table {
	width:99%;
	margin:7px 0;
	border:1px #e5e5e5 solid;
}
thead tr td {
	padding:3px;
	border-bottom:1px #d8d8d8 solid;
	background:#f1f1f1;
	font-style:italic;
	color:#444;
	font-size:13px;
}
table td {
	padding:1px 3px;
	color:#666;
}
table tr.alt td {
	background:#f3f3f3;
}
ol {
	font-size:1em;
	font-style:italic;
	font-size:14px;
	color:#999;
}
ol p, ul p {
	font-style:normal;
	color:#555;
	font-size:12px;
	margin-top:0;
	margin-bottom:0;
}
.float-left {
	float:left;
}
.float-right {
	float:right;
}
#content img {
	border:1px #ddd solid;
	margin:4px 10px;
	padding:5px;
}
form {
 margin:0;
 padding:0;
 border:0;
}
fieldset {
	margin:10px;
	padding:5px;
	border:1px #e5e5e5 solid;
}
input, textarea {
	background:#E9EEF1;
	border:1px #ccc solid;
	padding:2px;
	margin:2px 1px 1px;
	color:#555;
	width:300px;
	font:12px/16px "Lucida Grande",Verdana,"Bitstream Vera Sans",Arial,sans-serif;
}
label {
	padding:1px 3px;
	text-align:right;
	margin:0 4px 0 0;
	display:block;
	float:left;
	color:#555;
	font-weight:bold;
	width:250px;
}
#form-page-new  input, #form-page-new label{
	float:none;
}
#form-page-new .form-row-last {
	padding:0;
}
.form-row, .form-row-last {
	padding:7px;
	border-bottom:1px #ccc dotted;
}
.form-row-last {
	padding-left:267px;
	border:0;
}
.form-row-last input {
	width:auto;
	padding:5px;
}
blockquote {
	font-weight:bold;
	font-style:italic;
	margin:15px 30px;
}
cite {
	text-align:right;
	font-style:normal;
	display:block;
}
h1, h2, h3, h4, h5, h6, a {
	color:#901414;
}
.success {
color:#0C6F03;
font-weight:bold;	
}
.small {font-size:smaller;padding-left:260px;}
.gray {color:gray;}
.error {
background:#FF8480 none repeat scroll 0 0;
display:block;
border:1px solid #F41C16;
clear:both;
margin-bottom:15px;
padding:5px;
}
.success, #cms-success-box p {
background:#8FE886 none repeat scroll 0 0;
border:1px solid #0C6F03;
clear:both;
margin-bottom:15px;
padding:5px;
display:block;
}

</style>
<script type="text/javascript" src="includes/admin/js/jquery-1.2.6.min.js"></script>
<script type="text/javascript" src="includes/admin/js/jquery.alphanumeric.js"></script>
<script type="text/javascript">
$(document).ready(function() {
	$('#pass, #cpass').alphanumeric();
	$('#user').alphanumeric({nocaps:true});
});
</script>
</head>

<body>
<div id="wrapper">
	<div id="head">
		<h1>Installer <span>for LemurCMS</span></h1>
	</div>
	<div id="content-sidebar-wrapper">
		<div id="content">
			<div class="gutter">
			<h2>Step One: System Requirements</h3>
			<p>Your server needs to meet certain requirements for LemurCMS run.</p>
			<ul>
				<li>You must have PHP version 5.1.</li>
				<li>PHP GD image library.</li>
				<li>PHP MySQL support.</li>
				<li>You must have a MySQL database version 5 or higher.</li>
			</ul>
			<p>It is recommended that you have the following</p>
			<ul>
				<li>An Apache server with mod_rewrite enabled.</li>			
			</ul>
			<?php
				$o = 1;
				if(phpversion() >= 5.1) {
					echo '<div class="success">You have PHP version '.phpversion().' which is high enough to run LemurCMS.</div>';
				}
				else {
					echo '<div class="error">You have PHP version '.phpversion().' which isn\'t high enough to run LemurCMS. Installation cannot continue.</div>';
					$o = 0;
				}
				if(function_exists("gd_info")) {
					$x = gd_info();
					$x = $x['GD Version'];
					$x = explode('bundled (', $x);
					$x = explode('compatible)', $x[1]);
					echo '<div class="success">You have the PHP GD image library version '.$x[0].' which is sufficent to run LemurCMS.</div>';
				}
				else {
					echo '<div class="error">You don\'t have the PHP GD image library which isn\'t sufficent to run LemurCMS. Installation cannot continue.</div>';
					$o = 0;
				}
				if(function_exists("mysql_query")) {
					echo '<div class="success">You have PHP MySQL support which is required for LemurCMS. You many not have version 5 so fill out the form below.</div>';
				}
				else {
					echo '<div class="error">You don\'t have PHP MySQL support which is required for LemurCMS. Installation cannot continue.</div>';
					$o = 0;
				}
				if($o == 1) {
			?>
			<h3>Step Two: Database Info</h3>
			<?php
				if($_POST['submit']) {
$dir=getcwd();
$parts = explode('/', $dir);
$count = count($parts);
$baseurl = '/'.$parts[$count-1].'/';
					$dbname = $_POST['dbname'];
					$dbhost = $_POST['dbhost'];
					$dbport = $_POST['dbport'];
					$dbuser = $_POST['dbuser'];
					$dbpass = $_POST['dbpass'];
					$dbpre = $_POST['dbpre'];
					$user = $_POST['user'];
					$pass = $_POST['pass'];
					$email = $_POST['email'];
					$cpass = $_POST['cpass'];
					$sitetitle = $_POST['sitetitle'];
					$siteauthor = $_POST['siteauthor'];
					$metadesc = $_POST['metadesc'];
					$metakey = $_POST['metakey'];
					$slogan = $_POST['slogan'];
					$cleanurls = $_POST['cleanurls'];
					$cleanUrls = $_POST['clean-urls'];
					$link = mysql_connect($dbhost.":".$dbport, $dbuser, $dbpass);
					if(!$link) {
					    echo '<div class="error">Could not connect to MySQL server: double check all your database settings</div>';	
					}
					else {
						$dbselect = mysql_select_db($dbname);
						if(!dbselect) {
							echo '<div class="error">Could not select database: double check all your database settings</div>';							
						}
						else {
							$link = @mysql_connect($db_host, $db_user, $db_pass);
							if (!$link)
							$qry = "SELECT VERSION()";
							$result = @mysql_query($qry);
							if (!$result) {
							   die("<font color='red'>Query error: " . mysql_error() . "</font>");
							}
							$ver = @mysql_result($result, 0);
							$ver = substr($ver, 0, 1);
							if($ver >= 5) {
								echo "<div class=\"success\">You have PHP MySQL version $ver support which is required for LemurCMS.</div>";
							}
							else {
								echo "<div class=\"error\">You have PHP MySQL version $ver support which is lower than version 5 which is required for LemurCMS. You usually have an option about the version of the database you are creating. If you are having problems, contact your host.</div>";
								exit();
							}
							@mysql_free_result($result);
							if($pass!=$cpass) {
								echo '<div class="error">The two passwords are not the same.</div>';							
							}
							else {
								$file = "config.php";
								$fh = fopen($file, 'a+') or die("can't open config.php, make sure it exists");
$stringData = '<?php
define("PAGE_LOAD_START", round(microtime(), 4));
define("DBHOST", "'.$dbhost.'");
define("DBUSER", "'.$dbuser.'");
define("DBPASS", "'.$dbpass.'");
define("DBNAME", "'.$dbname.'");
define("DBTABLEPREFIX", "'.$dbpre.'");
define("DBPORT", "'.$dbport.'");
define("MYSQL_NUM_QUERIES", 0);
define("MYSQL_QUERY_TIME", 0);
$system_content = "";
$system_header = "";
$base_pages = array("index.php", "admin.php", "test.php", "config.php");
$base_url[0] = getcwd()."/";
foreach($base_pages as $key => $value) {
	$base_url = explode($value, $base_url[0]);
}
$visual[0] = $_SERVER["REQUEST_URI"]."/";
foreach($base_pages as $key => $value) {
	$visual = explode($value, $visual[0]);
	$visual = preg_split("/content\/*\/*/", $visual[0]);
}
define("BASE_URL", $base_url[0]);
define("THEME_URL", $visual[0]);
?>';
								fwrite($fh, $stringData);
								fclose($fh);
									$file = ".htaccess";
									$string = "#
#BEGIN LemurCMS
#


# Hide .htaccess file from browser
<Files .htaccess>
order allow,deny
deny from all
</Files>


# Hide template files from browser
	<Files *.tpl>
		order allow,deny
		deny from all
	</Files>
	<Files *.inc>
		order allow,deny
		deny from all
	</Files>
	
	
#    The next group is from Drupal, and is meant to lay done a base
# Don't show directory listings for URLs which map to a directory.
Options -Indexes

# Follow symbolic links in this directory.
Options +FollowSymLinks

# Customized error messages.
ErrorDocument 404 /index.php

# Set the default handler.
DirectoryIndex index.php

# Override PHP settings. More in sites/default/settings.php
# but the following cannot be changed at runtime.

# PHP 4, Apache 1.
<IfModule mod_php4.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_value mbstring.encoding_translation   0
</IfModule>

# PHP 4, Apache 2.
<IfModule sapi_apache2.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_value mbstring.encoding_translation   0
</IfModule>

# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_value mbstring.encoding_translation   0
</IfModule>

# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
  # Enable expirations.
  ExpiresActive On
  # Cache all files for 2 weeks after access (A).
  ExpiresDefault A1209600
  # Do not cache dynamically generated pages.
  ExpiresByType text/html A1
</IfModule>

";
									$fh = fopen($file, 'a+') or die("can't open .htaccess, make sure it exists");
									fwrite($fh, $string);
									fclose($fh);
								if($cleanurls == 'Enabled') {
$string = "# CLEAN URLS
# The RewriteBase rule should be absolute from the public folder.
# If your public folder is /html/public_html/, and you have LemurCMS in a folder called lemurcms then then the line would like this:
# 	RewriteBase /lemurcms/
#
# Remove the pound signs from the next 5 lines to enable clean urls. You must have Apache with mod_rewrite for this to work otherwise it will through an error
<IfModule mod_rewrite.c>
	RewriteEngine on 
	RewriteBase ".$baseurl."
	RewriteRule content(\/.*) index.php 
</IfModule>";

									$file = ".htaccess";
									$fh = fopen($file, 'a+') or die("can't open .htaccess, make sure it exists");
									fwrite($fh, $string);
									fclose($fh);
								}

								else {
									$string = "#
# CLEAN URLS
# The RewriteBase rule should be absolute from the public folder.
# If your public folder is /html/public_html/, and you have LemurCMS in a folder called lemurcms then then the line would like this:
# 	RewriteBase /lemurcms/
#
# Remove the pound signs from the next 5 lines to enable clean urls. You must have Apache with mod_rewrite for this to work otherwise it will through an error.
#<IfModule mod_rewrite.c>
#	RewriteEngine on 
#	RewriteBase ".$baseurl."
#	RewriteRule content(\/.*) index.php 
#</IfModule>";
									$file = ".htaccess";
									$fh = fopen($file, 'a+') or die("can't open .htaccess, make sure it exists");
									fwrite($fh, $string);
									fclose($fh);
								
								}
if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
    chmod('temp/', 0777);
}
								mysql_query("CREATE TABLE IF NOT EXISTS `{$dbpre}content_pages` (
  `id` int(6) NOT NULL auto_increment,
  `title` varchar(255) NOT NULL default '',
  `content` longtext NOT NULL,
  `orderingid` int(11) NOT NULL default '0',
  `menutitle` varchar(255) NOT NULL default '',
  `parent_id` text NOT NULL,
  `time` varchar(251) NOT NULL,
  `notused1` varchar(251) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1") or die(mysql_error());$time = time();
								mysql_query("INSERT INTO `".$dbpre."content_pages` VALUES (1, 'The first page', 'Content goes here. Edit in admin page', 0, 'Home', '0', '{$time}', '')") or die(mysql_error());
								mysql_query("CREATE TABLE IF NOT EXISTS `".$dbpre."settings_site` (
							  `id` int(4) NOT NULL auto_increment,
							  `settingname` varchar(255) NOT NULL default '',
							  `description` varchar(255) NOT NULL default '',
							  `value` text NOT NULL,
							  `custom` text NOT NULL,
							  `notused2` text NOT NULL,
							  KEY `id` (`id`)
								) TYPE=MyISAM ") or die(mysql_error());
								mysql_query("INSERT INTO `".$dbpre."settings_site` VALUES (1, 'Site Name', 'This is the name of your site (ex. Example Online).', '".mysql_real_escape_string($sitetitle)."', '', '')") or die(mysql_error());
								mysql_query("INSERT INTO `".$dbpre."settings_site` VALUES (2, 'Author', 'Who is authoring this site (A name or organization).', '".mysql_real_escape_string($siteauthor)."', '', '')") or die(mysql_error());
								mysql_query("INSERT INTO `".$dbpre."settings_site` VALUES (3, 'Theme', 'The theme for the site.', 'titlehere', '', '')") or die(mysql_error());
								mysql_query("INSERT INTO `".$dbpre."settings_site` VALUES (4, 'Home Page Id', 'This is the id of the homepage', '1', '', '')") or die(mysql_error());
								mysql_query("INSERT INTO `".$dbpre."settings_site` VALUES (5, 'Meta Description', 'Choose about 20-30 words that describe your site.', '".mysql_real_escape_string($metadesc)."', '', '')") or die(mysql_error());
								mysql_query("INSERT INTO `".$dbpre."settings_site` VALUES (6, 'Meta Keywords', 'Write a keyword-laden sentence that describes what your site is about and your goals with the site.', '".mysql_real_escape_string($metakey)."', '', '')") or die(mysql_error());
								mysql_query("INSERT INTO `".$dbpre."settings_site` VALUES (6, 'Clean Urls', 'Clean Urls are like \"pages/14\" as opposed to \"?pages=14\". Enable this for better search engine visibility.', '".mysql_real_escape_string($cleanurls)."', '', '')") or die(mysql_error());
								mysql_query("INSERT INTO `".$dbpre."settings_site` VALUES (6, 'Slogan', 'This is a slogan like: \"We strive to provide great products\"', '".mysql_real_escape_string($slogan)."', '', '')") or die(mysql_error());
								mysql_query("
									CREATE TABLE IF NOT EXISTS `{$dbpre}users` (
									  `id` int(4) NOT NULL auto_increment,
									  `username` varchar(255) NOT NULL default '',
									  `password` varchar(255) NOT NULL default '',
									  `level` varchar(49) NOT NULL,
									  `email` text NOT NULL,
									  PRIMARY KEY  (`id`)
										) ENGINE=MyISAM  DEFAULT CHARSET=latin1") or die(mysql_error());
								mysql_query("INSERT INTO `".$dbpre."users` VALUES (1, '".$user."', '".sha1($pass)."', 'admin', '{$email}')") or die(mysql_error());
								mysql_query("CREATE TABLE IF NOT EXISTS `".$dbpre."content_template` (
								`id` int(4) NOT NULL auto_increment,
  `name` varchar(251) NOT NULL,
  `template` longtext NOT NULL,
  `content` longtext NOT NULL,
  `notused2` varchar(251) NOT NULL,
  `notused3` varchar(251) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
								") or die(mysql_error());
								mysql_query("
CREATE TABLE IF NOT EXISTS `{$dbpre}settings_system` (
  `id` bigint(20) NOT NULL,
  `settingname` varchar(251) NOT NULL,
  `description` text NOT NULL,
  `value` text NOT NULL,
  `notused1` varchar(251) NOT NULL,
  KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1") or die(mysql_error());
								mysql_query("INSERT INTO `{$dbpre}settings_system` (`id`, `settingname`, `description`, `value`, `notused1`) VALUES (0, 'Powered By', 'This is what will show up in the template where ever ($info.system.Powered By.value} is placed. Default is: Powered By LemurCMS', '<a href=\"\"><em>lemur cms</em></a>', '')") or die(mysql_error());
								echo '<div class="success">LemurCMS was successfully installed. View your site <a href="index.php?frominstaller=true">here</a> and go to the administration <a href="admin.php">here</a></div>';
								exit();
							}
						}
					}
				}
			?>
			<form action="#" method="post">
			<div class="form-row"><label for="dbname">Database Name</label><input type="text" name="dbname" value="<?php echo $_POST['dbname'] ?>" /></div>
			<div class="form-row"><label for="dbuser">Database Username</label><input type="text" name="dbuser" value="<?php echo $_POST['dbuser'] ?>" /></div>
			<div class="form-row"><label for="dbpass">Database Password</label><input type="password" name="dbpass" value="<?php echo $_POST['dbpass'] ?>" /></div>
			<div class="form-row"><label for="dbhost">Database Host (usually localhost)</label><input type="text" name="dbhost" value="<?php if($_POST){echo $_POST['dbhost'];}else{echo'localhost';} ?>"/></div>
			<div class="form-row"><label for="dbport">Database Port (usally 3306)</label><input type="text" name="dbport" value="<?php if($_POST){echo $_POST['dbport'];}else{echo'3306';} ?>" /></div>
			<div class="form-row"><label for="dbpre">Database Table Prefix</label><input type="test" name="dbpre" value="<?php if($_POST){echo $_POST['dbpre'];}else{echo'".$dbpre."';} ?>" /><p class="small gray">(What will come before each table ex. "cms_")</p></div>
			<h3>Step Three: Create the first user</h3>
			<div class="form-row"><label for="user">Username</label><input type="text" name="user" id='user' value="<?php echo $_POST['user'] ?>" /><p class="small gray">Lowercase, alphanumeric only please!</p></div>
			<div class="form-row"><label for="pass">Password</label><input type="password" name="pass" id='pass' value="<?php echo $_POST['pass'] ?>" /><p class="small gray">Alphanumeric only please!</p></div>			
			<div class="form-row"><label for="cpass">Confirm Password</label><input type="password" name="cpass" id='cpass' value="<?php echo $_POST['cpass'] ?>" /><p class="small gray">Alphanumeric only please!</p></div>
			<div class="form-row"><label for="email">Email</label><input type="text" name="email" value="<?php echo $_POST['email'] ?>" /></div>			
			<h3>Step Four: Site Information</h3>
			<div class="form-row"><label for="sitetitle">Site Title (Example: Example Online)</label><input type="text" name="sitetitle" value="<?php echo $_POST['sitetitle'] ?>" /></div>			
			<div class="form-row"><label for="siteauthor">Site Author (Example: John Doe)</label><input type="text" name="siteauthor" value="<?php echo $_POST['siteauthor'] ?>" /></div>			
			<div class="form-row"><label for="slogan">Site Slogan (Example: We strive...)</label><input type="text" name="slogan" value="<?php echo $_POST['siteslogan'] ?>" /></div>			
			<div class="form-row"><label for="metadesc">Site Meta Description</label><input type="text" name="metadesc" value="<?php echo $_POST['metadesc'] ?>" /><p class="small gray">Write a keyword-laden sentence that describes what your site is about and your goals with the site.</p></div>			
			<div class="form-row"><label for="metakey">Site Meta Keywords</label><input type="text" name="metakey" value="<?php echo $_POST['metakey'] ?>" /><p class="small gray">Choose about 20-30 words that describe your site.</p></div>			
			<div class="form-row"><label for="cleanurls">Clean Urls</label><select name='cleanurls'><option>Enabled</option><option>Disabled</option></select><p class="small gray">Please only enable this if you are positive that your server supports mod_rewrite.</p></div>			
			<div class="form-row-last"><input type='hidden' name='cleanUrls' value='<?php echo $o ?>' /><input type="submit" value="Submit" name="submit"/></div>
			</form>
			<?php
			}
			?>
			</div>			
		</div>
		<div id="footer">
			<p>design by alec gorge</p>
		</div>
	</div>
</div>
</body>

</html>





<!-- design by alec gorge -->