1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
<?php
/**
* Check if user is logged in, or perform authentication
*
* This file is part of Zoph.
*
* Zoph is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Zoph is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with Zoph; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* This file lets a user pass through if one of the following is true:
* - a valid username/password was given
* - a $user object was found in the session
* - a default user has been defined in config.inc.php
*
* @package Zoph
* @author Jason Geiger
* @author Jeroen Roos
*/
namespace auth;
use conf\conf;
use user;
class cli implements auth {
private $user;
private $lang;
/**
* Create auth/cli object
* @SuppressWarnings(PHPMD.Superglobals)
*/
public function __construct() {
if (conf::get("interface.user.cli")!=="0") {
$user=new user(conf::get("interface.user.cli"));
} else {
$username=$_SERVER["USER"];
try {
$user=user::getByName($username);
} catch (\userNotFoundException $e) {
throw new \cliUserNotValidException($username . " is not a valid user");
}
}
$user->lookup();
$user->lookupPerson();
$user->lookupPrefs();
$user->prefs->load();
$lang=$user->loadLanguage();
$this->user=$user;
$this->lang=$lang;
}
public function getUser() {
return $this->user;
}
public function getLang() {
return $this->lang;
}
public function getRedirect() {
return;
}
}
?>
|