@@ -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"; |
@@ -692,8 +702,9 @@ discard block |
||
692 | 702 | |
693 | 703 | foreach ($row as $column => $value) |
694 | 704 | { |
695 | - if ($isShowStm) |
|
696 | - $column++; |
|
705 | + if ($isShowStm) { |
|
706 | + $column++; |
|
707 | + } |
|
697 | 708 | |
698 | 709 | if (gettype($value) == 'object') |
699 | 710 | { |
@@ -706,11 +717,10 @@ discard block |
||
706 | 717 | } |
707 | 718 | |
708 | 719 | $data["data"][$key][$column] = $val; |
720 | + } else { |
|
721 | + $data["data"][$key][$column] = $value; |
|
709 | 722 | } |
710 | - else |
|
711 | - $data["data"][$key][$column] = $value; |
|
712 | - } |
|
713 | - else { |
|
723 | + } else { |
|
714 | 724 | $data["data"][$key][$column] = $value; |
715 | 725 | } |
716 | 726 | } |
@@ -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,8 +901,9 @@ 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 | |
@@ -905,8 +918,9 @@ discard block |
||
905 | 918 | */ |
906 | 919 | $sql_text = trim($sql_text); |
907 | 920 | |
908 | - if (empty($sql_text)) |
|
909 | - throw new \Drone\Exception\Exception("Empty statement"); |
|
921 | + if (empty($sql_text)) { |
|
922 | + throw new \Drone\Exception\Exception("Empty statement"); |
|
923 | + } |
|
910 | 924 | |
911 | 925 | $pos = strpos($sql_text, ';'); |
912 | 926 | |
@@ -914,8 +928,9 @@ discard block |
||
914 | 928 | { |
915 | 929 | $end_stament = strstr($sql_text, ';'); |
916 | 930 | |
917 | - if ($end_stament == ';') |
|
918 | - $sql_text = strstr($sql_text, ';', true); |
|
931 | + if ($end_stament == ';') { |
|
932 | + $sql_text = strstr($sql_text, ';', true); |
|
933 | + } |
|
919 | 934 | } |
920 | 935 | |
921 | 936 | # clean comments and other characters |
@@ -936,8 +951,9 @@ discard block |
||
936 | 951 | $isShowStm = $data["showStm"] = (preg_match('/^SHOW/i', $clean_code)); |
937 | 952 | |
938 | 953 | # detect selection |
939 | - if (!$isSelectStm && !$isShowStm) |
|
940 | - throw new \Exception("You can't export a non-selection statement!"); |
|
954 | + if (!$isSelectStm && !$isShowStm) { |
|
955 | + throw new \Exception("You can't export a non-selection statement!"); |
|
956 | + } |
|
941 | 957 | |
942 | 958 | try { |
943 | 959 | |
@@ -983,8 +999,7 @@ discard block |
||
983 | 999 | |
984 | 1000 | # redirect view |
985 | 1001 | $this->setMethod('error'); |
986 | - } |
|
987 | - catch (\Exception $e) |
|
1002 | + } catch (\Exception $e) |
|
988 | 1003 | { |
989 | 1004 | # SUCCESS-MESSAGE |
990 | 1005 | $data["process"] = "error"; |
@@ -1055,8 +1070,9 @@ discard block |
||
1055 | 1070 | |
1056 | 1071 | foreach ($rows[0] as $column_name => $row) |
1057 | 1072 | { |
1058 | - if (!is_numeric($column_name)) |
|
1059 | - $column_names[] = $column_name; |
|
1073 | + if (!is_numeric($column_name)) { |
|
1074 | + $column_names[] = $column_name; |
|
1075 | + } |
|
1060 | 1076 | } |
1061 | 1077 | |
1062 | 1078 | $table .= "\t<thead>\r\n\t\t<tr>\r\n"; |
@@ -1075,8 +1091,9 @@ discard block |
||
1075 | 1091 | |
1076 | 1092 | foreach ($row as $column => $value) |
1077 | 1093 | { |
1078 | - if ($isShowStm) |
|
1079 | - $column++; |
|
1094 | + if ($isShowStm) { |
|
1095 | + $column++; |
|
1096 | + } |
|
1080 | 1097 | |
1081 | 1098 | if (gettype($value) == 'object') |
1082 | 1099 | { |
@@ -1089,11 +1106,10 @@ discard block |
||
1089 | 1106 | } |
1090 | 1107 | |
1091 | 1108 | $data["data"][$key][$column] = $val; |
1109 | + } else { |
|
1110 | + $data["data"][$key][$column] = $value; |
|
1092 | 1111 | } |
1093 | - else |
|
1094 | - $data["data"][$key][$column] = $value; |
|
1095 | - } |
|
1096 | - else { |
|
1112 | + } else { |
|
1097 | 1113 | $data["data"][$key][$column] = $value; |
1098 | 1114 | } |
1099 | 1115 | } |
@@ -1125,8 +1141,9 @@ discard block |
||
1125 | 1141 | |
1126 | 1142 | foreach ($rows[0] as $column_name => $row) |
1127 | 1143 | { |
1128 | - if (!is_numeric($column_name)) |
|
1129 | - $column_names[] = $column_name; |
|
1144 | + if (!is_numeric($column_name)) { |
|
1145 | + $column_names[] = $column_name; |
|
1146 | + } |
|
1130 | 1147 | } |
1131 | 1148 | |
1132 | 1149 | foreach ($column_names as $column_name) |
@@ -1143,8 +1160,9 @@ discard block |
||
1143 | 1160 | |
1144 | 1161 | foreach ($row as $column => $value) |
1145 | 1162 | { |
1146 | - if ($isShowStm) |
|
1147 | - $column++; |
|
1163 | + if ($isShowStm) { |
|
1164 | + $column++; |
|
1165 | + } |
|
1148 | 1166 | |
1149 | 1167 | if (gettype($value) == 'object') |
1150 | 1168 | { |
@@ -1157,11 +1175,10 @@ discard block |
||
1157 | 1175 | } |
1158 | 1176 | |
1159 | 1177 | $data["data"][$key][$column] = $val; |
1178 | + } else { |
|
1179 | + $data["data"][$key][$column] = $value; |
|
1160 | 1180 | } |
1161 | - else |
|
1162 | - $data["data"][$key][$column] = $value; |
|
1163 | - } |
|
1164 | - else { |
|
1181 | + } else { |
|
1165 | 1182 | $data["data"][$key][$column] = $value; |
1166 | 1183 | } |
1167 | 1184 | } |
@@ -1198,20 +1215,19 @@ discard block |
||
1198 | 1215 | |
1199 | 1216 | $data["filename"] = $filename; |
1200 | 1217 | |
1201 | - if (array_key_exists('id', $post)) |
|
1202 | - $data["id"] = $post["id"]; |
|
1218 | + if (array_key_exists('id', $post)) { |
|
1219 | + $data["id"] = $post["id"]; |
|
1220 | + } |
|
1203 | 1221 | |
1204 | 1222 | # SUCCESS-MESSAGE |
1205 | 1223 | $data["process"] = "success"; |
1206 | 1224 | } |
1207 | - } |
|
1208 | - catch (\Drone\Exception\Exception $e) |
|
1225 | + } catch (\Drone\Exception\Exception $e) |
|
1209 | 1226 | { |
1210 | 1227 | # ERROR-MESSAGE |
1211 | 1228 | $data["process"] = "warning"; |
1212 | 1229 | $data["message"] = $e->getMessage(); |
1213 | - } |
|
1214 | - catch (\Exception $e) |
|
1230 | + } catch (\Exception $e) |
|
1215 | 1231 | { |
1216 | 1232 | $file = str_replace('\\', '', __CLASS__); |
1217 | 1233 | $storage = new \Drone\Exception\Storage("cache/$file.json"); |
@@ -1226,8 +1242,9 @@ discard block |
||
1226 | 1242 | } |
1227 | 1243 | |
1228 | 1244 | # errors retrived by the use of ErrorTrait |
1229 | - if (count($this->getErrors())) |
|
1230 | - $this->handleErrors($this->getErrors(), __METHOD__); |
|
1245 | + if (count($this->getErrors())) { |
|
1246 | + $this->handleErrors($this->getErrors(), __METHOD__); |
|
1247 | + } |
|
1231 | 1248 | |
1232 | 1249 | $data["code"] = $errorCode; |
1233 | 1250 | $data["message"] = $e->getMessage(); |
@@ -1263,15 +1280,16 @@ discard block |
||
1263 | 1280 | if (!$hd || !@fwrite($hd, $errorInformation)) |
1264 | 1281 | { |
1265 | 1282 | # error storing are not mandatory! |
1283 | + } else { |
|
1284 | + @fclose($hd); |
|
1266 | 1285 | } |
1267 | - else |
|
1268 | - @fclose($hd); |
|
1269 | 1286 | |
1270 | 1287 | $config = include 'config/application.config.php'; |
1271 | 1288 | $dev = $config["environment"]["dev_mode"]; |
1272 | 1289 | |
1273 | - if ($dev) |
|
1274 | - echo $errorInformation; |
|
1290 | + if ($dev) { |
|
1291 | + echo $errorInformation; |
|
1292 | + } |
|
1275 | 1293 | } |
1276 | 1294 | } |
1277 | 1295 | } |
1278 | 1296 | \ No newline at end of file |