Change all the "new class" by "new Class"

This commit is contained in:
2021-05-07 13:10:37 +02:00
parent c8d275be31
commit c09fa961cd
39 changed files with 430 additions and 432 deletions
+6 -6
View File
@@ -160,7 +160,7 @@ class Auth
*/ */
public function authentication ($email, $password) public function authentication ($email, $password)
{ {
throw new exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No authentication available"), 405); "No authentication available"), 405);
} }
@@ -168,7 +168,7 @@ class Auth
*/ */
public function getdetails () public function getdetails ()
{ {
throw new exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No getdetails available"), 405); "No getdetails available"), 405);
} }
@@ -179,7 +179,7 @@ class Auth
*/ */
public function changepassword ($oldpassword, $newpassword) public function changepassword ($oldpassword, $newpassword)
{ {
throw new exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No password change available"), 405); "No password change available"), 405);
} }
@@ -191,7 +191,7 @@ class Auth
*/ */
public function overwritepassword ($email, $newpassword) public function overwritepassword ($email, $newpassword)
{ {
throw new exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No password overwrite available"), 405); "No password overwrite available"), 405);
} }
@@ -200,7 +200,7 @@ class Auth
*/ */
public function listusers () public function listusers ()
{ {
throw new exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No List User available"), 405); "No List User available"), 405);
} }
@@ -208,7 +208,7 @@ class Auth
*/ */
public function logout () public function logout ()
{ {
throw new exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No logout method available"), 405); "No logout method available"), 405);
} }
} }
+12 -12
View File
@@ -105,7 +105,7 @@ class Authentication
if (session_id () === "") if (session_id () === "")
session_start (); session_start ();
if ($this->debug) echo "<pre>LOGOUT\n"; if ($this->debug) echo "<pre>LOGOUT\n";
$authsession = new authsession (); $authsession = new Authsession ();
$param = $authsession->getdetails (); $param = $authsession->getdetails ();
if ($this->debug) echo "Logout for '".$param["email"]."'\n"; if ($this->debug) echo "Logout for '".$param["email"]."'\n";
call_user_func ($this->loggingFunc, call_user_func ($this->loggingFunc,
@@ -127,7 +127,7 @@ class Authentication
$algorithm = "HS256"; $algorithm = "HS256";
$cipherKey = null; $cipherKey = null;
$cacheDir = "data/jwtCache"; $cacheDir = "data/jwtCache";
$authjwt = new authjwt (); $authjwt = new Authjwt ();
$authjwt->serverKey = $this->authServers["authjwt"]["serverKey"]; $authjwt->serverKey = $this->authServers["authjwt"]["serverKey"];
if (isset ($this->authServers["authjwt"]["cipherKey"])) if (isset ($this->authServers["authjwt"]["cipherKey"]))
$authjwt->cipherKey = $this->authServers["authjwt"]["cipherKey"]; $authjwt->cipherKey = $this->authServers["authjwt"]["cipherKey"];
@@ -160,8 +160,8 @@ class Authentication
// If the user is already connected, redirect to the main page of the site // If the user is already connected, redirect to the main page of the site
if (session_id () === "") if (session_id () === "")
session_start (); session_start ();
$auth = new auth (); $auth = new Auth ();
$authparams = new authparams (array ("session")); $authparams = new Authparams (array ("session"));
if (isset ($_SESSION["domframework"]["authentication"]["message"])) if (isset ($_SESSION["domframework"]["authentication"]["message"]))
$message = $_SESSION["domframework"]["authentication"]["message"]; $message = $_SESSION["domframework"]["authentication"]["message"];
else else
@@ -189,7 +189,7 @@ class Authentication
session_start (); session_start ();
if ($this->debug) echo "Call verifAuthLoginPage ($url) : Start\n"; if ($this->debug) echo "Call verifAuthLoginPage ($url) : Start\n";
// rate-limit the connections // rate-limit the connections
$ratelimiter = new ratelimitfile (); $ratelimiter = new Ratelimitfile ();
// 3 connections by minutes // 3 connections by minutes
$ratelimiter->maxEntries = $this->ratelimitAuth; $ratelimiter->maxEntries = $this->ratelimitAuth;
$ratelimiter->storageDir = $this->ratelimitDir; $ratelimiter->storageDir = $this->ratelimitDir;
@@ -214,7 +214,7 @@ class Authentication
$this->route->redirect ("/authentication/$url", ""); $this->route->redirect ("/authentication/$url", "");
} }
} }
$authparams = new authparams (array ("post")); $authparams = new Authparams (array ("post"));
$res = $this->verifAuth ($authparams->email, $authparams->password); $res = $this->verifAuth ($authparams->email, $authparams->password);
if (! is_array ($res)) if (! is_array ($res))
{ {
@@ -224,7 +224,7 @@ class Authentication
call_user_func ($this->loggingFunc, call_user_func ($this->loggingFunc,
LOG_WARNING, LOG_WARNING,
"Logging error for '$authparams->email' (HTML) : $res"); "Logging error for '$authparams->email' (HTML) : $res");
$authsession = new authsession (); $authsession = new Authsession ();
$authsession->logout (); $authsession->logout ();
$baseURL = $this->route->baseURL (); $baseURL = $this->route->baseURL ();
$_SESSION["domframework"]["authentication"]["message"] = $res; $_SESSION["domframework"]["authentication"]["message"] = $res;
@@ -247,7 +247,7 @@ class Authentication
$res["lastname"] = null; $res["lastname"] = null;
if (! array_key_exists ("firstname", $res)) if (! array_key_exists ("firstname", $res))
$res["firstname"] = null; $res["firstname"] = null;
$session = new authsession (); $session = new Authsession ();
$session->savedata ($authparams->email, $authparams->password, $session->savedata ($authparams->email, $authparams->password,
$res["lastname"], $res["firstname"]); $res["lastname"], $res["firstname"]);
if (isset ($this->authServers["authjwt"]["serverKey"])) if (isset ($this->authServers["authjwt"]["serverKey"]))
@@ -278,7 +278,7 @@ class Authentication
if ($this->debug) if ($this->debug)
echo "=== entering verifAuthREST (restMethods=". echo "=== entering verifAuthREST (restMethods=".
print_r ($this->restMethods, true).")\n"; print_r ($this->restMethods, true).")\n";
$authparams = new authparams ($this->restMethods); $authparams = new Authparams ($this->restMethods);
$res = array ("email"=>"anonymous", "password"=>"anonymous"); $res = array ("email"=>"anonymous", "password"=>"anonymous");
if ($authparams->email !== "anonymous" && if ($authparams->email !== "anonymous" &&
$authparams->password !== "anonymous") $authparams->password !== "anonymous")
@@ -328,7 +328,7 @@ class Authentication
if (! key_exists ("email", $payloadArray) || if (! key_exists ("email", $payloadArray) ||
$payloadArray["email"] === "anonymous") $payloadArray["email"] === "anonymous")
throw new \Exception ("JWT Must authenticate", 401); throw new \Exception ("JWT Must authenticate", 401);
$authjwt = new authjwt (); $authjwt = new Authjwt ();
$authjwt->serverKey = $this->authServers["authjwt"]["serverKey"]; $authjwt->serverKey = $this->authServers["authjwt"]["serverKey"];
$authjwt->cipherKey = $cipherKey; $authjwt->cipherKey = $cipherKey;
$authjwt->algorithm = $algorithm; $authjwt->algorithm = $algorithm;
@@ -349,7 +349,7 @@ class Authentication
if ($this->debug) if ($this->debug)
echo "=== entering verifAuthHTML (htmlMethods=". echo "=== entering verifAuthHTML (htmlMethods=".
print_r ($this->htmlMethods, true).")\n"; print_r ($this->htmlMethods, true).")\n";
$authparams = new authparams ($this->htmlMethods); $authparams = new Authparams ($this->htmlMethods);
// Don't ask to the provider if anonymous is known // Don't ask to the provider if anonymous is known
if ($authparams->email === "anonymous" || $authparams->email === null) if ($authparams->email === "anonymous" || $authparams->email === null)
{ {
@@ -435,7 +435,7 @@ class Authentication
if (! is_array ($serversParam)) if (! is_array ($serversParam))
throw new \Exception ("Auth Server $key configuration error : ". throw new \Exception ("Auth Server $key configuration error : ".
"not an array", 500); "not an array", 500);
$class = __NAMESPACE__."\\$classname"; $class = __NAMESPACE__."\\".ucfirst ($classname);
$authmethod = new $class (); $authmethod = new $class ();
foreach ($serversParam as $param=>$value) foreach ($serversParam as $param=>$value)
{ {
+6 -6
View File
@@ -23,11 +23,11 @@ class Authhtpasswd extends Auth
public function connect () public function connect ()
{ {
if (! file_exists ($this->htpasswdFile)) if (! file_exists ($this->htpasswdFile))
throw new Exception (sprintf (dgettext ("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"The HTPasswd file '%s' is not found"), "The HTPasswd file '%s' is not found"),
$this->htpasswdFile), 500); $this->htpasswdFile), 500);
if (! is_readable ($this->htpasswdFile)) if (! is_readable ($this->htpasswdFile))
throw new Exception (sprintf (dgettext ("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"The HTPasswd file '%s' is not readable"), "The HTPasswd file '%s' is not readable"),
$this->htpasswdFile), 500); $this->htpasswdFile), 500);
} }
@@ -55,12 +55,12 @@ class Authhtpasswd extends Auth
throw new \Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Invalid format of password"), 500); "Invalid format of password"), 500);
if (crypt ($password, $cryptedPassword) !== $cryptedPassword) if (crypt ($password, $cryptedPassword) !== $cryptedPassword)
throw new Exception ("Bad password for '$email'", 401); throw new \Exception ("Bad password for '$email'", 401);
$this->details = array ("email"=>$email); $this->details = array ("email"=>$email);
return TRUE; return TRUE;
} }
} }
throw new Exception ("Unable to find the user : '$email'", 401); throw new \Exception ("Unable to find the user : '$email'", 401);
} }
/** Return all the parameters recorded for the authenticate user */ /** Return all the parameters recorded for the authenticate user */
@@ -75,7 +75,7 @@ class Authhtpasswd extends Auth
@param string $newpassword The new password to be recorded */ @param string $newpassword The new password to be recorded */
public function changepassword ($oldpassword, $newpassword) public function changepassword ($oldpassword, $newpassword)
{ {
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"The password can't be change for HTPasswd users"), "The password can't be change for HTPasswd users"),
405); 405);
} }
@@ -87,7 +87,7 @@ class Authhtpasswd extends Auth
@param string $newpassword The new password to be recorded */ @param string $newpassword The new password to be recorded */
public function overwritepassword ($email, $newpassword) public function overwritepassword ($email, $newpassword)
{ {
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"The password can't be change for HTPasswd users"), "The password can't be change for HTPasswd users"),
405); 405);
} }
+5 -5
View File
@@ -26,7 +26,7 @@ class Authimap extends Auth
function __construct () function __construct ()
{ {
if (!function_exists ("imap_open")) if (!function_exists ("imap_open"))
throw new Exception ("IMAP support unavailable in PHP", 500); throw new \Exception ("IMAP support unavailable in PHP", 500);
} }
/** Establish the connection to IMAP server. Don't do anything as the /** Establish the connection to IMAP server. Don't do anything as the
@@ -41,7 +41,7 @@ class Authimap extends Auth
@param string $password Password to authenticate */ @param string $password Password to authenticate */
public function authentication ($email, $password) public function authentication ($email, $password)
{ {
$imap = new imap ($this->imapServer, $this->imapPort, $imap = new Imap ($this->imapServer, $this->imapPort,
$email, $password, $email, $password,
$this->imapSSL, $this->imapSSLCheckCertificates); $this->imapSSL, $this->imapSSLCheckCertificates);
$this->details = array ("email" => $email); $this->details = array ("email" => $email);
@@ -61,7 +61,7 @@ class Authimap extends Auth
@param string $newpassword The new password to be recorded */ @param string $newpassword The new password to be recorded */
public function changepassword ($oldpassword, $newpassword) public function changepassword ($oldpassword, $newpassword)
{ {
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"The password can't be change for IMAP users"), 405); "The password can't be change for IMAP users"), 405);
} }
@@ -72,7 +72,7 @@ class Authimap extends Auth
@param string $newpassword The new password to be recorded */ @param string $newpassword The new password to be recorded */
public function overwritepassword ($email, $newpassword) public function overwritepassword ($email, $newpassword)
{ {
throw new exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"The password can't be overwrite for IMAP users"), "The password can't be overwrite for IMAP users"),
405); 405);
} }
@@ -81,7 +81,7 @@ class Authimap extends Auth
Return firstname, lastname, mail, with mail is an array */ Return firstname, lastname, mail, with mail is an array */
public function listusers () public function listusers ()
{ {
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Can't get list of users for IMAP server"), 405); "Can't get list of users for IMAP server"), 405);
} }
} }
+6 -6
View File
@@ -70,10 +70,10 @@ class Authjwt extends Auth
throw new \Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No Bearer Authentication available"), 401); "No Bearer Authentication available"), 401);
$token = substr ($_SERVER["HTTP_AUTHENTICATION"], 7); $token = substr ($_SERVER["HTTP_AUTHENTICATION"], 7);
$jwt = new jwt (); $jwt = new Jwt ();
$uuid = $jwt->decode ($token, $this->serverKey, $this->allowedAlg, $uuid = $jwt->decode ($token, $this->serverKey, $this->allowedAlg,
$this->cipherKey); $this->cipherKey);
$cachefile = new cachefile (); $cachefile = new Cachefile ();
$cachefile->directory = $this->cacheDir; $cachefile->directory = $this->cacheDir;
$payload = $cachefile->read ((string)$uuid); $payload = $cachefile->read ((string)$uuid);
// The JWT was tested in authparams. End of process // The JWT was tested in authparams. End of process
@@ -120,10 +120,10 @@ class Authjwt extends Auth
throw new \Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"AuthJWT : can not create token for anonymous"), 403); "AuthJWT : can not create token for anonymous"), 403);
$uuid = uuid::uuid4 (); $uuid = uuid::uuid4 ();
$cachefile = new cachefile (); $cachefile = new Cachefile ();
$cachefile->directory = $this->cacheDir; $cachefile->directory = $this->cacheDir;
$cachefile->write ($uuid, $auth); $cachefile->write ($uuid, $auth);
$jwt = new jwt (); $jwt = new Jwt ();
return $jwt->encode ($uuid, return $jwt->encode ($uuid,
$this->serverKey, $this->algorithm, $this->cipherKey); $this->serverKey, $this->algorithm, $this->cipherKey);
} }
@@ -168,10 +168,10 @@ class Authjwt extends Auth
throw new \Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No Bearer Authentication available"), 401); "No Bearer Authentication available"), 401);
$token = substr ($_SERVER["HTTP_AUTHENTICATION"], 7); $token = substr ($_SERVER["HTTP_AUTHENTICATION"], 7);
$jwt = new jwt (); $jwt = new Jwt ();
$uuid = $jwt->decode ($token, $this->serverKey, $this->allowedAlg, $uuid = $jwt->decode ($token, $this->serverKey, $this->allowedAlg,
$this->cipherKey); $this->cipherKey);
$cachefile = new cachefile (); $cachefile = new Cachefile ();
$cachefile->directory = $this->cacheDir; $cachefile->directory = $this->cacheDir;
$payload = $cachefile->read ((string)$uuid); $payload = $cachefile->read ((string)$uuid);
if (empty ($uuid) || empty ($payload) || ! key_exists ("email", $payload)) if (empty ($uuid) || empty ($payload) || ! key_exists ("email", $payload))
+1 -1
View File
@@ -116,7 +116,7 @@ class Authldap extends Auth
@param string $newpassword The new password to be recorded */ @param string $newpassword The new password to be recorded */
public function overwritepassword ($email, $newpassword) public function overwritepassword ($email, $newpassword)
{ {
throw new exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"The password can't be overwrite for LDAP users"), "The password can't be overwrite for LDAP users"),
405); 405);
} }
+64 -64
View File
@@ -28,7 +28,7 @@ class Authorizationdb extends Authorization
$driver_options=null) $driver_options=null)
{ {
// Define the structure of the table in the database // Define the structure of the table in the database
$this->db = new dblayer ($dsn, $username, $password, $driver_options); $this->db = new Dblayer ($dsn, $username, $password, $driver_options);
$this->db->table = "domframework_authorization"; $this->db->table = "domframework_authorization";
$this->db->tableprefix = $this->tableprefix; $this->db->tableprefix = $this->tableprefix;
$this->db->fields = array ( $this->db->fields = array (
@@ -44,7 +44,7 @@ class Authorizationdb extends Authorization
public function initialize () public function initialize ()
{ {
if ($this->db === null) if ($this->db === null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Database to authorize is not connected"), 500); "Database to authorize is not connected"), 500);
$tables = $this->db->listTables (); $tables = $this->db->listTables ();
if (!in_array ($this->db->tableprefix.$this->db->table, $tables)) if (!in_array ($this->db->tableprefix.$this->db->table, $tables))
@@ -63,16 +63,16 @@ class Authorizationdb extends Authorization
public function validate ($object) public function validate ($object)
{ {
if ($this->db === null) if ($this->db === null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Database to authorize is not connected"), 500); "Database to authorize is not connected"), 500);
if (substr ($object, -1) === "/") if (substr ($object, -1) === "/")
$object = substr ($object, 0, -1); $object = substr ($object, 0, -1);
if (substr ($object, 0, 1) !== "/") if (substr ($object, 0, 1) !== "/")
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Object don't start by slash"), 406); "Object don't start by slash"), 406);
$object = preg_replace ("#//+#", "/", $object); $object = preg_replace ("#//+#", "/", $object);
if ($this->authiduser === "") if ($this->authiduser === "")
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Not authenticated"), 401); "Not authenticated"), 401);
try try
{ {
@@ -80,14 +80,14 @@ class Authorizationdb extends Authorization
} }
catch (Exception $e) catch (Exception $e)
{ {
throw new Exception ($e->getMessage(), 405); throw new \Exception ($e->getMessage(), 405);
} }
// All the folder structure is accessible. Check if the object already // All the folder structure is accessible. Check if the object already
// exists // exists
$search = $this->db->read (array (array ("object", $object))); $search = $this->db->read (array (array ("object", $object)));
if (count ($search) === 0) if (count ($search) === 0)
throw new Exception (sprintf (dgettext ("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"Object %s doesn't exists"), "Object %s doesn't exists"),
$object), $object),
404); 404);
@@ -140,24 +140,24 @@ class Authorizationdb extends Authorization
public function add ($object, $ownerid, $groupid, $modbits) public function add ($object, $ownerid, $groupid, $modbits)
{ {
if ($this->db === null) if ($this->db === null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Database to authorize is not connected"), 500); "Database to authorize is not connected"), 500);
// The modbits are stored in octal to be more readable // The modbits are stored in octal to be more readable
$modbits = decoct ($modbits); $modbits = decoct ($modbits);
if (substr ($object, -1) === "/") if (substr ($object, -1) === "/")
$object = substr ($object, 0, -1); $object = substr ($object, 0, -1);
if (substr ($object, 0, 1) !== "/") if (substr ($object, 0, 1) !== "/")
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Object don't start by slash"), 406); "Object don't start by slash"), 406);
$object = preg_replace ("#//+#", "/", $object); $object = preg_replace ("#//+#", "/", $object);
if ($this->authiduser === "") if ($this->authiduser === "")
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Not authenticated"), 401); "Not authenticated"), 401);
if ($this->authiduser !== 0 && $this->authiduser !== $ownerid) if ($this->authiduser !== 0 && $this->authiduser !== $ownerid)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Can't create object not owned by myself"), 406); "Can't create object not owned by myself"), 406);
if ($this->authiduser !== 0 && !in_array ($groupid, $this->authgroups)) if ($this->authiduser !== 0 && !in_array ($groupid, $this->authgroups))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Can't create object with not owned group"), 406); "Can't create object with not owned group"), 406);
try try
{ {
@@ -165,14 +165,14 @@ class Authorizationdb extends Authorization
} }
catch (Exception $e) catch (Exception $e)
{ {
throw new Exception ($e->getMessage(), 405); throw new \Exception ($e->getMessage(), 405);
} }
// All the folder structure is accessible. Check if the object already // All the folder structure is accessible. Check if the object already
// exists // exists
$search = $this->db->read (array (array ("object", $object))); $search = $this->db->read (array (array ("object", $object)));
if (count ($search)) if (count ($search))
throw new Exception (sprintf (dgettext ("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"Object %s already defined"), $object), "Object %s already defined"), $object),
400); 400);
@@ -193,7 +193,7 @@ class Authorizationdb extends Authorization
} }
catch (Exception $e) catch (Exception $e)
{ {
throw new Exception ($e->getMessage(), 405); throw new \Exception ($e->getMessage(), 405);
} }
$this->db->create (array ("object"=>$object, $this->db->create (array ("object"=>$object,
@@ -209,19 +209,19 @@ class Authorizationdb extends Authorization
public function drop ($object) public function drop ($object)
{ {
if ($this->db === null) if ($this->db === null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Database to authorize is not connected"), 500); "Database to authorize is not connected"), 500);
if (substr ($object, -1) === "/") if (substr ($object, -1) === "/")
$object = substr ($object, 0, -1); $object = substr ($object, 0, -1);
if (substr ($object, 0, 1) !== "/") if (substr ($object, 0, 1) !== "/")
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Object don't start by slash"), 406); "Object don't start by slash"), 406);
$object = preg_replace ("#//+#", "/", $object); $object = preg_replace ("#//+#", "/", $object);
if ($this->authiduser === "") if ($this->authiduser === "")
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Not authenticated"), 401); "Not authenticated"), 401);
if ($object === "/") if ($object === "/")
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"The root can not be removed"), 406); "The root can not be removed"), 406);
try try
{ {
@@ -229,14 +229,14 @@ class Authorizationdb extends Authorization
} }
catch (Exception $e) catch (Exception $e)
{ {
throw new Exception ($e->getMessage(), 405); throw new \Exception ($e->getMessage(), 405);
} }
// All the folder structure is accessible. Check if the object already // All the folder structure is accessible. Check if the object already
// exists // exists
$search = $this->db->read (array (array ("object", $object))); $search = $this->db->read (array (array ("object", $object)));
if (count ($search) === 0) if (count ($search) === 0)
throw new Exception (sprintf (dgettext ("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"Object %s doesn't exists"), "Object %s doesn't exists"),
$object), 400); $object), 400);
@@ -246,10 +246,10 @@ class Authorizationdb extends Authorization
{ {
$rc = $this->db->delete ($object); $rc = $this->db->delete ($object);
if ($rc > 1) if ($rc > 1)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Removing more than one object"), 406); "Removing more than one object"), 406);
if ($rc == 0) if ($rc == 0)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No object removed"), 406); "No object removed"), 406);
$rc = $this->db->delete ("$object$this->separator%"); $rc = $this->db->delete ("$object$this->separator%");
return TRUE; return TRUE;
@@ -261,15 +261,15 @@ class Authorizationdb extends Authorization
} }
catch (Exception $e) catch (Exception $e)
{ {
throw new Exception ($e->getMessage(), 405); throw new \Exception ($e->getMessage(), 405);
} }
$rc = $this->db->delete ($object); $rc = $this->db->delete ($object);
if ($rc > 1) if ($rc > 1)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Removing more than one object"), 406); "Removing more than one object"), 406);
if ($rc == 0) if ($rc == 0)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No object removed"), 406); "No object removed"), 406);
$rc = $this->db->delete ("$object$this->separator%"); $rc = $this->db->delete ("$object$this->separator%");
return TRUE; return TRUE;
@@ -283,19 +283,19 @@ class Authorizationdb extends Authorization
public function chown ($object, $ownerid) public function chown ($object, $ownerid)
{ {
if ($this->db === null) if ($this->db === null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Database to authorize is not connected"), 500); "Database to authorize is not connected"), 500);
if (substr ($object, -1) === "/") if (substr ($object, -1) === "/")
$object = substr ($object, 0, -1); $object = substr ($object, 0, -1);
if (substr ($object, 0, 1) !== "/") if (substr ($object, 0, 1) !== "/")
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Object don't start by slash"), 406); "Object don't start by slash"), 406);
$object = preg_replace ("#//+#", "/", $object); $object = preg_replace ("#//+#", "/", $object);
if ($this->authiduser === "") if ($this->authiduser === "")
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Not authenticated"), 401); "Not authenticated"), 401);
if ($this->authiduser !== 0) if ($this->authiduser !== 0)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"The chown is reserved to root user"), 405); "The chown is reserved to root user"), 405);
try try
{ {
@@ -303,14 +303,14 @@ class Authorizationdb extends Authorization
} }
catch (Exception $e) catch (Exception $e)
{ {
throw new Exception ($e->getMessage(), 405); throw new \Exception ($e->getMessage(), 405);
} }
// All the folder structure is accessible. Check if the object already // All the folder structure is accessible. Check if the object already
// exists // exists
$search = $this->db->read (array (array ("object", $object))); $search = $this->db->read (array (array ("object", $object)));
if (count ($search) === 0) if (count ($search) === 0)
throw new Exception (sprintf (dgettext ("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"Object %s doesn't exists"), $object), "Object %s doesn't exists"), $object),
400); 400);
$search = reset ($search); $search = reset ($search);
@@ -326,22 +326,22 @@ class Authorizationdb extends Authorization
public function chgrp ($object, $groupid) public function chgrp ($object, $groupid)
{ {
if ($this->db === null) if ($this->db === null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Database to authorize is not connected"), 500); "Database to authorize is not connected"), 500);
if (substr ($object, -1) === "/") if (substr ($object, -1) === "/")
$object = substr ($object, 0, -1); $object = substr ($object, 0, -1);
if (substr ($object, 0, 1) !== "/") if (substr ($object, 0, 1) !== "/")
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Object don't start by slash"), 406); "Object don't start by slash"), 406);
$object = preg_replace ("#//+#", "/", $object); $object = preg_replace ("#//+#", "/", $object);
if ($this->authiduser === "") if ($this->authiduser === "")
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Not authenticated"), 401); "Not authenticated"), 401);
if ($this->authiduser !== 0 && !in_array ($groupid, $this->authgroups)) if ($this->authiduser !== 0 && !in_array ($groupid, $this->authgroups))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"The user must be in the wanted group"), 405); "The user must be in the wanted group"), 405);
if (!in_array ("WRITE", $this->validate ($object))) if (!in_array ("WRITE", $this->validate ($object)))
throw new Exception (sprintf (dgettext ("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"%s is write protected"), $object), 405); "%s is write protected"), $object), 405);
try try
{ {
@@ -349,14 +349,14 @@ class Authorizationdb extends Authorization
} }
catch (Exception $e) catch (Exception $e)
{ {
throw new Exception ($e->getMessage(), 405); throw new \Exception ($e->getMessage(), 405);
} }
// All the folder structure is accessible. Check if the object already // All the folder structure is accessible. Check if the object already
// exists // exists
$search = $this->db->read (array (array ("object", $object))); $search = $this->db->read (array (array ("object", $object)));
if (count ($search) === 0) if (count ($search) === 0)
throw new Exception (sprintf (dgettext ("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"Object %s doesn't exists"), $object), "Object %s doesn't exists"), $object),
400); 400);
$search = reset ($search); $search = reset ($search);
@@ -372,19 +372,19 @@ class Authorizationdb extends Authorization
public function chmod ($object, $mod) public function chmod ($object, $mod)
{ {
if ($this->db === null) if ($this->db === null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Database to authorize is not connected"), 500); "Database to authorize is not connected"), 500);
if (substr ($object, -1) === "/") if (substr ($object, -1) === "/")
$object = substr ($object, 0, -1); $object = substr ($object, 0, -1);
if (substr ($object, 0, 1) !== "/") if (substr ($object, 0, 1) !== "/")
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Object don't start by slash"), 406); "Object don't start by slash"), 406);
$object = preg_replace ("#//+#", "/", $object); $object = preg_replace ("#//+#", "/", $object);
if ($this->authiduser === "") if ($this->authiduser === "")
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Not authenticated"), 401); "Not authenticated"), 401);
if (!in_array ("WRITE", $this->validate ($object))) if (!in_array ("WRITE", $this->validate ($object)))
throw new Exception (sprintf (dgettext ("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"%s is write protected"), $object), 405); "%s is write protected"), $object), 405);
try try
{ {
@@ -392,14 +392,14 @@ class Authorizationdb extends Authorization
} }
catch (Exception $e) catch (Exception $e)
{ {
throw new Exception ($e->getMessage(), 405); throw new \Exception ($e->getMessage(), 405);
} }
// All the folder structure is accessible. Check if the object already // All the folder structure is accessible. Check if the object already
// exists // exists
$search = $this->db->read (array (array ("object", $object))); $search = $this->db->read (array (array ("object", $object)));
if (count ($search) === 0) if (count ($search) === 0)
throw new Exception (sprintf (dgettext ("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"Object %s doesn't exists"), $object), "Object %s doesn't exists"), $object),
400); 400);
$search = reset ($search); $search = reset ($search);
@@ -415,16 +415,16 @@ class Authorizationdb extends Authorization
public function lsmod ($object) public function lsmod ($object)
{ {
if ($this->db === null) if ($this->db === null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Database to authorize is not connected"), 500); "Database to authorize is not connected"), 500);
if (substr ($object, -1) === "/") if (substr ($object, -1) === "/")
$object = substr ($object, 0, -1); $object = substr ($object, 0, -1);
if (substr ($object, 0, 1) !== "/") if (substr ($object, 0, 1) !== "/")
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Object don't start by slash"), 406); "Object don't start by slash"), 406);
$object = preg_replace ("#//+#", "/", $object); $object = preg_replace ("#//+#", "/", $object);
if ($this->authiduser === "") if ($this->authiduser === "")
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Not authenticated"), 401); "Not authenticated"), 401);
try try
{ {
@@ -432,14 +432,14 @@ class Authorizationdb extends Authorization
} }
catch (Exception $e) catch (Exception $e)
{ {
throw new Exception ($e->getMessage(), 405); throw new \Exception ($e->getMessage(), 405);
} }
// All the folder structure is accessible. Check if the object already // All the folder structure is accessible. Check if the object already
// exists // exists
$search = $this->db->read (array (array ("object", $object))); $search = $this->db->read (array (array ("object", $object)));
if (count ($search) === 0) if (count ($search) === 0)
throw new Exception (sprintf (dgettext ("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"Object %s doesn't exists"), $object), "Object %s doesn't exists"), $object),
400); 400);
$search = reset ($search); $search = reset ($search);
@@ -453,16 +453,16 @@ class Authorizationdb extends Authorization
public function lsown ($object) public function lsown ($object)
{ {
if ($this->db === null) if ($this->db === null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Database to authorize is not connected"), 500); "Database to authorize is not connected"), 500);
if (substr ($object, -1) === "/") if (substr ($object, -1) === "/")
$object = substr ($object, 0, -1); $object = substr ($object, 0, -1);
if (substr ($object, 0, 1) !== "/") if (substr ($object, 0, 1) !== "/")
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Object don't start by slash"), 406); "Object don't start by slash"), 406);
$object = preg_replace ("#//+#", "/", $object); $object = preg_replace ("#//+#", "/", $object);
if ($this->authiduser === "") if ($this->authiduser === "")
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Not authenticated"), 401); "Not authenticated"), 401);
try try
{ {
@@ -470,14 +470,14 @@ class Authorizationdb extends Authorization
} }
catch (Exception $e) catch (Exception $e)
{ {
throw new Exception ($e->getMessage(), 405); throw new \Exception ($e->getMessage(), 405);
} }
// All the folder structure is accessible. Check if the object already // All the folder structure is accessible. Check if the object already
// exists // exists
$search = $this->db->read (array (array ("object", $object))); $search = $this->db->read (array (array ("object", $object)));
if (count ($search) === 0) if (count ($search) === 0)
throw new Exception (sprintf (dgettext ("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"Object %s doesn't exists"), $object), "Object %s doesn't exists"), $object),
400); 400);
$search = reset ($search); $search = reset ($search);
@@ -491,16 +491,16 @@ class Authorizationdb extends Authorization
public function lsgrp ($object) public function lsgrp ($object)
{ {
if ($this->db === null) if ($this->db === null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Database to authorize is not connected"), 500); "Database to authorize is not connected"), 500);
if (substr ($object, -1) === "/") if (substr ($object, -1) === "/")
$object = substr ($object, 0, -1); $object = substr ($object, 0, -1);
if (substr ($object, 0, 1) !== "/") if (substr ($object, 0, 1) !== "/")
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Object don't start by slash"), 406); "Object don't start by slash"), 406);
$object = preg_replace ("#//+#", "/", $object); $object = preg_replace ("#//+#", "/", $object);
if ($this->authiduser === "") if ($this->authiduser === "")
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Not authenticated"), 401); "Not authenticated"), 401);
try try
{ {
@@ -508,14 +508,14 @@ class Authorizationdb extends Authorization
} }
catch (Exception $e) catch (Exception $e)
{ {
throw new Exception ($e->getMessage(), 405); throw new \Exception ($e->getMessage(), 405);
} }
// All the folder structure is accessible. Check if the object already // All the folder structure is accessible. Check if the object already
// exists // exists
$search = $this->db->read (array (array ("object", $object))); $search = $this->db->read (array (array ("object", $object)));
if (count ($search) === 0) if (count ($search) === 0)
throw new Exception (sprintf (dgettext ("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"Object %s doesn't exists"), $object), "Object %s doesn't exists"), $object),
404); 404);
$search = reset ($search); $search = reset ($search);
@@ -531,7 +531,7 @@ class Authorizationdb extends Authorization
private function treecheckExecute ($object) private function treecheckExecute ($object)
{ {
if ($this->db === null) if ($this->db === null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Database to authorize is not connected"), 500); "Database to authorize is not connected"), 500);
// Search all the parents in an array // Search all the parents in an array
$parents = array (); $parents = array ();
@@ -568,7 +568,7 @@ class Authorizationdb extends Authorization
} }
} }
if (!$found) if (!$found)
throw new Exception (sprintf (dgettext ("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"The path %s is not found in database"), "The path %s is not found in database"),
$p), 404); $p), 404);
else else
@@ -593,7 +593,7 @@ class Authorizationdb extends Authorization
if (($parentModbits & 0001) === 1) if (($parentModbits & 0001) === 1)
continue; continue;
throw new Exception (sprintf (dgettext ("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"No execute rights on %s"), $p), 405); "No execute rights on %s"), $p), 405);
} }
} }
@@ -624,7 +624,7 @@ class Authorizationdb extends Authorization
if (($parentModbits & 0002) === 2) if (($parentModbits & 0002) === 2)
return TRUE; return TRUE;
throw new Exception (sprintf (dgettext ("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"No write rights on %s"), $parent), 405); "No write rights on %s"), $parent), 405);
} }
} }
+6 -6
View File
@@ -40,10 +40,10 @@ class Authshibboleth extends Auth
{ {
if ($this->urlAuthentificated !== "") if ($this->urlAuthentificated !== "")
{ {
$route = new route (); $route = new Route ();
$route->redirect ($this->urlAuthentificated); $route->redirect ($this->urlAuthentificated);
} }
throw new Exception ("Unable to authenticate user '$email'", 401); throw new \Exception ("Unable to authenticate user '$email'", 401);
} }
} }
@@ -73,10 +73,10 @@ class Authshibboleth extends Auth
{ {
// Redirect to Shibboleth IDP // Redirect to Shibboleth IDP
if ($this->urlPasswdChange == "") if ($this->urlPasswdChange == "")
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"The password can't be change for Shibboleth users"), "The password can't be change for Shibboleth users"),
405); 405);
$route = new route (); $route = new Route ();
$route->redirect ($this->urlPasswdChange); $route->redirect ($this->urlPasswdChange);
} }
@@ -87,7 +87,7 @@ class Authshibboleth extends Auth
@param string $newpassword The new password to be recorded */ @param string $newpassword The new password to be recorded */
public function overwritepassword ($email, $newpassword) public function overwritepassword ($email, $newpassword)
{ {
throw new exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"The password can't be overwrite for Shibboleth users"), "The password can't be overwrite for Shibboleth users"),
405); 405);
} }
@@ -99,7 +99,7 @@ class Authshibboleth extends Auth
if ($this->urlLogout === "") if ($this->urlLogout === "")
throw new \Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Shibboleth is not configured to allow logout"), 405); "Shibboleth is not configured to allow logout"), 405);
$route = new route (); $route = new Route ();
$route->redirect ($this->urlLogout); $route->redirect ($this->urlLogout);
} }
} }
+19 -19
View File
@@ -44,25 +44,25 @@ class Authsql extends Auth
public function connect () public function connect ()
{ {
if (! function_exists ("openssl_random_pseudo_bytes")) if (! function_exists ("openssl_random_pseudo_bytes"))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No PHP support for openssl_random_pseudo_bytes"), "No PHP support for openssl_random_pseudo_bytes"),
500); 500);
$this->db = new dblayer ($this->dsn, $this->username, $this->password, $this->db = new Dblayer ($this->dsn, $this->username, $this->password,
$this->driver_options); $this->driver_options);
if ($this->table === null) if ($this->table === null)
throw new Exception (dgettext ("domframework", "No SQL table defined"), throw new \Exception (dgettext ("domframework", "No SQL table defined"),
500); 500);
if ($this->fieldIdentifier === null) if ($this->fieldIdentifier === null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No fieldIdentifier defined"), 500); "No fieldIdentifier defined"), 500);
if ($this->fieldPassword === null) if ($this->fieldPassword === null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No fieldPassword defined"), 500); "No fieldPassword defined"), 500);
if ($this->fieldLastname === null) if ($this->fieldLastname === null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No fieldLastname defined"), 500); "No fieldLastname defined"), 500);
if ($this->fieldFirstname === null) if ($this->fieldFirstname === null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No fieldFirstname defined"), 500); "No fieldFirstname defined"), 500);
$fields = array_merge (array ($this->fieldIdentifier, $this->fieldPassword, $fields = array_merge (array ($this->fieldIdentifier, $this->fieldPassword,
$this->fieldLastname, $this->fieldFirstname), $this->fieldLastname, $this->fieldFirstname),
@@ -81,7 +81,7 @@ class Authsql extends Auth
public function authentication ($email, $password) public function authentication ($email, $password)
{ {
if ($this->db === null) if ($this->db === null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"The SQL database is not connected"), 500); "The SQL database is not connected"), 500);
$data = $this->db->read (array (array ($this->fieldIdentifier, $email)), $data = $this->db->read (array (array ($this->fieldIdentifier, $email)),
array_merge (array ($this->fieldIdentifier, array_merge (array ($this->fieldIdentifier,
@@ -90,16 +90,16 @@ class Authsql extends Auth
$this->fieldPassword), $this->fieldPassword),
$this->fieldsInfo)); $this->fieldsInfo));
if (count ($data) === 0) if (count ($data) === 0)
throw new Exception (sprintf (dgettext ("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"Unable to find the user : '%s'"), "Unable to find the user : '%s'"),
$email), 401); $email), 401);
if (! isset ($data[0][$this->fieldPassword])) if (! isset ($data[0][$this->fieldPassword]))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Unable to get the user password from database"), "Unable to get the user password from database"),
500); 500);
$cryptedPassword = $data[0][$this->fieldPassword]; $cryptedPassword = $data[0][$this->fieldPassword];
if (crypt ($password, $cryptedPassword) !== $cryptedPassword) if (crypt ($password, $cryptedPassword) !== $cryptedPassword)
throw new Exception (sprintf (dgettext ("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"Bad password for '%s'"), $email), "Bad password for '%s'"), $email),
401); 401);
// The password should never be stored by this function // The password should never be stored by this function
@@ -124,11 +124,11 @@ class Authsql extends Auth
public function changepassword ($oldpassword, $newpassword) public function changepassword ($oldpassword, $newpassword)
{ {
if ($this->db === null) if ($this->db === null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"The SQL database is not connected"), 500); "The SQL database is not connected"), 500);
if ($this->details === null || if ($this->details === null ||
! isset ($this->details[$this->fieldIdentifier])) ! isset ($this->details[$this->fieldIdentifier]))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Can't change the password if the user is not authenticated"), "Can't change the password if the user is not authenticated"),
500); 500);
$data = $this->db->read (array (array ($this->fieldIdentifier, $data = $this->db->read (array (array ($this->fieldIdentifier,
@@ -137,7 +137,7 @@ class Authsql extends Auth
$this->fieldPassword)); $this->fieldPassword));
$cryptedPassword = $data[0][$this->fieldPassword]; $cryptedPassword = $data[0][$this->fieldPassword];
if (crypt ($oldpassword, $cryptedPassword) !== $cryptedPassword) if (crypt ($oldpassword, $cryptedPassword) !== $cryptedPassword)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Bad old password provided"), 401); "Bad old password provided"), 401);
$cost = 11; $cost = 11;
$salt = substr (base64_encode (openssl_random_pseudo_bytes (17)), 0, 22); $salt = substr (base64_encode (openssl_random_pseudo_bytes (17)), 0, 22);
@@ -152,7 +152,7 @@ class Authsql extends Auth
$rc = $this->db->update ($this->details[$this->fieldIdentifier], $rc = $this->db->update ($this->details[$this->fieldIdentifier],
array ($this->fieldPassword => $cryptpassword)); array ($this->fieldPassword => $cryptpassword));
if ($rc !== 1) if ($rc !== 1)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Can't change the password"), 500); "Can't change the password"), 500);
} }
@@ -164,13 +164,13 @@ class Authsql extends Auth
public function overwritepassword ($email, $newpassword) public function overwritepassword ($email, $newpassword)
{ {
if ($this->db === null) if ($this->db === null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"The SQL database is not connected"), 500); "The SQL database is not connected"), 500);
$data = $this->db->read (array (array ($this->fieldIdentifier, $email)), $data = $this->db->read (array (array ($this->fieldIdentifier, $email)),
array ($this->fieldIdentifier, array ($this->fieldIdentifier,
$this->fieldPassword)); $this->fieldPassword));
if (count ($data) === 0) if (count ($data) === 0)
throw new Exception (sprintf (dgettext ("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"Unable to find the user : '%s'"), "Unable to find the user : '%s'"),
$email), 401); $email), 401);
$cost = 11; $cost = 11;
@@ -186,7 +186,7 @@ class Authsql extends Auth
$rc = $this->db->update ($email, $rc = $this->db->update ($email,
array ($this->fieldPassword => $cryptpassword)); array ($this->fieldPassword => $cryptpassword));
if ($rc !== 1) if ($rc !== 1)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Can't change the password"), 500); "Can't change the password"), 500);
} }
/** List all the users available in the database /** List all the users available in the database
@@ -194,7 +194,7 @@ class Authsql extends Auth
public function listusers () public function listusers ()
{ {
if ($this->db === null) if ($this->db === null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"The SQL database is not connected"), 500); "The SQL database is not connected"), 500);
$data = $this->db->read (null, array_merge (array ($this->fieldIdentifier, $data = $this->db->read (null, array_merge (array ($this->fieldIdentifier,
$this->fieldFirstname, $this->fieldFirstname,
+1 -1
View File
@@ -17,7 +17,7 @@ namespace Domframework;
It use the SOAP protocol. So the PHP SOAP library is needed and the network It use the SOAP protocol. So the PHP SOAP library is needed and the network
must be open between the Web server and the Sympa server. must be open between the Web server and the Sympa server.
POC : POC :
$auth = new authsympa (); $auth = new Authsympa ();
$auth->wsdl = "https://lists.domain.tld/sympa/wsdl"; $auth->wsdl = "https://lists.domain.tld/sympa/wsdl";
$auth->list = "listtest@lists.domain.tld"; $auth->list = "listtest@lists.domain.tld";
$auth->connect (); $auth->connect ();
+98 -98
View File
@@ -42,7 +42,7 @@ class Authzgroups
if ($this->rightCache !== null) if ($this->rightCache !== null)
return $this->rightCache; return $this->rightCache;
if ($this->dbObject == null) if ($this->dbObject == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for Object is not connected"), 500); "DB for Object is not connected"), 500);
// Do the SQL request in hard to be more performant on jointures // Do the SQL request in hard to be more performant on jointures
if ($user === "cli" || $user === "root") if ($user === "cli" || $user === "root")
@@ -74,7 +74,7 @@ class Authzgroups
{ {
if ($this->dbObject->debug) echo "DEBUG : PREPARE ERROR ! Return FALSE". if ($this->dbObject->debug) echo "DEBUG : PREPARE ERROR ! Return FALSE".
$e->getMessage()."\n"; $e->getMessage()."\n";
throw new Exception ($e->getMessage(), 500); throw new \Exception ($e->getMessage(), 500);
} }
if ($user !== "cli" && $user !== "root") if ($user !== "cli" && $user !== "root")
@@ -84,13 +84,13 @@ class Authzgroups
{ {
$rc = $st->execute (); $rc = $st->execute ();
if ($rc === false) if ($rc === false)
throw new Exception ("Can't execute SQL request", 500); throw new \Exception ("Can't execute SQL request", 500);
} }
catch (Exception $e) catch (Exception $e)
{ {
if ($this->dbObject->debug) echo "DEBUG : EXECUTE ERROR ! Return FALSE". if ($this->dbObject->debug) echo "DEBUG : EXECUTE ERROR ! Return FALSE".
$e->getMessage()."\n"; $e->getMessage()."\n";
throw new Exception ($e->getMessage(), 500); throw new \Exception ($e->getMessage(), 500);
} }
$res = array (); $res = array ();
while ($d = $st->fetch (PDO::FETCH_ASSOC)) while ($d = $st->fetch (PDO::FETCH_ASSOC))
@@ -103,7 +103,7 @@ class Authzgroups
case "2": $res[$k] = "RW"; break; case "2": $res[$k] = "RW"; break;
case "1": $res[$k] = "RO"; break; case "1": $res[$k] = "RO"; break;
default: default:
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Unknown right stored"), 500); "Unknown right stored"), 500);
} }
} }
@@ -156,16 +156,16 @@ class Authzgroups
public function accessRight ($module, $user, $object) public function accessRight ($module, $user, $object)
{ {
if ($this->dbObject === null) if ($this->dbObject === null)
throw new Exception ("Can't use authzgroups\\accessRight without ". throw new \Exception ("Can't use authzgroups\\accessRight without ".
"connected database", 500); "connected database", 500);
if ($module === null || ! is_string ($module) || trim ($module) === "") if ($module === null || ! is_string ($module) || trim ($module) === "")
throw new Exception ("Module not provided to authzgroups\\accessRight", throw new \Exception ("Module not provided to authzgroups\\accessRight",
500); 500);
if ($user === null || ! is_string ($user) || trim ($user) === "") if ($user === null || ! is_string ($user) || trim ($user) === "")
throw new Exception ("User not provided to authzgroups\\accessright", throw new \Exception ("User not provided to authzgroups\\accessright",
500); 500);
if ($object === null || ! is_string ($object)) if ($object === null || ! is_string ($object))
throw new Exception ("Object not provided to authzgroups\\accessRight", throw new \Exception ("Object not provided to authzgroups\\accessRight",
500); 500);
if ($object{0} !== "/") if ($object{0} !== "/")
$object = "/$object"; $object = "/$object";
@@ -176,9 +176,9 @@ class Authzgroups
if ($rc !== "NO") if ($rc !== "NO")
return TRUE; return TRUE;
if ($user === "anonymous") if ($user === "anonymous")
throw new Exception (dgettext ("domframework", "Anonymous not allowed"), throw new \Exception (dgettext ("domframework", "Anonymous not allowed"),
401); 401);
throw new Exception (dgettext ("domframework", "Access forbidden"), 403); throw new \Exception (dgettext ("domframework", "Access forbidden"), 403);
} }
/** Return TRUE if the user right allow to edit the object (RW only) /** Return TRUE if the user right allow to edit the object (RW only)
@@ -191,16 +191,16 @@ class Authzgroups
public function accessWrite ($module, $user, $object) public function accessWrite ($module, $user, $object)
{ {
if ($this->dbObject === null) if ($this->dbObject === null)
throw new Exception ("Can't use authzgroups\\accessWrite without ". throw new \Exception ("Can't use authzgroups\\accessWrite without ".
"connected database", 500); "connected database", 500);
if ($module === null || ! is_string ($module) || trim ($module) === "") if ($module === null || ! is_string ($module) || trim ($module) === "")
throw new Exception ("Module not provided to authzgroups\\accessWrite", throw new \Exception ("Module not provided to authzgroups\\accessWrite",
500); 500);
if ($user === null || ! is_string ($user) || trim ($user) === "") if ($user === null || ! is_string ($user) || trim ($user) === "")
throw new Exception ("User not provided to authzgroups\\accessWrite", throw new \Exception ("User not provided to authzgroups\\accessWrite",
500); 500);
if ($object === null || ! is_string ($object)) if ($object === null || ! is_string ($object))
throw new Exception ("Object not provided to authzgroups\\accessWrite", throw new \Exception ("Object not provided to authzgroups\\accessWrite",
500); 500);
if ($object{0} !== "/") if ($object{0} !== "/")
$object = "/$object"; $object = "/$object";
@@ -211,9 +211,9 @@ class Authzgroups
if ($rc === "RW") if ($rc === "RW")
return TRUE; return TRUE;
if ($user === "anonymous") if ($user === "anonymous")
throw new Exception (dgettext ("domframework", "Anonymous not allowed"), throw new \Exception (dgettext ("domframework", "Anonymous not allowed"),
401); 401);
throw new Exception (dgettext ("domframework", "Modification forbidden"), throw new \Exception (dgettext ("domframework", "Modification forbidden"),
403); 403);
} }
@@ -228,16 +228,16 @@ class Authzgroups
public function accessReadOnly ($module, $user, $object) public function accessReadOnly ($module, $user, $object)
{ {
if ($this->dbObject === null) if ($this->dbObject === null)
throw new Exception ("Can't use authzgroups\\accessReadOnly without ". throw new \Exception ("Can't use authzgroups\\accessReadOnly without ".
"connected database", 500); "connected database", 500);
if ($module === null || ! is_string ($module) || trim ($module) === "") if ($module === null || ! is_string ($module) || trim ($module) === "")
throw new Exception ("Module not provided to authzgroups\\accessReadOnly", throw new \Exception ("Module not provided to authzgroups\\accessReadOnly",
500); 500);
if ($user === null || ! is_string ($user) || trim ($user) === "") if ($user === null || ! is_string ($user) || trim ($user) === "")
throw new Exception ("User not provided to authzgroups\\accessReadOnly", throw new \Exception ("User not provided to authzgroups\\accessReadOnly",
500); 500);
if ($object === null || ! is_string ($object)) if ($object === null || ! is_string ($object))
throw new Exception ("Object not provided to authzgroups\\accessReadOnly", throw new \Exception ("Object not provided to authzgroups\\accessReadOnly",
500); 500);
if ($object{0} !== "/") if ($object{0} !== "/")
$object = "/$object"; $object = "/$object";
@@ -248,9 +248,9 @@ class Authzgroups
if ($rc === "RO") if ($rc === "RO")
return TRUE; return TRUE;
if ($user === "anonymous") if ($user === "anonymous")
throw new Exception (dgettext ("domframework", "Anonymous not allowed"), throw new \Exception (dgettext ("domframework", "Anonymous not allowed"),
401); 401);
throw new Exception (dgettext ("domframework", "Access forbidden"), 403); throw new \Exception (dgettext ("domframework", "Access forbidden"), 403);
} }
///////////////////////// /////////////////////////
@@ -267,7 +267,7 @@ class Authzgroups
public function connect ($dsn, $username=null, $password=null, public function connect ($dsn, $username=null, $password=null,
$driver_options=null) $driver_options=null)
{ {
$this->dbObject = new dblayer ($dsn, $username, $password, $driver_options); $this->dbObject = new Dblayer ($dsn, $username, $password, $driver_options);
$this->dbObject->debug = $this->debug; $this->dbObject->debug = $this->debug;
$this->dbObject->table = "authzobject"; $this->dbObject->table = "authzobject";
$this->dbObject->prefix = $this->tableprefix; $this->dbObject->prefix = $this->tableprefix;
@@ -284,7 +284,7 @@ class Authzgroups
"object" => dgettext ("domframework", "Object"), "object" => dgettext ("domframework", "Object"),
"comment" => dgettext ("domframework", "Comment")); "comment" => dgettext ("domframework", "Comment"));
$this->dbGroup = new dblayer ($dsn, $username, $password, $driver_options); $this->dbGroup = new Dblayer ($dsn, $username, $password, $driver_options);
$this->dbGroup->debug = $this->debug; $this->dbGroup->debug = $this->debug;
$this->dbGroup->table = "authzgroup"; $this->dbGroup->table = "authzgroup";
$this->dbGroup->prefix = $this->tableprefix; $this->dbGroup->prefix = $this->tableprefix;
@@ -301,7 +301,7 @@ class Authzgroups
"group" => dgettext ("domframework", "Group"), "group" => dgettext ("domframework", "Group"),
"comment" => dgettext ("domframework", "Comment")); "comment" => dgettext ("domframework", "Comment"));
$this->dbGroupMember = new dblayer ($dsn, $username, $password, $this->dbGroupMember = new Dblayer ($dsn, $username, $password,
$driver_options); $driver_options);
$this->dbGroupMember->debug = $this->debug; $this->dbGroupMember->debug = $this->debug;
$this->dbGroupMember->table = "authzgroupmember"; $this->dbGroupMember->table = "authzgroupmember";
@@ -323,7 +323,7 @@ class Authzgroups
"idgroup"=>dgettext ("domframework", "idgroup"), "idgroup"=>dgettext ("domframework", "idgroup"),
"comment"=>dgettext ("domframework", "Comment")); "comment"=>dgettext ("domframework", "Comment"));
$this->dbRight = new dblayer ($dsn, $username, $password, $driver_options); $this->dbRight = new Dblayer ($dsn, $username, $password, $driver_options);
$this->dbRight->debug = $this->debug; $this->dbRight->debug = $this->debug;
$this->dbRight->table = "authzright"; $this->dbRight->table = "authzright";
$this->dbRight->prefix = $this->tableprefix; $this->dbRight->prefix = $this->tableprefix;
@@ -362,17 +362,17 @@ class Authzgroups
public function createTables () public function createTables ()
{ {
if ($this->dbObject == null) if ($this->dbObject == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for Object is not connected"), 500); "DB for Object is not connected"), 500);
if ($this->dbGroup == null) if ($this->dbGroup == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for Group is not connected"), 500); "DB for Group is not connected"), 500);
if ($this->dbGroupMember == null) if ($this->dbGroupMember == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for GroupMember is not connected"), "DB for GroupMember is not connected"),
500); 500);
if ($this->dbRight == null) if ($this->dbRight == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for Right is not connected"), 500); "DB for Right is not connected"), 500);
$tables = array ("Object", "Group", "GroupMember", "Right"); $tables = array ("Object", "Group", "GroupMember", "Right");
foreach ($tables as $table) foreach ($tables as $table)
@@ -402,7 +402,7 @@ class Authzgroups
public function objectAdd ($module, $object, $comment="") public function objectAdd ($module, $object, $comment="")
{ {
if ($this->dbObject == null) if ($this->dbObject == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for Object is not connected"), 500); "DB for Object is not connected"), 500);
// TODO : Check parameters before saving them // TODO : Check parameters before saving them
$this->rightCache = null; $this->rightCache = null;
@@ -418,11 +418,11 @@ class Authzgroups
public function objectDel ($module, $object) public function objectDel ($module, $object)
{ {
if ($this->dbObject == null) if ($this->dbObject == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for Object is not connected"), 500); "DB for Object is not connected"), 500);
$idobjects = $this->objectRead ($module, $object); $idobjects = $this->objectRead ($module, $object);
if (! isset ($idobjects[0]["idobject"])) if (! isset ($idobjects[0]["idobject"]))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Wanted object not found"), 404); "Wanted object not found"), 404);
$this->rightCache = null; $this->rightCache = null;
return $this->dbObject->delete ($idobjects[0]["idobject"]); return $this->dbObject->delete ($idobjects[0]["idobject"]);
@@ -435,11 +435,11 @@ class Authzgroups
public function objectDelByID ($module, $idobject) public function objectDelByID ($module, $idobject)
{ {
if ($this->dbObject == null) if ($this->dbObject == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for Object is not connected"), 500); "DB for Object is not connected"), 500);
$idobjects = $this->objectReadByID ($module, $idobject); $idobjects = $this->objectReadByID ($module, $idobject);
if (! isset ($idobjects[0]["idobject"])) if (! isset ($idobjects[0]["idobject"]))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Wanted object not found"), 404); "Wanted object not found"), 404);
$this->rightCache = null; $this->rightCache = null;
return $this->dbObject->delete ($idobjects[0]["idobject"]); return $this->dbObject->delete ($idobjects[0]["idobject"]);
@@ -454,11 +454,11 @@ class Authzgroups
public function objectUpdate ($module, $object, $newobject, $newcomment="") public function objectUpdate ($module, $object, $newobject, $newcomment="")
{ {
if ($this->dbObject == null) if ($this->dbObject == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for Object is not connected"), 500); "DB for Object is not connected"), 500);
$idobjects = $this->objectRead ($module, $object); $idobjects = $this->objectRead ($module, $object);
if (! isset ($idobjects[0]["idobject"])) if (! isset ($idobjects[0]["idobject"]))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Wanted object not found"), 404); "Wanted object not found"), 404);
$this->rightCache = null; $this->rightCache = null;
return $this->dbObject->update ($idobjects[0]["idobject"], return $this->dbObject->update ($idobjects[0]["idobject"],
@@ -476,11 +476,11 @@ class Authzgroups
$newcomment="") $newcomment="")
{ {
if ($this->dbObject == null) if ($this->dbObject == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for Object is not connected"), 500); "DB for Object is not connected"), 500);
$idobjects = $this->objectReadByID ($module, $idobject); $idobjects = $this->objectReadByID ($module, $idobject);
if (! isset ($idobjects[0]["idobject"])) if (! isset ($idobjects[0]["idobject"]))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Wanted object not found"), 404); "Wanted object not found"), 404);
$this->rightCache = null; $this->rightCache = null;
return $this->dbObject->update ($idobjects[0]["idobject"], return $this->dbObject->update ($idobjects[0]["idobject"],
@@ -496,7 +496,7 @@ class Authzgroups
public function objectRead ($module, $object=null) public function objectRead ($module, $object=null)
{ {
if ($this->dbObject == null) if ($this->dbObject == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for Object is not connected"), 500); "DB for Object is not connected"), 500);
$select[] = array ("module", $module); $select[] = array ("module", $module);
if ($object !== null) if ($object !== null)
@@ -513,7 +513,7 @@ class Authzgroups
public function objectReadByID ($module, $idobject=null) public function objectReadByID ($module, $idobject=null)
{ {
if ($this->dbObject == null) if ($this->dbObject == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for Object is not connected"), 500); "DB for Object is not connected"), 500);
$select[] = array ("module", $module); $select[] = array ("module", $module);
if ($idobject !== null) if ($idobject !== null)
@@ -551,7 +551,7 @@ class Authzgroups
public function groupAdd ($module, $group, $comment="") public function groupAdd ($module, $group, $comment="")
{ {
if ($this->dbGroup == null) if ($this->dbGroup == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for Group is not connected"), 500); "DB for Group is not connected"), 500);
// TODO : Check parameters before saving them // TODO : Check parameters before saving them
return $this->dbGroup->insert (array ("module"=>$module, return $this->dbGroup->insert (array ("module"=>$module,
@@ -566,11 +566,11 @@ class Authzgroups
public function groupDel ($module, $group) public function groupDel ($module, $group)
{ {
if ($this->dbGroup == null) if ($this->dbGroup == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for Group is not connected"), 500); "DB for Group is not connected"), 500);
$idgroups = $this->groupRead ($module, $group); $idgroups = $this->groupRead ($module, $group);
if (! isset ($idgroups[0]["idgroup"])) if (! isset ($idgroups[0]["idgroup"]))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Wanted group not found"), 404); "Wanted group not found"), 404);
return $this->dbGroup->delete ($idgroups[0]["idgroup"]); return $this->dbGroup->delete ($idgroups[0]["idgroup"]);
} }
@@ -582,11 +582,11 @@ class Authzgroups
public function groupDelByID ($module, $idgroup) public function groupDelByID ($module, $idgroup)
{ {
if ($this->dbGroup == null) if ($this->dbGroup == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for Group is not connected"), 500); "DB for Group is not connected"), 500);
$idgroups = $this->groupReadByID ($module, $idgroup); $idgroups = $this->groupReadByID ($module, $idgroup);
if (! isset ($idgroups[0]["idgroup"])) if (! isset ($idgroups[0]["idgroup"]))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Wanted group not found"), 404); "Wanted group not found"), 404);
return $this->dbGroup->delete ($idgroups[0]["idgroup"]); return $this->dbGroup->delete ($idgroups[0]["idgroup"]);
} }
@@ -600,11 +600,11 @@ class Authzgroups
public function groupUpdate ($module, $group, $newgroup, $comment="") public function groupUpdate ($module, $group, $newgroup, $comment="")
{ {
if ($this->dbGroup == null) if ($this->dbGroup == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for Group is not connected"), 500); "DB for Group is not connected"), 500);
$idgroups = $this->groupRead ($module, $group); $idgroups = $this->groupRead ($module, $group);
if (! isset ($idgroups[0]["idgroup"])) if (! isset ($idgroups[0]["idgroup"]))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Wanted group not found"), 404); "Wanted group not found"), 404);
return $this->dbGroup->update ($idgroups[0]["idgroup"], return $this->dbGroup->update ($idgroups[0]["idgroup"],
array ("group"=>$newgroup, array ("group"=>$newgroup,
@@ -620,11 +620,11 @@ class Authzgroups
public function groupUpdateByID ($module, $idgroup, $newgroup, $comment="") public function groupUpdateByID ($module, $idgroup, $newgroup, $comment="")
{ {
if ($this->dbGroup == null) if ($this->dbGroup == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for Group is not connected"), 500); "DB for Group is not connected"), 500);
$idgroups = $this->groupReadByID ($module, $idgroup); $idgroups = $this->groupReadByID ($module, $idgroup);
if (! isset ($idgroups[0]["idgroup"])) if (! isset ($idgroups[0]["idgroup"]))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Wanted group not found"), 404); "Wanted group not found"), 404);
return $this->dbGroup->update ($idgroups[0]["idgroup"], return $this->dbGroup->update ($idgroups[0]["idgroup"],
array ("group"=>$newgroup, array ("group"=>$newgroup,
@@ -638,7 +638,7 @@ class Authzgroups
public function groupRead ($module, $group=null) public function groupRead ($module, $group=null)
{ {
if ($this->dbGroup == null) if ($this->dbGroup == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for Group is not connected"), 500); "DB for Group is not connected"), 500);
$select[] = array ("module", $module); $select[] = array ("module", $module);
if ($group !== null) if ($group !== null)
@@ -654,7 +654,7 @@ class Authzgroups
public function groupReadByID ($module, $idgroup) public function groupReadByID ($module, $idgroup)
{ {
if ($this->dbGroup == null) if ($this->dbGroup == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for Group is not connected"), 500); "DB for Group is not connected"), 500);
$select[] = array ("module", $module); $select[] = array ("module", $module);
$select[] = array ("idgroup", $idgroup); $select[] = array ("idgroup", $idgroup);
@@ -692,12 +692,12 @@ class Authzgroups
public function groupmemberAdd ($module, $group, $user, $comment="") public function groupmemberAdd ($module, $group, $user, $comment="")
{ {
if ($this->dbGroupMember == null) if ($this->dbGroupMember == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for GroupMember is not connected"), "DB for GroupMember is not connected"),
500); 500);
$groups = $this->groupRead ($module, $group); $groups = $this->groupRead ($module, $group);
if (! isset ($groups[0]["idgroup"])) if (! isset ($groups[0]["idgroup"]))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Wanted group not found"), 404); "Wanted group not found"), 404);
$this->rightCache = null; $this->rightCache = null;
return $this->dbGroupMember->insert (array ( return $this->dbGroupMember->insert (array (
@@ -714,18 +714,18 @@ class Authzgroups
public function groupmemberDel ($module, $group, $user) public function groupmemberDel ($module, $group, $user)
{ {
if ($this->dbGroupMember == null) if ($this->dbGroupMember == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for GroupMember is not connected"), "DB for GroupMember is not connected"),
500); 500);
$groups = $this->groupRead ($module, $group); $groups = $this->groupRead ($module, $group);
if (! isset ($groups[0]["idgroup"])) if (! isset ($groups[0]["idgroup"]))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Wanted group not found"), 404); "Wanted group not found"), 404);
$groupsMembers = $this->dbGroupMember->read (array ( $groupsMembers = $this->dbGroupMember->read (array (
array ("user", $user), array ("user", $user),
array ("idgroup", $groups[0]["idgroup"]))); array ("idgroup", $groups[0]["idgroup"])));
if (! isset ($groupsMembers[0]["idgroupmember"])) if (! isset ($groupsMembers[0]["idgroupmember"]))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Wanted GroupMember not found"), 404); "Wanted GroupMember not found"), 404);
$this->rightCache = null; $this->rightCache = null;
return $this->dbGroupMember->delete ($groupsMembers[0]["idgroupmember"]); return $this->dbGroupMember->delete ($groupsMembers[0]["idgroupmember"]);
@@ -739,17 +739,17 @@ class Authzgroups
public function groupmemberDelByID ($module, $idgroup, $idgroupmember) public function groupmemberDelByID ($module, $idgroup, $idgroupmember)
{ {
if ($this->dbGroupMember == null) if ($this->dbGroupMember == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for GroupMember is not connected"), 500); "DB for GroupMember is not connected"), 500);
$groups = $this->groupReadByID ($module, $idgroup); $groups = $this->groupReadByID ($module, $idgroup);
if (! isset ($groups[0]["idgroup"])) if (! isset ($groups[0]["idgroup"]))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Wanted group not found"), 404); "Wanted group not found"), 404);
$groupsMembers = $this->dbGroupMember->read (array ( $groupsMembers = $this->dbGroupMember->read (array (
array ("idgroupmember", $idgroupmember), array ("idgroupmember", $idgroupmember),
array ("idgroup", $idgroup))); array ("idgroup", $idgroup)));
if (! isset ($groupsMembers[0]["idgroupmember"])) if (! isset ($groupsMembers[0]["idgroupmember"]))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Wanted GroupMember not found"), 404); "Wanted GroupMember not found"), 404);
$this->rightCache = null; $this->rightCache = null;
return $this->dbGroupMember->delete ($groupsMembers[0]["idgroupmember"]); return $this->dbGroupMember->delete ($groupsMembers[0]["idgroupmember"]);
@@ -779,7 +779,7 @@ class Authzgroups
{ {
$data = $this->groupmemberReadUserDataByID ($module, $idgroup, $iduser); $data = $this->groupmemberReadUserDataByID ($module, $idgroup, $iduser);
if (count ($data) === 0) if (count ($data) === 0)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"IDUser in IDGroup not found"), 404); "IDUser in IDGroup not found"), 404);
$this->rightCache = null; $this->rightCache = null;
return $this->dbGroupMember->update ($iduser, return $this->dbGroupMember->update ($iduser,
@@ -795,7 +795,7 @@ class Authzgroups
public function groupmemberReadUser ($module, $user) public function groupmemberReadUser ($module, $user)
{ {
if ($this->dbGroupMember == null) if ($this->dbGroupMember == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for GroupMember is not connected"), "DB for GroupMember is not connected"),
500); 500);
$idgrouptmps = $this->groupRead ($module); $idgrouptmps = $this->groupRead ($module);
@@ -821,7 +821,7 @@ class Authzgroups
public function groupmemberReadUserByID ($module, $idgroupmember) public function groupmemberReadUserByID ($module, $idgroupmember)
{ {
if ($this->dbGroupMember == null) if ($this->dbGroupMember == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for GroupMember is not connected"), "DB for GroupMember is not connected"),
500); 500);
$idgrouptmps = $this->groupRead ($module); $idgrouptmps = $this->groupRead ($module);
@@ -848,12 +848,12 @@ class Authzgroups
public function groupmemberReadGroup ($module, $group) public function groupmemberReadGroup ($module, $group)
{ {
if ($this->dbGroupMember == null) if ($this->dbGroupMember == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for GroupMember is not connected"), "DB for GroupMember is not connected"),
500); 500);
$groups = $this->groupRead ($module, $group); $groups = $this->groupRead ($module, $group);
if (! isset ($groups[0]["idgroup"])) if (! isset ($groups[0]["idgroup"]))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Wanted group not found"), 404); "Wanted group not found"), 404);
$select[] = array ("idgroup", $groups[0]["idgroup"]); $select[] = array ("idgroup", $groups[0]["idgroup"]);
return $this->dbGroupMember->read ($select, array ("user")); return $this->dbGroupMember->read ($select, array ("user"));
@@ -867,12 +867,12 @@ class Authzgroups
public function groupmemberReadGroupByID ($module, $idgroup) public function groupmemberReadGroupByID ($module, $idgroup)
{ {
if ($this->dbGroupMember == null) if ($this->dbGroupMember == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for GroupMember is not connected"), "DB for GroupMember is not connected"),
500); 500);
$groups = $this->groupReadByID ($module, $idgroup); $groups = $this->groupReadByID ($module, $idgroup);
if (! isset ($groups[0]["idgroup"])) if (! isset ($groups[0]["idgroup"]))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Wanted group not found"), 404); "Wanted group not found"), 404);
$select[] = array ("idgroup", $groups[0]["idgroup"]); $select[] = array ("idgroup", $groups[0]["idgroup"]);
return $this->dbGroupMember->read ($select); return $this->dbGroupMember->read ($select);
@@ -886,12 +886,12 @@ class Authzgroups
public function groupmemberReadUserDataByID ($module, $idgroup, $iduser) public function groupmemberReadUserDataByID ($module, $idgroup, $iduser)
{ {
if ($this->dbGroupMember == null) if ($this->dbGroupMember == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for GroupMember is not connected"), "DB for GroupMember is not connected"),
500); 500);
$groups = $this->groupReadByID ($module, $idgroup); $groups = $this->groupReadByID ($module, $idgroup);
if (! isset ($groups[0]["idgroup"])) if (! isset ($groups[0]["idgroup"]))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Wanted group not found"), 404); "Wanted group not found"), 404);
$select[] = array ("idgroup", $groups[0]["idgroup"]); $select[] = array ("idgroup", $groups[0]["idgroup"]);
$select[] = array ("idgroupmember", $iduser); $select[] = array ("idgroupmember", $iduser);
@@ -930,24 +930,24 @@ class Authzgroups
public function rightAdd ($module, $group, $object, $right, $comment="") public function rightAdd ($module, $group, $object, $right, $comment="")
{ {
if ($this->dbRight == null) if ($this->dbRight == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for Right is not connected"), 500); "DB for Right is not connected"), 500);
switch ($right) switch ($right)
{ {
case "RW": $right=2;break; case "RW": $right=2;break;
case "RO": $right=1;break; case "RO": $right=1;break;
default: default:
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Unknown right provided (RO/RW only)"), "Unknown right provided (RO/RW only)"),
500); 500);
} }
$groups = $this->groupRead ($module, $group); $groups = $this->groupRead ($module, $group);
if (! isset ($groups[0]["idgroup"])) if (! isset ($groups[0]["idgroup"]))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Wanted group not found"), 404); "Wanted group not found"), 404);
$objects = $this->objectRead ($module, $object); $objects = $this->objectRead ($module, $object);
if (! isset ($objects[0]["idobject"])) if (! isset ($objects[0]["idobject"]))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Wanted object not found"), 404); "Wanted object not found"), 404);
$this->rightCache = null; $this->rightCache = null;
return $this->dbRight->insert (array ("idgroup"=>$groups[0]["idgroup"], return $this->dbRight->insert (array ("idgroup"=>$groups[0]["idgroup"],
@@ -968,24 +968,24 @@ class Authzgroups
$comment="") $comment="")
{ {
if ($this->dbRight == null) if ($this->dbRight == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for Right is not connected"), 500); "DB for Right is not connected"), 500);
switch ($idright) switch ($idright)
{ {
case "2": $right=2;break; case "2": $right=2;break;
case "1": $right=1;break; case "1": $right=1;break;
default: default:
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Unknown right provided (RO/RW only)"), "Unknown right provided (RO/RW only)"),
500); 500);
} }
$groups = $this->groupReadByID ($module, $idgroup); $groups = $this->groupReadByID ($module, $idgroup);
if (! isset ($groups[0]["idgroup"])) if (! isset ($groups[0]["idgroup"]))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Wanted group not found"), 404); "Wanted group not found"), 404);
$objects = $this->objectReadByID ($module, $idobject); $objects = $this->objectReadByID ($module, $idobject);
if (! isset ($objects[0]["idobject"])) if (! isset ($objects[0]["idobject"]))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Wanted object not found"), 404); "Wanted object not found"), 404);
$this->rightCache = null; $this->rightCache = null;
return $this->dbRight->insert (array ("idgroup"=>$groups[0]["idgroup"], return $this->dbRight->insert (array ("idgroup"=>$groups[0]["idgroup"],
@@ -1002,11 +1002,11 @@ class Authzgroups
public function rightDel ($module, $group, $object) public function rightDel ($module, $group, $object)
{ {
if ($this->dbRight == null) if ($this->dbRight == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for Right is not connected"), 500); "DB for Right is not connected"), 500);
$idrights = $this->rightRead ($module, $group, $object); $idrights = $this->rightRead ($module, $group, $object);
if (!isset ($idrights[0]["idright"])) if (!isset ($idrights[0]["idright"]))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Wanted right not found"), 404); "Wanted right not found"), 404);
$this->rightCache = null; $this->rightCache = null;
return $this->dbRight->delete ($idrights[0]["idright"]); return $this->dbRight->delete ($idrights[0]["idright"]);
@@ -1019,11 +1019,11 @@ class Authzgroups
public function rightDelByID ($module, $idright) public function rightDelByID ($module, $idright)
{ {
if ($this->dbRight == null) if ($this->dbRight == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for Right is not connected"), 500); "DB for Right is not connected"), 500);
$idrights = $this->rightReadByID ($module, $idright); $idrights = $this->rightReadByID ($module, $idright);
if (!isset ($idrights[0]["idright"])) if (!isset ($idrights[0]["idright"]))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Wanted right not found"), 404); "Wanted right not found"), 404);
$this->rightCache = null; $this->rightCache = null;
return $this->dbRight->delete ($idrights[0]["idright"]); return $this->dbRight->delete ($idrights[0]["idright"]);
@@ -1040,20 +1040,20 @@ class Authzgroups
$newcomment="") $newcomment="")
{ {
if ($this->dbRight == null) if ($this->dbRight == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for Right is not connected"), 500); "DB for Right is not connected"), 500);
switch ($newright) switch ($newright)
{ {
case "RW": $newright=2;break; case "RW": $newright=2;break;
case "RO": $newright=1;break; case "RO": $newright=1;break;
default: default:
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Unknown right provided (RO/RW only)"), "Unknown right provided (RO/RW only)"),
500); 500);
} }
$idrights = $this->rightRead ($module, $group, $object); $idrights = $this->rightRead ($module, $group, $object);
if (!isset ($idrights[0]["idright"])) if (!isset ($idrights[0]["idright"]))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Wanted right not found"), 404); "Wanted right not found"), 404);
$this->rightCache = null; $this->rightCache = null;
return $this->dbRight->update ($idrights[0]["idright"], return $this->dbRight->update ($idrights[0]["idright"],
@@ -1072,20 +1072,20 @@ class Authzgroups
$newcomment="") $newcomment="")
{ {
if ($this->dbRight == null) if ($this->dbRight == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for Right is not connected"), 500); "DB for Right is not connected"), 500);
switch ($newright) switch ($newright)
{ {
case "2": $newright=2;break; case "2": $newright=2;break;
case "1": $newright=1;break; case "1": $newright=1;break;
default: default:
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Unknown right provided (RO/RW only)"), "Unknown right provided (RO/RW only)"),
500); 500);
} }
$idrights = $this->rightReadByID ($module, $idright); $idrights = $this->rightReadByID ($module, $idright);
if (!isset ($idrights[0]["idright"])) if (!isset ($idrights[0]["idright"]))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Wanted right not found"), 404); "Wanted right not found"), 404);
$this->rightCache = null; $this->rightCache = null;
return $this->dbRight->update ($idrights[0]["idright"], return $this->dbRight->update ($idrights[0]["idright"],
@@ -1104,15 +1104,15 @@ class Authzgroups
public function rightRead ($module, $group, $object) public function rightRead ($module, $group, $object)
{ {
if ($this->dbRight == null) if ($this->dbRight == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for Right is not connected"), 500); "DB for Right is not connected"), 500);
$groups = $this->groupRead ($module, $group); $groups = $this->groupRead ($module, $group);
if (! isset ($groups[0]["idgroup"])) if (! isset ($groups[0]["idgroup"]))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Wanted group not found"), 404); "Wanted group not found"), 404);
$objects = $this->objectRead ($module, $object); $objects = $this->objectRead ($module, $object);
if (! isset ($objects[0]["idobject"])) if (! isset ($objects[0]["idobject"]))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Wanted object not found"), 404); "Wanted object not found"), 404);
$select[] = array ("idgroup", $groups[0]["idgroup"]); $select[] = array ("idgroup", $groups[0]["idgroup"]);
$select[] = array ("idobject", $objects[0]["idobject"]); $select[] = array ("idobject", $objects[0]["idobject"]);
@@ -1126,11 +1126,11 @@ class Authzgroups
public function rightReadByGroup ($module, $group) public function rightReadByGroup ($module, $group)
{ {
if ($this->dbRight == null) if ($this->dbRight == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for Right is not connected"), 500); "DB for Right is not connected"), 500);
$groups = $this->groupRead ($module, $group); $groups = $this->groupRead ($module, $group);
if (! isset ($groups[0]["idgroup"])) if (! isset ($groups[0]["idgroup"]))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Wanted group not found"), 404); "Wanted group not found"), 404);
return $this->rightReadByGroupByID ($module, $objects[0]["idgroup"]); return $this->rightReadByGroupByID ($module, $objects[0]["idgroup"]);
} }
@@ -1142,7 +1142,7 @@ class Authzgroups
public function rightReadByGroupByID ($module, $idgroup) public function rightReadByGroupByID ($module, $idgroup)
{ {
if ($this->dbRight == null) if ($this->dbRight == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for Right is not connected"), 500); "DB for Right is not connected"), 500);
$select[] = array ("idgroup", $idgroup); $select[] = array ("idgroup", $idgroup);
return $this->dbRight->read ($select); return $this->dbRight->read ($select);
@@ -1156,7 +1156,7 @@ class Authzgroups
public function rightReadByID ($module, $idright) public function rightReadByID ($module, $idright)
{ {
if ($this->dbRight == null) if ($this->dbRight == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for Right is not connected"), 500); "DB for Right is not connected"), 500);
$select[] = array ("idright", $idright); $select[] = array ("idright", $idright);
return $this->dbRight->read ($select); return $this->dbRight->read ($select);
@@ -1169,11 +1169,11 @@ class Authzgroups
public function rightReadByObject ($module, $object) public function rightReadByObject ($module, $object)
{ {
if ($this->dbRight == null) if ($this->dbRight == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for Right is not connected"), 500); "DB for Right is not connected"), 500);
$objects = $this->objectRead ($module, $object); $objects = $this->objectRead ($module, $object);
if (! isset ($objects[0]["idobject"])) if (! isset ($objects[0]["idobject"]))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Wanted object not found"), 404); "Wanted object not found"), 404);
$select[] = array ("idobject", $objects[0]["idobject"]); $select[] = array ("idobject", $objects[0]["idobject"]);
return $this->dbRight->read ($select); return $this->dbRight->read ($select);
@@ -1186,7 +1186,7 @@ class Authzgroups
public function rightReadByObjectByID ($module, $idobject) public function rightReadByObjectByID ($module, $idobject)
{ {
if ($this->dbRight == null) if ($this->dbRight == null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"DB for Right is not connected"), 500); "DB for Right is not connected"), 500);
// FIXME : Do not use $module ? // FIXME : Do not use $module ?
$select[] = array ("idobject", $idobject); $select[] = array ("idobject", $idobject);
+5 -5
View File
@@ -9,7 +9,7 @@ namespace Domframework;
/** All the needed functions to authorize or deny access to an authenticated /** All the needed functions to authorize or deny access to an authenticated
* user by its groups membership * user by its groups membership
* Based on dblayeroo * Based on Dblayeroo
*/ */
class Authzgroupsoo class Authzgroupsoo
{ {
@@ -288,7 +288,7 @@ class Authzgroupsoo
public function connect ($dsn, $username=null, $password=null, public function connect ($dsn, $username=null, $password=null,
$driver_options=null) $driver_options=null)
{ {
$this->dbObject = new dblayeroo ($dsn, $username, $password, $this->dbObject = new Dblayeroo ($dsn, $username, $password,
$driver_options); $driver_options);
$this->dbObject->debug ($this->debug); $this->dbObject->debug ($this->debug);
$this->dbObject->table ("authzobject"); $this->dbObject->table ("authzobject");
@@ -306,7 +306,7 @@ class Authzgroupsoo
"object" => dgettext ("domframework", "Object"), "object" => dgettext ("domframework", "Object"),
"comment" => dgettext ("domframework", "Comment"))); "comment" => dgettext ("domframework", "Comment")));
$this->dbGroup = new dblayeroo ($dsn, $username, $password, $this->dbGroup = new Dblayeroo ($dsn, $username, $password,
$driver_options); $driver_options);
$this->dbGroup->debug ($this->debug); $this->dbGroup->debug ($this->debug);
$this->dbGroup->table ("authzgroup"); $this->dbGroup->table ("authzgroup");
@@ -324,7 +324,7 @@ class Authzgroupsoo
"group" => dgettext ("domframework", "Group"), "group" => dgettext ("domframework", "Group"),
"comment" => dgettext ("domframework", "Comment"))); "comment" => dgettext ("domframework", "Comment")));
$this->dbGroupMember = new dblayeroo ($dsn, $username, $password, $this->dbGroupMember = new Dblayeroo ($dsn, $username, $password,
$driver_options); $driver_options);
$this->dbGroupMember->debug ($this->debug); $this->dbGroupMember->debug ($this->debug);
$this->dbGroupMember->table ("authzgroupmember"); $this->dbGroupMember->table ("authzgroupmember");
@@ -347,7 +347,7 @@ class Authzgroupsoo
"idgroup" => dgettext ("domframework", "idgroup"), "idgroup" => dgettext ("domframework", "idgroup"),
"comment" => dgettext ("domframework", "Comment"))); "comment" => dgettext ("domframework", "Comment")));
$this->dbRight = new dblayeroo ($dsn, $username, $password, $this->dbRight = new Dblayeroo ($dsn, $username, $password,
$driver_options); $driver_options);
$this->dbRight->debug ($this->debug); $this->dbRight->debug ($this->debug);
$this->dbRight->table ("authzright"); $this->dbRight->table ("authzright");
+3 -3
View File
@@ -11,7 +11,7 @@ namespace Domframework;
* available, use it. * available, use it.
* It resend the headers as the ouptut send them * It resend the headers as the ouptut send them
* Use it by : * Use it by :
* $c = new cacheoutput ("URL"); * $c = new Cacheoutput ("URL");
* Don't forget to define a variable or the cache saved is always empty * Don't forget to define a variable or the cache saved is always empty
*/ */
class Cacheoutput class Cacheoutput
@@ -36,13 +36,13 @@ class Cacheoutput
{ {
$res = @include ("domframework/cache$method.php"); $res = @include ("domframework/cache$method.php");
if ($res === false) if ($res === false)
throw new Exception (sprintf (dgettext ("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"Unkwnown cache method : "), $method), "Unkwnown cache method : "), $method),
500); 500);
$this->id = $id; $this->id = $id;
$this->ttl = $ttl; $this->ttl = $ttl;
$this->cacheCWD = getcwd(); $this->cacheCWD = getcwd();
$cachemethod = "cache$method"; $cachemethod = "Cache$method";
$this->cache = new $cachemethod (); $this->cache = new $cachemethod ();
if ($ttl === 0) if ($ttl === 0)
$this->cache->nocache = 1; $this->cache->nocache = 1;
+10 -11
View File
@@ -12,10 +12,9 @@ class Cli
{ {
/** Run in CLI mode with parameters /** Run in CLI mode with parameters
* Example of cli code : * Example of cli code :
* #!/usr/bin/php5 * #!/usr/bin/php
* <?php * <?php
* require ("domframework/cli.php"); * $cli = new Cli;
* $cli = new cli;
* $cli->run(); * $cli->run();
*/ */
/** The expert mode allow to see/execute the models */ /** The expert mode allow to see/execute the models */
@@ -98,7 +97,7 @@ class Cli
":$errline]\n"); ":$errline]\n");
if ($this->EXPERT) if ($this->EXPERT)
{ {
$e = new Exception; $e = new \Exception;
file_put_contents ("php://stderr", file_put_contents ("php://stderr",
print_r ($e->getTraceAsString(), TRUE)."\n"); print_r ($e->getTraceAsString(), TRUE)."\n");
} }
@@ -238,13 +237,13 @@ class Cli
$class = $shortClasses[$class]; $class = $shortClasses[$class];
$file = $classes[$class]; $file = $classes[$class];
require_once ($file); require_once ($file);
$refclass = new ReflectionClass ($class); $refclass = new \ReflectionClass ($class);
// Look at constructor parameters // Look at constructor parameters
// PARAMETERS MUST NOT BE OPTIONNAL // PARAMETERS MUST NOT BE OPTIONNAL
$constParams = ""; $constParams = "";
try try
{ {
$r = new ReflectionMethod ($class, "__construct"); $r = new \ReflectionMethod ($class, "__construct");
$params = $r->getParameters(); $params = $r->getParameters();
foreach ($params as $param) foreach ($params as $param)
{ {
@@ -277,7 +276,7 @@ class Cli
echo $method->name.$constParams; echo $method->name.$constParams;
if ($argv[0] !== "-listmethodsonly") if ($argv[0] !== "-listmethodsonly")
{ {
$r = new ReflectionMethod ($class, $method->name); $r = new \ReflectionMethod ($class, $method->name);
$params = $r->getParameters(); $params = $r->getParameters();
foreach ($params as $param) foreach ($params as $param)
{ {
@@ -325,7 +324,7 @@ class Cli
die ("No method for class '$class' to execute\n"); die ("No method for class '$class' to execute\n");
$method = $argv[0]; $method = $argv[0];
array_shift ($argv); array_shift ($argv);
$refclass = new ReflectionClass ($class); $refclass = new \ReflectionClass ($class);
$methods = $refclass->getMethods(); $methods = $refclass->getMethods();
$found = FALSE; $found = FALSE;
foreach ($methods as $meth) foreach ($methods as $meth)
@@ -343,7 +342,7 @@ class Cli
$paramsConst = array (); $paramsConst = array ();
try try
{ {
$r1 = new ReflectionMethod ($class, "__construct"); $r1 = new \ReflectionMethod ($class, "__construct");
$paramsConst = $r1->getParameters(); $paramsConst = $r1->getParameters();
$min = $max = count ($paramsConst); $min = $max = count ($paramsConst);
} }
@@ -352,7 +351,7 @@ class Cli
// No constructor available in class // No constructor available in class
} }
$r2 = new ReflectionMethod ($class, $method); $r2 = new \ReflectionMethod ($class, $method);
$params = $r2->getParameters(); $params = $r2->getParameters();
foreach ($params as $param) foreach ($params as $param)
{ {
@@ -425,7 +424,7 @@ class Cli
try try
{ {
$classReflection = new ReflectionClass($class); $classReflection = new \ReflectionClass($class);
$r = $classReflection->newInstanceArgs($paramConst); $r = $classReflection->newInstanceArgs($paramConst);
$s = call_user_func_array(array($r, $method), $argv); $s = call_user_func_array(array($r, $method), $argv);
if ($this->QUIET === false || $s !== "" && $s !== array () && $s !== null) if ($this->QUIET === false || $s !== "" && $s !== array () && $s !== null)
+3 -3
View File
@@ -244,7 +244,7 @@ class Color
*/ */
public static function colorList () public static function colorList ()
{ {
$color = new \color (); $color = new color ();
$colorList = $color->colorList; $colorList = $color->colorList;
return array_keys ($colorList); return array_keys ($colorList);
} }
@@ -254,7 +254,7 @@ class Color
*/ */
public static function textToRGB ($colorInText) public static function textToRGB ($colorInText)
{ {
$color = new \color (); $color = new color ();
$colorList = $color->colorList; $colorList = $color->colorList;
if (! array_key_exists ($colorInText, $colorList)) if (! array_key_exists ($colorInText, $colorList))
throw new \Exception (sprintf (dgettext ("domframework", throw new \Exception (sprintf (dgettext ("domframework",
@@ -273,7 +273,7 @@ class Color
throw new \Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No GD support in PHP : can't allocate color"), "No GD support in PHP : can't allocate color"),
500); 500);
$rgb = \color::textToRGB ($colorInText); $rgb = color::textToRGB ($colorInText);
return imagecolorallocate ($gd, $rgb[0], $rgb[1], $rgb[2]); return imagecolorallocate ($gd, $rgb[0], $rgb[1], $rgb[2]);
} }
} }
+16 -16
View File
@@ -19,7 +19,7 @@ namespace Domframework;
* @default : the default value (can be an array or a string or a number) * @default : the default value (can be an array or a string or a number)
* @group : Group all the parameters in a group * @group : Group all the parameters in a group
* POC : * POC :
* $config = new config(); * $config = new Config();
* $config->default = array ("param"=>"default", * $config->default = array ("param"=>"default",
* "param2"=>array (1,2,3), * "param2"=>array (1,2,3),
* "param3"=>null); * "param3"=>null);
@@ -64,7 +64,7 @@ class Config
$conf = array (); $conf = array ();
$rc = include ($this->confFile); $rc = include ($this->confFile);
if ($rc !== 1) if ($rc !== 1)
throw new Exception ("Error in configuration file", 500); throw new \Exception ("Error in configuration file", 500);
return $conf; return $conf;
} }
@@ -104,26 +104,26 @@ class Config
{ {
$this->selectConfFile (); $this->selectConfFile ();
if (!array_key_exists ($param, $this->default)) if (!array_key_exists ($param, $this->default))
throw new Exception ("Unknown configuration parameter '$param'", 500); throw new \Exception ("Unknown configuration parameter '$param'", 500);
if (!file_exists ($this->confFile)) if (!file_exists ($this->confFile))
{ {
if (@file_put_contents ($this->confFile, if (@file_put_contents ($this->confFile,
"<?php\r\n\$conf = array ();\r\n") "<?php\r\n\$conf = array ();\r\n")
=== FALSE) === FALSE)
throw new Exception (sprintf (dgettext ("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"No configuration file '%s' available and it can't be created"), "No configuration file '%s' available and it can't be created"),
$this->confFile), 500); $this->confFile), 500);
} }
elseif (! is_readable ($this->confFile)) elseif (! is_readable ($this->confFile))
throw new Exception (sprintf ( dgettext ("domframework", throw new \Exception (sprintf ( dgettext ("domframework",
"The configuration file '%s' is not readable"), "The configuration file '%s' is not readable"),
$this->confFile)); $this->confFile));
$conf = array (); $conf = array ();
$rc = include ($this->confFile); $rc = include ($this->confFile);
if ($rc !== 1) if ($rc !== 1)
throw new Exception ("Error in configuration file", 500); throw new \Exception ("Error in configuration file", 500);
if (! array_key_exists ($param, $this->default)) if (! array_key_exists ($param, $this->default))
throw new Exception (sprintf ("Configuration parameter '%s' not defined", throw new \Exception (sprintf ("Configuration parameter '%s' not defined",
$param), 500); $param), 500);
// Create a conf where all the keys are defined. If the keys are already // Create a conf where all the keys are defined. If the keys are already
// define, use them, or use the default ones // define, use them, or use the default ones
@@ -168,29 +168,29 @@ class Config
{ {
$this->selectConfFile (); $this->selectConfFile ();
if (!array_key_exists ($param, $this->default)) if (!array_key_exists ($param, $this->default))
throw new Exception ("Unknown parameter '$param'", 500); throw new \Exception ("Unknown parameter '$param'", 500);
if (!file_exists ($this->confFile)) if (!file_exists ($this->confFile))
{ {
if (@file_put_contents ($this->confFile, if (@file_put_contents ($this->confFile,
"<?php\r\n\$conf =array ();\r\n") "<?php\r\n\$conf =array ();\r\n")
=== FALSE) === FALSE)
throw new Exception (sprintf ( throw new \Exception (sprintf (
"No configuration file '%s' available and it can't be created", "No configuration file '%s' available and it can't be created",
$this->confFile)); $this->confFile));
} }
elseif (! is_readable ($this->confFile)) elseif (! is_readable ($this->confFile))
throw new Exception (sprintf ( throw new \Exception (sprintf (
dgettext ("domframework", dgettext ("domframework",
"The configuration file '%s' is not readable"), "The configuration file '%s' is not readable"),
$this->confFile), 500); $this->confFile), 500);
if (!is_writeable ($this->confFile)) if (!is_writeable ($this->confFile))
throw new Exception (sprintf (dgettext ("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"Configuration file '%s' is write protected"), "Configuration file '%s' is write protected"),
$this->confFile), 500); $this->confFile), 500);
$conf = array (); $conf = array ();
$rc = include ($this->confFile); $rc = include ($this->confFile);
if ($rc !== 1) if ($rc !== 1)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Error in configuration file"), 500); "Error in configuration file"), 500);
$newconf = array_merge ($this->default, $conf, array ($param=>$value)); $newconf = array_merge ($this->default, $conf, array ($param=>$value));
$txt = "<?php\r\n"; $txt = "<?php\r\n";
@@ -199,7 +199,7 @@ class Config
$txt .= ");\r\n"; $txt .= ");\r\n";
if (@file_put_contents ($this->confFile, $txt, LOCK_EX) === FALSE) if (@file_put_contents ($this->confFile, $txt, LOCK_EX) === FALSE)
throw new Exception (sprintf (dgettext ("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"Can't save configuration file '%s'"), "Can't save configuration file '%s'"),
$this->confFile), 500); $this->confFile), 500);
return TRUE; return TRUE;
@@ -236,7 +236,7 @@ class Config
$phpcode .= "),\r\n"; $phpcode .= "),\r\n";
} }
else else
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Config : missing type ").gettype ($val), 500); "Config : missing type ").gettype ($val), 500);
} }
@@ -429,7 +429,7 @@ class Config
public function docComment () public function docComment ()
{ {
$debug = 0; $debug = 0;
$reflector = new ReflectionClass (get_class ($this)); $reflector = new \ReflectionClass (get_class ($this));
$modelFile = $reflector->getFileName(); $modelFile = $reflector->getFileName();
if (! file_exists ($modelFile)) if (! file_exists ($modelFile))
throw new \Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
@@ -478,7 +478,7 @@ class Config
if (! isset ($data["param"])) if (! isset ($data["param"]))
continue; continue;
if (substr ($data["param"], 0, 1) !== "/") if (substr ($data["param"], 0, 1) !== "/")
throw new Exception (sprintf (dgettext ("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"Parameter '%s' doesn't start by slash"), $data["param"]), 500); "Parameter '%s' doesn't start by slash"), $data["param"]), 500);
$data["depth"] = $parenthesis; $data["depth"] = $parenthesis;
$data["group"] = $group; $data["group"] = $group;
+5 -5
View File
@@ -47,7 +47,7 @@ class Daemon
*/ */
public function start ($name, $callable, $params = array ()) public function start ($name, $callable, $params = array ())
{ {
$file = new \file (); $file = new file ();
if (! $file->is_writeable ($this->runDir)) if (! $file->is_writeable ($this->runDir))
throw new \Exception (sprintf ("Run Directory '%s' is not writeable", throw new \Exception (sprintf ("Run Directory '%s' is not writeable",
$this->runDir), 500); $this->runDir), 500);
@@ -61,7 +61,7 @@ class Daemon
throw new \Exception (sprintf ( throw new \Exception (sprintf (
"Can't start the daemon: already running with PID %d", $pid), 500); "Can't start the daemon: already running with PID %d", $pid), 500);
} }
$fork = new \fork (); $fork = new fork ();
$pid = $fork->startDetachedChild ($name, $callable, $params); $pid = $fork->startDetachedChild ($name, $callable, $params);
file_put_contents ($this->runDir."/$name.pid", $pid); file_put_contents ($this->runDir."/$name.pid", $pid);
return $pid; return $pid;
@@ -77,7 +77,7 @@ class Daemon
*/ */
public function stop ($name, $maxWaitStop = 3, $maxWaitKill = 3) public function stop ($name, $maxWaitStop = 3, $maxWaitKill = 3)
{ {
$file = new \file (); $file = new file ();
if (! $file->is_writeable ($this->runDir)) if (! $file->is_writeable ($this->runDir))
throw new \Exception (sprintf ("Run Directory '%s' is not writeable", throw new \Exception (sprintf ("Run Directory '%s' is not writeable",
$this->runDir), 500); $this->runDir), 500);
@@ -133,7 +133,7 @@ class Daemon
*/ */
public function status ($name) public function status ($name)
{ {
$file = new \file (); $file = new file ();
if (! $file->is_writeable ($this->runDir)) if (! $file->is_writeable ($this->runDir))
throw new \Exception (sprintf ("Run Directory '%s' is not writeable", throw new \Exception (sprintf ("Run Directory '%s' is not writeable",
$this->runDir), 500); $this->runDir), 500);
@@ -157,7 +157,7 @@ class Daemon
*/ */
public function reload ($name) public function reload ($name)
{ {
$file = new \file (); $file = new file ();
if (! $file->is_writeable ($this->runDir)) if (! $file->is_writeable ($this->runDir))
throw new \Exception (sprintf ("Run Directory '%s' is not writeable", throw new \Exception (sprintf ("Run Directory '%s' is not writeable",
$this->runDir), 500); $this->runDir), 500);
+33 -33
View File
@@ -167,10 +167,10 @@ class Dblayer
if ($this->debug) echo "CONNECT TO DATABASE\n"; if ($this->debug) echo "CONNECT TO DATABASE\n";
try try
{ {
self::$instance[$this->dsn] = new PDO ($dsn, $username, $password, self::$instance[$this->dsn] = new \PDO ($dsn, $username, $password,
$driver_options); $driver_options);
self::$instance[$this->dsn]->setAttribute (PDO::ATTR_ERRMODE, self::$instance[$this->dsn]->setAttribute (\PDO::ATTR_ERRMODE,
PDO::ERRMODE_EXCEPTION); \PDO::ERRMODE_EXCEPTION);
} }
catch (\Exception $e) catch (\Exception $e)
{ {
@@ -188,11 +188,11 @@ class Dblayer
if ($this->debug) echo "CONNECT TO DATABASE\n"; if ($this->debug) echo "CONNECT TO DATABASE\n";
try try
{ {
$driver_options[PDO::MYSQL_ATTR_FOUND_ROWS] = 1; $driver_options[\PDO::MYSQL_ATTR_FOUND_ROWS] = 1;
self::$instance[$this->dsn] = new PDO ($dsn, $username, $password, self::$instance[$this->dsn] = new \PDO ($dsn, $username, $password,
$driver_options); $driver_options);
self::$instance[$this->dsn]->setAttribute (PDO::ATTR_ERRMODE, self::$instance[$this->dsn]->setAttribute (\PDO::ATTR_ERRMODE,
PDO::ERRMODE_EXCEPTION); \PDO::ERRMODE_EXCEPTION);
} }
catch (\Exception $e) catch (\Exception $e)
{ {
@@ -210,10 +210,10 @@ class Dblayer
if ($this->debug) echo "CONNECT TO DATABASE\n"; if ($this->debug) echo "CONNECT TO DATABASE\n";
try try
{ {
self::$instance[$this->dsn] = new PDO ($dsn, $username, $password, self::$instance[$this->dsn] = new \PDO ($dsn, $username, $password,
$driver_options); $driver_options);
self::$instance[$this->dsn]->setAttribute (PDO::ATTR_ERRMODE, self::$instance[$this->dsn]->setAttribute (\PDO::ATTR_ERRMODE,
PDO::ERRMODE_EXCEPTION); \PDO::ERRMODE_EXCEPTION);
} }
catch (\Exception $e) catch (\Exception $e)
{ {
@@ -258,14 +258,14 @@ class Dblayer
if ($this->sep === "") if ($this->sep === "")
throw new \Exception (dgettext ("domframework", "Database not connected"), throw new \Exception (dgettext ("domframework", "Database not connected"),
500); 500);
switch (self::$instance[$this->dsn]->getAttribute(PDO::ATTR_DRIVER_NAME)) switch (self::$instance[$this->dsn]->getAttribute(\PDO::ATTR_DRIVER_NAME))
{ {
case "sqlite": case "sqlite":
$req = "SELECT name FROM sqlite_master WHERE type='table'"; $req = "SELECT name FROM sqlite_master WHERE type='table'";
$st = self::$instance[$this->dsn]->prepare ($req); $st = self::$instance[$this->dsn]->prepare ($req);
$st->execute (); $st->execute ();
$res = array (); $res = array ();
while ($d = $st->fetch (PDO::FETCH_ASSOC)) while ($d = $st->fetch (\PDO::FETCH_ASSOC))
$res[] = $d["name"]; $res[] = $d["name"];
break; break;
case "mysql": case "mysql":
@@ -275,7 +275,7 @@ class Dblayer
$st = self::$instance[$this->dsn]->prepare ($req); $st = self::$instance[$this->dsn]->prepare ($req);
$st->execute (); $st->execute ();
$res = array (); $res = array ();
while ($d = $st->fetch (PDO::FETCH_ASSOC)) while ($d = $st->fetch (\PDO::FETCH_ASSOC))
$res[] = $d["TABLE_NAME"]; $res[] = $d["TABLE_NAME"];
break; break;
case "pgsql": case "pgsql":
@@ -285,7 +285,7 @@ class Dblayer
$st = self::$instance[$this->dsn]->prepare ($req); $st = self::$instance[$this->dsn]->prepare ($req);
$st->execute (); $st->execute ();
$res = array (); $res = array ();
while ($d = $st->fetch (PDO::FETCH_ASSOC)) while ($d = $st->fetch (\PDO::FETCH_ASSOC))
$res[] = $d["tablename"]; $res[] = $d["tablename"];
break; break;
default: default:
@@ -564,15 +564,15 @@ class Dblayer
if ($this->debug) echo "DEBUG BIND : $column(".md5 ($column)."->". if ($this->debug) echo "DEBUG BIND : $column(".md5 ($column)."->".
var_export ($val, TRUE)."\n"; var_export ($val, TRUE)."\n";
if ($val === null) if ($val === null)
$st->bindValue (":".md5 ($key), $val, PDO::PARAM_NULL); $st->bindValue (":".md5 ($key), $val, \PDO::PARAM_NULL);
elseif ($this->fields[$foreign][0] === "integer") elseif ($this->fields[$foreign][0] === "integer")
$st->bindValue (":".md5 ($key), $val, PDO::PARAM_INT); $st->bindValue (":".md5 ($key), $val, \PDO::PARAM_INT);
elseif ($this->fields[$foreign][0] === "varchar") elseif ($this->fields[$foreign][0] === "varchar")
$st->bindValue (":".md5 ($key), $val, PDO::PARAM_STR); $st->bindValue (":".md5 ($key), $val, \PDO::PARAM_STR);
elseif ($this->fields[$foreign][0] === "datetime") elseif ($this->fields[$foreign][0] === "datetime")
$st->bindValue (":".md5 ($key), $val, PDO::PARAM_STR); $st->bindValue (":".md5 ($key), $val, \PDO::PARAM_STR);
elseif ($this->fields[$foreign][0] === "date") elseif ($this->fields[$foreign][0] === "date")
$st->bindValue (":".md5 ($key), $val, PDO::PARAM_STR); $st->bindValue (":".md5 ($key), $val, \PDO::PARAM_STR);
else else
{ {
throw new \Exception ("TO BE DEVELOPPED : ".$this->fields[$foreign][0], throw new \Exception ("TO BE DEVELOPPED : ".$this->fields[$foreign][0],
@@ -580,7 +580,7 @@ class Dblayer
} }
$st->execute (); $st->execute ();
$res = array (); $res = array ();
while ($d = $st->fetch (PDO::FETCH_ASSOC)) while ($d = $st->fetch (\PDO::FETCH_ASSOC))
$res[] = $d; $res[] = $d;
if (count ($res) === 0) if (count ($res) === 0)
{ {
@@ -655,15 +655,15 @@ class Dblayer
if ($this->debug) echo "DEBUG BIND : $key(".md5 ($key).")->". if ($this->debug) echo "DEBUG BIND : $key(".md5 ($key).")->".
var_export ($val, TRUE)."\n"; var_export ($val, TRUE)."\n";
if ($val === null) if ($val === null)
$st->bindValue (":".md5 ($key), $val, PDO::PARAM_NULL); $st->bindValue (":".md5 ($key), $val, \PDO::PARAM_NULL);
elseif ($this->fields[$key][0] === "integer") elseif ($this->fields[$key][0] === "integer")
$st->bindValue (":".md5 ($key), $val, PDO::PARAM_INT); $st->bindValue (":".md5 ($key), $val, \PDO::PARAM_INT);
elseif ($this->fields[$key][0] === "varchar") elseif ($this->fields[$key][0] === "varchar")
$st->bindValue (":".md5 ($key), $val, PDO::PARAM_STR); $st->bindValue (":".md5 ($key), $val, \PDO::PARAM_STR);
elseif ($this->fields[$key][0] === "datetime") elseif ($this->fields[$key][0] === "datetime")
$st->bindValue (":".md5 ($key), $val, PDO::PARAM_STR); $st->bindValue (":".md5 ($key), $val, \PDO::PARAM_STR);
elseif ($this->fields[$key][0] === "date") elseif ($this->fields[$key][0] === "date")
$st->bindValue (":".md5 ($key), $val, PDO::PARAM_STR); $st->bindValue (":".md5 ($key), $val, \PDO::PARAM_STR);
else else
throw new \Exception ("TO BE DEVELOPPED : ".$this->fields[$key][0], throw new \Exception ("TO BE DEVELOPPED : ".$this->fields[$key][0],
500); 500);
@@ -876,7 +876,7 @@ class Dblayer
if ($this->debug) echo "DEBUG : EXECUTE ERROR ! Return FALSE\n"; if ($this->debug) echo "DEBUG : EXECUTE ERROR ! Return FALSE\n";
} }
$res = array (); $res = array ();
while ($d = $st->fetch (PDO::FETCH_ASSOC)) while ($d = $st->fetch (\PDO::FETCH_ASSOC))
$res[] = $d; $res[] = $d;
$res = call_user_func ($this->hookpostreadFunc, $res); $res = call_user_func ($this->hookpostreadFunc, $res);
return $res; return $res;
@@ -952,27 +952,27 @@ class Dblayer
if ($val === null) if ($val === null)
{ {
if ($this->debug) echo "(null)\n"; if ($this->debug) echo "(null)\n";
$st->bindValue (":".md5 ($key), $val, PDO::PARAM_NULL); $st->bindValue (":".md5 ($key), $val, \PDO::PARAM_NULL);
} }
elseif ($fields[$key][0] === "integer") elseif ($fields[$key][0] === "integer")
{ {
if ($this->debug) echo "(integer)\n"; if ($this->debug) echo "(integer)\n";
$st->bindValue (":".md5 ($key), $val, PDO::PARAM_INT); $st->bindValue (":".md5 ($key), $val, \PDO::PARAM_INT);
} }
elseif ($fields[$key][0] === "varchar") elseif ($fields[$key][0] === "varchar")
{ {
if ($this->debug) echo "(varchar)\n"; if ($this->debug) echo "(varchar)\n";
$st->bindValue (":".md5 ($key), "$val", PDO::PARAM_STR); $st->bindValue (":".md5 ($key), "$val", \PDO::PARAM_STR);
} }
elseif ($fields[$key][0] === "datetime") elseif ($fields[$key][0] === "datetime")
{ {
if ($this->debug) echo "(datetime)\n"; if ($this->debug) echo "(datetime)\n";
$st->bindValue (":".md5 ($key), $val, PDO::PARAM_STR); $st->bindValue (":".md5 ($key), $val, \PDO::PARAM_STR);
} }
elseif ($fields[$key][0] === "date") elseif ($fields[$key][0] === "date")
{ {
if ($this->debug) echo "(date)\n"; if ($this->debug) echo "(date)\n";
$st->bindValue (":".md5 ($key), $val, PDO::PARAM_STR); $st->bindValue (":".md5 ($key), $val, \PDO::PARAM_STR);
} }
else else
{ {
@@ -1089,7 +1089,7 @@ class Dblayer
if ($this->table === null) if ($this->table === null)
throw new \Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No table name defined to create the table"), 500); "No table name defined to create the table"), 500);
switch (self::$instance[$this->dsn]->getAttribute(PDO::ATTR_DRIVER_NAME)) switch (self::$instance[$this->dsn]->getAttribute(\PDO::ATTR_DRIVER_NAME))
{ {
case "sqlite": case "sqlite":
$sql = "CREATE TABLE IF NOT EXISTS ". $sql = "CREATE TABLE IF NOT EXISTS ".
@@ -1400,7 +1400,7 @@ class Dblayer
$st = self::$instance[$this->dsn]->prepare ($sql); $st = self::$instance[$this->dsn]->prepare ($sql);
$st->execute (); $st->execute ();
$res = array (); $res = array ();
while ($d = $st->fetch (PDO::FETCH_ASSOC)) while ($d = $st->fetch (\PDO::FETCH_ASSOC))
$res[] = $d; $res[] = $d;
return $res; return $res;
} }
+27 -27
View File
@@ -52,14 +52,14 @@ class Dblayerauthzgroups extends Dblayer
&$foreignSelect) &$foreignSelect)
{ {
if ($this->module === null) if ($this->module === null)
throw new Exception ("No module defined for dblayerauthzgroups", 500); throw new \Exception ("No module defined for dblayerauthzgroups", 500);
if ($this->auth !== null && array_key_exists ("email", $this->auth) && if ($this->auth !== null && array_key_exists ("email", $this->auth) &&
$this->user === null) $this->user === null)
$this->user = $this->auth["email"]; $this->user = $this->auth["email"];
if ($this->user === null) if ($this->user === null)
throw new Exception ("No user defined for dblayerauthzgroups", 500); throw new \Exception ("No user defined for dblayerauthzgroups", 500);
if ($this->authzgroups === null) if ($this->authzgroups === null)
throw new Exception ("No authzgroups defined for dblayerauthzgroups", throw new \Exception ("No authzgroups defined for dblayerauthzgroups",
500); 500);
if ($display === null || ! in_array ($this->primary, $display)) if ($display === null || ! in_array ($this->primary, $display))
{ {
@@ -80,14 +80,14 @@ class Dblayerauthzgroups extends Dblayer
{ {
// TODO : If foreign keys, do we check if the access is allowed too ? // TODO : If foreign keys, do we check if the access is allowed too ?
if ($this->module === null) if ($this->module === null)
throw new Exception ("No module defined for dblayerauthzgroups", 500); throw new \Exception ("No module defined for dblayerauthzgroups", 500);
if ($this->auth !== null && array_key_exists ("email", $this->auth) && if ($this->auth !== null && array_key_exists ("email", $this->auth) &&
$this->user === null) $this->user === null)
$this->user = $this->auth["email"]; $this->user = $this->auth["email"];
if ($this->user === null) if ($this->user === null)
throw new Exception ("No user defined for dblayerauthzgroups", 500); throw new \Exception ("No user defined for dblayerauthzgroups", 500);
if ($this->authzgroups === null) if ($this->authzgroups === null)
throw new Exception ("No authzgroups defined for dblayerauthzgroups", throw new \Exception ("No authzgroups defined for dblayerauthzgroups",
500); 500);
$this->allowPath (); $this->allowPath ();
foreach ($data as $key=>$line) foreach ($data as $key=>$line)
@@ -116,17 +116,17 @@ class Dblayerauthzgroups extends Dblayer
public function hookpreinsert ($data) public function hookpreinsert ($data)
{ {
if ($this->module === null) if ($this->module === null)
throw new Exception ("No module defined for dblayerauthzgroups", 500); throw new \Exception ("No module defined for dblayerauthzgroups", 500);
if ($this->auth !== null && array_key_exists ("email", $this->auth) && if ($this->auth !== null && array_key_exists ("email", $this->auth) &&
$this->user === null) $this->user === null)
$this->user = $this->auth["email"]; $this->user = $this->auth["email"];
if ($this->user === null) if ($this->user === null)
throw new Exception ("No user defined for dblayerauthzgroups", 500); throw new \Exception ("No user defined for dblayerauthzgroups", 500);
if ($this->authzgroups === null) if ($this->authzgroups === null)
throw new Exception ("No authzgroups defined for dblayerauthzgroups", throw new \Exception ("No authzgroups defined for dblayerauthzgroups",
500); 500);
if ($this->createGroup === null) if ($this->createGroup === null)
throw new Exception ("No createGroup defined for dblayerauthzgroups", throw new \Exception ("No createGroup defined for dblayerauthzgroups",
500); 500);
$this->allowPath (); $this->allowPath ();
$this->authzgroups->accessWrite ($this->module, $this->user, $this->path); $this->authzgroups->accessWrite ($this->module, $this->user, $this->path);
@@ -142,17 +142,17 @@ class Dblayerauthzgroups extends Dblayer
public function hookpostinsert ($data, $lastID) public function hookpostinsert ($data, $lastID)
{ {
if ($this->module === null) if ($this->module === null)
throw new Exception ("No module defined for dblayerauthzgroups", 500); throw new \Exception ("No module defined for dblayerauthzgroups", 500);
if ($this->auth !== null && array_key_exists ("email", $this->auth) && if ($this->auth !== null && array_key_exists ("email", $this->auth) &&
$this->user === null) $this->user === null)
$this->user = $this->auth["email"]; $this->user = $this->auth["email"];
if ($this->user === null) if ($this->user === null)
throw new Exception ("No user defined for dblayerauthzgroups", 500); throw new \Exception ("No user defined for dblayerauthzgroups", 500);
if ($this->authzgroups === null) if ($this->authzgroups === null)
throw new Exception ("No authzgroups defined for dblayerauthzgroups", throw new \Exception ("No authzgroups defined for dblayerauthzgroups",
500); 500);
if ($this->createGroup === null) if ($this->createGroup === null)
throw new Exception ("No createGroup defined for dblayerauthzgroups", throw new \Exception ("No createGroup defined for dblayerauthzgroups",
500); 500);
$this->authzgroups->objectAdd ($this->module, $this->path."/$lastID"); $this->authzgroups->objectAdd ($this->module, $this->path."/$lastID");
if (is_array ($this->createGroup)) if (is_array ($this->createGroup))
@@ -171,7 +171,7 @@ class Dblayerauthzgroups extends Dblayer
} }
else else
{ {
throw new Exception ("createGroup defined for dblayerauthzgroups is not ". throw new \Exception ("createGroup defined for dblayerauthzgroups is not ".
"an array or a string", 500); "an array or a string", 500);
} }
return $lastID; return $lastID;
@@ -187,14 +187,14 @@ class Dblayerauthzgroups extends Dblayer
public function hookpreupdate ($updatekey, $data) public function hookpreupdate ($updatekey, $data)
{ {
if ($this->module === null) if ($this->module === null)
throw new Exception ("No module defined for dblayerauthzgroups", 500); throw new \Exception ("No module defined for dblayerauthzgroups", 500);
if ($this->auth !== null && array_key_exists ("email", $this->auth) && if ($this->auth !== null && array_key_exists ("email", $this->auth) &&
$this->user === null) $this->user === null)
$this->user = $this->auth["email"]; $this->user = $this->auth["email"];
if ($this->user === null) if ($this->user === null)
throw new Exception ("No user defined for dblayerauthzgroups", 500); throw new \Exception ("No user defined for dblayerauthzgroups", 500);
if ($this->authzgroups === null) if ($this->authzgroups === null)
throw new Exception ("No authzgroups defined for dblayerauthzgroups", throw new \Exception ("No authzgroups defined for dblayerauthzgroups",
500); 500);
$this->allowPath (); $this->allowPath ();
$this->authzgroups->accessWrite ($this->module, $this->user, $this->path); $this->authzgroups->accessWrite ($this->module, $this->user, $this->path);
@@ -211,14 +211,14 @@ class Dblayerauthzgroups extends Dblayer
public function hookpredelete ($deletekey) public function hookpredelete ($deletekey)
{ {
if ($this->module === null) if ($this->module === null)
throw new Exception ("No module defined for dblayerauthzgroups", 500); throw new \Exception ("No module defined for dblayerauthzgroups", 500);
if ($this->auth !== null && array_key_exists ("email", $this->auth) && if ($this->auth !== null && array_key_exists ("email", $this->auth) &&
$this->user === null) $this->user === null)
$this->user = $this->auth["email"]; $this->user = $this->auth["email"];
if ($this->user === null) if ($this->user === null)
throw new Exception ("No user defined for dblayerauthzgroups", 500); throw new \Exception ("No user defined for dblayerauthzgroups", 500);
if ($this->authzgroups === null) if ($this->authzgroups === null)
throw new Exception ("No authzgroups defined for dblayerauthzgroups", throw new \Exception ("No authzgroups defined for dblayerauthzgroups",
500); 500);
$this->allowPath (); $this->allowPath ();
$this->authzgroups->accessWrite ($this->module, $this->user, $this->path); $this->authzgroups->accessWrite ($this->module, $this->user, $this->path);
@@ -236,14 +236,14 @@ class Dblayerauthzgroups extends Dblayer
public function hookpostdelete ($deletekey, $nbLinesDeleted) public function hookpostdelete ($deletekey, $nbLinesDeleted)
{ {
if ($this->module === null) if ($this->module === null)
throw new Exception ("No module defined for dblayerauthzgroups", 500); throw new \Exception ("No module defined for dblayerauthzgroups", 500);
if ($this->auth !== null && array_key_exists ("email", $this->auth) && if ($this->auth !== null && array_key_exists ("email", $this->auth) &&
$this->user === null) $this->user === null)
$this->user = $this->auth["email"]; $this->user = $this->auth["email"];
if ($this->user === null) if ($this->user === null)
throw new Exception ("No user defined for dblayerauthzgroups", 500); throw new \Exception ("No user defined for dblayerauthzgroups", 500);
if ($this->authzgroups === null) if ($this->authzgroups === null)
throw new Exception ("No authzgroups defined for dblayerauthzgroups", throw new \Exception ("No authzgroups defined for dblayerauthzgroups",
500); 500);
$this->authzgroups->objectDel ($this->module, $this->path."/$deletekey"); $this->authzgroups->objectDel ($this->module, $this->path."/$deletekey");
return $nbLinesDeleted; return $nbLinesDeleted;
@@ -254,14 +254,14 @@ class Dblayerauthzgroups extends Dblayer
private function allowPath () private function allowPath ()
{ {
if ($this->module === null) if ($this->module === null)
throw new Exception ("No module defined for dblayerauthzgroups", 500); throw new \Exception ("No module defined for dblayerauthzgroups", 500);
if ($this->auth !== null && array_key_exists ("email", $this->auth) && if ($this->auth !== null && array_key_exists ("email", $this->auth) &&
$this->user === null) $this->user === null)
$this->user = $this->auth["email"]; $this->user = $this->auth["email"];
if ($this->user === null) if ($this->user === null)
throw new Exception ("No user defined for dblayerauthzgroups", 500); throw new \Exception ("No user defined for dblayerauthzgroups", 500);
if ($this->authzgroups === null) if ($this->authzgroups === null)
throw new Exception ("No authzgroups defined for dblayerauthzgroups", throw new \Exception ("No authzgroups defined for dblayerauthzgroups",
500); 500);
if (substr ($this->path, -1) === "/") if (substr ($this->path, -1) === "/")
$this->path = substr ($this->path, 0, -1); $this->path = substr ($this->path, 0, -1);
+1 -1
View File
@@ -491,7 +491,7 @@ class Form
* $route->requestURL () method to found the calling page * $route->requestURL () method to found the calling page
* *
* Example : * Example :
$form = new \form (); $form = new \Domframework\form ();
$form->logging (array ('\apps\general\controllers\logging', 'log'), $form->logging (array ('\apps\general\controllers\logging', 'log'),
$authHTML["email"]); $authHTML["email"]);
$values = $form->values (); $values = $form->values ();
+10 -10
View File
@@ -66,13 +66,13 @@ class Graph
if (! function_exists ("imagecreatetruecolor")) if (! function_exists ("imagecreatetruecolor"))
throw new \Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No GD support in PHP : can't create image"), 500); "No GD support in PHP : can't create image"), 500);
$this->title = new graphTitle (); $this->title = new GraphTitle ();
$this->legend = new graphLegend (); $this->legend = new GraphLegend ();
$this->data = new graphData (); $this->data = new GraphData ();
$this->series = new graphSeries (); $this->series = new GraphSeries ();
$this->axisX = new graphAxisX (); $this->axisX = new GraphAxisX ();
$this->axisY1 = new graphAxisY1 (); $this->axisY1 = new GraphAxisY1 ();
$this->axisY2 = new graphAxisY2 (); $this->axisY2 = new GraphAxisY2 ();
// Default values // Default values
$defaultTitleFontFile = "/usr/share/fonts/truetype/liberation/". $defaultTitleFontFile = "/usr/share/fonts/truetype/liberation/".
"LiberationSans-Bold.ttf"; "LiberationSans-Bold.ttf";
@@ -165,7 +165,7 @@ class Graph
! in_array ($style, array ("line", "points", "linePoints"))) ! in_array ($style, array ("line", "points", "linePoints")))
throw new \Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Invalid style provided to graph"), 406); "Invalid style provided to graph"), 406);
$styleClass = "graphStyle".$style; $styleClass = "GraphStyle".$style;
if ($this->style === null || $this->style ()->name () !== $style) if ($this->style === null || $this->style ()->name () !== $style)
{ {
$this->style = new $styleClass (); $this->style = new $styleClass ();
@@ -407,7 +407,7 @@ class GraphSeries
"Can't get a serie if the name is not a string"), "Can't get a serie if the name is not a string"),
406); 406);
if (! array_key_exists ($name, $this->series)) if (! array_key_exists ($name, $this->series))
$this->series[$name] = new graphSerie ($name); $this->series[$name] = new GraphSerie ($name);
return $this->series[$name]; return $this->series[$name];
} }
@@ -632,7 +632,7 @@ class GraphSerie
! in_array ($style, array ("line", "points", "linePoints"))) ! in_array ($style, array ("line", "points", "linePoints")))
throw new \Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Invalid style provided to serie"), 406); "Invalid style provided to serie"), 406);
$styleClass = "graphStyle".$style; $styleClass = "GraphStyle".$style;
if ($this->style === null) if ($this->style === null)
$this->style = new $styleClass (); $this->style = new $styleClass ();
return $this->style; return $this->style;
+1 -1
View File
@@ -653,7 +653,7 @@ class Httpclient
// {{{ // {{{
if ($this->tcpclient === null) if ($this->tcpclient === null)
{ {
$this->tcpclient = new tcpclient ($parseURL["host"], $this->port); $this->tcpclient = new Tcpclient ($parseURL["host"], $this->port);
$this->tcpclient->timeout ($this->timeout); $this->tcpclient->timeout ($this->timeout);
$this->tcpclient->connect (); $this->tcpclient->connect ();
if ($parseURL["scheme"] === "https") if ($parseURL["scheme"] === "https")
+2 -2
View File
@@ -53,7 +53,7 @@ class Jwt
$payload = $this->jsonEncode ($payload); $payload = $this->jsonEncode ($payload);
if ($ckey) if ($ckey)
{ {
$encrypt = new encrypt (); $encrypt = new Encrypt ();
$payload = $encrypt->encrypt ($payload, $ckey, $cipherMethod); $payload = $encrypt->encrypt ($payload, $ckey, $cipherMethod);
} }
$segments[] = $this->urlsafeB64Encode ($payload); $segments[] = $this->urlsafeB64Encode ($payload);
@@ -94,7 +94,7 @@ class Jwt
$payload = $this->urlsafeB64Decode ($payloadb64); $payload = $this->urlsafeB64Decode ($payloadb64);
if ($ckey) if ($ckey)
{ {
$encrypt = new encrypt (); $encrypt = new Encrypt ();
$payload = $encrypt->decrypt ($payload, $ckey); $payload = $encrypt->decrypt ($payload, $ckey);
} }
$payload = $this->jsonDecode ($payload); $payload = $this->jsonDecode ($payload);
+5 -5
View File
@@ -214,14 +214,14 @@ class Logger
private function logfile ($message, $priority) private function logfile ($message, $priority)
{ {
if ($this->logfile === FALSE) if ($this->logfile === FALSE)
throw new Exception ("Undefined file where logging"); throw new \Exception ("Undefined file where logging");
if (!file_exists ($this->logfile)) if (!file_exists ($this->logfile))
{ {
if (! is_dir (dirname ($this->logfile))) if (! is_dir (dirname ($this->logfile)))
throw new Exception ("You must create the ".dirname ($this->logfile). throw new \Exception ("You must create the ".dirname ($this->logfile).
"directory"); "directory");
if (! is_writable (dirname ($this->logfile))) if (! is_writable (dirname ($this->logfile)))
throw new Exception ("The directory ".dirname ($this->logfile)." must" throw new \Exception ("The directory ".dirname ($this->logfile)." must"
." be writable to create log file"); ." be writable to create log file");
} }
elseif (!is_writable ($this->logfile)) elseif (!is_writable ($this->logfile))
@@ -232,7 +232,7 @@ class Logger
$user = getenv('USERNAME'); $user = getenv('USERNAME');
else else
$user = ""; $user = "";
throw new Exception ("Logfile $this->logfile is not writable for user ". throw new \Exception ("Logfile $this->logfile is not writable for user ".
$user); $user);
} }
@@ -313,7 +313,7 @@ class Logger
private function logsession ($message, $priority) private function logsession ($message, $priority)
{ {
if (! isset ($_SESSION)) if (! isset ($_SESSION))
throw new Exception ("No session available to store the log", 500); throw new \Exception ("No session available to store the log", 500);
ini_set ("date.timezone", $this->timezone); ini_set ("date.timezone", $this->timezone);
$message = date ("Y/m/d H:i:s")." [".$this->priorities[$priority]."] ". $message = date ("Y/m/d H:i:s")." [".$this->priorities[$priority]."] ".
$message; $message;
+1 -1
View File
@@ -15,7 +15,7 @@ class Outputcsv extends Output
function __construct () function __construct ()
{ {
if (!function_exists ("fputcsv")) if (!function_exists ("fputcsv"))
throw new Exception ("CSV support not available in PHP !", 500); throw new \Exception ("CSV support not available in PHP !", 500);
} }
/** Display in CSV the data provided /** Display in CSV the data provided
+1 -1
View File
@@ -34,7 +34,7 @@ class Outputrest extends Output
{ {
if (! isset ($variable["exceptionCode"])) if (! isset ($variable["exceptionCode"]))
$variable["exceptionCode"] = 200; $variable["exceptionCode"] = 200;
$rest = new rest (); $rest = new Rest ();
$rest->display ($data, $variable["exceptionCode"]); $rest->display ($data, $variable["exceptionCode"]);
} }
} }
+1 -1
View File
@@ -29,7 +29,7 @@ class Outputxml extends Output
} }
else else
{ {
$xml = new SimpleXMLElement ("<?xml version=\"1.0\"?><root></root>"); $xml = new \SimpleXMLElement ("<?xml version=\"1.0\"?><root></root>");
// function call to convert array to xml // function call to convert array to xml
if (!is_array ($data)) if (!is_array ($data))
$data = array ($data); $data = array ($data);
+1 -1
View File
@@ -132,7 +132,7 @@ class Password
static public function cryptPasswd ($password) static public function cryptPasswd ($password)
// {{{ // {{{
{ {
$passwd = new password (); $passwd = new Password ();
return $passwd->cryptPassword ($password); return $passwd->cryptPassword ($password);
} }
// }}} // }}}
+8 -8
View File
@@ -36,7 +36,7 @@ class Queuefile extends Queue
throw new \Exception ("Invalid DSN provided to queuefile : not starting ". throw new \Exception ("Invalid DSN provided to queuefile : not starting ".
"by file://", 500); "by file://", 500);
$this->queue = substr ($dsn, 7); $this->queue = substr ($dsn, 7);
$file = new \file (); $file = new File ();
if (! $file->file_exists (dirname ($this->queue))) if (! $file->file_exists (dirname ($this->queue)))
$file->mkdir (dirname ($this->queue), 0777, true); $file->mkdir (dirname ($this->queue), 0777, true);
if (! $file->file_exists ($this->queue)) if (! $file->file_exists ($this->queue))
@@ -52,7 +52,7 @@ class Queuefile extends Queue
public function add ($entry) public function add ($entry)
// {{{ // {{{
{ {
$file = new \file (); $file = new File ();
$file->lockEX ($this->queue); $file->lockEX ($this->queue);
$file->file_put_contents ($this->queue, $file->file_put_contents ($this->queue,
json_encode ($entry)."\n", FILE_APPEND); json_encode ($entry)."\n", FILE_APPEND);
@@ -68,7 +68,7 @@ class Queuefile extends Queue
public function getAll ($delete =false) public function getAll ($delete =false)
// {{{ // {{{
{ {
$file = new \file (); $file = new File ();
if ($delete) if ($delete)
$file->lockEX ($this->queue); $file->lockEX ($this->queue);
else else
@@ -93,7 +93,7 @@ class Queuefile extends Queue
public function count () public function count ()
// {{{ // {{{
{ {
$file = new \file (); $file = new File ();
$file->lockSH ($this->queue); $file->lockSH ($this->queue);
$content = $file->file_get_contents ($this->queue); $content = $file->file_get_contents ($this->queue);
$count = substr_count ($content, "\n"); $count = substr_count ($content, "\n");
@@ -108,7 +108,7 @@ class Queuefile extends Queue
public function clear () public function clear ()
// {{{ // {{{
{ {
$file = new \file (); $file = new File ();
$file->lockEX ($this->queue); $file->lockEX ($this->queue);
$file->file_put_contents ($this->queue, ""); $file->file_put_contents ($this->queue, "");
$file->lockUN ($this->queue); $file->lockUN ($this->queue);
@@ -124,7 +124,7 @@ class Queuefile extends Queue
public function getFirst ($delete = false) public function getFirst ($delete = false)
// {{{ // {{{
{ {
$file = new \file (); $file = new File ();
if ($delete) if ($delete)
$file->lockEX ($this->queue); $file->lockEX ($this->queue);
else else
@@ -156,7 +156,7 @@ class Queuefile extends Queue
public function getLast ($delete = false) public function getLast ($delete = false)
// {{{ // {{{
{ {
$file = new \file (); $file = new File ();
if ($delete) if ($delete)
$file->lockEX ($this->queue); $file->lockEX ($this->queue);
else else
@@ -190,7 +190,7 @@ class Queuefile extends Queue
public function getRange ($start, $number, $delete = false) public function getRange ($start, $number, $delete = false)
// {{{ // {{{
{ {
$file = new \file (); $file = new File ();
if ($delete) if ($delete)
$file->lockEX ($this->queue); $file->lockEX ($this->queue);
else else
+1 -1
View File
@@ -36,7 +36,7 @@ class Ratelimitfile extends Ratelimit
"File '%s' not writeable for user '%s'"), "File '%s' not writeable for user '%s'"),
$file, $user["name"]), 500); $file, $user["name"]), 500);
file_put_contents ($file, $currentTimeStamp, FILE_APPEND); file_put_contents ($file, $currentTimeStamp, FILE_APPEND);
$lock = new lockfile (); $lock = new Lockfile ();
$lock->storagelock = $this->storageDir."/lockfile.lock"; $lock->storagelock = $this->storageDir."/lockfile.lock";
$lock->lockRW (); $lock->lockRW ();
$contents = file ($file); $contents = file ($file);
+3 -3
View File
@@ -35,7 +35,7 @@ class Renderer
// If the output is not defined in domframework, it will not be loaded but // If the output is not defined in domframework, it will not be loaded but
// without error, it can be loaded by the autoloader // without error, it can be loaded by the autoloader
//@require_once ("domframework/output$this->output.php"); //@require_once ("domframework/output$this->output.php");
$class = __NAMESPACE__."\\output$this->output"; $class = __NAMESPACE__."\\Output$this->output";
$obj = new $class (); $obj = new $class ();
$res = call_user_func_array (array ($obj, "out"), $res = call_user_func_array (array ($obj, "out"),
array ($this->result, $this->title, array ($this->result, $this->title,
@@ -119,7 +119,7 @@ class Renderer
if ($layoutfile !== false && ! file_exists ($layoutfile)) if ($layoutfile !== false && ! file_exists ($layoutfile))
throw new \Exception ("Layout file $layoutfile not found", 500); throw new \Exception ("Layout file $layoutfile not found", 500);
if ($route === null) if ($route === null)
$route = new route (); $route = new Route ();
// Return a $dataflash with the displayed flash in Bootstrap // Return a $dataflash with the displayed flash in Bootstrap
$dataflash = ""; $dataflash = "";
if (isset ($_SESSION["renderer"]["flash"])) if (isset ($_SESSION["renderer"]["flash"]))
@@ -158,7 +158,7 @@ class Renderer
unset ($_SESSION["renderer"]["flash"]); unset ($_SESSION["renderer"]["flash"]);
} }
$html = new outputhtml (); $html = new Outputhtml ();
$replacement = array_merge ($replacement, $replacement = array_merge ($replacement,
array ("{baseurl}"=>$route->baseURL (), array ("{baseurl}"=>$route->baseURL (),
"{baseurlresource}"=>$route->baseURLresource (), "{baseurlresource}"=>$route->baseURLresource (),
+3 -3
View File
@@ -38,7 +38,7 @@ class Rest
// the output plugin at the end // the output plugin at the end
$convert = array_intersect ($this->convert, $this->allowedtypes); $convert = array_intersect ($this->convert, $this->allowedtypes);
$type = array_search (reset ($this->allowedtypes), $this->convert); $type = array_search (reset ($this->allowedtypes), $this->convert);
$http = new http; $http = new Http;
$type = $http->bestChoice ($_SERVER["HTTP_ACCEPT"], array_keys ($convert), $type = $http->bestChoice ($_SERVER["HTTP_ACCEPT"], array_keys ($convert),
$type); $type);
$type = $this->convert[$type]; $type = $this->convert[$type];
@@ -56,12 +56,12 @@ class Rest
function display ($message, $code = 200) function display ($message, $code = 200)
// {{{ // {{{
{ {
$http = new http; $http = new Http;
$text = $http->codetext ($code); $text = $http->codetext ($code);
header ($_SERVER["SERVER_PROTOCOL"]." $code $text"); header ($_SERVER["SERVER_PROTOCOL"]." $code $text");
$type = $this->chooseType (); $type = $this->chooseType ();
require_once ("domframework/output$type.php"); require_once ("domframework/output$type.php");
$constr = __NAMESPACE__."\\output$type"; $constr = __NAMESPACE__."\\Output$type";
$method = "out"; $method = "out";
$obj = new $constr (); $obj = new $constr ();
$obj->$method ($message); $obj->$method ($message);
+5 -5
View File
@@ -68,7 +68,7 @@ class Route
/** The route constructor : initialize the parameters */ /** The route constructor : initialize the parameters */
function __construct () function __construct ()
{ {
$this->ratelimiter = new ratelimitfile (); $this->ratelimiter = new Ratelimitfile ();
} }
/** Get / Set the debug level /** Get / Set the debug level
@@ -533,7 +533,7 @@ class Route
{ {
$this->error ($e); $this->error ($e);
} }
$renderer = new renderer (); $renderer = new Renderer ();
$renderer->result = $data; $renderer->result = $data;
$renderer->output = $this->output; $renderer->output = $this->output;
$renderer->title = $this->title; $renderer->title = $this->title;
@@ -588,7 +588,7 @@ class Route
{ {
$this->error ($e); $this->error ($e);
} }
$renderer = new renderer (); $renderer = new Renderer ();
$renderer->result = $data; $renderer->result = $data;
$renderer->output = $this->output; $renderer->output = $this->output;
$renderer->title = $this->title; $renderer->title = $this->title;
@@ -669,7 +669,7 @@ class Route
$this->redirect ($this->authenticationURL.$this->requestURL(), ""); $this->redirect ($this->authenticationURL.$this->requestURL(), "");
} }
$http = new http (); $http = new Http ();
@header ($_SERVER["SERVER_PROTOCOL"]." $getCode ". @header ($_SERVER["SERVER_PROTOCOL"]." $getCode ".
$http->codetext ($getCode)); $http->codetext ($getCode));
if ($getCode === 401) if ($getCode === 401)
@@ -680,7 +680,7 @@ class Route
} }
// TODO : If the output is HTML, add the header line : // TODO : If the output is HTML, add the header line :
// echo " <meta name='ROBOTS' content='NOINDEX, NOFOLLOW'>\n"; // echo " <meta name='ROBOTS' content='NOINDEX, NOFOLLOW'>\n";
$renderer = new renderer (); $renderer = new Renderer ();
$renderer->result = $message; $renderer->result = $message;
$renderer->output = $this->output; $renderer->output = $this->output;
$renderer->title = $http->codetext ($getCode); $renderer->title = $http->codetext ($getCode);
+33 -34
View File
@@ -177,7 +177,7 @@ class RouteSQL
{ {
// The maximum of links available in the paginator // The maximum of links available in the paginator
$maxClickPaginator = 10; $maxClickPaginator = 10;
$route = new route (); $route = new Route ();
$prePage = false; $prePage = false;
$postPage = false; $postPage = false;
$content = " <div class='paginatorArea'>\n"; $content = " <div class='paginatorArea'>\n";
@@ -242,7 +242,7 @@ $content .= "</li>\n";
$content = ""; $content = "";
if ($this->displayActions && $this->readwriteAllowed) if ($this->displayActions && $this->readwriteAllowed)
{ {
$route = new route (); $route = new Route ();
$content .= " <div class='actionExtern'>\n"; $content .= " <div class='actionExtern'>\n";
$content .= " <a href='".$route->baseURL().$this->url_prefix."/add'>" $content .= " <a href='".$route->baseURL().$this->url_prefix."/add'>"
.dgettext ("domframework", "Add new entry")."</a>\n"; .dgettext ("domframework", "Add new entry")."</a>\n";
@@ -259,7 +259,7 @@ $content .= "</li>\n";
*/ */
private function numberEntryByDisplayArea ($nbentries, $page, $num, $search) private function numberEntryByDisplayArea ($nbentries, $page, $num, $search)
{ {
$route = new route (); $route = new Route ();
$content = ""; $content = "";
$content .= " <div class='numberEntryByDisplayArea'>\n"; $content .= " <div class='numberEntryByDisplayArea'>\n";
$content .= " <form method='get' action='".$route->baseURL(). $content .= " <form method='get' action='".$route->baseURL().
@@ -288,7 +288,7 @@ $content .= "</li>\n";
*/ */
private function searchArea ($nbentries, $page, $num, $search) private function searchArea ($nbentries, $page, $num, $search)
{ {
$route = new route (); $route = new Route ();
$content = ""; $content = "";
$content .= " <div class='searchArea'>\n"; $content .= " <div class='searchArea'>\n";
$content .= " <form method='get' action='".$route->baseURL(). $content .= " <form method='get' action='".$route->baseURL().
@@ -330,7 +330,7 @@ $content .= "</li>\n";
/** Create the routes for REST pages and the associated actions */ /** Create the routes for REST pages and the associated actions */
public function routesREST () public function routesREST ()
{ {
$route = new route (); $route = new Route ();
$route->debug = $this->debug;; $route->debug = $this->debug;;
$route->allowSlashes=false; $route->allowSlashes=false;
$route->get ("rest/".$this->url_prefix."(\.{extension})?". $route->get ("rest/".$this->url_prefix."(\.{extension})?".
@@ -431,7 +431,7 @@ $content .= "</li>\n";
// $chainedvalues are the information associated to the $chain // $chainedvalues are the information associated to the $chain
$chainedvalues = $this->chained->keyexists ($chain); $chainedvalues = $this->chained->keyexists ($chain);
if ($chainedvalues === false) if ($chainedvalues === false)
throw new exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Object not found"), 404); "Object not found"), 404);
} }
if ($this->accessright ($this->authREST["email"]) !== TRUE) if ($this->accessright ($this->authREST["email"]) !== TRUE)
@@ -502,7 +502,7 @@ $content .= "</li>\n";
// $chainedvalues are the information associated to the $chain // $chainedvalues are the information associated to the $chain
$chainedvalues = $this->chained->keyexists ($chain); $chainedvalues = $this->chained->keyexists ($chain);
if ($chainedvalues === false) if ($chainedvalues === false)
throw new exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Object not found"), 404); "Object not found"), 404);
} }
if ($this->accessright ($this->authREST["email"]) !== TRUE) if ($this->accessright ($this->authREST["email"]) !== TRUE)
@@ -624,7 +624,7 @@ $content .= "</li>\n";
$this->url_prefix; $this->url_prefix;
} }
/** Add HTML routes */ /** Add HTML routes */
$route = new route (); $route = new Route ();
$route->debug = $this->debug;; $route->debug = $this->debug;;
$route->allowSlashes=false; $route->allowSlashes=false;
$route->get ($this->url_prefix."/", function ($chain=null) use ($route) $route->get ($this->url_prefix."/", function ($chain=null) use ($route)
@@ -704,7 +704,7 @@ $content .= "</li>\n";
//echo "SEARCH=$search\n"; //echo "SEARCH=$search\n";
//$route->debug=$this->debug; //$route->debug=$this->debug;
$this->connect(); $this->connect();
$csrf = new csrf (); $csrf = new Csrf ();
$token = $csrf->createToken (); $token = $csrf->createToken ();
$titles = $this->objectDB->titles (); $titles = $this->objectDB->titles ();
unset ($titles[$this->chainedForeign]); unset ($titles[$this->chainedForeign]);
@@ -1140,9 +1140,9 @@ $content .= "</li>\n";
403); 403);
$this->connect(); $this->connect();
$csrf = new csrf (); $csrf = new Csrf ();
$renderer = new renderer (); $renderer = new Renderer ();
$route = new route (); $route = new Route ();
try try
{ {
$csrf->checkToken ($token); $csrf->checkToken ($token);
@@ -1356,11 +1356,11 @@ $content .= "</li>\n";
// CSS is in edit an id too ! // CSS is in edit an id too !
} }
$f = new form (); $f = new Form ();
$fields = array (); $fields = array ();
foreach ($titles as $key=>$val) foreach ($titles as $key=>$val)
{ {
$field = new formfield ($key, $val); $field = new Formfield ($key, $val);
if (! isset ($this->objectDB->fields[$key])) if (! isset ($this->objectDB->fields[$key]))
throw new \Exception (sprintf (dgettext ("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"Field '%s' (defined in titles) not found in fields"), "Field '%s' (defined in titles) not found in fields"),
@@ -1385,7 +1385,7 @@ $content .= "</li>\n";
unset ($field); unset ($field);
} }
$field = new formfield ("submit", dgettext ("domframework", $field = new Formfield ("submit", dgettext ("domframework",
"Save the data")); "Save the data"));
$field->defaults = dgettext ("domframework", "Save the data"); $field->defaults = dgettext ("domframework", "Save the data");
$field->type = "submit"; $field->type = "submit";
@@ -1414,7 +1414,7 @@ $content .= "</li>\n";
// $chainedvalues are the information associated to the $chain // $chainedvalues are the information associated to the $chain
$chainedvalues = $this->chained->keyexists ($chain); $chainedvalues = $this->chained->keyexists ($chain);
if ($chainedvalues === false) if ($chainedvalues === false)
throw new exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Object not found"), 404); "Object not found"), 404);
} }
if ($this->accessright ($this->authHTML["email"]) !== TRUE) if ($this->accessright ($this->authHTML["email"]) !== TRUE)
@@ -1438,7 +1438,7 @@ $content .= "</li>\n";
403); 403);
$this->connect(); $this->connect();
$f = new form (); $f = new Form ();
$values = $f->values (); $values = $f->values ();
$errorsChain = array (); $errorsChain = array ();
if ($this->chainedForeign !== null && if ($this->chainedForeign !== null &&
@@ -1453,7 +1453,7 @@ $content .= "</li>\n";
try try
{ {
$this->objectDB->insert ($values); $this->objectDB->insert ($values);
$renderer = new renderer (); $renderer = new Renderer ();
$renderer->flash ("SUCCESS", dgettext ("domframework", $renderer->flash ("SUCCESS", dgettext ("domframework",
"Creation done")); "Creation done"));
$route->redirect ("/". $route->redirect ("/".
@@ -1462,13 +1462,13 @@ $content .= "</li>\n";
} }
catch (\Exception $e) catch (\Exception $e)
{ {
$renderer = new renderer (); $renderer = new Renderer ();
$renderer->flash ("ERROR", $e->getMessage ()); $renderer->flash ("ERROR", $e->getMessage ());
} }
} }
else else
{ {
$renderer = new renderer (); $renderer = new Renderer ();
foreach ($errorsChain as $error) foreach ($errorsChain as $error)
$renderer->flash (strtoupper ($error[0]), $error[1]); $renderer->flash (strtoupper ($error[0]), $error[1]);
} }
@@ -1499,7 +1499,7 @@ $content .= "</li>\n";
// $chainedvalues are the information associated to the $chain // $chainedvalues are the information associated to the $chain
$chainedvalues = $this->chained->keyexists ($chain); $chainedvalues = $this->chained->keyexists ($chain);
if ($chainedvalues === false) if ($chainedvalues === false)
throw new exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Object not found"), 404); "Object not found"), 404);
} }
if ($this->accessright ($this->authHTML["email"], $id) !== TRUE) if ($this->accessright ($this->authHTML["email"], $id) !== TRUE)
@@ -1675,11 +1675,11 @@ $content .= "</li>\n";
// CSS is in add too ! // CSS is in add too !
} }
$f = new form (); $f = new Form ();
$fields = array (); $fields = array ();
foreach ($titles as $key=>$val) foreach ($titles as $key=>$val)
{ {
$field = new formfield ($key, $val); $field = new Formfield ($key, $val);
if (! isset ($this->objectDB->fields[$key])) if (! isset ($this->objectDB->fields[$key]))
throw new \Exception (sprintf (dgettext ("domframework", throw new \Exception (sprintf (dgettext ("domframework",
"Field '%s' (defined in titles) not found in fields"), "Field '%s' (defined in titles) not found in fields"),
@@ -1708,7 +1708,7 @@ $content .= "</li>\n";
if ($readonly === false && $this->readwriteAllowed === true) if ($readonly === false && $this->readwriteAllowed === true)
{ {
$field = new formfield ("submit", dgettext ("domframework", $field = new Formfield ("submit", dgettext ("domframework",
"Save the data")); "Save the data"));
$field->defaults = dgettext ("domframework", "Save the data"); $field->defaults = dgettext ("domframework", "Save the data");
$field->type = "submit"; $field->type = "submit";
@@ -1739,7 +1739,7 @@ $content .= "</li>\n";
// $chainedvalues are the information associated to the $chain // $chainedvalues are the information associated to the $chain
$chainedvalues = $this->chained->keyexists ($chain); $chainedvalues = $this->chained->keyexists ($chain);
if ($chainedvalues === false) if ($chainedvalues === false)
throw new exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Object not found"), 404); "Object not found"), 404);
} }
if ($this->accessright ($this->authHTML["email"], $id) !== TRUE) if ($this->accessright ($this->authHTML["email"], $id) !== TRUE)
@@ -1769,7 +1769,7 @@ $content .= "</li>\n";
throw new \Exception (dgettext ("domframework", "Object not found"), throw new \Exception (dgettext ("domframework", "Object not found"),
404); 404);
$oldvalues = $oldvalues[0]; $oldvalues = $oldvalues[0];
$f = new form (); $f = new Form ();
$values = $f->values (); $values = $f->values ();
if ($values[$this->objectDB->primary] !== $id) if ($values[$this->objectDB->primary] !== $id)
throw new \Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
@@ -1789,7 +1789,7 @@ $content .= "</li>\n";
try try
{ {
$this->objectDB->update ($id, $values); $this->objectDB->update ($id, $values);
$renderer = new renderer (); $renderer = new Renderer ();
$renderer->flash ("SUCCESS", dgettext ("domframework", $renderer->flash ("SUCCESS", dgettext ("domframework",
"Update done")); "Update done"));
$route->redirect ("/". $route->redirect ("/".
@@ -1798,13 +1798,13 @@ $content .= "</li>\n";
} }
catch (\Exception $e) catch (\Exception $e)
{ {
$renderer = new renderer (); $renderer = new Renderer ();
$renderer->flash ("ERROR", $e->getMessage ()); $renderer->flash ("ERROR", $e->getMessage ());
} }
} }
else else
{ {
$renderer = new renderer (); $renderer = new Renderer ();
foreach ($errorsChain as $error) foreach ($errorsChain as $error)
$renderer->flash (strtoupper ($error[0]), $error[1]); $renderer->flash (strtoupper ($error[0]), $error[1]);
} }
@@ -1897,9 +1897,9 @@ $content .= "</li>\n";
*/ */
private function rendererhtml ($data) private function rendererhtml ($data)
{ {
$route = new route (); $route = new Route ();
$html = new outputhtml (); $html = new Outputhtml ();
$replacement = array ("{baseurl}"=>$route->baseURL ()); $replacement = array ("{baseurl}"=>$route->baseURL ());
if ($this->rendererHTMLlayout === false) if ($this->rendererHTMLlayout === false)
{ {
@@ -1929,11 +1929,10 @@ $content .= "</li>\n";
*/ */
private function renderrest ($extension, $data, $getCode=200) private function renderrest ($extension, $data, $getCode=200)
{ {
require_once ("domframework/output$extension.php"); $http = new Http ();
$http = new http ();
@header ($_SERVER["SERVER_PROTOCOL"]." $getCode ". @header ($_SERVER["SERVER_PROTOCOL"]." $getCode ".
$http->codetext ($getCode)); $http->codetext ($getCode));
$class = "output$extension"; $class = "Output$extension";
$result = new $class (); $result = new $class ();
echo $result->out ($data)."\n"; echo $result->out ($data)."\n";
exit; exit;
+3 -3
View File
@@ -60,7 +60,7 @@ class Rss
return $this->link; return $this->link;
if (! is_string ($link)) if (! is_string ($link))
throw new \Exception ("Link provided to RSS is not a string", 500); throw new \Exception ("Link provided to RSS is not a string", 500);
$verify = new \verify (); $verify = new verify ();
if (! $verify->is_URL ($link)) if (! $verify->is_URL ($link))
throw new \Exception ("Link provided to RSS is not an URL", 500); throw new \Exception ("Link provided to RSS is not an URL", 500);
if ($link === "") if ($link === "")
@@ -124,7 +124,7 @@ class Rss
if (! is_string ($lastBuildDate)) if (! is_string ($lastBuildDate))
throw new \Exception ("lastBuildDate provided to RSS is not a string", throw new \Exception ("lastBuildDate provided to RSS is not a string",
500); 500);
$verify = new \verify (); $verify = new verify ();
if (! $verify->is_datetimeSQL ($lastBuildDate)) if (! $verify->is_datetimeSQL ($lastBuildDate))
throw new \Exception ("lastBuildDate provided to RSS is not a valid date", throw new \Exception ("lastBuildDate provided to RSS is not a valid date",
500); 500);
@@ -258,7 +258,7 @@ class Rssitem
return $this->link; return $this->link;
if (! is_string ($link)) if (! is_string ($link))
throw new \Exception ("Link provided to RSS Item is not a string", 500); throw new \Exception ("Link provided to RSS Item is not a string", 500);
$verify = new \verify (); $verify = new verify ();
if (! $verify->is_URL ($link)) if (! $verify->is_URL ($link))
throw new \Exception ("Link provided to RSS Item is not an URL", 500); throw new \Exception ("Link provided to RSS Item is not an URL", 500);
if ($link === "") if ($link === "")
+1 -1
View File
@@ -89,7 +89,7 @@ class Spfcheck
else else
throw new \Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"SFPCheck : Invalid IP address provided : Not Ipv4 neither IPv6"), 403); "SFPCheck : Invalid IP address provided : Not Ipv4 neither IPv6"), 403);
$ipaddresses = new ipaddresses (); $ipaddresses = new Ipaddresses ();
foreach ($ips as $key => $sub) foreach ($ips as $key => $sub)
{ {
foreach ($sub as $part => $spfips) foreach ($sub as $part => $spfips)
+12 -12
View File
@@ -95,15 +95,15 @@ class Users
public function checkEmail ($email) public function checkEmail ($email)
{ {
if (! is_string ($email)) if (! is_string ($email))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Invalid email provided : not a string"), "Invalid email provided : not a string"),
500); 500);
if (strlen ($email) < 5) if (strlen ($email) < 5)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Invalid email provided : too short"), "Invalid email provided : too short"),
500); 500);
if (strpos ($email, ":") !== false) if (strpos ($email, ":") !== false)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Invalid email provided : colon forbidden"), "Invalid email provided : colon forbidden"),
500); 500);
return true; return true;
@@ -115,15 +115,15 @@ class Users
public function checkFirstname ($firstname) public function checkFirstname ($firstname)
{ {
if (! is_string ($firstname)) if (! is_string ($firstname))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Invalid firstname provided : not a string"), "Invalid firstname provided : not a string"),
500); 500);
if (strlen ($firstname) < 1) if (strlen ($firstname) < 1)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Invalid firstname provided : too short"), "Invalid firstname provided : too short"),
500); 500);
if (strpos ($firstname, ":") !== false) if (strpos ($firstname, ":") !== false)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Invalid firstname provided : colon forbidden"), "Invalid firstname provided : colon forbidden"),
500); 500);
return true; return true;
@@ -135,11 +135,11 @@ class Users
public function checkLastname ($lastname) public function checkLastname ($lastname)
{ {
if (! is_string ($lastname)) if (! is_string ($lastname))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Invalid lastname provided : not a string"), "Invalid lastname provided : not a string"),
500); 500);
if (strpos ($lastname, ":") !== false) if (strpos ($lastname, ":") !== false)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Invalid lastname provided : colon forbidden"), "Invalid lastname provided : colon forbidden"),
500); 500);
return true; return true;
@@ -151,15 +151,15 @@ class Users
public function checkPassword ($password) public function checkPassword ($password)
{ {
if (! is_string ($password)) if (! is_string ($password))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Invalid password provided : not a string"), "Invalid password provided : not a string"),
500); 500);
if (strlen ($password) < 5) if (strlen ($password) < 5)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Invalid password provided : too short"), "Invalid password provided : too short"),
500); 500);
if (strlen ($password) >= 128) if (strlen ($password) >= 128)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Invalid password provided : too long"), "Invalid password provided : too long"),
500); 500);
return true; return true;
@@ -171,7 +171,7 @@ class Users
public function cryptPasswd ($password) public function cryptPasswd ($password)
{ {
if (! function_exists ("openssl_random_pseudo_bytes")) if (! function_exists ("openssl_random_pseudo_bytes"))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No PHP support for openssl_random_pseudo_bytes"), "No PHP support for openssl_random_pseudo_bytes"),
500); 500);
$cost = 11; $cost = 11;
+11 -11
View File
@@ -59,24 +59,24 @@ class Userssql extends Users
public function connect () public function connect ()
{ {
if ($this->table === null) if ($this->table === null)
throw new Exception (dgettext ("domframework", "No SQL table defined"), throw new \Exception (dgettext ("domframework", "No SQL table defined"),
500); 500);
if ($this->fieldEmail === null) if ($this->fieldEmail === null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No fieldIdentifier defined"), 500); "No fieldIdentifier defined"), 500);
if ($this->fieldPassword === null) if ($this->fieldPassword === null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No fieldPassword defined"), 500); "No fieldPassword defined"), 500);
if ($this->fieldLastname === null) if ($this->fieldLastname === null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No fieldLastname defined"), 500); "No fieldLastname defined"), 500);
if ($this->fieldFirstname === null) if ($this->fieldFirstname === null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No fieldFirstname defined"), 500); "No fieldFirstname defined"), 500);
if ($this->fieldLastchange === null) if ($this->fieldLastchange === null)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No fieldLastchange defined"), 500); "No fieldLastchange defined"), 500);
$this->db = new dblayer ($this->dsn, $this->username, $this->password, $this->db = new Dblayer ($this->dsn, $this->username, $this->password,
$this->driver_options); $this->driver_options);
$this->db->table = $this->table; $this->db->table = $this->table;
$this->db->fields = array ( $this->db->fields = array (
@@ -179,7 +179,7 @@ class Userssql extends Users
$this->checkPassword ($oldpassword); $this->checkPassword ($oldpassword);
$this->checkPassword ($newpassword); $this->checkPassword ($newpassword);
if ($this->checkValidPassword ($email, $oldpassword) !== true) if ($this->checkValidPassword ($email, $oldpassword) !== true)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"Bad old password provided"), 401); "Bad old password provided"), 401);
$cryptedPassword = $this->cryptPasswd ($newpassword); $cryptedPassword = $this->cryptPasswd ($newpassword);
return $this->db->update ($email, return $this->db->update ($email,
@@ -202,7 +202,7 @@ class Userssql extends Users
$data = $this->db->read (array (array ($this->fieldEmail, $email)), $data = $this->db->read (array (array ($this->fieldEmail, $email)),
array ($this->fieldPassword)); array ($this->fieldPassword));
if (count ($data) === 0) if (count ($data) === 0)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No information found for this email"), 404); "No information found for this email"), 404);
$cryptedPassword = $this->cryptPasswd ($newpassword); $cryptedPassword = $this->cryptPasswd ($newpassword);
return $this->db->update ($email, return $this->db->update ($email,
@@ -224,10 +224,10 @@ class Userssql extends Users
$data = $this->db->read (array (array ($this->fieldEmail, $email)), $data = $this->db->read (array (array ($this->fieldEmail, $email)),
array ($this->fieldPassword)); array ($this->fieldPassword));
if (count ($data) === 0) if (count ($data) === 0)
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No information found for this email"), 404); "No information found for this email"), 404);
if (! isset ($data[0][$this->fieldPassword])) if (! isset ($data[0][$this->fieldPassword]))
throw new Exception (dgettext ("domframework", throw new \Exception (dgettext ("domframework",
"No password available for this email"), 404); "No password available for this email"), 404);
$cryptedPassword = $data[0][$this->fieldPassword]; $cryptedPassword = $data[0][$this->fieldPassword];
if (crypt ($password, $cryptedPassword) !== $cryptedPassword) if (crypt ($password, $cryptedPassword) !== $cryptedPassword)
+1 -1
View File
@@ -63,7 +63,7 @@ class Xmppclient
// To have a really one microsecond precision in microtime function // To have a really one microsecond precision in microtime function
ini_set ("precision", 16); ini_set ("precision", 16);
$this->debug = $debug; $this->debug = $debug;
$this->sock = new tcpclient ($server, $port); $this->sock = new Tcpclient ($server, $port);
$this->sock->readMode ("binary"); $this->sock->readMode ("binary");
$client = gethostname (); $client = gethostname ();
@list ($user, $domain) = explode ("@", $login, 2); @list ($user, $domain) = explode ("@", $login, 2);