<?php
$thisapp="Post-Nuke";
$humanapp=str_replace("_", " ", $thisapp);
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Fantastico</title>

<?php
if (is_file("/usr/local/cpanel/base/frontend/<cpanel print="$CPDATA{'RS'}">/fantasticoinc.php"))
	{
	include("/usr/local/cpanel/base/frontend/<cpanel print="$CPDATA{'RS'}">/fantasticoinc.php");
	}
	
if ($inxcontroller) {
?>
<cpanel include="../themeheader_subdir1.html">
<cpanel include="includes/mainmenu_icon_subdir.html">
<cpanel include="../themeheader_subdir2.html">
<cpanel include="includes/mainmenu_label.html">
<cpanel include="../themeheader_subdir3.html">

<?php
} else {
?>
<cpanel include="includes/fantasticoheader.html">

<?php
}
?>

<cpanel include="admin/adminuser.inc.php">
<cpanel include="admin/fantasticopath.inc.php">
<cpanel include="includes/adminsettingspath.inc.php">
<cpanel include="includes/restrictions.inc.php">
<cpanel include="includes/masterfilespath.inc.php">
<cpanel include="includes/sidemenu.php">
<cpanel include="includes/mysqlconfig.php">



<p class="TableMiddleHead">Install <?=$humanapp ?> (3/3)</p>

<cpanel Mysql="adddb($FORM{'thismakedb'})"> 
<cpanel Mysql="adduser($FORM{'thismakedb'},$FORM{'SQLPass'})">
<cpanel Mysql="adduserdb($FORM{'connect'},$FORM{'connect'})">

<?
$INSTALLDIR=$installdir;
$MYSQLUSER = $connect;
$MYSQLDB = $connect;
$MYSQLPASS = $SQLPass;
$USER = $REMOTE_USER;
$DOMAIN = "<cpanel print="DOMAIN">";
$USER_ROOT = "<cpanel print="$homedir">/public_html";
$SCRIPTPATH = $scriptpath;
$THISDEPOT = $DEPOT.$thisapp;
$SQLDATA = $SCRIPTPATH."/data.sql";
$ADMIN = $adminuser;
$ADMINPASS = md5($password);
$SITENAME = $sitename;
$SITEURL = "http://".$DOMAIN."/".$INSTALLDIR;
$SLOGAN = $slogan;
$KEYWORDS = $keywords;
$BEGINDATE = $begindate;
$ADMINEMAIL = $adminemail;
$ARTICLECOUNT = $articlecount;
$ARTICLECOUNTHOME = $articlecounthome;
$FOOTER = $footer;
$BACKENDTITLE = $backendtitle;
$SENDEMAIL = $sendemail;
$ALLOWCOMMENTS = $allowcomments;
$MULTILINGUAL = $multilingual;
$USEFLAGS = $useflags;
$USER_REGDATE = time();

$LANGUAGE = $language;

$SITENAMESIZE = strlen($SITENAME);
$SLOGANSIZE = strlen($SLOGAN);
$KEYWORDSSIZE = strlen($KEYWORDS);
$BEGINDATESIZE = strlen($BEGINDATE);
$ADMINEMAILSIZE = strlen($ADMINEMAIL);
$FOOTERSIZE = strlen($FOOTER);
$BACKENDTITLESIZE = strlen($BACKENDTITLE);


//-----------------------------------------


if (!(is_dir($userdata)))
	{
	mkdir($userdata) or die("<p><span class=Hint><b>ERROR!</b></span> Your base directory must have write permissions for user to proceed");
	}
if (!(is_dir($userdata."/".$thisapp))) 
	{
	mkdir($userdata."/".$thisapp) or die("<p><span class=Hint><b>ERROR!</b></span> Your base directory must have write permissions for user to proceed");
	}

$myprefs = fopen($userdata."/".$thisapp."/"."$INSTALLDIR","w");
$fp = fputs($myprefs,"<?");
$fp = fwrite($myprefs,"\n");
$fp = fwrite($myprefs,"\$thisdb = \"".$mysqldb."\"; ");
$fp = fwrite($myprefs,"\n");
$fp = fputs($myprefs,"?>");
fclose($myprefs);

mkdir($SCRIPTPATH);
	$shell="cp -rfp ". $THISDEPOT ."/* ". $SCRIPTPATH."/";
	system($shell);

$CONFIG_FILE[]=$SCRIPTPATH."/config.php";
$CONFIG_FILE[]=$SQLDATA;

