<?php
$thisapp="OS_Commerce";
$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'})">
<cpanel Fileman="fmmkdir($homedir,.htpasswds)">
<cpanel Fileman="fmmkdir($homedir/.htpasswds,$FORM{'installdir'})">
<cpanel Fileman="fmmkdir($homedir/.htpasswds/$FORM{'installdir'},$FORM{'oscadminfolder'})">
<cpanel Fileman="fmmkdir($FORM{'userrootpath'},$FORM{'installdir'})">
<cpanel Fileman="fmmkdir($FORM{'scriptpath'},$FORM{'oscadminfolder'})">
<cpanel Htaccess="set_protect($FORM{'protectdir'},$FORM{'protected'},$FORM{'oscresname'})"> 
<cpanel Htaccess="set_pass($FORM{'protectdir'},$FORM{'adminuser'},$FORM{'password'})">            
-->

<?
$INSTALLDIR=$installdir;
$MYSQLUSER = $connect;
$MYSQLDB = $connect;
$MYSQLPASS = $SQLPass;
$USER = $REMOTE_USER;
$DOMAIN = "<cpanel print="DOMAIN">";
$USER_ROOT = $userroot;
$SCRIPTPATH = $scriptpath;
$THISDEPOT = $DEPOT.$thisapp;
$SQLDATA = $SCRIPTPATH."/data.sql";
$ADMIN = $adminuser;
$SHOPNAME = $shopname;
$OWNER = $owner;
$FROM = $from;
$EMAIL = $email;
$DOB = $dob;
$SEX = $sex;
$VAT = $vat;
$COMPANY = $company;
$SUBURB = $suburb;
$STATE = $state;
$SSL = $ssl;
$SSLSERVER = $sslserver;

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

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."/includes/configure.php";
$CONFIG_FILE[]=$SCRIPTPATH."/admin/includes/configure.php";
$CONFIG_FILE[]=$SCRIPTPATH."/includes/languages/english.php";
$CONFIG_FILE[]=$SCRIPTPATH."/includes/languages/espanol.php";
$CONFIG_FILE[]=$SCRIPTPATH."/includes/languages/german.php";
$CONFIG_FILE[]=$SCRIPTPATH."/admin/includes/languages/english.php";
$CONFIG_FILE[]=$SCRIPTPATH."/admin/includes/languages/espanol.php";
$CONFIG_FILE[]=$SCRIPTPATH."/admin/includes/languages/german.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("<SHOPNAME>", $SHOPNAME, $contents);
		$contents = str_replace("<OWNER>", $OWNER, $contents);
		$contents = str_replace("<FROM>", $FROM, $contents);
		$contents = str_replace("<EMAIL>", $EMAIL, $contents);
		$contents = str_replace("<VAT>", $VAT, $contents);
		$contents = str_replace("<DOB>", $DOB, $contents);
		$contents = str_replace("<SEX>", $SEX, $contents);
		$contents = str_replace("<COMPANY>", $COMPANY, $contents);
		$contents = str_replace("<SUBURB>", $SUBURB, $contents);
		$contents = str_replace("<STATE>", $STATE, $contents);
		$contents = str_replace("<SSL>", $SSL, $contents);
		$contents = str_replace("<SSLSERVER>", $SSLSERVER, $contents);
		$contents = str_replace("<USER_ROOT>", $USER_ROOT, $contents);
		$contents = str_replace("<SCRIPTPATH>", $SCRIPTPATH, $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">You need a username and a password to enter the admin area. Your username is <span class="Hint"><b><?=$ADMIN ?></b></span>. Your password is <span class="Hint"><b><?=$password ?></b></span>. The full URL to the admin area <span class="Hint"><b>(Bookmark this!)</b></span>: 
<a href="http://<?=$DOMAIN ?>/<?=$installdir ?>/admin/" target="blank">http://<?=$DOMAIN ?>/<?=$installdir ?>/admin/</a></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>

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