From 4ec2a4ef4fe63312e052ff44ed239ba146b6618b Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 16 Oct 2004 13:58:08 +0000 Subject: [PATCH] getshells() now returns an empty array if $_SESSION['lampath'] is not set --- lam/lib/account.inc | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/lam/lib/account.inc b/lam/lib/account.inc index 98164f33..c9d882e1 100644 --- a/lam/lib/account.inc +++ b/lam/lib/account.inc @@ -36,20 +36,23 @@ $Id$ */ function getshells() { // Load shells from file - $shells = file($_SESSION['lampath'].'config/shells'); - $i=0; - while (count($shells) > $i) { - // remove whitespaces - trim($shells[$i]); - // remove lineend - $shells[$i] = substr($shells[$i], 0, strpos($shells[$i], "\n")); - // remove comments - if ($shells[$i]{0}=='#') unset ($shells[$i]); - else $i++; + if (file_exists($_SESSION['lampath'] . 'config/shells')) { + $shells = file($_SESSION['lampath'] . 'config/shells'); + $i = 0; + while (count($shells) > $i) { + // remove whitespaces + trim($shells[$i]); + // remove lineend + $shells[$i] = substr($shells[$i], 0, strpos($shells[$i], "\n")); + // remove comments + if ($shells[$i]{0}=='#') unset ($shells[$i]); + else $i++; } - // $shells is array with all valid shells - return $shells; + // $shells is array with all valid shells + return $shells; } + else return array(); +} /* This function will replace umlates with ascci-chars