<?php

/************************************************************************/
/* Eleonline                                                            */
/* ============================================                         */
/*  Installer was based on Joomla Installer                             */
/************************************************************************/


/** Include common.php */
require_once( 'common.php' );

$DBhostname = mosGetParam( $_POST, 'DBhostname', '' );
$DBuserName = mosGetParam( $_POST, 'DBuserName', '' );
$DBpassword = mosGetParam( $_POST, 'DBpassword', '' );
$DBname  	= mosGetParam( $_POST, 'DBname', '' );
$DBPrefix  	= mosGetParam( $_POST, 'DBPrefix', 'soraldo' );
$sitename =  mosGetParam( $_POST, 'sitename', '' ) ;
$nomecomune = mosGetParam( $_POST, 'nomecomune', '' ) ;
$istat =  mosGetParam( $_POST, 'istat', '' ) ;
$Capoluogo = mosGetParam( $_POST, 'Capoluogo', '' );
$Lingua = mosGetParam( $_POST, 'Lingua', '' );
$Multicomune = mosGetParam( $_POST, 'Multicomune', '' );
$Replica = mosGetParam( $_POST, 'Replica', '' );

//tema
$tema = mosGetParam( $_POST, 'tema', '' );
$sceltatema = mosGetParam( $_POST, 'sceltatema', '' );
$blocco = mosGetParam( $_POST, 'blocco', '' );
$flash = mosGetParam( $_POST, 'flash', '' );
// d'hondt

$Limite = mosGetParam( $_POST, 'Limite', '' );

$adminName = mosGetParam( $_POST, 'adminName', '');
$adminEmail = mosGetParam( $_POST, 'adminEmail', '');
$CreateUSer = intval( mosGetParam( $_POST, 'CreateUSer', 1 ) );
$configArray['siteUrl'] = trim( mosGetParam( $_POST, 'siteUrl', '' ) );
$configArray['absolutePath'] = trim( mosGetParam( $_POST, 'absolutePath', '' ) );
if (get_magic_quotes_gpc()) {
	$configArray['absolutePath'] = stripslashes(stripslashes($configArray['absolutePath']));
	$sitename = stripslashes(stripslashes($sitename));
}





if ($sitename == '') {
	echo "<form name=\"stepBack\" method=\"post\" action=\"install2.php\">
			<input type=\"hidden\" name=\"DBhostname\" value=\"$DBhostname\">
			<input type=\"hidden\" name=\"DBuserName\" value=\"$DBuserName\">
			<input type=\"hidden\" name=\"DBpassword\" value=\"$DBpassword\">
			<input type=\"hidden\" name=\"DBname\" value=\"$DBname\">
			<input type=\"hidden\" name=\"DBPrefix\" value=\"$DBPrefix\">
			<input type=\"hidden\" name=\"DBcreated\" value=1>
			
		</form>";

	echo "<script>alert('Il nome del sito non e' stato inserito'); document.stepBack.submit();</script>";
	return;
}

echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>PHP-Nuke Installer</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="install.css" type="text/css" />
<script type="text/javascript">
<!--
function check() {
	// form validation check
	var formValid = true;
	var f = document.form;
	if ( f.adminName.value == '' ) {
		alert('Prego inserisci un nome per il tuo amministratore');
		f.siteUrl.focus();
		formValid = false;
	} else if ( f.siteUrl.value == '' ) {
		alert('Prego inserisci un URL corretto per il tuo sito');
		f.siteUrl.focus();
		formValid = false;
	} else if ( f.absolutePath.value == '' ) {
		alert('Prego inserisci la path assoluta del tuo sito');
		f.absolutePath.focus();
		formValid = false;
	} else if ( f.adminEmail.value == '' ) {
		alert('Prego inserisci un indirizzo email per contattare il tuo amministratore');
		f.adminEmail.focus();
		formValid = false;
	} else if ( f.adminPassword.value == '' ) {
		alert('Prego inserisci una password per il tuo amministratore');
		f.adminPassword.focus();
		formValid = false;
	}

	return formValid;
}

//-->
</script>
</head>
<body onload="document.form.siteUrl.focus();">
<div id="wrapper">
	<div id="header">
		<div id="eleonline"><img src="header_install.png" alt="Installazione Eleonline" title="Installazione Eleonline" /></div>
	</div>
</div>

