207 lines
5.5 KiB
PHP
Executable File
207 lines
5.5 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] => Le dossier de l'utilisateur n'existe pas
|
|
[ERREUR 2] => La commande pour évaluer la taille du fichier n'a pu etre executé
|
|
[ERREUR 3] => La modification de la chaine sortant de la commande d'evaluation de taille a échoué.
|
|
[ERREUR 4] => Le fichier de logs de trafic ne peut etre lu (pas forcement une erreur)
|
|
[ERREUR 5] => La mise a jour sur le panel a échoué.
|
|
[ERREUR 6] => Le fichier de log n'a pu etre supprimé
|
|
*/
|
|
|
|
|
|
// Annulation de la connexion MySql locale :
|
|
$ConnexionLocale = "non";
|
|
|
|
// Inclusion du core
|
|
require ('/var/www/daemon/system/core.php');
|
|
|
|
|
|
/* -------- */
|
|
/* Espace */
|
|
/* -------- */
|
|
|
|
echo "Mise a jour des quotas d'espace\n";
|
|
$ListBdd = $ConnexionPanel->Select("*", "utilisateur", "ServeurFichier='".$ServeurFichier."'", "", "", "", "");
|
|
if ( $ListBdd != FALSE )
|
|
{
|
|
$CountBdd = count ($ListBdd);
|
|
|
|
for ($i=0; $i < $CountBdd; $i++)
|
|
{
|
|
echo "Taille de ".$ListBdd[$i]["Utilisateur"]." : ";
|
|
|
|
if ( is_dir("/var/www/web/".$ListBdd[$i]["Utilisateur"]."/") )
|
|
{
|
|
$ExecTest = shell_exec("du -hcaL /var/www/web/".$ListBdd[$i]["Utilisateur"]."/ | grep -wv '/var/www/web/".$ListBdd[$i]["Utilisateur"]."/*'");
|
|
if ( $ExecTest != FALSE )
|
|
{
|
|
|
|
$Chiffre = explode ("\t", $ExecTest);
|
|
$Chiffre = str_replace(",", ".", $Chiffre[0]);
|
|
$Chiffre = trim ($Chiffre);
|
|
|
|
$MajPanel = $ConnexionPanel->Update ("utilisateur", "Espace", $Chiffre, "Utilisateur='".$ListBdd[$i]["Utilisateur"]."'");
|
|
if ( $MajPanel != FALSE )
|
|
{
|
|
echo "\t\t\t[OK]\n";
|
|
}
|
|
else
|
|
{
|
|
echo "\t\t\t[OK]\n";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
echo "\t\t\t[ERREUR 2]\n";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
echo "\t\t\t[ERREUR 1]\n";
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
echo "Aucun utilisateurs sur ".$ServeurFichier."\n";
|
|
}
|
|
|
|
|
|
/* ---------------- */
|
|
/* Bande Passante */
|
|
/* ---------------- */
|
|
/*
|
|
echo "\n\nMise a jour des quotas de bande passante\n";
|
|
$ListBdd = $ConnexionPanel->Select("*", "utilisateur", "ServeurFichier='".$ServeurFichier."'", "", "", "", "");
|
|
if ( $ListBdd != FALSE )
|
|
{
|
|
$CountBdd = count ($ListBdd);
|
|
|
|
for ($i=0; $i < $CountBdd; $i++)
|
|
{
|
|
|
|
// Domaine kelio.org
|
|
echo "Domaine de ".$ListBdd[$i]["Utilisateur"]." : ".$ListBdd[$i]["Utilisateur"].".kelio.org";
|
|
if ( is_readable("/var/www/logs/trafic/".$ListBdd[$i]["Utilisateur"].".kelio.org.log") )
|
|
{
|
|
$Fichier = file ("/var/www/logs/trafic/".$ListBdd[$i]["Utilisateur"].".kelio.org.log");
|
|
$Total = 0;
|
|
|
|
foreach ($Fichier as $key => $value)
|
|
{
|
|
$value = trim($value);
|
|
|
|
if ( is_numeric($value) )
|
|
{
|
|
$Total += $value;
|
|
}
|
|
}
|
|
$Suppression = unlink ("/var/www/logs/trafic/".$ListBdd[$i]["Utilisateur"].".kelio.org.log");
|
|
if ( $Suppression != FALSE )
|
|
{
|
|
echo "\t\t\t[OK]\n";
|
|
}
|
|
else
|
|
{
|
|
echo "\t\t\t[ERREUR 6]\n";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
echo "\t\t\t[ERREUR 4]\n";
|
|
}
|
|
|
|
//Domaine externe
|
|
$ListDomaine = $ConnexionPanel->Select("*", "domaine", "Utilisateur='".$ListBdd[$i]["Utilisateur"]."' AND Status='2'", "", "", "", "");
|
|
if ( $ListDomaine != FALSE )
|
|
{
|
|
$CountDomaine = count($ListDomaine);
|
|
|
|
for ($o=0; $o < $CountDomaine; $o++)
|
|
{
|
|
sleep (1);
|
|
echo "Domaine de ".$ListDomaine[$o]["Utilisateur"]." : ".$ListDomaine[$o]["Adresse"];
|
|
|
|
if ( is_readable("/var/www/logs/trafic/".$ListDomaine[$o]["Adresse"].".log") )
|
|
{
|
|
$Fichier = file ("/var/www/logs/trafic/".$ListDomaine[$o]["Adresse"].".log");
|
|
foreach ($Fichier as $key => $value)
|
|
{
|
|
$value = trim($value);
|
|
|
|
if ( is_numeric($value) )
|
|
{
|
|
$Total += $value;
|
|
}
|
|
}
|
|
$Suppression = unlink ("/var/www/logs/trafic/".$ListDomaine[$o]["Adresse"].".log");
|
|
if ( $Suppression != FALSE)
|
|
{
|
|
echo "\t\t\t[OK]\n";
|
|
}
|
|
else
|
|
{
|
|
echo "\t\t\t[ERREUR 6]\n";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
echo "\t\t\t[ERREUR 4]\n";
|
|
}
|
|
}
|
|
}
|
|
|
|
// Convertion et mise a jour du panel
|
|
$Total = ($Total / 1024) / 1024;
|
|
$Total = $ListBdd[$i]["BandePassante"] + $Total;
|
|
|
|
$MajPanel = $ConnexionPanel->Update ("utilisateur", "BandePassante", round($Total, 1), "Utilisateur='".$ListBdd[$i]["Utilisateur"]."'");
|
|
if ( $MajPanel != FALSE )
|
|
{
|
|
echo "Domaines de ".$ListBdd[$i]["Utilisateur"]."\t\t\t[OK]\n";
|
|
}
|
|
else
|
|
{
|
|
echo "Domaines de ".$ListBdd[$i]["Utilisateur"]."\t\t\t[ERREUR 5]\n";
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
echo "Aucun utilisateurs sur ".$ServeurFichier."\n";
|
|
}
|
|
*/
|
|
|
|
/* -------------- */
|
|
/* RECHARGEMENT */
|
|
/* -------------- */
|
|
/*
|
|
$Commande = shell_exec("sudo /etc/init.d/apache2 reload");
|
|
if ( $Commande != FALSE )
|
|
{
|
|
echo "Rechargement d'apache : \t\t\t[OK]\n\n";
|
|
}
|
|
else
|
|
{
|
|
echo "Rechargement d'apache : \t\t\t[ERREUR]\n\n";
|
|
}
|
|
*/
|
|
|
|
?>
|