diff --git a/auth.php b/auth.php index 8d71994..cde3197 100644 --- a/auth.php +++ b/auth.php @@ -100,13 +100,9 @@ class auth $res .= " \n"; - $res .= " \n"; - // $res .= " "; - // $res .= "".dgettext("domframework", - // "Remember me"); - // $res .= "\n"; $res .= " \n"; } diff --git a/authsympa.php b/authsympa.php index 79e3d46..c90621b 100644 --- a/authsympa.php +++ b/authsympa.php @@ -68,7 +68,7 @@ class authsympa extends auth $this->authkey = $this->client->login ($email, $password); if ($this->authkey === null) throw new Exception (dgettext("domframework", - "Can't connect with provided email/password to sympa"), + "Can't connect with provided email/password to sympa"), 401); $rc = $this->client->authenticateAndRun ($email, $this->authkey, 'amI', array ($this->list, $this->function, $email)); diff --git a/dblayer.php b/dblayer.php index 748fae7..699333e 100644 --- a/dblayer.php +++ b/dblayer.php @@ -837,8 +837,9 @@ class dblayer { if ($s[1] === null) continue; - if ($this->debug) echo "DEBUG BIND : ".$s[0]."(".md5 ($s[0].$s[1]).")->". - var_export ($s[1], TRUE)."\n"; + if ($this->debug) + echo "DEBUG BIND : ".$s[0]."(".md5 ($s[0].$s[1]).")->". + var_export ($s[1], TRUE)."\n"; $st->bindValue (":".md5 ($s[0].$s[1]), $s[1]); } } @@ -846,8 +847,9 @@ class dblayer { foreach ($foreignSelect as $s) { - if ($this->debug) echo "DEBUG BIND : ".$s[0]."(".md5 ($s[0].$s[1]).")->". - var_export ($s[1], TRUE)."\n"; + if ($this->debug) + echo "DEBUG BIND : ".$s[0]."(".md5 ($s[0].$s[1]).")->". + var_export ($s[1], TRUE)."\n"; $st->bindValue (":".md5 ($s[0].$s[1]), $s[1]); } } diff --git a/imap.php b/imap.php index 53c442e..a8abcaf 100644 --- a/imap.php +++ b/imap.php @@ -224,7 +224,8 @@ class imap ////////////////////// /// LIST MAILS /// ////////////////////// - /** Return an array of mailHeaders order by $field and by order ASC or DESC */ + /** Return an array of mailHeaders order by $field and by order ASC or DESC + */ public function imapSortMail ($mailHeaders, $field, $orderAsc = TRUE) { if ($this->mailbox === null) diff --git a/ipaddresses.php b/ipaddresses.php index ce0214d..c4b0173 100644 --- a/ipaddresses.php +++ b/ipaddresses.php @@ -10,7 +10,8 @@ class ipaddresses public function validIPAddress ($ip) { if (!is_string ($ip) || $ip === "") - throw new \Exception (dgettext("domframework", "Invalid IP address"), 500); + throw new \Exception (dgettext("domframework", "Invalid IP address"), + 500); $rc = $this->validIPv4Address ($ip); if ($rc === TRUE) return TRUE; @@ -22,7 +23,8 @@ class ipaddresses public function validIPv4Address ($ip) { if (!is_string ($ip) || $ip === "") - throw new \Exception (dgettext("domframework", "Invalid IPv4 address"), 500); + throw new \Exception (dgettext("domframework", "Invalid IPv4 address"), + 500); $rc = filter_var ($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4); if ($rc ===FALSE) return FALSE; @@ -33,22 +35,24 @@ class ipaddresses public function validIPv6Address ($ip) { if (!is_string ($ip) || $ip === "") - throw new \Exception (dgettext("domframework", "Invalid IPv6 address"), 500); + throw new \Exception (dgettext("domframework", "Invalid IPv6 address"), + 500); $rc = filter_var ($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6); if ($rc ===FALSE) return FALSE; return TRUE; } - /** Return the IPv6 uncompressed (all the fields exists). They are not filled by - zeros + /** Return the IPv6 uncompressed (all the fields exists). They are not filled + by zeros If the provided IP is IPv4, there is no change applied Return False if the parameter is invalid Based on http://www.weberdev.com/get_example.php3?ExampleID=3921 */ public function uncompressIPv6 ($ip) { if (! is_string ($ip) || $ip === "") - throw new \Exception (dgettext("domframework", "Invalid IP address"), 500); + throw new \Exception (dgettext("domframework", "Invalid IP address"), + 500); if (strstr ($ip,"::")) { $e = explode (":", $ip); @@ -84,9 +88,11 @@ class ipaddresses public function groupIPv6 ($ipv6) { if (! is_string ($ipv6) || $ipv6 === "") - throw new \Exception (dgettext("domframework", "Invalid IPv6 address"), 500); + throw new \Exception (dgettext("domframework", "Invalid IPv6 address"), + 500); if (substr_count ($ipv6, ".") !== 31) - throw new \Exception (dgettext("domframework", "Invalid IPv6 address"), 500); + throw new \Exception (dgettext("domframework", "Invalid IPv6 address"), + 500); $ipv6 = str_replace (".", "", $ipv6); $new = ""; for ($i = 0 ; $i < 32 ; $i++) @@ -101,11 +107,13 @@ class ipaddresses } /* Return the IP adddress with filling the fields with the missing zeros. - Valid only on IPv6 (but don't change anything if the provided address is IPv4) */ + Valid only on IPv6 (but don't change anything if the provided address is + IPv4) */ public function completeAddressWithZero ($ip) { if (! is_string ($ip) || $ip === "") - throw new \Exception (dgettext("domframework", "Invalid IP address"), 500); + throw new \Exception (dgettext("domframework", "Invalid IP address"), + 500); $ip = $this->uncompressIPv6 ($ip); if (substr_count ($ip, ":") === 7) { @@ -192,7 +200,8 @@ class ipaddresses function reverseIPAddress ($ipReverse) { if (!is_string ($ipReverse) || $ipReverse === "") - throw new \Exception (dgettext("domframework", "Invalid IP address"), 500); + throw new \Exception (dgettext("domframework", "Invalid IP address"), + 500); $ipReverse = $this->completeAddressWithZero ($ipReverse); if (substr_count ($ipReverse, ":") === 7 && strlen ($ipReverse) == 39) { diff --git a/mail.php b/mail.php index 4681506..e84e0d6 100644 --- a/mail.php +++ b/mail.php @@ -893,7 +893,8 @@ class mail continue; if ($inline === true && substr ($disposition, 0, 6) === "inline") $res[] = $sectionID; - elseif ($inline === false && substr ($disposition, 0, 10) === "attachment") + elseif ($inline === false && + substr ($disposition, 0, 10) === "attachment") $res[] = $sectionID; } return $res; diff --git a/renderer.php b/renderer.php index 0c9b2e0..46cd7ef 100644 --- a/renderer.php +++ b/renderer.php @@ -135,7 +135,8 @@ class renderer break; } $dataflash .= " alert-dismissable'>\n"; - $dataflash .= "debug = $this->debug;; $route->allowSlashes=false; - $route->get ("rest/".$this->url_prefix."(\.{extension})?". + $route->get ("rest/".$this->url_prefix."(\.{extension})?". "(\?({p1}=({v1})?)(&{p2}=({v2})?(&{p3}=({v3})?)?)?)?", function ($extension, $p1, $v1, $p2, $v2, $p3, $v3, $chain=null) { @@ -340,7 +340,7 @@ $content .= "\n"; throw new Exception (dgettext("domframework","Extension not allowed"), 403); $search = rawurldecode ($search); - $this->connect(); + $this->connect(); $titles = $this->objectDB->titles (); unset ($titles[$this->chainedForeign]); $foreignSelect = null; @@ -580,21 +580,21 @@ $content .= "\n"; $this->url_prefix = $this->chained->url_prefix."/{chain}/". $this->url_prefix; } - /** Add HTML routes */ - $route = new route (); + /** Add HTML routes */ + $route = new route (); $route->debug = $this->debug;; $route->allowSlashes=false; - $route->get ($this->url_prefix."/", function ($chain=null) use ($route) + $route->get ($this->url_prefix."/", function ($chain=null) use ($route) { $route->redirect ("/".str_replace ("{chain}", $chain, $this->url_prefix), ""); }); - $route->get ($this->url_prefix. + $route->get ($this->url_prefix. "(\?({p1}=({v1})?)(&{p2}=({v2})?(&{p3}=({v3})?)?)?)?", function ($p1, $v1, $p2, $v2, $p3, $v3, $chain=null) use ($route) - { - // List all the objects of the table + { + // List all the objects of the table if ($this->chained !== null) { if ($this->chained->accessright ($this->authHTML["email"], $chain) !== @@ -660,7 +660,7 @@ $content .= "\n"; //echo "NUM=$num\n"; //echo "SEARCH=$search\n"; //$route->debug=$this->debug; - $this->connect(); + $this->connect(); $csrf = new csrf (); $token = $csrf->createToken (); $titles = $this->objectDB->titles (); @@ -762,44 +762,174 @@ $content .= "\n"; if ($this->enableInternalCSS === true) { $content .= "\n"; } $content .= "\n"; @@ -920,12 +1050,12 @@ $content .= "\n"; $content .= " \n"; // End of bottomBar $content .= "\n"; $this->rendererhtml ($content); - }); + }); - $route->get ($this->url_prefix."/{id}/delete/{token}", + $route->get ($this->url_prefix."/{id}/delete/{token}", function ($id, $token, $chain=null) - { - // Delete an existing object if the token is valid + { + // Delete an existing object if the token is valid if ($this->chained !== null) { if ($this->chained->editright ($this->authHTML["email"], $chain) !== @@ -961,7 +1091,7 @@ $content .= "\n"; if ($this->readonly ($this->authHTML["email"], $id) === TRUE) throw new Exception (dgettext("domframework","Access forbidden"), 403); - $this->connect(); + $this->connect(); $csrf = new csrf (); $renderer = new renderer (); $route = new route (); @@ -982,10 +1112,10 @@ $content .= "\n"; } - }); + }); - $route->get ($this->url_prefix."/add", function ($chain=null) - { + $route->get ($this->url_prefix."/add", function ($chain=null) + { // Add a new entry : form to be filled by the user if ($this->chained !== null) { @@ -1022,7 +1152,7 @@ $content .= "\n"; if ($this->readonly ($this->authHTML["email"]) === TRUE) throw new Exception (dgettext("domframework","Access forbidden"), 403); - $this->connect(); + $this->connect(); // Get the non mandatory foreign keys and display them instead of the // unusable id @@ -1076,29 +1206,101 @@ $content .= "\n"; { // CSS is in edit an id too ! $content .= "\n"; // CSS is in edit an id too ! } @@ -1141,10 +1343,10 @@ $content .= "\n"; $f->fields ($fields); $content .= $f->printHTML ("post", $values, $errors); $this->rendererhtml ($content); - }); + }); - $route->post ($this->url_prefix."/add", function ($chain=null) use ($route) - { + $route->post ($this->url_prefix."/add", function ($chain=null) use ($route) + { // Add a new entry : effective save of the data if ($this->chained !== null) { @@ -1181,7 +1383,7 @@ $content .= "\n"; if ($this->readonly ($this->authHTML["email"]) === TRUE) throw new Exception (dgettext("domframework","Access forbidden"), 403); - $this->connect(); + $this->connect(); $f = new form (); $values = $f->values (); $errorsChain = array (); @@ -1223,10 +1425,10 @@ $content .= "\n"; $route->redirect ("/".str_replace("{chain}", $chain, $this->url_prefix). "/add", ""); - }); + }); - $route->get ($this->url_prefix."/{id}", function ($id, $chain=null) - { + $route->get ($this->url_prefix."/{id}", function ($id, $chain=null) + { // List the details of one existing object if ($this->chained !== null) { @@ -1261,7 +1463,7 @@ $content .= "\n"; $id); $readonly = $this->readonly ($this->authHTML["email"], $id); - $this->connect(); + $this->connect(); // Get the non mandatory foreign keys and display them instead of the // unusable id $foreignData = array (); @@ -1318,29 +1520,101 @@ $content .= "\n"; { // CSS is in add too ! $content .= "\n"; // CSS is in add too ! } @@ -1388,12 +1662,12 @@ $content .= "\n"; $f->fields ($fields); $content .= $f->printHTML ("post", $values, $errors); $this->rendererhtml ($content); - }); + }); - $route->post ($this->url_prefix."/{id}", function ($id, $chain=null) + $route->post ($this->url_prefix."/{id}", function ($id, $chain=null) use ($route) - { - // Save the details of one existing object + { + // Save the details of one existing object if ($this->chained !== null) { if ($this->chained->editright ($this->authHTML["email"], $chain) !== @@ -1479,7 +1753,7 @@ $content .= "\n"; $_SESSION["domframework"]["routeSQL"]["values"] = $values; $route->redirect ("/".str_replace ("{chain}", $chain, $this->url_prefix). "/$id", ""); - }); + }); } /** Authorization : Return TRUE if the user right allow to see the data diff --git a/tools/markdown.php b/tools/markdown.php index cce146d..a054bf3 100755 --- a/tools/markdown.php +++ b/tools/markdown.php @@ -5,17 +5,20 @@ require_once ("domframework/markdown.php"); if (! isset ($argv[1])) { - file_put_contents ("php://stderr", "No file to convert in markdown provided\n"); + file_put_contents ("php://stderr", + "No file to convert in markdown provided\n"); exit (1); } if (! file_exists ($argv[1])) { - file_put_contents ("php://stderr", "The file to convert in markdown doesn't exists\n"); + file_put_contents ("php://stderr", + "The file to convert in markdown doesn't exists\n"); exit (2); } if (! is_readable ($argv[1])) { - file_put_contents ("php://stderr", "The file to convert in markdown is not readable\n"); + file_put_contents ("php://stderr", + "The file to convert in markdown is not readable\n"); exit (3); }