<div id="ctr" align="center">
	<form action="install4.php" method="post" name="form" id="form" onsubmit="return check();">
	<input type="hidden" name="DBhostname" value="<?php echo "$DBhostname"; ?>" />
	<input type="hidden" name="DBuserName" value="<?php echo "$DBuserName"; ?>" />
	<input type="hidden" name="DBpassword" value="<?php echo "$DBpassword"; ?>" />
	<input type="hidden" name="DBname" value="<?php echo "$DBname"; ?>" />
	<input type="hidden" name="DBPrefix" value="<?php echo "$DBPrefix"; ?>" />
	
	<input type="hidden" name="sitename" value="<?php echo "$sitename"; ?>" />
	<input type="hidden" name="nomecomune" value="<?php echo "$nomecomune"; ?>" />
	<input type="hidden" name="istat" value="<?php echo "$istat"; ?>" />
	<input type="hidden" name="Capoluogo" value="<?php echo "$Capoluogo"; ?>" />
	<input type="hidden" name="Lingua" value="<?php echo "$Lingua"; ?>" />
	<input type="hidden" name="Multicomune" value="<?php echo "$Multicomune"; ?>" />
	<input type="hidden" name="Replica" value="<?php echo "$Replica"; ?>" />
	
	<input type="hidden" name="tema" value="<?php echo "$tema"; ?>" />
	<input type="hidden" name="sceltatema" value="<?php echo "$sceltatema"; ?>" />
	<input type="hidden" name="blocco" value="<?php echo "$blocco"; ?>" />
	<input type="hidden" name="flash" value="<?php echo "$flash"; ?>" />
	
	
	<input type="hidden" name="Limite" value="<?php echo "$Limite"; ?>" />
	
	
	
	<div class="install">
		<div id="stepbar">
			<div class="step-off">inizio</div>
			<div class="step-off">licenza</div>
			<div class="step-off">passo 1</div>
			<div class="step-off">passo 2</div>
			<div class="step-on">passo 3</div>
			<div class="step-off">passo 4</div>
		</div>
		<div id="right">
			<div id="step">passo 3</div>
			<div class="far-right">
				<input class="button" type="submit" name="next" value="Avanti >>"/>
			</div>
			<div class="clr"></div>
			<h1>Creazione Amministratore Super User</h1>
			<div class="install-text">
				
				<p>Il Super User o Admin ID di default e' <b>suser</b> Puoi cambiarlo da questo form<br /><br />
				   Inserisci il tuo indirizzo email, che sara' l'indirizzo email dell'amministratore del sito.<br /><br />
				   Inserisci la tua password (il sistema genera una password casuale). 
				  </p>
			</div>
			<div class="install-form">
				<div class="form-block">
					<table class="content2">
					<tr>
						<td nowarp>Admin ID:</td>
						<td align="center"><input class="inputbox" type="text" name="adminName" value="<?php echo "$adminName"; ?>" size="40" /></td>
<?php
	$abspath = "";
	if ($configArray['absolutePath'])
		$abspath = $configArray['absolutePath'];
	else {
		$path = getcwd();
		if (preg_match("/\/install/i", "$path"))
			$abspath = str_replace('/install',"",$path);
		else
			$abspath = str_replace('\install',"",$path);
	}
?>
					<input type="hidden" name="absolutePath" value="<?php echo $abspath; ?>" /></td>
					</tr>
<?php
	$url = "";
	if ($configArray['siteUrl'])
		$url = $configArray['siteUrl'];
	else {
		$port = ( $_SERVER['SERVER_PORT'] == 80 ) ? '' : ":".$_SERVER['SERVER_PORT'];
		$root = $_SERVER['SERVER_NAME'].$port.$_SERVER['PHP_SELF'];
		$root = str_replace("install/","",$root);
		$root = str_replace("/install3.php","",$root);
		$url = "http://".$root."/client";
	}
?>
					<tr>
						<td nowarp>URL del sito:</td>
					<td align="center"><input class="inputbox" type="text" name="siteUrl" value="<?php echo $url; ?>" size="40" /></td>
					</tr>
					<tr>
						<td nowarp>Tua E-mail:</td>
						<td align="center"><input class="inputbox" type="text" name="adminEmail" value="<?php echo "$adminEmail"; ?>" size="40" /></td>
					</tr>
					<tr>
						<td nowarp>Admin password:</td>
						<td align="center"><input class="inputbox" type="text" name="adminPassword" value="<?php echo mosMakePassword(8); ?>" size="40"/>
						</td>
					</tr>
					
					
					
					</table>
					<p></p>
				</div>
			</div>
			<div id="break"></div>
		</div>
		<div class="clr"></div>
	</div>
	</form>
</div>
<div class="clr"></div>
<?php include("footer.php"); ?>
</body>
</html>