<?php
$install = "yes";
include ("config.php");

if ($_GET['step'] == "") {
eval (" ?> ".admin_header()." <?php ");
?>
<script>
//"Accept terms" form submission- By Dynamic Drive
//For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
//This credit MUST stay intact for use

var checkobj

function agreesubmit(el){
checkobj=el
if (document.all||document.getElementById){
for (i=0;i<checkobj.form.length;i++){  //hunt down submit button
var tempobj=checkobj.form.elements[i]
if(tempobj.type.toLowerCase()=="submit")
tempobj.disabled=!checkobj.checked
}
}
}

function defaultagree(el){
if (!document.all&&!document.getElementById){
if (window.checkobj&&checkobj.checked)
return true
else{
alert("Please read/accept terms to continue to next step.")
return false
}
}
}

</script>
<title>AdaptCMS Lite - Install</title>
<form method="post" action="install.php?step=form" name="agreeform" onSubmit="return defaultagree(this)">
<textarea name='terms' cols='58' rows='7'>INSANE VISIONS SCRIPTS USAGE TERMS
AdaptCMS Lite is a copyrighted work of authorship and is also protected under applicable laws. Insane Visions retains ownership of the original software code. By installing and using AdaptCMS Lite on your server you agree to the following terms and conditions:

1. You agree to the GPL License.
2. You may not sell AdaptCMS Lite in any way, or even trade it for another product/service.
3. You may not claim ownership of AdaptCMS Lite or modify it and claim it as our own.
4. If any of these terms are broken we reserve the right to report there website to there host and any other method deemed necessary.
5. You agree NOT to remove any copyright notices. If you do, please replace it with an image or some sort of link or notice, noting copyright of AdaptCMS Lite.
6. You may modify and re-distribute AdaptCMS Lite with proper copyright given.

Be sure for the latest agreement policy to go to adaptcms.com</textarea><br />
<input name="agreecheck" type="checkbox" onClick="agreesubmit(this)"><b>I agree to the above terms</b><br />
<input type="Submit" value="Submit!" style='font-family: tahoma; font-size: 11px; border: 1px solid #444444' disabled>
</form>

<script>
document.forms.agreeform.agreecheck.checked=false
</script>
<?php
}

if ($_GET['step'] == "form" && $_POST['agreecheck']) {
eval (" ?> ".admin_header()." <?php ");
require("dbinfo.php");

if ($dbhost == "cms_dbhost") {
} else {
$form[1] = " value='".$dbhost."'";
}

if ($dbname == "cms_dbname") {
} else {
$form[2] = " value='".$dbname."'";
}

if ($dbuser == "cms_dbuser") {
} else {
$form[3] = " value='".$dbuser."'";
}

if ($dbpass == "cms_dbpass") {
} else {
$form[4] = " value='".$dbpass."'";
}

echo "<title>AdaptCMS Lite - Installation Form</title><form action='install.php?step=install' method='post'><table cellpadding='10' cellspacing='3' border='0'><tr><td>&nbsp;</td><td><h2>MySQL Information</h2></td></tr>";

echo "<tr><td><b>Table Prefix</b></td><td><input type='text' name='pre' value='".$pre."' style='font-family: tahoma; font-size: 11px; border: 1px solid #444444'></td></tr><tr><td><b>Database Host</b></td><td><input type='text' name='dbhost'".$form[1]." value='localhost' style='font-family: tahoma; font-size: 11px; border: 1px solid #444444'></td></tr><tr><td><b>Database Name</b></td><td><input type='text' name='dbname'".$form[2]." style='font-family: tahoma; font-size: 11px; border: 1px solid #444444'></td></tr><tr><td><b>Database Username</b></td><td><input type='text' name='dbuser'".$form[3]." style='font-family: tahoma; font-size: 11px; border: 1px solid #444444'></td></tr><tr><td><b>Database Password</b></td><td><input type='text' name='dbpass'".$form[4]." style='font-family: tahoma; font-size: 11px; border: 1px solid #444444'></td></tr>";

echo "<tr><td>&nbsp;</td><td><h2>Admin Account</h2></td></tr><tr><td><b>Username</b></td><td><input type='text' name='username' style='font-family: tahoma; font-size: 11px; border: 1px solid #444444'></td></tr><tr><td><b>Password</b></td><td><input type='text' name='password' style='font-family: tahoma; font-size: 11px; border: 1px solid #444444'></td></tr><tr><td><b>E-Mail</b></td><td><input type='text' name='email' style='font-family: tahoma; font-size: 11px; border: 1px solid #444444'></td></tr>";

echo "<tr><td>&nbsp;</td><td><h2>Your Website</h2></td></tr><tr><td><b>Site Name</b></td><td><input type='text' name='sitename' style='font-family: tahoma; font-size: 11px; border: 1px solid #444444' value='AdaptCMS Website'></td></tr>";

echo "<tr><td><input type='submit' name='submit' value='Install' style='font-family: tahoma; font-size: 11px; border: 1px solid #444444'>&nbsp;&nbsp;<input type='submit' name='submit' value='Upgrade' style='font-family: tahoma; font-size: 11px; border: 1px solid #444444'></td><td>&nbsp;</td></tr></table></form>";
}

if ($_GET['step'] == "upgrade_1.3") {
include ("dbinfo.php");
@mysql_select_db($dbname, @mysql_connect($dbhost, $dbuser, $dbpass));
eval (" ?> ".admin_header()." <?php ");
echo "<title>AdaptCMS Lite - Upgrade</title>";
$error = 0;

if (mysql_query("UPDATE `".$pre."plugins` SET version = '1.2' WHERE name = 'RSS Importer'") == TRUE && mysql_query("UPDATE `".$pre."plugins` SET version = '1.1' WHERE name = 'Shoutbox'") == TRUE) {
echo "`".$pre."plugins` MySQL data row #1-2 Updated? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."plugins` MySQL data row #1-2 Updated? <font color='red'>False</font><br />";
}

if (mysql_query("INSERT INTO `".$pre."plugins` VALUES (null, 'TinyURL', 'tinyurl.php', '1.0', 'On')") == TRUE && mysql_query("INSERT INTO `".$pre."plugins` VALUES (null, 'Form Builder', 'form_builder.php', '1.0', 'On')") == TRUE) {
echo "`".$pre."plugins` MySQL data row #1-2 Inserted? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."plugins` MySQL data row #1-2 Inserted? <font color='red'>False</font><br />";
}

$content_ht = "RewriteEngine On
RewriteBase ".str_replace($apage, "", $_SERVER['PHP_SELF'])."
RewriteCond %{HTTP_HOST} !^www\..* [NC]
RewriteCond %{HTTP_HOST} !^[0-9]+\.[0-9]+\..+ [NC]
RewriteRule ^([^/]+) http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

ErrorDocument 404 ".str_replace($apage, "", $_SERVER['PHP_SELF'])."index.php?view=error&type=404

# Mod_Rewrite for AdaptCMS v1.1-1.4
RewriteRule ^archive/?$ index.php?view=list
RewriteRule ^archive/([^/]+)/letter/([^/]+)/?$ index.php?view=list&cat=$1&abc=$2
RewriteRule ^archive/letter/([^/]+)/?$ index.php?view=list&abc=$1
RewriteRule ^archive/(.*)/?$ index.php?view=list&cat=$1
RewriteRule ^article/([0-9]+)/([^/]+)/trackback?$ index.php?view=trackback&id=$1
RewriteRule ^article/([0-9]+)/([^/]+)/([^/]+)/trackback?$ index.php?view=trackback&id=$1
RewriteRule ^article/([0-9]+)/([^/]+)/?$ index.php?view=article&id=$1
RewriteRule ^article/([0-9]+)/([^/]+)/([^/]+)/?$ index.php?view=article&id=$1
RewriteRule ^article/([0-9]+)/([^/]+)/page/([0-9]+)/?$ index.php?view=article&id=$1&page=$3
RewriteRule ^article/([0-9]+)/([^/]+)/([^/]+)/page/([0-9]+)/?$ index.php?view=article&id=$1&page=$4
RewriteRule ^category/([^/]+)/?$ index.php?view=list&cat=$1
RewriteRule ^feed/([^/]+)/?$ index.php?view=rss&section=$1
RewriteRule ^gallery/([0-9]+)/([^/]+)/?$ index.php?view=gallery&id=$1
RewriteRule ^page/([^/]+)/?$ index.php?view=page&id=$1
RewriteRule ^rss/([^/]+)/([^/]+)-([^/]+)/?$ index.php?view=rss&section=$1&field=$2&data=$3
RewriteRule ^rss/([^/]+)-([^/]+)/?$ index.php?view=rss&field=$1&data=$2
RewriteRule ^rss/([^/]+)/?$ index.php?view=rss&section=$1
RewriteRule ^section/([^/]+)/([^/]+)-([^/]+)/?$ index.php?view=list&cat=$1&field=$2&data=$3
RewriteRule ^section/([^/]+)-([^/]+)/?$ index.php?view=list&field=$1&data=$2
RewriteRule ^section/([^/]+)/?$ index.php?view=list&cat=$1
RewriteRule ^user/([^/]+)/?$ index.php?view=profile&user=$1

RewriteRule ^affiliates/?$ index.php?view=affiliates
RewriteRule ^affiliate-apply/?$ index.php?view=af_apply
RewriteRule ^edit-profile/?$ index.php?view=edit_profile
RewriteRule ^feed/?$ index.php?view=rss
RewriteRule ^gallery/?$ index.php?view=gallery
RewriteRule ^login/?$ index.php?view=login
RewriteRule ^logout/?$ index.php?view=logout
RewriteRule ^memberslist/?$ index.php?view=memberslist
RewriteRule ^poll-results/?$ index.php?results=yes
RewriteRule ^polls/?$ index.php?view=polls
RewriteRule ^profile/?$ index.php?view=edit_profile
RewriteRule ^re-direct/([^/]+)/?$ index.php?view=re-direct&id=$1
RewriteRule ^register/?$ index.php?view=register
RewriteRule ^rss/?$ index.php?view=rss
RewriteRule ^search/?$ index.php?view=search
RewriteRule ^submit-article/?$ index.php?view=submit_article

RewriteRule ^includes/jscripts/tiny_mce/plugins/emotions([^/]+).gif$ includes/smilies/$1.gif

# Mod_Rewrite for AdaptCMS v1.0
RewriteRule ^affiliate-apply.html$ index.php?view=af_apply
RewriteRule ^affiliates.html$ index.php?view=affiliates
RewriteRule ^article-([0-9]+).html$ index.php?view=article&id=$1
RewriteRule ^article-([0-9]+)-([^/]+).html$ index.php?view=article&id=$1
RewriteRule ^cat-([^/]+).html$ index.php?view=list&cat=$1
RewriteRule ^edit-profile.html$ index.php?view=edit_profile
RewriteRule ^gallery.html$ index.php?view=gallery
RewriteRule ^gallery([0-9]+)-([^/]+).html$ index.php?view=gallery&id=$1
RewriteRule ^list.html$ index.php?view=list
RewriteRule ^list-([^/]+).html$ index.php?view=list&cat=$1
RewriteRule ^login.html$ index.php?view=login
RewriteRule ^logout.html$ index.php?view=logout
RewriteRule ^memberslist.html$ index.php?view=memberslist
RewriteRule ^p-([^/]+).html$ index.php?view=page&id=$1
RewriteRule ^page-([^/]+).html$ index.php?view=page&id=$1
RewriteRule ^polls.html$ index.php?view=polls
RewriteRule ^profile.html$ index.php?view=edit_profile
RewriteRule ^register.html$ index.php?view=register
RewriteRule ^rss.html$ index.php?view=rss
RewriteRule ^search.html$ index.php?view=search
RewriteRule ^section-([^/]+).html$ index.php?view=list&cat=$1
RewriteRule ^user-([^/]+).html$ index.php?view=profile&user=$1";

$handle = fopen($sitepath.".htaccess", 'w');
fwrite($handle, $content_ht);
fclose($handle);

if ($handle == TRUE) {
echo ".htaccess file modified? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
echo ".htaccess file modified? <font color='red'>NO</font><br />";
}

if ($error == 0) {
echo "Upgrade sucessfull?: ";
echo " <font color='blue'>YES</font>";
echo "&nbsp;&nbsp;&nbsp;&nbsp;You are now finished upgrading to AdaptCMS Lite ".$version."!<br /><br />Please delete this file, <b>install.php</b> and have fun with AdaptCMS Lite ".$version."! <a href='admin.php'>Admin Panel</a>, <a href='/'>Frontend</a>";
} else {
echo "Upgrade sucessfull?: ";
echo " <font color='red'>NO</font>";
echo "&nbsp;&nbsp;&nbsp;&nbsp;There seemed to be a problem upgrading, go back and try again. If need be, please contact us - <a href='http://www.adaptcms.com/lite'>adaptcms.com</a>";
}
}

