From 62dde928c50175f4ebff78cdd1b94d10409d6c15 Mon Sep 17 00:00:00 2001 From: Alan Garcia Date: Wed, 26 Mar 2014 15:04:12 +0000 Subject: [PATCH] Cosmetic --- bureau/class/functions.php | 14 +++++++++----- bureau/class/m_authip.php | 1 - bureau/class/m_bro.php | 15 +++++++-------- bureau/class/m_export.php | 1 - bureau/class/m_ftp.php | 3 --- bureau/class/m_hooks.php | 2 +- bureau/class/m_hta.php | 4 +--- bureau/class/m_lxc.php | 9 +++++---- bureau/class/m_mail.php | 5 ++--- bureau/class/m_mem.php | 4 ++-- bureau/class/reset_stats_conf.php | 3 ++- 11 files changed, 29 insertions(+), 32 deletions(-) diff --git a/bureau/class/functions.php b/bureau/class/functions.php index cfb1d49f..c099c315 100644 --- a/bureau/class/functions.php +++ b/bureau/class/functions.php @@ -308,10 +308,12 @@ function getuserpath($user = null) { */ function cbox($test, $echo = TRUE) { if ($test) { - $return = " checked=\"checked\""; + $return = " checked=\"checked\""; + } else { + $return=''; } if( $echo ){ - echo $return; + echo $return; } return $return; } @@ -327,10 +329,12 @@ function cbox($test, $echo = TRUE) { */ function selected($bool, $echo = TRUE) { if ($bool) { - $return = " selected=\"selected\""; + $return = " selected=\"selected\""; + } else { + $return=''; } if( $echo ){ - echo $return; + echo $return; } return $return; } @@ -851,7 +855,7 @@ function display_browser($dir="", $caller="main.dir", $width=350, $height=450) { document.write(' '); document.write('
'); - document.write(' '); + document.write(' '); document.write('
'); // --> diff --git a/bureau/class/m_authip.php b/bureau/class/m_authip.php index e0caaac9..cedc4567 100644 --- a/bureau/class/m_authip.php +++ b/bureau/class/m_authip.php @@ -251,7 +251,6 @@ class m_authip { */ function get_auth_class() { global $hooks; - $authclass=array(); $authclass = $hooks->invoke('authip_class'); // Je rajoute la class DANS l'objet parce que diff --git a/bureau/class/m_bro.php b/bureau/class/m_bro.php index fa64c9b9..49b69d61 100644 --- a/bureau/class/m_bro.php +++ b/bureau/class/m_bro.php @@ -182,7 +182,7 @@ class m_bro { global $db,$cuid,$err; $db->query("UPDATE browser SET lastdir='$dir' WHERE uid='$cuid';"); $absolute=$this->convertabsolute($dir,0); - if (! file_exists($absolute)) { + if (!$absolute || !file_exists($absolute)) { $err->raise('bro',_("This directory do not exist")); return false; } @@ -239,11 +239,11 @@ class m_bro { $listmode=intval($listmode); $showicons=intval($showicons); $showtype=intval($showtype); $downfmt=intval($downfmt); $createfile=intval($createfile); $golastdir=intval($golastdir); - $db->query("SELECT * FROM browser WHERE uid='$cuid';"); + $db->query("SELECT * FROM browser WHERE uid='".intval($cuid)."';"); if ($db->num_rows()==0) { - $db->query("INSERT INTO browser (editsizex, editsizey, listmode, showicons, downfmt, createfile, showtype, uid, editor_font, editor_size, golastdir) VALUES (70, 21, 0, 0, 0, 0, 0, '".$this->uid."','Arial, Helvetica, Sans-serif','12px',1);"); + $db->query("INSERT INTO browser (editsizex, editsizey, listmode, showicons, downfmt, createfile, showtype, uid, editor_font, editor_size, golastdir) VALUES (70, 21, 0, 0, 0, 0, 0, '".intval($cuid)."','Arial, Helvetica, Sans-serif','12px',1);"); } - $db->query("UPDATE browser SET editsizex='$editsizex', editsizey='$editsizey', listmode='$listmode', showicons='$showicons', downfmt='$downfmt', createfile='$createfile', showtype='$showtype', editor_font='$editor_font', editor_size='$editor_size', golastdir='$golastdir' WHERE uid='$cuid';"); + $db->query("UPDATE browser SET editsizex='$editsizex', editsizey='$editsizey', listmode='$listmode', showicons='$showicons', downfmt='$downfmt', createfile='$createfile', showtype='$showtype', editor_font='$editor_font', editor_size='$editor_size', golastdir='$golastdir' WHERE uid='".intval($cuid)."';"); return true; } @@ -721,11 +721,11 @@ class m_bro { function content($R,$file) { global $err; $absolute=$this->convertabsolute($R,0); - $std=""; if (!strpos($file,"/")) { $absolute.="/".$file; if (file_exists($absolute)) { $std=str_replace("<","<",str_replace("&","&",file_get_contents($absolute))); + return $std; } else { $err->raise("bro",_("Cannot read the requested file. Please check the permissions")); return false; @@ -734,7 +734,6 @@ class m_bro { $err->raise("bro",_("File or folder name is incorrect")); return false; } - return $std; } @@ -970,7 +969,7 @@ class m_bro { header("Content-Disposition: attachment; filename=".$mem->user["login"].".zip"); header("Content-Type: application/x-zip"); header("Content-Transfer-Encoding: binary"); - $d=escapeshellarg($this->convertabsolute($dir,0)); + $d=escapeshellarg($this->convertabsolute($dir,false)); set_time_limit(0); passthru("/usr/bin/zip -r - $d"); } @@ -1020,7 +1019,7 @@ class m_bro { global $db,$err; $err->log("bro","export_conf"); $str="\n"; - $str=" \n"; + $str.=" \n"; $pref=$this->GetPrefs(); $i=1; diff --git a/bureau/class/m_export.php b/bureau/class/m_export.php index 7f4443a5..187fef91 100644 --- a/bureau/class/m_export.php +++ b/bureau/class/m_export.php @@ -11,7 +11,6 @@ Class m_export { function export_conf(){ global $hooks; - $conf = array(); $conf=$hooks->invoke('alternc_export_conf'); return $conf; } diff --git a/bureau/class/m_ftp.php b/bureau/class/m_ftp.php index 273b6b00..92b8c2af 100644 --- a/bureau/class/m_ftp.php +++ b/bureau/class/m_ftp.php @@ -271,7 +271,6 @@ class m_ftp { $err->raise("ftp",_("The chosen prefix is not allowed")); return false; } - $lo=$mem->user["login"]; $full_login=$prefixe; if ($login) $full_login.="_".$login; @@ -362,7 +361,6 @@ class m_ftp { } $db->query("SELECT login FROM membres WHERE uid='$cuid';"); $db->next_record(); - $lo=$db->f("login"); $absolute=getuserpath()."/$dir"; if (!file_exists($absolute)) { system("/bin/mkdir -p $absolute"); // FIXME replace with action @@ -397,7 +395,6 @@ class m_ftp { function is_ftp($dir) { global $mem,$db,$err; $err->log("ftp","is_ftp",$dir); - $lo=$mem->user["login"]; 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_hooks.php b/bureau/class/m_hooks.php index dc3854cc..673b18d2 100644 --- a/bureau/class/m_hooks.php +++ b/bureau/class/m_hooks.php @@ -88,7 +88,7 @@ class m_hooks { // First, build the list of script we want to launch $to_launch=array(); if (is_file($scripts)) { - if (is_executable($script)) { + if (is_executable($scripts)) { $to_launch[]=$scripts; } } else if (is_dir($scripts)) { diff --git a/bureau/class/m_hta.php b/bureau/class/m_hta.php index dc89cdee..f4499caf 100644 --- a/bureau/class/m_hta.php +++ b/bureau/class/m_hta.php @@ -147,11 +147,9 @@ class m_hta { global $mem,$err; $err->log("hta","is_protected",$dir); $absolute=ALTERNC_HTML."/".substr($mem->user["login"],0,1)."/".$mem->user["login"]."/$dir"; - $sortie=array(); if (file_exists("$absolute/.htpasswd")){ return true; - } - else { + } else { return false; } } diff --git a/bureau/class/m_lxc.php b/bureau/class/m_lxc.php index 08c871d1..538cc820 100644 --- a/bureau/class/m_lxc.php +++ b/bureau/class/m_lxc.php @@ -34,7 +34,9 @@ class m_lxc implements vm { public $IP; + public $KEY; public $PORT; + public $maxtime; public $TIMEOUT = 5; public $error = array(); @@ -107,7 +109,6 @@ class m_lxc implements vm { $this->error[] = 'Unable to send data'; return FALSE; } - $resp = ''; $resp = fgets($fp, 8192); fclose ($fp); @@ -147,14 +148,14 @@ class m_lxc implements vm { return $this->error; } else { $data = unserialize($res); - $error = $data['error']; + $error = (int)$data['error']; $hostname = $data['hostname']; $msg = $data['msg']; $date_start = 'NOW()'; $uid = $mem->user['uid']; - if ((int)$data['error'] != 0) { - $err->raise('lxc', _($data['msg'])); + if ($error != 0) { + $err->raise('lxc', _($msg)); return FALSE; } $db->query("INSERT INTO vm_history (ip,date_start,uid,serialized_object) VALUES ('$hostname', $date_start, '$uid', '$res')"); diff --git a/bureau/class/m_mail.php b/bureau/class/m_mail.php index 2d76d8fc..ffb9b760 100644 --- a/bureau/class/m_mail.php +++ b/bureau/class/m_mail.php @@ -76,6 +76,7 @@ class m_mail { var $srv_pop3s; var $cache_domain_mail_size = array(); + var $enum_domains=array(); /* ----------------------------------------------------------------- */ /** * Constructeur @@ -674,7 +675,7 @@ ORDER BY } } $db->query("DELETE FROM recipient WHERE address_id=".$mail_id.";"); - if ($m) { + if (isset($m) && $m) { $db->query("INSERT INTO recipient SET address_id=".$mail_id.", recipients='".addslashes($red)."';"); } return true; @@ -738,13 +739,11 @@ ORDER BY $err->log("mail","export"); $domain=$this->enum_domains(); $str="\n"; - $onepop=false; foreach ($domain as $d) { $str.=" \n ".xml_entities($d["domain"])."\n"; $s=$this->enum_domain_mails($d["id"]); if (count($s)) { while (list($key,$val)=each($s)){ - $test=$this->get_details($val['id']); $str.="
\n"; $str.=" ".xml_entities($val["address"])."\n"; $str.=" ".xml_entities($val["enabled"])."\n"; diff --git a/bureau/class/m_mem.php b/bureau/class/m_mem.php index fe30af48..b48b60a8 100644 --- a/bureau/class/m_mem.php +++ b/bureau/class/m_mem.php @@ -486,9 +486,9 @@ Cordially. $db->next_record(); // un cookie de 20 caractères pour le mail - $COOKIE=substr(md5(uniqid(rand(),1)),0,20); + $COOKIE=substr(md5(uniqid(rand(), true)),0,20); // et de 6 pour la clé à entrer. ca me semble suffisant... - $KEY=substr(md5(uniqid(rand(),1)),0,6); + $KEY=substr(md5(uniqid(rand(), true)),0,6); $link="https://$L_FQDN/mem_cm.php?usr=$cuid&cookie=$COOKIE"; $txt=sprintf(_("Hello, diff --git a/bureau/class/reset_stats_conf.php b/bureau/class/reset_stats_conf.php index 28f84a40..f70af959 100644 --- a/bureau/class/reset_stats_conf.php +++ b/bureau/class/reset_stats_conf.php @@ -8,6 +8,7 @@ if (!$admin->enabled) { } $db->query("SELECT id,hostname FROM stats;"); +$d=array(); while ($db->next_record()) { $d[]=$db->Record; } @@ -16,4 +17,4 @@ foreach ($d as $r) { $stats->_createconf($r[0],1); } -?> \ No newline at end of file +?>
Browser