@@ -14,8 +14,7 @@ |
||
| 14 | 14 | try { |
| 15 | 15 | $mvc = new Drone\Mvc\Application(include "config/application.config.php"); |
| 16 | 16 | $mvc->run(); |
| 17 | -} |
|
| 18 | -catch (Drone\Mvc\PageNotFoundException $e) |
|
| 17 | +} catch (Drone\Mvc\PageNotFoundException $e) |
|
| 19 | 18 | { |
| 20 | 19 | die('Error 404 (Page Not Found)!!'); |
| 21 | 20 | } |
| 22 | 21 | \ No newline at end of file |
@@ -26,8 +26,9 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | private function getUsersAdapter() |
| 28 | 28 | { |
| 29 | - if (!is_null($this->usersAdapter)) |
|
| 30 | - return $this->usersAdapter; |
|
| 29 | + if (!is_null($this->usersAdapter)) { |
|
| 30 | + return $this->usersAdapter; |
|
| 31 | + } |
|
| 31 | 32 | |
| 32 | 33 | $this->usersAdapter = new EntityAdapter(new TableGateway(new User())); |
| 33 | 34 | |
@@ -51,10 +52,11 @@ discard block |
||
| 51 | 52 | |
| 52 | 53 | if (array_key_exists($key, $_COOKIE) || !empty($_COOKIE[$key])) |
| 53 | 54 | { |
| 54 | - if (array_key_exists("CR_VAR_URL_REJECTED", $_SESSION) || !empty($_SESSION["CR_VAR_URL_REJECTED"])) |
|
| 55 | - header("location: " . $_SESSION["CR_VAR_URL_REJECTED"]); |
|
| 56 | - else |
|
| 57 | - header("location: " . $this->basePath . "/public/" . $config["redirect"]); |
|
| 55 | + if (array_key_exists("CR_VAR_URL_REJECTED", $_SESSION) || !empty($_SESSION["CR_VAR_URL_REJECTED"])) { |
|
| 56 | + header("location: " . $_SESSION["CR_VAR_URL_REJECTED"]); |
|
| 57 | + } else { |
|
| 58 | + header("location: " . $this->basePath . "/public/" . $config["redirect"]); |
|
| 59 | + } |
|
| 58 | 60 | } |
| 59 | 61 | |
| 60 | 62 | break; |
@@ -63,10 +65,11 @@ discard block |
||
| 63 | 65 | |
| 64 | 66 | if (array_key_exists($key, $_SESSION) || !empty($_SESSION[$key])) |
| 65 | 67 | { |
| 66 | - if (array_key_exists("CR_VAR_URL_REJECTED", $_SESSION) || !empty($_SESSION["CR_VAR_URL_REJECTED"])) |
|
| 67 | - header("location: " . $_SESSION["CR_VAR_URL_REJECTED"]); |
|
| 68 | - else |
|
| 69 | - header("location: " . $this->basePath . "/public/" . $config["redirect"]); |
|
| 68 | + if (array_key_exists("CR_VAR_URL_REJECTED", $_SESSION) || !empty($_SESSION["CR_VAR_URL_REJECTED"])) { |
|
| 69 | + header("location: " . $_SESSION["CR_VAR_URL_REJECTED"]); |
|
| 70 | + } else { |
|
| 71 | + header("location: " . $this->basePath . "/public/" . $config["redirect"]); |
|
| 72 | + } |
|
| 70 | 73 | } |
| 71 | 74 | |
| 72 | 75 | break; |
@@ -187,21 +190,24 @@ discard block |
||
| 187 | 190 | "$username_str" => $post["username"] |
| 188 | 191 | ]); |
| 189 | 192 | |
| 190 | - if (!count($row)) |
|
| 191 | - throw new \Drone\Exception\Exception("Username or password are incorrect"); |
|
| 193 | + if (!count($row)) { |
|
| 194 | + throw new \Drone\Exception\Exception("Username or password are incorrect"); |
|
| 195 | + } |
|
| 192 | 196 | |
| 193 | 197 | $user = array_shift($row); |
| 194 | 198 | |
| 195 | 199 | $securePass = $user->{$password_str}; |
| 196 | 200 | $password = $post["password"]; |
| 197 | 201 | |
| 198 | - if ($user->USER_STATE_ID == 1) |
|
| 199 | - throw new \Drone\Exception\Exception("User pending of email checking!"); |
|
| 202 | + if ($user->USER_STATE_ID == 1) { |
|
| 203 | + throw new \Drone\Exception\Exception("User pending of email checking!"); |
|
| 204 | + } |
|
| 200 | 205 | |
| 201 | 206 | $bcrypt = new Bcrypt(); |
| 202 | 207 | |
| 203 | - if (!$bcrypt->verify($password, $securePass)) |
|
| 204 | - throw new \Drone\Exception\Exception("Username or password are incorrect"); |
|
| 208 | + if (!$bcrypt->verify($password, $securePass)) { |
|
| 209 | + throw new \Drone\Exception\Exception("Username or password are incorrect"); |
|
| 210 | + } |
|
| 205 | 211 | |
| 206 | 212 | $key = $config["authentication"]["key"]; |
| 207 | 213 | $method = $config["authentication"]["method"]; |
@@ -219,14 +225,12 @@ discard block |
||
| 219 | 225 | |
| 220 | 226 | # SUCCESS-MESSAGE |
| 221 | 227 | $data["process"] = "success"; |
| 222 | - } |
|
| 223 | - catch (\Drone\Exception\Exception $e) |
|
| 228 | + } catch (\Drone\Exception\Exception $e) |
|
| 224 | 229 | { |
| 225 | 230 | # ERROR-MESSAGE |
| 226 | 231 | $data["process"] = "warning"; |
| 227 | 232 | $data["message"] = $e->getMessage(); |
| 228 | - } |
|
| 229 | - catch (\Exception $e) |
|
| 233 | + } catch (\Exception $e) |
|
| 230 | 234 | { |
| 231 | 235 | $file = str_replace('\\', '', __CLASS__); |
| 232 | 236 | $storage = new \Drone\Exception\Storage("cache/$file.json"); |
@@ -241,8 +245,9 @@ discard block |
||
| 241 | 245 | } |
| 242 | 246 | |
| 243 | 247 | # errors retrived by the use of ErrorTrait |
| 244 | - if (count($this->getErrors())) |
|
| 245 | - $this->handleErrors($this->getErrors(), __METHOD__); |
|
| 248 | + if (count($this->getErrors())) { |
|
| 249 | + $this->handleErrors($this->getErrors(), __METHOD__); |
|
| 250 | + } |
|
| 246 | 251 | |
| 247 | 252 | $data["code"] = $errorCode; |
| 248 | 253 | $data["message"] = $e->getMessage(); |
@@ -278,15 +283,16 @@ discard block |
||
| 278 | 283 | if (!$hd || !@fwrite($hd, $errorInformation)) |
| 279 | 284 | { |
| 280 | 285 | # error storing are not mandatory! |
| 286 | + } else { |
|
| 287 | + @fclose($hd); |
|
| 281 | 288 | } |
| 282 | - else |
|
| 283 | - @fclose($hd); |
|
| 284 | 289 | |
| 285 | 290 | $config = include 'config/application.config.php'; |
| 286 | 291 | $dev = $config["environment"]["dev_mode"]; |
| 287 | 292 | |
| 288 | - if ($dev) |
|
| 289 | - echo $errorInformation; |
|
| 293 | + if ($dev) { |
|
| 294 | + echo $errorInformation; |
|
| 295 | + } |
|
| 290 | 296 | } |
| 291 | 297 | } |
| 292 | 298 | } |
| 293 | 299 | \ No newline at end of file |
@@ -27,8 +27,9 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | private function getUsersEntity() |
| 29 | 29 | { |
| 30 | - if (!is_null($this->usersEntity)) |
|
| 31 | - return $this->usersEntity; |
|
| 30 | + if (!is_null($this->usersEntity)) { |
|
| 31 | + return $this->usersEntity; |
|
| 32 | + } |
|
| 32 | 33 | |
| 33 | 34 | $this->usersEntity = new EntityAdapter(new UserTbl(new User())); |
| 34 | 35 | |
@@ -52,10 +53,11 @@ discard block |
||
| 52 | 53 | |
| 53 | 54 | if (array_key_exists($key, $_COOKIE) || !empty($_COOKIE[$key])) |
| 54 | 55 | { |
| 55 | - if (array_key_exists("CR_VAR_URL_REJECTED", $_SESSION) || !empty($_SESSION["CR_VAR_URL_REJECTED"])) |
|
| 56 | - header("location: " . $_SESSION["CR_VAR_URL_REJECTED"]); |
|
| 57 | - else |
|
| 58 | - header("location: " . $this->basePath . "/public/" . $config["redirect"]); |
|
| 56 | + if (array_key_exists("CR_VAR_URL_REJECTED", $_SESSION) || !empty($_SESSION["CR_VAR_URL_REJECTED"])) { |
|
| 57 | + header("location: " . $_SESSION["CR_VAR_URL_REJECTED"]); |
|
| 58 | + } else { |
|
| 59 | + header("location: " . $this->basePath . "/public/" . $config["redirect"]); |
|
| 60 | + } |
|
| 59 | 61 | } |
| 60 | 62 | |
| 61 | 63 | break; |
@@ -64,10 +66,11 @@ discard block |
||
| 64 | 66 | |
| 65 | 67 | if (array_key_exists($key, $_SESSION) || !empty($_SESSION[$key])) |
| 66 | 68 | { |
| 67 | - if (array_key_exists("CR_VAR_URL_REJECTED", $_SESSION) || !empty($_SESSION["CR_VAR_URL_REJECTED"])) |
|
| 68 | - header("location: " . $_SESSION["CR_VAR_URL_REJECTED"]); |
|
| 69 | - else |
|
| 70 | - header("location: " . $this->basePath . "/public/" . $config["redirect"]); |
|
| 69 | + if (array_key_exists("CR_VAR_URL_REJECTED", $_SESSION) || !empty($_SESSION["CR_VAR_URL_REJECTED"])) { |
|
| 70 | + header("location: " . $_SESSION["CR_VAR_URL_REJECTED"]); |
|
| 71 | + } else { |
|
| 72 | + header("location: " . $this->basePath . "/public/" . $config["redirect"]); |
|
| 73 | + } |
|
| 71 | 74 | } |
| 72 | 75 | |
| 73 | 76 | break; |
@@ -136,8 +139,9 @@ discard block |
||
| 136 | 139 | |
| 137 | 140 | $this->checkSession(); |
| 138 | 141 | |
| 139 | - if ($post["password"] !== $post["password_confirm"]) |
|
| 140 | - throw new \Drone\Exception\Exception("The password fields are different!", 300); |
|
| 142 | + if ($post["password"] !== $post["password_confirm"]) { |
|
| 143 | + throw new \Drone\Exception\Exception("The password fields are different!", 300); |
|
| 144 | + } |
|
| 141 | 145 | |
| 142 | 146 | $components = [ |
| 143 | 147 | "attributes" => [ |
@@ -205,8 +209,9 @@ discard block |
||
| 205 | 209 | "USERNAME" => $post["username"] |
| 206 | 210 | ]); |
| 207 | 211 | |
| 208 | - if (count($row)) |
|
| 209 | - throw new \Drone\Exception\Exception("This username already exists!", 300); |
|
| 212 | + if (count($row)) { |
|
| 213 | + throw new \Drone\Exception\Exception("This username already exists!", 300); |
|
| 214 | + } |
|
| 210 | 215 | |
| 211 | 216 | $bcrypt = new Bcrypt(); |
| 212 | 217 | $securePass = $bcrypt->create($post["password"]); |
@@ -262,14 +267,12 @@ discard block |
||
| 262 | 267 | |
| 263 | 268 | # SUCCESS-MESSAGE |
| 264 | 269 | $data["process"] = "success"; |
| 265 | - } |
|
| 266 | - catch (\Drone\Exception\Exception $e) |
|
| 270 | + } catch (\Drone\Exception\Exception $e) |
|
| 267 | 271 | { |
| 268 | 272 | # ERROR-MESSAGE |
| 269 | 273 | $data["process"] = "warning"; |
| 270 | 274 | $data["message"] = $e->getMessage(); |
| 271 | - } |
|
| 272 | - catch (\Exception $e) |
|
| 275 | + } catch (\Exception $e) |
|
| 273 | 276 | { |
| 274 | 277 | $file = str_replace('\\', '', __CLASS__); |
| 275 | 278 | $storage = new \Drone\Exception\Storage("cache/$file.json"); |
@@ -284,8 +287,9 @@ discard block |
||
| 284 | 287 | } |
| 285 | 288 | |
| 286 | 289 | # errors retrived by the use of ErrorTrait |
| 287 | - if (count($this->getErrors())) |
|
| 288 | - $this->handleErrors($this->getErrors(), __METHOD__); |
|
| 290 | + if (count($this->getErrors())) { |
|
| 291 | + $this->handleErrors($this->getErrors(), __METHOD__); |
|
| 292 | + } |
|
| 289 | 293 | |
| 290 | 294 | $data["code"] = $errorCode; |
| 291 | 295 | $data["message"] = $e->getMessage(); |
@@ -346,13 +350,15 @@ discard block |
||
| 346 | 350 | "TOKEN" => $token |
| 347 | 351 | ]); |
| 348 | 352 | |
| 349 | - if (!count($row)) |
|
| 350 | - throw new \Drone\Exception\Exception("Token has expired or username does not exists!."); |
|
| 353 | + if (!count($row)) { |
|
| 354 | + throw new \Drone\Exception\Exception("Token has expired or username does not exists!."); |
|
| 355 | + } |
|
| 351 | 356 | |
| 352 | 357 | $user = array_shift($row); |
| 353 | 358 | |
| 354 | - if ($user->USER_STATE_ID <> 1) |
|
| 355 | - throw new \Drone\Exception\Exception("This email address had verified before!.", 300); |
|
| 359 | + if ($user->USER_STATE_ID <> 1) { |
|
| 360 | + throw new \Drone\Exception\Exception("This email address had verified before!.", 300); |
|
| 361 | + } |
|
| 356 | 362 | |
| 357 | 363 | $user->USER_STATE_ID = 2; |
| 358 | 364 | |
@@ -362,14 +368,12 @@ discard block |
||
| 362 | 368 | |
| 363 | 369 | # SUCCESS-MESSAGE |
| 364 | 370 | $data["process"] = "success"; |
| 365 | - } |
|
| 366 | - catch (\Drone\Exception\Exception $e) |
|
| 371 | + } catch (\Drone\Exception\Exception $e) |
|
| 367 | 372 | { |
| 368 | 373 | # ERROR-MESSAGE |
| 369 | 374 | $data["process"] = "warning"; |
| 370 | 375 | $data["message"] = $e->getMessage(); |
| 371 | - } |
|
| 372 | - catch (\Exception $e) |
|
| 376 | + } catch (\Exception $e) |
|
| 373 | 377 | { |
| 374 | 378 | $file = str_replace('\\', '', __CLASS__); |
| 375 | 379 | $storage = new \Drone\Exception\Storage("cache/$file.json"); |
@@ -384,8 +388,9 @@ discard block |
||
| 384 | 388 | } |
| 385 | 389 | |
| 386 | 390 | # errors retrived by the use of ErrorTrait |
| 387 | - if (count($this->getErrors())) |
|
| 388 | - $this->handleErrors($this->getErrors(), __METHOD__); |
|
| 391 | + if (count($this->getErrors())) { |
|
| 392 | + $this->handleErrors($this->getErrors(), __METHOD__); |
|
| 393 | + } |
|
| 389 | 394 | |
| 390 | 395 | $data["code"] = $errorCode; |
| 391 | 396 | $data["message"] = $e->getMessage(); |
@@ -421,15 +426,16 @@ discard block |
||
| 421 | 426 | if (!$hd || !@fwrite($hd, $errorInformation)) |
| 422 | 427 | { |
| 423 | 428 | # error storing are not mandatory! |
| 429 | + } else { |
|
| 430 | + @fclose($hd); |
|
| 424 | 431 | } |
| 425 | - else |
|
| 426 | - @fclose($hd); |
|
| 427 | 432 | |
| 428 | 433 | $config = include 'config/application.config.php'; |
| 429 | 434 | $dev = $config["environment"]["dev_mode"]; |
| 430 | 435 | |
| 431 | - if ($dev) |
|
| 432 | - echo $errorInformation; |
|
| 436 | + if ($dev) { |
|
| 437 | + echo $errorInformation; |
|
| 438 | + } |
|
| 433 | 439 | } |
| 434 | 440 | } |
| 435 | 441 | } |
| 436 | 442 | \ No newline at end of file |
@@ -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 |
@@ -121,9 +121,9 @@ |
||
| 121 | 121 | $again = true; |
| 122 | 122 | $new_config[$param . "_" . $key] = $value; |
| 123 | 123 | } |
| 124 | + } else { |
|
| 125 | + $new_config[$param] = $configure; |
|
| 124 | 126 | } |
| 125 | - else |
|
| 126 | - $new_config[$param] = $configure; |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | return (!$again) ? $new_config : $this->toFormConfig($new_config); |
@@ -96,8 +96,9 @@ discard block |
||
| 96 | 96 | */ |
| 97 | 97 | private function getUsersEntity() |
| 98 | 98 | { |
| 99 | - if (!is_null($this->usersEntity)) |
|
| 100 | - return $this->usersEntity; |
|
| 99 | + if (!is_null($this->usersEntity)) { |
|
| 100 | + return $this->usersEntity; |
|
| 101 | + } |
|
| 101 | 102 | |
| 102 | 103 | $this->usersEntity = new EntityAdapter(new TableGateway(new UserModel())); |
| 103 | 104 | |
@@ -109,8 +110,9 @@ discard block |
||
| 109 | 110 | */ |
| 110 | 111 | private function getIdentifiersEntity() |
| 111 | 112 | { |
| 112 | - if (!is_null($this->identifiersEntity)) |
|
| 113 | - return $this->identifiersEntity; |
|
| 113 | + if (!is_null($this->identifiersEntity)) { |
|
| 114 | + return $this->identifiersEntity; |
|
| 115 | + } |
|
| 114 | 116 | |
| 115 | 117 | $this->identifiersEntity = new EntityAdapter(new TableGateway(new Identifiers())); |
| 116 | 118 | |
@@ -122,8 +124,9 @@ discard block |
||
| 122 | 124 | */ |
| 123 | 125 | private function getConnectionTypesEntity() |
| 124 | 126 | { |
| 125 | - if (!is_null($this->connectionTypesEntity)) |
|
| 126 | - return $this->connectionTypesEntity; |
|
| 127 | + if (!is_null($this->connectionTypesEntity)) { |
|
| 128 | + return $this->connectionTypesEntity; |
|
| 129 | + } |
|
| 127 | 130 | |
| 128 | 131 | $this->connectionTypesEntity = new EntityAdapter(new TableGateway(new ConnectionType())); |
| 129 | 132 | |
@@ -135,8 +138,9 @@ discard block |
||
| 135 | 138 | */ |
| 136 | 139 | private function getConnectionFieldsEntity() |
| 137 | 140 | { |
| 138 | - if (!is_null($this->connectionFieldsEntity)) |
|
| 139 | - return $this->connectionFieldsEntity; |
|
| 141 | + if (!is_null($this->connectionFieldsEntity)) { |
|
| 142 | + return $this->connectionFieldsEntity; |
|
| 143 | + } |
|
| 140 | 144 | |
| 141 | 145 | $this->connectionFieldsEntity = new EntityAdapter(new TableGateway(new ConnectionTypeField())); |
| 142 | 146 | |
@@ -148,8 +152,9 @@ discard block |
||
| 148 | 152 | */ |
| 149 | 153 | private function getUserConnectionEntity() |
| 150 | 154 | { |
| 151 | - if (!is_null($this->userConnectionEntity)) |
|
| 152 | - return $this->userConnectionEntity; |
|
| 155 | + if (!is_null($this->userConnectionEntity)) { |
|
| 156 | + return $this->userConnectionEntity; |
|
| 157 | + } |
|
| 153 | 158 | |
| 154 | 159 | $this->userConnectionEntity = new EntityAdapter(new UserConnectionsTable(new UserConnection())); |
| 155 | 160 | |
@@ -161,8 +166,9 @@ discard block |
||
| 161 | 166 | */ |
| 162 | 167 | private function getUserConnectionDetailsEntity() |
| 163 | 168 | { |
| 164 | - if (!is_null($this->userConnectionDetailsEntity)) |
|
| 165 | - return $this->userConnectionDetailsEntity; |
|
| 169 | + if (!is_null($this->userConnectionDetailsEntity)) { |
|
| 170 | + return $this->userConnectionDetailsEntity; |
|
| 171 | + } |
|
| 166 | 172 | |
| 167 | 173 | $this->userConnectionDetailsEntity = new EntityAdapter(new TableGateway(new UserConnectionDetails())); |
| 168 | 174 | |
@@ -226,12 +232,12 @@ discard block |
||
| 226 | 232 | { |
| 227 | 233 | foreach ($idenfiers as $identifier) |
| 228 | 234 | { |
| 229 | - if ($field->CONN_IDENTI_ID == $identifier->CONN_IDENTI_ID) |
|
| 230 | - $dbconfig[$identifier->CONN_IDENTI_NAME] = $field->FIELD_VALUE; |
|
| 235 | + if ($field->CONN_IDENTI_ID == $identifier->CONN_IDENTI_ID) { |
|
| 236 | + $dbconfig[$identifier->CONN_IDENTI_NAME] = $field->FIELD_VALUE; |
|
| 237 | + } |
|
| 231 | 238 | } |
| 232 | 239 | } |
| 233 | - } |
|
| 234 | - else |
|
| 240 | + } else |
|
| 235 | 241 | { |
| 236 | 242 | # STANDARD VALIDATIONS [check needed arguments] |
| 237 | 243 | $needles = ['type', 'aliasname']; |
@@ -287,8 +293,9 @@ discard block |
||
| 287 | 293 | { |
| 288 | 294 | foreach ($idenfiers as $identifier) |
| 289 | 295 | { |
| 290 | - if ($field_number == $identifier->CONN_IDENTI_ID) |
|
| 291 | - $dbconfig[$identifier->CONN_IDENTI_NAME] = $field_value; |
|
| 296 | + if ($field_number == $identifier->CONN_IDENTI_ID) { |
|
| 297 | + $dbconfig[$identifier->CONN_IDENTI_NAME] = $field_value; |
|
| 298 | + } |
|
| 292 | 299 | } |
| 293 | 300 | } |
| 294 | 301 | } |
@@ -300,8 +307,7 @@ discard block |
||
| 300 | 307 | |
| 301 | 308 | $driverAdapter = new \Drone\Db\Driver\DriverAdapter($dbconfig, false); |
| 302 | 309 | $driverAdapter->getDb()->connect(); |
| 303 | - } |
|
| 304 | - catch (\Exception $e) |
|
| 310 | + } catch (\Exception $e) |
|
| 305 | 311 | { |
| 306 | 312 | # SUCCESS-MESSAGE |
| 307 | 313 | $data["process"] = "error"; |
@@ -312,14 +318,12 @@ discard block |
||
| 312 | 318 | |
| 313 | 319 | # SUCCESS-MESSAGE |
| 314 | 320 | $data["process"] = "success"; |
| 315 | - } |
|
| 316 | - catch (\Drone\Exception\Exception $e) |
|
| 321 | + } catch (\Drone\Exception\Exception $e) |
|
| 317 | 322 | { |
| 318 | 323 | # ERROR-MESSAGE |
| 319 | 324 | $data["process"] = "warning"; |
| 320 | 325 | $data["message"] = $e->getMessage(); |
| 321 | - } |
|
| 322 | - catch (\Exception $e) |
|
| 326 | + } catch (\Exception $e) |
|
| 323 | 327 | { |
| 324 | 328 | $file = str_replace('\\', '', __CLASS__); |
| 325 | 329 | $storage = new \Drone\Exception\Storage("cache/$file.json"); |
@@ -427,13 +431,15 @@ discard block |
||
| 427 | 431 | "USER_CONN_ID" => $id |
| 428 | 432 | ]); |
| 429 | 433 | |
| 430 | - if (!count($connection)) |
|
| 431 | - throw new \Exception("The Connection does not exists"); |
|
| 434 | + if (!count($connection)) { |
|
| 435 | + throw new \Exception("The Connection does not exists"); |
|
| 436 | + } |
|
| 432 | 437 | |
| 433 | 438 | $connection = array_shift($connection); |
| 434 | 439 | |
| 435 | - if ($connection->STATE == 'I') |
|
| 436 | - throw new \Drone\Exception\Exception("This connection was deleted", 300); |
|
| 440 | + if ($connection->STATE == 'I') { |
|
| 441 | + throw new \Drone\Exception\Exception("This connection was deleted", 300); |
|
| 442 | + } |
|
| 437 | 443 | |
| 438 | 444 | $details = $this->getUserConnectionDetailsEntity()->select([ |
| 439 | 445 | "USER_CONN_ID" => $id |
@@ -447,16 +453,18 @@ discard block |
||
| 447 | 453 | { |
| 448 | 454 | foreach ($idenfiers as $identifier) |
| 449 | 455 | { |
| 450 | - if ($field->CONN_IDENTI_ID == $identifier->CONN_IDENTI_ID) |
|
| 451 | - $dbconfig[$identifier->CONN_IDENTI_NAME] = $field->FIELD_VALUE; |
|
| 456 | + if ($field->CONN_IDENTI_ID == $identifier->CONN_IDENTI_ID) { |
|
| 457 | + $dbconfig[$identifier->CONN_IDENTI_NAME] = $field->FIELD_VALUE; |
|
| 458 | + } |
|
| 452 | 459 | } |
| 453 | 460 | } |
| 454 | 461 | |
| 455 | 462 | /* identifies if sql is base64 encoded */ |
| 456 | 463 | if (array_key_exists('base64', $post)) |
| 457 | 464 | { |
| 458 | - if ((bool) $post["base64"]) |
|
| 459 | - $post["sql"] = base64_decode($post["sql"]); |
|
| 465 | + if ((bool) $post["base64"]) { |
|
| 466 | + $post["sql"] = base64_decode($post["sql"]); |
|
| 467 | + } |
|
| 460 | 468 | } |
| 461 | 469 | |
| 462 | 470 | $data["sql"] = base64_encode($post["sql"]); |
@@ -468,8 +476,9 @@ discard block |
||
| 468 | 476 | */ |
| 469 | 477 | $sql_text = trim($sql_text); |
| 470 | 478 | |
| 471 | - if (empty($sql_text)) |
|
| 472 | - throw new \Drone\Exception\Exception("Empty statement"); |
|
| 479 | + if (empty($sql_text)) { |
|
| 480 | + throw new \Drone\Exception\Exception("Empty statement"); |
|
| 481 | + } |
|
| 473 | 482 | |
| 474 | 483 | $pos = strpos($sql_text, ';'); |
| 475 | 484 | |
@@ -477,8 +486,9 @@ discard block |
||
| 477 | 486 | { |
| 478 | 487 | $end_stament = strstr($sql_text, ';'); |
| 479 | 488 | |
| 480 | - if ($end_stament == ';') |
|
| 481 | - $sql_text = strstr($sql_text, ';', true); |
|
| 489 | + if ($end_stament == ';') { |
|
| 490 | + $sql_text = strstr($sql_text, ';', true); |
|
| 491 | + } |
|
| 482 | 492 | } |
| 483 | 493 | |
| 484 | 494 | # clean comments and other characters |
@@ -556,10 +566,11 @@ discard block |
||
| 556 | 566 | case 'mysqli': |
| 557 | 567 | |
| 558 | 568 | # show statement cannot be a subquery |
| 559 | - if (!$isShowStm) |
|
| 560 | - $sql_text = "SELECT (@ROW_NUM:=@ROW_NUM + 1) AS ROW_NUM, V.* FROM ( |
|
| 569 | + if (!$isShowStm) { |
|
| 570 | + $sql_text = "SELECT (@ROW_NUM:=@ROW_NUM + 1) AS ROW_NUM, V.* FROM ( |
|
| 561 | 571 | " . $sql_text . " |
| 562 | 572 | ) V LIMIT $row_start, $step"; |
| 573 | + } |
|
| 563 | 574 | break; |
| 564 | 575 | |
| 565 | 576 | case 'oci8': |
@@ -636,8 +647,7 @@ discard block |
||
| 636 | 647 | |
| 637 | 648 | # redirect view |
| 638 | 649 | $this->setMethod('error'); |
| 639 | - } |
|
| 640 | - catch (\Exception $e) |
|
| 650 | + } catch (\Exception $e) |
|
| 641 | 651 | { |
| 642 | 652 | # SUCCESS-MESSAGE |
| 643 | 653 | $data["process"] = "error"; |
@@ -689,8 +699,9 @@ discard block |
||
| 689 | 699 | |
| 690 | 700 | foreach ($row as $column => $value) |
| 691 | 701 | { |
| 692 | - if ($isShowStm) |
|
| 693 | - $column++; |
|
| 702 | + if ($isShowStm) { |
|
| 703 | + $column++; |
|
| 704 | + } |
|
| 694 | 705 | |
| 695 | 706 | if (gettype($value) == 'object') |
| 696 | 707 | { |
@@ -703,11 +714,10 @@ discard block |
||
| 703 | 714 | } |
| 704 | 715 | |
| 705 | 716 | $data["data"][$key][$column] = $val; |
| 717 | + } else { |
|
| 718 | + $data["data"][$key][$column] = $value; |
|
| 706 | 719 | } |
| 707 | - else |
|
| 708 | - $data["data"][$key][$column] = $value; |
|
| 709 | - } |
|
| 710 | - else { |
|
| 720 | + } else { |
|
| 711 | 721 | $data["data"][$key][$column] = $value; |
| 712 | 722 | } |
| 713 | 723 | } |
@@ -718,24 +728,24 @@ discard block |
||
| 718 | 728 | { |
| 719 | 729 | $data["column_errors"] = $column_errors; |
| 720 | 730 | |
| 721 | - if ($row_start > 1) |
|
| 722 | - $this->setMethod('nextResults'); |
|
| 731 | + if ($row_start > 1) { |
|
| 732 | + $this->setMethod('nextResults'); |
|
| 733 | + } |
|
| 723 | 734 | } |
| 724 | 735 | |
| 725 | - if (array_key_exists('id', $post)) |
|
| 726 | - $data["id"] = $post["id"]; |
|
| 736 | + if (array_key_exists('id', $post)) { |
|
| 737 | + $data["id"] = $post["id"]; |
|
| 738 | + } |
|
| 727 | 739 | |
| 728 | 740 | # SUCCESS-MESSAGE |
| 729 | 741 | $data["process"] = "success"; |
| 730 | 742 | } |
| 731 | - } |
|
| 732 | - catch (\Drone\Exception\Exception $e) |
|
| 743 | + } catch (\Drone\Exception\Exception $e) |
|
| 733 | 744 | { |
| 734 | 745 | # ERROR-MESSAGE |
| 735 | 746 | $data["process"] = "warning"; |
| 736 | 747 | $data["message"] = $e->getMessage(); |
| 737 | - } |
|
| 738 | - catch (\Exception $e) |
|
| 748 | + } catch (\Exception $e) |
|
| 739 | 749 | { |
| 740 | 750 | $file = str_replace('\\', '', __CLASS__); |
| 741 | 751 | $storage = new \Drone\Exception\Storage("cache/$file.json"); |
@@ -869,13 +879,15 @@ discard block |
||
| 869 | 879 | "USER_CONN_ID" => $id |
| 870 | 880 | ]); |
| 871 | 881 | |
| 872 | - if (!count($connection)) |
|
| 873 | - throw new \Exception("The Connection does not exists"); |
|
| 882 | + if (!count($connection)) { |
|
| 883 | + throw new \Exception("The Connection does not exists"); |
|
| 884 | + } |
|
| 874 | 885 | |
| 875 | 886 | $connection = array_shift($connection); |
| 876 | 887 | |
| 877 | - if ($connection->STATE == 'I') |
|
| 878 | - throw new \Drone\Exception\Exception("This connection was deleted", 300); |
|
| 888 | + if ($connection->STATE == 'I') { |
|
| 889 | + throw new \Drone\Exception\Exception("This connection was deleted", 300); |
|
| 890 | + } |
|
| 879 | 891 | |
| 880 | 892 | $details = $this->getUserConnectionDetailsEntity()->select([ |
| 881 | 893 | "USER_CONN_ID" => $id |
@@ -889,16 +901,18 @@ discard block |
||
| 889 | 901 | { |
| 890 | 902 | foreach ($idenfiers as $identifier) |
| 891 | 903 | { |
| 892 | - if ($field->CONN_IDENTI_ID == $identifier->CONN_IDENTI_ID) |
|
| 893 | - $dbconfig[$identifier->CONN_IDENTI_NAME] = $field->FIELD_VALUE; |
|
| 904 | + if ($field->CONN_IDENTI_ID == $identifier->CONN_IDENTI_ID) { |
|
| 905 | + $dbconfig[$identifier->CONN_IDENTI_NAME] = $field->FIELD_VALUE; |
|
| 906 | + } |
|
| 894 | 907 | } |
| 895 | 908 | } |
| 896 | 909 | |
| 897 | 910 | /* identifies if sql is base64 encoded */ |
| 898 | 911 | if (array_key_exists('base64', $post)) |
| 899 | 912 | { |
| 900 | - if ((bool) $post["base64"]) |
|
| 901 | - $post["sql"] = base64_decode($post["sql"]); |
|
| 913 | + if ((bool) $post["base64"]) { |
|
| 914 | + $post["sql"] = base64_decode($post["sql"]); |
|
| 915 | + } |
|
| 902 | 916 | } |
| 903 | 917 | |
| 904 | 918 | $data["sql"] = base64_encode($post["sql"]); |
@@ -910,8 +924,9 @@ discard block |
||
| 910 | 924 | */ |
| 911 | 925 | $sql_text = trim($sql_text); |
| 912 | 926 | |
| 913 | - if (empty($sql_text)) |
|
| 914 | - throw new \Drone\Exception\Exception("Empty statement"); |
|
| 927 | + if (empty($sql_text)) { |
|
| 928 | + throw new \Drone\Exception\Exception("Empty statement"); |
|
| 929 | + } |
|
| 915 | 930 | |
| 916 | 931 | $pos = strpos($sql_text, ';'); |
| 917 | 932 | |
@@ -919,8 +934,9 @@ discard block |
||
| 919 | 934 | { |
| 920 | 935 | $end_stament = strstr($sql_text, ';'); |
| 921 | 936 | |
| 922 | - if ($end_stament == ';') |
|
| 923 | - $sql_text = strstr($sql_text, ';', true); |
|
| 937 | + if ($end_stament == ';') { |
|
| 938 | + $sql_text = strstr($sql_text, ';', true); |
|
| 939 | + } |
|
| 924 | 940 | } |
| 925 | 941 | |
| 926 | 942 | # clean comments and other characters |
@@ -941,8 +957,9 @@ discard block |
||
| 941 | 957 | $isShowStm = $data["showStm"] = (preg_match('/^SHOW/i', $clean_code)); |
| 942 | 958 | |
| 943 | 959 | # detect selection |
| 944 | - if (!$isSelectStm && !$isShowStm) |
|
| 945 | - throw new \Exception("You can't export a non-selection statement!"); |
|
| 960 | + if (!$isSelectStm && !$isShowStm) { |
|
| 961 | + throw new \Exception("You can't export a non-selection statement!"); |
|
| 962 | + } |
|
| 946 | 963 | |
| 947 | 964 | try { |
| 948 | 965 | |
@@ -988,8 +1005,7 @@ discard block |
||
| 988 | 1005 | |
| 989 | 1006 | # redirect view |
| 990 | 1007 | $this->setMethod('error'); |
| 991 | - } |
|
| 992 | - catch (\Exception $e) |
|
| 1008 | + } catch (\Exception $e) |
|
| 993 | 1009 | { |
| 994 | 1010 | # SUCCESS-MESSAGE |
| 995 | 1011 | $data["process"] = "error"; |
@@ -1060,8 +1076,9 @@ discard block |
||
| 1060 | 1076 | |
| 1061 | 1077 | foreach ($rows[0] as $column_name => $row) |
| 1062 | 1078 | { |
| 1063 | - if (!is_numeric($column_name)) |
|
| 1064 | - $column_names[] = $column_name; |
|
| 1079 | + if (!is_numeric($column_name)) { |
|
| 1080 | + $column_names[] = $column_name; |
|
| 1081 | + } |
|
| 1065 | 1082 | } |
| 1066 | 1083 | |
| 1067 | 1084 | $table .= "\t<thead>\r\n\t\t<tr>\r\n"; |
@@ -1080,8 +1097,9 @@ discard block |
||
| 1080 | 1097 | |
| 1081 | 1098 | foreach ($row as $column => $value) |
| 1082 | 1099 | { |
| 1083 | - if ($isShowStm) |
|
| 1084 | - $column++; |
|
| 1100 | + if ($isShowStm) { |
|
| 1101 | + $column++; |
|
| 1102 | + } |
|
| 1085 | 1103 | |
| 1086 | 1104 | if (gettype($value) == 'object') |
| 1087 | 1105 | { |
@@ -1094,11 +1112,10 @@ discard block |
||
| 1094 | 1112 | } |
| 1095 | 1113 | |
| 1096 | 1114 | $data["data"][$key][$column] = $val; |
| 1115 | + } else { |
|
| 1116 | + $data["data"][$key][$column] = $value; |
|
| 1097 | 1117 | } |
| 1098 | - else |
|
| 1099 | - $data["data"][$key][$column] = $value; |
|
| 1100 | - } |
|
| 1101 | - else { |
|
| 1118 | + } else { |
|
| 1102 | 1119 | $data["data"][$key][$column] = $value; |
| 1103 | 1120 | } |
| 1104 | 1121 | } |
@@ -1130,8 +1147,9 @@ discard block |
||
| 1130 | 1147 | |
| 1131 | 1148 | foreach ($rows[0] as $column_name => $row) |
| 1132 | 1149 | { |
| 1133 | - if (!is_numeric($column_name)) |
|
| 1134 | - $column_names[] = $column_name; |
|
| 1150 | + if (!is_numeric($column_name)) { |
|
| 1151 | + $column_names[] = $column_name; |
|
| 1152 | + } |
|
| 1135 | 1153 | } |
| 1136 | 1154 | |
| 1137 | 1155 | foreach ($column_names as $column_name) |
@@ -1148,8 +1166,9 @@ discard block |
||
| 1148 | 1166 | |
| 1149 | 1167 | foreach ($row as $column => $value) |
| 1150 | 1168 | { |
| 1151 | - if ($isShowStm) |
|
| 1152 | - $column++; |
|
| 1169 | + if ($isShowStm) { |
|
| 1170 | + $column++; |
|
| 1171 | + } |
|
| 1153 | 1172 | |
| 1154 | 1173 | if (gettype($value) == 'object') |
| 1155 | 1174 | { |
@@ -1162,11 +1181,10 @@ discard block |
||
| 1162 | 1181 | } |
| 1163 | 1182 | |
| 1164 | 1183 | $data["data"][$key][$column] = $val; |
| 1184 | + } else { |
|
| 1185 | + $data["data"][$key][$column] = $value; |
|
| 1165 | 1186 | } |
| 1166 | - else |
|
| 1167 | - $data["data"][$key][$column] = $value; |
|
| 1168 | - } |
|
| 1169 | - else { |
|
| 1187 | + } else { |
|
| 1170 | 1188 | $data["data"][$key][$column] = $value; |
| 1171 | 1189 | } |
| 1172 | 1190 | } |
@@ -1203,20 +1221,19 @@ discard block |
||
| 1203 | 1221 | |
| 1204 | 1222 | $data["filename"] = $filename; |
| 1205 | 1223 | |
| 1206 | - if (array_key_exists('id', $post)) |
|
| 1207 | - $data["id"] = $post["id"]; |
|
| 1224 | + if (array_key_exists('id', $post)) { |
|
| 1225 | + $data["id"] = $post["id"]; |
|
| 1226 | + } |
|
| 1208 | 1227 | |
| 1209 | 1228 | # SUCCESS-MESSAGE |
| 1210 | 1229 | $data["process"] = "success"; |
| 1211 | 1230 | } |
| 1212 | - } |
|
| 1213 | - catch (\Drone\Exception\Exception $e) |
|
| 1231 | + } catch (\Drone\Exception\Exception $e) |
|
| 1214 | 1232 | { |
| 1215 | 1233 | # ERROR-MESSAGE |
| 1216 | 1234 | $data["process"] = "warning"; |
| 1217 | 1235 | $data["message"] = $e->getMessage(); |
| 1218 | - } |
|
| 1219 | - catch (\Exception $e) |
|
| 1236 | + } catch (\Exception $e) |
|
| 1220 | 1237 | { |
| 1221 | 1238 | $file = str_replace('\\', '', __CLASS__); |
| 1222 | 1239 | $storage = new \Drone\Exception\Storage("cache/$file.json"); |
@@ -1231,8 +1248,9 @@ discard block |
||
| 1231 | 1248 | } |
| 1232 | 1249 | |
| 1233 | 1250 | # errors retrived by the use of ErrorTrait |
| 1234 | - if (count($this->getErrors())) |
|
| 1235 | - $this->handleErrors($this->getErrors(), __METHOD__); |
|
| 1251 | + if (count($this->getErrors())) { |
|
| 1252 | + $this->handleErrors($this->getErrors(), __METHOD__); |
|
| 1253 | + } |
|
| 1236 | 1254 | |
| 1237 | 1255 | $data["code"] = $errorCode; |
| 1238 | 1256 | $data["message"] = $e->getMessage(); |
@@ -1268,15 +1286,16 @@ discard block |
||
| 1268 | 1286 | if (!$hd || !@fwrite($hd, $errorInformation)) |
| 1269 | 1287 | { |
| 1270 | 1288 | # error storing are not mandatory! |
| 1289 | + } else { |
|
| 1290 | + @fclose($hd); |
|
| 1271 | 1291 | } |
| 1272 | - else |
|
| 1273 | - @fclose($hd); |
|
| 1274 | 1292 | |
| 1275 | 1293 | $config = include 'config/application.config.php'; |
| 1276 | 1294 | $dev = $config["environment"]["dev_mode"]; |
| 1277 | 1295 | |
| 1278 | - if ($dev) |
|
| 1279 | - echo $errorInformation; |
|
| 1296 | + if ($dev) { |
|
| 1297 | + echo $errorInformation; |
|
| 1298 | + } |
|
| 1280 | 1299 | } |
| 1281 | 1300 | } |
| 1282 | 1301 | } |
| 1283 | 1302 | \ No newline at end of file |
@@ -86,15 +86,17 @@ discard block |
||
| 86 | 86 | { |
| 87 | 87 | case '_COOKIE': |
| 88 | 88 | |
| 89 | - if (!array_key_exists($key, $_COOKIE) || empty($_COOKIE[$key])) |
|
| 90 | - header("location: " . $c->basePath ."/public/". "Auth"); |
|
| 89 | + if (!array_key_exists($key, $_COOKIE) || empty($_COOKIE[$key])) { |
|
| 90 | + header("location: " . $c->basePath ."/public/". "Auth"); |
|
| 91 | + } |
|
| 91 | 92 | |
| 92 | 93 | break; |
| 93 | 94 | |
| 94 | 95 | case '_SESSION': |
| 95 | 96 | |
| 96 | - if (!array_key_exists($key, $_SESSION) || empty($_SESSION[$key])) |
|
| 97 | - header("location: " . $c->basePath ."/public/". "Auth"); |
|
| 97 | + if (!array_key_exists($key, $_SESSION) || empty($_SESSION[$key])) { |
|
| 98 | + header("location: " . $c->basePath ."/public/". "Auth"); |
|
| 99 | + } |
|
| 98 | 100 | |
| 99 | 101 | break; |
| 100 | 102 | } |
@@ -141,9 +143,9 @@ discard block |
||
| 141 | 143 | $again = true; |
| 142 | 144 | $new_config[$param . "_" . $key] = $value; |
| 143 | 145 | } |
| 146 | + } else { |
|
| 147 | + $new_config[$param] = $configure; |
|
| 144 | 148 | } |
| 145 | - else |
|
| 146 | - $new_config[$param] = $configure; |
|
| 147 | 149 | } |
| 148 | 150 | |
| 149 | 151 | return (!$again) ? $new_config : $this->toFormConfig($new_config); |
@@ -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 | } |