if ($_GET['step'] == "upgrade_1.2") {
include ("dbinfo.php");
@mysql_select_db($dbname, @mysql_connect($dbhost, $dbuser, $dbpass));
eval (" ?> ".admin_header()." <?php ");
echo "<title>AdaptCMS Lite - Upgrade</title>";
$error = 0;

if (mysql_query("ALTER TABLE ".$pre."stats ADD `date` INT( 11 ) NOT NULL") == TRUE) {
echo "`".$pre."stats` MySQL table structure altered? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."stats` MySQL table structure altered? <font color='red'>False</font><br />";
}

$sql = mysql_query("SELECT * FROM ".$pre."affiliates ORDER BY `id` ASC");
while($r = mysql_fetch_array($sql)) {
mysql_query("INSERT INTO ".$pre."fielddata VALUES (null, '".$r[sitename]."', '".$r[siteurl]."|".$r[target]."|".$r[imageurl]."|".$r[status]."|".$r[date]."|".$r[clicks]."', 'plugin_affiliates')");
}
if (mysql_query("DROP TABLE `".$pre."affiliates`") == TRUE) {
echo "`Affiliates` Plugin data converted to new format? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`Affiliates` Plugin data converted to new format? <font color='red'>False</font><br />";
}

if (mysql_query("INSERT INTO ".$pre."settings VALUES(null, 'captcha_login', 'Enter in \"yes\" if you would like a captcha confirmation to show when someone attempts to login in the frontend of your website.', 'no', 'setting', 'Modules')") == TRUE) {
echo "`".$pre."settings` MySQL data row Inserted? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."settings` MySQL data row Inserted? <font color='red'>False</font><br />";
}

if (mysql_query("INSERT INTO `".$pre."plugins` VALUES (null, 'Shoutbox', 'shoutbox.php', '1.1', 'On')") == TRUE) {
echo "`".$pre."plugins` MySQL data row Inserted? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."plugins` MySQL data row Inserted? <font color='red'>False</font><br />";
}

if (mysql_query("INSERT INTO `".$pre."settings` VALUES (null, 'guests_shoutbox', 'Can guests post to the Shoutbox?', 'no', 'setting', 'General')") == TRUE) {
echo "`".$pre."settings` MySQL data row Inserted? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."settings` MySQL data row Inserted? <font color='red'>False</font><br />";
}

if (mysql_query("UPDATE `".$pre."plugins` SET version = '1.2' WHERE name = 'RSS Importer'") == TRUE) {
echo "`".$pre."plugins` MySQL data row #1 Updated? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."plugins` MySQL data row #1 Updated? <font color='red'>False</font><br />";
}

if (mysql_query("INSERT INTO `".$pre."plugins` VALUES (null, 'TinyURL', 'tinyurl.php', '1.0', 'On')") == TRUE && mysql_query("INSERT INTO `".$pre."plugins` VALUES (null, 'Form Builder', 'form_builder.php', '1.0', 'On')") == TRUE) {
echo "`".$pre."plugins` MySQL data row #1-2 Inserted? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."plugins` MySQL data row #1-2 Inserted? <font color='red'>False</font><br />";
}

$content_ht = "RewriteEngine On
RewriteBase ".str_replace($apage, "", $_SERVER['PHP_SELF'])."
RewriteCond %{HTTP_HOST} !^www\..* [NC]
RewriteCond %{HTTP_HOST} !^[0-9]+\.[0-9]+\..+ [NC]
RewriteRule ^([^/]+) http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

ErrorDocument 404 ".str_replace($apage, "", $_SERVER['PHP_SELF'])."index.php?view=error&type=404

# Mod_Rewrite for AdaptCMS v1.1-1.4
RewriteRule ^archive/?$ index.php?view=list
RewriteRule ^archive/([^/]+)/letter/([^/]+)/?$ index.php?view=list&cat=$1&abc=$2
RewriteRule ^archive/letter/([^/]+)/?$ index.php?view=list&abc=$1
RewriteRule ^archive/(.*)/?$ index.php?view=list&cat=$1
RewriteRule ^article/([0-9]+)/([^/]+)/trackback?$ index.php?view=trackback&id=$1
RewriteRule ^article/([0-9]+)/([^/]+)/([^/]+)/trackback?$ index.php?view=trackback&id=$1
RewriteRule ^article/([0-9]+)/([^/]+)/?$ index.php?view=article&id=$1
RewriteRule ^article/([0-9]+)/([^/]+)/([^/]+)/?$ index.php?view=article&id=$1
RewriteRule ^article/([0-9]+)/([^/]+)/page/([0-9]+)/?$ index.php?view=article&id=$1&page=$3
RewriteRule ^article/([0-9]+)/([^/]+)/([^/]+)/page/([0-9]+)/?$ index.php?view=article&id=$1&page=$4
RewriteRule ^category/([^/]+)/?$ index.php?view=list&cat=$1
RewriteRule ^feed/([^/]+)/?$ index.php?view=rss&section=$1
RewriteRule ^gallery/([0-9]+)/([^/]+)/?$ index.php?view=gallery&id=$1
RewriteRule ^page/([^/]+)/?$ index.php?view=page&id=$1
RewriteRule ^rss/([^/]+)/([^/]+)-([^/]+)/?$ index.php?view=rss&section=$1&field=$2&data=$3
RewriteRule ^rss/([^/]+)-([^/]+)/?$ index.php?view=rss&field=$1&data=$2
RewriteRule ^rss/([^/]+)/?$ index.php?view=rss&section=$1
RewriteRule ^section/([^/]+)/([^/]+)-([^/]+)/?$ index.php?view=list&cat=$1&field=$2&data=$3
RewriteRule ^section/([^/]+)-([^/]+)/?$ index.php?view=list&field=$1&data=$2
RewriteRule ^section/([^/]+)/?$ index.php?view=list&cat=$1
RewriteRule ^user/([^/]+)/?$ index.php?view=profile&user=$1

RewriteRule ^affiliates/?$ index.php?view=affiliates
RewriteRule ^affiliate-apply/?$ index.php?view=af_apply
RewriteRule ^edit-profile/?$ index.php?view=edit_profile
RewriteRule ^feed/?$ index.php?view=rss
RewriteRule ^gallery/?$ index.php?view=gallery
RewriteRule ^login/?$ index.php?view=login
RewriteRule ^logout/?$ index.php?view=logout
RewriteRule ^memberslist/?$ index.php?view=memberslist
RewriteRule ^poll-results/?$ index.php?results=yes
RewriteRule ^polls/?$ index.php?view=polls
RewriteRule ^profile/?$ index.php?view=edit_profile
RewriteRule ^re-direct/([^/]+)/?$ index.php?view=re-direct&id=$1
RewriteRule ^register/?$ index.php?view=register
RewriteRule ^rss/?$ index.php?view=rss
RewriteRule ^search/?$ index.php?view=search
RewriteRule ^submit-article/?$ index.php?view=submit_article

RewriteRule ^includes/jscripts/tiny_mce/plugins/emotions([^/]+).gif$ includes/smilies/$1.gif

# Mod_Rewrite for AdaptCMS v1.0
RewriteRule ^affiliate-apply.html$ index.php?view=af_apply
RewriteRule ^affiliates.html$ index.php?view=affiliates
RewriteRule ^article-([0-9]+).html$ index.php?view=article&id=$1
RewriteRule ^article-([0-9]+)-([^/]+).html$ index.php?view=article&id=$1
RewriteRule ^cat-([^/]+).html$ index.php?view=list&cat=$1
RewriteRule ^edit-profile.html$ index.php?view=edit_profile
RewriteRule ^gallery.html$ index.php?view=gallery
RewriteRule ^gallery([0-9]+)-([^/]+).html$ index.php?view=gallery&id=$1
RewriteRule ^list.html$ index.php?view=list
RewriteRule ^list-([^/]+).html$ index.php?view=list&cat=$1
RewriteRule ^login.html$ index.php?view=login
RewriteRule ^logout.html$ index.php?view=logout
RewriteRule ^memberslist.html$ index.php?view=memberslist
RewriteRule ^p-([^/]+).html$ index.php?view=page&id=$1
RewriteRule ^page-([^/]+).html$ index.php?view=page&id=$1
RewriteRule ^polls.html$ index.php?view=polls
RewriteRule ^profile.html$ index.php?view=edit_profile
RewriteRule ^register.html$ index.php?view=register
RewriteRule ^rss.html$ index.php?view=rss
RewriteRule ^search.html$ index.php?view=search
RewriteRule ^section-([^/]+).html$ index.php?view=list&cat=$1
RewriteRule ^user-([^/]+).html$ index.php?view=profile&user=$1";

$handle = fopen($sitepath.".htaccess", 'w');
fwrite($handle, $content_ht);
fclose($handle);

if ($handle == TRUE) {
echo ".htaccess file modified? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
echo ".htaccess file modified? <font color='red'>NO</font><br />";
}

if ($error == 0) {
echo "Upgrade sucessfull?: ";
echo " <font color='blue'>YES</font>";
echo "&nbsp;&nbsp;&nbsp;&nbsp;You are now finished upgrading to AdaptCMS Lite ".$version."!<br /><br />Please delete this file, <b>install.php</b> and have fun with AdaptCMS Lite ".$version."! <a href='admin.php'>Admin Panel</a>, <a href='/'>Frontend</a>";
} else {
echo "Upgrade sucessfull?: ";
echo " <font color='red'>NO</font>";
echo "&nbsp;&nbsp;&nbsp;&nbsp;There seemed to be a problem upgrading, go back and try again. If need be, please contact us - <a href='http://pro.adaptcms.com'>adaptcms.com</a>";
}
}

