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

154
0.7.1/daemon/GestionMysql.php Executable file
View File

@@ -0,0 +1,154 @@
<?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] => La base de donn<6E>es pour l'utilisateur n'a pu <20>tre cr<63><72>e.
[ERREUR 2] => L'utilisateur pour la base de donn<6E>es n'a pu <20>tre cr<63><72>e.
[ERREUR 3] => Les droits n'ont pu <20>tre mis sur l'utilisateur.
[ERREUR 4] => La base de donn<6E>es n'a pu <20>tre mis a jour sur le panel.
[ERREUR 5] => La base de donn<6E>es pour l'utilisateur n'a pu <20>tre supprim<69>.
[ERREUR 6] => L'utilisateur pour la base de donn<6E>es n'a pu <20>tre supprim<69>.
[ERREUR 7] => La base de donn<6E>es n'a pu etre supprim<69> sur le panel.
*/
// Inclusion du core
require ('/var/www/daemon/system/core.php');
/* -------- */
/* Cr<43>ation */
/* -------- */
$ListBdd = $ConnexionPanel->Select("*", "basededonnee", "Status='1'", "", "", "", "");
if ( $ListBdd != FALSE )
{
$CountBdd = count ($ListBdd);
echo "\nBase(s) de donn<6E>es en attente de cr<63>ation : ".$CountBdd."\n";
if ( !empty($ServeurMySql) )
{
for ($i=0; $i < $CountBdd; $i++)
{
$DetecteServeur = $ConnexionPanel->Select ("*", "utilisateur", "Utilisateur='".$ListBdd[$i]["Utilisateur"]."'", "", "", "", "");
if ( $DetecteServeur[0]["ServeurMysql"] == $ServeurMySql )
{
echo "Base de ".$ListBdd[$i]["Utilisateur"]." : ".$ListBdd[$i]["Nom"];
$CreationBdd = $ConnexionLocale->Query ('CREATE DATABASE '.$ListBdd[$i]["Nom"]);
if ( $CreationBdd != FALSE )
{
$CreationUser = $ConnexionLocale->Query("CREATE USER '".$ListBdd[$i]["Nom"]."'@'%' IDENTIFIED BY '".$ListBdd[$i]["Password"]."'");
if ( $CreationUser != FALSE )
{
$AttribueDroit = $ConnexionLocale->Query ("GRANT SELECT , INSERT , UPDATE , DELETE , CREATE , DROP , INDEX , ALTER , CREATE TEMPORARY TABLES , CREATE VIEW , SHOW VIEW , CREATE ROUTINE, ALTER ROUTINE, EXECUTE ON `".$ListBdd[$i]["Nom"]."`.* TO'".$ListBdd[$i]["Nom"]."'@'%'");
if ( $AttribueDroit != FALSE )
{
$MajPanel = $ConnexionPanel->Update ("basededonnee", "Status", "2", "Nom='".$ListBdd[$i]["Nom"]."'");
if ( $MajPanel != FALSE )
{
echo "\t\t\t[OK]\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 "Erreur : Aucun serveur MySql n'est d<>finit\n";
}
}
else
{
echo "Aucune base de donn<6E>es n'est en attente de cr<63>ation\n";
}
/* ----------- */
/* Suppression */
/* ----------- */
$ListBdd = $ConnexionPanel->Select("*", "basededonnee", "Status='3'", "", "", "", "");
if ( $ListBdd != FALSE )
{
$CountBdd = count ($ListBdd);
echo "\nBase(s) de donn<6E>es en attente de suppr<70>ssion : ".$CountBdd."\n";
if ( !empty($ServeurMySql) )
{
for ($i=0; $i < $CountBdd; $i++)
{
$DetecteServeur = $ConnexionPanel->Select ("*", "utilisateur", "Utilisateur='".$ListBdd[$i]["Utilisateur"]."'", "", "", "", "");
if ( $DetecteServeur[0]["ServeurMysql"] == $ServeurMySql )
{
echo "Base de ".$ListBdd[$i]["Utilisateur"]." : ".$ListBdd[$i]["Nom"];
$SuppressionBdd = $ConnexionLocale->Query('DROP DATABASE '.$ListBdd[$i]["Nom"]);
if ( $SuppressionBdd != FALSE )
{
$SuppressionUser = $ConnexionLocale->Query("DROP USER ".$ListBdd[$i]["Nom"]."@'%'");
if ( $SuppressionUser != FALSE )
{
$MajPanel = $ConnexionPanel->Delete ('basededonnee', 'Nom="'.$ListBdd[$i]["Nom"].'"');
if ( $MajPanel != FALSE )
{
echo "\t\t\t[OK]\n";
}
else
{
echo "\t\t\t[ERREUR 7]\n";
}
}
else
{
echo "\t\t\t[ERREUR 6]\n";
}
}
else
{
echo "\t\t\t[ERREUR 5]\n";
}
}
}
}
else
{
echo "Erreur : Aucun serveur MySql n'est d<>finit\n";
}
}
else
{
echo "Aucune base de donn<6E>es n'est en attente de suppr<70>ssion\n";
}
?>