From 0bf6596466529472f5a9dc2070351117dfcdc75b Mon Sep 17 00:00:00 2001 From: Alan Garcia Date: Wed, 26 Mar 2014 13:31:06 +0000 Subject: [PATCH] Cosmetic, again --- awstats/bureau/class/m_aws.php | 7 ++++--- bureau/admin/mail_list.php | 2 +- bureau/class/class_system_bind.php | 4 ++-- bureau/class/m_dom.php | 18 +++++++++++------- bureau/class/m_ftp.php | 8 +++----- bureau/class/m_mail.php | 3 ++- bureau/class/m_mysql.php | 8 +++----- bureau/class/m_quota.php | 3 +-- phpunit/bootstrap.php | 8 +++++--- roundcube/class/m_roundcube.php | 8 ++++++-- squirrelmail/class/m_squirrelmail.php | 1 - 11 files changed, 38 insertions(+), 32 deletions(-) diff --git a/awstats/bureau/class/m_aws.php b/awstats/bureau/class/m_aws.php index 2ca628b4..c154c71c 100644 --- a/awstats/bureau/class/m_aws.php +++ b/awstats/bureau/class/m_aws.php @@ -139,7 +139,6 @@ class m_aws { function get_stats_details($id) { global $db,$err,$cuid; $err->log("aws","get_stats_details",$id); - $r=array(); $db->query("SELECT id, hostname, hostaliases, public FROM aws WHERE uid='$cuid' AND id='$id';"); if ($db->num_rows()) { $db->next_record(); @@ -295,7 +294,7 @@ class m_aws { */ function put_stats_details($id,$users,$hostaliases,$public) { global $err,$db,$cuid; - if ($c=$this->get_stats_details($id)) { + if ($this->get_stats_details($id)) { $this->delete_allowed_login($id, 1); if (is_array($users)) { foreach($users as $v) { @@ -306,7 +305,9 @@ class m_aws { $this->_createconf($id); $this->_createhtpasswd(); return true; - } else return false; + } else { + return false; + } } diff --git a/bureau/admin/mail_list.php b/bureau/admin/mail_list.php index 4d12ad60..2572cb0b 100644 --- a/bureau/admin/mail_list.php +++ b/bureau/admin/mail_list.php @@ -60,7 +60,7 @@ if ($fatal) { echo "
$error
"; } else { - if (!empty($error)) { echo "

$error

"; } + if (isset($error) && !empty($error)) { echo "

$error

"; } ?> diff --git a/bureau/class/class_system_bind.php b/bureau/class/class_system_bind.php index ea3ee011..b4b82028 100644 --- a/bureau/class/class_system_bind.php +++ b/bureau/class/class_system_bind.php @@ -136,7 +136,7 @@ class system_bind { * @param string $domain * @return string */ - function get_zone_header($domain) { + function get_zone_header() { return file_get_contents($this->ZONE_TEMPLATE); } @@ -315,7 +315,7 @@ class system_bind { function get_zone($domain) { global $L_FQDN, $L_NS1_HOSTNAME, $L_NS2_HOSTNAME, $L_DEFAULT_MX, $L_DEFAULT_SECONDARY_MX, $L_PUBLIC_IP; - $zone =$this->get_zone_header($domain); + $zone =$this->get_zone_header(); $zone.=implode("\n",$this->conf_from_db($domain)); $zone.="\n;;;HOOKED ENTRY\n"; diff --git a/bureau/class/m_dom.php b/bureau/class/m_dom.php index 2081f1d9..da305981 100644 --- a/bureau/class/m_dom.php +++ b/bureau/class/m_dom.php @@ -79,6 +79,8 @@ class m_dom { var $action_delete = "2"; var $tld_no_check_at_all = "1"; + + var $cache_domains_type_lst=false; /* ----------------------------------------------------------------- */ /** * Constructeur @@ -148,14 +150,16 @@ class m_dom { * authorisé. Retourne FALSE si une erreur s'est produite. */ function domains_type_lst() { - global $db,$err,$cuid; + global $db,$err; $err->log("dom","domains_type_lst"); - $db->query("select * from domaines_type order by advanced;"); - $this->domains_type_lst=false; - while ($db->next_record()) { - $this->domains_type_lst[strtolower($db->Record["name"])] = $db->Record; + if (empty($this->cache_domains_type_lst)) { + $db->query("select * from domaines_type order by advanced;"); + $this->cache_domains_type_lst=array(); + while ($db->next_record()) { + $this->cache_domains_type_lst[strtolower($db->Record["name"])] = $db->Record; + } } - return $this->domains_type_lst; + return $this->cache_domains_type_lst; } function domains_type_enable_values() { @@ -405,7 +409,7 @@ class m_dom { break; } - // If it is a know domains type + // If it is an unknown domains type if (! array_key_exists( strtolower($val['type']), $this->domains_type_lst() ) ) { echo "what is this shit ?\n"; print_r($entry); diff --git a/bureau/class/m_ftp.php b/bureau/class/m_ftp.php index 76fc4642..273b6b00 100644 --- a/bureau/class/m_ftp.php +++ b/bureau/class/m_ftp.php @@ -168,7 +168,7 @@ class m_ftp { $db->next_record(); $regexp="/^".preg_quote(getuserpath(),"/")."\/(.*)$/"; - $tr=preg_match($regexp, $db->f("homedir"),$match); + preg_match($regexp, $db->f("homedir"),$match); $lg=explode("_",$db->f("name")); if ((!is_array($lg)) || (count($lg)!=2)) { @@ -272,7 +272,7 @@ class m_ftp { return false; } $lo=$mem->user["login"]; - $l=substr($lo,0,1); + $full_login=$prefixe; if ($login) $full_login.="_".$login; if (! $this->check_login($full_login) ) return false; @@ -363,10 +363,9 @@ class m_ftp { $db->query("SELECT login FROM membres WHERE uid='$cuid';"); $db->next_record(); $lo=$db->f("login"); - $l=substr($lo,0,1); $absolute=getuserpath()."/$dir"; if (!file_exists($absolute)) { - system("/bin/mkdir -p $absolute"); + system("/bin/mkdir -p $absolute"); // FIXME replace with action } if (!is_dir($absolute)) { $err->raise("ftp",_("The directory cannot be created")); @@ -399,7 +398,6 @@ class m_ftp { global $mem,$db,$err; $err->log("ftp","is_ftp",$dir); $lo=$mem->user["login"]; - $l=substr($lo,0,1); if (substr($dir,0,1)=="/") $dir=substr($dir,1); $db->query("SELECT id FROM ftpusers WHERE homedir='".getuserpath()."/$dir';"); if ($db->num_rows()) { diff --git a/bureau/class/m_mail.php b/bureau/class/m_mail.php index bf7a40db..b2de3356 100644 --- a/bureau/class/m_mail.php +++ b/bureau/class/m_mail.php @@ -158,6 +158,7 @@ class m_mail { } function catchall_set($domain_id, $target) { + global $err; // target : $target=rtrim($target); if ( substr_count($target,'@') == 0 ) { // Pas de @ @@ -885,7 +886,7 @@ ORDER BY $db->query("SELECT value FROM variable where name='mailname_bounce';"); if (!$db->next_record()) { - $err->raise("mail",_("The email %s does not exist, it can't be deleted"),$mail); + $err->raise("mail",_("Problem: can't create default bounce mail")); return false; } $mailname=$db->f("value"); diff --git a/bureau/class/m_mysql.php b/bureau/class/m_mysql.php index afd0f918..d1ff5369 100644 --- a/bureau/class/m_mysql.php +++ b/bureau/class/m_mysql.php @@ -219,7 +219,6 @@ class m_mysql { $err->raise("mysql",_("Database %s not found"),$dbn); return array("enabled"=>false); } - $c=array(); $db->next_record(); list($dbu,$dbn)=split_mysql_database_name($db->f("db")); return array("enabled"=>true,"login"=>$db->f("login"),"db"=>$db->f("db"), "name"=>$dbn,"bck"=>$db->f("bck_mode"), "dir"=>substr($db->f("bck_dir"),strlen($root)), "size"=>$size, "pass"=>$db->f("pass"), "history"=>$db->f("bck_history"), "gzip"=>$db->f("bck_gzip")); @@ -604,7 +603,7 @@ class m_mysql { $dbu=$dbn; $r=array(); $dbn=str_replace('_','\_',$dbn); - $q=$this->dbus->query("Select * from mysql.db where Db='".$dbn."' and User!='".$cuid."_myadm';"); + $this->dbus->query("Select * from mysql.db where Db='".$dbn."' and User!='".$cuid."_myadm';"); if(!$db->num_rows()){ return $r; @@ -1073,14 +1072,14 @@ class m_mysql { $err->log("mysql","export"); $db->query("SELECT login, pass, db, bck_mode, bck_dir, bck_history, bck_gzip FROM db WHERE uid='$cuid';"); if ($db->next_record()) { - $str.=" \n"; + $str =" \n"; $str.=" ".$db->Record["login"]."\n"; $str.=" ".$db->Record["pass"]."\n"; do { $filename=$tmpdir."/mysql.".$db->Record["db"].".sql.gz"; $str.=" ".($db->Record["db"])."\n"; $str.=" ".($db->Record["pass"])."\n"; - if ($s["bck_mode"]!=0) { + if ($s["bck_mode"]!=0) { // FIXME what is $s ? $str.=" ".($db->Record["bck_mode"])."\n"; $str.=" ".($db->Record["bck_dir"])."\n"; $str.=" ".($db->Record["bck_history"])."\n"; @@ -1140,7 +1139,6 @@ class m_mysql { $this->dbus->query("show databases;"); $res=array(); - $d=array(); while($this->dbus->next_record()) { $dbname=$this->dbus->f("Database"); $c=mysql_query("SHOW TABLE STATUS FROM $dbname;"); diff --git a/bureau/class/m_quota.php b/bureau/class/m_quota.php index 62c4c370..443aa575 100644 --- a/bureau/class/m_quota.php +++ b/bureau/class/m_quota.php @@ -157,7 +157,7 @@ class m_quota { $err->log("quota","getquota",$ressource); if ($recheck) { // rebuilding quota $get_quota_cache=null; - $this->quota=array(); + $this->quotas=array(); } if (! empty($get_quota_cache[$cuid]) ) { // This function is called many time each webpage, so I cache the result @@ -346,7 +346,6 @@ class m_quota { */ function deltype($type) { global $db; - $qlist=$this->qlist(); if($db->query("UPDATE membres SET type='default' WHERE type='$type'") && $db->query("DELETE FROM defquotas WHERE type='$type'")) { diff --git a/phpunit/bootstrap.php b/phpunit/bootstrap.php index 1d1d8205..4f25b2e2 100644 --- a/phpunit/bootstrap.php +++ b/phpunit/bootstrap.php @@ -26,9 +26,9 @@ require_once ALTERNC_PANEL."/class/functions.php"; // General variables setup // ********************* if(is_readable('local.sh')){ - $configFile = file_get_contents('local.sh', 'r'); + $configFile = file_get_contents('local.sh'; } else if(is_readable('local.sh_generic')){ - $configFile = file_get_contents('local.sh_generic', 'r'); + $configFile = file_get_contents('local.sh_generic'); } else { throw new Exception("You must provide a local.sh file", 1 ); } @@ -88,7 +88,9 @@ if ( is_readable("my.cnf") ) { $mysqlConfigFile = file("my.cnf"); } else if(is_readable('my.cnf_generic')){ $mysqlConfigFile = file('my.cnf_generic'); -} +} else { + throw new Exception("You must provide a my.cnf file", 1 ); +} foreach ($mysqlConfigFile as $line) { if (preg_match('/^([A-Za-z0-9_]*) *= *"?(.*?)"?$/', trim($line), $matches)) { diff --git a/roundcube/class/m_roundcube.php b/roundcube/class/m_roundcube.php index e944fab9..90f1676b 100644 --- a/roundcube/class/m_roundcube.php +++ b/roundcube/class/m_roundcube.php @@ -39,7 +39,6 @@ class m_roundcube { global $db; // Search for the domain where the panel is hosted, then search for a webmail in it. $i=2; - $domain=""; if (!empty($_SERVER["HTTP_HOST"])) { do { // for each domain part (search panel.alternc.org then alternc.org then org, if the current panel is at www.panel.alternc.org) $expl=explode(".",$_SERVER["HTTP_HOST"],$i); @@ -79,6 +78,11 @@ class m_roundcube { // Use cleandb.sh filled by roundcube ? http://trac.roundcube.net/browser/github/bin/cleandb.sh include_once("/etc/roundcube/debian-db.php"); + if (! isset($dbtype)) { + global $err; + $err->raise("roundcube::hook_mail_delete_for_real",_("Problem: missing var in Debian Roundcube configuration file")); + return false; + } switch ($dbtype) { case "sqlite": @@ -89,7 +93,7 @@ class m_roundcube { if ($dbport != '') $dbport=":$dbport"; if ($dbserver == '') $dbserver="localhost"; $dbh= new PDO("$dbtype:host=$dbserver;dbname=$dbname;dbport=$dbport", $dbuser, $dbpass); - $rcdb = "$dbtype:$dbuser:$dbpass@$dbserver$dbport/$dbname"; + #$rcdb = "$dbtype:$dbuser:$dbpass@$dbserver$dbport/$dbname"; break; } diff --git a/squirrelmail/class/m_squirrelmail.php b/squirrelmail/class/m_squirrelmail.php index 7013881d..31bbdb39 100644 --- a/squirrelmail/class/m_squirrelmail.php +++ b/squirrelmail/class/m_squirrelmail.php @@ -39,7 +39,6 @@ class m_squirrelmail { global $db; // Search for the domain where the panel is hosted, then search for a webmail in it. $i=2; - $domain=""; if (!empty($_SERVER["HTTP_HOST"])) { do { // for each domain part (search panel.alternc.org then alternc.org then org, if the current panel is at www.panel.alternc.org) $expl=explode(".",$_SERVER["HTTP_HOST"],$i);