Migration

This commit is contained in:
2016-02-21 01:33:05 +01:00
commit 6db8a86a48
386 changed files with 17311 additions and 0 deletions

308
0.7.1/daemon/GestionDomaine.php Executable file
View File

@@ -0,0 +1,308 @@
<?php
/*
Copyright (C) 2007 Mercier Benjamin
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
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. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
[ERREUR 1] => Le vhost ne peut pas etre ouvert en ecriture.
{ERREUR 2] => Le vhost n'a pu etre lu.
[ERREUR 3] => Le vhost n'a pu etre supprim<69>
[ERREUR 4] => Le vhost n'a pu etre <20>crit
[ERREUR 5] => La mise a jour sur le panel a <20>chou<6F>.
*/
// Annulation de la connexion MySql locale :
$ConnexionLocale = "non";
// Inclusion du core
require ('/var/www/daemon/system/core.php');
/* ------------*/
/* Suppression */
/* ----------- */
$ListDomaine = $ConnexionPanel->Select ("*", "domaine", "Status='3' OR Regeneration='Oui'", "", "", "", "");
if ( $ListDomaine != FALSE )
{
$CountDomaine = count($ListDomaine);
echo "\nDomaine(s) en attente de suppr<70>ssion : ".$CountDomaine."\n";
for ($i=0; $i < $CountDomaine; $i++)
{
$SelectUtilisateur = $ConnexionPanel->Select ("*", "utilisateur", "Utilisateur='".$ListDomaine[$i]["Utilisateur"]."'", "", "", "", "");
if ( $SelectUtilisateur[0]["ServeurFichier"] == $ServeurFichier )
{
echo "Domaine de ".$ListDomaine[$i]["Utilisateur"]." : ".$ListDomaine[$i]["Adresse"];
if ( is_writable("/var/www/vhost/".$ListDomaine[$i]["Utilisateur"]) )
{
$LoadFichier = file_get_contents ("/var/www/vhost/".$ListDomaine[$i]["Utilisateur"]);
// Ne renvoit pas true ou false !!! http://fr.php.net/preg_replace
$SupprimeDomaine = preg_replace("#\#DEBUT: ".$ListDomaine[$i]["Adresse"]."(.+)\#FIN: ".$ListDomaine[$i]["Adresse"]."#iUs", "", $LoadFichier);
$Fichier = file_put_contents("/var/www/vhost/".$ListDomaine[$i]["Utilisateur"], $SupprimeDomaine);
if ( $Fichier != FALSE )
{
if ( $ListDomaine[$i]["Regeneration"] == "Oui" )
{
$MajPanel = $ConnexionPanel->Update("domaine", array("Status", "Regeneration"), array("1", "Non"), "Adresse='".$ListDomaine[$i]["Adresse"]."'");
}
else
{
$MajPanel = $ConnexionPanel->Delete("domaine", "Adresse='".$ListDomaine[$i]["Adresse"]."'");
}
if ( $MajPanel != FALSE )
{
echo "\t\t\t[OK]\n";
}
else
{
echo "\t\t\t[ERREUR 5]\n";
}
}
else
{
echo "\t\t\t[ERREUR 4]\n";
}
}
else
{
echo "\t\t\t[ERREUR 1]\n";
}
}
}
}
else
{
echo "Aucun domaine n'est en attente de suppression.\n";
}
/* -------- */
/* Cr<43>ation */
/* -------- */
$ListDomaine = $ConnexionPanel->Select ("*", "domaine", "Status='1'", "", "", "", "");
if ( $ListDomaine != FALSE )
{
$CountDomaine = count($ListDomaine);
echo "\nDomaine(s) en attente de cr<63>ation : ".$CountDomaine."\n";
for ( $i=0; $i < $CountDomaine; $i++)
{
$SelectUtilisateur = $ConnexionPanel->Select ("*", "utilisateur", "Utilisateur='".$ListDomaine[$i]["Utilisateur"]."'", "", "", "", "");
if ( $SelectUtilisateur[0]["ServeurFichier"] == $ServeurFichier )
{
echo "Domaine de ".$ListDomaine[$i]["Utilisateur"]." : ".$ListDomaine[$i]["Adresse"];
if ( is_writable("/var/www/vhost/".$ListDomaine[$i]["Utilisateur"]) )
{
// Pr<50>paration des variables
$Remplacement = array ();
if ( !empty($ListDomaine[$i]["MysqlDefaultHost"]) )
{
$Remplacement["{MYSQL_DEFAUT_HOST}"] = 'php_admin_value mysql.default_host "'.$ListDomaine[$i]["MysqlDefaultHost"].'"';
}
else
{
$Remplacement["{MYSQL_DEFAUT_HOST}"] = "";
}
if ( !empty($ListDomaine[$i]["MysqlDefaultUser"]) )
{
$Remplacement["{MYSQL_DEFAUT_USER}"] = 'php_admin_value mysql.default_user "'.$ListDomaine[$i]["MysqlDefaultUser"].'"';
}
else
{
$Remplacement["{MYSQL_DEFAUT_USER}"] = "";
}
if ( !empty($ListDomaine[$i]["MysqlDefaultPassword"]) )
{
$Remplacement["{MYSQL_DEFAUT_PASS}"] = 'php_admin_value mysql.default_password "'.$ListDomaine[$i]["MysqlDefaultPassword"].'"';
}
else
{
$Remplacement["{MYSQL_DEFAUT_PASS}"] = "";
}
if ( !empty($ListDomaine[$i]["tmp"]) )
{
$Remplacement["{TMP_DIR}"] = 'php_admin_value upload_tmp_dir "/var/www/web/'.$ListDomaine[$i]["Utilisateur"].$ListDomaine[$i]["tmp"].'"';
}
else
{
$Remplacement["{TMP_DIR}"] = "";
}
if ( !empty($ListDomaine[$i]["sessions"]) )
{
$Remplacement["{SESSION}"] = 'php_admin_value session.save_path "/var/www/web/'.$ListDomaine[$i]["Utilisateur"].$ListDomaine[$i]["sessions"].'"';
}
else
{
$Remplacement["{SESSION}"] = "";
}
if ( !empty($ListDomaine[$i]["Short_Open_Tag"]) )
{
if ( $ListDomaine[$i]["Allow_url_fopen"] == "Oui") { $Reponse = "On" ; } else { $Reponse = "Off"; }
$Remplacement["{SHORT_OPEN_TAG}"] = 'php_admin_value short_open_tag "'.$Reponse.'"';
}
else
{
$Remplacement["{SHORT_OPEN_TAG}"] = "";
}
if ( !empty($ListDomaine[$i]["Allow_url_fopen"]) )
{
if ( $ListDomaine[$i]["Allow_url_fopen"] == "Oui") { $Reponse = "On" ; } else { $Reponse = "Off"; }
$Remplacement["{URL_FOPEN}"] = 'php_admin_value allow_url_fopen "'.$Reponse.'"';
}
else
{
$Remplacement["{URL_FOPEN}"] = "";
}
if ( !empty($ListDomaine[$i]["Allow_url_include"]) )
{
if ( $ListDomaine[$i]["Allow_url_include"] == "Oui") { $Reponse = "On" ; } else { $Reponse = "Off"; }
$Remplacement["{URL_INCLUDE}"] = 'php_admin_value allow_url_include "'.$Reponse.'"';
}
else
{
$Remplacement["{URL_INCLUDE}"] = "";
}
if ( !empty($ListDomaine[$i]["Session_auto_start"]) )
{
if ( $ListDomaine[$i]["Session_auto_start"] == "Oui") { $Reponse = "On" ; } else { $Reponse = "Off"; }
$Remplacement["{SESSION_AUTO_START}"] = 'php_admin_value session.auto_start "'.$Reponse.'"';
}
else
{
$Remplacement["{SESSION_AUTO_START}"] = "";
}
if ( !empty($ListDomaine[$i]["Magic_quotes_gpc"]) )
{
if ( $ListDomaine[$i]["Magic_quotes_gpc"] == "Oui") { $Reponse = "On" ; } else { $Reponse = "Off"; }
$Remplacement["{MAGIC_QUOTE}"] = 'php_admin_value magic_quotes_gpc "'.$Reponse.'"';
}
else
{
$Remplacement["{MAGIC_QUOTE}"] = "";
}
if ( !empty($ListDomaine[$i]["Register_globals"]) )
{
if ( $ListDomaine[$i]["Register_globals"] == "Oui") { $Reponse = "On" ; } else { $Reponse = "Off"; }
$Remplacement["{REGISTER_GLOBAL}"] = 'php_admin_value register_globals "'.$Reponse.'"';
}
else
{
$Remplacement["{REGISTER_GLOBAL}"] = "";
}
if ( !empty($ListDomaine[$i]["DisplayErrors"]) )
{
if ( $ListDomaine[$i]["DisplayErrors"] == "Oui") { $Reponse = "On" ; } else { $Reponse = "Off"; }
$Remplacement["{DISPLAY_ERROR}"] = 'php_admin_value display_errors "'.$Reponse.'"';
}
else
{
$Remplacement["{DISPLAY_ERROR}"] = "";
}
if ( $ListDomaine[$i]["Listage"] == "Oui" )
{
$Remplacement["{INDEXE}"] = "Indexes";
}
else
{
$Remplacement["{INDEXE}"] = "-Indexes";
}
$Remplacement["{DOMAINE}"] = $ListDomaine[$i]["Adresse"];
$Remplacement["{CHEMIN}"] = "/var/www/web/".$ListDomaine[$i]["Utilisateur"].$ListDomaine[$i]["Racine"];
$Remplacement["{BASEDIR}"] = "/var/www/web/".$ListDomaine[$i]["Utilisateur"].$ListDomaine[$i]["OpenBasedir"];
if ( $ListDomaine[$i]["Bridage"] == "Oui" )
{
$Remplacement["{BRIDAGE}"] = "CBandRemoteSpeed 50kb/s 3 3";
}
else
{
$Remplacement["{BRIDAGE}"] = "";
}
$Fichier = file_get_contents("/var/www/daemon/system/vhost.tpl");
$Vhost = str_replace (array_keys($Remplacement), array_values($Remplacement), $Fichier);
$AncienVhost = file_get_contents("/var/www/vhost/".$ListDomaine[$i]["Utilisateur"]);
if ( $AncienVhost != FALSE )
{
$NouveauVhost = $AncienVhost.$Vhost."\n";
$SuppressionVhost = unlink("/var/www/vhost/".$ListDomaine[$i]["Utilisateur"]);
if ( $SuppressionVhost != FALSE )
{
$EcritureNouveauVhost = file_put_contents("/var/www/vhost/".$ListDomaine[$i]["Utilisateur"], $NouveauVhost);
if ( $EcritureNouveauVhost != FALSE )
{
$MajPanel = $ConnexionPanel->Update("domaine", array("Status", "Regeneration"), array("2", "Non"), "Adresse='".$ListDomaine[$i]["Adresse"]."'");
if ( $MajPanel != FALSE )
{
echo "\t\t\t[OK]\n";
}
else
{
echo "\t\t\t[ERREUR 5]\n";
}
}
else
{
echo "\t\t\t[ERREUR 4]\n";
}
}
else
{
echo "\t\t\t[ERREUR 3]\n";
}
}
else
{
echo "\t\t\t[ERREUR 2]\n";
}
}
else
{
echo "\t\t\t[ERREUR 1]\n";
}
}
}
}
else
{
echo "Aucun domaine n'est en attente de cr<63>ation.\n";
}
?>