From cac820c1ad2dc74d54effc1e0e7165d6deaf1d4b Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Thu, 11 Nov 2010 18:54:52 +0000 Subject: [PATCH] fixed bug 3107124, config/shell parsing --- lam/HISTORY | 2 ++ lam/lib/account.inc | 23 +++++++++++------------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lam/HISTORY b/lam/HISTORY index 7295e2f9..6e3e98eb 100644 --- a/lam/HISTORY +++ b/lam/HISTORY @@ -1,6 +1,8 @@ December 2010 3.3.0 - additional usability enhancements - PDF export: higher resolution for logos + - fixed bugs: + -> ignore comment lines in shells file (3107124) 28.10.2010 3.2.0 diff --git a/lam/lib/account.inc b/lam/lib/account.inc index 20359aec..b9c64c30 100644 --- a/lam/lib/account.inc +++ b/lam/lib/account.inc @@ -39,24 +39,23 @@ $Id$ * @return array list of shell names */ function getshells() { + $return = array(); $shellPath = dirname(__FILE__) . '/../config/shells'; - // Load shells from file + // load shells from file if (file_exists($shellPath)) { $shells = file($shellPath); - $i = 0; - while (count($shells) > $i) { - // remove whitespaces - trim($shells[$i]); - // remove lineend - $shells[$i] = substr($shells[$i], 0, strpos($shells[$i], "\n")); + for ($i = 0; $i < sizeof($shells); $i++) { + // remove whitespaces and line end + $shells[$i] = trim($shells[$i]); // remove comments - if ($shells[$i]{0}=='#') unset ($shells[$i]); - else $i++; + if ((strlen($shells[$i]) == 0) || $shells[$i]{0}=='#') { + continue; + } + $return[] = $shells[$i]; } - // $shells is array with all valid shells - return $shells; + return $return; } - else return array(); + return $return; }