diff --git a/controllers/d.admin.php b/controllers/d.admin.php
index 05de358..e54a70d 100755
--- a/controllers/d.admin.php
+++ b/controllers/d.admin.php
@@ -123,7 +123,8 @@ if(isset($controller->splitted_url[1]) && $user->rankIsHigher("moderator")) {
case 'stats':
if ($user->rankIsHigher("moderator")) {
$head['title'] = "Statistiques";
- $report = $config['abs_root_folder'].'report.html';
+
+ $report = $config['abs_root_folder'].'tmp/report.html';
$files = glob('/var/log/nginx/kabano.org-access.log*.gz');
$command = '/bin/bash -c \'(zcat '.implode(' ', $files).' && cat /var/log/nginx/kabano.org-access.log.1) | goaccess --log-format=COMBINED --no-progress -o '.escapeshellarg($report).' - \' 2>&1';
$output = shell_exec($command);
@@ -134,6 +135,37 @@ if(isset($controller->splitted_url[1]) && $user->rankIsHigher("moderator")) {
$notfound = 1;
}
break;
+ case 'sql-backup':
+ if ($user->rankIsHigher("administrator")) {
+ $head['title'] = "Export SQL";
+
+ if(isset($controller->splitted_url[2]) && $controller->splitted_url[2]=='delete' && isset($controller->splitted_url[3])) {
+ unlink($config['abs_root_folder'].'tmp/'.$controller->splitted_url[3]);
+ $output = Array();
+ $backup_file = null;
+ }
+ else {
+ // Nom du fichier de sauvegarde
+ $timestamp = date('Ymd_His');
+ $filename = $timestamp.'_backup.sql';
+ $backup_file = $config['abs_root_folder'].'tmp/'.$filename;
+
+ // Construction de la commande pg_dump
+ $cmd = 'PGPASSWORD="'.$config['SQL_pass'].'" pg_dump -h '.$config['SQL_host'].' -U '.$config['SQL_user'].' -F c -b -v -f "'.$backup_file.'" '.$config['SQL_db'].' 2>&1';
+
+ $output = [];
+ $return_var = 0;
+ exec($cmd, $output, $return_var);
+ }
+
+ $sql_files = glob($config['abs_root_folder'].'tmp/*.sql');
+
+ include ($config['views_folder']."d.admin.sql-dump.html");
+ }
+ else {
+ $notfound = 1;
+ }
+ break;
default:
$notfound = 1;
break;
diff --git a/views/css/d.index.css b/views/css/d.index.css
index 03979fa..d867ecd 100755
--- a/views/css/d.index.css
+++ b/views/css/d.index.css
@@ -39,6 +39,10 @@ small {
font-weight: 500;
}
+pre {
+ overflow: auto;
+}
+
.button {
padding: 5px 10px;
margin: 5px 10px;
diff --git a/views/d.admin.html b/views/d.admin.html
index 1ff6744..1fc7999 100755
--- a/views/d.admin.html
+++ b/views/d.admin.html
@@ -12,6 +12,7 @@
if($user->rankIsHigher("administrator")) { ?>
Mettre à jour Met à jour le logiciel depuis le dépôt GIT.
+ Sauvegarde SQLGénère un dump SQL téléchargeable.
} ?>
if($user->rankIsHigher("moderator")) { ?>
Voir les logs Permet d'accéder aux 200 dernières lignes des logs bruts des actions sur la base de données.
diff --git a/views/d.admin.sql-dump.html b/views/d.admin.sql-dump.html
new file mode 100644
index 0000000..5ed2179
--- /dev/null
+++ b/views/d.admin.sql-dump.html
@@ -0,0 +1,39 @@
+
+
+
+ include('blocks/d.head.html'); ?>
+
+
+ foreach($output as $line) {
+ echo $line."
";
+ }
+ ?>
+