@@ -169,12 +169,12 @@ discard block |
||
169 | 169 | * @return mixed|string |
170 | 170 | */ |
171 | 171 | private function friendly_error_type($type) { |
172 | - static $levels=null; |
|
173 | - if ($levels===null) { |
|
174 | - $levels=[]; |
|
172 | + static $levels = null; |
|
173 | + if ($levels === null) { |
|
174 | + $levels = []; |
|
175 | 175 | foreach (get_defined_constants() as $key=>$value) { |
176 | - if (strpos($key,'E_')!==0) {continue;} |
|
177 | - $levels[$value]= $key; //substr($key,2); |
|
176 | + if (strpos($key, 'E_') !== 0) {continue; } |
|
177 | + $levels[$value] = $key; //substr($key,2); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | return (isset($levels[$type]) ? $levels[$type] : "Error #{$type}"); |
@@ -224,43 +224,43 @@ discard block |
||
224 | 224 | */ |
225 | 225 | public function write_file_action() |
226 | 226 | { |
227 | - if(isset($_POST['file'])) |
|
227 | + if (isset($_POST['file'])) |
|
228 | 228 | { |
229 | 229 | $target_file = filter_input(INPUT_POST, 'file', FILTER_SANITIZE_STRING); |
230 | 230 | |
231 | - if(!$_POST['start']) |
|
231 | + if (!$_POST['start']) |
|
232 | 232 | $fp = fopen($target_file, "wb+"); |
233 | 233 | else |
234 | 234 | $fp = fopen($target_file, "ab+"); |
235 | 235 | |
236 | - if(!$fp) |
|
236 | + if (!$fp) |
|
237 | 237 | throw new Exception("Unable to open $target_file file for writing"); |
238 | 238 | |
239 | 239 | fseek($fp, $_POST['start']); |
240 | 240 | |
241 | - if(isset($_FILES['blob'])) |
|
241 | + if (isset($_FILES['blob'])) |
|
242 | 242 | { |
243 | 243 | $this->logger->debug(sprintf('Writing %s bytes to file %s starting position %s using FILES blob', filesize($_FILES['blob']['tmp_name']), $target_file, $_POST['start'])); |
244 | 244 | |
245 | 245 | $blob = file_get_contents($_FILES['blob']['tmp_name']); |
246 | 246 | |
247 | - if(!$bytes_written = fwrite($fp, $blob)) |
|
247 | + if (!$bytes_written = fwrite($fp, $blob)) |
|
248 | 248 | throw new Exception("Unable to write data to file $target_file"); |
249 | 249 | |
250 | 250 | try { |
251 | 251 | unlink($_FILES['blob']['tmp_name']); |
252 | - }catch(Exception $e){ |
|
252 | + }catch (Exception $e) { |
|
253 | 253 | |
254 | 254 | } |
255 | 255 | |
256 | - }elseif(isset($_POST['blob'])){ |
|
256 | + }elseif (isset($_POST['blob'])) { |
|
257 | 257 | $this->logger->debug(sprintf('Writing %s bytes to file %s starting position %s using POST blob', strlen($_POST['blob']), $target_file, $_POST['start'])); |
258 | 258 | |
259 | 259 | $blob = $_POST['blob']; |
260 | 260 | |
261 | - if(!$bytes_written = fwrite($fp, $blob)) |
|
261 | + if (!$bytes_written = fwrite($fp, $blob)) |
|
262 | 262 | throw new Exception("Unable to write data to file $target_file"); |
263 | - }else{ |
|
263 | + } else { |
|
264 | 264 | throw new Exception("Upload failed, did not receive any binary data"); |
265 | 265 | } |
266 | 266 | |
@@ -281,20 +281,20 @@ discard block |
||
281 | 281 | * @return mysqli |
282 | 282 | * @throws Exception |
283 | 283 | */ |
284 | - public function mysql_connect($remote_mysql_host, $remote_mysql_user, $remote_mysql_pass, $remote_mysql_db ) |
|
284 | + public function mysql_connect($remote_mysql_host, $remote_mysql_user, $remote_mysql_pass, $remote_mysql_db) |
|
285 | 285 | { |
286 | 286 | $this->logger->info(sprintf('Connecting to mysql database %s with %s@%s', $remote_mysql_db, $remote_mysql_user, $remote_mysql_host)); |
287 | 287 | |
288 | 288 | $mysqli = new mysqli($remote_mysql_host, $remote_mysql_user, $remote_mysql_pass, $remote_mysql_db); |
289 | 289 | |
290 | 290 | if ($mysqli->connect_error) { |
291 | - throw new Exception('Connect Error (' . $mysqli->connect_errno . ') ' |
|
291 | + throw new Exception('Connect Error ('.$mysqli->connect_errno.') ' |
|
292 | 292 | . $mysqli->connect_error); |
293 | 293 | } |
294 | 294 | |
295 | 295 | $mysqli->query("SET sql_mode='';"); |
296 | 296 | $mysqli->query("SET foreign_key_checks = 0;"); |
297 | - if(isset($_REQUEST['charset_of_file']) and $_REQUEST['charset_of_file']) |
|
297 | + if (isset($_REQUEST['charset_of_file']) and $_REQUEST['charset_of_file']) |
|
298 | 298 | $mysqli->query("SET NAMES ".$_REQUEST['charset_of_file'].""); |
299 | 299 | else |
300 | 300 | $mysqli->query("SET NAMES utf8;"); |
@@ -1015,8 +1015,8 @@ discard block |
||
1015 | 1015 | */ |
1016 | 1016 | private function return_bytes($val) { |
1017 | 1017 | $numeric_val = (int)trim($val); |
1018 | - $last = strtolower($val[strlen($val)-1]); |
|
1019 | - switch($last) { |
|
1018 | + $last = strtolower($val[strlen($val) - 1]); |
|
1019 | + switch ($last) { |
|
1020 | 1020 | // The 'G' modifier is available since PHP 5.1.0 |
1021 | 1021 | case 'g': |
1022 | 1022 | $numeric_val *= 1024; |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | * @param string $direction |
1098 | 1098 | * @return bool |
1099 | 1099 | */ |
1100 | - private function sort_by( &$array, $field, $direction = 'asc') |
|
1100 | + private function sort_by(&$array, $field, $direction = 'asc') |
|
1101 | 1101 | { |
1102 | 1102 | $direction = strtolower($direction); |
1103 | 1103 | |
@@ -1112,18 +1112,18 @@ discard block |
||
1112 | 1112 | return 0; |
1113 | 1113 | } |
1114 | 1114 | |
1115 | - if($direction == 'desc') { |
|
1116 | - if($a > $b) { |
|
1115 | + if ($direction == 'desc') { |
|
1116 | + if ($a > $b) { |
|
1117 | 1117 | return -1; |
1118 | 1118 | } |
1119 | - else{ |
|
1119 | + else { |
|
1120 | 1120 | return 1; |
1121 | 1121 | } |
1122 | - }else { |
|
1123 | - if($a < $b) { |
|
1122 | + } else { |
|
1123 | + if ($a < $b) { |
|
1124 | 1124 | return -1; |
1125 | 1125 | } |
1126 | - else{ |
|
1126 | + else { |
|
1127 | 1127 | return 1; |
1128 | 1128 | } |
1129 | 1129 | } |
@@ -1217,14 +1217,14 @@ discard block |
||
1217 | 1217 | */ |
1218 | 1218 | private function has_serialized($s) |
1219 | 1219 | { |
1220 | - if( |
|
1221 | - stristr($s, '{' ) !== false && |
|
1222 | - stristr($s, '}' ) !== false && |
|
1223 | - stristr($s, ';' ) !== false && |
|
1224 | - stristr($s, ':' ) !== false |
|
1225 | - ){ |
|
1220 | + if ( |
|
1221 | + stristr($s, '{') !== false && |
|
1222 | + stristr($s, '}') !== false && |
|
1223 | + stristr($s, ';') !== false && |
|
1224 | + stristr($s, ':') !== false |
|
1225 | + ) { |
|
1226 | 1226 | return true; |
1227 | - }else{ |
|
1227 | + } else { |
|
1228 | 1228 | return false; |
1229 | 1229 | } |
1230 | 1230 |