From 17168aaaefc220e99e0a0207b6456fdd494f0f41 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Thu, 23 May 2019 14:19:30 +0000 Subject: [PATCH] Update gettext : add spaces DomCi : remove line too longs on all the files git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5280 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- auth.php | 26 +-- authentication.php | 8 +- authhtpasswd.php | 8 +- authimap.php | 6 +- authldap.php | 4 +- authorizationdb.php | 104 ++++++------ authparams.php | 2 +- authsession.php | 4 +- authshibboleth.php | 6 +- authsql.php | 38 ++--- authsympa.php | 16 +- authzgroups.php | 57 +++---- authzgroupsoo.php | 54 +++---- cachefile.php | 16 +- cacheoutput.php | 2 +- certificationauthority.php | 2 +- config.php | 24 +-- csrf.php | 6 +- dbjson.php | 12 +- dblayer.php | 192 +++++++++++----------- dblayeroo.php | 34 ++-- form.php | 8 +- fts.php | 5 +- imap.php | 4 +- inifile.php | 16 +- ipaddresses.php | 56 +++---- language.php | 6 +- mail.php | 35 ++-- outputhtml.php | 2 +- outputjson.php | 2 +- queuefile.php | 2 +- ratelimit.php | 6 +- ratelimitfile.php | 2 +- renderer.php | 8 +- route.php | 2 +- routeSQL.php | 320 ++++++++++++++++++++----------------- smtp.php | 14 +- users.php | 24 +-- userssql.php | 20 +-- 39 files changed, 588 insertions(+), 565 deletions(-) diff --git a/auth.php b/auth.php index b8ecaaf..f7848f6 100644 --- a/auth.php +++ b/auth.php @@ -26,7 +26,7 @@ class auth $res .= "\n"; $res .= "\n"; - $res .= "".dgettext("domframework", "Sign in")."\n"; + $res .= "".dgettext ("domframework", "Sign in")."\n"; $res .= "\n"; $res .= " \n"; - $res .= " \n"; } else { - $res .= "

".dgettext("domframework", + $res .= "

".dgettext ("domframework", "Already sign in"); $res .= "

\n"; if (is_string ($alreadyAuth)) @@ -144,7 +144,7 @@ class auth */ public function connect () { - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "No connect to authentication available"), 405); } @@ -157,7 +157,7 @@ class auth */ public function authentication ($email, $password) { - throw new exception (dgettext("domframework", + throw new exception (dgettext ("domframework", "No authentication available"), 405); } @@ -165,7 +165,7 @@ class auth */ public function getdetails () { - throw new exception (dgettext("domframework", + throw new exception (dgettext ("domframework", "No getdetails available"), 405); } @@ -176,7 +176,7 @@ class auth */ public function changepassword ($oldpassword, $newpassword) { - throw new exception (dgettext("domframework", + throw new exception (dgettext ("domframework", "No password change available"), 405); } @@ -188,7 +188,7 @@ class auth */ public function overwritepassword ($email, $newpassword) { - throw new exception (dgettext("domframework", + throw new exception (dgettext ("domframework", "No password overwrite available"), 405); } @@ -197,7 +197,7 @@ class auth */ public function listusers () { - throw new exception (dgettext("domframework", + throw new exception (dgettext ("domframework", "No List User available"), 405); } @@ -205,7 +205,7 @@ class auth */ public function logout () { - throw new exception (dgettext("domframework", + throw new exception (dgettext ("domframework", "No logout method available"), 405); } } diff --git a/authentication.php b/authentication.php index 073f442..e3608ae 100644 --- a/authentication.php +++ b/authentication.php @@ -121,7 +121,7 @@ class authentication if ($url === "" || $url === null) { $_SESSION["domframework"]["authentication"]["message"] = - dgettext("domframework", "You have been logged out"); + dgettext ("domframework", "You have been logged out"); $this->route->redirect ("/authentication", ""); } else @@ -183,7 +183,7 @@ class authentication LOG_WARNING, "Ratelimiting for $ipClient"); $_SESSION["domframework"]["authentication"]["message"] = - dgettext("domframework", "Too much connections"); + dgettext ("domframework", "Too much connections"); if ($url === "") { $this->route->redirect ("/authentication", ""); @@ -305,7 +305,7 @@ class authentication { // Authentication error if ($this->debug) echo "Previous session not found"; - $msg = dgettext("domframework", "Previous session not found"); + $msg = dgettext ("domframework", "Previous session not found"); $_SESSION["domframework"]["authentication"]["message"] = $msg; call_user_func ($this->loggingFunc, LOG_WARNING, @@ -407,7 +407,7 @@ class authentication } } } - return dgettext("domframework", "Bad login/password"); + return dgettext ("domframework", "Bad login/password"); } // }}} diff --git a/authhtpasswd.php b/authhtpasswd.php index c4587ab..5a03dc1 100644 --- a/authhtpasswd.php +++ b/authhtpasswd.php @@ -21,11 +21,11 @@ class authhtpasswd extends auth public function connect () { if (! file_exists ($this->htpasswdFile)) - throw new Exception (sprintf (dgettext("domframework", + throw new Exception (sprintf (dgettext ("domframework", "The HTPasswd file '%s' is not found"), $this->htpasswdFile), 500); if (! is_readable ($this->htpasswdFile)) - throw new Exception (sprintf (dgettext("domframework", + throw new Exception (sprintf (dgettext ("domframework", "The HTPasswd file '%s' is not readable"), $this->htpasswdFile), 500); } @@ -73,7 +73,7 @@ class authhtpasswd extends auth @param string $newpassword The new password to be recorded */ public function changepassword ($oldpassword, $newpassword) { - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "The password can't be change for HTPasswd users"), 405); } @@ -85,7 +85,7 @@ class authhtpasswd extends auth @param string $newpassword The new password to be recorded */ public function overwritepassword ($email, $newpassword) { - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "The password can't be change for HTPasswd users"), 405); } diff --git a/authimap.php b/authimap.php index b0e228a..d6c6c06 100644 --- a/authimap.php +++ b/authimap.php @@ -60,7 +60,7 @@ class authimap extends auth @param string $newpassword The new password to be recorded */ 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); } @@ -71,7 +71,7 @@ class authimap extends auth @param string $newpassword The new password to be recorded */ public function overwritepassword ($email, $newpassword) { - throw new exception (dgettext("domframework", + throw new exception (dgettext ("domframework", "The password can't be overwrite for IMAP users"), 405); } @@ -80,7 +80,7 @@ class authimap extends auth Return firstname, lastname, mail, with mail is an array */ public function listusers () { - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Can't get list of users for IMAP server"), 405); } } diff --git a/authldap.php b/authldap.php index 507b80d..3c1008f 100644 --- a/authldap.php +++ b/authldap.php @@ -104,7 +104,7 @@ class authldap extends auth @param string $newpassword The new password to be recorded */ public function changepassword ($oldpassword, $newpassword) { - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "The password can't be change for LDAP users"), 405); } @@ -115,7 +115,7 @@ class authldap extends auth @param string $newpassword The new password to be recorded */ public function overwritepassword ($email, $newpassword) { - throw new exception (dgettext("domframework", + throw new exception (dgettext ("domframework", "The password can't be overwrite for LDAP users"), 405); } diff --git a/authorizationdb.php b/authorizationdb.php index 6859adb..8fcf2a7 100644 --- a/authorizationdb.php +++ b/authorizationdb.php @@ -44,7 +44,7 @@ class authorizationdb extends authorization public function initialize () { if ($this->db === null) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Database to authorize is not connected"), 500); $tables = $this->db->listTables (); if (!in_array ($this->db->tableprefix.$this->db->table, $tables)) @@ -63,16 +63,16 @@ class authorizationdb extends authorization public function validate ($object) { if ($this->db === null) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Database to authorize is not connected"), 500); if (substr ($object, -1) === "/") $object = 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 = preg_replace ("#//+#", "/", $object); if ($this->authiduser === "") - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Not authenticated"), 401); try { @@ -87,7 +87,7 @@ class authorizationdb extends authorization // exists $search = $this->db->read (array (array ("object", $object))); if (count ($search) === 0) - throw new Exception (sprintf (dgettext("domframework", + throw new Exception (sprintf (dgettext ("domframework", "Object %s doesn't exists"), $object), 404); @@ -140,24 +140,24 @@ class authorizationdb extends authorization public function add ($object, $ownerid, $groupid, $modbits) { if ($this->db === null) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Database to authorize is not connected"), 500); // The modbits are stored in octal to be more readable $modbits = decoct ($modbits); if (substr ($object, -1) === "/") $object = 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 = preg_replace ("#//+#", "/", $object); if ($this->authiduser === "") - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Not authenticated"), 401); 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); 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); try { @@ -172,7 +172,7 @@ class authorizationdb extends authorization // exists $search = $this->db->read (array (array ("object", $object))); if (count ($search)) - throw new Exception (sprintf (dgettext("domframework", + throw new Exception (sprintf (dgettext ("domframework", "Object %s already defined"), $object), 400); @@ -209,19 +209,19 @@ class authorizationdb extends authorization public function drop ($object) { if ($this->db === null) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Database to authorize is not connected"), 500); if (substr ($object, -1) === "/") $object = 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 = preg_replace ("#//+#", "/", $object); if ($this->authiduser === "") - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Not authenticated"), 401); if ($object === "/") - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "The root can not be removed"), 406); try { @@ -236,7 +236,7 @@ class authorizationdb extends authorization // exists $search = $this->db->read (array (array ("object", $object))); if (count ($search) === 0) - throw new Exception (sprintf (dgettext("domframework", + throw new Exception (sprintf (dgettext ("domframework", "Object %s doesn't exists"), $object), 400); @@ -246,10 +246,10 @@ class authorizationdb extends authorization { $rc = $this->db->delete ($object); if ($rc > 1) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Removing more than one object"), 406); if ($rc == 0) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "No object removed"), 406); $rc = $this->db->delete ("$object$this->separator%"); return TRUE; @@ -266,10 +266,10 @@ class authorizationdb extends authorization $rc = $this->db->delete ($object); if ($rc > 1) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Removing more than one object"), 406); if ($rc == 0) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "No object removed"), 406); $rc = $this->db->delete ("$object$this->separator%"); return TRUE; @@ -283,19 +283,19 @@ class authorizationdb extends authorization public function chown ($object, $ownerid) { if ($this->db === null) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Database to authorize is not connected"), 500); if (substr ($object, -1) === "/") $object = 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 = preg_replace ("#//+#", "/", $object); if ($this->authiduser === "") - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Not authenticated"), 401); if ($this->authiduser !== 0) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "The chown is reserved to root user"), 405); try { @@ -310,7 +310,7 @@ class authorizationdb extends authorization // exists $search = $this->db->read (array (array ("object", $object))); if (count ($search) === 0) - throw new Exception (sprintf (dgettext("domframework", + throw new Exception (sprintf (dgettext ("domframework", "Object %s doesn't exists"), $object), 400); $search = reset ($search); @@ -326,22 +326,22 @@ class authorizationdb extends authorization public function chgrp ($object, $groupid) { if ($this->db === null) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Database to authorize is not connected"), 500); if (substr ($object, -1) === "/") $object = 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 = preg_replace ("#//+#", "/", $object); if ($this->authiduser === "") - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Not authenticated"), 401); 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); 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); try { @@ -356,7 +356,7 @@ class authorizationdb extends authorization // exists $search = $this->db->read (array (array ("object", $object))); if (count ($search) === 0) - throw new Exception (sprintf (dgettext("domframework", + throw new Exception (sprintf (dgettext ("domframework", "Object %s doesn't exists"), $object), 400); $search = reset ($search); @@ -372,19 +372,19 @@ class authorizationdb extends authorization public function chmod ($object, $mod) { if ($this->db === null) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Database to authorize is not connected"), 500); if (substr ($object, -1) === "/") $object = 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 = preg_replace ("#//+#", "/", $object); if ($this->authiduser === "") - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Not authenticated"), 401); 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); try { @@ -399,7 +399,7 @@ class authorizationdb extends authorization // exists $search = $this->db->read (array (array ("object", $object))); if (count ($search) === 0) - throw new Exception (sprintf (dgettext("domframework", + throw new Exception (sprintf (dgettext ("domframework", "Object %s doesn't exists"), $object), 400); $search = reset ($search); @@ -415,16 +415,16 @@ class authorizationdb extends authorization public function lsmod ($object) { if ($this->db === null) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Database to authorize is not connected"), 500); if (substr ($object, -1) === "/") $object = 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 = preg_replace ("#//+#", "/", $object); if ($this->authiduser === "") - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Not authenticated"), 401); try { @@ -439,7 +439,7 @@ class authorizationdb extends authorization // exists $search = $this->db->read (array (array ("object", $object))); if (count ($search) === 0) - throw new Exception (sprintf (dgettext("domframework", + throw new Exception (sprintf (dgettext ("domframework", "Object %s doesn't exists"), $object), 400); $search = reset ($search); @@ -453,16 +453,16 @@ class authorizationdb extends authorization public function lsown ($object) { if ($this->db === null) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Database to authorize is not connected"), 500); if (substr ($object, -1) === "/") $object = 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 = preg_replace ("#//+#", "/", $object); if ($this->authiduser === "") - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Not authenticated"), 401); try { @@ -477,7 +477,7 @@ class authorizationdb extends authorization // exists $search = $this->db->read (array (array ("object", $object))); if (count ($search) === 0) - throw new Exception (sprintf (dgettext("domframework", + throw new Exception (sprintf (dgettext ("domframework", "Object %s doesn't exists"), $object), 400); $search = reset ($search); @@ -491,16 +491,16 @@ class authorizationdb extends authorization public function lsgrp ($object) { if ($this->db === null) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Database to authorize is not connected"), 500); if (substr ($object, -1) === "/") $object = 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 = preg_replace ("#//+#", "/", $object); if ($this->authiduser === "") - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Not authenticated"), 401); try { @@ -515,7 +515,7 @@ class authorizationdb extends authorization // exists $search = $this->db->read (array (array ("object", $object))); if (count ($search) === 0) - throw new Exception (sprintf (dgettext("domframework", + throw new Exception (sprintf (dgettext ("domframework", "Object %s doesn't exists"), $object), 404); $search = reset ($search); @@ -531,7 +531,7 @@ class authorizationdb extends authorization private function treecheckExecute ($object) { if ($this->db === null) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Database to authorize is not connected"), 500); // Search all the parents in an array $parents = array (); @@ -568,7 +568,7 @@ class authorizationdb extends authorization } } if (!$found) - throw new Exception (sprintf (dgettext("domframework", + throw new Exception (sprintf (dgettext ("domframework", "The path %s is not found in database"), $p), 404); else @@ -593,7 +593,7 @@ class authorizationdb extends authorization if (($parentModbits & 0001) === 1) continue; - throw new Exception (sprintf (dgettext("domframework", + throw new Exception (sprintf (dgettext ("domframework", "No execute rights on %s"), $p), 405); } } @@ -624,7 +624,7 @@ class authorizationdb extends authorization if (($parentModbits & 0002) === 2) return TRUE; - throw new Exception (sprintf (dgettext("domframework", + throw new Exception (sprintf (dgettext ("domframework", "No write rights on %s"), $parent), 405); } } diff --git a/authparams.php b/authparams.php index e6695d3..480b549 100644 --- a/authparams.php +++ b/authparams.php @@ -68,7 +68,7 @@ class authparams /** Get information from a HTTP authentication */ public function http() { - $realm = dgettext("domframework", + $realm = dgettext ("domframework", "Restricted access"); if (!isset($_SERVER['PHP_AUTH_USER'])) { diff --git a/authsession.php b/authsession.php index 2307de1..a07e814 100644 --- a/authsession.php +++ b/authsession.php @@ -55,7 +55,7 @@ class authsession extends auth */ public function changepassword ($oldpassword, $newpassword) { - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "The password can't be change for SESSION users"), 405); } @@ -68,7 +68,7 @@ class authsession extends auth */ public function overwritepassword ($email, $newpassword) { - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "The password can't be overwrite for SESSION users"), 405); } diff --git a/authshibboleth.php b/authshibboleth.php index c296e1d..a972e3b 100644 --- a/authshibboleth.php +++ b/authshibboleth.php @@ -71,7 +71,7 @@ class authshibboleth extends auth { // Redirect to Shibboleth IDP if ($this->urlPasswdChange == "") - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "The password can't be change for Shibboleth users"), 405); $route = new route (); @@ -85,7 +85,7 @@ class authshibboleth extends auth @param string $newpassword The new password to be recorded */ public function overwritepassword ($email, $newpassword) { - throw new exception (dgettext("domframework", + throw new exception (dgettext ("domframework", "The password can't be overwrite for Shibboleth users"), 405); } @@ -95,7 +95,7 @@ class authshibboleth extends auth { // Redirect to Shibboleth IDP if ($this->urlLogout === "") - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Shibboleth is not configured to allow logout"), 405); $route = new route (); $route->redirect ($this->urlLogout); diff --git a/authsql.php b/authsql.php index c1a3283..b6b427f 100644 --- a/authsql.php +++ b/authsql.php @@ -43,25 +43,25 @@ class authsql extends auth public function connect () { 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"), 500); $this->db = new dblayer ($this->dsn, $this->username, $this->password, $this->driver_options); if ($this->table === null) - throw new Exception (dgettext("domframework","No SQL table defined"), + throw new Exception (dgettext ("domframework","No SQL table defined"), 500); if ($this->fieldIdentifier === null) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "No fieldIdentifier defined"), 500); if ($this->fieldPassword === null) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "No fieldPassword defined"), 500); if ($this->fieldLastname === null) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "No fieldLastname defined"), 500); if ($this->fieldFirstname === null) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "No fieldFirstname defined"), 500); $fields = array_merge (array ($this->fieldIdentifier, $this->fieldPassword, $this->fieldLastname, $this->fieldFirstname), @@ -80,7 +80,7 @@ class authsql extends auth public function authentication ($email, $password) { if ($this->db === null) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "The SQL database is not connected"), 500); $data = $this->db->read (array (array ($this->fieldIdentifier, $email)), array_merge (array ($this->fieldIdentifier, @@ -89,16 +89,16 @@ class authsql extends auth $this->fieldPassword), $this->fieldsInfo)); if (count ($data) === 0) - throw new Exception (sprintf (dgettext("domframework", + throw new Exception (sprintf (dgettext ("domframework", "Unable to find the user : '%s'"), $email), 401); if (! isset ($data[0][$this->fieldPassword])) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Unable to get the user password from database"), 500); $cryptedPassword = $data[0][$this->fieldPassword]; if (crypt ($password, $cryptedPassword) !== $cryptedPassword) - throw new Exception (sprintf (dgettext("domframework", + throw new Exception (sprintf (dgettext ("domframework", "Bad password for '%s'"), $email), 401); // The password should never be stored by this function @@ -123,11 +123,11 @@ class authsql extends auth public function changepassword ($oldpassword, $newpassword) { if ($this->db === null) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "The SQL database is not connected"), 500); if ($this->details === null || ! 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"), 500); $data = $this->db->read (array (array ($this->fieldIdentifier, @@ -136,7 +136,7 @@ class authsql extends auth $this->fieldPassword)); $cryptedPassword = $data[0][$this->fieldPassword]; if (crypt ($oldpassword, $cryptedPassword) !== $cryptedPassword) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Bad old password provided"), 401); $cost = 11; $salt=substr(base64_encode(openssl_random_pseudo_bytes(17)),0,22); @@ -151,7 +151,7 @@ class authsql extends auth $rc = $this->db->update ($this->details[$this->fieldIdentifier], array ($this->fieldPassword => $cryptpassword)); if ($rc !== 1) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Can't change the password"), 500); } @@ -163,13 +163,13 @@ class authsql extends auth public function overwritepassword ($email, $newpassword) { if ($this->db === null) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "The SQL database is not connected"), 500); $data = $this->db->read (array (array ($this->fieldIdentifier, $email)), array ($this->fieldIdentifier, $this->fieldPassword)); if (count ($data) === 0) - throw new Exception (sprintf (dgettext("domframework", + throw new Exception (sprintf (dgettext ("domframework", "Unable to find the user : '%s'"), $email), 401); $cost = 11; @@ -185,15 +185,15 @@ class authsql extends auth $rc = $this->db->update ($email, array ($this->fieldPassword => $cryptpassword)); if ($rc !== 1) - throw new Exception (dgettext("domframework","Can't change the password"), - 500); + throw new Exception (dgettext ("domframework", + "Can't change the password"), 500); } /** List all the users available in the database Return firstname, lastname, mail, with mail is an array */ public function listusers () { if ($this->db === null) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "The SQL database is not connected"), 500); $data = $this->db->read (null, array_merge (array ($this->fieldIdentifier, $this->fieldFirstname, diff --git a/authsympa.php b/authsympa.php index 08453c6..b51a021 100644 --- a/authsympa.php +++ b/authsympa.php @@ -42,7 +42,7 @@ class authsympa extends auth public function __construct () { if (! class_exists ("SoapClient")) - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "No SOAP PHP library available"), 500); } @@ -50,7 +50,7 @@ class authsympa extends auth public function connect () { if ($this->wsdl === null) - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "No WSDL provided to Sympa auth"), 401); $this->client = new \SoapClient($this->wsdl); } @@ -61,20 +61,20 @@ class authsympa extends auth public function authentication ($email, $password) { if ($this->client === null) - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "The SOAP connection is not opened"), 401); if ($this->list === null) - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "The list to check is not defined"), 401); $this->authkey = $this->client->login ($email, $password); if ($this->authkey === null) - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Can't connect with provided email/password to sympa"), 401); $rc = $this->client->authenticateAndRun ($email, $this->authkey, 'amI', array ($this->list, $this->function, $email)); if ($rc === null || $rc === false) - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "User not in Sympa list or bad password"), 401); $this->details = array ("email"=>$email); return $rc; @@ -92,7 +92,7 @@ class authsympa extends auth @param string $newpassword The new password to be recorded */ public function changepassword ($oldpassword, $newpassword) { - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "The password can't be change for SYMPA users"), 405); } @@ -104,7 +104,7 @@ class authsympa extends auth @param string $newpassword The new password to be recorded */ public function overwritepassword ($email, $newpassword) { - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "The password can't be overwrite for Sympa users"), 405); } diff --git a/authzgroups.php b/authzgroups.php index 3861133..ea730be 100644 --- a/authzgroups.php +++ b/authzgroups.php @@ -174,9 +174,9 @@ class authzgroups if ($rc !== "NO") return TRUE; if ($user === "anonymous") - throw new Exception (dgettext("domframework", "Anonymous not allowed"), + throw new Exception (dgettext ("domframework", "Anonymous not allowed"), 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) @@ -209,9 +209,9 @@ class authzgroups if ($rc === "RW") return TRUE; if ($user === "anonymous") - throw new Exception (dgettext("domframework", "Anonymous not allowed"), + throw new Exception (dgettext ("domframework", "Anonymous not allowed"), 401); - throw new Exception (dgettext("domframework", "Modification forbidden"), + throw new Exception (dgettext ("domframework", "Modification forbidden"), 403); } @@ -246,9 +246,9 @@ class authzgroups if ($rc === "RO") return TRUE; if ($user === "anonymous") - throw new Exception (dgettext("domframework", "Anonymous not allowed"), + throw new Exception (dgettext ("domframework", "Anonymous not allowed"), 401); - throw new Exception (dgettext("domframework", "Access forbidden"), 403); + throw new Exception (dgettext ("domframework", "Access forbidden"), 403); } ///////////////////////// @@ -276,13 +276,13 @@ class authzgroups "comment"=> array ("varchar", "255")); $this->dbObject->primary = "idobject"; $this->dbObject->unique = array ("idobject", array ("object", "module")); - $this->dbObject->titles = array ("idobject"=>dgettext("domframework", + $this->dbObject->titles = array ("idobject"=>dgettext ("domframework", "idobject"), - "module"=>dgettext("domframework", + "module"=>dgettext ("domframework", "Module"), - "object"=>dgettext("domframework", + "object"=>dgettext ("domframework", "Object"), - "comment"=>dgettext("domframework", + "comment"=>dgettext ("domframework", "Comment")); $this->dbGroup = new dblayer ($dsn, $username, $password, $driver_options); @@ -296,13 +296,13 @@ class authzgroups "comment"=>array ("varchar", "255")); $this->dbGroup->primary = "idgroup"; $this->dbGroup->unique = array ("idgroup", array ("module","group")); - $this->dbGroup->titles = array ("idgroup"=>dgettext("domframework", + $this->dbGroup->titles = array ("idgroup"=>dgettext ("domframework", "idgroup"), - "module"=>dgettext("domframework", + "module"=>dgettext ("domframework", "Module"), - "group"=>dgettext("domframework", + "group"=>dgettext ("domframework", "Group"), - "comment"=>dgettext("domframework", + "comment"=>dgettext ("domframework", "Comment")); $this->dbGroupMember = new dblayer ($dsn, $username, $password, @@ -321,15 +321,11 @@ class authzgroups $this->dbGroupMember->foreign = array ( "idgroup"=>array ("authzgroup", "idgroup", "ON UPDATE CASCADE ON DELETE CASCADE")); - $this->dbGroupMember->titles = array ("idgroupmember"=> - dgettext("domframework", - "idgroupmember"), - "user"=>dgettext("domframework", - "User"), - "idgroup"=>dgettext("domframework", - "idgroup"), - "comment"=>dgettext("domframework", - "Comment")); + $this->dbGroupMember->titles = array ( + "idgroupmember"=> dgettext ("domframework", "idgroupmember"), + "user"=>dgettext ("domframework", "User"), + "idgroup"=>dgettext ("domframework", "idgroup"), + "comment"=>dgettext ("domframework", "Comment")); $this->dbRight = new dblayer ($dsn, $username, $password, $driver_options); $this->dbRight->debug = $this->debug; @@ -349,15 +345,12 @@ class authzgroups "idobject"=>array ("authzobject", "idobject", "ON UPDATE CASCADE ON DELETE CASCADE"), ); - $this->dbRight->titles = array ("idright"=>dgettext("domframework", - "idright"), - "idgroup"=>dgettext("domframework", - "idgroup"), - "idobject"=>dgettext("domframework", - "idobject"), - "right"=>dgettext("domframework", "Right"), - "comment"=>dgettext("domframework", - "Comment")); + $this->dbRight->titles = array ( + "idright"=>dgettext ("domframework", "idright"), + "idgroup"=>dgettext ("domframework", "idgroup"), + "idobject"=>dgettext ("domframework", "idobject"), + "right"=>dgettext ("domframework", "Right"), + "comment"=>dgettext ("domframework", "Comment")); return TRUE; } diff --git a/authzgroupsoo.php b/authzgroupsoo.php index 5cb4da3..15dc20f 100644 --- a/authzgroupsoo.php +++ b/authzgroupsoo.php @@ -196,9 +196,9 @@ class authzgroupsoo if ($rc !== "NO") return TRUE; if ($user === "anonymous") - throw new \Exception (dgettext("domframework", "Anonymous not allowed"), - 401); - throw new \Exception (dgettext("domframework", "Access forbidden"), 403); + throw new \Exception (dgettext ("domframework", "Anonymous not allowed"), + 401); + throw new \Exception (dgettext ("domframework", "Access forbidden"), 403); } /** Return TRUE if the user right allow to edit the object (RW only) @@ -231,10 +231,10 @@ class authzgroupsoo if ($rc === "RW") return TRUE; if ($user === "anonymous") - throw new \Exception (dgettext("domframework", "Anonymous not allowed"), - 401); - throw new \Exception (dgettext("domframework", "Modification forbidden"), - 403); + throw new \Exception (dgettext ("domframework", "Anonymous not allowed"), + 401); + throw new \Exception (dgettext ("domframework", "Modification forbidden"), + 403); } /** Return TRUE if the user right allow to see but without modification @@ -268,9 +268,9 @@ class authzgroupsoo if ($rc === "RO") return TRUE; if ($user === "anonymous") - throw new \Exception (dgettext("domframework", "Anonymous not allowed"), - 401); - throw new \Exception (dgettext("domframework", "Access forbidden"), 403); + throw new \Exception (dgettext ("domframework", "Anonymous not allowed"), + 401); + throw new \Exception (dgettext ("domframework", "Access forbidden"), 403); } ///////////////////////// @@ -300,10 +300,10 @@ class authzgroupsoo $this->dbObject->primary ("idobject"); $this->dbObject->unique (array ("idobject", array ("object", "module"))); $this->dbObject->titles (array ( - "idobject" => dgettext("domframework", "idobject"), - "module" => dgettext("domframework", "Module"), - "object" => dgettext("domframework", "Object"), - "comment" => dgettext("domframework", "Comment"))); + "idobject" => dgettext ("domframework", "idobject"), + "module" => dgettext ("domframework", "Module"), + "object" => dgettext ("domframework", "Object"), + "comment" => dgettext ("domframework", "Comment"))); $this->dbGroup = new dblayeroo ($dsn, $username, $password, $driver_options); @@ -318,10 +318,10 @@ class authzgroupsoo $this->dbGroup->primary ("idgroup"); $this->dbGroup->unique (array ("idgroup", array ("module","group"))); $this->dbGroup->titles (array ( - "idgroup" => dgettext("domframework", "idgroup"), - "module" => dgettext("domframework", "Module"), - "group" => dgettext("domframework", "Group"), - "comment" => dgettext("domframework", "Comment"))); + "idgroup" => dgettext ("domframework", "idgroup"), + "module" => dgettext ("domframework", "Module"), + "group" => dgettext ("domframework", "Group"), + "comment" => dgettext ("domframework", "Comment"))); $this->dbGroupMember = new dblayeroo ($dsn, $username, $password, $driver_options); @@ -341,10 +341,10 @@ class authzgroupsoo "ON UPDATE CASCADE ON DELETE CASCADE"))); $this->dbGroupMember->setForeignObj ($this->dbGroup); $this->dbGroupMember->titles (array ( - "idgroupmember" => dgettext("domframework", "idgroupmember"), - "user" => dgettext("domframework", "User"), - "idgroup" => dgettext("domframework", "idgroup"), - "comment" => dgettext("domframework", "Comment"))); + "idgroupmember" => dgettext ("domframework", "idgroupmember"), + "user" => dgettext ("domframework", "User"), + "idgroup" => dgettext ("domframework", "idgroup"), + "comment" => dgettext ("domframework", "Comment"))); $this->dbRight = new dblayeroo ($dsn, $username, $password, $driver_options); @@ -368,11 +368,11 @@ class authzgroupsoo $this->dbRight->setForeignObj ($this->dbGroup); $this->dbRight->setForeignObj ($this->dbObject); $this->dbRight->titles (array ( - "idright" => dgettext("domframework", "idright"), - "idgroup" => dgettext("domframework", "idgroup"), - "idobject" => dgettext("domframework", "idobject"), - "right" => dgettext("domframework", "Right"), - "comment" => dgettext("domframework", "Comment"))); + "idright" => dgettext ("domframework", "idright"), + "idgroup" => dgettext ("domframework", "idgroup"), + "idobject" => dgettext ("domframework", "idobject"), + "right" => dgettext ("domframework", "Right"), + "comment" => dgettext ("domframework", "Comment"))); return TRUE; } diff --git a/cachefile.php b/cachefile.php index 7499606..cf506ae 100644 --- a/cachefile.php +++ b/cachefile.php @@ -74,28 +74,28 @@ class cachefile public function cachedir () { if (! isset ($this->directory) || $this->directory === "") - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "No cache directory defined"), 500); if (! file_exists ($this->directory)) { // Need to create the cache dir $parent = realpath (dirname ($this->directory)); if (! is_writeable (dirname ($this->directory))) - throw new Exception (sprintf (dgettext("domframework", + throw new Exception (sprintf (dgettext ("domframework", "Directory %s is not writable : can not create cache directory"), $parent), 500); if (!mkdir ($this->directory)) - throw new Exception (sprintf (dgettext("domframework", + throw new Exception (sprintf (dgettext ("domframework", "Can not create cache directory %s"), $this->directory), 500); chmod ($this->directory, 0777); } if (! is_writable ($this->directory)) - throw new Exception (sprintf (dgettext("domframework", + throw new Exception (sprintf (dgettext ("domframework", "Cache directory %s is not writable"), $this->directory), 500); if (! is_readable ($this->directory)) - throw new Exception (sprintf (dgettext("domframework", + throw new Exception (sprintf (dgettext ("domframework", "Cache directory %s is not readable"), $this->directory), 500); if (!file_exists ($this->directory."/.htaccess")) @@ -114,7 +114,7 @@ class cachefile if ($this->nocache !== false) return false; if ($data === false) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Can not store FALSE in cache"), 500); try { @@ -158,11 +158,11 @@ class cachefile if (!file_exists ($fileCache)) return false; if (!is_readable ($fileCache)) - throw new Exception (sprintf (dgettext("domframework", + throw new Exception (sprintf (dgettext ("domframework", "File cache %s is not readable"), $fileCache), 500); if (!is_writable ($fileCache)) - throw new Exception (sprintf (dgettext("domframework", + throw new Exception (sprintf (dgettext ("domframework", "File cache %s is not writable"), $fileCache), 500); // Lock : waiting the reconstruction of the cache by another process diff --git a/cacheoutput.php b/cacheoutput.php index d622ba9..93bd150 100644 --- a/cacheoutput.php +++ b/cacheoutput.php @@ -27,7 +27,7 @@ class cacheoutput { $res = @include ("domframework/cache$method.php"); if ($res === false) - throw new Exception (sprintf (dgettext("domframework", + throw new Exception (sprintf (dgettext ("domframework", "Unkwnown cache method : "), $method), 500); $this->id = $id; diff --git a/certificationauthority.php b/certificationauthority.php index 119db86..67c18c6 100644 --- a/certificationauthority.php +++ b/certificationauthority.php @@ -58,7 +58,7 @@ extendedKeyUsage = serverAuth, clientAuth // {{{ { if (! function_exists ("openssl_csr_new")) - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "No openssl support in PHP"), 500); $this->opensslCnfPath = tempnam ("/tmp", "openssl-"); file_put_contents ($this->opensslCnfPath, $this->opensslConf); diff --git a/config.php b/config.php index bf953ed..a629e86 100644 --- a/config.php +++ b/config.php @@ -106,12 +106,12 @@ class config if (@file_put_contents ($this->confFile, "confFile), 500); } elseif (! is_readable ($this->confFile)) - throw new Exception (sprintf ( dgettext("domframework", + throw new Exception (sprintf ( dgettext ("domframework", "The configuration file '%s' is not readable"), $this->confFile)); $conf = array (); @@ -176,17 +176,17 @@ class config } elseif (! is_readable ($this->confFile)) throw new Exception (sprintf ( - dgettext("domframework", + dgettext ("domframework", "The configuration file '%s' is not readable"), $this->confFile), 500); if (!is_writeable ($this->confFile)) - throw new Exception (sprintf (dgettext("domframework", + throw new Exception (sprintf (dgettext ("domframework", "Configuration file '%s' is write protected"), $this->confFile), 500); $conf = array (); $rc = include ($this->confFile); if ($rc !== 1) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Error in configuration file"), 500); $newconf = array_merge ($this->default, $conf, array ($param=>$value)); $txt = "confFile, $txt, LOCK_EX) === FALSE) - throw new Exception (sprintf (dgettext("domframework", + throw new Exception (sprintf (dgettext ("domframework", "Can't save configuration file '%s'"), $this->confFile), 500); return TRUE; @@ -232,7 +232,7 @@ class config $phpcode .= "),\r\n"; } else - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Config : missing type ").gettype ($val), 500); } @@ -382,7 +382,7 @@ class config var_export ($val, true).";\n"; } 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'"), $this->confFile), 500); // The next command clear the include cache file and force the PHP to @@ -428,10 +428,10 @@ class config $reflector = new ReflectionClass (get_class ($this)); $modelFile = $reflector->getFileName(); if (! file_exists ($modelFile)) - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "The configuration model file is missing"), 500); if (! is_readable ($modelFile)) - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "The configuration model file is not readable"), 500); $filecontent = file_get_contents ($modelFile); @@ -440,7 +440,7 @@ class config $parenthesis = 0; $params = array (); $path = ""; - $group = dgettext("domframework", "Default parameters"); + $group = dgettext ("domframework", "Default parameters"); foreach ($tokens as $token) { if (is_array ($token)) @@ -474,7 +474,7 @@ class config if (! isset ($data["param"])) continue; 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); $data["depth"] = $parenthesis; $data["group"] = $group; diff --git a/csrf.php b/csrf.php index 61c6903..56d0876 100644 --- a/csrf.php +++ b/csrf.php @@ -67,18 +67,18 @@ class csrf return TRUE; if (! isset ($_SESSION["domframework"]["csrf"]["csrf"])) { - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "No previous CSRF token : abort"), 406); } if ($_SESSION["domframework"]["csrf"]["csrf"] !== $tokenFromUser) { - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Invalid CSRF token provided"), 406); } if (($_SESSION["domframework"]["csrf"]["csrfStart"] + $this->csrfTimeout) < microtime (TRUE)) { - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Obsolete CSRF token provided"), 406); } return TRUE; diff --git a/dbjson.php b/dbjson.php index 84c677e..3b353d6 100644 --- a/dbjson.php +++ b/dbjson.php @@ -38,32 +38,32 @@ class dbjson 500); $pos = strpos ($dsn, "://"); if ($pos === false) - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "No DSN provided to dbjson"), 500); if (substr ($dsn, 0, $pos) !== "dbjson") - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Invalid database type provided in dbjson"), 500); $this->dbfile = substr ($dsn, $pos+3); $directory = dirname ($this->dbfile); if (! file_exists ($directory)) @mkdir ($directory, 0777, true); if (! file_exists ($directory)) - throw new \Exception (sprintf (dgettext("domframework", + throw new \Exception (sprintf (dgettext ("domframework", "Directory '%s' doesn't exists"), $directory), 500); if (! file_exists ($this->dbfile)) { if (! is_readable ($directory)) throw new \Exception (sprintf ( - dgettext("domframework", + dgettext ("domframework", "Directory '%s' not writeable and dbfile '%s' not exists"), $directory, $this->dbfile), 500); touch ($this->dbfile); } if (! is_readable ($this->dbfile)) - throw new \Exception(sprintf (dgettext("domframework", + throw new \Exception(sprintf (dgettext ("domframework", "File '%s' not readable"), $this->dbfile), 500); if (! is_writeable ($this->dbfile)) - throw new \Exception(sprintf (dgettext("domframework", + throw new \Exception(sprintf (dgettext ("domframework", "File '%s' not readable"), $this->dbfile), 500); $this->dsn = $dsn; $this->dbfile = $this->dbfile; diff --git a/dblayer.php b/dblayer.php index 5e486d3..7f72a10 100644 --- a/dblayer.php +++ b/dblayer.php @@ -133,10 +133,10 @@ class dblayer $driver = @explode (":", $dsn); if (! isset ($driver[0])) - throw new Exception (dgettext("domframework", "No valid DSN provided"), + throw new \Exception (dgettext ("domframework", "No valid DSN provided"), 500); if (! in_array ($driver[0], pdo_drivers ())) - throw new \Exception (sprintf (dgettext("domframework", + throw new \Exception (sprintf (dgettext ("domframework", "Driver PDO '%s' not available in PHP"), $driver[0]), 500); // Force specifics initialisations @@ -147,11 +147,11 @@ class dblayer // Look at the right to write in database and in the directory $file = substr ($dsn, 7); if (! is_writeable (dirname ($file))) - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "The directory for SQLite database is write protected"), 500); if (file_exists ($file) && ! is_writeable ($file)) - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "The SQLite database file is write protected"), 500); if (function_exists ("posix_getuid") && @@ -170,9 +170,9 @@ class dblayer self::$instance[$this->dsn]->setAttribute (PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } - catch (Exception $e) + catch (\Exception $e) { - throw new Exception ("PDO error : ".$e->getMessage(), 500); + throw new \Exception ("PDO error : ".$e->getMessage(), 500); } } @@ -192,9 +192,9 @@ class dblayer self::$instance[$this->dsn]->setAttribute (PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } - catch (Exception $e) + catch (\Exception $e) { - throw new Exception ("PDO error : ".$e->getMessage(), 500); + throw new \Exception ("PDO error : ".$e->getMessage(), 500); } } @@ -213,9 +213,9 @@ class dblayer self::$instance[$this->dsn]->setAttribute (PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } - catch (Exception $e) + catch (\Exception $e) { - throw new Exception ("PDO error : ".$e->getMessage(), 500); + throw new \Exception ("PDO error : ".$e->getMessage(), 500); } } @@ -224,7 +224,7 @@ class dblayer $this->sep = "\""; break; default: - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Unknown PDO driver provided"), 500); } return self::$instance[$this->dsn]; @@ -235,7 +235,7 @@ class dblayer public function databasename () { if ($this->sep === "") - throw new Exception (dgettext("domframework", "Database not connected"), + throw new \Exception (dgettext ("domframework", "Database not connected"), 500); $vals = explode (";", substr (strstr ($this->dsn, ":"), 1)); $dsnExplode = array (); @@ -254,7 +254,7 @@ class dblayer public function listTables () { if ($this->sep === "") - throw new Exception (dgettext("domframework", "Database not connected"), + throw new \Exception (dgettext ("domframework", "Database not connected"), 500); switch (self::$instance[$this->dsn]->getAttribute(PDO::ATTR_DRIVER_NAME)) { @@ -287,7 +287,7 @@ class dblayer $res[] = $d["tablename"]; break; default: - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Unknown database driver in listTables"), 500); } return $res; @@ -313,14 +313,14 @@ class dblayer $data[$key] = null; if (in_array ("not null", $params) && !array_key_exists ($key, $data)) { - $errors[$key] = array ("error", sprintf (dgettext("domframework", + $errors[$key] = array ("error", sprintf (dgettext ("domframework", "Mandatory field '%s' not provided"), $key)); continue; } if (in_array ("not null", $params) && $data[$key] === "") { - $errors[$key] = array ("error", sprintf (dgettext("domframework", + $errors[$key] = array ("error", sprintf (dgettext ("domframework", "Mandatory field '%s' is empty"), $key)); continue; @@ -336,7 +336,7 @@ class dblayer if (is_array ($verify) && count ($verify)) { $errors[$key] = array ($verify[0], $verify[1]); - //." ". dgettext("domframework","in")." ".$key); + //." ". dgettext ("domframework","in")." ".$key); continue; } @@ -349,7 +349,7 @@ class dblayer elseif (! is_string ($data[$key]) && ! is_integer ($data[$key])) { $errors[$key] = array ("error", sprintf ( - dgettext("domframework", + dgettext ("domframework", "Errors in consistency : '%s' is not an integer or a string [is %s]"), $key, gettype ($data[$key]))); continue; @@ -359,7 +359,7 @@ class dblayer if (strspn ($data[$key], "0123456789") !== strlen ($data[$key])) { $errors[$key] = array ("error", sprintf ( - dgettext("domframework", + dgettext ("domframework", "Errors in consistency : '%s' is not an integer"), $key)); continue; @@ -370,7 +370,7 @@ class dblayer if (! isset ($params[1])) { $errors[$key] = array ("error", sprintf ( - dgettext("domframework", + dgettext ("domframework", "The length of varchar field '%s' is not provided"), $key)); continue; @@ -378,7 +378,7 @@ class dblayer if (mb_strlen ($data[$key]) > $params[1]) { $errors[$key] = array ("error", sprintf ( - dgettext("domframework", + dgettext ("domframework", "Errors in consistency : '%s' data is too long"), $key)); continue; @@ -391,7 +391,7 @@ class dblayer if (!$d || $d->format("Y-m-d H:i:s") !== $data[$key]) { $errors[$key] = array ("error", sprintf ( - dgettext("domframework", + dgettext ("domframework", "Incorrect datetime provided for field '%s'"), $key)); continue; @@ -404,7 +404,7 @@ class dblayer if (!$d || $d->format("Y-m-d") !== $data[$key]) { $errors[$key] = array ("error", sprintf ( - dgettext("domframework", + dgettext ("domframework", "Incorrect date provided for field '%s'"), $key)); continue; @@ -412,7 +412,7 @@ class dblayer } elseif ($data[$key] !== "") { - $errors[$key] = array ("error", sprintf (dgettext("domframework", + $errors[$key] = array ("error", sprintf (dgettext ("domframework", "Unknown field type for '%s'"), $key)); continue; } @@ -445,7 +445,7 @@ class dblayer // 1. Read the actual state $before = $this->read (array (array ($this->primary, $updatekey))); if (count ($before) === 0) - return array ("error", dgettext("domframework", + return array ("error", dgettext ("domframework", "Entry to modify unavailable")); $before = reset ($before); // 2. Map the proposal entries into the before state @@ -469,7 +469,7 @@ class dblayer { if ($this->primary === null) { - return array (dgettext("domframework", + return array (dgettext ("domframework", "No field primary defined for tests in primary")); } @@ -491,7 +491,7 @@ class dblayer $rc = $this->read ($select, array ($this->primary)); if (count ($rc) > 0) { - $errors[] = array ("error", dgettext("domframework", + $errors[] = array ("error", dgettext ("domframework", "An entry with these values already exists")); continue; } @@ -513,7 +513,7 @@ class dblayer array ($this->primary)); if (count ($rc) > 0) { - $errors[] = array ("error", dgettext("domframework", + $errors[] = array ("error", dgettext ("domframework", "An entry with this value already exists")); continue; } @@ -530,14 +530,14 @@ class dblayer if ($this->debug) echo " verify foreign $foreign\n"; if (! isset ($data[$foreign])) { - $errors[] = array ("error", sprintf (dgettext("domframework", + $errors[] = array ("error", sprintf (dgettext ("domframework", "The foreign column '%s' is not provided"), $foreign)); return $errors; } if (! isset ($data[$foreign][0])) { - $errors[] = array ("error", sprintf (dgettext("domframework", + $errors[] = array ("error", sprintf (dgettext ("domframework", "The field type for column '%s' is not provided"), $foreign)); return $errors; @@ -573,7 +573,7 @@ class dblayer $st->bindValue (":".md5 ($key), $val, PDO::PARAM_STR); else { - throw new Exception ("TO BE DEVELOPPED : ".$this->fields[$foreign][0], + throw new \Exception ("TO BE DEVELOPPED : ".$this->fields[$foreign][0], 500); } $st->execute (); @@ -582,7 +582,7 @@ class dblayer $res[] = $d; if (count ($res) === 0) { - $errors[] = array ("error", sprintf (dgettext("domframework", + $errors[] = array ("error", sprintf (dgettext ("domframework", "The foreign key '%s' doesn't exists"), $column)); continue; @@ -598,20 +598,20 @@ class dblayer { if ($this->debug) echo "== Entering insert\n"; if ($this->sep === "") - throw new Exception (dgettext("domframework", "Database not connected"), + throw new \Exception (dgettext ("domframework", "Database not connected"), 500); if ($this->table === null) - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "No table name defined to insert in the table"), 500); if ($this->unique === null) - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Unique fields of table are not defined"), 500); if (! is_array ($this->unique)) - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "The unique configuration is not an array"), 500); if (!is_array ($data)) - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "The data provided to create are not array"), 405); foreach ($this->fields as $key=>$params) @@ -628,7 +628,7 @@ class dblayer $errors = reset ($errors); if (! is_array ($errors)) $errors = array (0=>"error", 1=>$errors); - throw new Exception ($errors[1], 405); + throw new \Exception ($errors[1], 405); } foreach ($this->fields as $field=>$desc) { @@ -663,14 +663,15 @@ class dblayer elseif ($this->fields[$key][0] === "date") $st->bindValue (":".md5 ($key), $val, PDO::PARAM_STR); else - throw new Exception ("TO BE DEVELOPPED : ".$this->fields[$key][0], 500); + throw new \Exception ("TO BE DEVELOPPED : ".$this->fields[$key][0], + 500); } try { $st->execute (); } - catch (Exception $e) + catch (\Exception $e) { echo "dblayer execute exception : ".$e->getMessage()."\n"; exit; @@ -709,21 +710,21 @@ class dblayer { if ($this->debug) echo "== Entering read\n"; if ($this->sep === "") - throw new Exception (dgettext("domframework", "Database not connected"), + throw new \Exception (dgettext ("domframework", "Database not connected"), 500); if ($this->table === null) - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "No table name defined to read the table"), 500); if ($select !== null && !is_array ($select)) - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Select information provided is not an array"), 405); if ($display !== null && !is_array ($display)) - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Display information provided is not an array"), 405); if ($order !== null && !is_array ($order)) - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Order information provided is not an array"), 405); if ($display !== null) @@ -731,7 +732,7 @@ class dblayer foreach ($display as $f) { if (!in_array ($f, array_keys ($this->fields))) - throw new Exception (sprintf (dgettext("domframework", + throw new \Exception (sprintf (dgettext ("domframework", "Field '%s' not allowed"), $f), 500); } } @@ -763,14 +764,14 @@ class dblayer foreach ($select as $n=>$s) { if (! is_array ($s)) - throw new Exception ("Select not an array for element $n", 500); + throw new \Exception ("Select not an array for element $n", 500); // The foreign keys can not be in the select too (conflict) if (in_array ($s[0],$foreignSelectCols)) continue; if (! array_key_exists (0, $s)) - throw new Exception ("Select field for key $n not provided", 406); + throw new \Exception ("Select field for key $n not provided", 406); if (! array_key_exists (1, $s)) - throw new Exception ("Select value for key $n not provided", 406); + throw new \Exception ("Select value for key $n not provided", 406); if ($n > 0) { if ($whereOr === false) @@ -781,7 +782,7 @@ class dblayer if (!isset ($s[2])) $s[2] = "="; if (!isset ($s[0])) - throw new Exception (sprintf (dgettext("domframework", + throw new \Exception (sprintf (dgettext ("domframework", "Select not found for id=%d"), $n), 500); // The double-quotes are added for sqlite to escape the column if its // name is 'group' @@ -803,9 +804,9 @@ class dblayer foreach ($foreignSelect as $n=>$s) { if (! array_key_exists (0, $s)) - throw new Exception ("Foreign field for key $n not provided", 406); + throw new \Exception ("Foreign field for key $n not provided", 406); if (! array_key_exists (1, $s)) - throw new Exception ("Foreign value for key $n not provided", 406); + throw new \Exception ("Foreign value for key $n not provided", 406); if ($n > 0) { $req .= " AND"; @@ -837,11 +838,11 @@ class dblayer { $st = self::$instance[$this->dsn]->prepare ($req); } - catch (Exception $e) + catch (\Exception $e) { if ($this->debug) echo "DEBUG : PREPARE ERROR ! Return FALSE". $e->getMessage()."\n"; - throw new Exception ($e->getMessage(), 500); + throw new \Exception ($e->getMessage(), 500); } if ($select !== NULL) @@ -890,18 +891,19 @@ class dblayer { if ($this->debug) echo "== Entering update\n"; if ($this->sep === "") - throw new Exception (dgettext("domframework", "Database not connected"), + throw new \Exception (dgettext ("domframework", "Database not connected"), 500); if ($this->table === null) - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "No table name defined to update in the table"), 500); if (count ($this->fields) === 0) - throw new Exception (dgettext("domframework", "No Field defined"), 500); + throw new \Exception (dgettext ("domframework", "No Field defined"), 500); if ($this->primary === null) - throw new Exception (dgettext("domframework", "No Primary defined"), 500); + throw new \Exception (dgettext ("domframework", "No Primary defined"), + 500); if (count ($data) === 0) - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "No data to update provided"), 500); $dataOK = array (); $errors = $this->verify ($data, $updatekey); @@ -910,11 +912,11 @@ class dblayer if (is_array ($errors)) { if (isset ($errors[0][1])) - throw new Exception ($errors[0][1], 405); + throw new \Exception ($errors[0][1], 405); $err = reset ($errors); - throw new Exception ($err[1], 405); + throw new \Exception ($err[1], 405); } - throw new Exception ($errors[1], 405); + throw new \Exception ($errors[1], 405); } foreach ($this->fields as $field=>$desc) { @@ -973,7 +975,7 @@ class dblayer else { if ($this->debug) echo "(UNKNOWN)\n"; - throw new Exception ("TO BE DEVELOPPED : ".$fields[$key][0], 500); + throw new \Exception ("TO BE DEVELOPPED : ".$fields[$key][0], 500); } } @@ -992,9 +994,10 @@ class dblayer { if ($this->debug) echo "== Entering delete\n"; if ($this->sep === "") - throw new Exception (dgettext("domframework", "Database not connected")); + throw new \Exception (dgettext ("domframework", "Database not connected"), + 500); if ($this->table === null) - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "No table name defined to delete in the table"), 500); $deletekey = call_user_func ($this->hookpredeleteFunc, $deletekey); @@ -1009,7 +1012,7 @@ class dblayer { $st->execute (); } - catch (Exception $e) + catch (\Exception $e) { throw new \Exception ($e->getMessage (), 500); } @@ -1025,7 +1028,7 @@ class dblayer { if ($this->debug) echo "== Entering titles\n"; if (count ($this->fields) === 0) - throw new Exception (dgettext("domframework", "No Field defined"), 500); + throw new \Exception (dgettext ("domframework", "No Field defined"), 500); $arr = array (); if (count ($this->titles) !== 0) { @@ -1046,9 +1049,10 @@ class dblayer { if ($this->debug) echo "== Entering dropTables\n"; if ($this->sep === "") - throw new Exception (dgettext("domframework", "Database not connected")); + throw new \Exception (dgettext ("domframework", "Database not connected"), + 500); if ($this->table === null) - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "No table name defined to drop the table"), 500); $sql = "DROP TABLE $this->sep$this->tableprefix$this->table$this->sep"; if ($this->debug) @@ -1076,12 +1080,12 @@ class dblayer { if ($this->debug) echo "== Entering createTable\n"; if ($this->sep === "") - throw new Exception (dgettext("domframework", "Database not connected"), + throw new \Exception (dgettext ("domframework", "Database not connected"), 500); if (count ($this->fields) === 0) - throw new Exception (dgettext("domframework", "No Field defined"), 500); + throw new \Exception (dgettext ("domframework", "No Field defined"), 500); if ($this->table === null) - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "No table name defined to create the table"), 500); switch (self::$instance[$this->dsn]->getAttribute(PDO::ATTR_DRIVER_NAME)) { @@ -1098,8 +1102,8 @@ class dblayer $sql .= "$this->sep$field$this->sep "; // Type of field : in $params[0] if (!isset ($params[0])) - throw new Exception (sprintf ( - dgettext("domframework", + throw new \Exception (sprintf ( + dgettext ("domframework", "No database type defined for field '%s'"), $field), 500); @@ -1111,7 +1115,7 @@ class dblayer break; case "varchar": if (!isset ($params[1])) - throw new Exception (sprintf (dgettext("domframework", + throw new \Exception (sprintf (dgettext ("domframework", "No Size provided for varchar field '%s'"), $field), 500); $sql .= "VARCHAR(".$params[1].")"; @@ -1126,8 +1130,8 @@ class dblayer $params = array_slice ($params, 1); break; default: - throw new Exception (sprintf ( - dgettext("domframework", + throw new \Exception (sprintf ( + dgettext ("domframework", "Unknown type '%s' provided for field '%s'"), $params[0], $field), 500); } @@ -1145,7 +1149,7 @@ class dblayer case "not null": $sql .= " NOT NULL"; break; case "autoincrement": $sql .= " AUTOINCREMENT";break; default: - throw new Exception (sprintf (dgettext("domframework", + throw new \Exception (sprintf (dgettext ("domframework", "Unknown additionnal parameter for field '%s'"), $field), 500); } @@ -1156,7 +1160,7 @@ class dblayer if ($this->unique !== null) { if (!is_array ($this->unique)) - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "The Unique field definition is not an array"), 500); foreach ($this->unique as $u) @@ -1195,7 +1199,7 @@ class dblayer $sql .= "$this->sep$field$this->sep "; // Type of field : in $params[0] if (!isset ($params[0])) - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "No database type defined for field"), 500); switch ($params[0]) { @@ -1205,7 +1209,7 @@ class dblayer break; case "varchar": if (!isset ($params[1])) - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "No Size provided for varchar field"), 500); $sql .= "VARCHAR(".$params[1].")"; $params = array_slice ($params, 2); @@ -1219,8 +1223,8 @@ class dblayer $params = array_slice ($params, 1); break; default: - throw new Exception (sprintf ( - dgettext("domframework", + throw new \Exception (sprintf ( + dgettext ("domframework", "Unknown type provided for field '%s'"), $field), 500); } @@ -1238,8 +1242,8 @@ class dblayer case "not null": $sql .= " NOT NULL"; break; case "autoincrement": $sql .= " AUTO_INCREMENT";break; default: - throw new Exception (sprintf ( - dgettext("domframework", + throw new \Exception (sprintf ( + dgettext ("domframework", "Unknown additionnal parameter for field '%s'"), $field), 500); } @@ -1290,8 +1294,8 @@ class dblayer { // Type of field : in $params[0] if (!isset ($params[0])) - throw new Exception (sprintf ( - dgettext("domframework", + throw new \Exception (sprintf ( + dgettext ("domframework", "No database type defined for field '%s'"), $field), 500); switch ($params[0]) @@ -1302,8 +1306,8 @@ class dblayer break; case "varchar": if (!isset ($params[1])) - throw new Exception (sprintf ( - dgettext("domframework", + throw new \Exception (sprintf ( + dgettext ("domframework", "No Size provided for varchar field '%s'"), $field), 500); $sql .= "VARCHAR(".$params[1].")"; @@ -1318,8 +1322,8 @@ class dblayer $params = array_slice ($params, 1); break; default: - throw new Exception (sprintf ( - dgettext("domframework", + throw new \Exception (sprintf ( + dgettext ("domframework", "Unknown type provided for field '%s'"), $field), 500); } @@ -1336,8 +1340,8 @@ class dblayer { case "not null": $sql .= " NOT NULL"; break; default: - throw new Exception (sprintf ( - dgettext("domframework", + throw new \Exception (sprintf ( + dgettext ("domframework", "Unknown additionnal parameter for field '%s'"), $field), 500); } @@ -1373,7 +1377,7 @@ class dblayer $sql .=")"; break; default: - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "PDO Engine not supported in dbLayer"), 500); } diff --git a/dblayeroo.php b/dblayeroo.php index 4490830..9bb63f5 100644 --- a/dblayeroo.php +++ b/dblayeroo.php @@ -336,12 +336,12 @@ class dblayeroo { $this->debugLog ("Entering createTable"); if ($this->sep === "") - $this->DBException (dgettext("domframework", "Database not connected"), + $this->DBException (dgettext ("domframework", "Database not connected"), 500); if (count ($this->fields) === 0) - $this->DBException (dgettext("domframework", "No Field defined"), 500); + $this->DBException (dgettext ("domframework", "No Field defined"), 500); if ($this->table === null) - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "No table name defined to create the table"), 500); switch (self::$instance[$this->dsn]->getAttribute(\PDO::ATTR_DRIVER_NAME)) { @@ -381,7 +381,7 @@ class dblayeroo break; default: $this->DBException (sprintf ( - dgettext("domframework", + dgettext ("domframework", "Unknown type '%s' provided for field '%s'"), $this->fieldTypeLight ($field), $field), 500); } @@ -400,13 +400,13 @@ class dblayeroo case "autoincrement": if ($this->primary !== $field) throw new \Exception (sprintf ( - dgettext("domframework", + dgettext ("domframework", "Field '%s' is autoincrement but not primary"), $field), 500); $sql .= " AUTOINCREMENT"; break; default: - $this->DBException (sprintf (dgettext("domframework", + $this->DBException (sprintf (dgettext ("domframework", "Unknown additionnal parameter '%s' for field '%s'"), $p, $field), 500); } @@ -417,7 +417,7 @@ class dblayeroo if ($this->unique !== null) { if (!is_array ($this->unique)) - $this->DBException (dgettext("domframework", + $this->DBException (dgettext ("domframework", "The Unique field definition is not an array"), 500); foreach ($this->unique as $u) @@ -483,7 +483,7 @@ class dblayeroo break; default: $this->DBException (sprintf ( - dgettext("domframework", + dgettext ("domframework", "Unknown type provided for field '%s'"), $field), 500); } @@ -502,14 +502,14 @@ class dblayeroo case "autoincrement": if ($this->primary !== $field) throw new \Exception (sprintf ( - dgettext("domframework", + dgettext ("domframework", "Field '%s' is autoincrement but not primary"), $field), 500); $sql .= " AUTO_INCREMENT"; break; default: $this->DBException (sprintf ( - dgettext("domframework", + dgettext ("domframework", "Unknown additionnal '%s' parameter for field '%s'"), $p, $field), 500); } @@ -560,7 +560,7 @@ class dblayeroo { if ($this->primary !== $field) throw new \Exception (sprintf ( - dgettext("domframework", + dgettext ("domframework", "Field '%s' is autoincrement but not primary"), $field), 500); $sql .= "SERIAL"; @@ -592,7 +592,7 @@ class dblayeroo break; default: $this->DBException (sprintf ( - dgettext("domframework", + dgettext ("domframework", "Unknown type provided for field '%s'"), $field), 500); } @@ -610,7 +610,7 @@ class dblayeroo case "not null": $sql .= " NOT NULL"; break; default: $this->DBException (sprintf ( - dgettext("domframework", + dgettext ("domframework", "Unknown additionnal parameter '%s' for field '%s'"), $p, $field), 500); } @@ -648,7 +648,7 @@ class dblayeroo $sql .=")"; break; default: - $this->DBException (dgettext("domframework", + $this->DBException (dgettext ("domframework", "PDO Engine not supported in dbLayeroo"), 500); } @@ -664,9 +664,9 @@ class dblayeroo { $this->debugLog ("Entering dropTable ()"); if ($this->sep === "") - $this->DBException (dgettext("domframework", "Database not connected")); + $this->DBException (dgettext ("domframework", "Database not connected")); if ($this->table === null) - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "No table name defined to drop the table"), 500); $sql = "DROP TABLE $this->sep$this->tableprefix$this->table$this->sep"; $this->debugLog ($sql); @@ -1024,7 +1024,7 @@ class dblayeroo "foreignUsed" => $foreignUsed); break; default: - $this->DBException (dgettext("domframework", + $this->DBException (dgettext ("domframework", "PDO Engine not supported in dbLayeroo"), 500); } } diff --git a/form.php b/form.php index 5a3c13d..b61f18f 100644 --- a/form.php +++ b/form.php @@ -229,7 +229,7 @@ class form { $this->loggingCallable (LOG_ERR, "Unknown FORM method (GET or POST allowed)"); - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Unknown FORM method (GET or POST allowed)")); } @@ -243,7 +243,7 @@ class form catch (\Exception $e) { $this->loggingCallable (LOG_ERR, $e->getMessage ()); - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Can not read the data from the form : ". "Expired or missing CSRF Token"), 500); } @@ -453,7 +453,7 @@ class form if ($field->mandatory !== null && (! array_key_exists ($field->name, $values) || trim ($values[$field->name]) === "")) - $errors[$field->name] = dgettext("domframework", + $errors[$field->name] = dgettext ("domframework", "Field mandatory and not provided"); } return $errors; @@ -1173,7 +1173,7 @@ class formfield } else { - $res .= dgettext("domframework", "No value provided"); + $res .= dgettext ("domframework", "No value provided"); } $res .= " \n"; // End controls diff --git a/fts.php b/fts.php index 5dbfa5c..d738a6e 100644 --- a/fts.php +++ b/fts.php @@ -97,9 +97,8 @@ class fts foreach ($fields as $field) { if (! array_key_exists ($field, $dbl->fields ())) - throw new \Exception (sprintf ( - dgettext("domframework", "The field '%s' doesn't exists in database"), - $field), 500); + throw new \Exception (sprintf (dgettext ("domframework", + "The field '%s' doesn't exists in database"), $field), 500); if ($i > 0) $dbl->whereAddOR (); $dbl->whereAddParenthesisOpen (); diff --git a/imap.php b/imap.php index 54299c8..2cd5aec 100644 --- a/imap.php +++ b/imap.php @@ -603,7 +603,7 @@ class imap strtolower ($struct2->subtype); else throw new \Exception (sprintf ( - dgettext("domframework", + dgettext ("domframework", "Unknown type in imap_fetchstructure : %s"), $struct2->type), 500); } @@ -649,7 +649,7 @@ class imap strtolower ($struct1->subtype); else throw new \Exception (sprintf ( - dgettext("domframework", + dgettext ("domframework", "Unknown type in imap_fetchstructure : %s"), $struct1->type), 500); } diff --git a/inifile.php b/inifile.php index 4f1ec53..da8d125 100644 --- a/inifile.php +++ b/inifile.php @@ -17,10 +17,10 @@ class inifile public function getFile ($file, $sections=false) { if (! file_exists ($file)) - throw new \Exception (sprintf (dgettext("domframework", + throw new \Exception (sprintf (dgettext ("domframework", "File '%s' not found"), $file), 404); if (! is_readable ($file)) - throw new \Exception (sprintf (dgettext("domframework", + throw new \Exception (sprintf (dgettext ("domframework", "File '%s' not readable"), $file), 500); return $this->getString (file_get_contents ($file, $sections)); } @@ -75,7 +75,7 @@ class inifile { if (! is_array ($array)) throw new \Exception ( - dgettext("domframework", + dgettext ("domframework", "inifile::setString : provided data is not an array"), 500); $content = ""; @@ -85,7 +85,7 @@ class inifile { if (! is_array ($sub)) throw new \Exception ( - dgettext("domframework", + dgettext ("domframework", "inifile::setString : provided data is not an array"), 500); $content .= "[$section]\n"; @@ -97,7 +97,7 @@ class inifile { if (!is_scalar ($v) && ! is_null ($v)) throw new \Exception (sprintf ( - dgettext("domframework", + dgettext ("domframework", "Provided value for '%s' is not scalar"), $key), 500); if ($v === null) $v = "null"; @@ -123,7 +123,7 @@ class inifile { if (!is_scalar ($v) && ! is_null ($v)) throw new \Exception (sprintf ( - dgettext("domframework", + dgettext ("domframework", "Provided value for '%s' is not scalar"), $key), 500); if ($v === null) $v = "null"; @@ -155,11 +155,11 @@ class inifile $dir = basename ($file); if (! file_exists ($dir) || ! is_readable ($dir) || ! is_writeable ($dir)) throw new \Exception (sprintf ( - dgettext("domframework", + dgettext ("domframework", "Directory '%s' available or not readable or not writeable"), $dir), 500); if (file_exists ($file) && ! is_writeable ($file)) - throw new \Exception (sprintf (dgettext("domframework", + throw new \Exception (sprintf (dgettext ("domframework", "File '%s' is not writeable"), $file), 500); $content = $this->setString ($array, $sections); diff --git a/ipaddresses.php b/ipaddresses.php index fae63e3..8fb8ef7 100644 --- a/ipaddresses.php +++ b/ipaddresses.php @@ -12,7 +12,7 @@ class ipaddresses public function validIPAddress ($ip) { if (!is_string ($ip) || $ip === "") - throw new \Exception (dgettext("domframework", "Invalid IP address"), + throw new \Exception (dgettext ("domframework", "Invalid IP address"), 500); $rc = $this->validIPv4Address ($ip); if ($rc === TRUE) @@ -27,7 +27,7 @@ class ipaddresses public function validIPv4Address ($ip) { if (!is_string ($ip) || $ip === "") - throw new \Exception (dgettext("domframework", "Invalid IPv4 address"), + throw new \Exception (dgettext ("domframework", "Invalid IPv4 address"), 500); $rc = filter_var ($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4); if ($rc ===FALSE) @@ -41,7 +41,7 @@ class ipaddresses public function validIPv6Address ($ip) { if (!is_string ($ip) || $ip === "") - throw new \Exception (dgettext("domframework", "Invalid IPv6 address"), + throw new \Exception (dgettext ("domframework", "Invalid IPv6 address"), 500); $rc = filter_var ($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6); if ($rc ===FALSE) @@ -56,7 +56,7 @@ class ipaddresses public function validIPAddressWithCIDR ($ip) { if (!is_string ($ip) || $ip === "") - throw new \Exception (dgettext("domframework", "Invalid IP address"), + throw new \Exception (dgettext ("domframework", "Invalid IP address"), 500); $rc = $this->validIPv4AddressWithCIDR ($ip); if ($rc === true) @@ -72,7 +72,7 @@ class ipaddresses public function validIPv4AddressWithCIDR ($ip) { if (!is_string ($ip) || $ip === "") - throw new \Exception (dgettext("domframework", "Invalid IPv4 address"), + throw new \Exception (dgettext ("domframework", "Invalid IPv4 address"), 500); @list ($ip, $cidr) = @explode ("/", $ip); if ($cidr === null) @@ -92,7 +92,7 @@ class ipaddresses public function validIPv6AddressWithCIDR ($ip) { if (!is_string ($ip) || $ip === "") - throw new \Exception (dgettext("domframework", "Invalid IPv6 address"), + throw new \Exception (dgettext ("domframework", "Invalid IPv6 address"), 500); @list ($ip, $cidr) = @explode ("/", $ip); if ($cidr === null) @@ -112,7 +112,7 @@ class ipaddresses public function validCIDR ($cidr) { if (! is_integer ($cidr) && ! is_integer ($cidr)) - throw new \Exception (dgettext("domframework", "Invalid CIDR provided"), + throw new \Exception (dgettext ("domframework", "Invalid CIDR provided"), 500); if (strspn ($cidr, "0123456879") !== strlen ($cidr)) return false; @@ -128,7 +128,7 @@ class ipaddresses public function validIPv4CIDR ($cidr) { if (! is_integer ($cidr) && ! is_string ($cidr)) - throw new \Exception (dgettext("domframework", "Invalid CIDR provided"), + throw new \Exception (dgettext ("domframework", "Invalid CIDR provided"), 500); if (strspn ($cidr, "0123456879") !== strlen ($cidr)) return false; @@ -144,7 +144,7 @@ class ipaddresses public function validIPv6CIDR ($cidr) { if (! is_integer ($cidr) && ! is_string ($cidr)) - throw new \Exception (dgettext("domframework", "Invalid CIDR provided"), + throw new \Exception (dgettext ("domframework", "Invalid CIDR provided"), 500); if (strspn ($cidr, "0123456879") !== strlen ($cidr)) return false; @@ -230,7 +230,7 @@ class ipaddresses { if (! is_string ($ip) || $ip === "" || $this->validIPAddress ($ip) === false) - throw new \Exception (dgettext("domframework", "Invalid IP address"), + throw new \Exception (dgettext ("domframework", "Invalid IP address"), 500); if (strstr ($ip,"::")) { @@ -284,10 +284,10 @@ class ipaddresses public function groupIPv6 ($ipv6) { if (! is_string ($ipv6) || $ipv6 === "") - throw new \Exception (dgettext("domframework", "Invalid IPv6 address"), + throw new \Exception (dgettext ("domframework", "Invalid IPv6 address"), 500); if (substr_count ($ipv6, ".") !== 31) - throw new \Exception (dgettext("domframework", "Invalid IPv6 address"), + throw new \Exception (dgettext ("domframework", "Invalid IPv6 address"), 500); $ipv6 = str_replace (".", "", $ipv6); $new = ""; @@ -314,7 +314,7 @@ class ipaddresses public function completeAddressWithZero ($ip) { if (! is_string ($ip) || $ip === "") - throw new \Exception (dgettext("domframework", "Invalid IP address"), + throw new \Exception (dgettext ("domframework", "Invalid IP address"), 500); $ip = $this->uncompressIPv6 ($ip); if (substr_count ($ip, ":") === 7) @@ -338,7 +338,7 @@ class ipaddresses // IPv4 return $ip; } - throw new \Exception (dgettext("domframework", "Invalid IP address"), 500); + throw new \Exception (dgettext ("domframework", "Invalid IP address"), 500); } /** Return the provided CIDR in binary. Length must be in bytes. @@ -349,9 +349,9 @@ class ipaddresses public function cidrToBin ($cidr, $length) { if (! is_numeric ($cidr) || $cidr < 0 || $cidr > 128) - throw new \Exception (dgettext("domframework", "Invalid CIDR"), 500); + throw new \Exception (dgettext ("domframework", "Invalid CIDR"), 500); if (! is_numeric ($length) || $length < 1 || $length > 16) - throw new \Exception (dgettext("domframework", "Invalid length"), 500); + throw new \Exception (dgettext ("domframework", "Invalid length"), 500); $val=""; for ( $i=0 ; $i<$length*8 ; $i++ ) { @@ -413,7 +413,7 @@ class ipaddresses function reverseIPAddress ($ipReverse) { if (!is_string ($ipReverse) || $ipReverse === "") - throw new \Exception (dgettext("domframework", "Invalid IP address"), + throw new \Exception (dgettext ("domframework", "Invalid IP address"), 500); $ipReverse = $this->completeAddressWithZero ($ipReverse); if (substr_count ($ipReverse, ":") === 7 && strlen ($ipReverse) == 39) @@ -439,7 +439,7 @@ class ipaddresses $ipnew = implode (".", $tmp2); return $ipnew; } - throw new \Exception (dgettext("domframework", "Invalid IP address"), 500); + throw new \Exception (dgettext ("domframework", "Invalid IP address"), 500); } /** This function return the CIDR associated to the provided netmask @@ -452,7 +452,7 @@ class ipaddresses { $netmask = ip2long ($netmask); if ($netmask === FALSE) - throw new \Exception (dgettext("domframework", "Invalid netmask"), 500); + throw new \Exception (dgettext ("domframework", "Invalid netmask"), 500); $netmask = decbin ($netmask); for ($i=0 ; $i<32 ; $i++) { @@ -474,26 +474,26 @@ class ipaddresses public function ipInNetwork ($ip, $network, $cidr) { if ($this->validIPAddress ($ip) === false) - throw new \Excpetion (dgettext("domframework", "Invalid IP address"), + throw new \Exception (dgettext ("domframework", "Invalid IP address"), 500); if ($this->validIPAddress ($network) === false) - throw new \Excpetion (dgettext("domframework", "Invalid Network address"), - 500); + throw new \Exception (dgettext ("domframework", + "Invalid Network address"), 500); $ipv4 = $this->validIPv4Address ($ip); $networkv4 = $this->validIPv4Address ($network); if ($ipv4 !== $networkv4) - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Network and IP address are not compatible"), 500); if ($ipv4 === true) { if ($this->validIPv4CIDR ($cidr) === false) - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "CIDR is not IPv4 compatible"), 500); } else { if ($this->validIPv6CIDR ($cidr) === false) - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "CIDR is not IPv6 compatible"), 500); } return ($this->networkFirstIP ($ip, $cidr) === @@ -536,19 +536,19 @@ class ipaddresses private function networkFirstLastIP ($ip, $cidr, $map) { if ($this->validIPAddress ($ip) === false) - throw new \Exception (dgettext("domframework", "Invalid IP address"), + throw new \Exception (dgettext ("domframework", "Invalid IP address"), 500); $ipv4 = $this->validIPv4Address ($ip); if ($ipv4 === true) { if ($this->validIPv4CIDR ($cidr) === false) - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "CIDR is not IPv4 compatible"), 500); } else { if ($this->validIPv6CIDR ($cidr) === false) - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "CIDR is not IPv6 compatible"), 500); } // Convert the IP and CIDR to binary string diff --git a/language.php b/language.php index 0a0fc91..fdfabe2 100644 --- a/language.php +++ b/language.php @@ -355,9 +355,9 @@ class language { switch ($languageCode) { - case "fr_FR": return dgettext("domframework", "French"); - case "en_US": return dgettext("domframework", "English (US)"); - case "en_GB": return dgettext("domframework", "English (GB)"); + case "fr_FR": return dgettext ("domframework", "French"); + case "en_US": return dgettext ("domframework", "English (US)"); + case "en_GB": return dgettext ("domframework", "English (GB)"); default: throw new \Exception ("No language available for '$languageCode'", 500); } diff --git a/mail.php b/mail.php index 99c8722..3dc82cf 100644 --- a/mail.php +++ b/mail.php @@ -109,7 +109,7 @@ class mail private function sectionAddChild ($sectionIDParent, $sectionIDchild) { if (! array_key_exists ($sectionIDParent, $this->sections)) - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Section parent not found"), 404); $this->sections[$sectionIDParent]["_partsIDchild"][] = $sectionIDchild; $this->sections[$sectionIDchild]["_parentID"] = $sectionIDParent; @@ -122,7 +122,7 @@ class mail private function sectionAddChildFirst ($sectionIDParent, $sectionIDchild) { if (! array_key_exists ($sectionIDParent, $this->sections)) - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Section parent not found"), 404); array_unshift ($this->sections[$sectionIDParent]["_partsIDchild"], $sectionIDchild); @@ -136,7 +136,7 @@ class mail private function sectionDelChilds ($sectionID) { if (! array_key_exists ($sectionID, $this->sections)) - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Section not found"), 404); unset ($this->sections[$sectionID]["_partsIDchild"]); } @@ -148,9 +148,10 @@ class mail private function sectionUpdate ($sectionID, $param) { if (! array_key_exists ($sectionID, $this->sections)) - throw new \Exception (dgettext("domframework", "Section not found"), 404); + throw new \Exception (dgettext ("domframework", "Section not found"), + 404); if (! is_array ($param)) - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Param provided to sectionUpdate is not array"), 406); foreach ($param as $key=>$val) { @@ -189,7 +190,7 @@ class mail private function sectionGet ($sectionID) { if (! array_key_exists ($sectionID, $this->sections)) - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Section not found"), 404); return $this->sections[$sectionID]; } @@ -264,7 +265,7 @@ class mail $boundaryCR = array_shift ($boundaryArray); } if ($boundary === false) - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Can't find boundary in multipart/"), 406); $boundary = substr ($boundary, 2); unset ($boundaryArray); @@ -433,10 +434,10 @@ class mail public function __construct () { if (! function_exists ("finfo_buffer")) - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Missing FileInfo PHP Extension"), 500); if (! function_exists ("openssl_random_pseudo_bytes")) - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Missing OpenSSL PHP Extension"), 500); // Define default headers $this->addHeader ("Date", date ("r")); @@ -532,7 +533,7 @@ class mail if ($sectionIDtoChange === "") { // No existing section found : need to create one - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Can't find the place to store the HTML"), 500); } $htmlContent = iconv ("utf-8", $charset, $htmlContent); @@ -618,7 +619,7 @@ class mail if ($sectionIDtoChange === "") { // No existing section found : need to create one - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Can't find the place to store the TEXT"), 500); } $textContent = iconv ("utf-8", $charset, $textContent); @@ -875,7 +876,7 @@ class mail { $attachmentIDs = $this->getAttachmentID ($inline); if (! array_key_exists ($number, $attachmentIDs)) - throw new \Exception (sprintf (dgettext("domframework", + throw new \Exception (sprintf (dgettext ("domframework", "Attachment '%d' not found"), $number), 404); $part = $this->sectionGet ($attachmentIDs[$number]); $encoding = $this->getHeaderValue ("Content-Transfer-Encoding", @@ -892,7 +893,7 @@ class mail { $attachmentIDs = $this->getAttachmentID ($inline); if (! array_key_exists ($number, $attachmentIDs)) - throw new \Exception (sprintf (dgettext("domframework", + throw new \Exception (sprintf (dgettext ("domframework", "Attachment '%d' not found"), $number), 404); $part = $this->sectionGet ($attachmentIDs[$number]); foreach ($part as $key=>$val) @@ -1428,7 +1429,7 @@ class mail return chunk_split ($content); } throw new \Exception (sprintf ( - dgettext("domframework", + dgettext ("domframework", "Invalid encoding provided to encodingEncode : %s"), $encoding), 500); } @@ -1447,7 +1448,7 @@ class mail elseif ($encoding === "8bit" || $encoding === "7bit" || $encoding === false) return $content; throw new \Exception (sprintf ( - dgettext("domframework", + dgettext ("domframework", "Invalid encoding provided to encodingDecode : '%s'"), $encoding), 500); } @@ -1468,7 +1469,7 @@ class mail elseif ($encoding === "base64") $prefs["scheme"] = "B"; else - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Invalid encoding provided to encodeHeaders"), 500); return substr (iconv_mime_encode ($header, $content, $prefs), strlen ($header)+2); @@ -1503,7 +1504,7 @@ class mail elseif ($encoding === "base64") $prefs["scheme"] = "B"; else - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Invalid encoding provided to encodeHeaderStringWithPosition"), 500); return substr (iconv_mime_encode (str_repeat (" ", $blanks), $content, $prefs), diff --git a/outputhtml.php b/outputhtml.php index 4c7c5d2..e29ae82 100644 --- a/outputhtml.php +++ b/outputhtml.php @@ -56,7 +56,7 @@ class outputhtml extends output $title = $resView["title"]; if (! isset ($resView["content"])) throw new \Exception (sprintf ( - dgettext("domframework", + dgettext ("domframework", "No data provided from view %s::%s"), $viewClass,$viewMethod), 500); diff --git a/outputjson.php b/outputjson.php index 8f5141d..502c967 100644 --- a/outputjson.php +++ b/outputjson.php @@ -29,7 +29,7 @@ class outputjson extends output @header ("Content-Type: application/json"); $content = json_encode ($data); if (json_last_error () !== 0) - printf (dgettext("domframework", "Can't send in JSON invalid data : %s"), + printf (dgettext ("domframework", "Can't send in JSON invalid data : %s"), json_last_error_msg ()); echo $content; if (!defined ("PHPUNIT")) diff --git a/queuefile.php b/queuefile.php index c9fac0f..c24e686 100644 --- a/queuefile.php +++ b/queuefile.php @@ -203,7 +203,7 @@ class queuefile extends queue if (! key_exists ($i, $entries)) { $file->lockUN ($this->queue); - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Invalid entry requested"), 406); } $json = $entries[$i]; diff --git a/ratelimit.php b/ratelimit.php index 93125c2..363833a 100644 --- a/ratelimit.php +++ b/ratelimit.php @@ -18,7 +18,7 @@ class ratelimit */ public function set ($name) { - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "ratelimit : no valid ratelimiter available"), 500); } @@ -29,7 +29,7 @@ class ratelimit */ public function del ($name) { - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "ratelimit : no valid ratelimiter available"), 500); } @@ -39,7 +39,7 @@ class ratelimit */ public function clean () { - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "ratelimit : no valid ratelimiter available"), 500); } diff --git a/ratelimitfile.php b/ratelimitfile.php index 9393510..ff3fd6a 100644 --- a/ratelimitfile.php +++ b/ratelimitfile.php @@ -30,7 +30,7 @@ class ratelimitfile extends ratelimit $user = posix_getpwuid (posix_getuid()); if (file_exists ($file) && ! is_writeable ($file)) throw new \Exception (sprintf ( - dgettext("domframework", + dgettext ("domframework", "File '%s' not writeable for user '%s'"), $file, $user["name"]), 500); file_put_contents ($file, $currentTimeStamp, FILE_APPEND); diff --git a/renderer.php b/renderer.php index 7e868c7..d6ed3b0 100644 --- a/renderer.php +++ b/renderer.php @@ -128,19 +128,19 @@ class renderer { case 4: $dataflash .= "alert-danger"; - $alert = dgettext("domframework", "Error!"); + $alert = dgettext ("domframework", "Error!"); break; case 3: $dataflash .= "alert-warning"; - $alert = dgettext("domframework", "Warning!"); + $alert = dgettext ("domframework", "Warning!"); break; case 2: $dataflash .= "alert-info"; - $alert = dgettext("domframework", "Info :"); + $alert = dgettext ("domframework", "Info :"); break; case 1: $dataflash .= "alert-success"; - $alert = dgettext("domframework", "Success : "); + $alert = dgettext ("domframework", "Success : "); break; } $dataflash .= " alert-dismissable'>\n"; diff --git a/route.php b/route.php index 270d4db..1746c49 100644 --- a/route.php +++ b/route.php @@ -604,7 +604,7 @@ class route $this->ratelimiter->set ("error-$ipClient") === false) { $getCode = 406; - $message = dgettext("domframework", "Too much error requests"); + $message = dgettext ("domframework", "Too much error requests"); } else { diff --git a/routeSQL.php b/routeSQL.php index ed16262..887434d 100644 --- a/routeSQL.php +++ b/routeSQL.php @@ -146,13 +146,13 @@ class routeSQL switch ($flash[0]) { case 4: $dataflash .= "alert-danger"; - $alert = dgettext("domframework","Error!");break; + $alert = dgettext ("domframework","Error!");break; case 3: $dataflash .= "alert-warning"; - $alert = dgettext("domframework","Warning!");break; + $alert = dgettext ("domframework","Warning!");break; case 2: $dataflash .= "alert-info"; - $alert = dgettext("domframework","Info:");break; + $alert = dgettext ("domframework","Info:");break; case 1: $dataflash .= "alert-success"; - $alert = dgettext("domframework","Success:");break; + $alert = dgettext ("domframework","Success:");break; } $dataflash .= " alert-dismissable'>\n"; $dataflash .= "$alert ".$flash[1]."\n"; @@ -246,7 +246,7 @@ $content .= "\n"; $route = new route (); $content .= "
\n"; $content .= " " - .dgettext("domframework","Add new entry")."\n"; + .dgettext ("domframework","Add new entry")."\n"; $content .= "
\n"; } return $content; @@ -275,7 +275,7 @@ $content .= "\n"; $content .= ">$element\n"; } $content .= " \n"; - $content .= " ".dgettext("domframework","elements")."\n"; + $content .= " ".dgettext ("domframework","elements")."\n"; $content .= " \n"; $content .= " \n"; return $content; @@ -294,7 +294,7 @@ $content .= "\n"; $content .= "
\n"; $content .= "
\n"; - $content .= " ".dgettext("domframework","Search:"); + $content .= " ".dgettext ("domframework","Search:"); $content .= " \n"; $content .= "
\n"; @@ -312,7 +312,7 @@ $content .= "\n"; { $content = ""; $content .= "
\n"; - $message = dgettext("domframework", + $message = dgettext ("domframework", "Display the element {FIRST} to {LAST} on {COUNT} elements"); if ($nbentries === 0) $message = str_replace ("{FIRST}", 0, $message); @@ -344,24 +344,24 @@ $content .= "\n"; TRUE) { if ($this->authREST["email"] === "anonymous") - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Anonymous not allowed"), 401); - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Access forbidden"), 403); } $this->chained->connect(); // $chainedValues are the information associated to the $chain $chainedValues = $this->chained->keyexists ($chain); if ($chainedValues === false) - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Object not found"), 404); } if ($this->accessright ($this->authREST["email"]) !== TRUE) { if ($this->authREST["email"] === "anonymous") - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Anonymous not allowed"), 401); - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Access forbidden"), 403); } @@ -372,7 +372,7 @@ $content .= "\n"; if (!isset ($extension) || $extension === null || $extension === "") $extension = reset ($this->extensionsAllowed); if (!in_array ($extension, $this->extensionsAllowed)) - throw new Exception (dgettext("domframework","Extension not allowed"), + throw new \Exception (dgettext ("domframework","Extension not allowed"), 403); $search = rawurldecode ($search); $this->connect(); @@ -423,39 +423,42 @@ $content .= "\n"; TRUE) { if ($this->authREST["email"] === "anonymous") - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Anonymous not allowed"), 401); - throw new Exception (dgettext("domframework","Access forbidden"), + throw new \Exception (dgettext ("domframework","Access forbidden"), 403); } $this->chained->connect(); // $chainedvalues are the information associated to the $chain $chainedvalues = $this->chained->keyexists ($chain); if ($chainedvalues === false) - throw new exception (dgettext("domframework", + throw new exception (dgettext ("domframework", "Object not found"), 404); } if ($this->accessright ($this->authREST["email"]) !== TRUE) { if ($this->authREST["email"] === "anonymous") - throw new Exception (dgettext("domframework","Anonymous not allowed"), - 401); - throw new Exception (dgettext("domframework","Access forbidden"), 403); + throw new \Exception (dgettext ("domframework", + "Anonymous not allowed"), 401); + throw new \Exception (dgettext ("domframework", "Access forbidden"), + 403); } if ($this->editright ($this->authREST["email"]) !== TRUE) { if ($this->authREST["email"] === "anonymous") - throw new Exception (dgettext("domframework","Anonymous not allowed"), - 401); - throw new Exception (dgettext("domframework","Access forbidden"), 403); + throw new \Exception (dgettext ("domframework", + "Anonymous not allowed"), 401); + throw new \Exception (dgettext ("domframework", "Access forbidden"), + 403); } if ($this->readonly ($this->authREST["email"]) === TRUE) - throw new Exception (dgettext("domframework","Access forbidden"), 403); + throw new \Exception (dgettext ("domframework", "Access forbidden"), + 403); if (!isset ($extension) || $extension === null || $extension === "") $extension = reset ($this->extensionsAllowed); if (!in_array ($extension, $this->extensionsAllowed)) - throw new Exception (dgettext("domframework","Extension not allowed"), - 403); + throw new \Exception (dgettext ("domframework", + "Extension not allowed"), 403); $this->connect(); $values = $_POST; $errorsChain = array (); @@ -463,7 +466,7 @@ $content .= "\n"; isset ($values[$this->chainedForeign]) && $values[$this->chainedForeign] !== $chain) $errorsChain[$this->chainedForeign] = - array ("error", dgettext("domframework", + array ("error", dgettext ("domframework", "Can not change the external key")); if ($this->chainedForeign !== null) $values[$this->chainedForeign] = $chain; @@ -476,7 +479,7 @@ $content .= "\n"; $this->objectDB->insert ($values); $this->renderrest ($extension, "OK", 200); } - catch (Exception $e) + catch (\Exception $e) { $this->renderrest ($extension, $e->getMessage(), 400); } @@ -491,39 +494,42 @@ $content .= "\n"; TRUE) { if ($this->authREST["email"] === "anonymous") - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Anonymous not allowed"), 401); - throw new Exception (dgettext("domframework","Access forbidden"), + throw new \Exception (dgettext ("domframework", "Access forbidden"), 403); } $this->chained->connect(); // $chainedvalues are the information associated to the $chain $chainedvalues = $this->chained->keyexists ($chain); if ($chainedvalues === false) - throw new exception (dgettext("domframework", + throw new exception (dgettext ("domframework", "Object not found"), 404); } if ($this->accessright ($this->authREST["email"]) !== TRUE) { if ($this->authREST["email"] === "anonymous") - throw new Exception (dgettext("domframework","Anonymous not allowed"), - 401); - throw new Exception (dgettext("domframework","Access forbidden"), 403); + throw new \Exception (dgettext ("domframework", + "Anonymous not allowed"), 401); + throw new \Exception (dgettext ("domframework", "Access forbidden"), + 403); } if ($this->editright ($this->authREST["email"]) !== TRUE) { if ($this->authREST["email"] === "anonymous") - throw new Exception (dgettext("domframework","Anonymous not allowed"), - 401); - throw new Exception (dgettext("domframework","Access forbidden"), 403); + throw new \Exception (dgettext ("domframework", + "Anonymous not allowed"), 401); + throw new \Exception (dgettext ("domframework", "Access forbidden"), + 403); } if ($this->readonly ($this->authREST["email"]) === TRUE) - throw new Exception (dgettext("domframework","Access forbidden"), 403); + throw new \Exception (dgettext ("domframework", "Access forbidden"), + 403); if (!isset ($extension) || $extension === null || $extension === "") $extension = reset ($this->extensionsAllowed); if (!in_array ($extension, $this->extensionsAllowed)) - throw new Exception (dgettext("domframework","Extension not allowed"), - 403); + throw new \Exception (dgettext ("domframework", + "Extension not allowed"), 403); $this->connect(); parse_str (file_get_contents ("php://input"), $values); $errorsChain = array (); @@ -531,7 +537,7 @@ $content .= "\n"; isset ($values[$this->chainedForeign]) && $values[$this->chainedForeign] !== $chain) $errorsChain[$this->chainedForeign] = - array ("error", dgettext("domframework", + array ("error", dgettext ("domframework", "Can not change the external key")); $errors = $this->objectDB->verify ($values, $id); if (count ($errors) > 0 || count ($errorsChain) > 0) @@ -542,7 +548,7 @@ $content .= "\n"; $this->objectDB->update ($id, $values); $this->renderrest ($extension, "OK", 200); } - catch (Exception $e) + catch (\Exception $e) { $this->renderrest ($extension, $e->getMessage(), 400); } @@ -557,46 +563,49 @@ $content .= "\n"; TRUE) { if ($this->authHTML["email"] === "anonymous") - throw new Exception (dgettext("domframework", - "Anonymous not allowed"), 401); - throw new Exception (dgettext("domframework","Access forbidden"), - 403); + throw new \Exception (dgettext ("domframework", + "Anonymous not allowed"), 401); + throw new \Exception (dgettext ("domframework", "Access forbidden"), + 403); } $this->chained->connect(); // $chainedValues are the information associated to the $chain $chainedValues = $this->chained->keyexists ($chain); if ($chainedValues === false) - throw new Exception (dgettext("domframework", - "Object not found"), 404); + throw new \Exception (dgettext ("domframework", + "Object not found"), 404); } if ($this->accessright ($this->authREST["email"]) !== TRUE) { if ($this->authREST["email"] === "anonymous") - throw new Exception (dgettext("domframework","Anonymous not allowed"), - 401); - throw new Exception (dgettext("domframework","Access forbidden"), 403); + throw new \Exception (dgettext ("domframework", + "Anonymous not allowed"), 401); + throw new \Exception (dgettext ("domframework", "Access forbidden"), + 403); } if ($this->editright ($this->authREST["email"]) !== TRUE) { if ($this->authREST["email"] === "anonymous") - throw new Exception (dgettext("domframework","Anonymous not allowed"), - 401); - throw new Exception (dgettext("domframework","Access forbidden"), 403); + throw new \Exception (dgettext ("domframework", + "Anonymous not allowed"), 401); + throw new \Exception (dgettext ("domframework", "Access forbidden"), + 403); } if ($this->readonly ($this->authREST["email"]) === TRUE) - throw new Exception (dgettext("domframework","Access forbidden"), 403); + throw new \Exception (dgettext ("domframework", "Access forbidden"), + 403); if (!isset ($extension) || $extension === null || $extension === "") $extension = reset ($this->extensionsAllowed); if (!in_array ($extension, $this->extensionsAllowed)) - throw new Exception (dgettext("domframework","Extension not allowed"), - 403); + throw new \Exception (dgettext ("domframework", + "Extension not allowed"), 403); $this->connect(); try { $this->objectDB->delete ($id); $this->renderrest ($extension, "OK", 200); } - catch (Exception $e) + catch (\Exception $e) { $this->renderrest ($extension, $e->getMessage(), 400); } @@ -610,8 +619,8 @@ $content .= "\n"; if ($this->chained !== null) { if (strpos ($this->chained->url_prefix, "/{chain}/") !== false) - throw new Exception ("Chained can not have an already chained object", - 500); + throw new \Exception (dgettext ("domframework", + "Chained can not have an already chained object"), 500); $this->url_prefix = $this->chained->url_prefix."/{chain}/". $this->url_prefix; } @@ -636,25 +645,25 @@ $content .= "\n"; TRUE) { if ($this->authHTML["email"] === "anonymous") - throw new Exception (dgettext("domframework", - "Anonymous not allowed"), 401); - throw new Exception (dgettext("domframework", - "Access forbidden"), 403); + throw new \Exception (dgettext ("domframework", + "Anonymous not allowed"), 401); + throw new \Exception (dgettext ("domframework", + "Access forbidden"), 403); } $this->chained->connect(); // $chainedValues are the information associated to the $chain $chainedValues = $this->chained->keyexists ($chain); if ($chainedValues === false) - throw new Exception (dgettext("domframework", - "Object not found"), 404); + throw new \Exception (dgettext ("domframework", + "Object not found"), 404); } if ($this->accessright ($this->authHTML["email"]) !== TRUE) { if ($this->authHTML["email"] === "anonymous") - throw new Exception (dgettext("domframework", - "Anonymous not allowed"), 401); - throw new Exception (dgettext("domframework", - "Access forbidden"), 403); + throw new \Exception (dgettext ("domframework", + "Anonymous not allowed"), 401); + throw new \Exception (dgettext ("domframework", + "Access forbidden"), 403); } if ($this->chained !== null && @@ -741,9 +750,9 @@ $content .= "\n"; foreach ($this->objectDB->foreign as $foreign=>$params) { if (! isset ($params[0])) - throw new Exception ("Undefined foreign key", 500); + throw new \Exception ("Undefined foreign key", 500); if (! isset ($params[1])) - throw new Exception ("Undefined foreign key column", 500); + throw new \Exception ("Undefined foreign key column", 500); $class = $params[0]; $column = $params[1]; require_once ("models/model_$class.php"); @@ -990,12 +999,14 @@ $content .= "\n"; $content .= " \n"; if ($this->readwriteAllowed && $this->displayActions && $this->actionsAtEnd === false) - $content .= " ".dgettext("domframework","Actions")."\n"; + $content .= " ".dgettext ("domframework", "Actions"). + "\n"; foreach ($titles as $title) $content .= " ".htmlentities ($title)."\n"; if ($this->readwriteAllowed && $this->displayActions && $this->actionsAtEnd !== false) - $content .= " ".dgettext("domframework","Actions")."\n"; + $content .= " ".dgettext ("domframework", "Actions"). + "\n"; $content .= " \n"; $content .= " \n"; $content .= " \n"; @@ -1006,7 +1017,7 @@ $content .= "\n"; if ($this->readwriteAllowed && $this->displayActions) $countTitles++; $content .= " "; - $content .= dgettext("domframework","No entry available"); + $content .= dgettext ("domframework","No entry available"); $content .= "\n"; } else @@ -1038,13 +1049,13 @@ $content .= "\n"; $line[$this->objectDB->primary]."/delete/$token'"; if ($this->deleteConfirm) $content .= " onclick=\"return confirm('". - dgettext("domframework", + dgettext ("domframework", "Are you sure to delete this entry?")."')\""; $content .= " class='delete'>".$this->textDelete.""; foreach ($this->internalLinks as $linkData) { if (! isset ($linkData["linkname"])) - throw new Exception ("No linkname defined !", 500); + throw new \Exception ("No linkname defined !", 500); $content .= " "; @@ -1097,34 +1108,37 @@ $content .= "\n"; TRUE) { if ($this->authHTML["email"] === "anonymous") - throw new Exception (dgettext("domframework", - "Anonymous not allowed"), 401); - throw new Exception (dgettext("domframework","Access forbidden"), - 403); + throw new \Exception (dgettext ("domframework", + "Anonymous not allowed"), 401); + throw new \Exception (dgettext ("domframework","Access forbidden"), + 403); } $this->chained->connect(); // $chainedValues are the information associated to the $chain $chainedValues = $this->chained->keyexists ($chain); if ($chainedValues === false) - throw new Exception (dgettext("domframework", - "Object not found"), 404); + throw new \Exception (dgettext ("domframework", + "Object not found"), 404); } if ($this->accessright ($this->authHTML["email"], $id) !== TRUE) { if ($this->authHTML["email"] === "anonymous") - throw new Exception (dgettext("domframework","Anonymous not allowed"), - 401); - throw new Exception (dgettext("domframework","Access forbidden"), 403); + throw new \Exception (dgettext ("domframework", + "Anonymous not allowed"), 401); + throw new \Exception (dgettext ("domframework", "Access forbidden"), + 403); } if ($this->editright ($this->authHTML["email"], $id) !== TRUE) { if ($this->authHTML["email"] === "anonymous") - throw new Exception (dgettext("domframework","Anonymous not allowed"), - 401); - throw new Exception (dgettext("domframework","Access forbidden"), 403); + throw new \Exception (dgettext ("domframework", + "Anonymous not allowed"), 401); + throw new \Exception (dgettext ("domframework", "Access forbidden"), + 403); } if ($this->readonly ($this->authHTML["email"], $id) === TRUE) - throw new Exception (dgettext("domframework","Access forbidden"), 403); + throw new \Exception (dgettext ("domframework", "Access forbidden"), + 403); $this->connect(); $csrf = new csrf (); @@ -1138,7 +1152,7 @@ $content .= "\n"; str_replace ("{chain}", $chain, $this->url_prefix), ""); } - catch (Exception $e) + catch (\Exception $e) { $renderer->flash ("ERROR", $e->getMessage()); $route->redirect ("/". @@ -1158,34 +1172,37 @@ $content .= "\n"; TRUE) { if ($this->authHTML["email"] === "anonymous") - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Anonymous not allowed"), 401); - throw new Exception (dgettext("domframework","Access forbidden"), + throw new \Exception (dgettext ("domframework","Access forbidden"), 403); } $this->chained->connect(); // $chainedValues are the information associated to the $chain $chainedValues = $this->chained->keyexists ($chain); if ($chainedValues === false) - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Object not found"), 404); } if ($this->accessright ($this->authHTML["email"]) !== TRUE) { if ($this->authHTML["email"] === "anonymous") - throw new Exception (dgettext("domframework","Anonymous not allowed"), - 401); - throw new Exception (dgettext("domframework","Access forbidden"), 403); + throw new \Exception (dgettext ("domframework", + "Anonymous not allowed"), 401); + throw new \Exception (dgettext ("domframework", "Access forbidden"), + 403); } if ($this->editright ($this->authHTML["email"]) !== TRUE) { if ($this->authHTML["email"] === "anonymous") - throw new Exception (dgettext("domframework","Anonymous not allowed"), - 401); - throw new Exception (dgettext("domframework","Access forbidden"), 403); + throw new \Exception (dgettext ("domframework", + "Anonymous not allowed"), 401); + throw new \Exception (dgettext ("domframework", "Access forbidden"), + 403); } if ($this->readonly ($this->authHTML["email"]) === TRUE) - throw new Exception (dgettext("domframework","Access forbidden"), 403); + throw new \Exception (dgettext ("domframework", "Access forbidden"), + 403); $this->connect(); @@ -1197,9 +1214,9 @@ $content .= "\n"; foreach ($this->objectDB->foreign as $foreign=>$params) { if (! isset ($params[0])) - throw new Exception ("Undefined foreign key", 500); + throw new \Exception ("Undefined foreign key", 500); if (! isset ($params[1])) - throw new Exception ("Undefined foreign key column", 500); + throw new \Exception ("Undefined foreign key column", 500); $class = $params[0]; $column = $params[1]; require_once ("models/model_$class.php"); @@ -1346,7 +1363,7 @@ $content .= "\n"; { $field = new formfield ($key, $val); 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"), $key), 500); if (in_array ("not null", $this->objectDB->fields[$key])) @@ -1369,9 +1386,9 @@ $content .= "\n"; unset ($field); } - $field = new formfield ("submit", dgettext("domframework", + $field = new formfield ("submit", dgettext ("domframework", "Save the data")); - $field->defaults = dgettext("domframework","Save the data"); + $field->defaults = dgettext ("domframework","Save the data"); $field->type = "submit"; $fields[] = $field; unset ($field); @@ -1389,34 +1406,37 @@ $content .= "\n"; TRUE) { if ($this->authHTML["email"] === "anonymous") - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Anonymous not allowed"), 401); - throw new Exception (dgettext("domframework","Access forbidden"), + throw new \Exception (dgettext ("domframework","Access forbidden"), 403); } $this->chained->connect(); // $chainedvalues are the information associated to the $chain $chainedvalues = $this->chained->keyexists ($chain); if ($chainedvalues === false) - throw new exception (dgettext("domframework", + throw new exception (dgettext ("domframework", "Object not found"), 404); } if ($this->accessright ($this->authHTML["email"]) !== TRUE) { if ($this->authHTML["email"] === "anonymous") - throw new Exception (dgettext("domframework","Anonymous not allowed"), - 401); - throw new Exception (dgettext("domframework","Access forbidden"), 403); + throw new \Exception (dgettext ("domframework", + "Anonymous not allowed"), 401); + throw new \Exception (dgettext ("domframework", "Access forbidden"), + 403); } if ($this->editright ($this->authHTML["email"]) !== TRUE) { if ($this->authHTML["email"] === "anonymous") - throw new Exception (dgettext("domframework","Anonymous not allowed"), - 401); - throw new Exception (dgettext("domframework","Access forbidden"), 403); + throw new \Exception (dgettext ("domframework", + "Anonymous not allowed"), 401); + throw new \Exception (dgettext ("domframework", "Access forbidden"), + 403); } if ($this->readonly ($this->authHTML["email"]) === TRUE) - throw new Exception (dgettext("domframework","Access forbidden"), 403); + throw new \Exception (dgettext ("domframework", "Access forbidden"), + 403); $this->connect(); $f = new form (); @@ -1426,7 +1446,7 @@ $content .= "\n"; isset ($values[$this->chainedForeign]) && $values[$this->chainedForeign] !== $chain) $errorsChain[$this->chainedForeign] = - array ("error", dgettext("domframework", + array ("error", dgettext ("domframework", "Can not change the external key")); $errors = $this->objectDB->verify ($values); if (count ($errors) == 0 && count ($errorsChain) == 0) @@ -1435,13 +1455,13 @@ $content .= "\n"; { $this->objectDB->insert ($values); $renderer = new renderer (); - $renderer->flash ("SUCCESS", dgettext("domframework", + $renderer->flash ("SUCCESS", dgettext ("domframework", "Creation done")); $route->redirect ("/". str_replace ("{chain}", $chain, $this->url_prefix), ""); } - catch (Exception $e) + catch (\Exception $e) { $renderer = new renderer (); $renderer->flash ("ERROR", $e->getMessage ()); @@ -1471,24 +1491,25 @@ $content .= "\n"; TRUE) { if ($this->authHTML["email"] === "anonymous") - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Anonymous not allowed"), 401); - throw new Exception (dgettext("domframework","Access forbidden"), + throw new \Exception (dgettext ("domframework","Access forbidden"), 403); } $this->chained->connect(); // $chainedvalues are the information associated to the $chain $chainedvalues = $this->chained->keyexists ($chain); if ($chainedvalues === false) - throw new exception (dgettext("domframework", + throw new exception (dgettext ("domframework", "Object not found"), 404); } if ($this->accessright ($this->authHTML["email"], $id) !== TRUE) { if ($this->authHTML["email"] === "anonymous") - throw new Exception (dgettext("domframework","Anonymous not allowed"), - 401); - throw new Exception (dgettext("domframework","Access forbidden"), 403); + throw new \Exception (dgettext ("domframework", + "Anonymous not allowed"), 401); + throw new \Exception (dgettext ("domframework", "Access forbidden"), + 403); } if ($this->chained !== null && $this->chained->editright ($this->authHTML["email"], $chain) !== true) @@ -1507,9 +1528,9 @@ $content .= "\n"; foreach ($this->objectDB->foreign as $foreign=>$params) { if (! isset ($params[0])) - throw new Exception ("Undefined foreign key", 500); + throw new \Exception ("Undefined foreign key", 500); if (! isset ($params[1])) - throw new Exception ("Undefined foreign key column", 500); + throw new \Exception ("Undefined foreign key column", 500); $class = $params[0]; $column = $params[1]; require_once ("models/model_$class.php"); @@ -1538,7 +1559,8 @@ $content .= "\n"; $values = $this->objectDB->read (array (array ($this->objectDB->primary, $id))); if (count ($values) === 0) - throw new Exception (dgettext("domframework", "Object not found"), 404); + throw new \Exception (dgettext ("domframework", "Object not found"), + 404); $values = $values[0]; if (isset ($_SESSION["domframework"]["routeSQL"]["errors"])) { @@ -1660,7 +1682,7 @@ $content .= "\n"; { $field = new formfield ($key, $val); 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"), $key), 500); if (in_array ("not null", $this->objectDB->fields[$key])) @@ -1687,9 +1709,9 @@ $content .= "\n"; if ($readonly === false && $this->readwriteAllowed === true) { - $field = new formfield ("submit", dgettext("domframework", + $field = new formfield ("submit", dgettext ("domframework", "Save the data")); - $field->defaults = dgettext("domframework","Save the data"); + $field->defaults = dgettext ("domframework","Save the data"); $field->type = "submit"; $fields[] = $field; unset ($field); @@ -1709,52 +1731,56 @@ $content .= "\n"; TRUE) { if ($this->authHTML["email"] === "anonymous") - throw new Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Anonymous not allowed"), 401); - throw new Exception (dgettext("domframework","Access forbidden"), + throw new \Exception (dgettext ("domframework","Access forbidden"), 403); } $this->chained->connect(); // $chainedvalues are the information associated to the $chain $chainedvalues = $this->chained->keyexists ($chain); if ($chainedvalues === false) - throw new exception (dgettext("domframework", + throw new exception (dgettext ("domframework", "Object not found"), 404); } if ($this->accessright ($this->authHTML["email"], $id) !== TRUE) { if ($this->authHTML["email"] === "anonymous") - throw new Exception (dgettext("domframework","Anonymous not allowed"), - 401); - throw new Exception (dgettext("domframework","Access forbidden"), 403); + throw new \Exception (dgettext ("domframework", + "Anonymous not allowed"), 401); + throw new \Exception (dgettext ("domframework", "Access forbidden"), + 403); } if ($this->editright ($this->authHTML["email"], $id) !== TRUE) { if ($this->authHTML["email"] === "anonymous") - throw new Exception (dgettext("domframework","Anonymous not allowed"), - 401); - throw new Exception (dgettext("domframework","Access forbidden"), 403); + throw new \Exception (dgettext ("domframework", + "Anonymous not allowed"), 401); + throw new \Exception (dgettext ("domframework", "Access forbidden"), + 403); } if ($this->readonly ($this->authHTML["email"], $id) === TRUE) - throw new Exception (dgettext("domframework","Access forbidden"), 403); + throw new \Exception (dgettext ("domframework", "Access forbidden"), + 403); $this->connect(); $oldvalues = $this->objectDB->read (array (array ($this->objectDB->primary, $id))); if (count ($oldvalues) === 0) - throw new Exception (dgettext("domframework", "Object not found"), 404); + throw new \Exception (dgettext ("domframework", "Object not found"), + 404); $oldvalues = $oldvalues[0]; $f = new form (); $values = $f->values (); if ($values[$this->objectDB->primary] !== $id) - throw new Exception (dgettext("domframework", - "Can not change the primary key"), 403); + throw new \Exception (dgettext ("domframework", + "Can not change the primary key"), 403); $errorsChain = array (); if ($this->chainedForeign !== null && isset ($values[$this->chainedForeign]) && $values[$this->chainedForeign] !== $chain) $errorsChain[$this->chainedForeign] = - array ("error", dgettext("domframework", + array ("error", dgettext ("domframework", "Can not change the external key")); if ($this->chainedForeign !== null) $values[$this->chainedForeign] = $chain; @@ -1765,12 +1791,12 @@ $content .= "\n"; { $this->objectDB->update ($id, $values); $renderer = new renderer (); - $renderer->flash ("SUCCESS", dgettext("domframework","Update done")); + $renderer->flash ("SUCCESS", dgettext ("domframework","Update done")); $route->redirect ("/". str_replace ("{chain}", $chain, $this->url_prefix), ""); } - catch (Exception $e) + catch (\Exception $e) { $renderer = new renderer (); $renderer->flash ("ERROR", $e->getMessage ()); diff --git a/smtp.php b/smtp.php index bdd10d9..45b64d2 100644 --- a/smtp.php +++ b/smtp.php @@ -79,7 +79,7 @@ class smtp { if ($errstr === "" && $php_errormsg !== "") $errstr = $php_errormsg; - throw new \Exception (sprintf (dgettext("domframework", + throw new \Exception (sprintf (dgettext ("domframework", "Can't connect to SMTP server : %s"), $errstr), 500); } stream_set_timeout ($this->smtpStream, $this->timeout); @@ -103,14 +103,14 @@ class smtp if (@stream_socket_enable_crypto ($this->smtpStream, true, STREAM_CRYPTO_METHOD_TLS_CLIENT) === false) - throw new \Exception (sprintf (dgettext("domframework", + throw new \Exception (sprintf (dgettext ("domframework", "Can't activate STARTTLS %s"), strstr ($php_errormsg, ": ")), 500); ini_set('track_errors', 0); $this->debug ("STARTTLS ACTIVATED\n"); } } elseif ($this->starttls === "encrypt") - throw new \Exception (dgettext("domframework", + throw new \Exception (dgettext ("domframework", "Server doesn't supports STARTTLS"), 500); if ($this->user !== null && $this->password !== null) @@ -133,7 +133,7 @@ class smtp } else throw new \Exception ( - dgettext("domframework", + dgettext ("domframework", "No authentication method available for the server"), 500); } } @@ -169,7 +169,7 @@ class smtp { if ($this->smtpStream === null) throw new \Exception ( - dgettext("domframework", + dgettext ("domframework", "Can't send email : not connected to SMTP server"), 500); $from = $this->cleanMail ($from); if (is_string ($to)) @@ -199,7 +199,7 @@ class smtp { if ($this->smtpStream === null) throw new \Exception ( - dgettext("domframework", + dgettext ("domframework", "Can't send email : not connected to SMTP server"), 500); $this->putLine ("QUIT\r\n"); fclose ($this->smtpStream); @@ -211,7 +211,7 @@ class smtp { if ($this->smtpStream === null) throw new \Exception ( - dgettext("domframework", + dgettext ("domframework", "Can't send email : not connected to SMTP server"), 500); $this->putLine ("RSET\r\n"); } diff --git a/users.php b/users.php index d508957..b3427a0 100644 --- a/users.php +++ b/users.php @@ -87,15 +87,15 @@ class users public function checkEmail ($email) { if (! is_string ($email)) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Invalid email provided : not a string"), 500); if (strlen ($email) < 5) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Invalid email provided : too short"), 500); if (strpos ($email, ":") !== false) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Invalid email provided : colon forbidden"), 500); return true; @@ -107,15 +107,15 @@ class users public function checkFirstname ($firstname) { if (! is_string ($firstname)) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Invalid firstname provided : not a string"), 500); if (strlen ($firstname) < 1) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Invalid firstname provided : too short"), 500); if (strpos ($firstname, ":") !== false) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Invalid firstname provided : colon forbidden"), 500); return true; @@ -127,11 +127,11 @@ class users public function checkLastname ($lastname) { if (! is_string ($lastname)) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Invalid lastname provided : not a string"), 500); if (strpos ($lastname, ":") !== false) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Invalid lastname provided : colon forbidden"), 500); return true; @@ -143,15 +143,15 @@ class users public function checkPassword ($password) { if (! is_string ($password)) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Invalid password provided : not a string"), 500); if (strlen ($password) < 5) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Invalid password provided : too short"), 500); if (strlen ($password) >= 128) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Invalid password provided : too long"), 500); return true; @@ -163,7 +163,7 @@ class users public function cryptPasswd ($password) { 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"), 500); $cost = 11; diff --git a/userssql.php b/userssql.php index 525d148..7cd8055 100644 --- a/userssql.php +++ b/userssql.php @@ -57,22 +57,22 @@ class userssql extends users public function connect () { if ($this->table === null) - throw new Exception (dgettext("domframework","No SQL table defined"), + throw new Exception (dgettext ("domframework","No SQL table defined"), 500); if ($this->fieldEmail === null) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "No fieldIdentifier defined"), 500); if ($this->fieldPassword === null) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "No fieldPassword defined"), 500); if ($this->fieldLastname === null) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "No fieldLastname defined"), 500); if ($this->fieldFirstname === null) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "No fieldFirstname defined"), 500); if ($this->fieldLastchange === null) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "No fieldLastchange defined"), 500); $this->db = new dblayer ($this->dsn, $this->username, $this->password, $this->driver_options); @@ -177,7 +177,7 @@ class userssql extends users $this->checkPassword ($oldpassword); $this->checkPassword ($newpassword); if ($this->checkValidPassword ($email, $oldpassword) !== true) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "Bad old password provided"), 401); $cryptedPassword = $this->cryptPasswd ($newpassword); return $this->db->update ($email, @@ -200,7 +200,7 @@ class userssql extends users $data = $this->db->read (array (array ($this->fieldEmail, $email)), array ($this->fieldPassword)); if (count ($data) === 0) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "No information found for this email"), 404); $cryptedPassword = $this->cryptPasswd ($newpassword); return $this->db->update ($email, @@ -222,10 +222,10 @@ class userssql extends users $data = $this->db->read (array (array ($this->fieldEmail, $email)), array ($this->fieldPassword)); if (count ($data) === 0) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "No information found for this email"), 404); if (! isset ($data[0][$this->fieldPassword])) - throw new Exception (dgettext("domframework", + throw new Exception (dgettext ("domframework", "No password available for this email"), 404); $cryptedPassword = $data[0][$this->fieldPassword]; if (crypt ($password, $cryptedPassword) !== $cryptedPassword)