@@ -6,7 +6,7 @@ |
||
| 6 | 6 | date_default_timezone_set("America/Bogota"); |
| 7 | 7 | |
| 8 | 8 | // Memory limit |
| 9 | -ini_set("memory_limit","256M"); |
|
| 9 | +ini_set("memory_limit", "256M"); |
|
| 10 | 10 | |
| 11 | 11 | // Run application |
| 12 | 12 | require_once("vendor/autoload.php"); |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | $http = new Http(); |
| 87 | 87 | $http->writeStatus($http::HTTP_METHOD_NOT_ALLOWED); |
| 88 | 88 | |
| 89 | - die('Error ' . $http::HTTP_METHOD_NOT_ALLOWED .' (' . $http->getStatusText($http::HTTP_METHOD_NOT_ALLOWED) . ')!!'); |
|
| 89 | + die('Error ' . $http::HTTP_METHOD_NOT_ALLOWED . ' (' . $http->getStatusText($http::HTTP_METHOD_NOT_ALLOWED) . ')!!'); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | $this->checkSession(); |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | $http = new Http(); |
| 117 | 117 | $http->writeStatus($http::HTTP_METHOD_NOT_ALLOWED); |
| 118 | 118 | |
| 119 | - die('Error ' . $http::HTTP_METHOD_NOT_ALLOWED .' (' . $http->getStatusText($http::HTTP_METHOD_NOT_ALLOWED) . ')!!'); |
|
| 119 | + die('Error ' . $http::HTTP_METHOD_NOT_ALLOWED . ' (' . $http->getStatusText($http::HTTP_METHOD_NOT_ALLOWED) . ')!!'); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | # STANDARD VALIDATIONS [check needed arguments] |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | $http = new Http(); |
| 129 | 129 | $http->writeStatus($http::HTTP_BAD_REQUEST); |
| 130 | 130 | |
| 131 | - die('Error ' . $http::HTTP_BAD_REQUEST .' (' . $http->getStatusText($http::HTTP_BAD_REQUEST) . ')!!'); |
|
| 131 | + die('Error ' . $http::HTTP_BAD_REQUEST . ' (' . $http->getStatusText($http::HTTP_BAD_REQUEST) . ')!!'); |
|
| 132 | 132 | } |
| 133 | 133 | }); |
| 134 | 134 | |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | foreach ($errors as $errno => $error) |
| 269 | 269 | { |
| 270 | 270 | $errorInformation .= |
| 271 | - "<strong style='color: #a94442'>". |
|
| 271 | + "<strong style='color: #a94442'>" . |
|
| 272 | 272 | $method |
| 273 | 273 | . "</strong>: <span style='color: #e24f4c'>{$error}</span> \n<br />"; |
| 274 | 274 | } |
@@ -39,8 +39,9 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | private function getUserAdapter() |
| 41 | 41 | { |
| 42 | - if (!is_null($this->userAdapter)) |
|
| 43 | - return $this->userAdapter; |
|
| 42 | + if (!is_null($this->userAdapter)) { |
|
| 43 | + return $this->userAdapter; |
|
| 44 | + } |
|
| 44 | 45 | |
| 45 | 46 | $this->userAdapter = new EntityAdapter(new TableGateway(new User())); |
| 46 | 47 | |
@@ -52,8 +53,9 @@ discard block |
||
| 52 | 53 | */ |
| 53 | 54 | private function getUserRoleAdapter() |
| 54 | 55 | { |
| 55 | - if (!is_null($this->userRoleAdapter)) |
|
| 56 | - return $this->userRoleAdapter; |
|
| 56 | + if (!is_null($this->userRoleAdapter)) { |
|
| 57 | + return $this->userRoleAdapter; |
|
| 58 | + } |
|
| 57 | 59 | |
| 58 | 60 | $this->userRoleAdapter = new EntityAdapter(new TableGateway(new UserRole())); |
| 59 | 61 | |
@@ -65,8 +67,9 @@ discard block |
||
| 65 | 67 | */ |
| 66 | 68 | private function getDbUserRoleAdapter() |
| 67 | 69 | { |
| 68 | - if (!is_null($this->dbUserRoleAdapter)) |
|
| 69 | - return $this->dbUserRoleAdapter; |
|
| 70 | + if (!is_null($this->dbUserRoleAdapter)) { |
|
| 71 | + return $this->dbUserRoleAdapter; |
|
| 72 | + } |
|
| 70 | 73 | |
| 71 | 74 | $this->dbUserRoleAdapter = new EntityAdapter(new TableGateway(new DbUserRole())); |
| 72 | 75 | |
@@ -95,24 +98,27 @@ discard block |
||
| 95 | 98 | * $_SESSION["last_uri_" . $global_config["project"]["id"]] = $_SERVER["REQUEST_URI"]; |
| 96 | 99 | * It should be an unique session id for the app to prevent bad redirections with other projects. |
| 97 | 100 | */ |
| 98 | - if (array_key_exists("last_uri_" . $global_config["project"]["id"], $_SESSION) || !empty($_SESSION["last_uri_" . $global_config["project"]["id"]])) |
|
| 99 | - $location = $_SESSION["last_uri_" . $global_config["project"]["id"]]; |
|
| 100 | - else |
|
| 101 | - $location = $this->getBasePath() . "/public/" . $config["redirect"]; |
|
| 101 | + if (array_key_exists("last_uri_" . $global_config["project"]["id"], $_SESSION) || !empty($_SESSION["last_uri_" . $global_config["project"]["id"]])) { |
|
| 102 | + $location = $_SESSION["last_uri_" . $global_config["project"]["id"]]; |
|
| 103 | + } else { |
|
| 104 | + $location = $this->getBasePath() . "/public/" . $config["redirect"]; |
|
| 105 | + } |
|
| 102 | 106 | |
| 103 | 107 | switch ($method) |
| 104 | 108 | { |
| 105 | 109 | case '_COOKIE': |
| 106 | 110 | |
| 107 | - if (array_key_exists($key, $_COOKIE) || !empty($_COOKIE[$key])) |
|
| 108 | - header("location: " . $location); |
|
| 111 | + if (array_key_exists($key, $_COOKIE) || !empty($_COOKIE[$key])) { |
|
| 112 | + header("location: " . $location); |
|
| 113 | + } |
|
| 109 | 114 | |
| 110 | 115 | break; |
| 111 | 116 | |
| 112 | 117 | case '_SESSION': |
| 113 | 118 | |
| 114 | - if (array_key_exists($key, $_SESSION) || !empty($_SESSION[$key])) |
|
| 115 | - header("location: " . $location); |
|
| 119 | + if (array_key_exists($key, $_SESSION) || !empty($_SESSION[$key])) { |
|
| 120 | + header("location: " . $location); |
|
| 121 | + } |
|
| 116 | 122 | |
| 117 | 123 | break; |
| 118 | 124 | } |
@@ -241,14 +247,14 @@ discard block |
||
| 241 | 247 | $username_str => strtoupper($post["username"]) |
| 242 | 248 | ]); |
| 243 | 249 | |
| 244 | - if (!count($rowset)) |
|
| 245 | - throw new \Drone\Exception\Exception("Your user is not authorized to use this application!"); |
|
| 250 | + if (!count($rowset)) { |
|
| 251 | + throw new \Drone\Exception\Exception("Your user is not authorized to use this application!"); |
|
| 252 | + } |
|
| 246 | 253 | } |
| 247 | 254 | |
| 248 | 255 | $auth = new Authentication("default", false); |
| 249 | 256 | $result = $auth->authenticate($post["username"], $post["password"]); |
| 250 | - } |
|
| 251 | - catch (\Drone\Db\Driver\Exception\ConnectionException $e) |
|
| 257 | + } catch (\Drone\Db\Driver\Exception\ConnectionException $e) |
|
| 252 | 258 | { |
| 253 | 259 | throw new \Drone\Exception\Exception("Wrong user or password"); |
| 254 | 260 | } |
@@ -261,8 +267,9 @@ discard block |
||
| 261 | 267 | $username_str => $post["username"] |
| 262 | 268 | ]); |
| 263 | 269 | |
| 264 | - if (!count($rowset)) |
|
| 265 | - throw new \Drone\Exception\Exception("Username or password are incorrect"); |
|
| 270 | + if (!count($rowset)) { |
|
| 271 | + throw new \Drone\Exception\Exception("Username or password are incorrect"); |
|
| 272 | + } |
|
| 266 | 273 | |
| 267 | 274 | $user = array_shift($rowset); |
| 268 | 275 | |
@@ -274,23 +281,26 @@ discard block |
||
| 274 | 281 | $id_field => $user->{$id_field} |
| 275 | 282 | ]); |
| 276 | 283 | |
| 277 | - if (!count($rowset)) |
|
| 278 | - throw new \Drone\Exception\Exception("Your user is not authorized to use this application!"); |
|
| 284 | + if (!count($rowset)) { |
|
| 285 | + throw new \Drone\Exception\Exception("Your user is not authorized to use this application!"); |
|
| 286 | + } |
|
| 279 | 287 | } |
| 280 | 288 | |
| 281 | 289 | $state_field = $config["authentication"]["gateway"]["table_info"]["columns"]["state_field"]; |
| 282 | 290 | $state_pending_value = $config["authentication"]["gateway"]["table_info"]["column_values"]["state_field"]["pending_email"]; |
| 283 | 291 | |
| 284 | - if ($user->{$state_field} == $state_pending_value) |
|
| 285 | - throw new \Drone\Exception\Exception("User pending of email checking"); |
|
| 292 | + if ($user->{$state_field} == $state_pending_value) { |
|
| 293 | + throw new \Drone\Exception\Exception("User pending of email checking"); |
|
| 294 | + } |
|
| 286 | 295 | |
| 287 | 296 | $securePass = $user->{$password_str}; |
| 288 | 297 | $password = $post["password"]; |
| 289 | 298 | |
| 290 | 299 | $bcrypt = new Bcrypt(); |
| 291 | 300 | |
| 292 | - if (!$bcrypt->verify($password, $securePass)) |
|
| 293 | - throw new \Drone\Exception\Exception("Username or password are incorrect"); |
|
| 301 | + if (!$bcrypt->verify($password, $securePass)) { |
|
| 302 | + throw new \Drone\Exception\Exception("Username or password are incorrect"); |
|
| 303 | + } |
|
| 294 | 304 | |
| 295 | 305 | break; |
| 296 | 306 | |
@@ -315,14 +325,12 @@ discard block |
||
| 315 | 325 | |
| 316 | 326 | # SUCCESS-MESSAGE |
| 317 | 327 | $data["process"] = "success"; |
| 318 | - } |
|
| 319 | - catch (\Drone\Exception\Exception $e) |
|
| 328 | + } catch (\Drone\Exception\Exception $e) |
|
| 320 | 329 | { |
| 321 | 330 | # ERROR-MESSAGE |
| 322 | 331 | $data["process"] = "warning"; |
| 323 | 332 | $data["message"] = $e->getMessage(); |
| 324 | - } |
|
| 325 | - catch (\Exception $e) |
|
| 333 | + } catch (\Exception $e) |
|
| 326 | 334 | { |
| 327 | 335 | $file = str_replace('\\', '', __CLASS__); |
| 328 | 336 | $storage = new \Drone\Exception\Storage("cache/$file.json"); |
@@ -337,8 +345,9 @@ discard block |
||
| 337 | 345 | } |
| 338 | 346 | |
| 339 | 347 | # errors retrived by the use of ErrorTrait |
| 340 | - if (count($this->getErrors())) |
|
| 341 | - $this->handleErrors($this->getErrors(), __METHOD__); |
|
| 348 | + if (count($this->getErrors())) { |
|
| 349 | + $this->handleErrors($this->getErrors(), __METHOD__); |
|
| 350 | + } |
|
| 342 | 351 | |
| 343 | 352 | $data["code"] = $errorCode; |
| 344 | 353 | $data["message"] = $e->getMessage(); |
@@ -374,15 +383,16 @@ discard block |
||
| 374 | 383 | if (!$hd || !@fwrite($hd, $errorInformation)) |
| 375 | 384 | { |
| 376 | 385 | # error storing are not mandatory! |
| 386 | + } else { |
|
| 387 | + @fclose($hd); |
|
| 377 | 388 | } |
| 378 | - else |
|
| 379 | - @fclose($hd); |
|
| 380 | 389 | |
| 381 | 390 | $config = include 'config/application.config.php'; |
| 382 | 391 | $dev = $config["environment"]["dev_mode"]; |
| 383 | 392 | |
| 384 | - if ($dev) |
|
| 385 | - echo $errorInformation; |
|
| 393 | + if ($dev) { |
|
| 394 | + echo $errorInformation; |
|
| 395 | + } |
|
| 386 | 396 | } |
| 387 | 397 | } |
| 388 | 398 | } |
| 389 | 399 | \ No newline at end of file |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | $http = new Http(); |
| 21 | 21 | $http->writeStatus($http::HTTP_METHOD_NOT_ALLOWED); |
| 22 | 22 | |
| 23 | - die('Error ' . $http::HTTP_METHOD_NOT_ALLOWED .' (' . $http->getStatusText($http::HTTP_METHOD_NOT_ALLOWED) . ')!!'); |
|
| 23 | + die('Error ' . $http::HTTP_METHOD_NOT_ALLOWED . ' (' . $http->getStatusText($http::HTTP_METHOD_NOT_ALLOWED) . ')!!'); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | $config = include 'module/Auth/config/user.config.php'; |
@@ -30,8 +30,9 @@ |
||
| 30 | 30 | switch ($method) |
| 31 | 31 | { |
| 32 | 32 | case '_COOKIE': |
| 33 | - if (array_key_exists($key, $_COOKIE) || !empty($_COOKIE[$key])) |
|
| 34 | - setcookie($key, $_COOKIE[$key], time() - 1, '/'); |
|
| 33 | + if (array_key_exists($key, $_COOKIE) || !empty($_COOKIE[$key])) { |
|
| 34 | + setcookie($key, $_COOKIE[$key], time() - 1, '/'); |
|
| 35 | + } |
|
| 35 | 36 | break; |
| 36 | 37 | |
| 37 | 38 | case '_SESSION': |
@@ -21,9 +21,10 @@ |
||
| 21 | 21 | $db->setDbuser($user); |
| 22 | 22 | $db->setDbpass($pass); |
| 23 | 23 | |
| 24 | - if ($db->isConnected()) |
|
| 25 | - return $db->reconnect() |
|
| 24 | + if ($db->isConnected()) { |
|
| 25 | + return $db->reconnect() |
|
| 26 | 26 | else |
| 27 | 27 | return $db->connect(); |
| 28 | + } |
|
| 28 | 29 | } |
| 29 | 30 | } |
| 30 | 31 | \ No newline at end of file |
@@ -3,11 +3,11 @@ |
||
| 3 | 3 | return [ |
| 4 | 4 | 'router' => [ |
| 5 | 5 | 'routes' => [ |
| 6 | - 'Auth' => [ |
|
| 7 | - 'module' => 'Auth', |
|
| 8 | - 'controller' => 'LogIn', |
|
| 9 | - 'view' => 'index' |
|
| 10 | - ] |
|
| 6 | + 'Auth' => [ |
|
| 7 | + 'module' => 'Auth', |
|
| 8 | + 'controller' => 'LogIn', |
|
| 9 | + 'view' => 'index' |
|
| 10 | + ] |
|
| 11 | 11 | ], |
| 12 | 12 | ], |
| 13 | 13 | 'view_manager' => [ |
@@ -81,7 +81,7 @@ |
||
| 81 | 81 | { |
| 82 | 82 | $new = array(); |
| 83 | 83 | |
| 84 | - foreach($obj as $key => $val) |
|
| 84 | + foreach ($obj as $key => $val) |
|
| 85 | 85 | { |
| 86 | 86 | $new[$key] = $this->object_to_array($val); |
| 87 | 87 | } |
@@ -26,8 +26,9 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | foreach ($files as $file) |
| 28 | 28 | { |
| 29 | - if (!in_array($file, ['.', '..'])) |
|
| 30 | - $_files[] = $file; |
|
| 29 | + if (!in_array($file, ['.', '..'])) { |
|
| 30 | + $_files[] = $file; |
|
| 31 | + } |
|
| 31 | 32 | } |
| 32 | 33 | |
| 33 | 34 | $_folders[$folder] = $_files; |
@@ -74,8 +75,9 @@ discard block |
||
| 74 | 75 | |
| 75 | 76 | private function object_to_array($obj) |
| 76 | 77 | { |
| 77 | - if (is_object($obj)) |
|
| 78 | - $obj = (array) $obj; |
|
| 78 | + if (is_object($obj)) { |
|
| 79 | + $obj = (array) $obj; |
|
| 80 | + } |
|
| 79 | 81 | |
| 80 | 82 | if (is_array($obj)) |
| 81 | 83 | { |
@@ -85,9 +87,9 @@ discard block |
||
| 85 | 87 | { |
| 86 | 88 | $new[$key] = $this->object_to_array($val); |
| 87 | 89 | } |
| 90 | + } else { |
|
| 91 | + $new = $obj; |
|
| 88 | 92 | } |
| 89 | - else |
|
| 90 | - $new = $obj; |
|
| 91 | 93 | |
| 92 | 94 | return $new; |
| 93 | 95 | } |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | ], |
| 25 | 25 | 'environment' => [ |
| 26 | 26 | 'base_path' => (dirname(dirname($_SERVER['PHP_SELF'])) == "/") ? "" : dirname(dirname($_SERVER['PHP_SELF'])), |
| 27 | - 'dev_mode' => true, // set this to FALSE for production environments |
|
| 27 | + 'dev_mode' => true, // set this to FALSE for production environments |
|
| 28 | 28 | 'locale' => 'en' |
| 29 | 29 | ], |
| 30 | 30 | ]; |
| 31 | 31 | \ No newline at end of file |
@@ -1,12 +1,12 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | - 'default' => [ |
|
| 5 | - 'dbname' => '', |
|
| 6 | - 'dbuser' => '', |
|
| 7 | - 'dbpass' => '', |
|
| 8 | - 'dbhost' => '', |
|
| 9 | - 'driver' => 'Oci8', |
|
| 10 | - 'dbchar' => 'utf8' |
|
| 11 | - ], |
|
| 4 | + 'default' => [ |
|
| 5 | + 'dbname' => '', |
|
| 6 | + 'dbuser' => '', |
|
| 7 | + 'dbpass' => '', |
|
| 8 | + 'dbhost' => '', |
|
| 9 | + 'driver' => 'Oci8', |
|
| 10 | + 'dbchar' => 'utf8' |
|
| 11 | + ], |
|
| 12 | 12 | ]; |
| 13 | 13 | \ No newline at end of file |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | { |
| 5 | 5 | function ifdef($value, Array $array) |
| 6 | 6 | { |
| 7 | - $global = __DIR__ . '/../../../config/global.config.php'; |
|
| 7 | + $global = __DIR__ . '/../../../config/global.config.php'; |
|
| 8 | 8 | |
| 9 | 9 | if (file_exists($global)) |
| 10 | 10 | { |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | if (!$key) |
| 29 | 29 | return $in; |
| 30 | 30 | |
| 31 | - } while($key); |
|
| 31 | + } while ($key); |
|
| 32 | 32 | } |
| 33 | 33 | else |
| 34 | 34 | return $value; |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | return [ |
| 39 | 39 | 'project' => [ |
| 40 | - 'name' => ifdef('PROJECT NAME', ["project", "name"]), # The name of your project |
|
| 40 | + 'name' => ifdef('PROJECT NAME', ["project", "name"]), # The name of your project |
|
| 41 | 41 | ], |
| 42 | 42 | 'mail' => [ |
| 43 | 43 | /** CHECKING: |
@@ -51,8 +51,8 @@ discard block |
||
| 51 | 51 | "host" => ifdef('localhost', ["mail", "host"]) |
| 52 | 52 | ], |
| 53 | 53 | "authentication" => [ |
| 54 | - "method" => ifdef('_COOKIE', ["authentication", "method"]), # the method to store credentials (_COOKIE, _SESSION) |
|
| 55 | - "key" => ifdef('session_id', ["authentication", "key"]), # the key in the array to store credentials |
|
| 54 | + "method" => ifdef('_COOKIE', ["authentication", "method"]), # the method to store credentials (_COOKIE, _SESSION) |
|
| 55 | + "key" => ifdef('session_id', ["authentication", "key"]), # the key in the array to store credentials |
|
| 56 | 56 | /** AUTH TYPE: |
| 57 | 57 | * db_table: get credentials from a table in a database |
| 58 | 58 | * db_user: get credentials from database users (database authentication) |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | * a database and checks the specified credentials. Theses will checked only if the AUTH TYPE is db_table. |
| 64 | 64 | */ |
| 65 | 65 | "gateway" => [ |
| 66 | - "entity" => "USER", # Table name (without prefix if exists) |
|
| 66 | + "entity" => "USER", # Table name (without prefix if exists) |
|
| 67 | 67 | /** CREDENTIALS: |
| 68 | 68 | * The field names of credentials in the table. |
| 69 | 69 | */ |
@@ -81,14 +81,14 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | "table_info" => [ |
| 83 | 83 | "columns" => [ |
| 84 | - "id_field" => "USER_ID", # often the primary key |
|
| 85 | - "state_field" => "USER_STATE_ID", # required if mail_checking is enabled |
|
| 84 | + "id_field" => "USER_ID", # often the primary key |
|
| 85 | + "state_field" => "USER_STATE_ID", # required if mail_checking is enabled |
|
| 86 | 86 | "email_field" => "EMAIL" # required registration process |
| 87 | 87 | ], |
| 88 | 88 | "column_values" => [ |
| 89 | 89 | "state_field" => [ |
| 90 | - "pending_email" => 1, # required if mail_checking is enabled |
|
| 91 | - "user_active" => 2, # required if mail_checking is enabled |
|
| 90 | + "pending_email" => 1, # required if mail_checking is enabled |
|
| 91 | + "user_active" => 2, # required if mail_checking is enabled |
|
| 92 | 92 | ] |
| 93 | 93 | ] |
| 94 | 94 | ] |
@@ -15,23 +15,25 @@ |
||
| 15 | 15 | { |
| 16 | 16 | if (is_array($in)) |
| 17 | 17 | { |
| 18 | - if (array_key_exists($key, $in)) |
|
| 19 | - $in = $in[$key]; |
|
| 20 | - else |
|
| 21 | - return $value; |
|
| 18 | + if (array_key_exists($key, $in)) { |
|
| 19 | + $in = $in[$key]; |
|
| 20 | + } else { |
|
| 21 | + return $value; |
|
| 22 | + } |
|
| 23 | + } else { |
|
| 24 | + return $value; |
|
| 22 | 25 | } |
| 23 | - else |
|
| 24 | - return $value; |
|
| 25 | 26 | |
| 26 | 27 | $key = ($array) ? array_shift($array) : NULL; |
| 27 | 28 | |
| 28 | - if (!$key) |
|
| 29 | - return $in; |
|
| 29 | + if (!$key) { |
|
| 30 | + return $in; |
|
| 31 | + } |
|
| 30 | 32 | |
| 31 | 33 | } while($key); |
| 34 | + } else { |
|
| 35 | + return $value; |
|
| 32 | 36 | } |
| 33 | - else |
|
| 34 | - return $value; |
|
| 35 | 37 | } |
| 36 | 38 | } |
| 37 | 39 | |
@@ -2,100 +2,100 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | if (!function_exists('ifdef')) |
| 4 | 4 | { |
| 5 | - function ifdef($value, Array $array) |
|
| 6 | - { |
|
| 7 | - $global = __DIR__ . '/../../../config/global.config.php'; |
|
| 5 | + function ifdef($value, Array $array) |
|
| 6 | + { |
|
| 7 | + $global = __DIR__ . '/../../../config/global.config.php'; |
|
| 8 | 8 | |
| 9 | - if (file_exists($global)) |
|
| 10 | - { |
|
| 11 | - $key = array_shift($array); |
|
| 12 | - $in = include $global; |
|
| 9 | + if (file_exists($global)) |
|
| 10 | + { |
|
| 11 | + $key = array_shift($array); |
|
| 12 | + $in = include $global; |
|
| 13 | 13 | |
| 14 | - do |
|
| 15 | - { |
|
| 16 | - if (is_array($in)) |
|
| 17 | - { |
|
| 18 | - if (array_key_exists($key, $in)) |
|
| 19 | - $in = $in[$key]; |
|
| 20 | - else |
|
| 21 | - return $value; |
|
| 22 | - } |
|
| 23 | - else |
|
| 24 | - return $value; |
|
| 14 | + do |
|
| 15 | + { |
|
| 16 | + if (is_array($in)) |
|
| 17 | + { |
|
| 18 | + if (array_key_exists($key, $in)) |
|
| 19 | + $in = $in[$key]; |
|
| 20 | + else |
|
| 21 | + return $value; |
|
| 22 | + } |
|
| 23 | + else |
|
| 24 | + return $value; |
|
| 25 | 25 | |
| 26 | - $key = ($array) ? array_shift($array) : NULL; |
|
| 26 | + $key = ($array) ? array_shift($array) : NULL; |
|
| 27 | 27 | |
| 28 | - if (!$key) |
|
| 29 | - return $in; |
|
| 28 | + if (!$key) |
|
| 29 | + return $in; |
|
| 30 | 30 | |
| 31 | - } while($key); |
|
| 32 | - } |
|
| 33 | - else |
|
| 34 | - return $value; |
|
| 35 | - } |
|
| 31 | + } while($key); |
|
| 32 | + } |
|
| 33 | + else |
|
| 34 | + return $value; |
|
| 35 | + } |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | return [ |
| 39 | - 'project' => [ |
|
| 40 | - 'name' => ifdef('PROJECT NAME', ["project", "name"]), # The name of your project |
|
| 41 | - ], |
|
| 42 | - 'mail' => [ |
|
| 39 | + 'project' => [ |
|
| 40 | + 'name' => ifdef('PROJECT NAME', ["project", "name"]), # The name of your project |
|
| 41 | + ], |
|
| 42 | + 'mail' => [ |
|
| 43 | 43 | /** CHECKING: |
| 44 | 44 | * If checking is enabled, the registering process will require e-mail verification. |
| 45 | 45 | * If checking is enabled, the user will log in after registering. |
| 46 | 46 | */ |
| 47 | - 'checking' => [ |
|
| 48 | - 'enabled' => "N", |
|
| 49 | - 'from' => ifdef('[email protected]', ["mail", "noreply"]) |
|
| 50 | - ], |
|
| 51 | - "host" => ifdef('localhost', ["mail", "host"]) |
|
| 52 | - ], |
|
| 53 | - "authentication" => [ |
|
| 54 | - "method" => ifdef('_COOKIE', ["authentication", "method"]), # the method to store credentials (_COOKIE, _SESSION) |
|
| 55 | - "key" => ifdef('session_id', ["authentication", "key"]), # the key in the array to store credentials |
|
| 47 | + 'checking' => [ |
|
| 48 | + 'enabled' => "N", |
|
| 49 | + 'from' => ifdef('[email protected]', ["mail", "noreply"]) |
|
| 50 | + ], |
|
| 51 | + "host" => ifdef('localhost', ["mail", "host"]) |
|
| 52 | + ], |
|
| 53 | + "authentication" => [ |
|
| 54 | + "method" => ifdef('_COOKIE', ["authentication", "method"]), # the method to store credentials (_COOKIE, _SESSION) |
|
| 55 | + "key" => ifdef('session_id', ["authentication", "key"]), # the key in the array to store credentials |
|
| 56 | 56 | /** AUTH TYPE: |
| 57 | 57 | * db_table: get credentials from a table in a database |
| 58 | 58 | * db_user: get credentials from database users (database authentication) |
| 59 | 59 | */ |
| 60 | - "type" => "db_table", |
|
| 60 | + "type" => "db_table", |
|
| 61 | 61 | /** DB GATEWAY: |
| 62 | 62 | * Gateway is used to connect to database. It consists in an entity that connects to |
| 63 | 63 | * a database and checks the specified credentials. Theses will checked only if the AUTH TYPE is db_table. |
| 64 | 64 | */ |
| 65 | - "gateway" => [ |
|
| 66 | - "entity" => "USER", # Table name (without prefix if exists) |
|
| 67 | - /** CREDENTIALS: |
|
| 68 | - * The field names of credentials in the table. |
|
| 69 | - */ |
|
| 70 | - "credentials" => [ |
|
| 71 | - "username" => "USERNAME", |
|
| 72 | - "password" => "USER_PASSWORD" |
|
| 73 | - ], |
|
| 65 | + "gateway" => [ |
|
| 66 | + "entity" => "USER", # Table name (without prefix if exists) |
|
| 67 | + /** CREDENTIALS: |
|
| 68 | + * The field names of credentials in the table. |
|
| 69 | + */ |
|
| 70 | + "credentials" => [ |
|
| 71 | + "username" => "USERNAME", |
|
| 72 | + "password" => "USER_PASSWORD" |
|
| 73 | + ], |
|
| 74 | 74 | |
| 75 | - // [TO DO] - Add validations for the following ... |
|
| 75 | + // [TO DO] - Add validations for the following ... |
|
| 76 | 76 | |
| 77 | 77 | |
| 78 | - /** TABLE INFO: |
|
| 79 | - * Other information may be required for abstraction. If mail_checking is not enabled, your must define |
|
| 80 | - * at least the id_field for the table. |
|
| 81 | - */ |
|
| 82 | - "table_info" => [ |
|
| 83 | - "columns" => [ |
|
| 84 | - "id_field" => "USER_ID", # often the primary key |
|
| 85 | - "state_field" => "USER_STATE_ID", # required if mail_checking is enabled |
|
| 86 | - "email_field" => "EMAIL" # required registration process |
|
| 87 | - ], |
|
| 88 | - "column_values" => [ |
|
| 89 | - "state_field" => [ |
|
| 90 | - "pending_email" => 1, # required if mail_checking is enabled |
|
| 91 | - "user_active" => 2, # required if mail_checking is enabled |
|
| 92 | - ] |
|
| 93 | - ] |
|
| 94 | - ] |
|
| 78 | + /** TABLE INFO: |
|
| 79 | + * Other information may be required for abstraction. If mail_checking is not enabled, your must define |
|
| 80 | + * at least the id_field for the table. |
|
| 81 | + */ |
|
| 82 | + "table_info" => [ |
|
| 83 | + "columns" => [ |
|
| 84 | + "id_field" => "USER_ID", # often the primary key |
|
| 85 | + "state_field" => "USER_STATE_ID", # required if mail_checking is enabled |
|
| 86 | + "email_field" => "EMAIL" # required registration process |
|
| 87 | + ], |
|
| 88 | + "column_values" => [ |
|
| 89 | + "state_field" => [ |
|
| 90 | + "pending_email" => 1, # required if mail_checking is enabled |
|
| 91 | + "user_active" => 2, # required if mail_checking is enabled |
|
| 92 | + ] |
|
| 93 | + ] |
|
| 94 | + ] |
|
| 95 | 95 | |
| 96 | 96 | |
| 97 | - ], |
|
| 98 | - ], |
|
| 97 | + ], |
|
| 98 | + ], |
|
| 99 | 99 | /** AUTHORIZATION: |
| 100 | 100 | * |
| 101 | 101 | * If authorization is enabled, after user registering someone must authorize the first login of a user. |
@@ -104,14 +104,14 @@ discard block |
||
| 104 | 104 | * |
| 105 | 105 | * If authorization is not enabled, users will log in after registration process without a previous authorization. |
| 106 | 106 | */ |
| 107 | - "authorization" => [ |
|
| 108 | - "enabled" => "N" |
|
| 109 | - ], |
|
| 110 | - "database" => [ |
|
| 111 | - /** TABLE PREFIX: |
|
| 112 | - * Database prefix of tables, specifically here, the prefix of entity gateway above. |
|
| 113 | - */ |
|
| 114 | - "prefix" => ifdef('APP', ["database", "prefix"]) |
|
| 115 | - ], |
|
| 116 | - "redirect" => "App" # the module that will be redirect to, after authentication |
|
| 107 | + "authorization" => [ |
|
| 108 | + "enabled" => "N" |
|
| 109 | + ], |
|
| 110 | + "database" => [ |
|
| 111 | + /** TABLE PREFIX: |
|
| 112 | + * Database prefix of tables, specifically here, the prefix of entity gateway above. |
|
| 113 | + */ |
|
| 114 | + "prefix" => ifdef('APP', ["database", "prefix"]) |
|
| 115 | + ], |
|
| 116 | + "redirect" => "App" # the module that will be redirect to, after authentication |
|
| 117 | 117 | ]; |
| 118 | 118 | \ No newline at end of file |