<?php
	
	////////////////////////////////// version actual (la que se va a instalar).
	$currentversion = '1.6';
	
	error_reporting (0);
	
	if (file_exists('../db.php')) {
		// si existe config, verificar que tenga contenido
		$contenidodeconfig = file_get_contents('../db.php');
		if (preg_match('/db__name/i',$contenidodeconfig)){
			// es un update
			include_once('../db.php');
			
			$db_link=@mysql_connect($db__server,$db__user,$db__password);
			if(!@mysql_select_db($db__name,$db_link)){
				echo "ERROR 11<br>
				Impossible to connect to the database.
				<br>
				Fall&oacute; la conexi&oacute;n a la base de datos.";
				echo '
				<form method="post" action="';
				echo $PHP_SELF;
				echo '?step=3&lang='.$_REQUEST[lang].'&type='.$_REQUEST[type].'">
				<p align="center"><input class="btnformyellow" type="submit" value="'.ucfirst(_RETURN).'"></p>
				</form>';
				exit;
			}
			$versionanterior = $VERSION;
			if (!$versionanterior) {$versionanterior = 'unknow';}
			}else{
			// es una instalacion
			$versionanterior = null;
		}
		}else{
		// si no existe config, es una instalacion nueva
		$versionanterior = null;
	}
	
	
	function verifylangs() {
		if (!$db__name) {include('../db.php');}
		$db_link = mysql_connect ($db__server, $db__user, $db__password);
		if (!mysql_select_db($db__name,$db_link)){
			echo "ERROR 12<br>Impossible to connect to the database.
			<br>Fall&oacute; la conexi&oacute;n a la base de datos.";
			echo '
			<form method="post" action="';
			echo $PHP_SELF;
			echo '?step=3&lang='.$_REQUEST[lang].'&type='.$_REQUEST[type].'">
			<p align="center"><input class="btnformyellow" type="submit" value="'.ucfirst(_RETURN).'"></p>
			</form>';
			exit;
		}
		@mysql_query("SET NAMES 'utf8'");
		$existe_en = 0; $existe_es = 0;
		$result = mysql_query("SHOW COLUMNS FROM ml_languages");
		if (mysql_num_rows($result) > 0) {
			while ($row = mysql_fetch_assoc($result)) {
				if ($row[Field]=='en'){$existe_en = 1;}
				if ($row[Field]=='es'){$existe_es = 1;}
			}
		}
		if ($existe_en == 0) {mysql_query("ALTER TABLE `ml_languages` ADD `en` TEXT NULL",$db_link);}
		if ($existe_es == 0) {mysql_query("ALTER TABLE `ml_languages` ADD `es` TEXT NULL",$db_link);}
	}
	
	function query($query,$type) {
		$result = mysql_query($query);
		$error = mysql_error();
		global $query_count;
		global $queries_used;
		$query_count++;
		$queries_used .= $query.'<br>';
		if (!empty($error)) {
			ob_end_clean();
			$errno = mysql_errno();
			die("ERROR 13 <br>MULTILANG was unable to successfully run a MySQL query.<br>MySQL Returned this error: <b>$error</b> Error number: <b>$errno</b><br>The query that caused this error was: <b>$query</b>");
		}
		if ($type == 0) {
			return $result;
		}
		if ($type == 1) {
			$array = mysql_fetch_array($result);
			return $array;
		}
		if ($type == 2) {
			$array = mysql_num_rows($result);
			return $array;
		}
		if ($type == 3) {
			return mysql_insert_id();
		}
		if ($type == 4) {
			return mysql_result($result,0);
		}
		@mysql_free_result($result);
	}
	
	
	function mysql_dump($sqlfile){
		if (!$db__name) {include('../db.php');}
		$db_link=mysql_connect($db__server,$db__user,$db__password);
		if(!mysql_select_db($db__name,$db_link)){
			if ($sqlfile == 'bookingo.sql') {
				$output = '';
				$fp = fopen ('../db.php', 'w');
				fwrite ($fp, $output);
				fclose ($fp);
			}
			echo "<strong>ERROR 14: "._PASS_INCORRECT."</strong><hr>
			Impossible to connect to the database.
			<br>
			Fall&oacute; la conexi&oacute;n a la base de datos.<hr>";
			echo "<br><strong>db__server:</strong> ".$db__server;
			echo "<br><strong>db__user:</strong> ".$db__user;
			echo "<br><strong>db__name:</strong> ".$db__name;
			echo "<br><strong>db__password:</strong> ".$db__password;
			echo "<hr>";
			echo '
			<form method="post" action="';
			echo $PHP_SELF;
			echo '?step=3&lang='.$_REQUEST[lang].'&type='.$_REQUEST[type].'">
			<p align="center"><input class="btnformyellow" type="submit" value="'.ucfirst(_RETURN).'"></p>
			</form>';
			exit;
		}
		@mysql_query("SET NAMES 'utf8'");
		
		$file_content = file_get_contents($sqlfile);
		$file_content2 = explode('-- --------------------------------------------------------',$file_content);
		foreach($file_content2 as $sql_line){
			if (!mysql_query($sql_line)) {echo '<hr><b>ERROR 15:</b><br>'.mysql_error().'<br><b>SQL_LINE:</b> '.$sql_line; exit;}
		}
		echo "<br><font color='green' class='sizeextrabold'><b>"._FILE." ".$sqlfile." "._INSERTED_CORRECTLY_INTO_THE_DATABASE."</b></font>";
	}
	
	
	if ($_REQUEST['lang']=='spanish'){
		define("_SYSTEM_REQUERIMENTS","Requerimientos del sistema");
		define("_INSTALL_UPDATE","Instalaci&oacute;n o actualizaci&oacute;n");
		define("_PHP_VERSION","Versi&oacute;n de PHP");
		define("_OK","Correcto");
		define("_CONTINUE","Continuar");
		define("_PHP_ERROR","Por favor actualice PHP al menos a la versi&oacute;n 5.3.0");
		define("_MYSQL_ERROR","MySQL no disponible");
		define("_PERMISSIONS","Permisos");
		define("_FILE","Archivo");
		define("_FOLDER","Carpeta");
		define("_CONFIG_ERROR","Por favor fije permisos 777 (CHMOD 777) al archivo db.php");
		define("_ERRORLOG_ERROR","Por favor fije permisos 777 (CHMOD 777) al archivo <strong>error.log</strong>");
		define("_INSTALL_ERROR","<b>Se detectaron errores.</b><br>Por favor corrija los errores que se detallan arriba y recargue la p&aacute;gina");
		define("_INSTALLATION_TYPE","Elija el tipo de instalaci&oacute;n");
		define("_VERSION","versi&oacute;n");
		define("_NEW_INSTALL","Instalaci&oacute;n nueva");
		define("_UPDATE_FROM","Actualizar desde");
		define("_TO","a");
		define("_ALREADY_UPDATED","YA ACTUALIZADO. La versi&oacute;n instalada es la ".$currentversion);
		define("_BEGIN_INSTALLATION","Comenzar la instalaci&oacute;n");
		define("_DATABASE_CONNECTION","Conexi&oacute;n a la bases de datos");
		define("_DATABASE_HOST","Servidor de la base de datos");
		define("_DATABASE_NAME","Nombre de la base de datos");
		define("_DATABASE_USERNAME","Usuario de la base de datos");
		define("_DATABASE_PASSWORD","Contrasena de la base de datos");
		define("_NOTHING_TO_DO","nada para hacer");
		define("_INSTALLATION_COMPLETE","Instalaci&oacute;n completa");
		define("_STEPS_TO_FOLLOW","Pasos a seguir");
		define("_DELETE_FILE_INSTALL","Elimine el archivo install.php");
		define("_LOGIN_TO_THE_ADMIN_AREA","Ingrese al &aacute;rea administrativa");
		define("_THE_PASSWORD_IS_1234","La <b>contrase&ntilde;a</b> es <b>1234</b>.");
		define("_DELETE_THE_FILE_INSTALL","Elimine el archivo install.php");
		define("_ENTER_VIA_FTP_AND_DELETE_THE_FILE_INSTALL","Ingrese mediante FTP y elimine la carpeta install");
		define("_WRONG","incorrecto/a");
		define("_HERE","AQUI");
		define("_STATUS","ESTADO");
		define("_RETURN","VOLVER");
		define("_CLICK_HERE_TO_HELP","Click aqu&iacute; para ayuda");
		define("_INSERTED_CORRECTLY_INTO_THE_DATABASE","insertado correctamente en la base de datos");
		define("_CONFIG_RENAMED","Si es la primera instalacion, renombre el archivo <strong>config_dist.php</strong> a <strong>db.php</strong>");
		define("_PASS_INCORRECT","Contraseña con caracteres no permitidos. Cambie la contraseña del usuario en el panel de hosting");
		}else{
		define("_SYSTEM_REQUERIMENTS","System requirements");
		define("_INSTALL_UPDATE","Install or update");
		define("_PHP_VERSION","PHP version");
		define("_OK","OK");
		define("_CONTINUE","Continue");
		define("_PHP_ERROR","Please update PHP to at least version 5.3.0");
		define("_MYSQL_ERROR","MySQL not available");
		define("_PERMISSIONS","Permissions");
		define("_FILE","File");
		define("_FOLDER","Folder");
		define("_CONFIG_ERROR","Please set permissions for db.php file to 777 (CHMOD 777)");
		define("_ERRORLOG_ERROR","Please set permissions for <strong>error.log</strong> file to 777 (CHMOD 777)");
		define("_INSTALL_ERROR","<b>Errors were detected.</b><br>Please correct the errors as described above and reload the page");
		define("_INSTALLATION_TYPE","Choose installation type");
		define("_VERSION","version");
		define("_NEW_INSTALL","New install");
		define("_UPDATE_FROM","Update from");
		define("_TO","to");
		define("_ALREADY_UPDATED","ALREADY UPDATED. The installed version is ".$currentversion);
		define("_BEGIN_INSTALLATION","Begin installation");
		define("_DATABASE_CONNECTION","Database Connection");
		define("_DATABASE_HOST","Database Host");
		define("_DATABASE_NAME","Database Name");
		define("_DATABASE_USERNAME","Database Username");
		define("_DATABASE_PASSWORD","Database Password");
		define("_NOTHING_TO_DO","Nothing to do");
		define("_INSTALLATION_COMPLETE","Installation complete");
		define("_STEPS_TO_FOLLOW","Steps to follow");
		define("_DELETE_FILE_INSTALL","Delete the file install.php");
		define("_LOGIN_TO_THE_ADMIN_AREA","Login to the admin area");
		define("_THE_PASSWORD_IS_1234","The User: <b>admin</b> Password: <b>demo123</b>.");
		define("_DELETE_THE_FILE_INSTALL","Delete the file install.php");
		define("_ENTER_VIA_FTP_AND_DELETE_THE_FILE_INSTALL","Enter via FTP and delete the folder install");
		define("_WRONG","wrong");
		define("_HERE","HERE");
		define("_STATUS","STATUS");
		define("_RETURN","RETURN");
		define("_CLICK_HERE_TO_HELP","Click here to help");
		define("_INSERTED_CORRECTLY_INTO_THE_DATABASE","inserted correctly into the database");
		define("_CONFIG_RENAMED","If is the first installation, rename the file <strong>config_dist.php</strong> to <strong>db.php</strong>");
		define("_PASS_INCORRECT","Password with illegal characters. Change the password in the hosting panel");
	}
	
