php-cs-fixer for all the code

This commit is contained in:
2023-04-13 20:21:34 +02:00
parent eed1fe690d
commit 63b150a493
18 changed files with 279 additions and 278 deletions

View File

@@ -8,10 +8,10 @@
namespace Domframework; namespace Domframework;
/* /*
* To use it, the $serverKey must be defined. It can be created by example, * To use it, the $serverKey must be defined. It can be created by example,
* by using $serverKey = sha1 (microtime (true)); * by using $serverKey = sha1 (microtime (true));
*/ */
class Authjwt extends Auth class Authjwt extends Auth
{ {
// PROPERTIES SET BY AUTH // PROPERTIES SET BY AUTH

View File

@@ -82,8 +82,8 @@ class Authparams
if (!isset($_SERVER['PHP_AUTH_USER'])) { if (!isset($_SERVER['PHP_AUTH_USER'])) {
throw new \Exception("No user defined in HTTP header", 401); throw new \Exception("No user defined in HTTP header", 401);
//header("WWW-Authenticate: Basic realm=\"$realm\""); //header("WWW-Authenticate: Basic realm=\"$realm\"");
//header("HTTP/1.0 401 Unauthorized"); //header("HTTP/1.0 401 Unauthorized");
//die ($realm); //die ($realm);
} else { } else {
if (! array_key_exists("PHP_AUTH_PW", $_SERVER)) { if (! array_key_exists("PHP_AUTH_PW", $_SERVER)) {
$_SERVER["PHP_AUTH_PW"] = null; $_SERVER["PHP_AUTH_PW"] = null;

View File

@@ -11,7 +11,7 @@ namespace Domframework;
/** User authentication against SQL database */ /** User authentication against SQL database */
class Authsql extends Auth class Authsql extends Auth
{ {
/** The DSN to use to connect to SQL database */ /** The DSN to use to connect to SQL database */
public $dsn = null; public $dsn = null;
/** The username to connect to the database */ /** The username to connect to the database */
public $username = null; public $username = null;

View File

@@ -41,8 +41,8 @@ class Authzgroups
*/ */
public function userrightsget($module, $user) public function userrightsget($module, $user)
{ {
// if (isset ($_SESSION["domframework"]["authzgroups"][$module][$user])) // if (isset ($_SESSION["domframework"]["authzgroups"][$module][$user]))
// return $_SESSION["domframework"]["authzgroups"][$module][$user]; // return $_SESSION["domframework"]["authzgroups"][$module][$user];
if ($this->rightCache !== null) { if ($this->rightCache !== null) {
return $this->rightCache; return $this->rightCache;
} }

View File

@@ -68,8 +68,8 @@ class Authzgroupsoo
*/ */
public function userrightsget($module, $user) public function userrightsget($module, $user)
{ {
// if (isset ($_SESSION["domframework"]["authzgroups"][$module][$user])) // if (isset ($_SESSION["domframework"]["authzgroups"][$module][$user]))
// return $_SESSION["domframework"]["authzgroups"][$module][$user]; // return $_SESSION["domframework"]["authzgroups"][$module][$user];
if ($this->rightCache !== null) { if ($this->rightCache !== null) {
return $this->rightCache; return $this->rightCache;
} }
@@ -1353,8 +1353,8 @@ class Authzgroupsoo
case "RO": case "RO":
$right = 1; $right = 1;
break; break;
// Normally, the NO is not used as the entry should be removed and the user // Normally, the NO is not used as the entry should be removed and the user
// will have the same result. The NO allow to force the value. // will have the same result. The NO allow to force the value.
case "NO": case "NO":
$right = 0; $right = 0;
break; break;

View File

@@ -162,7 +162,7 @@ class Dblayer
$this->dsn = $dsn; $this->dsn = $dsn;
switch ($driver[0]) { switch ($driver[0]) {
case "sqlite": case "sqlite":
// 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( throw new \Exception(
@@ -189,8 +189,8 @@ class Dblayer
) { ) {
chmod($file, 0666); chmod($file, 0666);
} }
// Print the instances of PDO objects stored : // Print the instances of PDO objects stored :
// var_dump (self::$instance); // var_dump (self::$instance);
if (! array_key_exists($this->dsn, self::$instance)) { if (! array_key_exists($this->dsn, self::$instance)) {
if ($this->debug) { if ($this->debug) {
echo "CONNECT TO DATABASE\n"; echo "CONNECT TO DATABASE\n";
@@ -211,14 +211,14 @@ class Dblayer
} }
} }
// Force ForeignKeys support (disabled by default) // Force ForeignKeys support (disabled by default)
self::$instance[$this->dsn]->exec("PRAGMA foreign_keys = ON"); self::$instance[$this->dsn]->exec("PRAGMA foreign_keys = ON");
$this->sep = "`"; $this->sep = "`";
break; break;
case "mysql": case "mysql":
if (! array_key_exists($this->dsn, self::$instance)) { if (! array_key_exists($this->dsn, self::$instance)) {
if ($this->debug) { if ($this->debug) {
echo "CONNECT TO DATABASE\n"; echo "CONNECT TO DATABASE\n";
} }
try { try {
$driver_options[\PDO::MYSQL_ATTR_FOUND_ROWS] = 1; $driver_options[\PDO::MYSQL_ATTR_FOUND_ROWS] = 1;
@@ -228,23 +228,23 @@ class Dblayer
$password, $password,
$driver_options $driver_options
); );
self::$instance[$this->dsn]->setAttribute( self::$instance[$this->dsn]->setAttribute(
\PDO::ATTR_ERRMODE, \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);
} }
} }
// Set the coding to UTF8 // Set the coding to UTF8
self::$instance[$this->dsn]->exec("SET CHARACTER SET utf8"); self::$instance[$this->dsn]->exec("SET CHARACTER SET utf8");
$this->sep = "`"; $this->sep = "`";
break; break;
case "pgsql": case "pgsql":
if (! array_key_exists($this->dsn, self::$instance)) { if (! array_key_exists($this->dsn, self::$instance)) {
if ($this->debug) { if ($this->debug) {
echo "CONNECT TO DATABASE\n"; echo "CONNECT TO DATABASE\n";
} }
try { try {
self::$instance[$this->dsn] = new \PDO( self::$instance[$this->dsn] = new \PDO(
@@ -253,16 +253,16 @@ class Dblayer
$password, $password,
$driver_options $driver_options
); );
self::$instance[$this->dsn]->setAttribute( self::$instance[$this->dsn]->setAttribute(
\PDO::ATTR_ERRMODE, \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);
} }
} }
// Set the coding to UTF8 // Set the coding to UTF8
self::$instance[$this->dsn]->exec("SET NAMES 'utf8'"); self::$instance[$this->dsn]->exec("SET NAMES 'utf8'");
$this->sep = "\""; $this->sep = "\"";
break; break;
@@ -623,17 +623,17 @@ class Dblayer
)); ));
return $errors; return $errors;
} }
/* if (! isset($data[$foreign][0])) { /* if (! isset($data[$foreign][0])) {
$errors[] = array("error", sprintf( $errors[] = array("error", sprintf(
dgettext( dgettext(
"domframework", "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;
continue; continue;
}*/ }*/
} else { } else {
if (! array_key_exists($foreign, $d)) { if (! array_key_exists($foreign, $d)) {
continue; continue;
@@ -1324,11 +1324,11 @@ class Dblayer
$i = 0; $i = 0;
foreach ($this->fields as $field => $params) { foreach ($this->fields as $field => $params) {
if ($i > 0) { if ($i > 0) {
$sql .= ",\n"; $sql .= ",\n";
} }
// Name of field // Name of field
$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( dgettext(
@@ -1375,21 +1375,21 @@ class Dblayer
$field $field
), 500); ), 500);
} }
// Primary key // Primary key
if ($this->primary === $field) { if ($this->primary === $field) {
$sql .= " PRIMARY KEY"; $sql .= " PRIMARY KEY";
} }
// Others parameters for field // Others parameters for field
// Sort to put the autoincrement field in front of params, if it is // Sort to put the autoincrement field in front of params, if it is
// present // present
sort($params); sort($params);
foreach ($params as $p) { foreach ($params as $p) {
switch ($p) { switch ($p) {
case "not null": case "not null":
$sql .= " NOT NULL"; $sql .= " NOT NULL";
break; break;
case "autoincrement": case "autoincrement":
$sql .= " AUTOINCREMENT"; $sql .= " AUTOINCREMENT";
break; break;
default: default:
throw new \Exception(sprintf( throw new \Exception(sprintf(
@@ -1403,19 +1403,19 @@ class Dblayer
} }
$i++; $i++;
} }
// Unique fields // Unique fields
if ($this->unique !== null) { if ($this->unique !== null) {
if (!is_array($this->unique)) { if (!is_array($this->unique)) {
throw new \Exception( throw new \Exception(
dgettext( dgettext(
"domframework", "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) {
$sql .= ",\n UNIQUE ($this->sep"; $sql .= ",\n UNIQUE ($this->sep";
if (is_array($u)) { if (is_array($u)) {
$sql .= implode("$this->sep,$this->sep", $u); $sql .= implode("$this->sep,$this->sep", $u);
} else { } else {
@@ -1424,7 +1424,7 @@ class Dblayer
$sql .= "$this->sep)"; $sql .= "$this->sep)";
} }
} }
// Foreign keys // Foreign keys
$i = 0; $i = 0;
foreach ($this->foreign as $field => $k) { foreach ($this->foreign as $field => $k) {
$sql .= ",\n FOREIGN KEY($this->sep$field$this->sep) " . $sql .= ",\n FOREIGN KEY($this->sep$field$this->sep) " .
@@ -1444,11 +1444,11 @@ class Dblayer
$i = 0; $i = 0;
foreach ($this->fields as $field => $params) { foreach ($this->fields as $field => $params) {
if ($i > 0) { if ($i > 0) {
$sql .= ",\n"; $sql .= ",\n";
} }
// Name of field // Name of field
$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( throw new \Exception(dgettext(
"domframework", "domframework",
@@ -1487,21 +1487,21 @@ class Dblayer
$field $field
), 500); ), 500);
} }
// Primary key // Primary key
if ($this->primary === $field) { if ($this->primary === $field) {
$sql .= " PRIMARY KEY"; $sql .= " PRIMARY KEY";
} }
// Others parameters for field // Others parameters for field
// Sort to put the autoincrement field in front of params, if it is // Sort to put the autoincrement field in front of params, if it is
// present // present
sort($params); sort($params);
foreach ($params as $p) { foreach ($params as $p) {
switch ($p) { switch ($p) {
case "not null": case "not null":
$sql .= " NOT NULL"; $sql .= " NOT NULL";
break; break;
case "autoincrement": case "autoincrement":
$sql .= " AUTO_INCREMENT"; $sql .= " AUTO_INCREMENT";
break; break;
default: default:
throw new \Exception(sprintf( throw new \Exception(sprintf(
@@ -1515,10 +1515,10 @@ class Dblayer
} }
$i++; $i++;
} }
// Unique fields // Unique fields
if ($this->unique !== null) { if ($this->unique !== null) {
foreach ($this->unique as $u) { foreach ($this->unique as $u) {
$sql .= ",\n UNIQUE ($this->sep"; $sql .= ",\n UNIQUE ($this->sep";
if (is_array($u)) { if (is_array($u)) {
$sql .= implode("$this->sep,$this->sep", $u); $sql .= implode("$this->sep,$this->sep", $u);
} else { } else {
@@ -1527,7 +1527,7 @@ class Dblayer
$sql .= "$this->sep)"; $sql .= "$this->sep)";
} }
} }
// Foreign keys // Foreign keys
$i = 0; $i = 0;
foreach ($this->foreign as $field => $k) { foreach ($this->foreign as $field => $k) {
$sql .= ",\n FOREIGN KEY($this->sep$field$this->sep) " . $sql .= ",\n FOREIGN KEY($this->sep$field$this->sep) " .
@@ -1549,14 +1549,14 @@ class Dblayer
$i = 0; $i = 0;
foreach ($this->fields as $field => $params) { foreach ($this->fields as $field => $params) {
if ($i > 0) { if ($i > 0) {
$sql .= ",\n"; $sql .= ",\n";
} }
// Name of field // Name of field
$sql .= "\"$field\" "; $sql .= "\"$field\" ";
if (in_array("autoincrement", $params)) { if (in_array("autoincrement", $params)) {
$sql .= "SERIAL"; $sql .= "SERIAL";
} else { } else {
// 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( dgettext(
@@ -1601,18 +1601,18 @@ class Dblayer
$field $field
), 500); ), 500);
} }
// Primary key // Primary key
if ($this->primary === $field) { if ($this->primary === $field) {
$sql .= " PRIMARY KEY"; $sql .= " PRIMARY KEY";
} }
// Others parameters for field // Others parameters for field
// Sort to put the autoincrement field in front of params, if it is // Sort to put the autoincrement field in front of params, if it is
// present // present
sort($params); sort($params);
foreach ($params as $p) { foreach ($params as $p) {
switch ($p) { switch ($p) {
case "not null": case "not null":
$sql .= " NOT NULL"; $sql .= " NOT NULL";
break; break;
default: default:
throw new \Exception(sprintf( throw new \Exception(sprintf(
@@ -1627,10 +1627,10 @@ class Dblayer
} }
$i++; $i++;
} }
// Unique fields // Unique fields
if ($this->unique !== null) { if ($this->unique !== null) {
foreach ($this->unique as $u) { foreach ($this->unique as $u) {
$sql .= ",\n UNIQUE (\""; $sql .= ",\n UNIQUE (\"";
if (is_array($u)) { if (is_array($u)) {
$sql .= implode("\",\"", $u); $sql .= implode("\",\"", $u);
} else { } else {
@@ -1639,7 +1639,7 @@ class Dblayer
$sql .= "\")"; $sql .= "\")";
} }
} }
// Foreign keys // Foreign keys
$i = 0; $i = 0;
foreach ($this->foreign as $field => $k) { foreach ($this->foreign as $field => $k) {
$sql .= ",\n FOREIGN KEY(\"$field\") REFERENCES \"" . $k[0] . "\"(\"" . $sql .= ",\n FOREIGN KEY(\"$field\") REFERENCES \"" . $k[0] . "\"(\"" .

View File

@@ -117,7 +117,7 @@ class Dblayeroo
$this->dsn = $dsn; $this->dsn = $dsn;
switch ($driver[0]) { switch ($driver[0]) {
case "sqlite": case "sqlite":
// 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))) {
$this->DBException(dgettext( $this->DBException(dgettext(
@@ -138,8 +138,8 @@ class Dblayeroo
) { ) {
chmod($file, 0666); chmod($file, 0666);
} }
// Print the instances of PDO objects stored : // Print the instances of PDO objects stored :
// var_dump (self::$instance); // var_dump (self::$instance);
if (! array_key_exists($this->dsn, self::$instance)) { if (! array_key_exists($this->dsn, self::$instance)) {
$this->debugLog("CONNECT TO SQLite DATABASE", 2); $this->debugLog("CONNECT TO SQLite DATABASE", 2);
try { try {
@@ -157,7 +157,7 @@ class Dblayeroo
$this->DBException("PDO error : " . $e->getMessage()); $this->DBException("PDO error : " . $e->getMessage());
} }
} }
// Force ForeignKeys support (disabled by default) // Force ForeignKeys support (disabled by default)
self::$instance[$this->dsn]->exec("PRAGMA foreign_keys = ON"); self::$instance[$this->dsn]->exec("PRAGMA foreign_keys = ON");
$this->sep = "`"; $this->sep = "`";
if ($this->databasename() === null) { if ($this->databasename() === null) {
@@ -168,29 +168,29 @@ class Dblayeroo
if (! array_key_exists($this->dsn, self::$instance)) { if (! array_key_exists($this->dsn, self::$instance)) {
$this->debugLog("CONNECT TO MySQL DATABASE", 2); $this->debugLog("CONNECT TO MySQL DATABASE", 2);
try { try {
$driver_options[\PDO::MYSQL_ATTR_FOUND_ROWS] = 1; $driver_options[\PDO::MYSQL_ATTR_FOUND_ROWS] = 1;
self::$instance[$this->dsn] = new \PDO( self::$instance[$this->dsn] = new \PDO(
$dsn, $dsn,
$username, $username,
$password, $password,
$driver_options $driver_options
); );
self::$instance[$this->dsn]->setAttribute( self::$instance[$this->dsn]->setAttribute(
\PDO::ATTR_ERRMODE, \PDO::ATTR_ERRMODE,
\PDO::ERRMODE_EXCEPTION \PDO::ERRMODE_EXCEPTION
); );
} catch (\Exception $e) { } catch (\Exception $e) {
$this->DBException("PDO error : " . $e->getMessage()); $this->DBException("PDO error : " . $e->getMessage());
} }
} }
// Set the coding to UTF8 // Set the coding to UTF8
self::$instance[$this->dsn]->exec("SET CHARACTER SET utf8"); self::$instance[$this->dsn]->exec("SET CHARACTER SET utf8");
$this->sep = "`"; $this->sep = "`";
if ($this->databasename() === null) { if ($this->databasename() === null) {
$this->DBException("No Database provided in DSN"); $this->DBException("No Database provided in DSN");
} }
// Force the GROUP_CONCAT value max to the max allowed from the server // Force the GROUP_CONCAT value max to the max allowed from the server
$st = self::$instance[$this->dsn]->query( $st = self::$instance[$this->dsn]->query(
"SHOW VARIABLES LIKE 'max_allowed_packet'", "SHOW VARIABLES LIKE 'max_allowed_packet'",
\PDO::FETCH_COLUMN, \PDO::FETCH_COLUMN,
@@ -212,22 +212,22 @@ class Dblayeroo
if (! array_key_exists($this->dsn, self::$instance)) { if (! array_key_exists($this->dsn, self::$instance)) {
$this->debugLog("CONNECT TO PGSQL DATABASE", 2); $this->debugLog("CONNECT TO PGSQL DATABASE", 2);
try { try {
self::$instance[$this->dsn] = new \PDO( self::$instance[$this->dsn] = new \PDO(
$dsn, $dsn,
$username, $username,
$password, $password,
$driver_options $driver_options
); );
self::$instance[$this->dsn]->setAttribute( self::$instance[$this->dsn]->setAttribute(
\PDO::ATTR_ERRMODE, \PDO::ATTR_ERRMODE,
\PDO::ERRMODE_EXCEPTION \PDO::ERRMODE_EXCEPTION
); );
} catch (\Exception $e) { } catch (\Exception $e) {
$this->DBException("PDO error : " . $e->getMessage()); $this->DBException("PDO error : " . $e->getMessage());
} }
} }
// Set the coding to UTF8 // Set the coding to UTF8
self::$instance[$this->dsn]->exec("SET NAMES 'utf8'"); self::$instance[$this->dsn]->exec("SET NAMES 'utf8'");
$this->sep = "\""; $this->sep = "\"";
if ($this->databasename() === null) { if ($this->databasename() === null) {
@@ -335,7 +335,7 @@ class Dblayeroo
$res = array(); $res = array();
while ($d = $st->fetch(\PDO::FETCH_ASSOC)) { while ($d = $st->fetch(\PDO::FETCH_ASSOC)) {
if ($d["name"] !== "sqlite_sequence") { if ($d["name"] !== "sqlite_sequence") {
$res[] = $d["name"]; $res[] = $d["name"];
} }
} }
break; break;
@@ -413,9 +413,9 @@ class Dblayeroo
$i = 0; $i = 0;
foreach ($this->fields as $field => $params) { foreach ($this->fields as $field => $params) {
if ($i > 0) { if ($i > 0) {
$sql .= ",\n"; $sql .= ",\n";
} }
// Name of field // Name of field
$sql .= "$this->sep$field$this->sep "; $sql .= "$this->sep$field$this->sep ";
switch ($this->fieldTypeLight($field)) { switch ($this->fieldTypeLight($field)) {
case "blob": case "blob":
@@ -431,8 +431,8 @@ class Dblayeroo
$params = array_slice($params, 1); $params = array_slice($params, 1);
break; break;
case "float": case "float":
$sql .= "FLOAT"; $sql .= "FLOAT";
$params = array_slice($params, 1); $params = array_slice($params, 1);
break; break;
case "integer": case "integer":
$sql .= "INTEGER"; $sql .= "INTEGER";
@@ -453,18 +453,18 @@ class Dblayeroo
$field $field
), 500); ), 500);
} }
// Primary key // Primary key
if ($this->primary === $field) { if ($this->primary === $field) {
$sql .= " PRIMARY KEY"; $sql .= " PRIMARY KEY";
} }
// Others parameters for field // Others parameters for field
// Sort to put the autoincrement field in front of params, if it is // Sort to put the autoincrement field in front of params, if it is
// present // present
sort($params); sort($params);
foreach ($params as $p) { foreach ($params as $p) {
switch ($p) { switch ($p) {
case "not null": case "not null":
$sql .= " NOT NULL"; $sql .= " NOT NULL";
break; break;
case "autoincrement": case "autoincrement":
if ($this->primary !== $field) { if ($this->primary !== $field) {
@@ -491,19 +491,19 @@ class Dblayeroo
} }
$i++; $i++;
} }
// Unique fields // Unique fields
if ($this->unique !== null) { if ($this->unique !== null) {
if (!is_array($this->unique)) { if (!is_array($this->unique)) {
$this->DBException( $this->DBException(
dgettext( dgettext(
"domframework", "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) {
$sql .= ",\n UNIQUE ($this->sep"; $sql .= ",\n UNIQUE ($this->sep";
if (is_array($u)) { if (is_array($u)) {
$sql .= implode("$this->sep,$this->sep", $u); $sql .= implode("$this->sep,$this->sep", $u);
} else { } else {
@@ -512,7 +512,7 @@ class Dblayeroo
$sql .= "$this->sep)"; $sql .= "$this->sep)";
} }
} }
// Foreign keys // Foreign keys
$i = 0; $i = 0;
foreach ($this->foreign as $field => $k) { foreach ($this->foreign as $field => $k) {
$field = explode(",", $field); $field = explode(",", $field);
@@ -539,9 +539,9 @@ class Dblayeroo
$i = 0; $i = 0;
foreach ($this->fields as $field => $params) { foreach ($this->fields as $field => $params) {
if ($i > 0) { if ($i > 0) {
$sql .= ",\n"; $sql .= ",\n";
} }
// Name of field // Name of field
$sql .= "$this->sep$field$this->sep "; $sql .= "$this->sep$field$this->sep ";
switch ($this->fieldTypeLight($field)) { switch ($this->fieldTypeLight($field)) {
case "blob": case "blob":
@@ -558,8 +558,8 @@ class Dblayeroo
$params = array_slice($params, 1); $params = array_slice($params, 1);
break; break;
case "float": case "float":
$sql .= "FLOAT"; $sql .= "FLOAT";
$params = array_slice($params, 1); $params = array_slice($params, 1);
break; break;
case "datetime": case "datetime":
$sql .= "DATETIME"; $sql .= "DATETIME";
@@ -578,18 +578,18 @@ class Dblayeroo
$field $field
), 500); ), 500);
} }
// Primary key // Primary key
if ($this->primary === $field) { if ($this->primary === $field) {
$sql .= " PRIMARY KEY"; $sql .= " PRIMARY KEY";
} }
// Others parameters for field // Others parameters for field
// Sort to put the autoincrement field in front of params, if it is // Sort to put the autoincrement field in front of params, if it is
// present // present
sort($params); sort($params);
foreach ($params as $p) { foreach ($params as $p) {
switch ($p) { switch ($p) {
case "not null": case "not null":
$sql .= " NOT NULL"; $sql .= " NOT NULL";
break; break;
case "autoincrement": case "autoincrement":
if ($this->primary !== $field) { if ($this->primary !== $field) {
@@ -616,10 +616,10 @@ class Dblayeroo
} }
$i++; $i++;
} }
// Unique fields // Unique fields
if ($this->unique !== null) { if ($this->unique !== null) {
foreach ($this->unique as $u) { foreach ($this->unique as $u) {
$sql .= ",\n UNIQUE ($this->sep"; $sql .= ",\n UNIQUE ($this->sep";
if (is_array($u)) { if (is_array($u)) {
$sql .= implode("$this->sep,$this->sep", $u); $sql .= implode("$this->sep,$this->sep", $u);
} else { } else {
@@ -628,7 +628,7 @@ class Dblayeroo
$sql .= "$this->sep)"; $sql .= "$this->sep)";
} }
} }
// Foreign keys // Foreign keys
$i = 0; $i = 0;
foreach ($this->foreign as $field => $k) { foreach ($this->foreign as $field => $k) {
$field = explode(",", $field); $field = explode(",", $field);
@@ -654,9 +654,9 @@ class Dblayeroo
$i = 0; $i = 0;
foreach ($this->fields as $field => $params) { foreach ($this->fields as $field => $params) {
if ($i > 0) { if ($i > 0) {
$sql .= ",\n"; $sql .= ",\n";
} }
// Name of field // Name of field
$sql .= "\"$field\" "; $sql .= "\"$field\" ";
if (in_array("autoincrement", $params)) { if (in_array("autoincrement", $params)) {
if ($this->primary !== $field) { if ($this->primary !== $field) {
@@ -668,25 +668,25 @@ class Dblayeroo
$field $field
), 500); ), 500);
} }
$sql .= "SERIAL"; $sql .= "SERIAL";
} else { } else {
switch ($this->fieldTypeLight($field)) { switch ($this->fieldTypeLight($field)) {
case "blob": case "blob":
$sql .= "BLOB"; $sql .= "BLOB";
$params = array_slice($params, 1); $params = array_slice($params, 1);
break; break;
case "integer": case "integer":
$sql .= "INTEGER"; $sql .= "INTEGER";
$params = array_slice($params, 1); $params = array_slice($params, 1);
break; break;
case "varchar": case "varchar":
$length = $this->fieldLength($field); $length = $this->fieldLength($field);
$sql .= "VARCHAR($length)"; $sql .= "VARCHAR($length)";
$params = array_slice($params, 1); $params = array_slice($params, 1);
break; break;
case "float": case "float":
$sql .= "FLOAT"; $sql .= "FLOAT";
$params = array_slice($params, 1); $params = array_slice($params, 1);
break; break;
case "datetime": case "datetime":
$sql .= "timestamp with time zone"; $sql .= "timestamp with time zone";
@@ -705,13 +705,13 @@ class Dblayeroo
$field $field
), 500); ), 500);
} }
// Primary key // Primary key
if ($this->primary === $field) { if ($this->primary === $field) {
$sql .= " PRIMARY KEY"; $sql .= " PRIMARY KEY";
} }
// Others parameters for field // Others parameters for field
// Sort to put the autoincrement field in front of params, if it is // Sort to put the autoincrement field in front of params, if it is
// present // present
sort($params); sort($params);
foreach ($params as $p) { foreach ($params as $p) {
switch ($p) { switch ($p) {
@@ -732,10 +732,10 @@ class Dblayeroo
} }
$i++; $i++;
} }
// Unique fields // Unique fields
if ($this->unique !== null) { if ($this->unique !== null) {
foreach ($this->unique as $u) { foreach ($this->unique as $u) {
$sql .= ",\n UNIQUE (\""; $sql .= ",\n UNIQUE (\"";
if (is_array($u)) { if (is_array($u)) {
$sql .= implode("\",\"", $u); $sql .= implode("\",\"", $u);
} else { } else {
@@ -744,7 +744,7 @@ class Dblayeroo
$sql .= "\")"; $sql .= "\")";
} }
} }
// Foreign keys // Foreign keys
$i = 0; $i = 0;
foreach ($this->foreign as $field => $k) { foreach ($this->foreign as $field => $k) {
$field = explode(",", $field); $field = explode(",", $field);
@@ -830,14 +830,14 @@ class Dblayeroo
$st = self::$instance[$this->dsn]->prepare( $st = self::$instance[$this->dsn]->prepare(
"PRAGMA index_info(" . $c["name"] . ")" "PRAGMA index_info(" . $c["name"] . ")"
); );
$st->execute(); $st->execute();
$content2 = $st->fetchAll(\PDO::FETCH_ASSOC); $content2 = $st->fetchAll(\PDO::FETCH_ASSOC);
if (count($content2) > 1) { if (count($content2) > 1) {
$index = array(); $index = array();
foreach ($content2 as $c2) { foreach ($content2 as $c2) {
$index[] = $c2["name"]; $index[] = $c2["name"];
} }
$unique[$content2[0]["cid"] - 1] = $index; $unique[$content2[0]["cid"] - 1] = $index;
} elseif (count($content2) === 1 && $content2[0]["cid"] >= 1) { } elseif (count($content2) === 1 && $content2[0]["cid"] >= 1) {
$index = $content2[0]["name"]; $index = $content2[0]["name"];
$unique[$content2[0]["cid"] - 1] = $index; $unique[$content2[0]["cid"] - 1] = $index;
@@ -855,10 +855,10 @@ class Dblayeroo
$st->execute(); $st->execute();
$content = $st->fetchAll(\PDO::FETCH_ASSOC); $content = $st->fetchAll(\PDO::FETCH_ASSOC);
if (count($content) > 0 && $primary !== "") { if (count($content) > 0 && $primary !== "") {
$fields[$primary][] = "autoincrement"; $fields[$primary][] = "autoincrement";
} }
} catch (\Exception $e) { } catch (\Exception $e) {
// If no autoincrement key, the sqlite_sequence table doesn't exists // If no autoincrement key, the sqlite_sequence table doesn't exists
} }
$st = self::$instance[$this->dsn]->prepare( $st = self::$instance[$this->dsn]->prepare(
@@ -876,7 +876,7 @@ class Dblayeroo
$cascade .= "ON DELETE " . $for["on_delete"]; $cascade .= "ON DELETE " . $for["on_delete"];
} }
if ($cascade !== "") { if ($cascade !== "") {
$tmp[] = $cascade; $tmp[] = $cascade;
} }
$foreign[$for["from"]] = $tmp; $foreign[$for["from"]] = $tmp;
} }
@@ -903,7 +903,7 @@ class Dblayeroo
"unique" => $unique, "unique" => $unique,
"foreign" => $foreign, "foreign" => $foreign,
"foreignUsed" => $foreignUsed); "foreignUsed" => $foreignUsed);
break; break;
case "mysql": case "mysql":
$st = self::$instance[$this->dsn]->prepare( $st = self::$instance[$this->dsn]->prepare(
"SHOW COLUMNS FROM `$tableName`" "SHOW COLUMNS FROM `$tableName`"
@@ -922,10 +922,10 @@ class Dblayeroo
$tmp[] = $col["Type"]; $tmp[] = $col["Type"];
} }
if ($col["Null"] === "NO") { if ($col["Null"] === "NO") {
$tmp[] = "not null"; $tmp[] = "not null";
} }
if ($col["Extra"] === "auto_increment") { if ($col["Extra"] === "auto_increment") {
$tmp[] = "autoincrement"; $tmp[] = "autoincrement";
} }
$fields[$col["Field"]] = $tmp; $fields[$col["Field"]] = $tmp;
} }
@@ -985,7 +985,7 @@ class Dblayeroo
$tmp[2] .= "ON DELETE " . $f["DELETE_RULE"]; $tmp[2] .= "ON DELETE " . $f["DELETE_RULE"];
} }
if ($tmp[2] !== "") { if ($tmp[2] !== "") {
$tmp[2] = trim($tmp[2]); $tmp[2] = trim($tmp[2]);
} else { } else {
unset($tmp[2]); unset($tmp[2]);
} }
@@ -1015,13 +1015,13 @@ class Dblayeroo
"unique" => $unique, "unique" => $unique,
"foreign" => $foreign, "foreign" => $foreign,
"foreignUsed" => $foreignUsed); "foreignUsed" => $foreignUsed);
break; break;
case "pgsql": case "pgsql":
$fields = array(); $fields = array();
$unique = array(); $unique = array();
$foreign = array(); $foreign = array();
$primary = ""; $primary = "";
// Get the defined primary key if not autoincrement // Get the defined primary key if not autoincrement
$st = self::$instance[$this->dsn]->prepare(" $st = self::$instance[$this->dsn]->prepare("
SELECT a.attname, format_type(a.atttypid, a.atttypmod) AS data_type SELECT a.attname, format_type(a.atttypid, a.atttypmod) AS data_type
FROM pg_index i FROM pg_index i
@@ -1035,7 +1035,7 @@ class Dblayeroo
if (key_exists(0, $content)) { if (key_exists(0, $content)) {
$primary = $content[0]["attname"]; $primary = $content[0]["attname"];
} }
// Get the primary key if autoincrement // Get the primary key if autoincrement
$st = self::$instance[$this->dsn]->prepare( $st = self::$instance[$this->dsn]->prepare(
"SELECT * "SELECT *
FROM information_schema.columns FROM information_schema.columns
@@ -1051,11 +1051,11 @@ class Dblayeroo
$tmp[] = $col["data_type"]; $tmp[] = $col["data_type"];
} }
if ($col["is_nullable"] === "NO") { if ($col["is_nullable"] === "NO") {
$tmp[] = "not null"; $tmp[] = "not null";
} }
if (is_string($col["column_default"]) && substr($col["column_default"], 0, 7) === "nextval") { if (is_string($col["column_default"]) && substr($col["column_default"], 0, 7) === "nextval") {
$tmp[] = "autoincrement"; $tmp[] = "autoincrement";
$primary = $col["column_name"]; $primary = $col["column_name"];
} }
$fields[$col["column_name"]] = $tmp; $fields[$col["column_name"]] = $tmp;
} }
@@ -1116,7 +1116,7 @@ class Dblayeroo
$tmp[2] .= "ON DELETE " . $f["delete_rule"]; $tmp[2] .= "ON DELETE " . $f["delete_rule"];
} }
if ($tmp[2] !== "") { if ($tmp[2] !== "") {
$tmp[2] = trim($tmp[2]); $tmp[2] = trim($tmp[2]);
} else { } else {
unset($tmp[2]); unset($tmp[2]);
} }
@@ -1158,7 +1158,7 @@ class Dblayeroo
"unique" => $unique, "unique" => $unique,
"foreign" => $foreign, "foreign" => $foreign,
"foreignUsed" => $foreignUsed); "foreignUsed" => $foreignUsed);
break; break;
default: default:
$this->DBException(dgettext( $this->DBException(dgettext(
"domframework", "domframework",
@@ -1172,7 +1172,7 @@ class Dblayeroo
*/ */
private function fieldTypeComplete($field) private function fieldTypeComplete($field)
{ {
// $this->debugLog ("Entering fieldTypeComplete (",$field,")", 2); // $this->debugLog ("Entering fieldTypeComplete (",$field,")", 2);
if (! array_key_exists($field, $this->fields)) { if (! array_key_exists($field, $this->fields)) {
$this->DBException(sprintf( $this->DBException(sprintf(
"fieldType : can't find the definition for field '%s'", "fieldType : can't find the definition for field '%s'",
@@ -1335,7 +1335,7 @@ class Dblayeroo
} }
if ( if (
$params[0] !== "integer" && ( $params[0] !== "integer" && (
isset($params[1]) && $params[1] === "autoincrement" || isset($params[1]) && $params[1] === "autoincrement" ||
isset($params[2]) && $params[2] === "autoincrement" isset($params[2]) && $params[2] === "autoincrement"
) )
) { ) {
@@ -2794,7 +2794,7 @@ class Dblayeroo
if (! empty($this->limitExpression)) { if (! empty($this->limitExpression)) {
$sql .= "\n LIMIT $this->limitExpression"; $sql .= "\n LIMIT $this->limitExpression";
} }
// No set Values for SELECT // No set Values for SELECT
$this->setValues = array(); $this->setValues = array();
break; break;
case "INSERT": case "INSERT":
@@ -2805,7 +2805,7 @@ class Dblayeroo
$i = 0; $i = 0;
foreach ($this->setValues as $key => $val) { foreach ($this->setValues as $key => $val) {
if ($i > 0) { if ($i > 0) {
$sql .= ","; $sql .= ",";
} }
$sql .= $this->sep . $key . $this->sep; $sql .= $this->sep . $key . $this->sep;
$i++; $i++;
@@ -2820,7 +2820,7 @@ class Dblayeroo
$i++; $i++;
} }
$sql .= ")"; $sql .= ")";
// No WHERE in INSERT : remove the WHERE parameters // No WHERE in INSERT : remove the WHERE parameters
$this->whereExpression = array(); $this->whereExpression = array();
$this->whereValues = array(); $this->whereValues = array();
break; break;
@@ -2836,7 +2836,7 @@ class Dblayeroo
if (! empty($this->limitExpression)) { if (! empty($this->limitExpression)) {
$sql .= " LIMIT $this->limitExpression"; $sql .= " LIMIT $this->limitExpression";
} }
// No set Values for DELETE // No set Values for DELETE
$this->setValues = array(); $this->setValues = array();
break; break;
case "UPDATE": case "UPDATE":
@@ -2848,7 +2848,7 @@ class Dblayeroo
$i = 0; $i = 0;
foreach ($this->setValues as $key => $val) { foreach ($this->setValues as $key => $val) {
if ($i > 0) { if ($i > 0) {
$sql .= ","; $sql .= ",";
} }
$hash = md5("$key, $val"); $hash = md5("$key, $val");
$sql .= $this->sep . $key . $this->sep . "=:" . $hash; $sql .= $this->sep . $key . $this->sep . "=:" . $hash;
@@ -3127,7 +3127,7 @@ class Dblayeroo
} }
switch ($this->fieldTypeLight($field)) { switch ($this->fieldTypeLight($field)) {
case "blob": case "blob":
// Blob can be anything. Do not test // Blob can be anything. Do not test
break; break;
case "integer": case "integer":
if (strspn($values[$field], "0123456789") !== strlen($values[$field])) { if (strspn($values[$field], "0123456789") !== strlen($values[$field])) {
@@ -3551,13 +3551,13 @@ class Dblayeroo
switch ($this->command) { switch ($this->command) {
case "SELECT": case "SELECT":
$result = $st->fetchAll(\PDO::FETCH_NUM); $result = $st->fetchAll(\PDO::FETCH_NUM);
// There is no fetchAll corresponding to the columnName->value. Assign the // There is no fetchAll corresponding to the columnName->value. Assign the
// name to the value by index. // name to the value by index.
// FETCH_ASSOC doesn't work in empty left join (return NULL instead of // FETCH_ASSOC doesn't work in empty left join (return NULL instead of
// the filled value) // the filled value)
$fieldsAll = $this->fieldsAll(true); $fieldsAll = $this->fieldsAll(true);
// If the displayed fields are all in the same table, remove the table // If the displayed fields are all in the same table, remove the table
// name in the columns // name in the columns
$cleanable = true; $cleanable = true;
$cleanTable = ""; $cleanTable = "";
foreach ($this->displayGet(true) as $display) { foreach ($this->displayGet(true) as $display) {
@@ -3567,26 +3567,26 @@ class Dblayeroo
$matches $matches
); );
if ($cleanTable === "") { if ($cleanTable === "") {
$cleanTable = $matches[1][0]; $cleanTable = $matches[1][0];
} elseif ($cleanTable !== $matches[1][0]) { } elseif ($cleanTable !== $matches[1][0]) {
$cleanable = false; $cleanable = false;
break; break;
} }
} }
$columns = array_values($this->displayGet(true)); $columns = array_values($this->displayGet(true));
// Get the columns names that will be displayed to user. // Get the columns names that will be displayed to user.
// If the cleanable is possible, remove the table names // If the cleanable is possible, remove the table names
$columnNames = array_combine($columns, $columns); $columnNames = array_combine($columns, $columns);
//if ($this->joinObject === null && count ($this->displayGet (false))) //if ($this->joinObject === null && count ($this->displayGet (false)))
if ($cleanable) { if ($cleanable) {
// Remove the table name as there is no collisions risk // Remove the table name as there is no collisions risk
// In case of Alias, remove the $this->sep too // In case of Alias, remove the $this->sep too
foreach ($columnNames as $key => $col) { foreach ($columnNames as $key => $col) {
// Remove the table and the separator if exists // Remove the table and the separator if exists
$col = preg_replace("#" . $this->sep . "[^" . $this->sep . "]+" . $col = preg_replace("#" . $this->sep . "[^" . $this->sep . "]+" .
$this->sep . "\.#U", "", $col); $this->sep . "\.#U", "", $col);
// Remove the separator if not table exists // Remove the separator if not table exists
$col = str_replace($this->sep, "", $col); $col = str_replace($this->sep, "", $col);
if ($col[0] === $this->sep) { if ($col[0] === $this->sep) {
$col = substr($col, 1); $col = substr($col, 1);
} elseif (strpos($col, "DISTINCT " . $this->sep) === 0) { } elseif (strpos($col, "DISTINCT " . $this->sep) === 0) {
@@ -3607,42 +3607,42 @@ class Dblayeroo
} }
} else { } else {
foreach ($columnNames as $key => $col) { foreach ($columnNames as $key => $col) {
$columnNames[$key] = str_replace($this->sep, "", $col); $columnNames[$key] = str_replace($this->sep, "", $col);
} }
} }
foreach ($result as $rownb => $row) { foreach ($result as $rownb => $row) {
foreach ($row as $colNb => $val) { foreach ($row as $colNb => $val) {
// Harmonize the fetchAll result between all the databases drivers // Harmonize the fetchAll result between all the databases drivers
$pos = strpos($columns[$colNb], "("); $pos = strpos($columns[$colNb], "(");
if ($pos) { if ($pos) {
// Function. The function that return an int must be added in this // Function. The function that return an int must be added in this
// list, to cast correctely the value // list, to cast correctely the value
$func = strtoupper(trim(substr($columns[$colNb], 0, $pos))); $func = strtoupper(trim(substr($columns[$colNb], 0, $pos)));
if (in_array($func, array("AVG", "COUNT", "MAX", "MIN", "SUM"))) { if (in_array($func, array("AVG", "COUNT", "MAX", "MIN", "SUM"))) {
$val = intval($val); $val = intval($val);
} }
} else { } else {
$name = $columns[$colNb]; $name = $columns[$colNb];
$pos = strpos($columns[$colNb], " AS "); $pos = strpos($columns[$colNb], " AS ");
if ($pos) { if ($pos) {
$name = substr($columns[$colNb], 0, $pos); $name = substr($columns[$colNb], 0, $pos);
} }
$name = str_replace("DISTINCT ", "", $name); $name = str_replace("DISTINCT ", "", $name);
/*if ($cleanable) /*if ($cleanable)
$name = str_replace ($this->sep.$this->tableprefix.$this->table. $name = str_replace ($this->sep.$this->tableprefix.$this->table.
$this->sep.".", "", $name);*/ $this->sep.".", "", $name);*/
if ( if (
strtolower($fieldsAll[$name][0]) === "integer" && strtolower($fieldsAll[$name][0]) === "integer" &&
$val !== null $val !== null
) { ) {
$val = intval($val); $val = intval($val);
} }
} }
if (($pos = strpos($columns[$colNb], " AS " . $this->sep)) !== false) { if (($pos = strpos($columns[$colNb], " AS " . $this->sep)) !== false) {
$pos += strlen(" AS " . $this->sep); $pos += strlen(" AS " . $this->sep);
$colName = substr($columns[$colNb], $pos, -1); $colName = substr($columns[$colNb], $pos, -1);
} else { } else {
$colName = $columnNames[$columns[$colNb]]; $colName = $columnNames[$columns[$colNb]];
} }
$result[$rownb][$colName] = $val; $result[$rownb][$colName] = $val;
unset($result[$rownb][$colNb]); unset($result[$rownb][$colNb]);
@@ -3664,8 +3664,8 @@ class Dblayeroo
"displayQuery" => $this->getDisplayQuery(), "displayQuery" => $this->getDisplayQuery(),
"nbrows" => $st->rowCount(), "nbrows" => $st->rowCount(),
); );
// If the primary key is not autoincrement, return the provided value if // If the primary key is not autoincrement, return the provided value if
// exists // exists
if ( if (
! in_array("autoincrement", $this->fields[$this->primary]) && ! in_array("autoincrement", $this->fields[$this->primary]) &&
key_exists($this->primary, $this->setValues) key_exists($this->primary, $this->setValues)
@@ -3673,8 +3673,8 @@ class Dblayeroo
return $this->setValues[$this->primary]; return $this->setValues[$this->primary];
} }
// If the primary key is autoincrement and the provided value is not null // If the primary key is autoincrement and the provided value is not null
// Return it // Return it
if ( if (
in_array("autoincrement", $this->fields[$this->primary]) && in_array("autoincrement", $this->fields[$this->primary]) &&
key_exists($this->primary, $this->setValues) && key_exists($this->primary, $this->setValues) &&
@@ -3683,9 +3683,9 @@ class Dblayeroo
return $this->setValues[$this->primary]; return $this->setValues[$this->primary];
} }
// If the primary key is autoincrement and the provided value is null or // If the primary key is autoincrement and the provided value is null or
// not provided, return the autoincremented value // not provided, return the autoincremented value
// PostGres need the name of the column autoincrement to return something // PostGres need the name of the column autoincrement to return something
$autoInc = null; $autoInc = null;
if ($this->driver === "pgsql") { if ($this->driver === "pgsql") {
foreach ($this->fields as $col => $params) { foreach ($this->fields as $col => $params) {

View File

@@ -1061,8 +1061,8 @@ class File
if ($prio <= $this->debug) { if ($prio <= $this->debug) {
echo "[$prio] $message\n"; echo "[$prio] $message\n";
//file_put_contents ("/tmp/domframework.file.debug", //file_put_contents ("/tmp/domframework.file.debug",
// date ("Y:m:d H:i:s")." [$prio] $message\n", // date ("Y:m:d H:i:s")." [$prio] $message\n",
// FILE_APPEND); // FILE_APPEND);
} }
} }

View File

@@ -14,8 +14,8 @@ namespace Domframework;
*/ */
class Form class Form
{ {
/** All the fields /** All the fields
*/ */
private $fields = null; private $fields = null;
/** The name of the form /** The name of the form
*/ */

View File

@@ -35,9 +35,9 @@ class Macaddresses
return false; return false;
} }
return ( return (
preg_match("/^([a-fA-F0-9]{2}[-:]){5}[0-9A-Fa-f]{2}$/", $mac) === 1 || preg_match("/^([a-fA-F0-9]{2}[-:]){5}[0-9A-Fa-f]{2}$/", $mac) === 1 ||
preg_match("/^([a-fA-F0-9]{4}[.]){2}[a-fA-F0-9]{4}$/", $mac) === 1 || preg_match("/^([a-fA-F0-9]{4}[.]){2}[a-fA-F0-9]{4}$/", $mac) === 1 ||
preg_match("/^[a-fA-F0-9]{12}$/", $mac) === 1); preg_match("/^[a-fA-F0-9]{12}$/", $mac) === 1);
} }
/** Reform the mac address with the separator. /** Reform the mac address with the separator.

View File

@@ -12,8 +12,8 @@ namespace Domframework;
*/ */
class Mail class Mail
{ {
/** The complete of the mail /** The complete of the mail
*/ */
private $completeEmailEML = ""; private $completeEmailEML = "";
/** Private the separator between the headers and the mail. Should be /** Private the separator between the headers and the mail. Should be

View File

@@ -55,7 +55,7 @@ class Outputhtml extends Output
require_once("views/$viewClass.php"); require_once("views/$viewClass.php");
} }
// If the file doesn't exists, an autoloader maybe exists. If it is not // If the file doesn't exists, an autoloader maybe exists. If it is not
// the case, the class will not be found // the case, the class will not be found
} }
$obj = new $viewClass(); $obj = new $viewClass();
$resView = $obj->$viewMethod($data, $variable); $resView = $obj->$viewMethod($data, $variable);

View File

@@ -20,8 +20,8 @@ namespace Domframework;
*/ */
class Queuefile extends Queue class Queuefile extends Queue
{ {
/** The queue connected object /** The queue connected object
*/ */
private $queue = null; private $queue = null;
/** Connect to the queue. Create it if not exists /** Connect to the queue. Create it if not exists

View File

@@ -99,8 +99,8 @@ class Robotstxt
$line = trim($content[$nb]); $line = trim($content[$nb]);
if (stripos($line, "Sitemap:") === 0) { if (stripos($line, "Sitemap:") === 0) {
// Already managed in the general parser. Not needed in the specific // Already managed in the general parser. Not needed in the specific
// user-agent parser. Must at least be catched to not generate an // user-agent parser. Must at least be catched to not generate an
// error // error
} elseif (stripos($line, "Host:") === 0) { } elseif (stripos($line, "Host:") === 0) {
if ($this->host !== null) { if ($this->host !== null) {
$this->errors[$nb] = dgettext( $this->errors[$nb] = dgettext(
@@ -115,7 +115,7 @@ class Robotstxt
} elseif (stripos($line, "allow:") === 0) { } elseif (stripos($line, "allow:") === 0) {
$allow = $this->getValueFromLine($line); $allow = $this->getValueFromLine($line);
if (trim($allow) === "" || $allow[0] === "/") { if (trim($allow) === "" || $allow[0] === "/") {
$this->allow[] = $allow; $this->allow[] = $allow;
} else { } else {
$this->errors[$nb] = dgettext( $this->errors[$nb] = dgettext(
"domframework", "domframework",

View File

@@ -354,7 +354,7 @@ class Route
if ( if (
isset($_POST["_METHOD"]) && isset($_POST["_METHOD"]) &&
( (
$_POST["_METHOD"] === "GET" || $_POST["_METHOD"] === "GET" ||
$_POST["_METHOD"] === "POST" || $_POST["_METHOD"] === "POST" ||
$_POST["_METHOD"] === "PUT" || $_POST["_METHOD"] === "PUT" ||
$_POST["_METHOD"] === "DELETE" || $_POST["_METHOD"] === "DELETE" ||

View File

@@ -154,19 +154,19 @@ class RouteSQL
switch ($flash[0]) { switch ($flash[0]) {
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";
@@ -457,7 +457,7 @@ class RouteSQL
$foreignSelect $foreignSelect
); );
} }
// Limiting access to data only to data with read access right // Limiting access to data only to data with read access right
foreach ($data as $key => $vals) { foreach ($data as $key => $vals) {
if ( if (
$this->accessright( $this->accessright(
@@ -783,7 +783,7 @@ class RouteSQL
$this->url_prefix . $this->url_prefix .
"(\?({p1}=({v1})?)(&{p2}=({v2})?(&{p3}=({v3})?)?)?)?", "(\?({p1}=({v1})?)(&{p2}=({v2})?(&{p3}=({v3})?)?)?)?",
function ($p1, $v1, $p2, $v2, $p3, $v3, $chain = null) use ($route) { 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 !== null) {
if ( if (
$this->chained->accessright($this->authHTML["email"], $chain) !== $this->chained->accessright($this->authHTML["email"], $chain) !==
@@ -841,9 +841,9 @@ class RouteSQL
if (isset($_COOKIE["$cookiePrefix-search"])) { if (isset($_COOKIE["$cookiePrefix-search"])) {
$search = $_COOKIE["$cookiePrefix-search"]; $search = $_COOKIE["$cookiePrefix-search"];
} }
// num is the number of elements displayed by page // num is the number of elements displayed by page
// page is the page to display // page is the page to display
// Allow the parameters to be sent in any order // Allow the parameters to be sent in any order
if ($p1 === "num") { if ($p1 === "num") {
$num = $v1; $num = $v1;
} }
@@ -891,10 +891,10 @@ class RouteSQL
time() + 3600 * 24 * 30, time() + 3600 * 24 * 30,
$this->path $this->path
); );
//echo "PAGE=$page\n"; //echo "PAGE=$page\n";
//echo "NUM=$num\n"; //echo "NUM=$num\n";
//echo "SEARCH=$search\n"; //echo "SEARCH=$search\n";
//$route->debug=$this->debug; //$route->debug=$this->debug;
$this->connect(); $this->connect();
$csrf = new Csrf(); $csrf = new Csrf();
$token = $csrf->createToken(); $token = $csrf->createToken();
@@ -936,7 +936,7 @@ class RouteSQL
$foreignSelect $foreignSelect
); );
} }
// Limiting access to data only to data with read access right // Limiting access to data only to data with read access right
foreach ($data as $key => $vals) { foreach ($data as $key => $vals) {
if ( if (
$this->accessright( $this->accessright(
@@ -948,8 +948,8 @@ class RouteSQL
} }
} }
// Get the non mandatory foreign keys and display them instead of the // Get the non mandatory foreign keys and display them instead of the
// unusable id // unusable id
$foreignData = array(); $foreignData = array();
if (isset($this->objectDB->foreign)) { if (isset($this->objectDB->foreign)) {
foreach ($this->objectDB->foreign as $foreign => $params) { foreach ($this->objectDB->foreign as $foreign => $params) {
@@ -976,9 +976,9 @@ class RouteSQL
$associated = array(); $associated = array();
$unique = reset($foreignObject->unique); $unique = reset($foreignObject->unique);
foreach ($tmpData as $vals) { foreach ($tmpData as $vals) {
// TODO : If $foreignObject->unique is not an array ? // TODO : If $foreignObject->unique is not an array ?
// or multidimensionnal array // or multidimensionnal array
$associated[$vals[$column]] = $vals[$unique]; $associated[$vals[$column]] = $vals[$unique];
} }
// Add the unique text to the identifier // Add the unique text to the identifier
foreach ($data as $line => $vals) { foreach ($data as $line => $vals) {
@@ -1001,7 +1001,7 @@ class RouteSQL
$route->redirect("/" . str_replace("{chain}", $chain, $this->url_prefix) $route->redirect("/" . str_replace("{chain}", $chain, $this->url_prefix)
. "?page=1&num=$num&search=$search", ""); . "?page=1&num=$num&search=$search", "");
} }
// Push on the last page if the values are too high // Push on the last page if the values are too high
if ($nbentries > 0 && ($page - 1) * $num > $nbentries) { if ($nbentries > 0 && ($page - 1) * $num > $nbentries) {
$maxPage = intval($nbentries / $num) + 1; $maxPage = intval($nbentries / $num) + 1;
$route->redirect("/" . str_replace("{chain}", $chain, $this->url_prefix) . $route->redirect("/" . str_replace("{chain}", $chain, $this->url_prefix) .
@@ -1010,7 +1010,7 @@ class RouteSQL
$content = ""; $content = "";
// Internal CSS // Internal CSS
if ($this->enableInternalCSS === true) { if ($this->enableInternalCSS === true) {
$content .= "<style type='text/css' scoped='scoped'>\n"; $content .= "<style type='text/css' scoped='scoped'>\n";
$content .= ".routeSQL { $content .= ".routeSQL {
@@ -1314,7 +1314,7 @@ class RouteSQL
$route->get( $route->get(
$this->url_prefix . "/{id}/delete/{token}", $this->url_prefix . "/{id}/delete/{token}",
function ($id, $token, $chain = null) { 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 !== null) {
if ( if (
$this->chained->editright($this->authHTML["email"], $chain) !== $this->chained->editright($this->authHTML["email"], $chain) !==
@@ -1372,10 +1372,10 @@ class RouteSQL
); );
} }
$this->connect(); $this->connect();
$csrf = new Csrf(); $csrf = new Csrf();
$renderer = new Renderer(); $renderer = new Renderer();
$route = new Route(); $route = new Route();
try { try {
$csrf->checkToken($token); $csrf->checkToken($token);
$this->objectDB->delete($id); $this->objectDB->delete($id);

View File

@@ -296,7 +296,7 @@ class Sse
// and reopen it just after // and reopen it just after
if ( if (
key_exists($event, $this->fps) && ( key_exists($event, $this->fps) && (
! file_exists($this->files[$event]) || ! file_exists($this->files[$event]) ||
! is_readable($this->files[$event]) ! is_readable($this->files[$event])
) )
) { ) {

View File

@@ -1,6 +1,7 @@
<?php <?php
/** DomFramework /**
* DomFramework
* @package domframework * @package domframework
* @author Dominique Fournier <dominique@fournier38.fr> * @author Dominique Fournier <dominique@fournier38.fr>
* @license BSD * @license BSD