if ($_GET['step'] == "upgrade_1.1") {
include ("dbinfo.php");
@mysql_select_db($dbname, @mysql_connect($dbhost, $dbuser, $dbpass));
eval (" ?> ".admin_header()." <?php ");
echo "<title>AdaptCMS Lite - Upgrade</title>";
$error = 0;

// 1.3
if (mysql_query("ALTER TABLE ".$pre."stats ADD `date` INT( 11 ) NOT NULL") == TRUE) {
echo "`".$pre."stats` MySQL table structure altered? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."stats` MySQL table structure altered? <font color='red'>False</font><br />";
}

$sql = mysql_query("SELECT * FROM ".$pre."affiliates ORDER BY `id` ASC");
while($r = mysql_fetch_array($sql)) {
mysql_query("INSERT INTO ".$pre."fielddata VALUES (null, '".$r[sitename]."', '".$r[siteurl]."|".$r[target]."|".$r[imageurl]."|".$r[status]."|".$r[date]."|".$r[clicks]."', 'plugin_affiliates')");
}
if (mysql_query("DROP TABLE `".$pre."affiliates`") == TRUE) {
echo "`Affiliates` Plugin data converted to new format? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`Affiliates` Plugin data converted to new format? <font color='red'>False</font><br />";
}

if (mysql_query("INSERT INTO `".$pre."plugins` VALUES (null, 'Shoutbox', 'shoutbox.php', '1.1', 'On')") == TRUE) {
echo "`".$pre."plugins` MySQL data row Inserted? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."plugins` MySQL data row Inserted? <font color='red'>False</font><br />";
}

if (mysql_query("INSERT INTO `".$pre."settings` VALUES (null, 'guests_shoutbox', 'Can guests post to the Shoutbox?', 'no', 'setting', 'General')") == TRUE) {
echo "`".$pre."settings` MySQL data row Inserted? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."settings` MySQL data row Inserted? <font color='red'>False</font><br />";
}

if (mysql_query("INSERT INTO ".$pre."settings VALUES(null, 'captcha_login', 'Enter in \"yes\" if you would like a captcha confirmation to show when someone attempts to login in the frontend of your website.', 'no', 'setting', 'Modules')") == TRUE) {
echo "`".$pre."settings` MySQL data row Inserted? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."settings` MySQL data row Inserted? <font color='red'>False</font><br />";
}

// 1.2
if (mysql_query("ALTER TABLE `".$pre."stats_archive` ADD `data` TEXT NOT NULL AFTER `name`") == TRUE) {
echo "`".$pre."stats_archive` structure changed? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."stats_archive` structure changed? <font color='red'>False</font><br />";
}

if (mysql_query("ALTER TABLE `".$pre."polls` ADD `options` TEXT NOT NULL AFTER `type`") == TRUE) {
echo "`".$pre."polls` structure changed? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."polls` structure changed? <font color='red'>False</font><br />";
}

if (mysql_query("ALTER TABLE `".$pre."levels` ADD `options` TEXT NOT NULL AFTER `value`") == TRUE) {
echo "`".$pre."levels` structure changed? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."levels` structure changed? <font color='red'>False</font><br />";
}

if (mysql_query("INSERT INTO ".$pre."settings VALUES(null, 'trackback_urls', 'Notify websites of new articles. Separate with a comma (ex. http://weblogs.com/RPC2,http://www.bblog.com/ping.php,http://ping.blo.gs)', 'http://www.bblog.com/ping.php,http://ping.blo.gs', 'setting', 'Modules')") == TRUE && mysql_query("INSERT INTO ".$pre."settings VALUES(null, 'Polls', '', '', 'section', '')") == TRUE && mysql_query("INSERT INTO ".$pre."settings VALUES(null, 'custom_poll_limit', 'What is the max amount of custom poll options that can be entered? (note that the custom poll option must be checked for the specific poll and someone may only enter 1 themselves)', '3', 'setting', 'Polls')") == TRUE && mysql_query("INSERT INTO ".$pre."settings VALUES(null, 'custom_poll_guest', 'Can guests enter in a custom poll option? (applicable if the \"custom poll option\" is checked for the specific poll)', 'no', 'setting', 'Polls')") == TRUE && mysql_query("INSERT INTO ".$pre."settings VALUES(null, 'admin_limit', '# of items to display per page (admin panel)', '20', 'setting', 'Other')") == TRUE) {
echo "`".$pre."settings` MySQL data row #1-#5 Inserted? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."settings` MySQL data row #1-#5 Inserted? <font color='red'>False</font><br />";
}

if (mysql_query("INSERT INTO `".$pre."settings` VALUES (null, 'word_filter', 'Separate bad words with a , (ex. word,word2,word3).', 'fuck,bitch,cunt,whore,nigger', 'setting', 'Other')") == TRUE) {
echo "`".$pre."settings` MySQL data row #6 Inserted? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."settings` MySQL data row #6 Inserted? <font color='red'>False</font><br />";
}

if (mysql_query("INSERT INTO ".$pre."settings VALUES (null, 'sitemap_update', 'How often should a sitemap file be generated? (in days)', '14', 'setting', 'Modules')") == TRUE) {
echo "`".$pre."settings` MySQL data row #7 Inserted? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."settings` MySQL data row #7 Inserted? <font color='red'>False</font><br />";
}
if (mysql_query("INSERT INTO ".$pre."settings VALUES (null, 'sitemap_yahoo_key', 'Put in your yahoo API key (only required for yahoo to be pinged upon sitemap update)', '', 'setting', 'Modules')") == TRUE) {
echo "`".$pre."settings` MySQL data row #8 Inserted? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."settings` MySQL data row #8 Inserted? <font color='red'>False</font><br />";
}

if (mysql_query("INSERT INTO ".$pre."plugins VALUES (null, 'Sitemap', 'sitemap.php', '1.0', 'On')") == TRUE) {
echo "`".$pre."plugins` MySQL data row #1 Inserted? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."plugins` MySQL data row #1 Inserted? <font color='red'>False</font><br />";
}

if (mysql_query("INSERT INTO ".$pre."plugins VALUES (null, 'RSS Importer', 'rss_importer.php', '1.2', 'On')") == TRUE) {
echo "`".$pre."plugins` MySQL data row #2 Inserted? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."plugins` MySQL data row #2 Inserted? <font color='red'>False</font><br />";
}

if (mysql_query("INSERT INTO `".$pre."plugins` VALUES (null, 'TinyURL', 'tinyurl.php', '1.0', 'On')") == TRUE && mysql_query("INSERT INTO `".$pre."plugins` VALUES (null, 'Form Builder', 'form_builder.php', '1.0', 'On')") == TRUE) {
echo "`".$pre."plugins` MySQL data row #1-2 Inserted? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."plugins` MySQL data row #1-2 Inserted? <font color='red'>False</font><br />";
}

$content_ht = "RewriteEngine On
RewriteBase ".str_replace($apage, "", $_SERVER['PHP_SELF'])."
RewriteCond %{HTTP_HOST} !^www\..* [NC]
RewriteCond %{HTTP_HOST} !^[0-9]+\.[0-9]+\..+ [NC]
RewriteRule ^([^/]+) http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

ErrorDocument 404 ".str_replace($apage, "", $_SERVER['PHP_SELF'])."index.php?view=error&type=404

# Mod_Rewrite for AdaptCMS v1.1-1.4
RewriteRule ^archive/?$ index.php?view=list
RewriteRule ^archive/([^/]+)/letter/([^/]+)/?$ index.php?view=list&cat=$1&abc=$2
RewriteRule ^archive/letter/([^/]+)/?$ index.php?view=list&abc=$1
RewriteRule ^archive/(.*)/?$ index.php?view=list&cat=$1
RewriteRule ^article/([0-9]+)/([^/]+)/trackback?$ index.php?view=trackback&id=$1
RewriteRule ^article/([0-9]+)/([^/]+)/([^/]+)/trackback?$ index.php?view=trackback&id=$1
RewriteRule ^article/([0-9]+)/([^/]+)/?$ index.php?view=article&id=$1
RewriteRule ^article/([0-9]+)/([^/]+)/([^/]+)/?$ index.php?view=article&id=$1
RewriteRule ^article/([0-9]+)/([^/]+)/page/([0-9]+)/?$ index.php?view=article&id=$1&page=$3
RewriteRule ^article/([0-9]+)/([^/]+)/([^/]+)/page/([0-9]+)/?$ index.php?view=article&id=$1&page=$4
RewriteRule ^category/([^/]+)/?$ index.php?view=list&cat=$1
RewriteRule ^feed/([^/]+)/?$ index.php?view=rss&section=$1
RewriteRule ^gallery/([0-9]+)/([^/]+)/?$ index.php?view=gallery&id=$1
RewriteRule ^page/([^/]+)/?$ index.php?view=page&id=$1
RewriteRule ^rss/([^/]+)/([^/]+)-([^/]+)/?$ index.php?view=rss&section=$1&field=$2&data=$3
RewriteRule ^rss/([^/]+)-([^/]+)/?$ index.php?view=rss&field=$1&data=$2
RewriteRule ^rss/([^/]+)/?$ index.php?view=rss&section=$1
RewriteRule ^section/([^/]+)/([^/]+)-([^/]+)/?$ index.php?view=list&cat=$1&field=$2&data=$3
RewriteRule ^section/([^/]+)-([^/]+)/?$ index.php?view=list&field=$1&data=$2
RewriteRule ^section/([^/]+)/?$ index.php?view=list&cat=$1
RewriteRule ^user/([^/]+)/?$ index.php?view=profile&user=$1

RewriteRule ^affiliates/?$ index.php?view=affiliates
RewriteRule ^affiliate-apply/?$ index.php?view=af_apply
RewriteRule ^edit-profile/?$ index.php?view=edit_profile
RewriteRule ^feed/?$ index.php?view=rss
RewriteRule ^gallery/?$ index.php?view=gallery
RewriteRule ^login/?$ index.php?view=login
RewriteRule ^logout/?$ index.php?view=logout
RewriteRule ^memberslist/?$ index.php?view=memberslist
RewriteRule ^poll-results/?$ index.php?results=yes
RewriteRule ^polls/?$ index.php?view=polls
RewriteRule ^profile/?$ index.php?view=edit_profile
RewriteRule ^re-direct/([^/]+)/?$ index.php?view=re-direct&id=$1
RewriteRule ^register/?$ index.php?view=register
RewriteRule ^rss/?$ index.php?view=rss
RewriteRule ^search/?$ index.php?view=search
RewriteRule ^submit-article/?$ index.php?view=submit_article

RewriteRule ^includes/jscripts/tiny_mce/plugins/emotions([^/]+).gif$ includes/smilies/$1.gif

# Mod_Rewrite for AdaptCMS v1.0
RewriteRule ^affiliate-apply.html$ index.php?view=af_apply
RewriteRule ^affiliates.html$ index.php?view=affiliates
RewriteRule ^article-([0-9]+).html$ index.php?view=article&id=$1
RewriteRule ^article-([0-9]+)-([^/]+).html$ index.php?view=article&id=$1
RewriteRule ^cat-([^/]+).html$ index.php?view=list&cat=$1
RewriteRule ^edit-profile.html$ index.php?view=edit_profile
RewriteRule ^gallery.html$ index.php?view=gallery
RewriteRule ^gallery([0-9]+)-([^/]+).html$ index.php?view=gallery&id=$1
RewriteRule ^list.html$ index.php?view=list
RewriteRule ^list-([^/]+).html$ index.php?view=list&cat=$1
RewriteRule ^login.html$ index.php?view=login
RewriteRule ^logout.html$ index.php?view=logout
RewriteRule ^memberslist.html$ index.php?view=memberslist
RewriteRule ^p-([^/]+).html$ index.php?view=page&id=$1
RewriteRule ^page-([^/]+).html$ index.php?view=page&id=$1
RewriteRule ^polls.html$ index.php?view=polls
RewriteRule ^profile.html$ index.php?view=edit_profile
RewriteRule ^register.html$ index.php?view=register
RewriteRule ^rss.html$ index.php?view=rss
RewriteRule ^search.html$ index.php?view=search
RewriteRule ^section-([^/]+).html$ index.php?view=list&cat=$1
RewriteRule ^user-([^/]+).html$ index.php?view=profile&user=$1";

$handle = fopen($sitepath.".htaccess", 'w');
fwrite($handle, $content_ht);
fclose($handle);

if ($handle == TRUE) {
echo ".htaccess file modified? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
echo ".htaccess file modified? <font color='red'>NO</font><br />";
}

if ($error == 0) {
echo "Upgrade sucessfull?: ";
echo " <font color='blue'>YES</font>";
echo "&nbsp;&nbsp;&nbsp;&nbsp;You are now finished upgrading to AdaptCMS Lite ".$version."!<br /><br />Please delete this file, <b>install.php</b> and have fun with AdaptCMS Lite ".$version."! <a href='admin.php'>Admin Panel</a>, <a href='/'>Frontend</a>";
} else {
echo "Upgrade sucessfull?: ";
echo " <font color='red'>NO</font>";
echo "&nbsp;&nbsp;&nbsp;&nbsp;There seemed to be a problem upgrading, go back and try again. If need be, please contact us - <a href='http://pro.adaptcms.com'>adaptcms.com</a>";
}
}