foreach($CONFIG_FILE AS $FILE){
	if(is_file($FILE)){
		echo "<b>".$FILE."</b> configured<br>";
		$fd = fopen ($FILE, "r");
		$contents = fread ($fd, filesize ($FILE));
		$contents = str_replace("<MYSQLHOST>", $MYSQLHOST, $contents);
		$contents = str_replace("<MYSQLUSER>", $MYSQLUSER, $contents);
		$contents = str_replace("<MYSQLDB>", $MYSQLDB, $contents);
		$contents = str_replace("<MYSQLPASS>", $MYSQLPASS, $contents);		
		$contents = str_replace("<USER>", $USER, $contents);
		$contents = str_replace("<DOMAIN>", $DOMAIN, $contents);
		$contents = str_replace("<ADMIN>", $ADMIN, $contents);
		$contents = str_replace("<ADMINPASS>", $ADMINPASS, $contents);
		$contents = str_replace("<SITENAME>", $SITENAME, $contents);
		$contents = str_replace("<SITEURL>", $SITEURL, $contents);
		$contents = str_replace("<SLOGAN>", $SLOGAN, $contents);
		$contents = str_replace("<KEYWORDS>", $KEYWORDS, $contents);
		$contents = str_replace("<BEGINDATE>", $BEGINDATE, $contents);
		$contents = str_replace("<ADMINEMAIL>", $ADMINEMAIL, $contents);
		$contents = str_replace("<ARTICLECOUNT>", $ARTICLECOUNT, $contents);
		$contents = str_replace("<ARTICLECOUNTHOME>", $ARTICLECOUNTHOME, $contents);
		$contents = str_replace("<FOOTER>", $FOOTER, $contents);
		$contents = str_replace("<BACKENDTITLE>", $BACKENDTITLE, $contents);		
		$contents = str_replace("<SENDEMAIL>", $SENDEMAIL, $contents);		
		$contents = str_replace("<ALLOWCOMMENTS>", $ALLOWCOMMENTS, $contents);
		$contents = str_replace("<MULTILINGUAL>", $MULTILINGUAL, $contents);		
		$contents = str_replace("<USEFLAGS>", $USEFLAGS, $contents);
		$contents = str_replace("<LANGUAGE>", $LANGUAGE, $contents);
		$contents = str_replace("<SITENAMESIZE>", $SITENAMESIZE, $contents);
		$contents = str_replace("<SLOGANSIZE>", $SLOGANSIZE, $contents);		
		$contents = str_replace("<KEYWORDSSIZE>", $KEYWORDSSIZE, $contents);		
		$contents = str_replace("<BEGINDATESIZE>", $BEGINDATESIZE, $contents);
		$contents = str_replace("<ADMINEMAILSIZE>", $ADMINEMAILSIZE, $contents);		
		$contents = str_replace("<FOOTERSIZE>", $FOOTERSIZE, $contents);
		$contents = str_replace("<BACKENDTITLESIZE>", $BACKENDTITLESIZE, $contents);
		$contents = str_replace("<USER_REGDATE>", $USER_REGDATE, $contents);
		$contents = str_replace("<INSTALLDIR>", $INSTALLDIR, $contents);

		fclose ($fd);
		$fd = fopen ($FILE, "w");
		fputs($fd, $contents);
		fclose($fd);
	}else{
echo ++$i.") File:<b> ".$FILE."</b> [<span class='Hint'><i>Error </i></span>]<br>";
	}
}
	$shellsqlimport=$MYSQLPATH. " -h" .$MYSQLHOST. " -u ". $MYSQLUSER ." -p". $MYSQLPASS." ".$MYSQLDB." < $SQLDATA";
	system($shellsqlimport);
?>

<p align="center"><b>Please notice:</b></p>
<p align="left">We only offer auto-installation and auto-configuration of <span class="Emphasize"><?=$humanapp ?></span> but do not offer any kind of support.</p>
<p align="left">The full URL to this installation of <span class="Emphasize"><?=$humanapp ?></span>: <a href="http://<?=$DOMAIN ?>/<?=$installdir ?>" target="blank">http://<?=$DOMAIN ?>/<?=$installdir ?></a>. </p>
<p align="left">Login with username <span class="Hint"><b><?=$ADMIN ?></b></span>, password <span class="Hint"><b><?=$password ?></b></span> to access the administration menu.</p>

<cpanel include="includes/fantasticofooter.html">
