[fix] not using debug_backtrace, please, [doc] doc to english

This commit is contained in:
Benjamin Sonntag 2017-10-06 19:34:50 +02:00
parent 1f4ea5d132
commit cc64e7745f
5 changed files with 57 additions and 58 deletions

View File

@ -38,8 +38,8 @@ $r=$mysql->get_userslist();
<hr id="topbar"/> <hr id="topbar"/>
<br /> <br />
<?php <?php
// On regarde d'abord si on a une db existante. Sioui, on regarde si on a des utilisateurs existants // If the db exists, we look at users
if(!$rdb || empty($rdb)){ if (!$rdb || empty($rdb)) {
$msg->raise("INFO", "mysql", _("You have no database at the moment.")); $msg->raise("INFO", "mysql", _("You have no database at the moment."));
} else if(!$r || empty($r)){ } else if(!$r || empty($r)){
$msg->raise("INFO", "mysql", _("You have no sql user at the moment.")); $msg->raise("INFO", "mysql", _("You have no sql user at the moment."));
@ -54,7 +54,7 @@ if($rdb){
<form method="post" action="sql_del.php" name="main" id="main"> <form method="post" action="sql_del.php" name="main" id="main">
<?php csrf_get(); ?> <?php csrf_get(); ?>
<table class="tlist"> <table class="tlist">
<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> <tr><th>&nbsp;</th><th><?php __("Database"); ?></th><?php if ( variable_get('sql_allow_users_backups') ) { ?><th><?php __("Backup"); ?></th><?php } ?><th><?php __("Restore"); ?></th><th><?php __("Show Settings"); ?></th><th><?php __("Size"); ?></th></tr>
<?php <?php
for($i=0;$i<count($rdb);$i++) { for($i=0;$i<count($rdb);$i++) {

View File

@ -62,8 +62,8 @@ if (isset($fatal) && $fatal) {
<table class="tedit"> <table class="tedit">
<tr> <tr>
<?php <?php
// On récupère la taille max d'un nom d'utilisateur mysql (définit dans les variables globales d'AlternC // We check the max length of a mysql user (defined in the variables of AlternC)
// et on l'utilise pour mettre la propriété maxlength de l'Input du nom // we use that for the maxlenght of the Input
$len=variable_get('sql_max_username_length', NULL)-strlen($mem->user["login"]."_"); $len=variable_get('sql_max_username_length', NULL)-strlen($mem->user["login"]."_");
?> ?>
<th><label for="usern"><?php __("Username"); ?></label></th> <th><label for="usern"><?php __("Username"); ?></label></th>

View File

@ -52,7 +52,7 @@ include_once("head.php");
?> ?>
<h3><?php __("MySQL users"); ?></h3> <h3><?php __("MySQL users"); ?></h3>
<hr id="topbar"/> <hr id="topbar"/>
<BR /> <br />
<p class="alert alert-warning"><?php __("WARNING"); ?></big><br /><?php __("Confirm the deletion of the following MySQL users"); ?><br /> <p class="alert alert-warning"><?php __("WARNING"); ?></big><br /><?php __("Confirm the deletion of the following MySQL users"); ?><br />
</p> </p>
<form method="post" action="sql_users_del.php" id="main"> <form method="post" action="sql_users_del.php" id="main">

View File

@ -36,7 +36,7 @@ $fields = array (
getFields($fields); getFields($fields);
if ($mysql->change_user_password($id,$password,$passwordconf)) if ($mysql->change_user_password($id,$password,$passwordconf))
$msg->raise("INFO", "mysql", _("Mot de passe changé pour l'utilisateur '%s'."), $id); $msg->raise("INFO", "mysql", _("Password changed for user '%s'."), $id);
include("sql_users_list.php"); include("sql_users_list.php");
?> ?>

View File

@ -259,12 +259,12 @@ class m_mysql {
return false; return false;
} }
// On empèche la création auto d'utilisateurs si la taille du nom de la db est plus grand que la taille max du nom d'utilisateur // We prevent the automatic creation of user account longer than the max allowed lenght of a MySQL username
$len=variable_get('sql_max_username_length', NULL); $len=variable_get('sql_max_username_length', NULL);
if (strlen($dbname) <= $len) { if (strlen($dbname) <= $len) {
$db->query("SELECT name from dbusers where name= ? and enable='ACTIVATED' ;", array($dbname)); $db->query("SELECT name from dbusers where name= ? and enable='ACTIVATED' ;", array($dbname));
if (!$db->num_rows()) { if (!$db->num_rows()) {
// On récupère la complexité du mdp qu'on doit générer que l'on va passer en paramètre de la fonction create_pass // We get the password complexity set in the policy and ensure we have that complexity in the create_pass() call
$c=$admin->listPasswordPolicies(); $c=$admin->listPasswordPolicies();
$passwd_classcount = $c['mysql']['classcount']; $passwd_classcount = $c['mysql']['classcount'];
@ -279,7 +279,7 @@ class m_mysql {
$msg->raise("ALERT", "mysql", "L'utilisateur '$dbname' n'a pas été automatiquement créé car il dépasse la limite de taille pour les utilisateurs qui est à $len<br>Allez à la page 'Utilisateurs Mysql' pour en créer un avec le nom que vous voulez.<br>Et n'oubliez pas de lui donner les droits sur la base de données."); $msg->raise("ALERT", "mysql", "L'utilisateur '$dbname' n'a pas été automatiquement créé car il dépasse la limite de taille pour les utilisateurs qui est à $len<br>Allez à la page 'Utilisateurs Mysql' pour en créer un avec le nom que vous voulez.<br>Et n'oubliez pas de lui donner les droits sur la base de données.");
} }
//checking for the phpmyadmin user // checking for the phpmyadmin user
$db->query("SELECT * FROM dbusers WHERE uid= ? AND enable='ADMIN';", array($cuid)); $db->query("SELECT * FROM dbusers WHERE uid= ? AND enable='ADMIN';", array($cuid));
if ($db->num_rows()) { if ($db->num_rows()) {
$db->next_record(); $db->next_record();
@ -290,7 +290,7 @@ class m_mysql {
return false; return false;
} }
//Grant the special user every rights. // Grant the special user every rights.
if ($this->dbus->exec("CREATE DATABASE $dbname;")) { // secured: dbname is checked against ^[0-9a-z]*$ if ($this->dbus->exec("CREATE DATABASE $dbname;")) { // secured: dbname is checked against ^[0-9a-z]*$
$msg->log("mysql", "add_db_succes", $dbn); $msg->log("mysql", "add_db_succes", $dbn);
// Ok, database does not exist, quota is ok and dbname is compliant. Let's proceed // Ok, database does not exist, quota is ok and dbname is compliant. Let's proceed
@ -334,11 +334,11 @@ class m_mysql {
$db_esc = str_replace('_', '\_', $dbname); $db_esc = str_replace('_', '\_', $dbname);
$this->dbus->query("DELETE FROM mysql.db WHERE Db= ? ;", array($db_esc)); $this->dbus->query("DELETE FROM mysql.db WHERE Db= ? ;", array($db_esc));
#We test if the user created with the database is associated with more than 1 database. // We test if the user created with the database is associated with more than 1 database.
$this->dbus->query("select User from mysql.db where User= ? ;", array($dbname)); $this->dbus->query("select User from mysql.db where User= ? ;", array($dbname));
if (($this->dbus->num_rows()) == 0) { if (($this->dbus->num_rows()) == 0) {
#If not we can delete it. // If not we can delete it.
$this->del_user($dbname); $this->del_user($dbname, false, true );
} }
return true; return true;
} }
@ -608,7 +608,7 @@ class m_mysql {
$listRights = array('Select', 'Insert', 'Update', 'Delete', 'Create', 'Drop', 'References', 'Index', 'Alter', 'Create_tmp_table', 'Lock_tables', 'Create_view', 'Show_view', 'Create_routine', 'Alter_routine', 'Execute', 'Event', 'Trigger'); $listRights = array('Select', 'Insert', 'Update', 'Delete', 'Create', 'Drop', 'References', 'Index', 'Alter', 'Create_tmp_table', 'Lock_tables', 'Create_view', 'Show_view', 'Create_routine', 'Alter_routine', 'Execute', 'Event', 'Trigger');
while ($this->dbus->next_record()) { while ($this->dbus->next_record()) {
// rTmp est l'array dans lequel on met les infos recupérées à chaque tour de boucle et est ajouté à l'array $r // rTmp is the array where we put the informations from each loop, added to array $r
$rTmp = array(); $rTmp = array();
$variable = $this->dbus->Record; $variable = $this->dbus->Record;
@ -641,7 +641,7 @@ class m_mysql {
$r[] = $rTmp; $r[] = $rTmp;
} //endwhile } // endwhile
return $r; return $r;
} }
@ -746,7 +746,7 @@ class m_mysql {
* @param integer $all * @param integer $all
* @return boolean if the user has been deleted in MySQL or FALSE if an error occurred * @return boolean if the user has been deleted in MySQL or FALSE if an error occurred
* */ * */
function del_user($user, $all = false) { function del_user($user, $all = false, $caller_is_deldb = false) {
global $db, $msg, $cuid; global $db, $msg, $cuid;
$msg->log("mysql", "del_user", $user); $msg->log("mysql", "del_user", $user);
if (!preg_match("#^[0-9a-z]#", $user)) { if (!preg_match("#^[0-9a-z]#", $user)) {
@ -759,9 +759,8 @@ class m_mysql {
$db->query("SELECT name FROM dbusers WHERE uid= ? ;", array($cuid)); $db->query("SELECT name FROM dbusers WHERE uid= ? ;", array($cuid));
} }
$backtrace = debug_backtrace();
if (!$db->num_rows()) { if (!$db->num_rows()) {
if ($backtrace[1]["function"] != "del_db") if (! $caller_is_deldb )
$msg->raise("ERROR", "mysql", _("The username was not found")); $msg->raise("ERROR", "mysql", _("The username was not found"));
return false; return false;
@ -777,8 +776,8 @@ class m_mysql {
$db->query("DELETE FROM dbusers WHERE uid= ? AND name= ? ;", array($cuid, $user)); $db->query("DELETE FROM dbusers WHERE uid= ? AND name= ? ;", array($cuid, $user));
if ($backtrace[1]["function"] == "del_db") if ( $caller_is_deldb )
$msg->raise('info', "mysql", _("The user '%s' has been successfully deleted"), $user); $msg->raise("INFO", "mysql", _("The user '%s' has been successfully deleted"), $user);
return true; return true;
} }
@ -995,7 +994,7 @@ class m_mysql {
$d = $this->get_userslist(1); $d = $this->get_userslist(1);
if (!empty($d)) { if (!empty($d)) {
for ($i = 0; $i < count($d); $i++) { for ($i = 0; $i < count($d); $i++) {
$this->del_user($d[$i]["name"], 1); $this->del_user($d[$i]["name"], 1,true);
} }
} }
return true; return true;