Subversion Repositories ALCASAR

Rev

Rev 2829 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log

<!DOCTYPE HTML>
<!-- Written by Rexy -->
<html>
<head>
        <title>Sauvegarde</title>
        <link rel="stylesheet" href="/css/acc.css" type="text/css">
</head>
<body>
<?
# choice of language
$Language = "en";
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
 $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
 $Language = strtolower(substr(chop($Langue[0]),0,2));}
if ($Language == 'fr'){
 $l_backups = "Sauvegarde";
 $l_create_user_db_backup = "Créer le fichier de la base actuelle des usagers";
 $l_traceability_backup = "Créer le fichier de traces de la semaine en cours";
 $l_create_system_backup = "Créer un fichier de configuration";
 $l_execute = "Exécuter";
 $l_backup_files = "Fichiers disponibles pour archivage";
 $l_firewall_log = "Journaux de traçabilité";
 $l_users_db_backups = "Base des usagers";
 $l_weekly_report = "Rapports d'activité hebdomadaire";
 $l_empty = "vide";
}
else {
 $l_backups = "Backups";
 $l_create_user_db_backup = "Create the current users database file";
 $l_traceability_backup = "Create the traceability file of the current week";
 $l_create_system_backup = "Create the configuration file";
 $l_execute = "Execute";
 $l_backup_files = "Archive backup files";
 $l_firewall_log = "Traceability log files";
 $l_users_db_backups = "Users database";
 $l_weekly_report = "Weekly activity reports";
 $l_empty = "empty";
}
function taille_fichier($fichier)
{
        $taille_fichier = filesize($fichier);
        if ($taille_fichier >= 1073741824){
                $taille_fichier = round($taille_fichier / 1073741824 * 100) / 100 . " Go";}
        elseif ($taille_fichier >= 1048576){
                $taille_fichier = round($taille_fichier / 1048576 * 100) / 100 . " Mo";}
        elseif ($taille_fichier >= 1024){
                $taille_fichier = round($taille_fichier / 1024 * 100) / 100 . " Ko";}
        else {$taille_fichier = $taille_fichier . " o";} 
        return $taille_fichier;
}
?>
<div class="panel">
        <div class="panel-header"><?= $l_backups ?></div>
        <div class="panel-row">
                <div class="panel-cell">
                        <form action="sauvegarde.php" method=POST>
                        <select name='choix'>
                                <option value="traceability_backup"><?= $l_traceability_backup?>
                                <option value="user_DB_backup"><?= $l_create_user_db_backup?>
                                <option value="system_backup"><?= $l_create_system_backup?>
                        </select>
                        <input type=submit value="<?= $l_execute?>">
                        </form>
                </div>
        </div>
</div>
<div class="panel">
        <div class="panel-header"><?= $l_backup_files?></div>
        <div class="panel-row">
                <div class="panel-cell">
                <table width="100%" border=0 cellspacing=0 cellpadding=1>
                        <tr align="center">
                                <td><b><?= $l_firewall_log?></b></td>
                                <td><b><?= $l_users_db_backups?></b></td>
                                <td><b><?= $l_weekly_report?></b></td>
                        </tr>
                        <tr align="center">
<?
if (isset($_POST['choix'])){
        switch ($_POST['choix']){
                case 'user_DB_backup' :
                        exec ("sudo /usr/local/bin/alcasar-mysql.sh --dump");
                break;
                case 'traceability_backup' :
                        exec ("sudo /usr/local/bin/alcasar-archive.sh --live");
                break;
                case 'system_backup' :
                        exec ("sudo /usr/local/bin/alcasar-conf.sh --create");
                        header('Location: alcasar-conf.tar.gz');
                break;
        }
}
$dir[0]="archive";
$dir[1]="base";
$dir[2]="activity_report";
$j=0;
$nb=count($dir);
while ($j != $nb)
{
        echo "<td valign='top'>";
        $rep = opendir("/var/Save/".$dir[$j]);
        $i=0; unset ($liste_f);
        while ( $file = readdir($rep) )
        {
                if ($file != '.' && $file != '..')
                {
                        $liste_f[$i] = $file;
                        $i++;
                }
        }
        closedir($rep);
        if ($i == 0)
        {
                echo "$l_empty";
        }
        else
        {
                sort($liste_f);
                while ( $i > 0)
                {
                        $i--;
                        echo "<a href=\"/save/$dir[$j]/$liste_f[$i]\">$liste_f[$i]</A> (";echo taille_fichier("/var/Save/".$dir[$j]."/".$liste_f[$i]);echo ")<br>\n";
                }
        }
        echo "</td>\n";
        $j++;
}
?>
                        </tr>
                </table>
                </div>
        </div>
</div>
</body>
</html>