if ($_GET['step'] == "upgrade_1.0") {
include ("dbinfo.php");
@mysql_select_db($dbname, @mysql_connect($dbhost, $dbuser, $dbpass));
eval (" ?> ".admin_header()." <?php ");
echo "<title>AdaptCMS Lite - Upgrade</title>";
$error = 0;

// 1.3
if (mysql_query("ALTER TABLE ".$pre."stats ADD `date` INT( 11 ) NOT NULL") == TRUE) {
echo "`".$pre."stats` MySQL table structure altered? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."stats` MySQL table structure altered? <font color='red'>False</font><br />";
}

$sql = mysql_query("SELECT * FROM ".$pre."affiliates ORDER BY `id` ASC");
while($r = mysql_fetch_array($sql)) {
mysql_query("INSERT INTO ".$pre."fielddata VALUES (null, '".$r[sitename]."', '".$r[siteurl]."|".$r[target]."|".$r[imageurl]."|".$r[status]."|".$r[date]."|".$r[clicks]."', 'plugin_affiliates')");
}
if (mysql_query("DROP TABLE `".$pre."affiliates`") == TRUE) {
echo "`Affiliates` Plugin data converted to new format? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`Affiliates` Plugin data converted to new format? <font color='red'>False</font><br />";
}

if (mysql_query("INSERT INTO `".$pre."plugins` VALUES (null, 'Shoutbox', 'shoutbox.php', '1.1', 'On')") == TRUE) {
echo "`".$pre."plugins` MySQL data row Inserted? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."plugins` MySQL data row Inserted? <font color='red'>False</font><br />";
}

if (mysql_query("INSERT INTO `".$pre."settings` VALUES (null, 'guests_shoutbox', 'Can guests post to the Shoutbox?', 'no', 'setting', 'General')") == TRUE) {
echo "`".$pre."settings` MySQL data row Inserted? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."settings` MySQL data row Inserted? <font color='red'>False</font><br />";
}

if (mysql_query("INSERT INTO ".$pre."settings VALUES(null, 'captcha_login', 'Enter in \"yes\" if you would like a captcha confirmation to show when someone attempts to login in the frontend of your website.', 'no', 'setting', 'Modules')") == TRUE) {
echo "`".$pre."settings` MySQL data row Inserted? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."settings` MySQL data row Inserted? <font color='red'>False</font><br />";
}

// 1.2
if (mysql_query("ALTER TABLE `".$pre."stats_archive` ADD `data` TEXT NOT NULL AFTER `name`") == TRUE) {
echo "`".$pre."stats_archive` structure changed? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."stats_archive` structure changed? <font color='red'>False</font><br />";
}

if (mysql_query("ALTER TABLE `".$pre."polls` ADD `options` TEXT NOT NULL AFTER `type`") == TRUE) {
echo "`".$pre."polls` structure changed? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."polls` structure changed? <font color='red'>False</font><br />";
}

if (mysql_query("ALTER TABLE `".$pre."levels` ADD `options` TEXT NOT NULL AFTER `value`") == TRUE) {
echo "`".$pre."levels` structure changed? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."levels` structure changed? <font color='red'>False</font><br />";
}

if (mysql_query("INSERT INTO ".$pre."settings VALUES(null, 'trackback_urls', 'Notify websites of new articles. Separate with a comma (ex. http://weblogs.com/RPC2,http://www.bblog.com/ping.php,http://ping.blo.gs)', 'http://www.bblog.com/ping.php,http://ping.blo.gs', 'setting', 'Modules')") == TRUE && mysql_query("INSERT INTO ".$pre."settings VALUES(null, 'Polls', '', '', 'section', '')") == TRUE && mysql_query("INSERT INTO ".$pre."settings VALUES(null, 'custom_poll_limit', 'What is the max amount of custom poll options that can be entered? (note that the custom poll option must be checked for the specific poll and someone may only enter 1 themselves)', '3', 'setting', 'Polls')") == TRUE && mysql_query("INSERT INTO ".$pre."settings VALUES(null, 'custom_poll_guest', 'Can guests enter in a custom poll option? (applicable if the \"custom poll option\" is checked for the specific poll)', 'no', 'setting', 'Polls')") == TRUE && mysql_query("INSERT INTO ".$pre."settings VALUES(null, 'admin_limit', '# of items to display per page (admin panel)', '20', 'setting', 'Other')") == TRUE) {
echo "`".$pre."settings` MySQL data row #1-#5 Inserted? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."settings` MySQL data row #1-#5 Inserted? <font color='red'>False</font><br />";
}

if (mysql_query("INSERT INTO `".$pre."settings` VALUES (null, 'word_filter', 'Separate bad words with a , (ex. word,word2,word3).', 'fuck,bitch,cunt,whore,nigger', 'setting', 'Other')") == TRUE) {
echo "`".$pre."settings` MySQL data row #6 Inserted? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."settings` MySQL data row #6 Inserted? <font color='red'>False</font><br />";
}

// v1.0-1.1
$content_ht = "RewriteEngine On
RewriteBase ".str_replace($apage, "", $_SERVER['PHP_SELF'])."
RewriteCond %{HTTP_HOST} !^www\..* [NC]
RewriteCond %{HTTP_HOST} !^[0-9]+\.[0-9]+\..+ [NC]
RewriteRule ^([^/]+) http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

ErrorDocument 404 ".str_replace($apage, "", $_SERVER['PHP_SELF'])."index.php?view=error&type=404

# Mod_Rewrite for AdaptCMS v1.1-1.4
RewriteRule ^archive/?$ index.php?view=list
RewriteRule ^archive/([^/]+)/letter/([^/]+)/?$ index.php?view=list&cat=$1&abc=$2
RewriteRule ^archive/letter/([^/]+)/?$ index.php?view=list&abc=$1
RewriteRule ^archive/(.*)/?$ index.php?view=list&cat=$1
RewriteRule ^article/([0-9]+)/([^/]+)/trackback?$ index.php?view=trackback&id=$1
RewriteRule ^article/([0-9]+)/([^/]+)/([^/]+)/trackback?$ index.php?view=trackback&id=$1
RewriteRule ^article/([0-9]+)/([^/]+)/?$ index.php?view=article&id=$1
RewriteRule ^article/([0-9]+)/([^/]+)/([^/]+)/?$ index.php?view=article&id=$1
RewriteRule ^article/([0-9]+)/([^/]+)/page/([0-9]+)/?$ index.php?view=article&id=$1&page=$3
RewriteRule ^article/([0-9]+)/([^/]+)/([^/]+)/page/([0-9]+)/?$ index.php?view=article&id=$1&page=$4
RewriteRule ^category/([^/]+)/?$ index.php?view=list&cat=$1
RewriteRule ^feed/([^/]+)/?$ index.php?view=rss&section=$1
RewriteRule ^gallery/([0-9]+)/([^/]+)/?$ index.php?view=gallery&id=$1
RewriteRule ^page/([^/]+)/?$ index.php?view=page&id=$1
RewriteRule ^rss/([^/]+)/([^/]+)-([^/]+)/?$ index.php?view=rss&section=$1&field=$2&data=$3
RewriteRule ^rss/([^/]+)-([^/]+)/?$ index.php?view=rss&field=$1&data=$2
RewriteRule ^rss/([^/]+)/?$ index.php?view=rss&section=$1
RewriteRule ^section/([^/]+)/([^/]+)-([^/]+)/?$ index.php?view=list&cat=$1&field=$2&data=$3
RewriteRule ^section/([^/]+)-([^/]+)/?$ index.php?view=list&field=$1&data=$2
RewriteRule ^section/([^/]+)/?$ index.php?view=list&cat=$1
RewriteRule ^user/([^/]+)/?$ index.php?view=profile&user=$1

RewriteRule ^affiliates/?$ index.php?view=affiliates
RewriteRule ^affiliate-apply/?$ index.php?view=af_apply
RewriteRule ^edit-profile/?$ index.php?view=edit_profile
RewriteRule ^feed/?$ index.php?view=rss
RewriteRule ^gallery/?$ index.php?view=gallery
RewriteRule ^login/?$ index.php?view=login
RewriteRule ^logout/?$ index.php?view=logout
RewriteRule ^memberslist/?$ index.php?view=memberslist
RewriteRule ^poll-results/?$ index.php?results=yes
RewriteRule ^polls/?$ index.php?view=polls
RewriteRule ^profile/?$ index.php?view=edit_profile
RewriteRule ^re-direct/([^/]+)/?$ index.php?view=re-direct&id=$1
RewriteRule ^register/?$ index.php?view=register
RewriteRule ^rss/?$ index.php?view=rss
RewriteRule ^search/?$ index.php?view=search
RewriteRule ^submit-article/?$ index.php?view=submit_article

RewriteRule ^includes/jscripts/tiny_mce/plugins/emotions([^/]+).gif$ includes/smilies/$1.gif

# Mod_Rewrite for AdaptCMS v1.0
RewriteRule ^affiliate-apply.html$ index.php?view=af_apply
RewriteRule ^affiliates.html$ index.php?view=affiliates
RewriteRule ^article-([0-9]+).html$ index.php?view=article&id=$1
RewriteRule ^article-([0-9]+)-([^/]+).html$ index.php?view=article&id=$1
RewriteRule ^cat-([^/]+).html$ index.php?view=list&cat=$1
RewriteRule ^edit-profile.html$ index.php?view=edit_profile
RewriteRule ^gallery.html$ index.php?view=gallery
RewriteRule ^gallery([0-9]+)-([^/]+).html$ index.php?view=gallery&id=$1
RewriteRule ^list.html$ index.php?view=list
RewriteRule ^list-([^/]+).html$ index.php?view=list&cat=$1
RewriteRule ^login.html$ index.php?view=login
RewriteRule ^logout.html$ index.php?view=logout
RewriteRule ^memberslist.html$ index.php?view=memberslist
RewriteRule ^p-([^/]+).html$ index.php?view=page&id=$1
RewriteRule ^page-([^/]+).html$ index.php?view=page&id=$1
RewriteRule ^polls.html$ index.php?view=polls
RewriteRule ^profile.html$ index.php?view=edit_profile
RewriteRule ^register.html$ index.php?view=register
RewriteRule ^rss.html$ index.php?view=rss
RewriteRule ^search.html$ index.php?view=search
RewriteRule ^section-([^/]+).html$ index.php?view=list&cat=$1
RewriteRule ^user-([^/]+).html$ index.php?view=profile&user=$1";

$handle = fopen($sitepath.".htaccess", 'w');
fwrite($handle, $content_ht);
fclose($handle);

if ($handle == TRUE) {
echo ".htaccess file modified? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
echo ".htaccess file modified? <font color='red'>NO</font><br />";
}

if (mysql_query("INSERT INTO `".$pre."settings` VALUES (null, 'banned_users', 'Separated by commas, put the names of users that will not be able to access your site. (they will see a message)', '', 'setting', 'Modules')") == TRUE) {
echo "`".$pre."settings` MySQL data row #1 Inserted? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."settings` MySQL data row #1 Inserted? <font color='red'>False</font><br />";
}

if (mysql_query("INSERT INTO ".$pre."settings VALUES (null, 'sitemap_update', 'How often should a sitemap file be generated? (in days)', '14', 'setting', 'Modules')") == TRUE) {
echo "`".$pre."settings` MySQL data row #2 Inserted? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."settings` MySQL data row #2 Inserted? <font color='red'>False</font><br />";
}
if (mysql_query("INSERT INTO ".$pre."settings VALUES (null, 'sitemap_yahoo_key', 'Put in your yahoo API key (only required for yahoo to be pinged upon sitemap update)', '', 'setting', 'Modules')") == TRUE) {
echo "`".$pre."settings` MySQL data row #3 Inserted? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."settings` MySQL data row #3 Inserted? <font color='red'>False</font><br />";
}

if (mysql_query("INSERT INTO ".$pre."settings VALUES (null, 'captcha_comments', 'Enter in \"yes\" if you would like a captcha confirmation to show when someone is adding a comment to an article. \"no\" will not show it.', 'yes', 'setting', 'Modules')") == TRUE) {
echo "`".$pre."settings` MySQL data row #4 Inserted? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."settings` MySQL data row #4 Inserted? <font color='red'>False</font><br />";
}
if (mysql_query("INSERT INTO ".$pre."settings VALUES (null, 'offline_message', 'Enter an offline message, this will be shown if you set your website to be offline.', 'Sorry, but we are currently offline. Please come back soon.', 'setting', 'General')") == TRUE) {
echo "`".$pre."settings` MySQL data row #5 Inserted? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."settings` MySQL data row #5 Inserted? <font color='red'>False</font><br />";
}

if (mysql_query("INSERT INTO ".$pre."plugins VALUES (null, 'Sitemap', 'sitemap.php', '1.0', 'On')") == TRUE) {
echo "`".$pre."plugins` MySQL data row #1 Inserted? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."plugins` MySQL data row #1 Inserted? <font color='red'>False</font><br />";
}

if (mysql_query("INSERT INTO ".$pre."plugins VALUES (null, 'RSS Importer', 'rss_importer.php', '1.2', 'On')") == TRUE) {
echo "`".$pre."plugins` MySQL data row #2 Inserted? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."plugins` MySQL data row #2 Inserted? <font color='red'>False</font><br />";
}

if (mysql_query("INSERT INTO ".$pre."templates VALUES (null, 'gallery_view', '<title>{sitename} - {name} Gallery</title>\r\n\r\n<h2>{name}</h2>\r\n\r\n<table width=\'100%\'><tr><td align=\"left\">{download_zip}</td><td align=\"right\">{sortby}</td></tr></table>\r\n\r\n<table align=\'center\' border=\'0\' cellpadding=\'5\' cellspacing=\'3\' width=\'100%\'><tr>{image}</tr></table>', '".time()."')") == TRUE) {
echo "`".$pre."templates` MySQL data row #1 Inserted? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."templates` MySQL data row #1 Inserted? <font color='red'>False</font><br />";
}
if (mysql_query("INSERT INTO ".$pre."templates VALUES (null, 'gallery_image', '<td><a href=\'{image}\' rel=\'lightbox[{name}]\'><img src=\'{thumb}\' border=\'1\'></a></td>', '".time()."')") == TRUE) {
echo "`".$pre."templates` MySQL data row #2 Inserted? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."templates` MySQL data row #2 Inserted? <font color='red'>False</font><br />";
}
if (mysql_query("UPDATE ".$pre."templates SET template = '<title>{sitename} - Gallery</title>\r\n\r\n<table align=\'center\' border=\'0\' cellpadding=\'10\' cellspacing=\'5\' width=\'100%\'><tr>{images}</tr></table>', date = '".time()."' WHERE name = 'gallery'") == TRUE) {
echo "`".$pre."templates` MySQL data row #3 Updated? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."templates` MySQL data row #3 Updated? <font color='red'>False</font><br />";
}

if (mysql_query("ALTER TABLE ".$pre."files ADD `rate` VARCHAR( 30 ) NOT NULL DEFAULT '0|0' AFTER `gallery`") == TRUE) {
echo "`".$pre."files` structure altered? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."files` structure altered? <font color='red'>False</font><br />";
}

if (mysql_query("ALTER TABLE ".$pre."plugins CHANGE `version` `version` VARCHAR( 5 ) NOT NULL ") == TRUE) {
echo "`".$pre."plugins` structure altered? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."plugins` structure altered? <font color='red'>False</font><br />";
}

if (mysql_query("INSERT INTO `".$pre."plugins` VALUES (null, 'TinyURL', 'tinyurl.php', '1.0', 'On')") == TRUE && mysql_query("INSERT INTO `".$pre."plugins` VALUES (null, 'Form Builder', 'form_builder.php', '1.0', 'On')") == TRUE) {
echo "`".$pre."plugins` MySQL data row #1-2 Inserted? <font color='green'>True</font><br />";
} else {
$error = $error + 1;
echo "`".$pre."plugins` MySQL data row #1-2 Inserted? <font color='red'>False</font><br />";
}

if ($error == 0) {
echo "Upgrade sucessfull?: ";
echo " <font color='blue'>YES</font>";
echo "&nbsp;&nbsp;&nbsp;&nbsp;You are now finished upgrading to AdaptCMS Lite ".$version."!<br /><br />Please delete this file, <b>install.php</b> and have fun with AdaptCMS Lite ".$version."! <a href='admin.php'>Admin Panel</a>, <a href='/'>Frontend</a>";
} else {
echo "Upgrade sucessfull?: ";
echo " <font color='red'>NO</font>";
echo "&nbsp;&nbsp;&nbsp;&nbsp;There seemed to be a problem upgrading, go back and try again. If need be, please contact us - <a href='http://pro.adaptcms.com'>adaptcms.com</a>";
}
}

if ($_GET['step'] == "install") {
if ($_POST['submit'] == "Upgrade") {
include ("dbinfo.php");
@mysql_select_db($dbname, @mysql_connect($dbhost, $dbuser, $dbpass));
eval (" ?> ".admin_header()." <?php ");
echo "<title>AdaptCMS Lite - Confirm Upgrade</title>It appears you already have AdaptCMS installed. Before we continue we want to confirm that you do wish to upgrade.<br /><br /><a href='install.php?step=upgrade_1.0'>Upgrade from v1.0</a> - <a href='install.php?step=upgrade_1.1'>Upgrade from v1.1</a> - <a href='install.php?step=upgrade_1.2'>Upgrade from 1.2</a> - <a href='install.php?step=upgrade_1.3'>Upgrade from 1.3</a>";
}
if ($_POST['submit'] == "Install") {
if ((((($_POST['pre']) && ($_POST['dbhost']) && ($_POST['dbuser']) && ($_POST['dbname']) && ($_POST['dbpass']))))) {
$code = "";
$hi = file(getcwd()."/dbinfo.php");
foreach ($hi as $line_num => $line) {
$code .= stripslashes($line);
}

$pab[0] = '"cms_dbhost"';
$pab[1] = '"cms_dbuser"';
$pab[2] = '"cms_dbname"';
$pab[3] = '"cms_dbpass"';
$pab[4] = '"adaptcms_"';

$rab[0] = '"'.htmlentities($_POST['dbhost']).'"';
$rab[1] = '"'.htmlentities($_POST['dbuser']).'"';
$rab[2] = '"'.htmlentities($_POST['dbname']).'"';
$rab[3] = '"'.htmlentities($_POST['dbpass']).'"';
$rab[4] = '"'.htmlentities($_POST['pre']).'"';

$code2 = str_replace($pab, $rab, $code);

$fp = @fopen(getcwd()."/dbinfo.php", "w");
@fwrite($fp,stripslashes($code2));
@fclose($fp);
include ("dbinfo.php");

if ((@mysql_connect($dbhost, $dbuser, $dbpass) == TRUE) && (@mysql_num_rows(@mysql_query("SELECT * FROM ".$pre."templates")) == 0)) {
@mysql_select_db($dbname, @mysql_connect($dbhost, $dbuser, $dbpass));
$error = "0";
$data .= "<title>AdaptCMS Lite - Installing...</title>Database information updated?: ";
$data .= " <font color='blue'>YES</font><br /><br />";

$data .= "<p><b>.htaccess file updated</b></p><p>";

$content_ht = "RewriteEngine On
RewriteBase ".str_replace($apage, "", $_SERVER['PHP_SELF'])."
RewriteCond %{HTTP_HOST} !^www\..* [NC]
RewriteCond %{HTTP_HOST} !^[0-9]+\.[0-9]+\..+ [NC]
RewriteRule ^([^/]+) http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

ErrorDocument 404 ".str_replace($apage, "", $_SERVER['PHP_SELF'])."index.php?view=error&type=404

# Mod_Rewrite for AdaptCMS v1.1-1.4
RewriteRule ^archive/?$ index.php?view=list
RewriteRule ^archive/([^/]+)/letter/([^/]+)/?$ index.php?view=list&cat=$1&abc=$2
RewriteRule ^archive/letter/([^/]+)/?$ index.php?view=list&abc=$1
RewriteRule ^archive/(.*)/?$ index.php?view=list&cat=$1
RewriteRule ^article/([0-9]+)/([^/]+)/trackback?$ index.php?view=trackback&id=$1
RewriteRule ^article/([0-9]+)/([^/]+)/([^/]+)/trackback?$ index.php?view=trackback&id=$1
RewriteRule ^article/([0-9]+)/([^/]+)/?$ index.php?view=article&id=$1
RewriteRule ^article/([0-9]+)/([^/]+)/([^/]+)/?$ index.php?view=article&id=$1
RewriteRule ^article/([0-9]+)/([^/]+)/page/([0-9]+)/?$ index.php?view=article&id=$1&page=$3
RewriteRule ^article/([0-9]+)/([^/]+)/([^/]+)/page/([0-9]+)/?$ index.php?view=article&id=$1&page=$4
RewriteRule ^category/([^/]+)/?$ index.php?view=list&cat=$1
RewriteRule ^feed/([^/]+)/?$ index.php?view=rss&section=$1
RewriteRule ^gallery/([0-9]+)/([^/]+)/?$ index.php?view=gallery&id=$1
RewriteRule ^page/([^/]+)/?$ index.php?view=page&id=$1
RewriteRule ^rss/([^/]+)/([^/]+)-([^/]+)/?$ index.php?view=rss&section=$1&field=$2&data=$3
RewriteRule ^rss/([^/]+)-([^/]+)/?$ index.php?view=rss&field=$1&data=$2
RewriteRule ^rss/([^/]+)/?$ index.php?view=rss&section=$1
RewriteRule ^section/([^/]+)/([^/]+)-([^/]+)/?$ index.php?view=list&cat=$1&field=$2&data=$3
RewriteRule ^section/([^/]+)-([^/]+)/?$ index.php?view=list&field=$1&data=$2
RewriteRule ^section/([^/]+)/?$ index.php?view=list&cat=$1
RewriteRule ^user/([^/]+)/?$ index.php?view=profile&user=$1

RewriteRule ^affiliates/?$ index.php?view=affiliates
RewriteRule ^affiliate-apply/?$ index.php?view=af_apply
RewriteRule ^edit-profile/?$ index.php?view=edit_profile
RewriteRule ^feed/?$ index.php?view=rss
RewriteRule ^gallery/?$ index.php?view=gallery
RewriteRule ^login/?$ index.php?view=login
RewriteRule ^logout/?$ index.php?view=logout
RewriteRule ^memberslist/?$ index.php?view=memberslist
RewriteRule ^poll-results/?$ index.php?results=yes
RewriteRule ^polls/?$ index.php?view=polls
RewriteRule ^profile/?$ index.php?view=edit_profile
RewriteRule ^re-direct/([^/]+)/?$ index.php?view=re-direct&id=$1
RewriteRule ^register/?$ index.php?view=register
RewriteRule ^rss/?$ index.php?view=rss
RewriteRule ^search/?$ index.php?view=search
RewriteRule ^submit-article/?$ index.php?view=submit_article

RewriteRule ^includes/jscripts/tiny_mce/plugins/emotions([^/]+).gif$ includes/smilies/$1.gif

# Mod_Rewrite for AdaptCMS v1.0
RewriteRule ^affiliate-apply.html$ index.php?view=af_apply
RewriteRule ^affiliates.html$ index.php?view=affiliates
RewriteRule ^article-([0-9]+).html$ index.php?view=article&id=$1
RewriteRule ^article-([0-9]+)-([^/]+).html$ index.php?view=article&id=$1
RewriteRule ^cat-([^/]+).html$ index.php?view=list&cat=$1
RewriteRule ^edit-profile.html$ index.php?view=edit_profile
RewriteRule ^gallery.html$ index.php?view=gallery
RewriteRule ^gallery([0-9]+)-([^/]+).html$ index.php?view=gallery&id=$1
RewriteRule ^list.html$ index.php?view=list
RewriteRule ^list-([^/]+).html$ index.php?view=list&cat=$1
RewriteRule ^login.html$ index.php?view=login
RewriteRule ^logout.html$ index.php?view=logout
RewriteRule ^memberslist.html$ index.php?view=memberslist
RewriteRule ^p-([^/]+).html$ index.php?view=page&id=$1
RewriteRule ^page-([^/]+).html$ index.php?view=page&id=$1
RewriteRule ^polls.html$ index.php?view=polls
RewriteRule ^profile.html$ index.php?view=edit_profile
RewriteRule ^register.html$ index.php?view=register
RewriteRule ^rss.html$ index.php?view=rss
RewriteRule ^search.html$ index.php?view=search
RewriteRule ^section-([^/]+).html$ index.php?view=list&cat=$1
RewriteRule ^user-([^/]+).html$ index.php?view=profile&user=$1";

$handle = fopen($sitepath.".htaccess", 'w');
fwrite($handle, $content_ht);
fclose($handle);

if ($handle == TRUE) {
$data .= ".htaccess file modified? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= ".htaccess file modified? <font color='red'>NO</font><br />";
}

$data .= "</p><p><b>MySQL Structure</b></p><p>";

if (mysql_query("CREATE TABLE `".$pre."articles` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `name` text NOT NULL,
  `username` text NOT NULL,
  `section` text NOT NULL,
  `ver` text NOT NULL,
  `date` int(8) NOT NULL,
  `mdate` int(8) NOT NULL,
  `ydate` int(8) NOT NULL,
  `rate` varchar(30) NOT NULL default '0|0',
  `views` int(11) NOT NULL default '0',
  PRIMARY KEY  (`id`))") == TRUE) {
$data .= "Created table '".$pre."articles'? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= "Created table '".$pre."articles'? <font color='red'>NO</font><br />";
}

if (mysql_query("CREATE TABLE `".$pre."comments` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `aid` text NOT NULL,
  `comment` text NOT NULL,
  `author` text NOT NULL,
  `email` text NOT NULL,
  `url` text NOT NULL,
  `ip` text NOT NULL,
  `date` int(12) NOT NULL,
  PRIMARY KEY  (`id`))") == TRUE) {
$data .= "Created table '".$pre."comments'? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= "Created table '".$pre."comments'? <font color='red'>NO</font><br />";
}

if (mysql_query("CREATE TABLE `".$pre."fielddata` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `fname` text NOT NULL,
  `data` text NOT NULL,
  `aid` text NOT NULL,
  PRIMARY KEY  (`id`))") == TRUE) {
$data .= "Created table '".$pre."fielddata'? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= "Created table '".$pre."fielddata'? <font color='red'>NO</font><br />";
}

if (mysql_query("CREATE TABLE `".$pre."fields` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `name` text NOT NULL,
  `cat` text NOT NULL,
  `type` text NOT NULL,
  `des` text NOT NULL,
  `info` text NOT NULL,
  PRIMARY KEY  (`id`))") == TRUE) {
$data .= "Created table '".$pre."fields'? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= "Created table '".$pre."fields'? <font color='red'>NO</font><br />";
}

if (mysql_query("CREATE TABLE `".$pre."files` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `filename` text NOT NULL,
  `filedir` text NOT NULL,
  `gallery` text NOT NULL,
  `rate` varchar(30) NOT NULL default '0|0',
  `date` int(12) NOT NULL,
  PRIMARY KEY  (`id`))") == TRUE) {
$data .= "Created table '".$pre."files'? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= "Created table '".$pre."files'? <font color='red'>NO</font><br />";
}

if (mysql_query("CREATE TABLE `".$pre."gallery` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `name` text NOT NULL,
  PRIMARY KEY  (`id`))") == TRUE) {
$data .= "Created table '".$pre."gallery'? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= "Created table '".$pre."gallery'? <font color='red'>NO</font><br />";
}

if (mysql_query("CREATE TABLE `".$pre."levels` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `name` text NOT NULL,
  `value` text NOT NULL,
  `options` text NOT NULL,
  PRIMARY KEY  (`id`))") == TRUE) {
$data .= "Created table '".$pre."levels'? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= "Created table '".$pre."levels'? <font color='red'>NO</font><br />";
}

if (mysql_query("CREATE TABLE `".$pre."pages` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `name` text NOT NULL,
  `url` text NOT NULL,
  `content` text NOT NULL,
  `username` text NOT NULL,
  `date` int(12) NOT NULL,
  PRIMARY KEY  (`id`))") == TRUE) {
$data .= "Created table '".$pre."pages'? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= "Created table '".$pre."pages'? <font color='red'>NO</font><br />";
}

if (mysql_query("CREATE TABLE `".$pre."permissions` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `level` text NOT NULL,
  `name` text NOT NULL,
  `padd` text NOT NULL,
  `pedit` text NOT NULL,
  `pdelete` text NOT NULL,
  PRIMARY KEY  (`id`))") == TRUE) {
$data .= "Created table '".$pre."permissions'? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= "Created table '".$pre."permissions'? <font color='red'>NO</font><br />";
}

if (mysql_query("CREATE TABLE `".$pre."plugins` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `name` text NOT NULL,
  `url` text NOT NULL,
  `version` varchar(5) NOT NULL,
  `status` varchar(5) NOT NULL,
  PRIMARY KEY  (`id`))") == TRUE) {
$data .= "Created table '".$pre."plugins'? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= "Created table '".$pre."plugins'? <font color='red'>NO</font><br />";
}

if (mysql_query("CREATE TABLE `".$pre."polls` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `name` text NOT NULL,
  `type` text NOT NULL,
  `options` text NOT NULL,
  `pname` text NOT NULL,
  `votes` text NOT NULL,
  `date` int(12) NOT NULL,
  PRIMARY KEY  (`id`))") == TRUE) {
$data .= "Created table '".$pre."polls'? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= "Created table '".$pre."polls'? <font color='red'>NO</font><br />";
}

if (mysql_query("CREATE TABLE `".$pre."ranks` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `name` text NOT NULL,
  `color` text NOT NULL,
  `image` text NOT NULL,
  `prequired` text NOT NULL,
  PRIMARY KEY  (`id`))") == TRUE) {
$data .= "Created table '".$pre."ranks'? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= "Created table '".$pre."ranks'? <font color='red'>NO</font><br />";
}

if (mysql_query("CREATE TABLE `".$pre."relations` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `section` text NOT NULL,
  `sub` text NOT NULL,
  PRIMARY KEY  (`id`))") == TRUE) {
$data .= "Created table '".$pre."relations'? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= "Created table '".$pre."relations'? <font color='red'>NO</font><br />";
}

if (mysql_query("CREATE TABLE `".$pre."sections` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `name` text NOT NULL,
  `type` text NOT NULL,
  PRIMARY KEY  (`id`))") == TRUE) {
$data .= "Created table '".$pre."sections'? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= "Created table '".$pre."sections'? <font color='red'>NO</font><br />";
}

if (mysql_query("CREATE TABLE `".$pre."settings` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `name` text NOT NULL,
  `des` text NOT NULL,
  `data` text NOT NULL,
  `type` text NOT NULL,
  `section` text NOT NULL,
  PRIMARY KEY  (`id`))") == TRUE) {
$data .= "Created table '".$pre."settings'? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= "Created table '".$pre."settings'? <font color='red'>NO</font><br />";
}

if (mysql_query("CREATE TABLE `".$pre."stats` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `page` text NOT NULL,
  `referral` text NOT NULL,
  `type` text NOT NULL,
  `ptype` text NOT NULL,
  `username` text NOT NULL,
  `ip` text NOT NULL,
  `info` text NOT NULL,
  `day` text NOT NULL,
  `tday` text NOT NULL,
  `month` text NOT NULL,
  `week` text NOT NULL,
  `year` text NOT NULL,
  `date` INT( 11 ) NOT NULL,
  PRIMARY KEY  (`id`))") == TRUE) {
$data .= "Created table '".$pre."stats'? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= "Created table '".$pre."stats'? <font color='red'>NO</font><br />";
}

if (mysql_query("CREATE TABLE `".$pre."stats_archive` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `name` text NOT NULL,
  `data` text NOT NULL,
  `week` int(2) NOT NULL,
  `month` int(2) NOT NULL,
  `year` int(4) NOT NULL,
  `views` int(20) NOT NULL,
  `uniques` int(20) NOT NULL,
  `date` int(11) NOT NULL,
  PRIMARY KEY  (`id`))") == TRUE) {
$data .= "Created table '".$pre."stats_archive'? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= "Created table '".$pre."stats_archive'? <font color='red'>NO</font><br />";
}

if (mysql_query("CREATE TABLE `".$pre."templates` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `name` text NOT NULL,
  `template` text NOT NULL,
  `date` int(12) NOT NULL,
  PRIMARY KEY  (`id`))") == TRUE) {
$data .= "Created table '".$pre."templates'? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= "Created table '".$pre."templates'? <font color='red'>NO</font><br />";
}

if (mysql_query("CREATE TABLE `".$pre."users` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `username` text NOT NULL,
  `password` text NOT NULL,
  `email` text NOT NULL,
  `level` text NOT NULL,
  `rank` text NOT NULL,
  `logged` text NOT NULL,
  `date` int(12) NOT NULL,
  PRIMARY KEY  (`id`))") == TRUE) {
$data .= "Created table '".$pre."users'? <font color='blue'>YES</font>";
} else {
$error = $error + 1;
$data .= "Created table '".$pre."users'? <font color='red'>NO</font>";
}
$data .= "</p><p><b>MySQL Data</b></p><p>";

if (mysql_query("INSERT INTO `".$pre."fields` VALUES (null, 'ESRB', 'Games', 'select', 'ESRB rating for games.', 'Teen,Mature,Everyone')") == TRUE && mysql_query("INSERT INTO `".$pre."fields` VALUES (null, 'genre', 'Games', 'textfield', 'Genre for example \'Sports\' for games, \'Action/Drama\' for movies.', '')") == TRUE && mysql_query("INSERT INTO `".$pre."fields` VALUES (null, 'online_tag', 'user-profile', 'textfield', 'What is your gamertag/sony/pc online name?', '')") == TRUE && mysql_query("INSERT INTO `".$pre."fields` VALUES (null, 'Short', 'News', 'textarea', 'Description of news story.', '')") == TRUE && mysql_query("INSERT INTO `".$pre."fields` VALUES (null, 'Full', 'News', 'textarea', 'Full news story.', '')") == TRUE && mysql_query("INSERT INTO `".$pre."fields` VALUES (null, 'news_types', 'News', 'radio', '', 'announcement,gone gold,shipped')") == TRUE && mysql_query("INSERT INTO `".$pre."fields` VALUES (null, 'summary', 'Games', 'textarea', 'Description field for games, a short summary.', '')") == TRUE && mysql_query("INSERT INTO `".$pre."fields` VALUES (null, 'user_birthday_month', 'user-profile', 'select', '', 'January,February,March,April,May,June,July,August,September,November,December')") == TRUE && mysql_query("INSERT INTO `".$pre."fields` VALUES (null, 'user_birthday_day', 'user-profile', 'select', '', '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31')") == TRUE && mysql_query("INSERT INTO `".$pre."fields` VALUES (null, 'user_birthday_year', 'user-profile', 'textfield', '', '')") == TRUE && mysql_query("INSERT INTO `".$pre."fields` VALUES (null, 'user_aim', 'user-profile', 'textfield', 'AOL Instant Messenger handler', '')") == TRUE && mysql_query("INSERT INTO `".$pre."fields` VALUES (null, 'user_msn', 'user-profile', 'textfield', 'MSN Handler', '')") == TRUE && mysql_query("INSERT INTO `".$pre."fields` VALUES (null, 'user_name', 'user-profile', 'textfield', 'Your real-life name.', '')") == TRUE && mysql_query("INSERT INTO `".$pre."fields` VALUES (null, 'user_icq', 'user-profile', 'textfield', 'ICQ Handler', '')") == TRUE && mysql_query("INSERT INTO `".$pre."fields` VALUES (null, 'user_yahoo', 'user-profile', 'textfield', 'Yahoo! Messenger handler', '')") == TRUE && mysql_query("INSERT INTO `".$pre."fields` VALUES (null, 'user_gtalk', 'user-profile', 'textfield', 'Google Talk handler', '')") == TRUE && mysql_query("INSERT INTO `".$pre."fields` VALUES (null, 'user_website', 'user-profile', 'textfield', 'Full URL to your website (including http)', '')") == TRUE && mysql_query("INSERT INTO `".$pre."fields` VALUES (null, 'user_avatar', 'user-profile', 'textfield', 'URL to your avatar image', '')") == TRUE && mysql_query("INSERT INTO `".$pre."fields` VALUES(35, 'the_bad', 'Reviews', 'textarea', 'Negative things about this game.', '')") == TRUE && mysql_query("INSERT INTO `".$pre."fields` VALUES(34, 'the_good', 'Reviews', 'textarea', 'Positives about this game.', '')") == TRUE && mysql_query("INSERT INTO `".$pre."fields` VALUES(33, 'system', 'Games', 'select', 'What platform this game is on.', 'PS2,Gamecube,DS,XBOX,PC,PSP,XBOX 360,PS3,Wii')") == TRUE && mysql_query("INSERT INTO `".$pre."fields` VALUES(32, 'boxart_url', 'Games', 'textfield', 'URL to picture of box for game.', '')") == TRUE && mysql_query("INSERT INTO `".$pre."fields` VALUES(31, 'article_text', 'Features', 'textarea', 'Article goes here.', '')") == TRUE && mysql_query("INSERT INTO `".$pre."fields` VALUES(30, 'price', 'Games', 'select', 'Cost of game.', '$19.99,$29.99,$39.99,$49.99,$59.99,$69.99')") == TRUE && mysql_query("INSERT INTO `".$pre."fields` VALUES(29, 'release_date', 'Games', 'textfield', 'Date this game was/will be released. (dd/mm/yy)', '')") == TRUE && mysql_query("INSERT INTO `".$pre."fields` VALUES(27, 'developer', 'Games', 'textfield', 'Company who developed this game.', '')") == TRUE && mysql_query("INSERT INTO `".$pre."fields` VALUES(26, 'publisher', 'Games', 'textfield', 'Company who published this game.', '')") == TRUE && mysql_query("INSERT INTO `".$pre."fields` VALUES(25, 'overall_rating', 'Reviews', 'select', 'Overall (total, not avg) rating of game.', '1,2,3,4,5,6,7,8,9,10')") == TRUE && mysql_query("INSERT INTO `".$pre."fields` VALUES(24, 'anticipation_rating', 'Previews', 'select', 'How high your anticipation for this game is.', '1,2,3,4,5,6,7,8,9,10')") == TRUE && mysql_query("INSERT INTO `".$pre."fields` VALUES(23, 'review_article', 'Reviews', 'textarea', 'Text for the reviewed game.', '')") == TRUE && mysql_query("INSERT INTO `".$pre."fields` VALUES(22, 'preview_article', 'Previews', 'textarea', 'Article text for previewed game.', '')") == TRUE) {
$data .= "Entered data for table '".$pre."fields'? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= "Entered data for table '".$pre."fields'? <font color='red'>NO</font><br />";
}

if (mysql_query("INSERT INTO `".$pre."fielddata` VALUES (1, 'name', 'Welcome to AdaptCMS', '1')") == TRUE && mysql_query("INSERT INTO `".$pre."fielddata` VALUES (2, 'Short', 'On behalf of the <a href=\"http://www.insanevisions.com\">Insane Visions</a> staff, we hope you enjoy your copy of <a href=\"http://www.adaptcms.com/lite\">AdaptCMS Lite</a>. Feel free to delete this article and good luck on your new web site!', '1')") == TRUE && mysql_query("INSERT INTO `".$pre."fielddata` VALUES (3, 'Full', 'We try to make the safest, most easy to use and best quality products possible. In this first version of <a href=\"http://www.adaptcms.com\">AdaptCMS</a> we have presented you with the a Content Management System that you can use for any content website with the tools for content, polls, galleries, static pages, sections and countless backend features including custom fields, easily editable templates, advanced permissions and so much more!\r<br /><br />\nIf you have feedback, suggestions or any questions feel free to contact us at the <a href=\"http://www.adaptcms.com\">AdaptCMS Website</a> or through the <a href=\"admin.php?view=support\">support page</a> in your admin panel.\r<br /><br />\nThank you!', '1')") == TRUE && mysql_query("INSERT INTO ".$pre."fielddata VALUES (null, 'AdaptCMS', 'http://www.adaptcms.com|yes|http://www.adaptcms.com/button.png|1|".time()."|0', 'plugin_affiliates')") == TRUE && mysql_query("INSERT INTO ".$pre."fielddata VALUES (null, 'Insane Visions', 'http://www.insanevisions.com|yes||1|".time()."|0', 'plugin_affiliates')") == TRUE) {
$data .= "Entered data for table '".$pre."fielddata'? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= "Entered data for table '".$pre."fielddata'? <font color='red'>NO</font><br />";
}

if (mysql_query("INSERT INTO `".$pre."files` VALUES (1, 'adaptcms1.png', 'upload/', '1', '0|0', '".time()."')") == TRUE && mysql_query("INSERT INTO `".$pre."files` VALUES (2, 'adaptcms4.png', 'upload/', '1', '0|0', '".time()."')") == TRUE && mysql_query("INSERT INTO `".$pre."files` VALUES (3, 'adaptcms2.png', 'upload/', '1', '0|0', '".time()."')") == TRUE && mysql_query("INSERT INTO `".$pre."files` VALUES (4, 'adaptcms3.png', 'upload/', '1', '0|0', '".time()."')") == TRUE && mysql_query("INSERT INTO `".$pre."files` VALUES (5, 'adaptcms5.png', 'upload/', '1', '0|0', '".time()."')") == TRUE && mysql_query("INSERT INTO `".$pre."files` VALUES (6, 'adaptcms6.png', 'upload/', '1', '0|0', '".time()."')") == TRUE) {
$data .= "Entered data for table '".$pre."files'? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= "Entered data for table '".$pre."files'? <font color='red'>NO</font><br />";
}

if (mysql_query("INSERT INTO `".$pre."gallery` VALUES (1, 'AdaptCMS Pics')") == TRUE) {
$data .= "Entered data for table '".$pre."gallery'? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= "Entered data for table '".$pre."gallery'? <font color='red'>NO</font><br />";
}

if (mysql_query("INSERT INTO `".$pre."levels` VALUES (1, 'Admin', '1', '')") == TRUE && mysql_query("INSERT INTO `".$pre."levels` VALUES (2, 'Staff', '2', '')") == TRUE && mysql_query("INSERT INTO `".$pre."levels` VALUES (3, 'Member', '3', '')") == TRUE) {
$data .= "Entered data for table '".$pre."levels'? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= "Entered data for table '".$pre."levels'? <font color='red'>NO</font><br />";
}

if (mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Admin', 'templates', '', '1', '')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Admin', 'fields', '1', '1', '1')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Admin', 'polls', '1', '1', '1')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Admin', 'pages', '1', '1', '1')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Admin', 'gallery', '1', '1', '1')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Admin', 'files', '1', '', '1')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Admin', 'sections', '1', '1', '1')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Admin', 'users', '1', '1', '1')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Admin', 'News', '1', '1', '1')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Admin', 'Features', '', '', '')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Admin', 'Reviews', '1', '1', '1')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Admin', 'Previews', '1', '1', '1')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Admin', 'Games', '1', '1', '1')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Staff', 'users', '', '', '')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Staff', 'sections', '', '', '')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Staff', 'files', '1', '', '')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Staff', 'gallery', '1', '', '')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Staff', 'pages', '1', '', '')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Staff', 'polls', '1', '', '')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Staff', 'fields', '', '', '')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Staff', 'templates', '', '', '')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Staff', 'News', '1', '1', '1')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Staff', 'Features', '', '', '')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Staff', 'Reviews', '1', '1', '1')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Staff', 'Previews', '1', '1', '1')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Staff', 'Games', '1', '1', '1')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Member', 'users', '', '', '')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Member', 'sections', '', '', '')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Member', 'files', '', '', '')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Member', 'gallery', '', '', '')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Member', 'pages', '', '', '')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Member', 'polls', '', '', '')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Member', 'fields', '', '', '')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Member', 'templates', '', '', '')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Member', 'News', '', '', '')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Member', 'Features', '', '', '')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Member', 'Reviews', '', '', '')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Admin', 'plugins', 1, 1, 1)") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Member', 'Previews', '', '', '')") == TRUE && mysql_query("INSERT INTO `".$pre."permissions` VALUES (null, 'Member', 'Games', '', '', '')") == TRUE)  {
$data .= "Entered data for table '".$pre."permissions'? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= "Entered data for table '".$pre."permissions'? <font color='red'>NO</font><br />";
}

if (mysql_query("INSERT INTO `".$pre."plugins` VALUES (null, 'Affiliates', 'affiliates.php', '1.2', 'On')") == TRUE && mysql_query("INSERT INTO ".$pre."plugins VALUES (null, 'Sitemap', 'sitemap.php', '1.1', 'On')") == TRUE && mysql_query("INSERT INTO `".$pre."plugins` VALUES (null, 'RSS Importer', 'rss_importer.php', '1.2', 'On')") == TRUE && mysql_query("INSERT INTO `".$pre."plugins` VALUES (null, 'Shoutbox', 'shoutbox.php', '1.1', 'On')") == TRUE && mysql_query("INSERT INTO `".$pre."plugins` VALUES (null, 'TinyURL', 'tinyurl.php', '1.0', 'On')") == TRUE && mysql_query("INSERT INTO `".$pre."plugins` VALUES (null, 'Form Builder', 'form_builder.php', '1.0', 'On')") == TRUE) {
$data .= "Entered data for table '".$pre."plugins'? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= "Entered data for table '".$pre."plugins'? <font color='red'>NO</font><br />";
}

if (mysql_query("INSERT INTO `".$pre."polls` VALUES (1, 'Your impression of AdaptCMS, so far?', 'poll', '', 'Your impression of AdaptCMS, so far?', '0', '".time()."')") == TRUE && mysql_query("INSERT INTO `".$pre."polls` VALUES (2, 'AWESOME!!!', 'option', '', 'Your impression of AdaptCMS, so far?', '0', '".time()."')") == TRUE && mysql_query("INSERT INTO `".$pre."polls` VALUES (3, 'Pretty nice', 'option', '', 'Your impression of AdaptCMS, so far?', '0', '".time()."')") == TRUE && mysql_query("INSERT INTO `".$pre."polls` VALUES (4, 'Not bad, but I see some issues', 'option', '', 'Your impression of AdaptCMS, so far?', '0', '".time()."')") == TRUE && mysql_query("INSERT INTO `".$pre."polls` VALUES (5, 'Sucks :(', 'option', '', 'Your impression of AdaptCMS, so far?', '0', '".time()."')") == TRUE)  {
$data .= "Entered data for table '".$pre."polls? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= "Entered data for table '".$pre."polls'? <font color='red'>NO</font><br />";
}

if (mysql_query("INSERT INTO `".$pre."ranks` VALUES (1, 'n00b', 'pink', '', '0')") == TRUE && mysql_query("INSERT INTO `".$pre."ranks` VALUES (2, 'Beginner', 'orange', '', '25')") == TRUE && mysql_query("INSERT INTO `".$pre."ranks` VALUES (3, 'Prospect', 'red', '', '50')") == TRUE && mysql_query("INSERT INTO `".$pre."ranks` VALUES (4, 'Pro', 'blue', '', '100')") == TRUE)  {
$data .= "Entered data for table '".$pre."ranks'? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= "Entered data for table '".$pre."ranks'? <font color='red'>NO</font><br />";
}

if (mysql_query("INSERT INTO `".$pre."relations` VALUES (1, 'Previews', 'Games')") == TRUE && mysql_query("INSERT INTO `".$pre."relations` VALUES (4, 'Features', 'Games')") == TRUE && mysql_query("INSERT INTO `".$pre."relations` VALUES (2, 'Reviews', 'Games')") == TRUE && mysql_query("INSERT INTO `".$pre."relations` VALUES (3, 'News', 'Games')") == TRUE)  {
$data .= "Entered data for table '".$pre."relations'? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= "Entered data for table '".$pre."relations'? <font color='red'>NO</font><br />";
}

if (mysql_query("INSERT INTO `".$pre."sections` VALUES (3, 'Reviews', 'section')") == TRUE && mysql_query("INSERT INTO `".$pre."sections` VALUES (5, 'Features', 'section')") == TRUE && mysql_query("INSERT INTO `".$pre."sections` VALUES (4, 'Previews', 'section')") == TRUE && mysql_query("INSERT INTO `".$pre."sections` VALUES (1, 'Games', 'sub')") == TRUE && mysql_query("INSERT INTO `".$pre."sections` VALUES (2, 'News', 'section')") == TRUE) {
$data .= "Entered data for table '".$pre."sections'? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= "Entered data for table '".$pre."sections'? <font color='red'>NO</font><br />";
}

if (mysql_query("INSERT INTO `".$pre."settings` VALUES (null, 'General', '', '', 'section', '')") == TRUE && mysql_query("INSERT INTO `".$pre."settings` VALUES (null, 'Other', '', '', 'section', '')") == TRUE && mysql_query("INSERT INTO `".$pre."settings` VALUES (null, 'guestsc', 'Can guests post comments?', 'no', 'setting', 'General')") == TRUE && mysql_query("INSERT INTO `".$pre."settings` VALUES (null, 'guestsp', 'Can guests post content?', 'no', 'setting', 'General')") == TRUE && mysql_query("INSERT INTO `".$pre."settings` VALUES (null, 'wysiwyg', 'Enabled wysiwyg editor?', 'yes', 'setting', 'Other')") == TRUE && mysql_query("INSERT INTO `".$pre."settings` VALUES (null, 'mod_rewrite', 'Enable mod_rewrite?', 'yes', 'setting', 'Other')") == TRUE && mysql_query("INSERT INTO `".$pre."settings` VALUES (null, 'online', 'Is the site online?', 'yes', 'setting', 'General')") == TRUE && mysql_query("INSERT INTO `".$pre."settings` VALUES (null, 'sitename', 'Name of website.', '".$_POST['sitename']."', 'setting', 'General')") == TRUE && mysql_query("INSERT INTO `".$pre."settings` VALUES (null, 'limit', '# of items to display per page.', '15', 'setting', 'Other')") == TRUE && mysql_query("INSERT INTO `".$pre."settings` VALUES (null, 'Variables', '', '', 'section', '')") == TRUE && mysql_query("INSERT INTO `".$pre."settings` VALUES (null, 'date_format', 'Date format', 'M d, Y - g:i a', 'setting', 'Other')") == TRUE && mysql_query("INSERT INTO `".$pre."settings` VALUES (null, 'home_section', 'For homepage, which section\'s content should be shown? (ex. News or put in nothing, for all to be used)', 'News', 'setting', 'Other')") == TRUE && mysql_query("INSERT INTO `".$pre."settings` VALUES (null, 'Modules', '', '', 'section', '')") == TRUE && mysql_query("INSERT INTO `".$pre."settings` VALUES (null, 'cache', 'Turning this to \"yes\" will enable the feature to cache your frontend pages.', 'no', 'setting', 'Modules')") == TRUE && mysql_query("INSERT INTO `".$pre."settings` VALUES (null, 'banned_ips', 'Separated by commas, put IP\'s that will not be able to access your site.', 'localhost,127.0.0.0', 'setting', 'Modules')") == TRUE && mysql_query("INSERT INTO `".$pre."settings` VALUES (null, 'banned_users', 'Separated by commas, put the names of users that will not be able to access your site. (they will see a message)', '', 'setting', 'Modules')") == TRUE && mysql_query("INSERT INTO `".$pre."settings` VALUES (null, 'poll_type', 'What type of display? graphic or just text?', 'graphic', 'setting', 'Other')") == TRUE && mysql_query("INSERT INTO ".$pre."settings VALUES (null, 'sitemap_update', 'How often should a sitemap file be generated? (in days)', '14', 'setting', 'Modules')") == TRUE && mysql_query("INSERT INTO ".$pre."settings VALUES (null, 'sitemap_yahoo_key', 'Put in your yahoo API key (only required for yahoo to be pinged upon sitemap update)', '', 'setting', 'Modules')") == TRUE && mysql_query("INSERT INTO ".$pre."settings VALUES (null, 'captcha_comments', 'Enter in \"yes\" if you would like a captcha confirmation to show when someone is adding a comment to an article. \"no\" will not show it.', 'yes', 'setting', 'Modules')") == TRUE && mysql_query("INSERT INTO ".$pre."settings VALUES (null, 'offline_message', 'Enter an offline message, this will be shown if you set your website to be offline.', 'Sorry, but we are currently offline. Please come back soon.', 'setting', 'General')") == TRUE && mysql_query("INSERT INTO `".$pre."settings` VALUES (null, 'gallery_width', 'Width for gallery thumbnail.', '150', 'setting', 'Modules')") == TRUE && mysql_query("INSERT INTO `".$pre."settings` VALUES (null, 'gallery_height', 'Height for gallery thumbnail.', '90', 'setting', 'Modules')") == TRUE && mysql_query("INSERT INTO ".$pre."settings VALUES(null, 'trackback_urls', 'Notify websites of new articles. Separate with a comma (ex. http://weblogs.com/RPC2,http://www.bblog.com/ping.php,http://ping.blo.gs)', 'http://www.bblog.com/ping.php,http://ping.blo.gs', 'setting', 'Modules')") == TRUE && mysql_query("INSERT INTO ".$pre."settings VALUES(null, 'Polls', '', '', 'section', '')") == TRUE && mysql_query("INSERT INTO ".$pre."settings VALUES(null, 'custom_poll_limit', 'What is the max amount of custom poll options that can be entered? (note that the custom poll option must be checked for the specific poll and someone may only enter 1 themselves)', '3', 'setting', 'Polls')") == TRUE && mysql_query("INSERT INTO ".$pre."settings VALUES(null, 'custom_poll_guest', 'Can guests enter in a custom poll option? (applicable if the \"custom poll option\" is checked for the specific poll)', 'no', 'setting', 'Polls')") == TRUE && mysql_query("INSERT INTO ".$pre."settings VALUES(null, 'admin_limit', '# of items to display per page (admin panel)', '20', 'setting', 'Other')") == TRUE && mysql_query("INSERT INTO `".$pre."settings` VALUES (null, 'word_filter', 'Separate bad words with a , (ex. word,word2,word3).', 'fuck,bitch,cunt,whore,nigger', 'setting', 'Other')") == TRUE && mysql_query("INSERT INTO `".$pre."settings` VALUES (null, 'guests_shoutbox', 'Can guests post to the Shoutbox?', 'no', 'setting', 'General')") == TRUE && mysql_query("INSERT INTO ".$pre."settings VALUES(null, 'captcha_login', 'Enter in \"yes\" if you would like a captcha confirmation to show when someone attempts to login in the frontend of your website.', 'no', 'setting', 'Modules')") == TRUE) {
$data .= "Entered data for table '".$pre."settings'? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= "Entered data for table '".$pre."settings'? <font color='red'>NO</font><br />";
}

$mysqls = "";
$mysqls .= "INSERT INTO `".$pre."templates` VALUES (";
$mysqls .= '2, "layout", "<html>
<head>
<script language=\'javascript\'>function awindow(towhere, newwinname, properties) {window.open(towhere,newwinname,properties);}</script>
<STYLE type=\'text/css\'>body { font-family: tahoma;font-size: 11px;color: #4a4a4a; }td { font-family: tahoma;font-size: 11px;color: #4a4a4a;}a:link {color: #4a4a4a; text-decoration: none;font-weight: bold}a:visited {color: #4a4a4a; text-decoration: none;font-weight: bold} a:active {color: #4a4a4a; text-decoration: none;font-weight: bold} a:hover {text-decoration: none; color: #4a4a4a;font-weight: bold}a:visited:hover {text-decoration: none; color: #4a4a4a;font-weight: bold</style>
</head>
<body>

<table cellpadding=\"0\" cellspacing=\"0\" width=\"757\" border=\"0\" align=\"center\"><tr><td>

<table cellpadding=\"0\" cellspacing=\"0\" width=\"757\" border=\"0\" align=\"center\"><tr><td><img src=\"<?php echo $siteurl; ?>skins/<?php echo $skin; ?>/top.png\"></td></tr></table><br />

<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td align=\"left\" valign=\"top\">

<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td background=\"<?php echo $siteurl; ?>includes/leftbg.png\" height=\"281\" width=\"168\" align=\"left\" valign=\"top\"><img src=\"<?php echo $siteurl; ?>skins/<?php echo $skin; ?>/menu1.png\">

<table cellpadding=\"10\" cellspacing=\"0\" border=\"0\" width=\"center\"><tr><td>
<a href=\"<?php echo $siteurl; ?>index.php\">Home</a>
{sections}<br />
<a href=\"<?php echo $mrw_1[gallery]; ?>\">Gallery</a><br /><br />
{pages}<br /><br />
<?php echo translate(); ?>
</td></tr></table>
</td></tr></table><br />

<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td background=\"<?php echo $siteurl; ?>includes/leftbg.png\" height=\"281\" width=\"168\" align=\"left\" valign=\"top\"><img src=\"<?php echo $siteurl; ?>skins/<?php echo $skin; ?>/menu2.png\">

<table cellpadding=\"10\" cellspacing=\"0\" border=\"0\" width=\"center\"><tr><td>
<?php echo show_poll(\"1\", \"Your impression of AdaptCMS, so far?\"); ?><br clear=\'all\'><br>
<center>
<?php echo affiliates(\"\"); ?>
<br /><br />
<?php
if ($_SESSION[adaptcms_username]) {
//echo \"MEMBERS ONLY CONTENT HERE, REMOVE THE 2 SLASHES TO TEST OUT\";
}
?></center>
</td></tr></table>
</td></tr></table>


</td><td valign=\"top\" width=\"591\" align=\"center\"><table cellpadding=\"1\" cellspacing=\"0\" border=\"0\" width=\"480\"><tr><td align=\"center\">
<?php
if ($_SESSION[adaptcms_username]) {
?>
Welcome back <a href=\"<?php echo $mrw[profile]; ?>\"><?php echo $_SESSION[adaptcms_username]; ?></a>. There are <b><?php echo $time; ?></b> users online and <b><?php echo $num1; ?></b> articles at <a href=\'http://www.<?php echo $domain; ?>\'><?php echo $domain; ?></a> - <a href=\'<?php echo $mrw[logout]; ?>logout\'>Logout</a>
<?php
} else {
?>
Welcome <b>Guest</b>. Please <a href=\'<?php echo $mrw[login]; ?>login\'>Login</a> or <a href=\'<?php echo $mrw[register]; ?>register\'>Sign-Up</a> to use some features of <a href=\'http://www.<?php echo $domain; ?>\'><?php echo $domain; ?></a>
<?php
}
?>

</td><td align=\"right\">
<form action=\'<?php echo $_SERVER[REQUEST_URI]; ?>\' method=\'post\'><select name=\'skin\' style=\'background-color: <?php echo $color; ?>;color: <?php echo $color2; ?>;font-size: 11px;font-face: tahoma;font-weight: bold\' onchange=\'this.form.submit()\'><option value=\'skin1\' style=\'background-color: <?php echo $color; ?>;color: <?php echo $color2; ?>;font-size: 11px;font-face: tahoma;font-weight: bold\' selected> - Choose Skin -</option><option value=\'skin1\' style=\'background-color: #feb011;color: #4a4a4a;font-size: 11px;font-face: tahoma;font-weight: bold\'>Orange Skin</option><option value=\'skin2\' style=\'background-color: #db1c1c;color: white;font-size: 11px;font-face: tahoma;font-weight: bold\'>Red Skin</option><option value=\'skin3\' style=\'background-color: #5400ff;color: white;font-size: 11px;font-face: tahoma;font-weight: bold\'>Blue Skin</option><option value=\'skin4\' style=\'background-color: #176b12;color: white;font-size: 11px;font-face: tahoma;font-weight: bold\'>Green Skin</option><option value=\'skin5\' style=\'background-color: #64126b;color: white;font-size: 11px;font-face: tahoma;font-weight: bold\'>Dark Skin</option></select></form>
</td></tr></table>

<?php //BANNER SPOT HERE// ?><br /><br />

<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"center\"><tr><td background=\'<?php echo $siteurl; ?>includes/contentbg.png\' height=\'480\' width=\'518\' valign=\'top\' align=\'left\'><img src=\"<?php echo $siteurl; ?>skins/<?php echo $skin; ?>/content.png\">

<table cellpadding=\"10\" cellspacing=\"0\" border=\"0\" width=\"center\"><tr><td>{content}</td></tr></table>

</td></tr></table>
<img src=\"<?php echo $siteurl; ?>includes/footer1.png\">

</td></tr></table>
</td></tr></table>

</body>
</html>"';

$mysqls .= ", \"".time()."\")";

mysql_query("INSERT INTO `".$pre."templates` VALUES (1, 'search_results', '<tr><td>{link}</td><td>{cat}</td><td>{date}</td></tr>', '".time()."')");
mysql_query($mysqls);
mysql_query("INSERT INTO `".$pre."templates` VALUES (3, 'welcome_message', 'Welcome back {username}. You have {articles} articles and there are {online} users online at {domain} - {logout}', '".time()."')");
mysql_query("INSERT INTO `".$pre."templates` VALUES (4, 'content_list', '{link} - {cat}<br>', '".time()."')");
mysql_query("INSERT INTO `".$pre."templates` VALUES (5, 'page', '<b>{name}</b><br>\r\n\r\n<p>{page}</p>', '".time()."')");
mysql_query("INSERT INTO `".$pre."templates` VALUES (6, 'poll_results', '<table cellpadding=\'0\' cellspacing=\'0\' border=\'0\' align=\'center\'><tr><td><b>{question}</b><br />\r\n{options}\r\n<b>Votes:</b> {vote_total}</td></tr></table><br clear=\"all\">', '".time()."')");
mysql_query("INSERT INTO `".$pre."templates` VALUES (7, 'poll_options', '{name} {data}<br />', '".time()."')");
mysql_query("INSERT INTO `".$pre."templates` VALUES(8, 'Reviews', '<title>{subject} - {sitename}</title>\r\n\r\n<h2>{name}</h2>\r\n\r\n<table width=\"475\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\"><tr><td align=\"center\">{News;News;News}</td><td align=\"center\">{Previews;Preview;Previews}</td><td align=\"center\">{Games;Game Page;Games}</td><td align=\"center\">{Features;Feature;Features}</td></tr></table><br />\r\n\r\n<h3>{name}</h3>\r\n<b>By:</b> {author}<br>\r\n<b>Written:</b> {date}<br><br>\r\n\r\n<table width=\"475\" cellpadding=\'3\'><tr><td valign=\'top\'><img src=\"{Games_boxart_url}\"></td><td><p>{review_article}</p></tr></table><br>\r\n\r\n<table  width=\"475\" border=\"1\" cellpadding=\"3\" cellspacing=\"1\"><tr><td><u><font color=\'green\'>The Good</font></u></td><td><u><font color=\'red\'>The Bad</font></u></td></tr><tr><td>{the_good}</td><td>{the_bad}</td></tr></table><br>\r\n\r\n<center><h2>{overall_rating}/10</h2></center><br>\r\n\r\n<p><b>Rating:</b> {user_rate_img}\r\n{user_rate_form}</p>\r\n<br>{comments}<br>{cform}', '".time()."')");
mysql_query("INSERT INTO `".$pre."templates` VALUES(9, 'Previews', '<title>{subject} - {sitename}</title>\r\n\r\n<h2>{name}</h2>\r\n\r\n<table width=\"475\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\"><tr><td align=\"center\">{News;News;News}</td><td align=\"center\">{Reviews;Review;Reviews}</td><td align=\"center\">{Features;Feature;Features}</td><td align=\"center\">{Games;Game Page;Games}</td></tr></table><br />\r\n\r\n<h3>{name}</h3>\r\n<b>By:</b> {author}<br>\r\n<b>Written:</b> {date}<br><br>\r\n\r\n<table width=\"475\" cellpadding=\'3\'><tr><td valign=\'top\'><img src=\"{Games_boxart_url}\"></td><td><p>{preview_article}</p></tr></table><br>\r\n\r\n<center><h2>{anticipation_rating}/10</h2><br>\r\n\r\n<p><b>Rating:</b> {user_rate_img}\r\n{user_rate_form}</p>\r\n<br>{comments}<br>{cform}', '".time()."')");
mysql_query("INSERT INTO `".$pre."templates` VALUES(10, 'Games', '<title>{name} ({system}) - {sitename}</title>\r\n\r\n<h2>{name}</h2>\r\n\r\n<table width=\"475\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\"><tr><td align=\"center\">{News;News;News}</td><td align=\"center\">{Previews;Preview;Previews}</td><td align=\"center\">{Reviews;Review;Reviews}</td><td align=\"center\">{Features;Feature;Features}</td></tr></table><br />\r\n\r\n<table><tr><td><img src=\"{boxart_url}\"></td><td>{summary}</td></tr></table><br />\r\n\r\n<table width=\"475\"><tr><td bgcolor=\'white\'><b>Game Info</b></td></tr><tr><td><b>Publisher:</b> {publisher}</td></tr><tr><td><b>Developer:</b> {developer}</td></tr><tr><td><b>Genre:</b> {genre}</td></tr><tr><td><b>ESRB:</b> {ESRB}</td></tr><tr><td><b>Release:</b> {release_date}</td></tr><tr><td><b>Price:</b> {price}</td></tr></table><br />\r\n\r\n<p><b>Rating:</b> {user_rate_img}\r\n{user_rate_form}</p>\r\n<br>{comments}<br>{cform}', '".time()."')");
mysql_query("INSERT INTO `".$pre."templates` VALUES(11, 'News', '<title>{subject} - {sitename}</title>\r\n\r\n<h2>{name}</h2>\r\n\r\n<table width=\"475\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\"><tr><td align=\"center\">{Reviews;Review;Reviews}</td><td align=\"center\">{Previews;Preview;Previews}</td><td align=\"center\">{Games;Game Page;Games}</td><td align=\"center\">{Features;Feature;Features}</td></tr></table>\r\n\r\n<h3>{name}</h3>\r\n<b>Posted by:</b> {username} at <i>{date}</i><br><br>\r\n\r\n<b><i>{Short}</b></i><br><br>{Full}\r\n\r\n</td></tr></table><br>\r\n\r\n<p><b>Rating:</b> {user_rate_img}\r\n{user_rate_form}</p>\r\n<br>{comments}<br>{cform}', '".time()."')");
mysql_query("INSERT INTO `".$pre."templates` VALUES (12, 'section_page', '{name}', '".time()."')");
mysql_query("INSERT INTO `".$pre."templates` VALUES (13, 'homepage', '<title>{sitename} - Homepage</title>\r\n\r\n{content}<br>{archive}', '".time()."')");
mysql_query("INSERT INTO `".$pre."templates` VALUES (14, 'homepage_content', '<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" align=\"center\" width=\"394\"><tr><td><font face=\"Tahoma\" size=\"4\" color=\"#3A3A3A\"><b>{link}</b></font><br />Posted: {date} (<b>{section}</b>)</td></tr><tr><td><br />{story}<br /><br /></td></tr><tr><td align=\"right\">{comments} (<font color=\"red\"><b>{cnum}</b></font>) <b>| {pcomment}</b><br /><br /></td></tr><tr><td align=\"center\">------------------------------<br /><br /></td></tr></table>', '".time()."')");
mysql_query("INSERT INTO `".$pre."templates` VALUES (15, 'comments', '<br /><table class=\"newstxt\" cellpadding=\"5\" cellspacing=\"2\" border=\"0\" style=\"border: 2px solid #868585\" width=\"100%\"><tr><td bgcolor=\"#868585\"> <a href=\"/user-{author}.html\">{author}</a> @ <i>{date}</i></td></tr><tr><td bgcolor=\"white\"> {comment}</td></tr></table><br />', '".time()."')");
mysql_query("INSERT INTO `".$pre."templates` VALUES (16, 'poll_vote', '<table cellpadding=\'0\' cellspacing=\'0\' border=\'0\' align=\'right\'><tr><td><b>{question}</b></td></tr></table><br clear=\'all\'>\r\n<table cellpadding=\'0\' cellspacing=\'0\' border=\'0\' align=\'right\'>\r\n{options}\r\n<tr><td><a href=\"".$siteurl."poll-results/\">Results</a></td><td>{submit}</td></tr></table><br clear=\'all\'>', '".time()."')");
mysql_query("INSERT INTO `".$pre."templates` VALUES (17, 'profile', '<title>{username}\'s Profile - {sitename}</title>\r\n<table cellspacing=\"0\" cellpadding=\"2\" border=\"0\" align=\"center\" width=\"100%\"><tr><td align=\'center\'><b><a href=\'mailto:{email}\'>{username}</a></b><br><img src=\'{user_avatar}\' style=\'border: 1px solid black\'><br>{level}</td><td align=\'left\'><table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td><b>Name</b></td><td>{user_name}</td></tr><tr><tr><td><b>Birthday</b></td><td>{user_birthday_month} {user_birthday_day}, {user_birthday_year}</td></tr><tr><td><b>Website</b></td><td><a href=\'{user_website}\' target=\'popup\'>{user_website}</a></td></tr><td><b>AIM</b></td><td><a href=\'aim:goim?screenname={user_aim}&message=Hello+Are+you+there?\'>{user_aim}</a></td></tr><tr><td><b>MSN</b></td><td>{user_aim}</td></tr><tr><td><b>YIM</b></td><td><a href=\'http://edit.yahoo.com/config/send_webmesg?.target={user_yahoo}&.src=pg\'>{user_yahoo}</a></td></tr><tr><td><b>ICQ</b></td><td><a href=\'http://www.icq.com/whitepages/cmd.php?uin={user_icq}&action=message\'>{user_icq}</a></td></tr><tr><td><b>Google Talk</b></td><td>{user_gtalk}</td></tr></table></td></tr></table><table><tr><td align=\'right\'>{content_posted}</td></tr></table><br><br><center>{edit_profile}</center>', '".time()."')");
mysql_query("INSERT INTO `".$pre."templates` VALUES (18, 'related_articlelist_entry', '<li>{name}</li>', '".time()."')");
mysql_query("INSERT INTO `".$pre."templates` VALUES (19, 'related_articlelist_start', '<ul>', '".time()."')");
mysql_query("INSERT INTO `".$pre."templates` VALUES (20, 'related_articlelist_end', '</ul>', '".time()."')");
mysql_query("INSERT INTO `".$pre."templates` VALUES (21, 'gallery', '<title>{sitename} - Gallery</title>\r\n\r\n<table align=\'center\' border=\'0\' cellpadding=\'10\' cellspacing=\'5\' width=\'100%\'><tr>{images}</tr></table>', '".time()."')");
mysql_query("INSERT INTO ".$pre."templates VALUES (22, 'plugin_affiliates', '{affiliate}<br>', '".time()."')");
mysql_query("INSERT INTO ".$pre."templates VALUES (23, 'gallery_view', '<title>{sitename} - {name} Gallery</title>\r\n\r\n<h2>{name}</h2>\r\n\r\n<table width=\'100%\'><tr><td align=\"left\">{download_zip}</td><td align=\"right\">{sortby}</td></tr></table>\r\n\r\n<table align=\'center\' border=\'0\' cellpadding=\'5\' cellspacing=\'3\' width=\'100%\'><tr>{image}</tr></table>', '".time()."')");
mysql_query("INSERT INTO ".$pre."templates VALUES (24, 'gallery_image', '<td><a href=\'{image}\' rel=\'lightbox[{name}]\'><img src=\'{thumb}\' border=\'1\'></a></td>', '".time()."')");

if (@mysql_num_rows(mysql_query("SELECT * FROM ".$pre."templates")) == 24) {
$data .= "Entered data for table '".$pre."templates'? <font color='blue'>YES</font><br />";
} else {
$error = $error + 1;
$data .= "Entered data for table '".$pre."templates'? <font color='red'>NO</font><br />";
}

$data .= "</p><p>";

if ($error == "0") {
$data .= "<u>SQL Uploaded to Database?: </u>";
$data .= " <font color='blue'>YES</font></p><p>";
$sql = mysql_query("INSERT INTO ".$pre."users VALUES (null, '".$_POST['username']."', '".md5($_POST['password'])."', '".$_POST['email']."', 'Admin', 'n00b', '0', '".time()."')");
$_SESSION[adaptcms_username] = strip_tags($_POST['username']);
$_SESSION[adaptcms_password] = strip_tags(md5($_POST['password']));

if ($sql == TRUE) {
eval (" ?> ".admin_header()." <?php ");
echo $data;
echo "User account added successfully?: ";
echo " <font color='blue'>YES</font>";
echo "&nbsp;&nbsp;&nbsp;&nbsp;You are now finished! You can now view the - <a href='index.php'><b>Frontend</b></a> and the <a href='admin.php'><b>Admin Panel</b></a><br /><br />Thank you and enjoy using AdaptCMS Lite ".$version."! (<b>don't forget to delete install.php!</b>)";

mysql_query("INSERT INTO `".$pre."articles` VALUES (1, 'Welcome to AdaptCMS', '".$_POST['username']."', 'News', '', '".time()."', '".date("m")."', '".date("Y")."', '0|0', '0')");
mysql_query("INSERT INTO `".$pre."pages` VALUES (1, 'Contact Us', 'contactus', 'You can contact us through the following options:\r\n<br><br>\r\nAIM: My AIM here<br>\r\nE-Mail: ".$_POST['email']."', '".$_POST['username']."', '".time()."')");
mysql_query("INSERT INTO `".$pre."comments` VALUES (1, 1, 'A test comment here!<br /><br />Feel free to delete this.', '".$_POST['username']."', '".$_POST['email']."', '".$siteurl."', '".$_SERVER['REMOTE_ADDR']."', '".time()."')");
} else {
eval (" ?> ".admin_header()." <?php ");
echo "User account added successfully?: ";
echo "<font color='red'>NO</font>";
echo "&nbsp;&nbsp;&nbsp;&nbsp;Please make sure the SQL is uploaded, database information is correct and then try again";
}
echo "</p>";
} else {
eval (" ?> ".admin_header()." <?php ");
echo $data;
echo "<u>SQL Uploaded to Database?: </u>";
echo "<font color='red'>NO</font>";
}
} else {
if (@mysql_num_rows(@mysql_query("SELECT * FROM ".$pre."templates")) == 0) {
eval (" ?> ".admin_header()." <?php ");
echo "Database information updated?: ";
echo "<font color='red'>NO</font>";
echo "&nbsp;&nbsp;&nbsp;&nbsp;Please make sure the database information is correct and then try again</p>";
} else {
header("location: install.php?step=upgrade");
}
}
} else {
echo "Sorry, not all the information was filled out. Go back and make sure everything is entered.";
}
}
}
eval (" ?> ".admin_footer()." <?php ");
?>