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