743 lines
20 KiB
PHP
743 lines
20 KiB
PHP
|
<?php
|
||
|
|
||
|
/**-----------------------------------------------
|
||
|
*
|
||
|
* Rooty, 2018 <rooty@rooty.me>
|
||
|
*
|
||
|
*
|
||
|
* This software is protected by copyright, please
|
||
|
* read the file COPYRIGHT.
|
||
|
* This program is distributed in the hope that it
|
||
|
* will be useful, but without any warranty; without
|
||
|
* even the implied warranty of merchantability or
|
||
|
* fitness for a particular purpose. Please
|
||
|
* read the file LICENCE.
|
||
|
*
|
||
|
* Ce fichier contient la gestion de l'installation granilim
|
||
|
*
|
||
|
* @author Comendatore <www.comendatore.net|commendatore@comendatore.net>
|
||
|
* @copyright Copyright © 2009-2018, Rooty
|
||
|
* @since 2007/01/07
|
||
|
* @version 0.3
|
||
|
* @link www.rooty.me
|
||
|
* @package install
|
||
|
*/
|
||
|
|
||
|
/**
|
||
|
* Fonction de gestion des étapes d'installation
|
||
|
*
|
||
|
* @author Initiance <www.initiance.com|martial@initiance.com>
|
||
|
*/
|
||
|
function stepprocess($step,$etat)
|
||
|
{
|
||
|
global $message, $on, $off, $stepimg;
|
||
|
|
||
|
switch($etat)
|
||
|
{
|
||
|
case 0 :
|
||
|
$img =$stepimg;
|
||
|
break;
|
||
|
case 1 :
|
||
|
$img = $on;
|
||
|
break;
|
||
|
case 2 :
|
||
|
$img = $off;
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
if($etat==1)
|
||
|
{
|
||
|
$chaine = "<li class=\"pass\">".$message->getMessage("Step".$step)."</li>";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if(!isset($_GET["step"]))
|
||
|
{
|
||
|
$_GET["step"]=0;
|
||
|
}
|
||
|
if($_GET["step"] == $step)
|
||
|
{
|
||
|
$chaine = "<li class=\"current\">".$message->getMessage("Step".$step)."</li>";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
$chaine = "<li>".$message->getMessage("Step".$step)."</li>";
|
||
|
}
|
||
|
}
|
||
|
return $chaine;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Parse les modules PHP depuis phpinfo()
|
||
|
*
|
||
|
* <P>Retourne le tableau des modules Php</P>
|
||
|
*
|
||
|
* @return tableau tableau des modules Php
|
||
|
*/
|
||
|
function getPhpModules()
|
||
|
{
|
||
|
ob_start();
|
||
|
phpinfo(INFO_MODULES);
|
||
|
$s = ob_get_contents();
|
||
|
ob_end_clean();
|
||
|
|
||
|
$s = strip_tags($s,'<h2><th><td>');
|
||
|
$s = preg_replace('/<th[^>]*>([^<]+)<\/th>/',"<info>\\1</info>",$s);
|
||
|
$s = preg_replace('/<td[^>]*>([^<]+)<\/td>/',"<info>\\1</info>",$s);
|
||
|
$vTmp = preg_split('/(<h2>[^<]+<\/h2>)/',$s,-1,PREG_SPLIT_DELIM_CAPTURE);
|
||
|
$arrayModules = array();
|
||
|
|
||
|
for ($i=1;$i<count($vTmp);$i++)
|
||
|
{
|
||
|
if (preg_match('/<h2>([^<]+)<\/h2>/',$vTmp[$i],$vMat))
|
||
|
{
|
||
|
$vName = trim($vMat[1]);
|
||
|
$vTmp2 = explode("\n",$vTmp[$i+1]);
|
||
|
|
||
|
foreach ($vTmp2 AS $vOne)
|
||
|
{
|
||
|
$vPat = '<info>([^<]+)<\/info>';
|
||
|
$vPat3 = "/$vPat\s*$vPat\s*$vPat/";
|
||
|
$vPat2 = "/$vPat\s*$vPat/";
|
||
|
|
||
|
if (preg_match($vPat3,$vOne,$vMat))
|
||
|
{ // 3 colonnes
|
||
|
$arrayModules[$vName][trim($vMat[1])] = array(trim($vMat[2]),trim($vMat[3]));
|
||
|
} elseif (preg_match($vPat2,$vOne,$vMat))
|
||
|
{ // 2 colonnes
|
||
|
$arrayModules[$vName][trim($vMat[1])] = trim($vMat[2]);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return $arrayModules;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Obtenir le paramètre d'un module
|
||
|
*
|
||
|
* <P>Retourne la valeur du paramètre du module Php demandé</P>
|
||
|
*
|
||
|
* @param chaîne module php
|
||
|
* @param chaîne paramètre du module
|
||
|
* @return string valeur du paramètre du module php
|
||
|
*/
|
||
|
function getModuleSetting($modulename,$setting)
|
||
|
{
|
||
|
$arrayModules = getPhpModules();
|
||
|
return $arrayModules[$modulename][$setting];
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Définit la version du backend BD à utiliser
|
||
|
*
|
||
|
* <P>Retourne la version du backend BD</P>
|
||
|
*
|
||
|
* @param string Backend BD
|
||
|
* @return string Version du backend BD
|
||
|
*
|
||
|
* <br>Trois backends sont actuellement imlémentés :
|
||
|
* mysql
|
||
|
* pgsql
|
||
|
* odbc
|
||
|
* </br>
|
||
|
* @TODO Implémentation des scripts d'installations des backends
|
||
|
*/
|
||
|
function setVersionDbConnector($dbserver)
|
||
|
{
|
||
|
|
||
|
switch($dbserver)
|
||
|
{
|
||
|
case "mysql":
|
||
|
$backendString = "Client API version";
|
||
|
break;
|
||
|
case "pgsql" :
|
||
|
$backendString = "PostgreSQL(libpq) Version";
|
||
|
break;
|
||
|
case "odbc" :
|
||
|
$backendString = "";
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
$mysqlclientversion = getModuleSetting($dbserver,$backendString);
|
||
|
$mysqlConnector = explode(".", $mysqlclientversion);
|
||
|
$mysqlConnector = $mysqlConnector[0];
|
||
|
return $mysqlConnector;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Fonction permettant de remplacer une chaîne de caractères par une
|
||
|
* autre dans le fichier cible passé en paramètre.
|
||
|
*
|
||
|
* <P>Retourne true/false</P>
|
||
|
*
|
||
|
* @param array En clé, l'ancienne valeur et en valeur, la valeur a remplacer
|
||
|
* @param string chemin absolu du fichier
|
||
|
* @return booléen true/false
|
||
|
* @TODO Implémenter 2 tableaux à la place des variables
|
||
|
*/
|
||
|
function updateStringInFile($arrayValue,$file)
|
||
|
{
|
||
|
$buffer = @fread(@fopen($file, 'r'), @filesize($file));
|
||
|
|
||
|
foreach($arrayValue as $oValue=>$nValue){
|
||
|
$buffer = str_replace($oValue, $nValue, $buffer);
|
||
|
}
|
||
|
|
||
|
if (($fp = @fopen($file,"w")) !== false)
|
||
|
{
|
||
|
if (@fwrite($fp,$buffer) !== false)
|
||
|
{
|
||
|
$res = true;
|
||
|
} else {
|
||
|
$res = false;
|
||
|
}
|
||
|
fclose($fp);
|
||
|
} else {
|
||
|
$res = false;
|
||
|
}
|
||
|
return $res;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Créé une chaîne "aléatoire"
|
||
|
*
|
||
|
* <P>Retourne une chaîne aléatoire</P>
|
||
|
*
|
||
|
* @return string chaîne aléatoire
|
||
|
*/
|
||
|
function makeMcryptKey($lenght)
|
||
|
{
|
||
|
while($i<$lenght)
|
||
|
{
|
||
|
$mcryptKey.=chr((rand()%26)+97);
|
||
|
$i++;
|
||
|
}
|
||
|
$mcryptKey=$mcryptKey.substr(uniqid (""),0,22);
|
||
|
return $mcryptKey;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Fonction d'affichage de l'aide
|
||
|
*
|
||
|
* @author Initiance <www.initiance.com|martial@initiance.com>
|
||
|
*/
|
||
|
function aide($form,$nameField)
|
||
|
{
|
||
|
global $message, $help;
|
||
|
// return "<a href=\"javascript:recupelement('".$message->getMessage("H".$nameField)."');\"><img src=\"media/$help\" alt=\"".$message->getMessage("H".$nameField)."\"/></a>";
|
||
|
return "<a href=\"#\"><img src=\"media/$help\" alt=\"".$message->getMessage("".$nameField."")."\"/><span>".$message->getMessage("H".$nameField)."</span></a>";
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
*
|
||
|
*/
|
||
|
function datasource($POST="")
|
||
|
{
|
||
|
global $message, $etat, $CONF_LIB_PATH, $help;
|
||
|
|
||
|
if($POST=="")
|
||
|
{
|
||
|
$chaine = "<div class='main'>
|
||
|
<form id=\"myform\" action=\"index.php?step=1\" method=\"post\">
|
||
|
<div class=\"field\">
|
||
|
<table>
|
||
|
<tr>
|
||
|
<td>".aide("myform","NameServeur")."</td>
|
||
|
<td><label for='serveur'>".$message->getMessage("NameServeur")."</label></td>
|
||
|
<td><input id='serveur' type=\"text\" name=\"NameServeur\"/></td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</div>
|
||
|
<div class=\"field\">
|
||
|
<table>
|
||
|
<tr>
|
||
|
<td>".aide("myform","LoginServeur")."
|
||
|
<td><label for='loginserveur'>".$message->getMessage("LoginServeur")."</label></td>
|
||
|
<td><input id='loginserveur' type=\"text\" name=\"LoginServeur\"/></td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</div>
|
||
|
<div class=\"field\">
|
||
|
<table>
|
||
|
<tr>
|
||
|
<td>".aide("myform","PwdServeur")."
|
||
|
<td><label for='pwdserveur'>".$message->getMessage("PwdServeur")."</label></td>
|
||
|
<td><input id='pwdserveur' type=\"password\" name=\"PwdServeur\"/></td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</div>
|
||
|
<div class=\"field\">
|
||
|
<table>
|
||
|
<tr>
|
||
|
<td>".aide("myform","BdServeur")."
|
||
|
<td><label for='bdserveur'>".$message->getMessage("BdServeur")."</label></td>
|
||
|
<td><input id='bdserveur' type=\"text\" name=\"BdServeur\"/></td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</div>
|
||
|
<div class=\"field\">
|
||
|
<table>
|
||
|
<tr>
|
||
|
<td>".aide("myform","PrefxBdServeur")."
|
||
|
<td><label for='prefxbdserveur'>".$message->getMessage("PrefxBdServeur")."</label></td>
|
||
|
<td><input id='prefxbdserveur' type=\"text\" name=\"PrefxBdServeur\"/></td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</div>
|
||
|
<div>
|
||
|
<textarea id='helpdesc' name=\"helpdesc\" cols=\"45\" rows=\"4\"></textarea>
|
||
|
</div>
|
||
|
<div>
|
||
|
<input type=\"submit\" name=\"ok\" value=\"".$message->getMessage("Next")."\" class=\"button\"/>
|
||
|
</div>
|
||
|
</form>
|
||
|
</div>";
|
||
|
$etat = 0;
|
||
|
return $chaine;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
$chaine = "";
|
||
|
if($_POST)
|
||
|
{
|
||
|
|
||
|
foreach($_POST as $cle=>$val)
|
||
|
{
|
||
|
if($val=="" && ($cle !="PwdServeur" && $cle !="NameServeur" && $cle !="PrefxBdServeur" && $cle !="helpdesc"))
|
||
|
{
|
||
|
$chaine .= $message->getMessage($cle).", ";
|
||
|
}
|
||
|
}
|
||
|
if($chaine!="")
|
||
|
{
|
||
|
$chaine .= $message->getMessage('obligatory');
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//Si certains champs sont manquants pour l'inscription
|
||
|
if ($chaine != "")
|
||
|
{
|
||
|
return datasource()."<p class='alert'>".$chaine."</p>";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
|
||
|
$dbhost = (!empty($_POST['NameServeur'])) ? $_POST['NameServeur'] : 'localhost';
|
||
|
$dbuser = (!empty($_POST['LoginServeur'])) ? $_POST['LoginServeur']: "";
|
||
|
$dbpasswd = (!empty($_POST['PwdServeur'])) ? $_POST['PwdServeur'] : "";
|
||
|
$dbname = (!empty($_POST['BdServeur'])) ? $_POST['BdServeur']: "";
|
||
|
$dbnameprefx = (!empty($_POST['PrefxBdServeur'])) ? $_POST['PrefxBdServeur']: "";
|
||
|
$bd_connect = @mysql_connect($dbhost, $dbuser, $dbpasswd);
|
||
|
$dbselect = @mysql_select_db($dbname);
|
||
|
|
||
|
if(!$bd_connect)
|
||
|
{
|
||
|
return datasource()."<p class='alert'>".$message->getMessage("NoMysqlConnexion")."</p>";
|
||
|
}
|
||
|
|
||
|
if(!$dbselect)
|
||
|
{
|
||
|
include_once($CONF_LIB_PATH."lib/system/system_data_source/database/sql_parse.php");
|
||
|
|
||
|
//var_dump(setVersionDbConnector("mysql"));
|
||
|
$sql_query = @fread(@fopen("./db_scripts/mysql/".setVersionDbConnector("mysql")."_create_database.sql", 'r'), @filesize("./db_scripts/mysql/".setVersionDbConnector("mysql")."_create_database.sql"));
|
||
|
$sql_query = preg_replace('/{_DATABASE_}/', "`".$dbname."`", $sql_query);
|
||
|
var_dump($sql_query."<br>");
|
||
|
$sql_query = remove_remarks($sql_query);
|
||
|
$sql_query = split_sql_file($sql_query, ";");
|
||
|
var_dump($sql_query);
|
||
|
for ($i = 0; $i < sizeof($sql_query); $i++)
|
||
|
{
|
||
|
if (!($result = mysql_query($sql_query[$i],$bd_connect)))
|
||
|
{
|
||
|
return datasource()."<p class='alert'>".$message->getMessage('BdCreateError')."</p>";
|
||
|
exit;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$dbselect = @mysql_select_db($dbname);
|
||
|
if($dbselect)
|
||
|
{
|
||
|
$sql_query = @fread(@fopen("./db_scripts/mysql/".setVersionDbConnector("mysql")."_create_structure.sql", 'r'), @filesize("./db_scripts/mysql/".setVersionDbConnector("mysql")."_create_structure.sql"));
|
||
|
if($dbnameprefx != "") { $dbnameprefx = $dbnameprefx."_"; } else { $dbnameprefx = "sys_"; }
|
||
|
$sql_query = preg_replace('/{_PREFIX_}/', $dbnameprefx, $sql_query);
|
||
|
|
||
|
$sql_query = remove_remarks($sql_query);
|
||
|
$sql_query = split_sql_file($sql_query, ";");
|
||
|
|
||
|
for ($i = 0; $i < sizeof($sql_query); $i++)
|
||
|
{
|
||
|
if (!($result = mysql_query($sql_query[$i],$bd_connect)))
|
||
|
{
|
||
|
return datasource()."<p class='alert'>".$message->getMessage('BdStructureError')."</p>";
|
||
|
exit;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$sql_query = "";
|
||
|
$sql_query = @fread(@fopen("./db_scripts/mysql/".setVersionDbConnector("mysql")."_insert_datas.sql", 'r'), @filesize("./db_scripts/mysql/".setVersionDbConnector("mysql")."_insert_datas.sql"));
|
||
|
$sql_query = preg_replace('/{_PREFIX_}/', $dbnameprefx, $sql_query);
|
||
|
|
||
|
$sql_query = remove_remarks($sql_query);
|
||
|
$sql_query = split_sql_file($sql_query, ";");
|
||
|
|
||
|
for ($i = 0; $i < sizeof($sql_query); $i++)
|
||
|
{
|
||
|
if (trim($sql_query[$i]) != '')
|
||
|
{
|
||
|
#####################################
|
||
|
### Ajout du remplacement des paths images!!!
|
||
|
$sql_query[$i]=make_path($sql_query[$i]);
|
||
|
#####################################
|
||
|
|
||
|
if (!($result = mysql_query($sql_query[$i],$bd_connect)))
|
||
|
{
|
||
|
return datasource()."<p class='alert'>".$message->getMessage('BdDatasError')."</p>";
|
||
|
exit;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return datasource()."<p class='alert'>".$message->getMessage('BdStructureError')."2</p>";
|
||
|
exit;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
include_once($CONF_LIB_PATH."lib/system/system_data_source/database/sql_parse.php");
|
||
|
|
||
|
$sql_query = @fread(@fopen("./db_scripts/mysql/".setVersionDbConnector("mysql")."_create_structure.sql", 'r'), @filesize("./db_scripts/mysql/".setVersionDbConnector("mysql")."_create_structure.sql"));
|
||
|
if($dbnameprefx != "") { $dbnameprefx = $dbnameprefx."_"; } else { $dbnameprefx = "sys_"; }
|
||
|
$sql_query = preg_replace('/{_PREFIX_}/', $dbnameprefx, $sql_query);
|
||
|
|
||
|
$sql_query = remove_remarks($sql_query);
|
||
|
$sql_query = split_sql_file($sql_query, ";");
|
||
|
|
||
|
for ($i = 0; $i < sizeof($sql_query); $i++)
|
||
|
{
|
||
|
if (!($result = mysql_query($sql_query[$i],$bd_connect)))
|
||
|
{
|
||
|
return datasource()."<p class='alert'>".$message->getMessage('BdStructureError')."</p>";
|
||
|
exit;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$sql_query = "";
|
||
|
$sql_query = @fread(@fopen("./db_scripts/mysql/".setVersionDbConnector("mysql")."_insert_datas.sql", 'r'), @filesize("./db_scripts/mysql/".setVersionDbConnector("mysql")."_insert_datas.sql"));
|
||
|
$sql_query = preg_replace('/{_PREFIX_}/', $dbnameprefx, $sql_query);
|
||
|
|
||
|
$sql_query = remove_remarks($sql_query);
|
||
|
$sql_query = split_sql_file($sql_query, ";");
|
||
|
|
||
|
for ($i = 0; $i < sizeof($sql_query); $i++)
|
||
|
{
|
||
|
if (trim($sql_query[$i]) != '')
|
||
|
{
|
||
|
#####################################
|
||
|
### Ajout du remplacement des paths images!!!
|
||
|
$sql_query[$i]=make_path($sql_query[$i]);
|
||
|
#####################################
|
||
|
|
||
|
if (!($result = mysql_query($sql_query[$i],$bd_connect)))
|
||
|
{
|
||
|
return datasource()."<p class='alert'>".$message->getMessage('BdDatasError')."</p>";
|
||
|
exit;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// On met à jour le fichier config.data_source.php
|
||
|
if ( updateStringInFile(array("{_DBCONNECTOR_}"=>"mysql".setVersionDbConnector('mysql'),
|
||
|
"{_DBHOST_}"=>$dbhost,
|
||
|
"{_DBUSER_}"=>$dbuser,
|
||
|
"{_DBPASSWD_}"=>$dbpasswd,
|
||
|
"{_DBNAME_}"=>$dbname,
|
||
|
),$CONF_LIB_PATH.'config/config.data_source.php') == false) { redirect("index.php?step=1"); }
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
// On met à jour le fichier config.data_acces.php
|
||
|
//if ( updateStringInFile("{_TABLEVERSION_}","1",$CONF_LIB_PATH.'config/config.data_access.php') == false) { redirect("index.php?step=1"); }
|
||
|
if ( updateStringInFile(array("{_PREFIX_}"=>$dbnameprefx),$CONF_LIB_PATH.'config/config.data_acces.php') !== false) { redirect("index.php?step=2"); } else { redirect("index.php?step=1"); }
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
*
|
||
|
*
|
||
|
* @author Comendatore <www.comendatore.net|commendatore@comendatore.net>
|
||
|
*/
|
||
|
function adapt($POST="")
|
||
|
{
|
||
|
global $message, $etat, $CONF_LIB_PATH, $help;
|
||
|
|
||
|
if($POST=="")
|
||
|
{
|
||
|
$chaine = "<div class='main'>
|
||
|
<form id=\"myform\" action=\"index.php?step=3\" method=\"post\">
|
||
|
<div class=\"field\">
|
||
|
<table>
|
||
|
<tr>
|
||
|
<td>".aide("myform","McryptKey")."</td>
|
||
|
<td><label for='mcryptkey'>".$message->getMessage("McryptKey")."</label></td>
|
||
|
<td><input id='mcryptkey' type=\"text\" name=\"McryptKey\" value=\"".makeMcryptKey(25)."\"/></td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</div>
|
||
|
<div class=\"field\">
|
||
|
<table>
|
||
|
<tr>
|
||
|
<td>".aide("myform","AdminCourriel")."
|
||
|
<td><label for='admincourriel'>".$message->getMessage("AdminCourriel")."</label></td>
|
||
|
<td><input id='admincourriel' type=\"text\" name=\"AdminCourriel\"/></td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</div>
|
||
|
<div>
|
||
|
<textarea id='helpdesc' name=\"helpdesc\" cols=\"45\" rows=\"4\"></textarea>
|
||
|
</div>
|
||
|
<div>
|
||
|
<input type=\"submit\" name=\"ok\" value=\"".$message->getMessage("Next")."\" class=\"button\"/>
|
||
|
</div>
|
||
|
</form>
|
||
|
</div>";
|
||
|
$etat = 0;
|
||
|
return $chaine;
|
||
|
} else {
|
||
|
$chaine = "";
|
||
|
if($_POST)
|
||
|
{
|
||
|
foreach($_POST as $cle=>$val)
|
||
|
{
|
||
|
if($val=="")
|
||
|
{
|
||
|
$chaine .= $message->getMessage($cle).", ";
|
||
|
}
|
||
|
}
|
||
|
if($chaine!="")
|
||
|
{
|
||
|
$chaine .= $message->getMessage('obligatory');
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//Si certains champs sont manquants pour l'inscription
|
||
|
if ($chaine != "")
|
||
|
{
|
||
|
return adapt()."<p class='alert'>".$chaine."</p>";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
*
|
||
|
*/
|
||
|
function admin($POST="")
|
||
|
{
|
||
|
global $message, $etat, $CONF_LIB_PATH;
|
||
|
|
||
|
if($POST=="")
|
||
|
{
|
||
|
$chaine = "
|
||
|
<form id=\"myform\" action=\"index.php?step=3\" method=\"post\">
|
||
|
<div class='main'>
|
||
|
|
||
|
<table>
|
||
|
<tr>
|
||
|
<td><strong>".$message->getMessage("Title")." (*)</strong></td>
|
||
|
<td align='center'>".$message->getMessage("mr")."<input class='checkbox' type=\"radio\" name=\"Title\" value=\"0\" checked=\"checked\"/>
|
||
|
<td align='center'>".$message->getMessage("mrs")."<input class='checkbox' type=\"radio\" name=\"Title\" value=\"1\"/>
|
||
|
<td align='center'>".$message->getMessage("miss")."<input class='checkbox' type=\"radio\" name=\"Title\" value=\"2\"/></td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
<table>
|
||
|
<div>
|
||
|
<tr><td><div class=\"field\"><label for='nom'>".$message->getMessage("FirstName")." (*)</label><input type=\"text\" id='nom' name=\"FirstName\"/></div></td></tr>
|
||
|
<tr><td><div class=\"field\"><label for='prenom'>".$message->getMessage("LastName")." (*)</label><input type=\"text\" id='prenom' name=\"LastName\" /></div></td></tr>
|
||
|
<tr><td><div class=\"field\"><label for='email'>".$message->getMessage("Mail")." (*)</label><input type=\"text\" id='email' name=\"Mail\" /></div></td></tr>
|
||
|
<tr><td><div class=\"field\"><label for='log'>".$message->getMessage("Login")." (*)</label><input type=\"text\" id='log' name=\"Login\" /></div></td></tr>
|
||
|
<tr><td><div class=\"field\"><label for='pwd'>".$message->getMessage("Password")." (*)</label><input type=\"password\" id='pwd' name=\"Password\" /></div></td></tr>
|
||
|
<tr><td><div class=\"field\"><label for='pwdbis'>".$message->getMessage("RePassword")." (*)</label><input type=\"password\" id='pwdbis' name=\"Password2\" /></div></td></tr>
|
||
|
<hr class=\"clean\" />
|
||
|
<tr><td><div class=\"field\"> (*) : ".$message->getMessage("obligatory")."</div></td></tr>
|
||
|
<tr><td>
|
||
|
<input type=\"submit\" name=\"ok\" value=\"".$message->getMessage("Next")."\" class=\"button\"/>
|
||
|
</td></tr>
|
||
|
</div>
|
||
|
</table>
|
||
|
</div>
|
||
|
</form>
|
||
|
";
|
||
|
$etat = 0;
|
||
|
return $chaine;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
$chaine = "";
|
||
|
if($_POST)
|
||
|
{
|
||
|
foreach($_POST as $cle=>$val)
|
||
|
{
|
||
|
if($val=="")
|
||
|
{
|
||
|
$chaine .= $message->getMessage($cle).", ";
|
||
|
}
|
||
|
}
|
||
|
if($chaine!="")
|
||
|
{
|
||
|
$chaine .= $message->getMessage('obligatory');
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//Si certains champs sont manquants pour l'inscription
|
||
|
if ($chaine != "")
|
||
|
{
|
||
|
return admin()."<p class='alert'>".$chaine."</p>";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if($_POST["Password"]!=$_POST["Password2"])
|
||
|
{
|
||
|
return admin()."<p class='alert'>".$message->getMessage('Passworderror')."</p>";
|
||
|
}
|
||
|
|
||
|
include($CONF_LIB_PATH.'lib/system/system_control/systemcontrol.php');
|
||
|
/* Création des ressources */
|
||
|
$var=SystemControl::includeFiles($CONF_LIB_PATH."config/", "config");
|
||
|
$GLOBALS["CONF_LIB_PATH"]="../";
|
||
|
$var=SystemControl::MakeSystemConn();
|
||
|
|
||
|
/* Création du Manager Utilisateur */
|
||
|
$GLOBALS["SYSTEM_MANAGER"]["USER"]=UserManagerFactory::createInstance( DATA_ACCES_MANAGER_USER );
|
||
|
/* Création du Manager Utilisateur */
|
||
|
|
||
|
$User=new User();
|
||
|
$User->setId($GLOBALS['SYSTEM_DEFAULT_USER_ADMIN']);
|
||
|
$User->setPassword($_POST['Password']);
|
||
|
$User->setTitle($_POST['Title']);
|
||
|
$User->setFirstName($_POST['FirstName']);
|
||
|
$User->setLastName($_POST['LastName']);
|
||
|
$User->setLogin($_POST['Login']);
|
||
|
$User->setMail($_POST['Mail']);
|
||
|
|
||
|
$User=$GLOBALS["SYSTEM_MANAGER"]["USER"]->updateInstance($User);
|
||
|
|
||
|
$contenu_installControl="<?
|
||
|
/**-----------------------------------------------
|
||
|
*
|
||
|
* Rooty, 2018 <rooty@rooty.me>
|
||
|
*
|
||
|
*
|
||
|
* This software is protected by copyright, please
|
||
|
* read the file COPYRIGHT.
|
||
|
* This program is distributed in the hope that it
|
||
|
* will be useful, but without any warranty; without
|
||
|
* even the implied warranty of merchantability or
|
||
|
* fitness for a particular purpose. Please
|
||
|
* read the file LICENCE.
|
||
|
*
|
||
|
* InstallControl.php
|
||
|
*
|
||
|
* <P>Ce fichier sert à vérifier l'installation du portail <br>*</P>
|
||
|
*
|
||
|
* @author Initiance <www.initiance.com|martial@initiance.com>
|
||
|
* @since 2018/04/02
|
||
|
* @version 0.3
|
||
|
* @link www.rooty.me
|
||
|
* @package install
|
||
|
* @copyright Copyright © 2009-2018, Rooty
|
||
|
*/
|
||
|
|
||
|
// Cette variable existe lorque l'installation est effectuée
|
||
|
define ('GRANILIM_INSTALLED', true); /* Granilim installé */
|
||
|
?>";
|
||
|
if (($fp = @fopen($CONF_LIB_PATH.'config/installcontrol.php','w')) !== false)
|
||
|
{
|
||
|
if (@fwrite($fp,$contenu_installControl) !== false)
|
||
|
{
|
||
|
$res = true;
|
||
|
} else {
|
||
|
$res = false;
|
||
|
}
|
||
|
fclose($fp);
|
||
|
}
|
||
|
redirect("index.php?step=4");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Vérifie le droit en écriture sur le répertoire cible
|
||
|
*
|
||
|
* <P>Retourne true/false</P>
|
||
|
*
|
||
|
* @author Comendatore <www.comendatore.net|commendatore@comendatore.net>
|
||
|
*
|
||
|
* @param chaîne chemin absolu du répertoire
|
||
|
* @return booléen true/false
|
||
|
*/
|
||
|
function checkRepWritable($chemin)
|
||
|
{
|
||
|
if (!is_writable($chemin))
|
||
|
{
|
||
|
return false;
|
||
|
} else {
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Créé un fichier s'il n'existe pas
|
||
|
*
|
||
|
* <P>Retourne true/false</P>
|
||
|
*
|
||
|
* @author Comendatore <www.comendatore.net|commendatore@comendatore.net>
|
||
|
*
|
||
|
* @param chaîne chemin absolu du répertoire (sans le / de fin)
|
||
|
* @param chaîne nom du fichier à créer
|
||
|
* @return booléen true/false
|
||
|
*/
|
||
|
function createFileIfNotExists($chemin,$file)
|
||
|
{
|
||
|
if (checkRepWritable($chemin) == true)
|
||
|
{
|
||
|
if ((@fopen($chemin."/",$file,"w")) == true)
|
||
|
{
|
||
|
return true;
|
||
|
} else {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Vérifie le droit en écriture sur le fichier cible
|
||
|
*
|
||
|
* <P>Retourne true/false</P>
|
||
|
*
|
||
|
* @author Comendatore <www.comendatore.net|commendatore@comendatore.net>
|
||
|
*
|
||
|
* @param chaîne chemin absolu du fichier
|
||
|
* @return booléen true/false
|
||
|
*/
|
||
|
function checkFileWritable($chemin)
|
||
|
{
|
||
|
if (!is_writable($chemin))
|
||
|
{
|
||
|
return false;
|
||
|
} else {
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
?>
|