From 8e93341cd33287bdb9d300541b9395cc7ae39987 Mon Sep 17 00:00:00 2001 From: Alan Garcia Date: Thu, 27 Mar 2014 13:50:44 +0000 Subject: [PATCH] Some cosmetics --- bureau/admin/adm_mxaccount.php | 2 +- bureau/admin/adm_var_edit.php | 2 +- bureau/class/class_system_bind.php | 2 +- bureau/class/m_action.php | 2 +- bureau/class/m_admin.php | 19 +++++++++++-------- bureau/class/m_bro.php | 4 ++-- bureau/class/m_dom.php | 8 ++++++-- phpunit/lib/AlterncTest.php | 5 ++++- src/fix_dovecot_quota.php | 3 +++ 9 files changed, 30 insertions(+), 17 deletions(-) diff --git a/bureau/admin/adm_mxaccount.php b/bureau/admin/adm_mxaccount.php index 6df1875a..408d9145 100644 --- a/bureau/admin/adm_mxaccount.php +++ b/bureau/admin/adm_mxaccount.php @@ -51,7 +51,7 @@ if ($newlogin) { // Add an account if ($mail->add_slave_account($newlogin,$newpass)) { $error=_("The requested account address has been created. It is now allowed."); - $newlogin=false;$newpass=false; + $newlogin='';$newpass=''; } } diff --git a/bureau/admin/adm_var_edit.php b/bureau/admin/adm_var_edit.php index 7684ae58..f4c1dc8f 100644 --- a/bureau/admin/adm_var_edit.php +++ b/bureau/admin/adm_var_edit.php @@ -138,7 +138,7 @@ function var_input($infotype, $name, $value='') { break; case "boolean": echo ""; // This way, there is allways something send, even if checkbox is unchecked - echo ""; + echo ""; break; default: echo "WTF ? Dunno what to do with a ".$infotype['type']; diff --git a/bureau/class/class_system_bind.php b/bureau/class/class_system_bind.php index cd2ffac9..9596af07 100644 --- a/bureau/class/class_system_bind.php +++ b/bureau/class/class_system_bind.php @@ -143,7 +143,7 @@ class system_bind { * * @global m_dom $dom * @param string $domain - * @return string + * @return array */ function get_domain_summary($domain=false) { global $dom; diff --git a/bureau/class/m_action.php b/bureau/class/m_action.php index 23b720b9..a1bec46d 100644 --- a/bureau/class/m_action.php +++ b/bureau/class/m_action.php @@ -50,7 +50,7 @@ class m_action { function do_action() { global $err, $L_INOTIFY_DO_ACTION; $err->log("action", "do_action"); - if( ! touch($L_INOTIFY_DO_ACTION) ){ + if( ! @touch($L_INOTIFY_DO_ACTION) ){ return FALSE; } return TRUE; diff --git a/bureau/class/m_admin.php b/bureau/class/m_admin.php index b592043d..53ee8f88 100644 --- a/bureau/class/m_admin.php +++ b/bureau/class/m_admin.php @@ -569,11 +569,11 @@ class m_admin { * @param int $duration * @param string $notes * @param integer $force - * @param boolean $create_dom + * @param string $create_dom * @param int $db_server_id * @return boolean Returns FALSE if an error occurs, TRUE if not. */ - function add_mem($login, $pass, $nom, $prenom, $mail, $canpass=1, $type='default', $duration=0, $notes = "", $force=0, $create_dom=false, $db_server_id) { + function add_mem($login, $pass, $nom, $prenom, $mail, $canpass=1, $type='default', $duration=0, $notes = "", $force=0, $create_dom='', $db_server_id) { global $err,$quota,$classes,$cuid,$mem,$L_MYSQL_DATABASE,$L_MYSQL_LOGIN,$hooks,$action; $err->log("admin","add_mem",$login."/".$mail); if (!$this->enabled) { @@ -1135,7 +1135,7 @@ EOF; function checkalldom() { global $db,$L_NS1,$L_NS2,$L_MX,$L_PUBLIC_IP; $checked=array(); - $r=$db->query("SELECT * FROM domaines ORDER BY domaine;"); + $db->query("SELECT * FROM domaines ORDER BY domaine;"); $dl=array(); while ($db->next_record()) { $dl[$db->Record["domaine"]]=$db->Record; @@ -1179,10 +1179,14 @@ EOF; // Check the IP: $out=array(); exec("dig +short A ".escapeshellarg($d["sub"].(($d["sub"]!="")?".":"").$c["domaine"]),$out); - if (!in_array($L_PUBLIC_IP,$out)) { - $errstr.="subdomain '".$d["sub"]."' don't point to $L_PUBLIC_IP but to ".implode(",",$out)."\n"; - $errno=1; - } + if (! is_array($out)) { // exec dig can fail + $errno=1; $errstr.="Fail to get the DNS information. Try again.\n"; + } else { + if (!in_array($L_PUBLIC_IP,$out)) { + $errstr.="subdomain '".$d["sub"]."' don't point to $L_PUBLIC_IP but to ".implode(",",$out)."\n"; + $errno=1; + } + } } } } @@ -1362,7 +1366,6 @@ EOF; global $db,$classes,$hooks; $tmp1=array(); $tmp2=array(); - $tmp3=array(); $policies=array(); $db->query("SELECT * FROM policy;"); while ($db->next_record()) { diff --git a/bureau/class/m_bro.php b/bureau/class/m_bro.php index b25bdeb1..b9afbd11 100644 --- a/bureau/class/m_bro.php +++ b/bureau/class/m_bro.php @@ -99,12 +99,12 @@ class m_bro { * @param string $dir * @global m_mem $mem * @param string $dir Dossier absolu que l'on souhaite vérifier - * @param integer $strip + * @param boolean $strip * @return false|string Retourne le nom du dossier vrifi, relatif au * dossier de l'utilisateur courant, ventuellement corrig. * ou FALSE si le dossier n'est pas dans le dossier de l'utilisateur. */ - function convertabsolute($dir,$strip=1) { + function convertabsolute($dir,$strip=true) { global $mem; $root=$this->get_user_root($mem->user["login"]); // Sauvegarde du chemin de base. diff --git a/bureau/class/m_dom.php b/bureau/class/m_dom.php index 3fce3abb..cadb44b3 100644 --- a/bureau/class/m_dom.php +++ b/bureau/class/m_dom.php @@ -435,7 +435,7 @@ class m_dom { $this->lock(); // function add_domain($domain,$dns,$noerase=0,$force=0,$isslave=0,$slavedom="") - if (! $this->add_domain($domain, true, false, 1) ) { + if (! $this->add_domain($domain, true, false, true) ) { $err->raise('dom', "Error adding domain"); return false; } @@ -652,7 +652,7 @@ class m_dom { * force ne devrait être utilisé que par le super-admin. $ @return boolean Retourne FALSE si une erreur s'est produite, TRUE sinon. */ - function add_domain($domain,$dns,$noerase=0,$force=0,$isslave=0,$slavedom="") { + function add_domain($domain,$dns,$noerase=false,$force=false,$isslave=false,$slavedom="") { global $db,$err,$quota,$classes,$L_MX,$L_FQDN,$tld,$cuid,$bro,$hooks; $err->log("dom","add_domain",$domain); @@ -1608,6 +1608,10 @@ class m_dom { return $res; } + /** + * + * @return array + */ function get_domain_all_summary() { global $db,$err; $res=array(); diff --git a/phpunit/lib/AlterncTest.php b/phpunit/lib/AlterncTest.php index 36faa47c..a2188044 100644 --- a/phpunit/lib/AlterncTest.php +++ b/phpunit/lib/AlterncTest.php @@ -23,6 +23,9 @@ abstract class AlterncTest extends PHPUnit_Extensions_Database_TestCase */ public function loadDataSet($fileList) { + if (empty($fileList)) { + throw new \Exception("No files specified"); + } if( !is_array($fileList)){ $fileList = array($fileList); } @@ -41,4 +44,4 @@ abstract class AlterncTest extends PHPUnit_Extensions_Database_TestCase -} \ No newline at end of file +} diff --git a/src/fix_dovecot_quota.php b/src/fix_dovecot_quota.php index 668788f0..9095e8c5 100755 --- a/src/fix_dovecot_quota.php +++ b/src/fix_dovecot_quota.php @@ -25,6 +25,8 @@ if ( $nb != 1 ){ } #we check that for that type only one option is specified +# FIXME je doute que ca fasse un truc pertinent ce morceau +$nb2=0; foreach($options as $opt => $val){ $nb2=count($options[$opt]); } @@ -61,6 +63,7 @@ function FixQuotaDovecot($conditions){ } #We construct a sql query to get the mailbox root based on the option. +// FIXME where does $opt come from ?? switch($opt){ case "m": if (!filter_var($val,FILTER_VALIDATE_EMAIL)) {