<?php
// $Id: install3.php,v 1.8 2003/12/24 10:34:38 rcastley Exp $
/**
* Step 3 of Installation
* @package Mambo Open Source
* @Copyright (C) 2000 - 2003 Miro International Pty Ltd
* @ All rights reserved
* @ Mambo Open Source is Free Software
* @ Released under GNU/GPL License : http://www.gnu.org/copyleft/gpl.html
* @version $Revision: 1.8 $
**/

include_once("common.php");

$DBhostname = trim( mosGetParam( $_POST, 'DBhostname', '' ) );
$DBuserName = trim( mosGetParam( $_POST, 'DBuserName', '' ) );
$DBpassword = trim( mosGetParam( $_POST, 'DBpassword', '' ) );
$DBname  	= trim( mosGetParam( $_POST, 'DBname', '' ) );
$sitename  	= trim( mosGetParam( $_POST, 'sitename', '' ) );
$adminEmail = trim( mosGetParam( $_POST, 'adminEmail', '') );
$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=\"DBcreated\" value=1>
		</form>";

	echo "<SCRIPT>alert('The sitename has not been provided'); document.stepBack.submit();</SCRIPT>";
	return;
}

function makePass(){
	$makepass="";
	$salt = "abchefghjkmnpqrstuvwxyz0123456789";
	srand((double)microtime()*1000000);
	$i = 0;
	while ($i <= 7) {
		$num = rand() % 33;
		$tmp = substr($salt, $num, 1);
		$makepass = $makepass . $tmp;
		$i++;
	}
	return ($makepass);
}
?>
<?php 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>Mambo Open Source Installer</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="shortcut icon" href="../../images/M_images/favicon.ico" />
<link rel="stylesheet" href="install.css" type="text/css" />
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="dottedline">
  <tr>
    <td align="center" class="contentbackgr"><span class="installheader">Welcome
      to Mambo Open Source installation</span></td>
  </tr>
</table>
<br />
<form action="install4.php" method="post" name="form" id="form">
  <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="sitename" value="<?php echo "$sitename"; ?>" />

  <table width="550" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td width="10" height="10"><img src="../images/M_images/top_left_corner.png" width="10" height="10" /></td>
      <td background="../images/M_images/top_line.png"></td>
      <td width="10" height="10"><img src="../images/M_images/top_right_corner.png" width="10" height="10" /></td>
    </tr>
    <tr>
      <td background="../images/M_images/left_line.png"></td>
      <td>
  <table width="100%" border="0" align="center" cellpadding="0" cellspacing="4">
          <tr>
            <td colspan="2" class="heading">Step 3 - Confirm the site URL, absolute
        path and admin e-mail</td>
          </tr>
          <tr>
            <td colspan="2"> <p>If URL and Path looks correct then please do not change.
          If you are not sure then please contact your ISP or administrator. Usually
          the values displayed below will work for your site.<br />
          <br />
          Enter your e-mail address, this will be the e-mail address of the site
          SuperAdministrator.<br />
          <br />
          Enter your admin password, this will be the password of the site
          SuperAdministrator. You can use generated one or enter yours.<br />
          <br />
        </p></td>
          </tr>
          <tr>
            <td width="100">URL</td>
            <td align="center"><input class="inputbox" type="text" name="siteUrl" value="<?php if($configArray['siteUrl']) { echo $configArray['siteUrl'];
      } else {
      	$url = $_SERVER['SERVER_NAME'];
      	$root = $url.$_SERVER['PHP_SELF'];
      	$root = str_replace("installation/","",$root);
      	$root = str_replace("/install3.php","",$root);
      	echo "http://$root";
      }
						?>" size="50" /> </td>
          </tr>
          <tr>
            <td>Path</td>
            <td align="center"><input class="inputbox" type="text" name="absolutePath" value="<?php
      if($configArray['absolutePath'])
      {
      	echo $configArray['absolutePath'];
      }
      else
      {
      	$path = getcwd();
      	if (preg_match("/\/installation/i", "$path")) {
      		$abspath = str_replace('/installation',"",$path);
      	} else {
      		$abspath = str_replace('\installation',"",$path);
      	}
      	echo $abspath;
      }
						?>" size="50" /> </td>
          </tr>
          <tr>
            <td>Your E-mail</td>
            <td align="center"><input class="inputbox" type="text" name="adminEmail" value="<?php echo "$adminEmail"; ?>" size="50" /></td>
          </tr>
          <tr>
            <td>Admin password</td>
            <td align="center"><input class="inputbox" type="text" name="adminPassword" value="<?php
		echo makePass();
						?>" size="50" /></td>
          </tr>
          <tr>
            <td colspan="2" align="right"><br />
        <input class="button" type="submit" name="next" value="Next" /></td>
          </tr>
  </table></td>
      <td background="../images/M_images/right_line.png"></td>
    </tr>
    <tr>
      <td width="10" height="10" background="../images/M_images/bottom_left_corner.png"></td>
      <td background="../images/M_images/bottom_line.png"></td>
      <td width="10" height="10" background="../images/M_images/bottom_right_corner.png"></td>
    </tr>
  </table>
</form>
</body>
</html>
