authparams : in CLI, return the user "cli"

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1833 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2014-09-19 07:29:23 +00:00
parent b2b1048bee
commit 853280c19d

View File

@@ -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";
}
}
}
}