Files
keliopanel-v1/0.7.1/daemon/GestionFtp.php
2016-02-21 01:33:05 +01:00

126 lines
3.7 KiB
PHP
Executable File

<?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] => L'utilisateur n'est pas trouvé dans la table utilisateur (afin de detecter le serveur de stockage)
[ERREUR 2] => L'utilisateur n'a aucun serveur d'attribué
[ERREUR 3] => L'insertion dans la table accessible via proftpd à échoué
[ERREUR 4] => La mise a jour du compte ftp sur le panel a échoué
[ERREUR 5] => La suppression de la table accessible via proftpd à échoué
[ERREUR 6] => La suppression du compte ftp sur le panel à échoué
*/
// Annulation de la connexion MySql locale :
$ConnexionLocale = "non";
// Inclusion du core
require ('/var/www/daemon/system/core.php');
/* -------- */
/* Création */
/* -------- */
$ListFtp = $ConnexionPanel->Select ("*", "ftp", "Status='1'", "", "", "", "");
if ( $ListFtp != FALSE )
{
$CountFtp = count ($ListFtp);
echo "\nCompte(s) en attente de création : ".$CountFtp."\n";
for ($i=0; $i < $CountFtp; $i++)
{
echo "Compte de ".$ListFtp[$i]["Utilisateur"]." : ".$ListFtp[$i]["Nom"];
$SelectServeur = $ConnexionPanel->Select ("*", "utilisateur", "Utilisateur='".$ListFtp[$i]["Utilisateur"]."'", "", "", "", "");
if ( $SelectServeur != FALSE )
{
if ( !empty($SelectServeur[0]["ServeurFichier"]) )
{
$Champs = "userid, passwd, homedir, Server";
$Valeurs = "'".$ListFtp[$i]["Nom"]."', ENCRYPT('".$ListFtp[$i]["Password"]."'), '/var/www/web/".$ListFtp[$i]["Utilisateur"].$ListFtp[$i]["Chemin"]."', '".$SelectServeur[0]["ServeurFichier"]."'";
$InsertFtp = $ConnexionSystem->Insert ($Champs, $Valeurs, "ftpuser");
if ( $InsertFtp != FALSE )
{
$MajPanel = $ConnexionPanel->Update ("ftp", "Status", "2", "Nom='".$ListFtp[$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 "Aucun compte n'est en attente de création\n";
}
/* ----------- */
/* Suppression */
/* ----------- */
$ListFtp = $ConnexionPanel->Select ("*", "ftp", "Status='3'", "", "", "", "");
if ( $ListFtp != FALSE )
{
$CountFtp = count ($ListFtp);
echo "\nCompte(s) en attente de suppression : ".$CountFtp."\n";
for ($i=0; $i < $CountFtp; $i++)
{
echo "Compte de ".$ListFtp[$i]["Utilisateur"]." : ".$ListFtp[$i]["Nom"];
$SuppressionSystem = $ConnexionSystem->Delete ("ftpuser", "userid='".$ListFtp[$i]["Nom"]."'");
if ( $SuppressionSystem != FALSE )
{
$SuppressionPanel = $ConnexionPanel->Delete ("ftp", "Nom='".$ListFtp[$i]["Nom"]."'");
if ( $SuppressionPanel != FALSE )
{
echo "\t\t\t[OK]\n";
}
else
{
echo "\t\t\t[ERREUR 6]\n";
}
}
else
{
echo "\t\t\t[ERREUR 5]\n";
}
}
}
else
{
echo "Aucun compte n'est en attente de supression\n";
}
?>