getshells() now returns an empty array if $_SESSION['lampath'] is not set

This commit is contained in:
Roland Gruber 2004-10-16 13:58:08 +00:00
parent 153da7bf86
commit 4ec2a4ef4f
1 changed files with 15 additions and 12 deletions

View File

@ -36,20 +36,23 @@ $Id$
*/ */
function getshells() { function getshells() {
// Load shells from file // Load shells from file
$shells = file($_SESSION['lampath'].'config/shells'); if (file_exists($_SESSION['lampath'] . 'config/shells')) {
$i=0; $shells = file($_SESSION['lampath'] . 'config/shells');
while (count($shells) > $i) { $i = 0;
// remove whitespaces while (count($shells) > $i) {
trim($shells[$i]); // remove whitespaces
// remove lineend trim($shells[$i]);
$shells[$i] = substr($shells[$i], 0, strpos($shells[$i], "\n")); // remove lineend
// remove comments $shells[$i] = substr($shells[$i], 0, strpos($shells[$i], "\n"));
if ($shells[$i]{0}=='#') unset ($shells[$i]); // remove comments
else $i++; if ($shells[$i]{0}=='#') unset ($shells[$i]);
else $i++;
} }
// $shells is array with all valid shells // $shells is array with all valid shells
return $shells; return $shells;
} }
else return array();
}
/* This function will replace umlates with ascci-chars /* This function will replace umlates with ascci-chars