php-cs-fixer for all the code
This commit is contained in:
@@ -8,10 +8,10 @@
|
||||
|
||||
namespace Domframework;
|
||||
|
||||
/*
|
||||
* To use it, the $serverKey must be defined. It can be created by example,
|
||||
* by using $serverKey = sha1 (microtime (true));
|
||||
*/
|
||||
/*
|
||||
* To use it, the $serverKey must be defined. It can be created by example,
|
||||
* by using $serverKey = sha1 (microtime (true));
|
||||
*/
|
||||
class Authjwt extends Auth
|
||||
{
|
||||
// PROPERTIES SET BY AUTH
|
||||
|
||||
@@ -82,8 +82,8 @@ class Authparams
|
||||
if (!isset($_SERVER['PHP_AUTH_USER'])) {
|
||||
throw new \Exception("No user defined in HTTP header", 401);
|
||||
//header("WWW-Authenticate: Basic realm=\"$realm\"");
|
||||
//header("HTTP/1.0 401 Unauthorized");
|
||||
//die ($realm);
|
||||
//header("HTTP/1.0 401 Unauthorized");
|
||||
//die ($realm);
|
||||
} else {
|
||||
if (! array_key_exists("PHP_AUTH_PW", $_SERVER)) {
|
||||
$_SERVER["PHP_AUTH_PW"] = null;
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Domframework;
|
||||
/** User authentication against SQL database */
|
||||
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;
|
||||
/** The username to connect to the database */
|
||||
public $username = null;
|
||||
|
||||
@@ -41,8 +41,8 @@ class Authzgroups
|
||||
*/
|
||||
public function userrightsget($module, $user)
|
||||
{
|
||||
// if (isset ($_SESSION["domframework"]["authzgroups"][$module][$user]))
|
||||
// return $_SESSION["domframework"]["authzgroups"][$module][$user];
|
||||
// if (isset ($_SESSION["domframework"]["authzgroups"][$module][$user]))
|
||||
// return $_SESSION["domframework"]["authzgroups"][$module][$user];
|
||||
if ($this->rightCache !== null) {
|
||||
return $this->rightCache;
|
||||
}
|
||||
|
||||
@@ -68,8 +68,8 @@ class Authzgroupsoo
|
||||
*/
|
||||
public function userrightsget($module, $user)
|
||||
{
|
||||
// if (isset ($_SESSION["domframework"]["authzgroups"][$module][$user]))
|
||||
// return $_SESSION["domframework"]["authzgroups"][$module][$user];
|
||||
// if (isset ($_SESSION["domframework"]["authzgroups"][$module][$user]))
|
||||
// return $_SESSION["domframework"]["authzgroups"][$module][$user];
|
||||
if ($this->rightCache !== null) {
|
||||
return $this->rightCache;
|
||||
}
|
||||
@@ -1353,8 +1353,8 @@ class Authzgroupsoo
|
||||
case "RO":
|
||||
$right = 1;
|
||||
break;
|
||||
// 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.
|
||||
// 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.
|
||||
case "NO":
|
||||
$right = 0;
|
||||
break;
|
||||
|
||||
142
src/Dblayer.php
142
src/Dblayer.php
@@ -162,7 +162,7 @@ class Dblayer
|
||||
$this->dsn = $dsn;
|
||||
switch ($driver[0]) {
|
||||
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);
|
||||
if (! is_writeable(dirname($file))) {
|
||||
throw new \Exception(
|
||||
@@ -189,8 +189,8 @@ class Dblayer
|
||||
) {
|
||||
chmod($file, 0666);
|
||||
}
|
||||
// Print the instances of PDO objects stored :
|
||||
// var_dump (self::$instance);
|
||||
// Print the instances of PDO objects stored :
|
||||
// var_dump (self::$instance);
|
||||
if (! array_key_exists($this->dsn, self::$instance)) {
|
||||
if ($this->debug) {
|
||||
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");
|
||||
$this->sep = "`";
|
||||
break;
|
||||
case "mysql":
|
||||
if (! array_key_exists($this->dsn, self::$instance)) {
|
||||
if ($this->debug) {
|
||||
echo "CONNECT TO DATABASE\n";
|
||||
echo "CONNECT TO DATABASE\n";
|
||||
}
|
||||
try {
|
||||
$driver_options[\PDO::MYSQL_ATTR_FOUND_ROWS] = 1;
|
||||
@@ -228,23 +228,23 @@ class Dblayer
|
||||
$password,
|
||||
$driver_options
|
||||
);
|
||||
self::$instance[$this->dsn]->setAttribute(
|
||||
\PDO::ATTR_ERRMODE,
|
||||
\PDO::ERRMODE_EXCEPTION
|
||||
);
|
||||
self::$instance[$this->dsn]->setAttribute(
|
||||
\PDO::ATTR_ERRMODE,
|
||||
\PDO::ERRMODE_EXCEPTION
|
||||
);
|
||||
} 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");
|
||||
$this->sep = "`";
|
||||
break;
|
||||
case "pgsql":
|
||||
if (! array_key_exists($this->dsn, self::$instance)) {
|
||||
if ($this->debug) {
|
||||
echo "CONNECT TO DATABASE\n";
|
||||
echo "CONNECT TO DATABASE\n";
|
||||
}
|
||||
try {
|
||||
self::$instance[$this->dsn] = new \PDO(
|
||||
@@ -253,16 +253,16 @@ class Dblayer
|
||||
$password,
|
||||
$driver_options
|
||||
);
|
||||
self::$instance[$this->dsn]->setAttribute(
|
||||
\PDO::ATTR_ERRMODE,
|
||||
\PDO::ERRMODE_EXCEPTION
|
||||
);
|
||||
self::$instance[$this->dsn]->setAttribute(
|
||||
\PDO::ATTR_ERRMODE,
|
||||
\PDO::ERRMODE_EXCEPTION
|
||||
);
|
||||
} 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'");
|
||||
$this->sep = "\"";
|
||||
break;
|
||||
@@ -623,17 +623,17 @@ class Dblayer
|
||||
));
|
||||
return $errors;
|
||||
}
|
||||
/* if (! isset($data[$foreign][0])) {
|
||||
$errors[] = array("error", sprintf(
|
||||
dgettext(
|
||||
"domframework",
|
||||
"The field type for column '%s' is not provided"
|
||||
),
|
||||
$foreign
|
||||
));
|
||||
return $errors;
|
||||
continue;
|
||||
}*/
|
||||
/* if (! isset($data[$foreign][0])) {
|
||||
$errors[] = array("error", sprintf(
|
||||
dgettext(
|
||||
"domframework",
|
||||
"The field type for column '%s' is not provided"
|
||||
),
|
||||
$foreign
|
||||
));
|
||||
return $errors;
|
||||
continue;
|
||||
}*/
|
||||
} else {
|
||||
if (! array_key_exists($foreign, $d)) {
|
||||
continue;
|
||||
@@ -1324,11 +1324,11 @@ class Dblayer
|
||||
$i = 0;
|
||||
foreach ($this->fields as $field => $params) {
|
||||
if ($i > 0) {
|
||||
$sql .= ",\n";
|
||||
$sql .= ",\n";
|
||||
}
|
||||
// Name of field
|
||||
// Name of field
|
||||
$sql .= "$this->sep$field$this->sep ";
|
||||
// Type of field : in $params[0]
|
||||
// Type of field : in $params[0]
|
||||
if (!isset($params[0])) {
|
||||
throw new \Exception(sprintf(
|
||||
dgettext(
|
||||
@@ -1375,21 +1375,21 @@ class Dblayer
|
||||
$field
|
||||
), 500);
|
||||
}
|
||||
// Primary key
|
||||
// Primary key
|
||||
if ($this->primary === $field) {
|
||||
$sql .= " PRIMARY KEY";
|
||||
}
|
||||
// Others parameters for field
|
||||
// Sort to put the autoincrement field in front of params, if it is
|
||||
// present
|
||||
// Others parameters for field
|
||||
// Sort to put the autoincrement field in front of params, if it is
|
||||
// present
|
||||
sort($params);
|
||||
foreach ($params as $p) {
|
||||
switch ($p) {
|
||||
case "not null":
|
||||
$sql .= " NOT NULL";
|
||||
$sql .= " NOT NULL";
|
||||
break;
|
||||
case "autoincrement":
|
||||
$sql .= " AUTOINCREMENT";
|
||||
$sql .= " AUTOINCREMENT";
|
||||
break;
|
||||
default:
|
||||
throw new \Exception(sprintf(
|
||||
@@ -1403,19 +1403,19 @@ class Dblayer
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
// Unique fields
|
||||
// Unique fields
|
||||
if ($this->unique !== null) {
|
||||
if (!is_array($this->unique)) {
|
||||
throw new \Exception(
|
||||
dgettext(
|
||||
"domframework",
|
||||
"The Unique field definition is not an array"
|
||||
),
|
||||
500
|
||||
);
|
||||
throw new \Exception(
|
||||
dgettext(
|
||||
"domframework",
|
||||
"The Unique field definition is not an array"
|
||||
),
|
||||
500
|
||||
);
|
||||
}
|
||||
foreach ($this->unique as $u) {
|
||||
$sql .= ",\n UNIQUE ($this->sep";
|
||||
$sql .= ",\n UNIQUE ($this->sep";
|
||||
if (is_array($u)) {
|
||||
$sql .= implode("$this->sep,$this->sep", $u);
|
||||
} else {
|
||||
@@ -1424,7 +1424,7 @@ class Dblayer
|
||||
$sql .= "$this->sep)";
|
||||
}
|
||||
}
|
||||
// Foreign keys
|
||||
// Foreign keys
|
||||
$i = 0;
|
||||
foreach ($this->foreign as $field => $k) {
|
||||
$sql .= ",\n FOREIGN KEY($this->sep$field$this->sep) " .
|
||||
@@ -1444,11 +1444,11 @@ class Dblayer
|
||||
$i = 0;
|
||||
foreach ($this->fields as $field => $params) {
|
||||
if ($i > 0) {
|
||||
$sql .= ",\n";
|
||||
$sql .= ",\n";
|
||||
}
|
||||
// Name of field
|
||||
// Name of field
|
||||
$sql .= "$this->sep$field$this->sep ";
|
||||
// Type of field : in $params[0]
|
||||
// Type of field : in $params[0]
|
||||
if (!isset($params[0])) {
|
||||
throw new \Exception(dgettext(
|
||||
"domframework",
|
||||
@@ -1487,21 +1487,21 @@ class Dblayer
|
||||
$field
|
||||
), 500);
|
||||
}
|
||||
// Primary key
|
||||
// Primary key
|
||||
if ($this->primary === $field) {
|
||||
$sql .= " PRIMARY KEY";
|
||||
}
|
||||
// Others parameters for field
|
||||
// Sort to put the autoincrement field in front of params, if it is
|
||||
// present
|
||||
// Others parameters for field
|
||||
// Sort to put the autoincrement field in front of params, if it is
|
||||
// present
|
||||
sort($params);
|
||||
foreach ($params as $p) {
|
||||
switch ($p) {
|
||||
case "not null":
|
||||
$sql .= " NOT NULL";
|
||||
$sql .= " NOT NULL";
|
||||
break;
|
||||
case "autoincrement":
|
||||
$sql .= " AUTO_INCREMENT";
|
||||
$sql .= " AUTO_INCREMENT";
|
||||
break;
|
||||
default:
|
||||
throw new \Exception(sprintf(
|
||||
@@ -1515,10 +1515,10 @@ class Dblayer
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
// Unique fields
|
||||
// Unique fields
|
||||
if ($this->unique !== null) {
|
||||
foreach ($this->unique as $u) {
|
||||
$sql .= ",\n UNIQUE ($this->sep";
|
||||
$sql .= ",\n UNIQUE ($this->sep";
|
||||
if (is_array($u)) {
|
||||
$sql .= implode("$this->sep,$this->sep", $u);
|
||||
} else {
|
||||
@@ -1527,7 +1527,7 @@ class Dblayer
|
||||
$sql .= "$this->sep)";
|
||||
}
|
||||
}
|
||||
// Foreign keys
|
||||
// Foreign keys
|
||||
$i = 0;
|
||||
foreach ($this->foreign as $field => $k) {
|
||||
$sql .= ",\n FOREIGN KEY($this->sep$field$this->sep) " .
|
||||
@@ -1549,14 +1549,14 @@ class Dblayer
|
||||
$i = 0;
|
||||
foreach ($this->fields as $field => $params) {
|
||||
if ($i > 0) {
|
||||
$sql .= ",\n";
|
||||
$sql .= ",\n";
|
||||
}
|
||||
// Name of field
|
||||
// Name of field
|
||||
$sql .= "\"$field\" ";
|
||||
if (in_array("autoincrement", $params)) {
|
||||
$sql .= "SERIAL";
|
||||
} else {
|
||||
// Type of field : in $params[0]
|
||||
// Type of field : in $params[0]
|
||||
if (!isset($params[0])) {
|
||||
throw new \Exception(sprintf(
|
||||
dgettext(
|
||||
@@ -1601,18 +1601,18 @@ class Dblayer
|
||||
$field
|
||||
), 500);
|
||||
}
|
||||
// Primary key
|
||||
// Primary key
|
||||
if ($this->primary === $field) {
|
||||
$sql .= " PRIMARY KEY";
|
||||
}
|
||||
// Others parameters for field
|
||||
// Sort to put the autoincrement field in front of params, if it is
|
||||
// present
|
||||
// Others parameters for field
|
||||
// Sort to put the autoincrement field in front of params, if it is
|
||||
// present
|
||||
sort($params);
|
||||
foreach ($params as $p) {
|
||||
switch ($p) {
|
||||
case "not null":
|
||||
$sql .= " NOT NULL";
|
||||
$sql .= " NOT NULL";
|
||||
break;
|
||||
default:
|
||||
throw new \Exception(sprintf(
|
||||
@@ -1627,10 +1627,10 @@ class Dblayer
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
// Unique fields
|
||||
// Unique fields
|
||||
if ($this->unique !== null) {
|
||||
foreach ($this->unique as $u) {
|
||||
$sql .= ",\n UNIQUE (\"";
|
||||
$sql .= ",\n UNIQUE (\"";
|
||||
if (is_array($u)) {
|
||||
$sql .= implode("\",\"", $u);
|
||||
} else {
|
||||
@@ -1639,7 +1639,7 @@ class Dblayer
|
||||
$sql .= "\")";
|
||||
}
|
||||
}
|
||||
// Foreign keys
|
||||
// Foreign keys
|
||||
$i = 0;
|
||||
foreach ($this->foreign as $field => $k) {
|
||||
$sql .= ",\n FOREIGN KEY(\"$field\") REFERENCES \"" . $k[0] . "\"(\"" .
|
||||
|
||||
@@ -117,7 +117,7 @@ class Dblayeroo
|
||||
$this->dsn = $dsn;
|
||||
switch ($driver[0]) {
|
||||
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);
|
||||
if (! is_writeable(dirname($file))) {
|
||||
$this->DBException(dgettext(
|
||||
@@ -138,8 +138,8 @@ class Dblayeroo
|
||||
) {
|
||||
chmod($file, 0666);
|
||||
}
|
||||
// Print the instances of PDO objects stored :
|
||||
// var_dump (self::$instance);
|
||||
// Print the instances of PDO objects stored :
|
||||
// var_dump (self::$instance);
|
||||
if (! array_key_exists($this->dsn, self::$instance)) {
|
||||
$this->debugLog("CONNECT TO SQLite DATABASE", 2);
|
||||
try {
|
||||
@@ -157,7 +157,7 @@ class Dblayeroo
|
||||
$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");
|
||||
$this->sep = "`";
|
||||
if ($this->databasename() === null) {
|
||||
@@ -168,29 +168,29 @@ class Dblayeroo
|
||||
if (! array_key_exists($this->dsn, self::$instance)) {
|
||||
$this->debugLog("CONNECT TO MySQL DATABASE", 2);
|
||||
try {
|
||||
$driver_options[\PDO::MYSQL_ATTR_FOUND_ROWS] = 1;
|
||||
self::$instance[$this->dsn] = new \PDO(
|
||||
$dsn,
|
||||
$username,
|
||||
$password,
|
||||
$driver_options
|
||||
);
|
||||
self::$instance[$this->dsn]->setAttribute(
|
||||
\PDO::ATTR_ERRMODE,
|
||||
\PDO::ERRMODE_EXCEPTION
|
||||
);
|
||||
$driver_options[\PDO::MYSQL_ATTR_FOUND_ROWS] = 1;
|
||||
self::$instance[$this->dsn] = new \PDO(
|
||||
$dsn,
|
||||
$username,
|
||||
$password,
|
||||
$driver_options
|
||||
);
|
||||
self::$instance[$this->dsn]->setAttribute(
|
||||
\PDO::ATTR_ERRMODE,
|
||||
\PDO::ERRMODE_EXCEPTION
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
$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");
|
||||
$this->sep = "`";
|
||||
if ($this->databasename() === null) {
|
||||
$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(
|
||||
"SHOW VARIABLES LIKE 'max_allowed_packet'",
|
||||
\PDO::FETCH_COLUMN,
|
||||
@@ -212,22 +212,22 @@ class Dblayeroo
|
||||
if (! array_key_exists($this->dsn, self::$instance)) {
|
||||
$this->debugLog("CONNECT TO PGSQL DATABASE", 2);
|
||||
try {
|
||||
self::$instance[$this->dsn] = new \PDO(
|
||||
$dsn,
|
||||
$username,
|
||||
$password,
|
||||
$driver_options
|
||||
);
|
||||
self::$instance[$this->dsn]->setAttribute(
|
||||
\PDO::ATTR_ERRMODE,
|
||||
\PDO::ERRMODE_EXCEPTION
|
||||
);
|
||||
self::$instance[$this->dsn] = new \PDO(
|
||||
$dsn,
|
||||
$username,
|
||||
$password,
|
||||
$driver_options
|
||||
);
|
||||
self::$instance[$this->dsn]->setAttribute(
|
||||
\PDO::ATTR_ERRMODE,
|
||||
\PDO::ERRMODE_EXCEPTION
|
||||
);
|
||||
} 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'");
|
||||
$this->sep = "\"";
|
||||
if ($this->databasename() === null) {
|
||||
@@ -335,7 +335,7 @@ class Dblayeroo
|
||||
$res = array();
|
||||
while ($d = $st->fetch(\PDO::FETCH_ASSOC)) {
|
||||
if ($d["name"] !== "sqlite_sequence") {
|
||||
$res[] = $d["name"];
|
||||
$res[] = $d["name"];
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -413,9 +413,9 @@ class Dblayeroo
|
||||
$i = 0;
|
||||
foreach ($this->fields as $field => $params) {
|
||||
if ($i > 0) {
|
||||
$sql .= ",\n";
|
||||
$sql .= ",\n";
|
||||
}
|
||||
// Name of field
|
||||
// Name of field
|
||||
$sql .= "$this->sep$field$this->sep ";
|
||||
switch ($this->fieldTypeLight($field)) {
|
||||
case "blob":
|
||||
@@ -431,8 +431,8 @@ class Dblayeroo
|
||||
$params = array_slice($params, 1);
|
||||
break;
|
||||
case "float":
|
||||
$sql .= "FLOAT";
|
||||
$params = array_slice($params, 1);
|
||||
$sql .= "FLOAT";
|
||||
$params = array_slice($params, 1);
|
||||
break;
|
||||
case "integer":
|
||||
$sql .= "INTEGER";
|
||||
@@ -453,18 +453,18 @@ class Dblayeroo
|
||||
$field
|
||||
), 500);
|
||||
}
|
||||
// Primary key
|
||||
// Primary key
|
||||
if ($this->primary === $field) {
|
||||
$sql .= " PRIMARY KEY";
|
||||
$sql .= " PRIMARY KEY";
|
||||
}
|
||||
// Others parameters for field
|
||||
// Sort to put the autoincrement field in front of params, if it is
|
||||
// present
|
||||
// Others parameters for field
|
||||
// Sort to put the autoincrement field in front of params, if it is
|
||||
// present
|
||||
sort($params);
|
||||
foreach ($params as $p) {
|
||||
switch ($p) {
|
||||
case "not null":
|
||||
$sql .= " NOT NULL";
|
||||
$sql .= " NOT NULL";
|
||||
break;
|
||||
case "autoincrement":
|
||||
if ($this->primary !== $field) {
|
||||
@@ -491,19 +491,19 @@ class Dblayeroo
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
// Unique fields
|
||||
// Unique fields
|
||||
if ($this->unique !== null) {
|
||||
if (!is_array($this->unique)) {
|
||||
$this->DBException(
|
||||
dgettext(
|
||||
"domframework",
|
||||
"The Unique field definition is not an array"
|
||||
),
|
||||
500
|
||||
);
|
||||
$this->DBException(
|
||||
dgettext(
|
||||
"domframework",
|
||||
"The Unique field definition is not an array"
|
||||
),
|
||||
500
|
||||
);
|
||||
}
|
||||
foreach ($this->unique as $u) {
|
||||
$sql .= ",\n UNIQUE ($this->sep";
|
||||
$sql .= ",\n UNIQUE ($this->sep";
|
||||
if (is_array($u)) {
|
||||
$sql .= implode("$this->sep,$this->sep", $u);
|
||||
} else {
|
||||
@@ -512,7 +512,7 @@ class Dblayeroo
|
||||
$sql .= "$this->sep)";
|
||||
}
|
||||
}
|
||||
// Foreign keys
|
||||
// Foreign keys
|
||||
$i = 0;
|
||||
foreach ($this->foreign as $field => $k) {
|
||||
$field = explode(",", $field);
|
||||
@@ -539,9 +539,9 @@ class Dblayeroo
|
||||
$i = 0;
|
||||
foreach ($this->fields as $field => $params) {
|
||||
if ($i > 0) {
|
||||
$sql .= ",\n";
|
||||
$sql .= ",\n";
|
||||
}
|
||||
// Name of field
|
||||
// Name of field
|
||||
$sql .= "$this->sep$field$this->sep ";
|
||||
switch ($this->fieldTypeLight($field)) {
|
||||
case "blob":
|
||||
@@ -558,8 +558,8 @@ class Dblayeroo
|
||||
$params = array_slice($params, 1);
|
||||
break;
|
||||
case "float":
|
||||
$sql .= "FLOAT";
|
||||
$params = array_slice($params, 1);
|
||||
$sql .= "FLOAT";
|
||||
$params = array_slice($params, 1);
|
||||
break;
|
||||
case "datetime":
|
||||
$sql .= "DATETIME";
|
||||
@@ -578,18 +578,18 @@ class Dblayeroo
|
||||
$field
|
||||
), 500);
|
||||
}
|
||||
// Primary key
|
||||
// Primary key
|
||||
if ($this->primary === $field) {
|
||||
$sql .= " PRIMARY KEY";
|
||||
$sql .= " PRIMARY KEY";
|
||||
}
|
||||
// Others parameters for field
|
||||
// Sort to put the autoincrement field in front of params, if it is
|
||||
// present
|
||||
// Others parameters for field
|
||||
// Sort to put the autoincrement field in front of params, if it is
|
||||
// present
|
||||
sort($params);
|
||||
foreach ($params as $p) {
|
||||
switch ($p) {
|
||||
case "not null":
|
||||
$sql .= " NOT NULL";
|
||||
$sql .= " NOT NULL";
|
||||
break;
|
||||
case "autoincrement":
|
||||
if ($this->primary !== $field) {
|
||||
@@ -616,10 +616,10 @@ class Dblayeroo
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
// Unique fields
|
||||
// Unique fields
|
||||
if ($this->unique !== null) {
|
||||
foreach ($this->unique as $u) {
|
||||
$sql .= ",\n UNIQUE ($this->sep";
|
||||
$sql .= ",\n UNIQUE ($this->sep";
|
||||
if (is_array($u)) {
|
||||
$sql .= implode("$this->sep,$this->sep", $u);
|
||||
} else {
|
||||
@@ -628,7 +628,7 @@ class Dblayeroo
|
||||
$sql .= "$this->sep)";
|
||||
}
|
||||
}
|
||||
// Foreign keys
|
||||
// Foreign keys
|
||||
$i = 0;
|
||||
foreach ($this->foreign as $field => $k) {
|
||||
$field = explode(",", $field);
|
||||
@@ -654,9 +654,9 @@ class Dblayeroo
|
||||
$i = 0;
|
||||
foreach ($this->fields as $field => $params) {
|
||||
if ($i > 0) {
|
||||
$sql .= ",\n";
|
||||
$sql .= ",\n";
|
||||
}
|
||||
// Name of field
|
||||
// Name of field
|
||||
$sql .= "\"$field\" ";
|
||||
if (in_array("autoincrement", $params)) {
|
||||
if ($this->primary !== $field) {
|
||||
@@ -668,25 +668,25 @@ class Dblayeroo
|
||||
$field
|
||||
), 500);
|
||||
}
|
||||
$sql .= "SERIAL";
|
||||
$sql .= "SERIAL";
|
||||
} else {
|
||||
switch ($this->fieldTypeLight($field)) {
|
||||
case "blob":
|
||||
$sql .= "BLOB";
|
||||
$params = array_slice($params, 1);
|
||||
$sql .= "BLOB";
|
||||
$params = array_slice($params, 1);
|
||||
break;
|
||||
case "integer":
|
||||
$sql .= "INTEGER";
|
||||
$params = array_slice($params, 1);
|
||||
$sql .= "INTEGER";
|
||||
$params = array_slice($params, 1);
|
||||
break;
|
||||
case "varchar":
|
||||
$length = $this->fieldLength($field);
|
||||
$sql .= "VARCHAR($length)";
|
||||
$params = array_slice($params, 1);
|
||||
$length = $this->fieldLength($field);
|
||||
$sql .= "VARCHAR($length)";
|
||||
$params = array_slice($params, 1);
|
||||
break;
|
||||
case "float":
|
||||
$sql .= "FLOAT";
|
||||
$params = array_slice($params, 1);
|
||||
$sql .= "FLOAT";
|
||||
$params = array_slice($params, 1);
|
||||
break;
|
||||
case "datetime":
|
||||
$sql .= "timestamp with time zone";
|
||||
@@ -705,13 +705,13 @@ class Dblayeroo
|
||||
$field
|
||||
), 500);
|
||||
}
|
||||
// Primary key
|
||||
// Primary key
|
||||
if ($this->primary === $field) {
|
||||
$sql .= " PRIMARY KEY";
|
||||
}
|
||||
// Others parameters for field
|
||||
// Sort to put the autoincrement field in front of params, if it is
|
||||
// present
|
||||
// Others parameters for field
|
||||
// Sort to put the autoincrement field in front of params, if it is
|
||||
// present
|
||||
sort($params);
|
||||
foreach ($params as $p) {
|
||||
switch ($p) {
|
||||
@@ -732,10 +732,10 @@ class Dblayeroo
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
// Unique fields
|
||||
// Unique fields
|
||||
if ($this->unique !== null) {
|
||||
foreach ($this->unique as $u) {
|
||||
$sql .= ",\n UNIQUE (\"";
|
||||
$sql .= ",\n UNIQUE (\"";
|
||||
if (is_array($u)) {
|
||||
$sql .= implode("\",\"", $u);
|
||||
} else {
|
||||
@@ -744,7 +744,7 @@ class Dblayeroo
|
||||
$sql .= "\")";
|
||||
}
|
||||
}
|
||||
// Foreign keys
|
||||
// Foreign keys
|
||||
$i = 0;
|
||||
foreach ($this->foreign as $field => $k) {
|
||||
$field = explode(",", $field);
|
||||
@@ -830,14 +830,14 @@ class Dblayeroo
|
||||
$st = self::$instance[$this->dsn]->prepare(
|
||||
"PRAGMA index_info(" . $c["name"] . ")"
|
||||
);
|
||||
$st->execute();
|
||||
$content2 = $st->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$st->execute();
|
||||
$content2 = $st->fetchAll(\PDO::FETCH_ASSOC);
|
||||
if (count($content2) > 1) {
|
||||
$index = array();
|
||||
$index = array();
|
||||
foreach ($content2 as $c2) {
|
||||
$index[] = $c2["name"];
|
||||
}
|
||||
$unique[$content2[0]["cid"] - 1] = $index;
|
||||
$unique[$content2[0]["cid"] - 1] = $index;
|
||||
} elseif (count($content2) === 1 && $content2[0]["cid"] >= 1) {
|
||||
$index = $content2[0]["name"];
|
||||
$unique[$content2[0]["cid"] - 1] = $index;
|
||||
@@ -855,10 +855,10 @@ class Dblayeroo
|
||||
$st->execute();
|
||||
$content = $st->fetchAll(\PDO::FETCH_ASSOC);
|
||||
if (count($content) > 0 && $primary !== "") {
|
||||
$fields[$primary][] = "autoincrement";
|
||||
$fields[$primary][] = "autoincrement";
|
||||
}
|
||||
} 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(
|
||||
@@ -876,7 +876,7 @@ class Dblayeroo
|
||||
$cascade .= "ON DELETE " . $for["on_delete"];
|
||||
}
|
||||
if ($cascade !== "") {
|
||||
$tmp[] = $cascade;
|
||||
$tmp[] = $cascade;
|
||||
}
|
||||
$foreign[$for["from"]] = $tmp;
|
||||
}
|
||||
@@ -903,7 +903,7 @@ class Dblayeroo
|
||||
"unique" => $unique,
|
||||
"foreign" => $foreign,
|
||||
"foreignUsed" => $foreignUsed);
|
||||
break;
|
||||
break;
|
||||
case "mysql":
|
||||
$st = self::$instance[$this->dsn]->prepare(
|
||||
"SHOW COLUMNS FROM `$tableName`"
|
||||
@@ -922,10 +922,10 @@ class Dblayeroo
|
||||
$tmp[] = $col["Type"];
|
||||
}
|
||||
if ($col["Null"] === "NO") {
|
||||
$tmp[] = "not null";
|
||||
$tmp[] = "not null";
|
||||
}
|
||||
if ($col["Extra"] === "auto_increment") {
|
||||
$tmp[] = "autoincrement";
|
||||
$tmp[] = "autoincrement";
|
||||
}
|
||||
$fields[$col["Field"]] = $tmp;
|
||||
}
|
||||
@@ -985,7 +985,7 @@ class Dblayeroo
|
||||
$tmp[2] .= "ON DELETE " . $f["DELETE_RULE"];
|
||||
}
|
||||
if ($tmp[2] !== "") {
|
||||
$tmp[2] = trim($tmp[2]);
|
||||
$tmp[2] = trim($tmp[2]);
|
||||
} else {
|
||||
unset($tmp[2]);
|
||||
}
|
||||
@@ -1015,13 +1015,13 @@ class Dblayeroo
|
||||
"unique" => $unique,
|
||||
"foreign" => $foreign,
|
||||
"foreignUsed" => $foreignUsed);
|
||||
break;
|
||||
break;
|
||||
case "pgsql":
|
||||
$fields = array();
|
||||
$unique = array();
|
||||
$foreign = array();
|
||||
$primary = "";
|
||||
// Get the defined primary key if not autoincrement
|
||||
// Get the defined primary key if not autoincrement
|
||||
$st = self::$instance[$this->dsn]->prepare("
|
||||
SELECT a.attname, format_type(a.atttypid, a.atttypmod) AS data_type
|
||||
FROM pg_index i
|
||||
@@ -1035,7 +1035,7 @@ class Dblayeroo
|
||||
if (key_exists(0, $content)) {
|
||||
$primary = $content[0]["attname"];
|
||||
}
|
||||
// Get the primary key if autoincrement
|
||||
// Get the primary key if autoincrement
|
||||
$st = self::$instance[$this->dsn]->prepare(
|
||||
"SELECT *
|
||||
FROM information_schema.columns
|
||||
@@ -1051,11 +1051,11 @@ class Dblayeroo
|
||||
$tmp[] = $col["data_type"];
|
||||
}
|
||||
if ($col["is_nullable"] === "NO") {
|
||||
$tmp[] = "not null";
|
||||
$tmp[] = "not null";
|
||||
}
|
||||
if (is_string($col["column_default"]) && substr($col["column_default"], 0, 7) === "nextval") {
|
||||
$tmp[] = "autoincrement";
|
||||
$primary = $col["column_name"];
|
||||
$tmp[] = "autoincrement";
|
||||
$primary = $col["column_name"];
|
||||
}
|
||||
$fields[$col["column_name"]] = $tmp;
|
||||
}
|
||||
@@ -1116,7 +1116,7 @@ class Dblayeroo
|
||||
$tmp[2] .= "ON DELETE " . $f["delete_rule"];
|
||||
}
|
||||
if ($tmp[2] !== "") {
|
||||
$tmp[2] = trim($tmp[2]);
|
||||
$tmp[2] = trim($tmp[2]);
|
||||
} else {
|
||||
unset($tmp[2]);
|
||||
}
|
||||
@@ -1158,7 +1158,7 @@ class Dblayeroo
|
||||
"unique" => $unique,
|
||||
"foreign" => $foreign,
|
||||
"foreignUsed" => $foreignUsed);
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
$this->DBException(dgettext(
|
||||
"domframework",
|
||||
@@ -1172,7 +1172,7 @@ class Dblayeroo
|
||||
*/
|
||||
private function fieldTypeComplete($field)
|
||||
{
|
||||
// $this->debugLog ("Entering fieldTypeComplete (",$field,")", 2);
|
||||
// $this->debugLog ("Entering fieldTypeComplete (",$field,")", 2);
|
||||
if (! array_key_exists($field, $this->fields)) {
|
||||
$this->DBException(sprintf(
|
||||
"fieldType : can't find the definition for field '%s'",
|
||||
@@ -1335,7 +1335,7 @@ class Dblayeroo
|
||||
}
|
||||
if (
|
||||
$params[0] !== "integer" && (
|
||||
isset($params[1]) && $params[1] === "autoincrement" ||
|
||||
isset($params[1]) && $params[1] === "autoincrement" ||
|
||||
isset($params[2]) && $params[2] === "autoincrement"
|
||||
)
|
||||
) {
|
||||
@@ -2794,7 +2794,7 @@ class Dblayeroo
|
||||
if (! empty($this->limitExpression)) {
|
||||
$sql .= "\n LIMIT $this->limitExpression";
|
||||
}
|
||||
// No set Values for SELECT
|
||||
// No set Values for SELECT
|
||||
$this->setValues = array();
|
||||
break;
|
||||
case "INSERT":
|
||||
@@ -2805,7 +2805,7 @@ class Dblayeroo
|
||||
$i = 0;
|
||||
foreach ($this->setValues as $key => $val) {
|
||||
if ($i > 0) {
|
||||
$sql .= ",";
|
||||
$sql .= ",";
|
||||
}
|
||||
$sql .= $this->sep . $key . $this->sep;
|
||||
$i++;
|
||||
@@ -2820,7 +2820,7 @@ class Dblayeroo
|
||||
$i++;
|
||||
}
|
||||
$sql .= ")";
|
||||
// No WHERE in INSERT : remove the WHERE parameters
|
||||
// No WHERE in INSERT : remove the WHERE parameters
|
||||
$this->whereExpression = array();
|
||||
$this->whereValues = array();
|
||||
break;
|
||||
@@ -2836,7 +2836,7 @@ class Dblayeroo
|
||||
if (! empty($this->limitExpression)) {
|
||||
$sql .= " LIMIT $this->limitExpression";
|
||||
}
|
||||
// No set Values for DELETE
|
||||
// No set Values for DELETE
|
||||
$this->setValues = array();
|
||||
break;
|
||||
case "UPDATE":
|
||||
@@ -2848,7 +2848,7 @@ class Dblayeroo
|
||||
$i = 0;
|
||||
foreach ($this->setValues as $key => $val) {
|
||||
if ($i > 0) {
|
||||
$sql .= ",";
|
||||
$sql .= ",";
|
||||
}
|
||||
$hash = md5("$key, $val");
|
||||
$sql .= $this->sep . $key . $this->sep . "=:" . $hash;
|
||||
@@ -3127,7 +3127,7 @@ class Dblayeroo
|
||||
}
|
||||
switch ($this->fieldTypeLight($field)) {
|
||||
case "blob":
|
||||
// Blob can be anything. Do not test
|
||||
// Blob can be anything. Do not test
|
||||
break;
|
||||
case "integer":
|
||||
if (strspn($values[$field], "0123456789") !== strlen($values[$field])) {
|
||||
@@ -3551,13 +3551,13 @@ class Dblayeroo
|
||||
switch ($this->command) {
|
||||
case "SELECT":
|
||||
$result = $st->fetchAll(\PDO::FETCH_NUM);
|
||||
// There is no fetchAll corresponding to the columnName->value. Assign the
|
||||
// name to the value by index.
|
||||
// FETCH_ASSOC doesn't work in empty left join (return NULL instead of
|
||||
// the filled value)
|
||||
// There is no fetchAll corresponding to the columnName->value. Assign the
|
||||
// name to the value by index.
|
||||
// FETCH_ASSOC doesn't work in empty left join (return NULL instead of
|
||||
// the filled value)
|
||||
$fieldsAll = $this->fieldsAll(true);
|
||||
// If the displayed fields are all in the same table, remove the table
|
||||
// name in the columns
|
||||
// If the displayed fields are all in the same table, remove the table
|
||||
// name in the columns
|
||||
$cleanable = true;
|
||||
$cleanTable = "";
|
||||
foreach ($this->displayGet(true) as $display) {
|
||||
@@ -3567,26 +3567,26 @@ class Dblayeroo
|
||||
$matches
|
||||
);
|
||||
if ($cleanTable === "") {
|
||||
$cleanTable = $matches[1][0];
|
||||
$cleanTable = $matches[1][0];
|
||||
} elseif ($cleanTable !== $matches[1][0]) {
|
||||
$cleanable = false;
|
||||
break;
|
||||
$cleanable = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$columns = array_values($this->displayGet(true));
|
||||
// Get the columns names that will be displayed to user.
|
||||
// If the cleanable is possible, remove the table names
|
||||
// Get the columns names that will be displayed to user.
|
||||
// If the cleanable is possible, remove the table names
|
||||
$columnNames = array_combine($columns, $columns);
|
||||
//if ($this->joinObject === null && count ($this->displayGet (false)))
|
||||
//if ($this->joinObject === null && count ($this->displayGet (false)))
|
||||
if ($cleanable) {
|
||||
// Remove the table name as there is no collisions risk
|
||||
// In case of Alias, remove the $this->sep too
|
||||
// Remove the table name as there is no collisions risk
|
||||
// In case of Alias, remove the $this->sep too
|
||||
foreach ($columnNames as $key => $col) {
|
||||
// Remove the table and the separator if exists
|
||||
$col = preg_replace("#" . $this->sep . "[^" . $this->sep . "]+" .
|
||||
// Remove the table and the separator if exists
|
||||
$col = preg_replace("#" . $this->sep . "[^" . $this->sep . "]+" .
|
||||
$this->sep . "\.#U", "", $col);
|
||||
// Remove the separator if not table exists
|
||||
$col = str_replace($this->sep, "", $col);
|
||||
// Remove the separator if not table exists
|
||||
$col = str_replace($this->sep, "", $col);
|
||||
if ($col[0] === $this->sep) {
|
||||
$col = substr($col, 1);
|
||||
} elseif (strpos($col, "DISTINCT " . $this->sep) === 0) {
|
||||
@@ -3607,42 +3607,42 @@ class Dblayeroo
|
||||
}
|
||||
} else {
|
||||
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 ($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], "(");
|
||||
if ($pos) {
|
||||
// Function. The function that return an int must be added in this
|
||||
// list, to cast correctely the value
|
||||
$func = strtoupper(trim(substr($columns[$colNb], 0, $pos)));
|
||||
// Function. The function that return an int must be added in this
|
||||
// list, to cast correctely the value
|
||||
$func = strtoupper(trim(substr($columns[$colNb], 0, $pos)));
|
||||
if (in_array($func, array("AVG", "COUNT", "MAX", "MIN", "SUM"))) {
|
||||
$val = intval($val);
|
||||
}
|
||||
} else {
|
||||
$name = $columns[$colNb];
|
||||
$pos = strpos($columns[$colNb], " AS ");
|
||||
$name = $columns[$colNb];
|
||||
$pos = strpos($columns[$colNb], " AS ");
|
||||
if ($pos) {
|
||||
$name = substr($columns[$colNb], 0, $pos);
|
||||
}
|
||||
$name = str_replace("DISTINCT ", "", $name);
|
||||
/*if ($cleanable)
|
||||
$name = str_replace ($this->sep.$this->tableprefix.$this->table.
|
||||
$this->sep.".", "", $name);*/
|
||||
$name = str_replace("DISTINCT ", "", $name);
|
||||
/*if ($cleanable)
|
||||
$name = str_replace ($this->sep.$this->tableprefix.$this->table.
|
||||
$this->sep.".", "", $name);*/
|
||||
if (
|
||||
strtolower($fieldsAll[$name][0]) === "integer" &&
|
||||
$val !== null
|
||||
strtolower($fieldsAll[$name][0]) === "integer" &&
|
||||
$val !== null
|
||||
) {
|
||||
$val = intval($val);
|
||||
}
|
||||
}
|
||||
if (($pos = strpos($columns[$colNb], " AS " . $this->sep)) !== false) {
|
||||
$pos += strlen(" AS " . $this->sep);
|
||||
$colName = substr($columns[$colNb], $pos, -1);
|
||||
$pos += strlen(" AS " . $this->sep);
|
||||
$colName = substr($columns[$colNb], $pos, -1);
|
||||
} else {
|
||||
$colName = $columnNames[$columns[$colNb]];
|
||||
$colName = $columnNames[$columns[$colNb]];
|
||||
}
|
||||
$result[$rownb][$colName] = $val;
|
||||
unset($result[$rownb][$colNb]);
|
||||
@@ -3664,8 +3664,8 @@ class Dblayeroo
|
||||
"displayQuery" => $this->getDisplayQuery(),
|
||||
"nbrows" => $st->rowCount(),
|
||||
);
|
||||
// If the primary key is not autoincrement, return the provided value if
|
||||
// exists
|
||||
// If the primary key is not autoincrement, return the provided value if
|
||||
// exists
|
||||
if (
|
||||
! in_array("autoincrement", $this->fields[$this->primary]) &&
|
||||
key_exists($this->primary, $this->setValues)
|
||||
@@ -3673,8 +3673,8 @@ class Dblayeroo
|
||||
return $this->setValues[$this->primary];
|
||||
}
|
||||
|
||||
// If the primary key is autoincrement and the provided value is not null
|
||||
// Return it
|
||||
// If the primary key is autoincrement and the provided value is not null
|
||||
// Return it
|
||||
if (
|
||||
in_array("autoincrement", $this->fields[$this->primary]) &&
|
||||
key_exists($this->primary, $this->setValues) &&
|
||||
@@ -3683,9 +3683,9 @@ class Dblayeroo
|
||||
return $this->setValues[$this->primary];
|
||||
}
|
||||
|
||||
// If the primary key is autoincrement and the provided value is null or
|
||||
// not provided, return the autoincremented value
|
||||
// PostGres need the name of the column autoincrement to return something
|
||||
// If the primary key is autoincrement and the provided value is null or
|
||||
// not provided, return the autoincremented value
|
||||
// PostGres need the name of the column autoincrement to return something
|
||||
$autoInc = null;
|
||||
if ($this->driver === "pgsql") {
|
||||
foreach ($this->fields as $col => $params) {
|
||||
|
||||
@@ -1061,8 +1061,8 @@ class File
|
||||
if ($prio <= $this->debug) {
|
||||
echo "[$prio] $message\n";
|
||||
//file_put_contents ("/tmp/domframework.file.debug",
|
||||
// date ("Y:m:d H:i:s")." [$prio] $message\n",
|
||||
// FILE_APPEND);
|
||||
// date ("Y:m:d H:i:s")." [$prio] $message\n",
|
||||
// FILE_APPEND);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ namespace Domframework;
|
||||
*/
|
||||
class Form
|
||||
{
|
||||
/** All the fields
|
||||
*/
|
||||
/** All the fields
|
||||
*/
|
||||
private $fields = null;
|
||||
/** The name of the form
|
||||
*/
|
||||
|
||||
@@ -35,9 +35,9 @@ class Macaddresses
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
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]{12}$/", $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]{12}$/", $mac) === 1);
|
||||
}
|
||||
|
||||
/** Reform the mac address with the separator.
|
||||
|
||||
@@ -12,8 +12,8 @@ namespace Domframework;
|
||||
*/
|
||||
class Mail
|
||||
{
|
||||
/** The complete of the mail
|
||||
*/
|
||||
/** The complete of the mail
|
||||
*/
|
||||
private $completeEmailEML = "";
|
||||
|
||||
/** Private the separator between the headers and the mail. Should be
|
||||
|
||||
@@ -55,7 +55,7 @@ class Outputhtml extends Output
|
||||
require_once("views/$viewClass.php");
|
||||
}
|
||||
// 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();
|
||||
$resView = $obj->$viewMethod($data, $variable);
|
||||
|
||||
@@ -20,8 +20,8 @@ namespace Domframework;
|
||||
*/
|
||||
class Queuefile extends Queue
|
||||
{
|
||||
/** The queue connected object
|
||||
*/
|
||||
/** The queue connected object
|
||||
*/
|
||||
private $queue = null;
|
||||
|
||||
/** Connect to the queue. Create it if not exists
|
||||
|
||||
@@ -99,8 +99,8 @@ class Robotstxt
|
||||
$line = trim($content[$nb]);
|
||||
if (stripos($line, "Sitemap:") === 0) {
|
||||
// Already managed in the general parser. Not needed in the specific
|
||||
// user-agent parser. Must at least be catched to not generate an
|
||||
// error
|
||||
// user-agent parser. Must at least be catched to not generate an
|
||||
// error
|
||||
} elseif (stripos($line, "Host:") === 0) {
|
||||
if ($this->host !== null) {
|
||||
$this->errors[$nb] = dgettext(
|
||||
@@ -115,7 +115,7 @@ class Robotstxt
|
||||
} elseif (stripos($line, "allow:") === 0) {
|
||||
$allow = $this->getValueFromLine($line);
|
||||
if (trim($allow) === "" || $allow[0] === "/") {
|
||||
$this->allow[] = $allow;
|
||||
$this->allow[] = $allow;
|
||||
} else {
|
||||
$this->errors[$nb] = dgettext(
|
||||
"domframework",
|
||||
|
||||
@@ -354,7 +354,7 @@ class Route
|
||||
if (
|
||||
isset($_POST["_METHOD"]) &&
|
||||
(
|
||||
$_POST["_METHOD"] === "GET" ||
|
||||
$_POST["_METHOD"] === "GET" ||
|
||||
$_POST["_METHOD"] === "POST" ||
|
||||
$_POST["_METHOD"] === "PUT" ||
|
||||
$_POST["_METHOD"] === "DELETE" ||
|
||||
|
||||
@@ -154,19 +154,19 @@ class RouteSQL
|
||||
switch ($flash[0]) {
|
||||
case 4:
|
||||
$dataflash .= "alert-danger";
|
||||
$alert = dgettext("domframework", "Error!");
|
||||
$alert = dgettext("domframework", "Error!");
|
||||
break;
|
||||
case 3:
|
||||
$dataflash .= "alert-warning";
|
||||
$alert = dgettext("domframework", "Warning!");
|
||||
$alert = dgettext("domframework", "Warning!");
|
||||
break;
|
||||
case 2:
|
||||
$dataflash .= "alert-info";
|
||||
$alert = dgettext("domframework", "Info:");
|
||||
$alert = dgettext("domframework", "Info:");
|
||||
break;
|
||||
case 1:
|
||||
$dataflash .= "alert-success";
|
||||
$alert = dgettext("domframework", "Success:");
|
||||
$alert = dgettext("domframework", "Success:");
|
||||
break;
|
||||
}
|
||||
$dataflash .= " alert-dismissable'>\n";
|
||||
@@ -457,7 +457,7 @@ class RouteSQL
|
||||
$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) {
|
||||
if (
|
||||
$this->accessright(
|
||||
@@ -783,7 +783,7 @@ class RouteSQL
|
||||
$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) !==
|
||||
@@ -841,9 +841,9 @@ class RouteSQL
|
||||
if (isset($_COOKIE["$cookiePrefix-search"])) {
|
||||
$search = $_COOKIE["$cookiePrefix-search"];
|
||||
}
|
||||
// num is the number of elements displayed by page
|
||||
// page is the page to display
|
||||
// Allow the parameters to be sent in any order
|
||||
// num is the number of elements displayed by page
|
||||
// page is the page to display
|
||||
// Allow the parameters to be sent in any order
|
||||
if ($p1 === "num") {
|
||||
$num = $v1;
|
||||
}
|
||||
@@ -891,10 +891,10 @@ class RouteSQL
|
||||
time() + 3600 * 24 * 30,
|
||||
$this->path
|
||||
);
|
||||
//echo "PAGE=$page\n";
|
||||
//echo "NUM=$num\n";
|
||||
//echo "SEARCH=$search\n";
|
||||
//$route->debug=$this->debug;
|
||||
//echo "PAGE=$page\n";
|
||||
//echo "NUM=$num\n";
|
||||
//echo "SEARCH=$search\n";
|
||||
//$route->debug=$this->debug;
|
||||
$this->connect();
|
||||
$csrf = new Csrf();
|
||||
$token = $csrf->createToken();
|
||||
@@ -936,7 +936,7 @@ class RouteSQL
|
||||
$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) {
|
||||
if (
|
||||
$this->accessright(
|
||||
@@ -948,8 +948,8 @@ class RouteSQL
|
||||
}
|
||||
}
|
||||
|
||||
// Get the non mandatory foreign keys and display them instead of the
|
||||
// unusable id
|
||||
// Get the non mandatory foreign keys and display them instead of the
|
||||
// unusable id
|
||||
$foreignData = array();
|
||||
if (isset($this->objectDB->foreign)) {
|
||||
foreach ($this->objectDB->foreign as $foreign => $params) {
|
||||
@@ -976,9 +976,9 @@ class RouteSQL
|
||||
$associated = array();
|
||||
$unique = reset($foreignObject->unique);
|
||||
foreach ($tmpData as $vals) {
|
||||
// TODO : If $foreignObject->unique is not an array ?
|
||||
// or multidimensionnal array
|
||||
$associated[$vals[$column]] = $vals[$unique];
|
||||
// TODO : If $foreignObject->unique is not an array ?
|
||||
// or multidimensionnal array
|
||||
$associated[$vals[$column]] = $vals[$unique];
|
||||
}
|
||||
// Add the unique text to the identifier
|
||||
foreach ($data as $line => $vals) {
|
||||
@@ -1001,7 +1001,7 @@ class RouteSQL
|
||||
$route->redirect("/" . str_replace("{chain}", $chain, $this->url_prefix)
|
||||
. "?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) {
|
||||
$maxPage = intval($nbentries / $num) + 1;
|
||||
$route->redirect("/" . str_replace("{chain}", $chain, $this->url_prefix) .
|
||||
@@ -1010,7 +1010,7 @@ class RouteSQL
|
||||
|
||||
|
||||
$content = "";
|
||||
// Internal CSS
|
||||
// Internal CSS
|
||||
if ($this->enableInternalCSS === true) {
|
||||
$content .= "<style type='text/css' scoped='scoped'>\n";
|
||||
$content .= ".routeSQL {
|
||||
@@ -1314,7 +1314,7 @@ class RouteSQL
|
||||
$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) !==
|
||||
@@ -1372,10 +1372,10 @@ class RouteSQL
|
||||
);
|
||||
}
|
||||
|
||||
$this->connect();
|
||||
$csrf = new Csrf();
|
||||
$renderer = new Renderer();
|
||||
$route = new Route();
|
||||
$this->connect();
|
||||
$csrf = new Csrf();
|
||||
$renderer = new Renderer();
|
||||
$route = new Route();
|
||||
try {
|
||||
$csrf->checkToken($token);
|
||||
$this->objectDB->delete($id);
|
||||
|
||||
@@ -296,7 +296,7 @@ class Sse
|
||||
// and reopen it just after
|
||||
if (
|
||||
key_exists($event, $this->fps) && (
|
||||
! file_exists($this->files[$event]) ||
|
||||
! file_exists($this->files[$event]) ||
|
||||
! is_readable($this->files[$event])
|
||||
)
|
||||
) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/** DomFramework
|
||||
/**
|
||||
* DomFramework
|
||||
* @package domframework
|
||||
* @author Dominique Fournier <dominique@fournier38.fr>
|
||||
* @license BSD
|
||||
|
||||
Reference in New Issue
Block a user