?>
<!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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Bookingo - Installer</title>
    <meta name="author" content="Bookingo" />
    <meta name="description" content="" />
    <meta name="keywords" content="" />
    <meta name="application-name" content="Bookingo" />

    <!-- Mobile Specific Metas -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <!-- Force IE9 to render in normla mode -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />

    <!-- Le styles -->
    <link href="../bk-admin/css/bootstrap/bootstrap.css" rel="stylesheet" />
    <link href="../bk-admin/css/bootstrap/bootstrap-responsive.css" rel="stylesheet" />
    <link href="../bk-admin/css/supr-theme/jquery.ui.supr.css" rel="stylesheet" type="text/css"/>
    <link href="../bk-admin/css/icons.css" rel="stylesheet" type="text/css" />
    <link href="../bk-admin/plugins/forms/uniform/uniform.default.css" type="text/css" rel="stylesheet" />

    <!-- Main stylesheets -->
    <link href="../bk-admin/css/main.css" rel="stylesheet" type="text/css" /> 

    <!--[if IE 8]><link href="css/ie8.css" rel="stylesheet" type="text/css" /><![endif]-->
    
    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script type="text/javascript" src="js/libs/excanvas.min.js"></script>
      <script type="text/javascript" src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
      <script type="text/javascript" src="js/libs/respond.min.js"></script>
    <![endif]-->

    <!-- Le fav and touch icons -->
    <link rel="shortcut icon" href="../bk-admin/images/favicon.ico" />
    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="../bk-admin/images/apple-touch-icon-144-precomposed.png" />
    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="../bk-admin/images/apple-touch-icon-114-precomposed.png" />
    <link rel="apple-touch-icon-precomposed" sizes="72x72" href="../bk-admin/images/apple-touch-icon-72-precomposed.png" />
    <link rel="apple-touch-icon-precomposed" href="../bk-admin/images/apple-touch-icon-57-precomposed.png" />

    <script type="text/javascript" src="../bk-admin/js/libs/modernizr.js"></script>

    </head>
      
    <body class="loginPage">

    <div class="container-fluid">

        <div id="header">

            <div class="row-fluid">

                <div class="navbar">
                    <div class="navbar-inner">
                      <div class="container">
                            <a class="brand" href="./"><img src="../bk-admin/images/logo.png" /></a>
                      </div>
                    </div><!-- /navbar-inner -->
                  </div><!-- /navbar -->
                

            </div><!-- End .row-fluid -->

        </div><!-- End #header -->

    </div><!-- End .container-fluid -->    

    <div class="container-fluid">
    <div class="container" style="padding-top:300px; padding-bottom:100px; border: 1px solid #c4c4c4; background: #fefefe; box-shadow: 0px 0px 1px 1px rgba(0, 0, 0, 0.1);">

        <table border="0" width="90%" align="center">
					<tr>
						<th width=45% colspan=2><font size=5>Bookingo - Installer 1.6</font><br /><br /></th>
					</tr>
					
					<tr><td valign="top" align="center">
						
						
						<?php
							$step = $_REQUEST['step'];
							$type = $_REQUEST['type'];
							
							
							/////////////////111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
							/////////////////
							///////////////////////////////////////////////////////////////////////////// SELECCIONAR IDIOMA //////////////////////////////////////////////
							if ($step == '')	{
								///////////////////////// seleccionar idioma
								
								echo '<br><br>
								<p><b><font size=4>Welcome to Bookingo, please make sure you create first a Database and user to fill in the next form, click next to start the installation process</font></b></p>
								<br><br>';
								
								echo '
								<p align=center>
								<input class="sizeextrabold" type="submit" value="NEXT" onClick="window.location=\'';
								echo $PHP_SELF;
								echo '?step=2&lang=english\'">';
							}
							
							
							
							/////////////////222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
							/////////////////
							/////////////////////////////////////////////////////////////////////////// CHEQUEAR REQUERIMIENTOS Y TIPO DE INSTALACION /////////////////////
							if ($step == '2')	{
								
								
								//////////////////////// verificar permisos, etc
							?>
							<table border="1" width="90%" cellpadding="9" cellspacing="9">
								
								<thead>
									<tr>
										<th bgcolor="#CCCCCC"><?= strtoupper(_SYSTEM_REQUERIMENTS)?></th>
										<th bgcolor="#CCCCCC"><?= strtoupper(_STATUS)?></th>
									</tr>
								</thead>
								<tbody>
									<tr>
										<td width="75%"><?php echo _PHP_VERSION.': '.phpversion (); ?></td>
										<?php
											if ('5.3.0' <= phpversion ())		{
												echo '<td align="center" bgcolor="green"><font color="white"><B>'._OK.'</B></font></td>';
												}else{
												echo '<td align="center" bgcolor="red"><font color="white">'._PHP_ERROR.'</font></td>';
												$error = '1';
											}
										?>
									</tr>
									
									<tr>
										<td>MySQL</td>
										<?php
											if (function_exists ('mysql_connect'))		{
												echo '<td align="center" bgcolor="green"><font color="white"><B>'._OK.'</B></font></td>';
												}else{
												echo '<td align="center" bgcolor="red"><font color="white">'._MYSQL_ERROR.'</font></td>';
												$error = '1';
											}
										?>
									</tr>
									
								</tbody>
							</table>
							
							<table border="1" width="90%" cellpadding="9" cellspacing="9">
								<thead>
									<tr>
										<th bgcolor="#CCCCCC"><?= strtoupper(_PERMISSIONS)?></th>
										<th bgcolor="#CCCCCC"><?= strtoupper(_STATUS)?></th>
									</tr>
								</thead>
								<tbody>
									
									<tr>
										<td width="75%"><?= _FILE ?> <b>db.php</b></td>
										
										<?php
											if (is_writable ('../db.php'))		{
												echo '<td align="center" bgcolor="green"><font color="white"><B>'._OK.'</B></font></td>';
												}else{
												echo '<td align="center" bgcolor="red"><font color="white">'._CONFIG_ERROR.'</font>';
												echo "&nbsp;&nbsp;&nbsp;&nbsp;<a href='images/filezilla.jpg' target='_blank' onClick=\"window.open(this.href, this.target, 'width=500, height=294, left=20, top=20, scrollbars=1'); return false;\"><b>|"._CLICK_HERE_TO_HELP."|</b></a>&nbsp;&nbsp;";
												echo '</td>';
												$error = '1';
											}
										?>
									</tr>
									
									
									
									<tr><td><?= _FILE ?> <b>error.log</b></td>
										<?php
											if (is_writable ('error.log'))		{
												echo '<td align="center" bgcolor="green"><font color="white"><B>'._OK.'</B></font></td>';
												}else{
												echo '<td align="center" bgcolor="red"><font color="white">'._ERRORLOG_ERROR.'</font>';
												echo "&nbsp;&nbsp;&nbsp;&nbsp;<a href='images/filezilla.jpg' target='_blank' onClick=\"window.open(this.href, this.target, 'width=500, height=294, left=20, top=20, scrollbars=1'); return false;\"><b>|"._CLICK_HERE_TO_HELP."|</b></a>&nbsp;&nbsp;";
												echo '</td>';
												$error = '1';
											}
										?>
									</tr>
									
									
								</tbody>
							</table>
							
							<table>
								
								<?php
									if ($error == '1')	{
										echo '<tr>
										<td colspan="2" align="center" bgcolor="red"><font color="#ffffff" size="5">
										'._INSTALL_ERROR.'
										</font>
										</td>
										</tr>
										';
										}else{
										echo '	<tr>
										<td colspan=2 align=center bgcolor="#FFFF99"><b>'.strtoupper(_INSTALLATION_TYPE).'</b></td>
										</tr>';
										
										echo '	<tr>
										<td colspan=2>';
										
										if ($versionanterior <> $currentversion) {
											echo '<form method="post" action="';
											echo $PHP_SELF;
											echo '?step=3&lang='.$_REQUEST[lang].'"><p align="center">';
											
											echo '<select name="type" style="font-size:20px;" class="input-xxlarge">';
											
											echo '<option value="newinstall"';
											if ($versionanterior == null)	{echo ' selected';}else{echo ' disabled';}
											echo ' style="font-size:20px;"> '._NEW_INSTALL.' - '._VERSION.' '.$currentversion.'</option>';
											
											// echo '<br><option value="update1"';
											// if ($versionanterior == '1')	{echo ' selected';}elseif($versionanterior == 'unknow'){echo '';}else{echo ' disabled';}
											// echo ' style="font-size:20px;"> '._UPDATE_FROM.' '._VERSION.' 1 '._TO.' '._VERSION.' '.$currentversion.'</option>';
											
											
											
											
											////////////// Agregar antes de esto lo de la ultima version
											
											echo '</select>';
											
											echo '</p><p align="center"><input class="btnformgreen" type="submit" value="'._BEGIN_INSTALLATION.'"></p></form>';
											}else{
											echo '<font size="5" color="red"><b>'._ALREADY_UPDATED.'</b><font>';
										}
										echo '</td>';
									}
									echo '</tr>';
								?>
							</table>
							<?php
							}
							
							
							
							/////////////////3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333
							/////////////////
							/////////////////////////////////////////////////////////////////// DATOS DE LA DB ///////////////////////////////////////////////////////
							if ($step == '3')	{
								echo '<form method="post" action="';
								echo $PHP_SELF;
								echo '?step=4&lang='.$_REQUEST[lang].'&type='.$_REQUEST[type].'">
								
								<p><b>'.ucfirst(_DATABASE_CONNECTION).'</b></p>
								
								<table class="table table-striped">
								<tr>
								<td width="50%">'.ucfirst(_DATABASE_HOST).'</td>
								<td><input type="text" name="dbhost" size="20" value="'.$db__server.'" placeholder="(localhost OR server IP)"></td>
								</tr>
								<tr>
								<td>'.ucfirst(_DATABASE_NAME).'</td>
								<td><input type="text" name="dbname" size="20" value="'.$db__name.'"></td>
								</tr>
								<tr>
								<td>'.ucfirst(_DATABASE_USERNAME).'</td>
								<td><input type="text" name="dbusername" size="20" value="'.$db__user.'"></td>
								</tr>
								<tr>
								<td>'.ucfirst(_DATABASE_PASSWORD).'</td>
								<td><input type="password" name="dbpassword" size="20" value="'.$db__password.'"></td>
								</tr>
								</table>
								
								<p align="center"><input class="btnformgreen" type="submit" value="'.ucfirst(_CONTINUE).'"></p>
								</form>';
							}
							
							
							
							/////////////////444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444
							/////////////////
							///////////////////////////////////////////////////// PROCESO DE INSTALACION O ACTUALIZACION ///////////////////////////////////////////////
							if ($step == '4')	{
								if ($_REQUEST['dbhost'] == '')	{echo '<br>'.ucfirst(_DATABASE_HOST).' '._WRONG; exit ();}
								if ($_REQUEST['dbname'] == '')	{echo '<br>'.ucfirst(_DATABASE_NAME).' '._WRONG; exit ();}
								if ($_REQUEST['dbusername'] == '')	{echo '<br>'.ucfirst(_DATABASE_USERNAME).' '._WRONG; exit ();}
								if ($_REQUEST['dbpassword'] == '')	{echo '<br>'.ucfirst(_DATABASE_PASSWORD).' '._WRONG; exit ();}
								
								$db_link = @mysql_connect ($_REQUEST['dbhost'], $_REQUEST['dbusername'], $_REQUEST['dbpassword']);
								if (!@mysql_select_db($_REQUEST['dbname'],$db_link)){
									echo "ERROR 40<br>
									Impossible to connect to the database. &nbsp;&nbsp;&nbsp;
									Fall&oacute; la conexi&oacute;n a la base de datos.";
									echo '
									<form method="post" action="';
									echo $PHP_SELF;
									echo '?step=3&lang='.$_REQUEST[lang].'&type='.$_REQUEST[type].'">
									<p align="center"><input class="btnformyellow" type="submit" value="'.ucfirst(_RETURN).'"></p>
									</form>';
									exit;
									}else{
									@mysql_query("SET NAMES 'utf8'");
									
									// convertir la DB a utf8
									if (!mysql_query("ALTER DATABASE `".$_REQUEST['dbname']."` CHARACTER SET utf8 COLLATE utf8_general_ci")) {
										print ("ERROR 41<br>".mysql_error()); exit;
									}
									
									if (!isset($DEFAULT_LANGUAGE)) {
										$DEFAULT_LANGUAGE = 'autodetect';
									}
									
									if (!isset($GOOGLE_TRANSLATE_API_KEY)) {
										$GOOGLE_TRANSLATE_API_KEY = '';
									}
									
									if (!isset($PASSWORD)) {
										$PASSWORD = '1234';
									}
									
									if (!isset($NATIVE_LANGUAGE)) {
										$NATIVE_LANGUAGE = 'en';
									}
									
									if (!isset($VERSION)) {
										$VERSION = 1;
									}
									
									if (!isset($DEMO_MODE)) {
										$DEMO_MODE = 0;
									}
									
									$multilangpath= @substr($_SERVER['SCRIPT_FILENAME'], 0, @strrpos($_SERVER['SCRIPT_FILENAME'], "/"));
									$multilangurl= @substr($_SERVER['REQUEST_URI'], 0, @strrpos($_SERVER['REQUEST_URI'], "/"));
									$websitedirectory = @substr($multilangurl, 0, @strrpos($multilangurl, "/"));
									if ($websitedirectory == '') {$websitedirectory = '/';}
									
									$output = 
'<?php
//Mysqli Connection
// db connection string variables
define("BKDB_HOST", "' . $_REQUEST['dbhost'] . '"); // database location
define("BKDB_NAME", "' . $_REQUEST['dbname'] . '"); // database name
define("BKDB_USER", "' . $_REQUEST['dbusername'] . '"); // user name
define("BKDB_PASS", "' . $_REQUEST['dbpassword'] . '"); // password

$conn = mysqli_connect(BKDB_HOST, BKDB_USER, BKDB_PASS) or die("<link id=\"bootstrap\" href=\"/bk-admin/css/bootstrap/bootstrap.min.css\" rel=\"stylesheet\" type=\"text/css\" /><div class=\"alert alert-error\"><strong>MySQL Error: Oops!</strong> UNABLE to CONNECT to the DATABASE!</div>");
mysqli_select_db($conn, BKDB_NAME) or die("<link id=\"bootstrap\" href=\"/bk-admin/css/bootstrap/bootstrap.min.css\" rel=\"stylesheet\" type=\"text/css\" /><div class=\"alert alert-error\"><strong>MYSQL ERROR: Oops!</strong> Database access FAILED!</div>");
mysqli_set_charset($conn, "utf8") or die("<link id=\"bootstrap\" href=\"/bk-admin/css/bootstrap/bootstrap.min.css\" rel=\"stylesheet\" type=\"text/css\" /><div class=\"alert\"><strong>Warning!</strong>UNABLE to SET database connection ENCODING!</div>");

//Installation Connection
$db__server = "' . $_REQUEST['dbhost'] . '";
$db__user = "' . $_REQUEST['dbusername'] . '";
$db__password = "' . $_REQUEST['dbpassword'] . '";
$db__name = "' . $_REQUEST['dbname'] . '";
?>';
									
									$fp = fopen ('../db.php', 'w');
									fwrite ($fp, $output);
									fclose ($fp);
									include_once '../db.php';
									
								}
								//	echo 'type: '.$_REQUEST['type'];
								
								if ($_REQUEST['type'] == 'newinstall' AND !$versionanterior) {
								mysql_dump ('bookingo.sql');
								// }elseif ($_REQUEST['type'] == 'update1') {
								// verifylangs(); mysql_dump ('update-from-1-to-2.sql');
								}else{
								echo '<br>'.ucfirst(_NOTHING_TO_DO); exit;
									}
									
									echo '
									<form method="post" action="';
									echo $PHP_SELF;
									echo '?step=5&lang='.$_REQUEST[lang].'&type='.$_REQUEST[type].'">
									<p align="center"><input class="btnformgreen" type="submit" value="'.ucfirst(_CONTINUE).'"></p>
										</form>';
										
										}
										
										
										
										/////////////////555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555
										/////////////////
										////////////////////////////////////////////////////////////////// INSTRUCCIONES FINALES /////////////////////////////////////////////////////////
										if ($step == '5')	{
										
										echo '<br><br>
										<p align="left"><b><font size="6">'.ucfirst(_INSTALLATION_COMPLETE).'</font></b></p>
										
										<p align="left"><font size="4">'.ucfirst(_STEPS_TO_FOLLOW).':</font></p>
											
										<p align="left"><font size="3"><b>1- '.ucfirst(_DELETE_THE_FILE_INSTALL).'</b></font>&nbsp;&nbsp;&nbsp;'._ENTER_VIA_FTP_AND_DELETE_THE_FILE_INSTALL.'</p>
										
										<p align="left"><font size="3"><b>2- '.ucfirst(_LOGIN_TO_THE_ADMIN_AREA).'</b>&nbsp;&nbsp;&nbsp;<a href="../bk-admin/"><b>'._HERE.'</b></a>';
										if ($_REQUEST['type'] == 'newinstall') {
										echo '&nbsp;&nbsp;&nbsp;'._THE_PASSWORD_IS_1234.'';
										}
										echo '</font></p>';
										}
										
										?>
										</td>
										</tr>
									
									</table>
		</div>
    </div><!-- End .container-fluid -->                

     
    </body>
</html>