On peux désactiver la possibilité pour l'utilisateur de faire ses propres backups de MySQL

Utile pour les hébergement mutu qui ont déjà des backups de configuré.
This commit is contained in:
Alan Garcia 2013-03-04 16:28:19 +00:00
parent 2693aab130
commit 19e4739d79
4 changed files with 33 additions and 9 deletions

View File

@ -30,6 +30,18 @@
require_once("../class/config.php");
include_once("head.php");
?>
<h3><?php __("MySQL Databases - Configure backups"); ?></h3>
<hr id="topbar"/>
<br />
<?php
if ( ! variable_get('sql_allow_users_backups') ) {
echo "<p class=\"error\">"._("You aren't allowed to access this page. Contact your administrator if you want to.")."</p>";
include_once('foot.php');
exit;
}
$fields = array (
"id" => array ("request", "string", ""),
"bck_mode" => array ("request", "integer", 0),
@ -44,14 +56,9 @@ if (!$r=$mysql->get_mysql_details($id)) {
$error=$err->errstr();
}
?>
<h3><?php __("MySQL Databases"); ?></h3>
<hr id="topbar"/>
<br />
<?php
if (isset($error) && $error) {
if (isset($error) && $error) {
echo "<p class=\"error\">$error</p><p>&nbsp;</p>";
}
}
if (is_array($r)) {
?>

View File

@ -29,6 +29,14 @@
*/
require_once("../class/config.php");
if ( ! variable_get('sql_allow_users_backups') ) {
include_once('head.php');
echo "<p class=\"error\">"._("You aren't allowed to access this page. Contact your administrator if you want to.")."</p>";
include_once('foot.php');
exit;
}
$fields = array (
"id" => array ("request", "string", ""),
"bck_mode" => array ("request", "integer", 0),

View File

@ -51,7 +51,7 @@ if($rdb){
?>
<form method="post" action="sql_del.php" name="main" id="main">
<table class="tlist">
<tr><th>&nbsp;</th><th><?php __("Database"); ?></th><th><?php __("Backup"); ?></th><th><?php __("Restore"); ?></th><th><?php __("Show Settings"); ?></th><th><?php __("Size"); ?></th></tr>
<tr><th>&nbsp;</th><th><?php __("Database"); ?></th><?php if ( variable_get('sql_allow_users_backups') ) { ?><th><?php __("Backup"); ?></th><?php } // sql_allow_users_backups ?><th><?php __("Restore"); ?></th><th><?php __("Show Settings"); ?></th><th><?php __("Size"); ?></th></tr>
<?php
$col=1;
@ -63,7 +63,9 @@ for($i=0;$i<count($rdb);$i++) {
<tr class="lst<?php echo $col; ?>">
<td align="center"><input type="checkbox" class="inc" id="del_<?php echo $val["db"]; ?>" name="del_<?php echo $val["db"]; ?>" value="<?php echo ($val["db"]); ?>" /></td>
<td><label for="del_<?php echo $val["db"]; ?>"><?php echo $val["db"]; ?></label></td>
<?php if ( variable_get('sql_allow_users_backups') ) { ?>
<td><div class="ina"><a href="sql_bck.php?id=<?php echo $val["db"] ?>"><?php __("Backup"); ?></a></div></td>
<?php } // sql_allow_users_backups ?>
<td><div class="ina"><a href="sql_restore.php?id=<?php echo $val["db"] ?>"><?php __("Restore"); ?></a></div></td>
<td><div class="ina"><a href="sql_getparam.php?dbname=<?php echo $val["db"] ?>"><?php __("Show Settings"); ?></a></div></td>
<td><code><?php echo format_size($val["size"]); ?></code></td>

View File

@ -74,6 +74,7 @@ class m_mysql {
if (!empty($cuid)) {
$this->dbus = new DB_users();
}
variable_get('sql_allow_users_backups', 1,'Set 1 to allow users to configure backup of their databases, 0 if you want do disable this feature. Warning: it will not stop configured backup made by sqlbackup.sh');
}
function reload_dbus() {
@ -346,6 +347,12 @@ class m_mysql {
function put_mysql_backup($dbn,$bck_mode,$bck_history,$bck_gzip,$bck_dir) {
global $db,$err,$mem,$bro,$cuid;
$err->log("mysql","put_mysql_backup");
if ( ! variable_get('sql_allow_users_backups') ) {
$err->raise("mysql",_("User aren't allowed to configure their backups"));
return false;
}
$pos=strpos($dbn,'_');
if($pos === false){
$dbname=$dbn;