From 853280c19dd9a5cd7b4ba0bae15cd57f990b6c8c Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Fri, 19 Sep 2014 07:29:23 +0000 Subject: [PATCH] authparams : in CLI, return the user "cli" git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1833 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- authparams.php | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/authparams.php b/authparams.php index c853dcd..996d337 100644 --- a/authparams.php +++ b/authparams.php @@ -14,19 +14,27 @@ class authparams If non is found, return "anonymous", "anonymous" */ public function __construct ($authprocesses=array("session","post")) { - foreach ($authprocesses as $authprocess) + if (php_sapi_name () === "cli") { - try + $this->email = "cli"; + $this->password = ""; + } + else + { + foreach ($authprocesses as $authprocess) { - $res = $this->$authprocess(); - $this->email = $res["email"]; - $this->password = $res["password"]; - break; - } - catch (Exception $e) - { - $this->email = "anonymous"; - $this->password = "anonymous"; + try + { + $res = $this->$authprocess(); + $this->email = $res["email"]; + $this->password = $res["password"]; + break; + } + catch (Exception $e) + { + $this->email = "anonymous"; + $this->password = "anonymous"; + } } } }