<?php if ($_SESSION['inputcache.okas']!='collectinfo') redirect('./'); $errorareas=array(); $data=$_SESSION['inputcache.data']; require_once("../config.common.inc.php"); require_once("../config.locals.inc.php"); require_once("../includes/db.inc.php"); initialize_config($Config); set_local_configurations($Config); initialize_db_config($Config); $DBConn=db_init_connection($Config); $DBConn->connect(); if ($data['dbreconstruct']) { $createdbsql=file_get_contents("db/createdb.sql"); $createdbsql=str_replace("`reserv`.","`".$Config->DBConfWritable[0]['DBName']."`.",$createdbsql); $createdbsql=str_replace("`reserv_","`".$Config->TablePrefix['reserv'],$createdbsql); $createdbsql=ereg_replace(" AUTO_INCREMENT=[0-9]+","",$createdbsql); $func_start=strpos($createdbsql,'DELIMITER $$'); $func_end=strpos($createdbsql,'DELIMITER ;'); $createfuncsqls=substr($createdbsql,$func_start+13,$func_end-$func_start-13); $createfuncsqllist=explode('$$',$createfuncsqls); foreach ($createfuncsqllist as $cfsql) { $cfsql=trim($cfsql); if ($cfsql) $DBConn->real_query($cfsql,'error.db.createfunction'); } $createdbsql=substr($createdbsql,0,$func_start).substr($createdbsql,$func_end+12); $DBConn->multi_query($createdbsql,"error.db.createtables"); if ($DBConn->error()) { $errorareas['ERROR-DB-CREATE']=array(0); $dataset['dberror']=$DBConn->error(); } do { $DBConn->store_result(); } while ($DBConn->next_result()); $dataset['OK-DB-CREATE']=array(0); } if (!$errorareas) { $sql="SELECT MIN(`mb_id`) " ."FROM `{$Config->TableMap['login']}` " ."WHERE " ."mb_status='VALID'"; $mb_id=$DBConn->query_value($sql); if ($data['dbreconstruct']) { $comperebasic=array( 'cp_name'=>$data['businessname'], 'cp_timezone'=>$data['timezone'] ); db_set_compere($DBConn,$mb_id,$comperebasic); db_create_team($DBConn,$mb_id); $dataset['OK-DB-INITIALIZE']=array(0); } $config_locals=file_get_contents('../config.locals.inc.php'); $config_locals=str_replace('$Config->DefaultCPID=0;','$Config->DefaultCPID='.$mb_id.';',$config_locals); file_put_contents('../config.locals.inc.php',$config_locals); $dataset['file.config.locals']='config.locals.inc.php'; $dataset['OK-CREATE-CONFIG-LOCAL']=array(0); } $CMD_TMPL_NAME='install'; $dataset+=$data; $dataset+=$errorareas; if (count_true_entries($errorareas)==0) $dataset['INSTALL-COMPLETE']=array(0); else $dataset['INSTALL-INCOMPLETE']=array(0); ?>