@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | * @param Object $queryObject |
| 442 | 442 | * @param resource $connection |
| 443 | 443 | * @param boolean $with_values |
| 444 | - * @return Object |
|
| 444 | + * @return Object|null |
|
| 445 | 445 | */ |
| 446 | 446 | function _executeSelectAct($queryObject, $connection = null, $with_values = false) |
| 447 | 447 | { |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | * opt : notnull, default, size\n |
| 495 | 495 | * index : primary key, index, unique\n |
| 496 | 496 | * @param string $xml_doc xml schema contents |
| 497 | - * @return void|object |
|
| 497 | + * @return null|false |
|
| 498 | 498 | */ |
| 499 | 499 | function _createTable($xml_doc) |
| 500 | 500 | { |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | function __connect($connection) |
| 45 | 45 | { |
| 46 | 46 | // Attempt to connect |
| 47 | - if($connection["db_port"]) |
|
| 47 | + if ($connection["db_port"]) |
|
| 48 | 48 | { |
| 49 | 49 | $result = @mysqli_connect($connection["db_hostname"] |
| 50 | 50 | , $connection["db_userid"] |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | , $connection["db_database"]); |
| 61 | 61 | } |
| 62 | 62 | $error = mysqli_connect_errno(); |
| 63 | - if($error) |
|
| 63 | + if ($error) |
|
| 64 | 64 | { |
| 65 | 65 | $this->setError($error, mysqli_connect_error()); |
| 66 | 66 | return; |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | { |
| 90 | 90 | $connection = $this->_getConnection('master'); |
| 91 | 91 | |
| 92 | - if(!$transactionLevel) |
|
| 92 | + if (!$transactionLevel) |
|
| 93 | 93 | { |
| 94 | 94 | $this->_query("begin"); |
| 95 | 95 | } |
@@ -111,14 +111,14 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | $point = $transactionLevel - 1; |
| 113 | 113 | |
| 114 | - if($point) |
|
| 114 | + if ($point) |
|
| 115 | 115 | { |
| 116 | 116 | $this->_query("ROLLBACK TO SP" . $point, $connection); |
| 117 | 117 | } |
| 118 | 118 | else |
| 119 | 119 | { |
| 120 | 120 | mysqli_rollback($connection); |
| 121 | - $this->setQueryLog( array("query"=>"rollback") ); |
|
| 121 | + $this->setQueryLog(array("query"=>"rollback")); |
|
| 122 | 122 | } |
| 123 | 123 | return true; |
| 124 | 124 | } |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | { |
| 133 | 133 | $connection = $this->_getConnection('master'); |
| 134 | 134 | mysqli_commit($connection); |
| 135 | - $this->setQueryLog( array("query"=>"commit") ); |
|
| 135 | + $this->setQueryLog(array("query"=>"commit")); |
|
| 136 | 136 | return true; |
| 137 | 137 | } |
| 138 | 138 | |
@@ -145,11 +145,11 @@ discard block |
||
| 145 | 145 | */ |
| 146 | 146 | function addQuotes($string) |
| 147 | 147 | { |
| 148 | - if(version_compare(PHP_VERSION, "5.4.0", "<") && get_magic_quotes_gpc()) |
|
| 148 | + if (version_compare(PHP_VERSION, "5.4.0", "<") && get_magic_quotes_gpc()) |
|
| 149 | 149 | { |
| 150 | 150 | $string = stripslashes(str_replace("\\", "\\\\", $string)); |
| 151 | 151 | } |
| 152 | - if(!is_numeric($string)) |
|
| 152 | + if (!is_numeric($string)) |
|
| 153 | 153 | { |
| 154 | 154 | $connection = $this->_getConnection('master'); |
| 155 | 155 | $string = mysqli_escape_string($connection, $string); |
@@ -166,23 +166,23 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | function __query($query, $connection) |
| 168 | 168 | { |
| 169 | - if($this->use_prepared_statements == 'Y') |
|
| 169 | + if ($this->use_prepared_statements == 'Y') |
|
| 170 | 170 | { |
| 171 | 171 | // 1. Prepare query |
| 172 | 172 | $stmt = mysqli_prepare($connection, $query); |
| 173 | - if($stmt) |
|
| 173 | + if ($stmt) |
|
| 174 | 174 | { |
| 175 | 175 | $types = ''; |
| 176 | 176 | $params = array(); |
| 177 | 177 | $this->_prepareQueryParameters($types, $params); |
| 178 | 178 | |
| 179 | - if(!empty($params)) |
|
| 179 | + if (!empty($params)) |
|
| 180 | 180 | { |
| 181 | 181 | $args[0] = $stmt; |
| 182 | 182 | $args[1] = $types; |
| 183 | 183 | |
| 184 | 184 | $i = 2; |
| 185 | - foreach($params as $key => $param) |
|
| 185 | + foreach ($params as $key => $param) |
|
| 186 | 186 | { |
| 187 | 187 | $copy[$key] = $param; |
| 188 | 188 | $args[$i++] = &$copy[$key]; |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | |
| 191 | 191 | // 2. Bind parameters |
| 192 | 192 | $status = call_user_func_array('mysqli_stmt_bind_param', $args); |
| 193 | - if(!$status) |
|
| 193 | + if (!$status) |
|
| 194 | 194 | { |
| 195 | 195 | $this->setError(-1, "Invalid arguments: $query" . mysqli_error($connection) . PHP_EOL . print_r($args, true)); |
| 196 | 196 | } |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | // 3. Execute query |
| 200 | 200 | $status = mysqli_stmt_execute($stmt); |
| 201 | 201 | |
| 202 | - if(!$status) |
|
| 202 | + if (!$status) |
|
| 203 | 203 | { |
| 204 | 204 | $this->setError(-1, "Prepared statement failed: $query" . mysqli_error($connection) . PHP_EOL . print_r($args, true)); |
| 205 | 205 | } |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | $result = mysqli_query($connection, $query); |
| 214 | 214 | // Error Check |
| 215 | 215 | $error = mysqli_error($connection); |
| 216 | - if($error) |
|
| 216 | + if ($error) |
|
| 217 | 217 | { |
| 218 | 218 | $this->setError(mysqli_errno($connection), $error); |
| 219 | 219 | } |
@@ -232,23 +232,23 @@ discard block |
||
| 232 | 232 | { |
| 233 | 233 | $types = ''; |
| 234 | 234 | $params = array(); |
| 235 | - if(!$this->param) |
|
| 235 | + if (!$this->param) |
|
| 236 | 236 | { |
| 237 | 237 | return; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - foreach($this->param as $k => $o) |
|
| 240 | + foreach ($this->param as $k => $o) |
|
| 241 | 241 | { |
| 242 | 242 | $value = $o->getUnescapedValue(); |
| 243 | 243 | $type = $o->getType(); |
| 244 | 244 | |
| 245 | 245 | // Skip column names -> this should be concatenated to query string |
| 246 | - if($o->isColumnName()) |
|
| 246 | + if ($o->isColumnName()) |
|
| 247 | 247 | { |
| 248 | 248 | continue; |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - switch($type) |
|
| 251 | + switch ($type) |
|
| 252 | 252 | { |
| 253 | 253 | case 'number' : |
| 254 | 254 | $type = 'i'; |
@@ -260,9 +260,9 @@ discard block |
||
| 260 | 260 | $type = 's'; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - if(is_array($value)) |
|
| 263 | + if (is_array($value)) |
|
| 264 | 264 | { |
| 265 | - foreach($value as $v) |
|
| 265 | + foreach ($value as $v) |
|
| 266 | 266 | { |
| 267 | 267 | $params[] = $v; |
| 268 | 268 | $types .= $type; |
@@ -284,12 +284,12 @@ discard block |
||
| 284 | 284 | */ |
| 285 | 285 | function _fetch($result, $arrayIndexEndValue = NULL) |
| 286 | 286 | { |
| 287 | - if($this->use_prepared_statements != 'Y') |
|
| 287 | + if ($this->use_prepared_statements != 'Y') |
|
| 288 | 288 | { |
| 289 | 289 | return parent::_fetch($result, $arrayIndexEndValue); |
| 290 | 290 | } |
| 291 | 291 | $output = array(); |
| 292 | - if(!$this->isConnected() || $this->isError() || !$result) |
|
| 292 | + if (!$this->isConnected() || $this->isError() || !$result) |
|
| 293 | 293 | { |
| 294 | 294 | return $output; |
| 295 | 295 | } |
@@ -305,9 +305,9 @@ discard block |
||
| 305 | 305 | * MYSQLI_TYPE for longtext is 252 |
| 306 | 306 | */ |
| 307 | 307 | $longtext_exists = false; |
| 308 | - foreach($fields as $field) |
|
| 308 | + foreach ($fields as $field) |
|
| 309 | 309 | { |
| 310 | - if(isset($resultArray[$field->name])) // When joined tables are used and the same column name appears twice, we should add it separately, otherwise bind_result fails |
|
| 310 | + if (isset($resultArray[$field->name])) // When joined tables are used and the same column name appears twice, we should add it separately, otherwise bind_result fails |
|
| 311 | 311 | { |
| 312 | 312 | $field->name = 'repeat_' . $field->name; |
| 313 | 313 | } |
@@ -316,14 +316,14 @@ discard block |
||
| 316 | 316 | $row[$field->name] = ""; |
| 317 | 317 | $resultArray[$field->name] = &$row[$field->name]; |
| 318 | 318 | |
| 319 | - if($field->type == 252) |
|
| 319 | + if ($field->type == 252) |
|
| 320 | 320 | { |
| 321 | 321 | $longtext_exists = true; |
| 322 | 322 | } |
| 323 | 323 | } |
| 324 | 324 | $resultArray = array_merge(array($stmt), $resultArray); |
| 325 | 325 | |
| 326 | - if($longtext_exists) |
|
| 326 | + if ($longtext_exists) |
|
| 327 | 327 | { |
| 328 | 328 | mysqli_stmt_store_result($stmt); |
| 329 | 329 | } |
@@ -331,17 +331,17 @@ discard block |
||
| 331 | 331 | call_user_func_array('mysqli_stmt_bind_result', $resultArray); |
| 332 | 332 | |
| 333 | 333 | $rows = array(); |
| 334 | - while(mysqli_stmt_fetch($stmt)) |
|
| 334 | + while (mysqli_stmt_fetch($stmt)) |
|
| 335 | 335 | { |
| 336 | 336 | $resultObject = new stdClass(); |
| 337 | 337 | |
| 338 | - foreach($resultArray as $key => $value) |
|
| 338 | + foreach ($resultArray as $key => $value) |
|
| 339 | 339 | { |
| 340 | - if($key === 0) |
|
| 340 | + if ($key === 0) |
|
| 341 | 341 | { |
| 342 | 342 | continue; // Skip stmt object |
| 343 | 343 | } |
| 344 | - if(strpos($key, 'repeat_')) |
|
| 344 | + if (strpos($key, 'repeat_')) |
|
| 345 | 345 | { |
| 346 | 346 | $key = substr($key, 6); |
| 347 | 347 | } |
@@ -353,9 +353,9 @@ discard block |
||
| 353 | 353 | |
| 354 | 354 | mysqli_stmt_close($stmt); |
| 355 | 355 | |
| 356 | - if($arrayIndexEndValue) |
|
| 356 | + if ($arrayIndexEndValue) |
|
| 357 | 357 | { |
| 358 | - foreach($rows as $row) |
|
| 358 | + foreach ($rows as $row) |
|
| 359 | 359 | { |
| 360 | 360 | $output[$arrayIndexEndValue--] = $row; |
| 361 | 361 | } |
@@ -365,9 +365,9 @@ discard block |
||
| 365 | 365 | $output = $rows; |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | - if(count($output) == 1) |
|
| 368 | + if (count($output) == 1) |
|
| 369 | 369 | { |
| 370 | - if(isset($arrayIndexEndValue)) |
|
| 370 | + if (isset($arrayIndexEndValue)) |
|
| 371 | 371 | { |
| 372 | 372 | return $output; |
| 373 | 373 | } |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | */ |
| 389 | 389 | function _executeInsertAct($queryObject, $with_values = false) |
| 390 | 390 | { |
| 391 | - if($this->use_prepared_statements != 'Y') |
|
| 391 | + if ($this->use_prepared_statements != 'Y') |
|
| 392 | 392 | { |
| 393 | 393 | return parent::_executeInsertAct($queryObject); |
| 394 | 394 | } |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | */ |
| 407 | 407 | function _executeUpdateAct($queryObject, $with_values = false) |
| 408 | 408 | { |
| 409 | - if($this->use_prepared_statements != 'Y') |
|
| 409 | + if ($this->use_prepared_statements != 'Y') |
|
| 410 | 410 | { |
| 411 | 411 | return parent::_executeUpdateAct($queryObject); |
| 412 | 412 | } |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | */ |
| 425 | 425 | function _executeDeleteAct($queryObject, $with_values = false) |
| 426 | 426 | { |
| 427 | - if($this->use_prepared_statements != 'Y') |
|
| 427 | + if ($this->use_prepared_statements != 'Y') |
|
| 428 | 428 | { |
| 429 | 429 | return parent::_executeDeleteAct($queryObject); |
| 430 | 430 | } |
@@ -445,7 +445,7 @@ discard block |
||
| 445 | 445 | */ |
| 446 | 446 | function _executeSelectAct($queryObject, $connection = null, $with_values = false) |
| 447 | 447 | { |
| 448 | - if($this->use_prepared_statements != 'Y') |
|
| 448 | + if ($this->use_prepared_statements != 'Y') |
|
| 449 | 449 | { |
| 450 | 450 | return parent::_executeSelectAct($queryObject, $connection); |
| 451 | 451 | } |
@@ -503,13 +503,13 @@ discard block |
||
| 503 | 503 | $xml_obj = $oXml->parse($xml_doc); |
| 504 | 504 | // Create a table schema |
| 505 | 505 | $table_name = $xml_obj->table->attrs->name; |
| 506 | - if($this->isTableExists($table_name)) |
|
| 506 | + if ($this->isTableExists($table_name)) |
|
| 507 | 507 | { |
| 508 | 508 | return; |
| 509 | 509 | } |
| 510 | 510 | $table_name = $this->prefix . $table_name; |
| 511 | 511 | |
| 512 | - if(!is_array($xml_obj->table->column)) |
|
| 512 | + if (!is_array($xml_obj->table->column)) |
|
| 513 | 513 | { |
| 514 | 514 | $columns[] = $xml_obj->table->column; |
| 515 | 515 | } |
@@ -518,7 +518,7 @@ discard block |
||
| 518 | 518 | $columns = $xml_obj->table->column; |
| 519 | 519 | } |
| 520 | 520 | |
| 521 | - foreach($columns as $column) |
|
| 521 | + foreach ($columns as $column) |
|
| 522 | 522 | { |
| 523 | 523 | $name = $column->attrs->name; |
| 524 | 524 | $type = $column->attrs->type; |
@@ -532,36 +532,36 @@ discard block |
||
| 532 | 532 | |
| 533 | 533 | $column_schema[] = sprintf('`%s` %s%s %s %s %s', $name, $this->column_type[$type], $size ? '(' . $size . ')' : '', isset($default) ? "default '" . $default . "'" : '', $notnull ? 'not null' : '', $auto_increment ? 'auto_increment' : ''); |
| 534 | 534 | |
| 535 | - if($primary_key) |
|
| 535 | + if ($primary_key) |
|
| 536 | 536 | { |
| 537 | 537 | $primary_list[] = $name; |
| 538 | 538 | } |
| 539 | - else if($unique) |
|
| 539 | + else if ($unique) |
|
| 540 | 540 | { |
| 541 | 541 | $unique_list[$unique][] = $name; |
| 542 | 542 | } |
| 543 | - else if($index) |
|
| 543 | + else if ($index) |
|
| 544 | 544 | { |
| 545 | 545 | $index_list[$index][] = $name; |
| 546 | 546 | } |
| 547 | 547 | } |
| 548 | 548 | |
| 549 | - if(count($primary_list)) |
|
| 549 | + if (count($primary_list)) |
|
| 550 | 550 | { |
| 551 | 551 | $column_schema[] = sprintf("primary key (%s)", '`' . implode($primary_list, '`,`') . '`'); |
| 552 | 552 | } |
| 553 | 553 | |
| 554 | - if(count($unique_list)) |
|
| 554 | + if (count($unique_list)) |
|
| 555 | 555 | { |
| 556 | - foreach($unique_list as $key => $val) |
|
| 556 | + foreach ($unique_list as $key => $val) |
|
| 557 | 557 | { |
| 558 | 558 | $column_schema[] = sprintf("unique %s (%s)", $key, '`' . implode($val, '`,`') . '`'); |
| 559 | 559 | } |
| 560 | 560 | } |
| 561 | 561 | |
| 562 | - if(count($index_list)) |
|
| 562 | + if (count($index_list)) |
|
| 563 | 563 | { |
| 564 | - foreach($index_list as $key => $val) |
|
| 564 | + foreach ($index_list as $key => $val) |
|
| 565 | 565 | { |
| 566 | 566 | $column_schema[] = sprintf("index %s (%s)", $key, '`' . implode($val, '`,`') . '`'); |
| 567 | 567 | } |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | $schema = sprintf('create table `%s` (%s%s) %s;', $this->addQuotes($table_name), "\n", implode($column_schema, ",\n"), "ENGINE = INNODB CHARACTER SET utf8 COLLATE utf8_general_ci"); |
| 571 | 571 | |
| 572 | 572 | $output = $this->_query($schema); |
| 573 | - if(!$output) |
|
| 573 | + if (!$output) |
|
| 574 | 574 | { |
| 575 | 575 | return false; |
| 576 | 576 | } |
@@ -51,8 +51,7 @@ discard block |
||
| 51 | 51 | , $connection["db_password"] |
| 52 | 52 | , $connection["db_database"] |
| 53 | 53 | , $connection["db_port"]); |
| 54 | - } |
|
| 55 | - else |
|
| 54 | + } else |
|
| 56 | 55 | { |
| 57 | 56 | $result = @mysqli_connect($connection["db_hostname"] |
| 58 | 57 | , $connection["db_userid"] |
@@ -92,8 +91,7 @@ discard block |
||
| 92 | 91 | if(!$transactionLevel) |
| 93 | 92 | { |
| 94 | 93 | $this->_query("begin"); |
| 95 | - } |
|
| 96 | - else |
|
| 94 | + } else |
|
| 97 | 95 | { |
| 98 | 96 | $this->_query("SAVEPOINT SP" . $transactionLevel, $connection); |
| 99 | 97 | } |
@@ -114,8 +112,7 @@ discard block |
||
| 114 | 112 | if($point) |
| 115 | 113 | { |
| 116 | 114 | $this->_query("ROLLBACK TO SP" . $point, $connection); |
| 117 | - } |
|
| 118 | - else |
|
| 115 | + } else |
|
| 119 | 116 | { |
| 120 | 117 | mysqli_rollback($connection); |
| 121 | 118 | $this->setQueryLog( array("query"=>"rollback") ); |
@@ -267,8 +264,7 @@ discard block |
||
| 267 | 264 | $params[] = $v; |
| 268 | 265 | $types .= $type; |
| 269 | 266 | } |
| 270 | - } |
|
| 271 | - else |
|
| 267 | + } else |
|
| 272 | 268 | { |
| 273 | 269 | $params[] = $value; |
| 274 | 270 | $types .= $type; |
@@ -307,10 +303,12 @@ discard block |
||
| 307 | 303 | $longtext_exists = false; |
| 308 | 304 | foreach($fields as $field) |
| 309 | 305 | { |
| 310 | - if(isset($resultArray[$field->name])) // When joined tables are used and the same column name appears twice, we should add it separately, otherwise bind_result fails |
|
| 306 | + if(isset($resultArray[$field->name])) { |
|
| 307 | + // When joined tables are used and the same column name appears twice, we should add it separately, otherwise bind_result fails |
|
| 311 | 308 | { |
| 312 | 309 | $field->name = 'repeat_' . $field->name; |
| 313 | 310 | } |
| 311 | + } |
|
| 314 | 312 | |
| 315 | 313 | // Array passed needs to contain references, not values |
| 316 | 314 | $row[$field->name] = ""; |
@@ -359,8 +357,7 @@ discard block |
||
| 359 | 357 | { |
| 360 | 358 | $output[$arrayIndexEndValue--] = $row; |
| 361 | 359 | } |
| 362 | - } |
|
| 363 | - else |
|
| 360 | + } else |
|
| 364 | 361 | { |
| 365 | 362 | $output = $rows; |
| 366 | 363 | } |
@@ -370,8 +367,7 @@ discard block |
||
| 370 | 367 | if(isset($arrayIndexEndValue)) |
| 371 | 368 | { |
| 372 | 369 | return $output; |
| 373 | - } |
|
| 374 | - else |
|
| 370 | + } else |
|
| 375 | 371 | { |
| 376 | 372 | return $output[0]; |
| 377 | 373 | } |
@@ -512,8 +508,7 @@ discard block |
||
| 512 | 508 | if(!is_array($xml_obj->table->column)) |
| 513 | 509 | { |
| 514 | 510 | $columns[] = $xml_obj->table->column; |
| 515 | - } |
|
| 516 | - else |
|
| 511 | + } else |
|
| 517 | 512 | { |
| 518 | 513 | $columns = $xml_obj->table->column; |
| 519 | 514 | } |
@@ -535,12 +530,10 @@ discard block |
||
| 535 | 530 | if($primary_key) |
| 536 | 531 | { |
| 537 | 532 | $primary_list[] = $name; |
| 538 | - } |
|
| 539 | - else if($unique) |
|
| 533 | + } else if($unique) |
|
| 540 | 534 | { |
| 541 | 535 | $unique_list[$unique][] = $name; |
| 542 | - } |
|
| 543 | - else if($index) |
|
| 536 | + } else if($index) |
|
| 544 | 537 | { |
| 545 | 538 | $index_list[$index][] = $name; |
| 546 | 539 | } |
@@ -97,6 +97,9 @@ |
||
| 97 | 97 | return $this->pipe . ' ' . $this->getConditionPart($this->_value); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | + /** |
|
| 101 | + * @param string $pipe |
|
| 102 | + */ |
|
| 100 | 103 | function setPipe($pipe) |
| 101 | 104 | {
|
| 102 | 105 | $this->pipe = $pipe; |
@@ -61,13 +61,13 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | function toString($withValue = true) |
| 63 | 63 | {
|
| 64 | - if(!isset($this->_value_to_string)) |
|
| 64 | + if (!isset($this->_value_to_string)) |
|
| 65 | 65 | {
|
| 66 | - if(!$this->show()) |
|
| 66 | + if (!$this->show()) |
|
| 67 | 67 | {
|
| 68 | 68 | $this->_value_to_string = ''; |
| 69 | 69 | } |
| 70 | - else if($withValue) |
|
| 70 | + else if ($withValue) |
|
| 71 | 71 | {
|
| 72 | 72 | $this->_value_to_string = $this->toStringWithValue(); |
| 73 | 73 | } |
@@ -107,16 +107,16 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | function show() |
| 109 | 109 | {
|
| 110 | - if(!isset($this->_show)) |
|
| 110 | + if (!isset($this->_show)) |
|
| 111 | 111 | {
|
| 112 | - if(is_array($this->_value) && count($this->_value) === 1 && $this->_value[0] === '') |
|
| 112 | + if (is_array($this->_value) && count($this->_value) === 1 && $this->_value[0] === '') |
|
| 113 | 113 | {
|
| 114 | 114 | $this->_show = false; |
| 115 | 115 | } |
| 116 | 116 | else |
| 117 | 117 | {
|
| 118 | 118 | $this->_show = true; |
| 119 | - switch($this->operation) |
|
| 119 | + switch ($this->operation) |
|
| 120 | 120 | {
|
| 121 | 121 | case 'equal' : |
| 122 | 122 | case 'more' : |
@@ -138,30 +138,30 @@ discard block |
||
| 138 | 138 | case 'not': |
| 139 | 139 | case 'notequal' : |
| 140 | 140 | // if variable is not set or is not string or number, return |
| 141 | - if(!isset($this->_value)) |
|
| 141 | + if (!isset($this->_value)) |
|
| 142 | 142 | {
|
| 143 | 143 | $this->_show = false; |
| 144 | 144 | break; |
| 145 | 145 | } |
| 146 | - if($this->_value === '') |
|
| 146 | + if ($this->_value === '') |
|
| 147 | 147 | {
|
| 148 | 148 | $this->_show = false; |
| 149 | 149 | break; |
| 150 | 150 | } |
| 151 | 151 | $tmpArray = array('string' => 1, 'integer' => 1);
|
| 152 | - if(!isset($tmpArray[gettype($this->_value)])) |
|
| 152 | + if (!isset($tmpArray[gettype($this->_value)])) |
|
| 153 | 153 | {
|
| 154 | 154 | $this->_show = false; |
| 155 | 155 | break; |
| 156 | 156 | } |
| 157 | 157 | break; |
| 158 | 158 | case 'between' : |
| 159 | - if(!is_array($this->_value)) |
|
| 159 | + if (!is_array($this->_value)) |
|
| 160 | 160 | {
|
| 161 | 161 | $this->_show = false; |
| 162 | 162 | break; |
| 163 | 163 | } |
| 164 | - if(count($this->_value) != 2) |
|
| 164 | + if (count($this->_value) != 2) |
|
| 165 | 165 | {
|
| 166 | 166 | $this->_show = false; |
| 167 | 167 | break; |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | $name = $this->column_name; |
| 189 | 189 | $operation = $this->operation; |
| 190 | 190 | |
| 191 | - switch($operation) |
|
| 191 | + switch ($operation) |
|
| 192 | 192 | {
|
| 193 | 193 | case 'equal' : |
| 194 | 194 | return $name . ' = ' . $value; |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | case 'like_tail' : |
| 209 | 209 | case 'like_prefix' : |
| 210 | 210 | case 'like' : |
| 211 | - if(defined('__CUBRID_VERSION__')
|
|
| 211 | + if (defined('__CUBRID_VERSION__')
|
|
| 212 | 212 | && __CUBRID_VERSION__ >= '8.4.1') |
| 213 | 213 | return $name . ' rlike ' . $value; |
| 214 | 214 | else |
@@ -66,12 +66,10 @@ discard block |
||
| 66 | 66 | if(!$this->show()) |
| 67 | 67 | {
|
| 68 | 68 | $this->_value_to_string = ''; |
| 69 | - } |
|
| 70 | - else if($withValue) |
|
| 69 | + } else if($withValue) |
|
| 71 | 70 | {
|
| 72 | 71 | $this->_value_to_string = $this->toStringWithValue(); |
| 73 | - } |
|
| 74 | - else |
|
| 72 | + } else |
|
| 75 | 73 | {
|
| 76 | 74 | $this->_value_to_string = $this->toStringWithoutValue(); |
| 77 | 75 | } |
@@ -112,8 +110,7 @@ discard block |
||
| 112 | 110 | if(is_array($this->_value) && count($this->_value) === 1 && $this->_value[0] === '') |
| 113 | 111 | {
|
| 114 | 112 | $this->_show = false; |
| 115 | - } |
|
| 116 | - else |
|
| 113 | + } else |
|
| 117 | 114 | {
|
| 118 | 115 | $this->_show = true; |
| 119 | 116 | switch($this->operation) |
@@ -209,10 +206,11 @@ discard block |
||
| 209 | 206 | case 'like_prefix' : |
| 210 | 207 | case 'like' : |
| 211 | 208 | if(defined('__CUBRID_VERSION__')
|
| 212 | - && __CUBRID_VERSION__ >= '8.4.1') |
|
| 213 | - return $name . ' rlike ' . $value; |
|
| 214 | - else |
|
| 215 | - return $name . ' like ' . $value; |
|
| 209 | + && __CUBRID_VERSION__ >= '8.4.1') { |
|
| 210 | + return $name . ' rlike ' . $value; |
|
| 211 | + } else { |
|
| 212 | + return $name . ' like ' . $value; |
|
| 213 | + } |
|
| 216 | 214 | break; |
| 217 | 215 | case 'notlike_tail' : |
| 218 | 216 | case 'notlike_prefix' : |
@@ -12,10 +12,10 @@ |
||
| 12 | 12 | /** |
| 13 | 13 | * constructor |
| 14 | 14 | * @param string $column_name |
| 15 | - * @param mixed $argument |
|
| 15 | + * @param integer $argument |
|
| 16 | 16 | * @param string $operation |
| 17 | 17 | * @param string $pipe |
| 18 | - * @return void |
|
| 18 | + * @return boolean |
|
| 19 | 19 | */ |
| 20 | 20 | function ConditionWithoutArgument($column_name, $argument, $operation, $pipe = "") |
| 21 | 21 | {
|
@@ -21,9 +21,9 @@ |
||
| 21 | 21 | {
|
| 22 | 22 | parent::Condition($column_name, $argument, $operation, $pipe); |
| 23 | 23 | $tmpArray = array('in' => 1, 'notin' => 1, 'not_in' => 1);
|
| 24 | - if(isset($tmpArray[$operation])) |
|
| 24 | + if (isset($tmpArray[$operation])) |
|
| 25 | 25 | {
|
| 26 | - if(is_array($argument)) |
|
| 26 | + if (is_array($argument)) |
|
| 27 | 27 | {
|
| 28 | 28 | $argument = implode($argument, ','); |
| 29 | 29 | } |
@@ -111,8 +111,7 @@ |
||
| 111 | 111 | if($this->limit) |
| 112 | 112 | {
|
| 113 | 113 | return $this->limit->toString(); |
| 114 | - } |
|
| 115 | - else |
|
| 114 | + } else |
|
| 116 | 115 | {
|
| 117 | 116 | return ""; |
| 118 | 117 | } |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | /** |
| 21 | 21 | * constructor |
| 22 | 22 | * @param string $column_name |
| 23 | - * @param object $argument |
|
| 23 | + * @param Argument $argument |
|
| 24 | 24 | * @return void |
| 25 | 25 | */ |
| 26 | 26 | function UpdateExpression($column_name, $argument) |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | function getExpression($with_value = true) |
| 37 | 37 | {
|
| 38 | - if($with_value) |
|
| 38 | + if ($with_value) |
|
| 39 | 39 | {
|
| 40 | 40 | return $this->getExpressionWithValue(); |
| 41 | 41 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | {
|
| 51 | 51 | $value = $this->argument->getValue(); |
| 52 | 52 | $operation = $this->argument->getColumnOperation(); |
| 53 | - if(isset($operation)) |
|
| 53 | + if (isset($operation)) |
|
| 54 | 54 | {
|
| 55 | 55 | return "$this->column_name = $this->column_name $operation $value"; |
| 56 | 56 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | function getExpressionWithoutValue() |
| 66 | 66 | {
|
| 67 | 67 | $operation = $this->argument->getColumnOperation(); |
| 68 | - if(isset($operation)) |
|
| 68 | + if (isset($operation)) |
|
| 69 | 69 | {
|
| 70 | 70 | return "$this->column_name = $this->column_name $operation ?"; |
| 71 | 71 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | {
|
| 77 | 77 | // TODO Escape value according to column type instead of variable type |
| 78 | 78 | $value = $this->argument->getValue(); |
| 79 | - if(!is_numeric($value)) |
|
| 79 | + if (!is_numeric($value)) |
|
| 80 | 80 | {
|
| 81 | 81 | return "'" . $value . "'"; |
| 82 | 82 | } |
@@ -85,12 +85,12 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | function show() |
| 87 | 87 | {
|
| 88 | - if(!$this->argument) |
|
| 88 | + if (!$this->argument) |
|
| 89 | 89 | {
|
| 90 | 90 | return false; |
| 91 | 91 | } |
| 92 | 92 | $value = $this->argument->getValue(); |
| 93 | - if(!isset($value)) |
|
| 93 | + if (!isset($value)) |
|
| 94 | 94 | {
|
| 95 | 95 | return false; |
| 96 | 96 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | function getArguments() |
| 106 | 106 | {
|
| 107 | - if($this->argument) |
|
| 107 | + if ($this->argument) |
|
| 108 | 108 | {
|
| 109 | 109 | return array($this->argument); |
| 110 | 110 | } |
@@ -111,8 +111,7 @@ |
||
| 111 | 111 | if($this->limit) |
| 112 | 112 | {
|
| 113 | 113 | return $this->limit->toString(); |
| 114 | - } |
|
| 115 | - else |
|
| 114 | + } else |
|
| 116 | 115 | {
|
| 117 | 116 | return ""; |
| 118 | 117 | } |
@@ -251,6 +251,9 @@ |
||
| 251 | 251 | return $this->orderby; |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | + /** |
|
| 255 | + * @param integer $limit |
|
| 256 | + */ |
|
| 254 | 257 | function setLimit($limit = NULL) |
| 255 | 258 | { |
| 256 | 259 | if(!isset($limit)) |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | $this->action = $action; |
| 109 | 109 | $this->priority = $priority; |
| 110 | 110 | |
| 111 | - if(!isset($tables)) |
|
| 111 | + if (!isset($tables)) |
|
| 112 | 112 | { |
| 113 | 113 | return; |
| 114 | 114 | } |
@@ -144,12 +144,12 @@ discard block |
||
| 144 | 144 | function setColumnList($columnList) |
| 145 | 145 | { |
| 146 | 146 | $this->columnList = $columnList; |
| 147 | - if(count($this->columnList) > 0) |
|
| 147 | + if (count($this->columnList) > 0) |
|
| 148 | 148 | { |
| 149 | 149 | $selectColumns = array(); |
| 150 | 150 | $dbParser = DB::getParser(); |
| 151 | 151 | |
| 152 | - foreach($this->columnList as $columnName) |
|
| 152 | + foreach ($this->columnList as $columnName) |
|
| 153 | 153 | { |
| 154 | 154 | $columnName = $dbParser->escapeColumn($columnName); |
| 155 | 155 | $selectColumns[] = new SelectExpression($columnName); |
@@ -161,13 +161,13 @@ discard block |
||
| 161 | 161 | |
| 162 | 162 | function setColumns($columns) |
| 163 | 163 | { |
| 164 | - if(!isset($columns) || count($columns) === 0) |
|
| 164 | + if (!isset($columns) || count($columns) === 0) |
|
| 165 | 165 | { |
| 166 | 166 | $this->columns = array(new StarExpression()); |
| 167 | 167 | return; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - if(!is_array($columns)) |
|
| 170 | + if (!is_array($columns)) |
|
| 171 | 171 | { |
| 172 | 172 | $columns = array($columns); |
| 173 | 173 | } |
@@ -177,14 +177,14 @@ discard block |
||
| 177 | 177 | |
| 178 | 178 | function setTables($tables) |
| 179 | 179 | { |
| 180 | - if(!isset($tables) || count($tables) === 0) |
|
| 180 | + if (!isset($tables) || count($tables) === 0) |
|
| 181 | 181 | { |
| 182 | 182 | $this->setError(TRUE); |
| 183 | 183 | $this->setMessage("You must provide at least one table for the query."); |
| 184 | 184 | return; |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - if(!is_array($tables)) |
|
| 187 | + if (!is_array($tables)) |
|
| 188 | 188 | { |
| 189 | 189 | $tables = array($tables); |
| 190 | 190 | } |
@@ -200,18 +200,18 @@ discard block |
||
| 200 | 200 | function setConditions($conditions) |
| 201 | 201 | { |
| 202 | 202 | $this->conditions = array(); |
| 203 | - if(!isset($conditions) || count($conditions) === 0) |
|
| 203 | + if (!isset($conditions) || count($conditions) === 0) |
|
| 204 | 204 | { |
| 205 | 205 | return; |
| 206 | 206 | } |
| 207 | - if(!is_array($conditions)) |
|
| 207 | + if (!is_array($conditions)) |
|
| 208 | 208 | { |
| 209 | 209 | $conditions = array($conditions); |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - foreach($conditions as $conditionGroup) |
|
| 212 | + foreach ($conditions as $conditionGroup) |
|
| 213 | 213 | { |
| 214 | - if($conditionGroup->show()) |
|
| 214 | + if ($conditionGroup->show()) |
|
| 215 | 215 | { |
| 216 | 216 | $this->conditions[] = $conditionGroup; |
| 217 | 217 | } |
@@ -220,11 +220,11 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | function setGroups($groups) |
| 222 | 222 | { |
| 223 | - if(!isset($groups) || count($groups) === 0) |
|
| 223 | + if (!isset($groups) || count($groups) === 0) |
|
| 224 | 224 | { |
| 225 | 225 | return; |
| 226 | 226 | } |
| 227 | - if(!is_array($groups)) |
|
| 227 | + if (!is_array($groups)) |
|
| 228 | 228 | { |
| 229 | 229 | $groups = array($groups); |
| 230 | 230 | } |
@@ -234,11 +234,11 @@ discard block |
||
| 234 | 234 | |
| 235 | 235 | function setOrder($order) |
| 236 | 236 | { |
| 237 | - if(!isset($order) || count($order) === 0) |
|
| 237 | + if (!isset($order) || count($order) === 0) |
|
| 238 | 238 | { |
| 239 | 239 | return; |
| 240 | 240 | } |
| 241 | - if(!is_array($order)) |
|
| 241 | + if (!is_array($order)) |
|
| 242 | 242 | { |
| 243 | 243 | $order = array($order); |
| 244 | 244 | } |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | |
| 254 | 254 | function setLimit($limit = NULL) |
| 255 | 255 | { |
| 256 | - if(!isset($limit)) |
|
| 256 | + if (!isset($limit)) |
|
| 257 | 257 | { |
| 258 | 258 | return; |
| 259 | 259 | } |
@@ -354,9 +354,9 @@ discard block |
||
| 354 | 354 | function getClickCountColumns() |
| 355 | 355 | { |
| 356 | 356 | $click_count_columns = array(); |
| 357 | - foreach($this->columns as $column) |
|
| 357 | + foreach ($this->columns as $column) |
|
| 358 | 358 | { |
| 359 | - if($column->show() && is_a($column, 'ClickCountExpression')) |
|
| 359 | + if ($column->show() && is_a($column, 'ClickCountExpression')) |
|
| 360 | 360 | { |
| 361 | 361 | $click_count_columns[] = $column; |
| 362 | 362 | } |
@@ -371,11 +371,11 @@ discard block |
||
| 371 | 371 | */ |
| 372 | 372 | function getSelectString($with_values = TRUE) |
| 373 | 373 | { |
| 374 | - foreach($this->columns as $column) |
|
| 374 | + foreach ($this->columns as $column) |
|
| 375 | 375 | { |
| 376 | - if($column->show()) |
|
| 376 | + if ($column->show()) |
|
| 377 | 377 | { |
| 378 | - if($column->isSubquery()) |
|
| 378 | + if ($column->isSubquery()) |
|
| 379 | 379 | { |
| 380 | 380 | $select[] = $column->toString($with_values) . ' as ' . $column->getAlias(); |
| 381 | 381 | } |
@@ -395,15 +395,15 @@ discard block |
||
| 395 | 395 | */ |
| 396 | 396 | function getUpdateString($with_values = TRUE) |
| 397 | 397 | { |
| 398 | - foreach($this->columns as $column) |
|
| 398 | + foreach ($this->columns as $column) |
|
| 399 | 399 | { |
| 400 | - if($column->show()) |
|
| 400 | + if ($column->show()) |
|
| 401 | 401 | { |
| 402 | 402 | $update[] = $column->getExpression($with_values); |
| 403 | 403 | } |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | - if(!$update) return; |
|
| 406 | + if (!$update) return; |
|
| 407 | 407 | return trim(implode($update, ', ')); |
| 408 | 408 | } |
| 409 | 409 | |
@@ -416,9 +416,9 @@ discard block |
||
| 416 | 416 | { |
| 417 | 417 | $columnsList = ''; |
| 418 | 418 | // means we have insert-select |
| 419 | - if($this->subquery) |
|
| 419 | + if ($this->subquery) |
|
| 420 | 420 | { |
| 421 | - foreach($this->columns as $column) |
|
| 421 | + foreach ($this->columns as $column) |
|
| 422 | 422 | { |
| 423 | 423 | $columnsList .= $column->getColumnName() . ', '; |
| 424 | 424 | } |
@@ -429,9 +429,9 @@ discard block |
||
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | $valuesList = ''; |
| 432 | - foreach($this->columns as $column) |
|
| 432 | + foreach ($this->columns as $column) |
|
| 433 | 433 | { |
| 434 | - if($column->show()) |
|
| 434 | + if ($column->show()) |
|
| 435 | 435 | { |
| 436 | 436 | $columnsList .= $column->getColumnName() . ', '; |
| 437 | 437 | $valuesList .= $column->getValue($with_values) . ', '; |
@@ -460,9 +460,9 @@ discard block |
||
| 460 | 460 | { |
| 461 | 461 | $from = ''; |
| 462 | 462 | $simple_table_count = 0; |
| 463 | - foreach($this->tables as $table) |
|
| 463 | + foreach ($this->tables as $table) |
|
| 464 | 464 | { |
| 465 | - if($table->isJoinTable() || !$simple_table_count) |
|
| 465 | + if ($table->isJoinTable() || !$simple_table_count) |
|
| 466 | 466 | { |
| 467 | 467 | $from .= $table->toString($with_values) . ' '; |
| 468 | 468 | } |
@@ -471,14 +471,14 @@ discard block |
||
| 471 | 471 | $from .= ', ' . $table->toString($with_values) . ' '; |
| 472 | 472 | } |
| 473 | 473 | |
| 474 | - if(is_a($table, 'Subquery')) |
|
| 474 | + if (is_a($table, 'Subquery')) |
|
| 475 | 475 | { |
| 476 | 476 | $from .= $table->getAlias() ? ' as ' . $table->getAlias() . ' ' : ' '; |
| 477 | 477 | } |
| 478 | 478 | |
| 479 | 479 | $simple_table_count++; |
| 480 | 480 | } |
| 481 | - if(trim($from) == '') |
|
| 481 | + if (trim($from) == '') |
|
| 482 | 482 | { |
| 483 | 483 | return ''; |
| 484 | 484 | } |
@@ -496,9 +496,9 @@ discard block |
||
| 496 | 496 | $where = ''; |
| 497 | 497 | $condition_count = 0; |
| 498 | 498 | |
| 499 | - foreach($this->conditions as $conditionGroup) |
|
| 499 | + foreach ($this->conditions as $conditionGroup) |
|
| 500 | 500 | { |
| 501 | - if($condition_count === 0) |
|
| 501 | + if ($condition_count === 0) |
|
| 502 | 502 | { |
| 503 | 503 | $conditionGroup->setPipe(""); |
| 504 | 504 | } |
@@ -507,22 +507,22 @@ discard block |
||
| 507 | 507 | $condition_count++; |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | - if($with_optimization && |
|
| 510 | + if ($with_optimization && |
|
| 511 | 511 | (strstr($this->getOrderByString(), 'list_order') || strstr($this->getOrderByString(), 'update_order'))) |
| 512 | 512 | { |
| 513 | 513 | |
| 514 | - if($condition_count !== 0) |
|
| 514 | + if ($condition_count !== 0) |
|
| 515 | 515 | { |
| 516 | 516 | $where = '(' . $where . ') '; |
| 517 | 517 | } |
| 518 | 518 | |
| 519 | - foreach($this->orderby as $order) |
|
| 519 | + foreach ($this->orderby as $order) |
|
| 520 | 520 | { |
| 521 | 521 | $colName = $order->getColumnName(); |
| 522 | - if(strstr($colName, 'list_order') || strstr($colName, 'update_order')) |
|
| 522 | + if (strstr($colName, 'list_order') || strstr($colName, 'update_order')) |
|
| 523 | 523 | { |
| 524 | 524 | $opt_condition = new ConditionWithoutArgument($colName, 2100000000, 'less', 'and'); |
| 525 | - if($condition_count === 0) |
|
| 525 | + if ($condition_count === 0) |
|
| 526 | 526 | { |
| 527 | 527 | $opt_condition->setPipe(""); |
| 528 | 528 | } |
@@ -542,9 +542,9 @@ discard block |
||
| 542 | 542 | function getGroupByString() |
| 543 | 543 | { |
| 544 | 544 | $groupBy = ''; |
| 545 | - if($this->groups) |
|
| 545 | + if ($this->groups) |
|
| 546 | 546 | { |
| 547 | - if($this->groups[0] !== "") |
|
| 547 | + if ($this->groups[0] !== "") |
|
| 548 | 548 | { |
| 549 | 549 | $groupBy = implode(', ', $this->groups); |
| 550 | 550 | } |
@@ -558,14 +558,14 @@ discard block |
||
| 558 | 558 | */ |
| 559 | 559 | function getOrderByString() |
| 560 | 560 | { |
| 561 | - if(!$this->_orderByString) |
|
| 561 | + if (!$this->_orderByString) |
|
| 562 | 562 | { |
| 563 | - if(count($this->orderby) === 0) |
|
| 563 | + if (count($this->orderby) === 0) |
|
| 564 | 564 | { |
| 565 | 565 | return ''; |
| 566 | 566 | } |
| 567 | 567 | $orderBy = ''; |
| 568 | - foreach($this->orderby as $order) |
|
| 568 | + foreach ($this->orderby as $order) |
|
| 569 | 569 | { |
| 570 | 570 | $orderBy .= $order->toString() . ', '; |
| 571 | 571 | } |
@@ -587,7 +587,7 @@ discard block |
||
| 587 | 587 | function getLimitString() |
| 588 | 588 | { |
| 589 | 589 | $limit = ''; |
| 590 | - if(count($this->limit) > 0) |
|
| 590 | + if (count($this->limit) > 0) |
|
| 591 | 591 | { |
| 592 | 592 | $limit = ''; |
| 593 | 593 | $limit .= $this->limit->toString(); |
@@ -606,19 +606,19 @@ discard block |
||
| 606 | 606 | */ |
| 607 | 607 | function getArguments() |
| 608 | 608 | { |
| 609 | - if(!isset($this->arguments)) |
|
| 609 | + if (!isset($this->arguments)) |
|
| 610 | 610 | { |
| 611 | 611 | $this->arguments = array(); |
| 612 | 612 | |
| 613 | 613 | // Join table arguments |
| 614 | - if(count($this->tables) > 0) |
|
| 614 | + if (count($this->tables) > 0) |
|
| 615 | 615 | { |
| 616 | - foreach($this->tables as $table) |
|
| 616 | + foreach ($this->tables as $table) |
|
| 617 | 617 | { |
| 618 | - if($table->isJoinTable() || is_a($table, 'Subquery')) |
|
| 618 | + if ($table->isJoinTable() || is_a($table, 'Subquery')) |
|
| 619 | 619 | { |
| 620 | 620 | $args = $table->getArguments(); |
| 621 | - if($args) |
|
| 621 | + if ($args) |
|
| 622 | 622 | { |
| 623 | 623 | $this->arguments = array_merge($this->arguments, $args); |
| 624 | 624 | } |
@@ -628,14 +628,14 @@ discard block |
||
| 628 | 628 | |
| 629 | 629 | // Column arguments |
| 630 | 630 | // The if is for delete statements, all others must have columns |
| 631 | - if(count($this->columns) > 0) |
|
| 631 | + if (count($this->columns) > 0) |
|
| 632 | 632 | { |
| 633 | - foreach($this->columns as $column) |
|
| 633 | + foreach ($this->columns as $column) |
|
| 634 | 634 | { |
| 635 | - if($column->show()) |
|
| 635 | + if ($column->show()) |
|
| 636 | 636 | { |
| 637 | 637 | $args = $column->getArguments(); |
| 638 | - if($args) |
|
| 638 | + if ($args) |
|
| 639 | 639 | { |
| 640 | 640 | $this->arguments = array_merge($this->arguments, $args); |
| 641 | 641 | } |
@@ -644,12 +644,12 @@ discard block |
||
| 644 | 644 | } |
| 645 | 645 | |
| 646 | 646 | // Condition arguments |
| 647 | - if(count($this->conditions) > 0) |
|
| 647 | + if (count($this->conditions) > 0) |
|
| 648 | 648 | { |
| 649 | - foreach($this->conditions as $conditionGroup) |
|
| 649 | + foreach ($this->conditions as $conditionGroup) |
|
| 650 | 650 | { |
| 651 | 651 | $args = $conditionGroup->getArguments(); |
| 652 | - if(count($args) > 0) |
|
| 652 | + if (count($args) > 0) |
|
| 653 | 653 | { |
| 654 | 654 | $this->arguments = array_merge($this->arguments, $args); |
| 655 | 655 | } |
@@ -657,12 +657,12 @@ discard block |
||
| 657 | 657 | } |
| 658 | 658 | |
| 659 | 659 | // Navigation arguments |
| 660 | - if(count($this->orderby) > 0) |
|
| 660 | + if (count($this->orderby) > 0) |
|
| 661 | 661 | { |
| 662 | - foreach($this->orderby as $order) |
|
| 662 | + foreach ($this->orderby as $order) |
|
| 663 | 663 | { |
| 664 | 664 | $args = $order->getArguments(); |
| 665 | - if(count($args) > 0) |
|
| 665 | + if (count($args) > 0) |
|
| 666 | 666 | { |
| 667 | 667 | $this->arguments = array_merge($this->arguments, $args); |
| 668 | 668 | } |
@@ -378,8 +378,7 @@ discard block |
||
| 378 | 378 | if($column->isSubquery()) |
| 379 | 379 | { |
| 380 | 380 | $select[] = $column->toString($with_values) . ' as ' . $column->getAlias(); |
| 381 | - } |
|
| 382 | - else |
|
| 381 | + } else |
|
| 383 | 382 | { |
| 384 | 383 | $select[] = $column->getExpression($with_values); |
| 385 | 384 | } |
@@ -403,7 +402,9 @@ discard block |
||
| 403 | 402 | } |
| 404 | 403 | } |
| 405 | 404 | |
| 406 | - if(!$update) return; |
|
| 405 | + if(!$update) { |
|
| 406 | + return; |
|
| 407 | + } |
|
| 407 | 408 | return trim(implode($update, ', ')); |
| 408 | 409 | } |
| 409 | 410 | |
@@ -465,8 +466,7 @@ discard block |
||
| 465 | 466 | if($table->isJoinTable() || !$simple_table_count) |
| 466 | 467 | { |
| 467 | 468 | $from .= $table->toString($with_values) . ' '; |
| 468 | - } |
|
| 469 | - else |
|
| 469 | + } else |
|
| 470 | 470 | { |
| 471 | 471 | $from .= ', ' . $table->toString($with_values) . ' '; |
| 472 | 472 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | * Print debugging message to designated output source depending on the value set to __DEBUG_OUTPUT_. \n |
| 134 | 134 | * This method only functions when __DEBUG__ variable is set to 1. |
| 135 | 135 | * __DEBUG_OUTPUT__ == 0, messages are written in ./files/_debug_message.php |
| 136 | - * @return void |
|
| 136 | + * @return null|string |
|
| 137 | 137 | */ |
| 138 | 138 | function _debugOutput() |
| 139 | 139 | { |
@@ -358,6 +358,7 @@ discard block |
||
| 358 | 358 | |
| 359 | 359 | /** |
| 360 | 360 | * print a HTTP HEADER for HTML, which is encoded in UTF-8 |
| 361 | + * @param integer $code |
|
| 361 | 362 | * @return void |
| 362 | 363 | */ |
| 363 | 364 | function _printHttpStatusCode($code) |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | function printContent(&$oModule) |
| 26 | 26 | { |
| 27 | 27 | // Check if the gzip encoding supported |
| 28 | - if( |
|
| 28 | + if ( |
|
| 29 | 29 | (defined('__OB_GZHANDLER_ENABLE__') && __OB_GZHANDLER_ENABLE__ == 1) && |
| 30 | 30 | strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE && |
| 31 | 31 | function_exists('ob_gzhandler') && |
@@ -37,23 +37,23 @@ discard block |
||
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | // Extract contents to display by the request method |
| 40 | - if(Context::get('xeVirtualRequestMethod') == 'xml') |
|
| 40 | + if (Context::get('xeVirtualRequestMethod') == 'xml') |
|
| 41 | 41 | { |
| 42 | 42 | $handler = new VirtualXMLDisplayHandler(); |
| 43 | 43 | } |
| 44 | - else if(Context::getRequestMethod() == 'XMLRPC') |
|
| 44 | + else if (Context::getRequestMethod() == 'XMLRPC') |
|
| 45 | 45 | { |
| 46 | 46 | $handler = new XMLDisplayHandler(); |
| 47 | - if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) |
|
| 47 | + if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) |
|
| 48 | 48 | { |
| 49 | 49 | $this->gz_enabled = FALSE; |
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | - else if(Context::getRequestMethod() == 'JSON') |
|
| 52 | + else if (Context::getRequestMethod() == 'JSON') |
|
| 53 | 53 | { |
| 54 | 54 | $handler = new JSONDisplayHandler(); |
| 55 | 55 | } |
| 56 | - else if(Context::getRequestMethod() == 'JS_CALLBACK') |
|
| 56 | + else if (Context::getRequestMethod() == 'JS_CALLBACK') |
|
| 57 | 57 | { |
| 58 | 58 | $handler = new JSCallbackDisplayHandler(); |
| 59 | 59 | } |
@@ -71,9 +71,9 @@ discard block |
||
| 71 | 71 | $called_position = 'before_display_content'; |
| 72 | 72 | $oAddonController = getController('addon'); |
| 73 | 73 | $addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? "mobile" : "pc"); |
| 74 | - if(file_exists($addon_file)) include($addon_file); |
|
| 74 | + if (file_exists($addon_file)) include($addon_file); |
|
| 75 | 75 | |
| 76 | - if(method_exists($handler, "prepareToPrint")) |
|
| 76 | + if (method_exists($handler, "prepareToPrint")) |
|
| 77 | 77 | { |
| 78 | 78 | $handler->prepareToPrint($output); |
| 79 | 79 | } |
@@ -81,17 +81,17 @@ discard block |
||
| 81 | 81 | // header output |
| 82 | 82 | |
| 83 | 83 | $httpStatusCode = $oModule->getHttpStatusCode(); |
| 84 | - if($httpStatusCode && $httpStatusCode != 200) |
|
| 84 | + if ($httpStatusCode && $httpStatusCode != 200) |
|
| 85 | 85 | { |
| 86 | 86 | $this->_printHttpStatusCode($httpStatusCode); |
| 87 | 87 | } |
| 88 | 88 | else |
| 89 | 89 | { |
| 90 | - if(Context::getResponseMethod() == 'JSON' || Context::getResponseMethod() == 'JS_CALLBACK') |
|
| 90 | + if (Context::getResponseMethod() == 'JSON' || Context::getResponseMethod() == 'JS_CALLBACK') |
|
| 91 | 91 | { |
| 92 | 92 | $this->_printJSONHeader(); |
| 93 | 93 | } |
| 94 | - else if(Context::getResponseMethod() != 'HTML') |
|
| 94 | + else if (Context::getResponseMethod() != 'HTML') |
|
| 95 | 95 | { |
| 96 | 96 | $this->_printXMLHeader(); |
| 97 | 97 | } |
@@ -107,13 +107,13 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | // disable gzip if output already exists |
| 109 | 109 | ob_flush(); |
| 110 | - if(headers_sent()) |
|
| 110 | + if (headers_sent()) |
|
| 111 | 111 | { |
| 112 | 112 | $this->gz_enabled = FALSE; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | // results directly output |
| 116 | - if($this->gz_enabled) |
|
| 116 | + if ($this->gz_enabled) |
|
| 117 | 117 | { |
| 118 | 118 | header("Content-Encoding: gzip"); |
| 119 | 119 | print ob_gzhandler($output, 5); |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | function _debugOutput() |
| 139 | 139 | { |
| 140 | - if(!__DEBUG__) |
|
| 140 | + if (!__DEBUG__) |
|
| 141 | 141 | { |
| 142 | 142 | return; |
| 143 | 143 | } |
@@ -145,21 +145,21 @@ discard block |
||
| 145 | 145 | $end = getMicroTime(); |
| 146 | 146 | |
| 147 | 147 | // Firebug console output |
| 148 | - if(__DEBUG_OUTPUT__ == 2 && version_compare(PHP_VERSION, '6.0.0') === -1) |
|
| 148 | + if (__DEBUG_OUTPUT__ == 2 && version_compare(PHP_VERSION, '6.0.0') === -1) |
|
| 149 | 149 | { |
| 150 | 150 | static $firephp; |
| 151 | - if(!isset($firephp)) |
|
| 151 | + if (!isset($firephp)) |
|
| 152 | 152 | { |
| 153 | 153 | $firephp = FirePHP::getInstance(true); |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) |
|
| 156 | + if (__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) |
|
| 157 | 157 | { |
| 158 | 158 | $firephp->fb('Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php', 'The IP address is not allowed.'); |
| 159 | 159 | return; |
| 160 | 160 | } |
| 161 | 161 | // display total execution time and Request/Response info |
| 162 | - if(__DEBUG__ & 2) |
|
| 162 | + if (__DEBUG__ & 2) |
|
| 163 | 163 | { |
| 164 | 164 | $firephp->fb( |
| 165 | 165 | array( |
@@ -197,10 +197,10 @@ discard block |
||
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | // display DB query history |
| 200 | - if((__DEBUG__ & 4) && $GLOBALS['__db_queries__']) |
|
| 200 | + if ((__DEBUG__ & 4) && $GLOBALS['__db_queries__']) |
|
| 201 | 201 | { |
| 202 | - $queries_output = array(array('Result/'.PHP_EOL.'Elapsed time', 'Query ID', 'Query')); |
|
| 203 | - foreach($GLOBALS['__db_queries__'] as $query) |
|
| 202 | + $queries_output = array(array('Result/' . PHP_EOL . 'Elapsed time', 'Query ID', 'Query')); |
|
| 203 | + foreach ($GLOBALS['__db_queries__'] as $query) |
|
| 204 | 204 | { |
| 205 | 205 | $queries_output[] = array($query['result'] . PHP_EOL . sprintf('%0.5f', $query['elapsed_time']), str_replace(_XE_PATH_, '', $query['called_file']) . PHP_EOL . $query['called_method'] . '()' . PHP_EOL . $query['query_id'], $query['query']); |
| 206 | 206 | } |
@@ -219,9 +219,9 @@ discard block |
||
| 219 | 219 | |
| 220 | 220 | $buff = array(); |
| 221 | 221 | // display total execution time and Request/Response info |
| 222 | - if(__DEBUG__ & 2) |
|
| 222 | + if (__DEBUG__ & 2) |
|
| 223 | 223 | { |
| 224 | - if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) |
|
| 224 | + if (__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) |
|
| 225 | 225 | { |
| 226 | 226 | return; |
| 227 | 227 | } |
@@ -252,21 +252,21 @@ discard block |
||
| 252 | 252 | $buff[] = sprintf("\tTrans Content \t\t\t\t\t: %0.5f sec", $GLOBALS['__trans_content_elapsed__']); |
| 253 | 253 | } |
| 254 | 254 | // DB Logging |
| 255 | - if(__DEBUG__ & 4) |
|
| 255 | + if (__DEBUG__ & 4) |
|
| 256 | 256 | { |
| 257 | - if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) |
|
| 257 | + if (__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) |
|
| 258 | 258 | { |
| 259 | 259 | return; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - if($GLOBALS['__db_queries__']) |
|
| 262 | + if ($GLOBALS['__db_queries__']) |
|
| 263 | 263 | { |
| 264 | 264 | $buff[] = sprintf("\n- DB Queries : %d Queries. %0.5f sec", count($GLOBALS['__db_queries__']), $GLOBALS['__db_elapsed_time__']); |
| 265 | 265 | $num = 0; |
| 266 | 266 | |
| 267 | - foreach($GLOBALS['__db_queries__'] as $query) |
|
| 267 | + foreach ($GLOBALS['__db_queries__'] as $query) |
|
| 268 | 268 | { |
| 269 | - if($query['result'] == 'Success') |
|
| 269 | + if ($query['result'] == 'Success') |
|
| 270 | 270 | { |
| 271 | 271 | $query_result = "Query Success"; |
| 272 | 272 | } |
@@ -283,12 +283,12 @@ discard block |
||
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | // Output in HTML comments |
| 286 | - if($buff && __DEBUG_OUTPUT__ == 1 && Context::getResponseMethod() == 'HTML') |
|
| 286 | + if ($buff && __DEBUG_OUTPUT__ == 1 && Context::getResponseMethod() == 'HTML') |
|
| 287 | 287 | { |
| 288 | 288 | $buff = implode("\r\n", $buff); |
| 289 | 289 | $buff = sprintf("[%s %s:%d]\r\n%s", date('Y-m-d H:i:s'), $file_name, $line_num, print_r($buff, true)); |
| 290 | 290 | |
| 291 | - if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) |
|
| 291 | + if (__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) |
|
| 292 | 292 | { |
| 293 | 293 | $buff = 'The IP address is not allowed. Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php'; |
| 294 | 294 | } |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | // Output to a file |
| 300 | - if($buff && __DEBUG_OUTPUT__ == 0) |
|
| 300 | + if ($buff && __DEBUG_OUTPUT__ == 0) |
|
| 301 | 301 | { |
| 302 | 302 | $debug_file = _XE_PATH_ . 'files/_debug_message.php'; |
| 303 | 303 | $buff = implode(PHP_EOL, $buff); |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | $buff = str_repeat('=', 80) . "\n" . $buff . "\n" . str_repeat('-', 80); |
| 307 | 307 | $buff = "\n<?php\n/*" . $buff . "*/\n?>\n"; |
| 308 | 308 | |
| 309 | - if (!@file_put_contents($debug_file, $buff, FILE_APPEND|LOCK_EX)) |
|
| 309 | + if (!@file_put_contents($debug_file, $buff, FILE_APPEND | LOCK_EX)) |
|
| 310 | 310 | { |
| 311 | 311 | return; |
| 312 | 312 | } |
@@ -40,24 +40,20 @@ discard block |
||
| 40 | 40 | if(Context::get('xeVirtualRequestMethod') == 'xml') |
| 41 | 41 | { |
| 42 | 42 | $handler = new VirtualXMLDisplayHandler(); |
| 43 | - } |
|
| 44 | - else if(Context::getRequestMethod() == 'XMLRPC') |
|
| 43 | + } else if(Context::getRequestMethod() == 'XMLRPC') |
|
| 45 | 44 | { |
| 46 | 45 | $handler = new XMLDisplayHandler(); |
| 47 | 46 | if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) |
| 48 | 47 | { |
| 49 | 48 | $this->gz_enabled = FALSE; |
| 50 | 49 | } |
| 51 | - } |
|
| 52 | - else if(Context::getRequestMethod() == 'JSON') |
|
| 50 | + } else if(Context::getRequestMethod() == 'JSON') |
|
| 53 | 51 | { |
| 54 | 52 | $handler = new JSONDisplayHandler(); |
| 55 | - } |
|
| 56 | - else if(Context::getRequestMethod() == 'JS_CALLBACK') |
|
| 53 | + } else if(Context::getRequestMethod() == 'JS_CALLBACK') |
|
| 57 | 54 | { |
| 58 | 55 | $handler = new JSCallbackDisplayHandler(); |
| 59 | - } |
|
| 60 | - else |
|
| 56 | + } else |
|
| 61 | 57 | { |
| 62 | 58 | $handler = new HTMLDisplayHandler(); |
| 63 | 59 | } |
@@ -71,7 +67,9 @@ discard block |
||
| 71 | 67 | $called_position = 'before_display_content'; |
| 72 | 68 | $oAddonController = getController('addon'); |
| 73 | 69 | $addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? "mobile" : "pc"); |
| 74 | - if(file_exists($addon_file)) include($addon_file); |
|
| 70 | + if(file_exists($addon_file)) { |
|
| 71 | + include($addon_file); |
|
| 72 | + } |
|
| 75 | 73 | |
| 76 | 74 | if(method_exists($handler, "prepareToPrint")) |
| 77 | 75 | { |
@@ -84,18 +82,15 @@ discard block |
||
| 84 | 82 | if($httpStatusCode && $httpStatusCode != 200) |
| 85 | 83 | { |
| 86 | 84 | $this->_printHttpStatusCode($httpStatusCode); |
| 87 | - } |
|
| 88 | - else |
|
| 85 | + } else |
|
| 89 | 86 | { |
| 90 | 87 | if(Context::getResponseMethod() == 'JSON' || Context::getResponseMethod() == 'JS_CALLBACK') |
| 91 | 88 | { |
| 92 | 89 | $this->_printJSONHeader(); |
| 93 | - } |
|
| 94 | - else if(Context::getResponseMethod() != 'HTML') |
|
| 90 | + } else if(Context::getResponseMethod() != 'HTML') |
|
| 95 | 91 | { |
| 96 | 92 | $this->_printXMLHeader(); |
| 97 | - } |
|
| 98 | - else |
|
| 93 | + } else |
|
| 99 | 94 | { |
| 100 | 95 | $this->_printHTMLHeader(); |
| 101 | 96 | } |
@@ -117,8 +112,7 @@ discard block |
||
| 117 | 112 | { |
| 118 | 113 | header("Content-Encoding: gzip"); |
| 119 | 114 | print ob_gzhandler($output, 5); |
| 120 | - } |
|
| 121 | - else |
|
| 115 | + } else |
|
| 122 | 116 | { |
| 123 | 117 | print $output; |
| 124 | 118 | } |
@@ -213,8 +207,7 @@ discard block |
||
| 213 | 207 | ); |
| 214 | 208 | } |
| 215 | 209 | // dislpay the file and HTML comments |
| 216 | - } |
|
| 217 | - else |
|
| 210 | + } else |
|
| 218 | 211 | { |
| 219 | 212 | |
| 220 | 213 | $buff = array(); |
@@ -269,8 +262,7 @@ discard block |
||
| 269 | 262 | if($query['result'] == 'Success') |
| 270 | 263 | { |
| 271 | 264 | $query_result = "Query Success"; |
| 272 | - } |
|
| 273 | - else |
|
| 265 | + } else |
|
| 274 | 266 | { |
| 275 | 267 | $query_result = sprintf("Query $s : %d\n\t\t\t %s", $query['result'], $query['errno'], $query['errstr']); |
| 276 | 268 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @param string $target_dir Path of target dir |
| 35 | 35 | * @param string $filter Regex to filter files. If file matches this regex, the file is not copied. |
| 36 | 36 | * @param string $type If set as 'force'. Even if the file exists in target, the file is copied. |
| 37 | - * @return void |
|
| 37 | + * @return false|null |
|
| 38 | 38 | */ |
| 39 | 39 | function copyDir($source_dir, $target_dir, $filter = null, $type = null) |
| 40 | 40 | { |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | * This function creates directories recursively, which means that if ancestors of the target directory does not exist, they will be created too. |
| 276 | 276 | * |
| 277 | 277 | * @param string $path_string Path of target directory |
| 278 | - * @return bool TRUE if success. It might return nothing when ftp is used and connection to the ftp address failed. |
|
| 278 | + * @return boolean|null TRUE if success. It might return nothing when ftp is used and connection to the ftp address failed. |
|
| 279 | 279 | */ |
| 280 | 280 | function makeDir($path_string) |
| 281 | 281 | { |
@@ -615,7 +615,7 @@ discard block |
||
| 615 | 615 | * @param string $url The address of the target file |
| 616 | 616 | * @param string $target_filename The location to store |
| 617 | 617 | * @param string $body HTTP request body |
| 618 | - * @param string $timeout Connection timeout |
|
| 618 | + * @param integer $timeout Connection timeout |
|
| 619 | 619 | * @param string $method GET/POST |
| 620 | 620 | * @param string $content_type Content type header of HTTP request |
| 621 | 621 | * @param string[] $headers Headers key value array. |
@@ -636,8 +636,8 @@ discard block |
||
| 636 | 636 | * Convert size in string into numeric value |
| 637 | 637 | * |
| 638 | 638 | * @see self::filesize() |
| 639 | - * @param $val Size in string (ex., 10, 10K, 10M, 10G ) |
|
| 640 | - * @return int converted size |
|
| 639 | + * @param string $val Size in string (ex., 10, 10K, 10M, 10G ) |
|
| 640 | + * @return double converted size |
|
| 641 | 641 | */ |
| 642 | 642 | function returnBytes($val) |
| 643 | 643 | { |
@@ -687,7 +687,7 @@ discard block |
||
| 687 | 687 | * @param int $resize_height Height to resize |
| 688 | 688 | * @param string $target_type If $target_type is set (gif, jpg, png, bmp), result image will be saved as target type |
| 689 | 689 | * @param string $thumbnail_type Thumbnail type(crop, ratio) |
| 690 | - * @return bool TRUE: success, FALSE: failed |
|
| 690 | + * @return null|boolean TRUE: success, FALSE: failed |
|
| 691 | 691 | */ |
| 692 | 692 | function createImageFile($source_file, $target_file, $resize_width = 0, $resize_height = 0, $target_type = '', $thumbnail_type = 'crop') |
| 693 | 693 | { |
@@ -1000,7 +1000,7 @@ discard block |
||
| 1000 | 1000 | * Check file exists. |
| 1001 | 1001 | * |
| 1002 | 1002 | * @param string $filename Target file name |
| 1003 | - * @return bool Returns FALSE if the file does not exists, or Returns full path file(string). |
|
| 1003 | + * @return string|false Returns FALSE if the file does not exists, or Returns full path file(string). |
|
| 1004 | 1004 | */ |
| 1005 | 1005 | function exists($filename) |
| 1006 | 1006 | { |
@@ -1011,8 +1011,8 @@ discard block |
||
| 1011 | 1011 | /** |
| 1012 | 1012 | * Check it is dir |
| 1013 | 1013 | * |
| 1014 | - * @param string $dir Target dir path |
|
| 1015 | - * @return bool Returns FALSE if the dir is not dir, or Returns full path of dir(string). |
|
| 1014 | + * @param string $path |
|
| 1015 | + * @return string|false Returns FALSE if the dir is not dir, or Returns full path of dir(string). |
|
| 1016 | 1016 | */ |
| 1017 | 1017 | function isDir($path) |
| 1018 | 1018 | { |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | function getRealPath($source) |
| 19 | 19 | { |
| 20 | - if(strlen($source) >= 2 && substr_compare($source, './', 0, 2) === 0) |
|
| 20 | + if (strlen($source) >= 2 && substr_compare($source, './', 0, 2) === 0) |
|
| 21 | 21 | { |
| 22 | 22 | return _XE_PATH_ . substr($source, 2); |
| 23 | 23 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | { |
| 41 | 41 | $source_dir = self::getRealPath($source_dir); |
| 42 | 42 | $target_dir = self::getRealPath($target_dir); |
| 43 | - if(!is_dir($source_dir)) |
|
| 43 | + if (!is_dir($source_dir)) |
|
| 44 | 44 | { |
| 45 | 45 | return FALSE; |
| 46 | 46 | } |
@@ -48,42 +48,42 @@ discard block |
||
| 48 | 48 | // generate when no target exists |
| 49 | 49 | self::makeDir($target_dir); |
| 50 | 50 | |
| 51 | - if(substr($source_dir, -1) != DIRECTORY_SEPARATOR) |
|
| 51 | + if (substr($source_dir, -1) != DIRECTORY_SEPARATOR) |
|
| 52 | 52 | { |
| 53 | 53 | $source_dir .= DIRECTORY_SEPARATOR; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - if(substr($target_dir, -1) != DIRECTORY_SEPARATOR) |
|
| 56 | + if (substr($target_dir, -1) != DIRECTORY_SEPARATOR) |
|
| 57 | 57 | { |
| 58 | 58 | $target_dir .= DIRECTORY_SEPARATOR; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | $oDir = dir($source_dir); |
| 62 | - while($file = $oDir->read()) |
|
| 62 | + while ($file = $oDir->read()) |
|
| 63 | 63 | { |
| 64 | - if($file{0} == '.') |
|
| 64 | + if ($file{0} == '.') |
|
| 65 | 65 | { |
| 66 | 66 | continue; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - if($filter && preg_match($filter, $file)) |
|
| 69 | + if ($filter && preg_match($filter, $file)) |
|
| 70 | 70 | { |
| 71 | 71 | continue; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if(is_dir($source_dir . $file)) |
|
| 74 | + if (is_dir($source_dir . $file)) |
|
| 75 | 75 | { |
| 76 | 76 | self::copyDir($source_dir . $file, $target_dir . $file, $type); |
| 77 | 77 | } |
| 78 | 78 | else |
| 79 | 79 | { |
| 80 | - if($type == 'force') |
|
| 80 | + if ($type == 'force') |
|
| 81 | 81 | { |
| 82 | 82 | @unlink($target_dir . $file); |
| 83 | 83 | } |
| 84 | 84 | else |
| 85 | 85 | { |
| 86 | - if(!file_exists($target_dir . $file)) |
|
| 86 | + if (!file_exists($target_dir . $file)) |
|
| 87 | 87 | { |
| 88 | 88 | @copy($source_dir . $file, $target_dir . $file); |
| 89 | 89 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | self::makeDir($target_dir); |
| 112 | 112 | |
| 113 | - if($force == 'Y') |
|
| 113 | + if ($force == 'Y') |
|
| 114 | 114 | { |
| 115 | 115 | @unlink($target_dir . DIRECTORY_SEPARATOR . $target); |
| 116 | 116 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | function readFile($filename) |
| 128 | 128 | { |
| 129 | - if(($filename = self::exists($filename)) === FALSE || filesize($filename) < 1) |
|
| 129 | + if (($filename = self::exists($filename)) === FALSE || filesize($filename) < 1) |
|
| 130 | 130 | { |
| 131 | 131 | return; |
| 132 | 132 | } |
@@ -149,12 +149,12 @@ discard block |
||
| 149 | 149 | self::makeDir($pathinfo['dirname']); |
| 150 | 150 | |
| 151 | 151 | $flags = 0; |
| 152 | - if(strtolower($mode) == 'a') |
|
| 152 | + if (strtolower($mode) == 'a') |
|
| 153 | 153 | { |
| 154 | 154 | $flags = FILE_APPEND; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - @file_put_contents($filename, $buff, $flags|LOCK_EX); |
|
| 157 | + @file_put_contents($filename, $buff, $flags | LOCK_EX); |
|
| 158 | 158 | @chmod($filename, 0644); |
| 159 | 159 | } |
| 160 | 160 | |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | */ |
| 193 | 193 | function moveFile($source, $target) |
| 194 | 194 | { |
| 195 | - if(($source = self::exists($source)) !== FALSE) |
|
| 195 | + if (($source = self::exists($source)) !== FALSE) |
|
| 196 | 196 | { |
| 197 | 197 | self::removeFile($target); |
| 198 | 198 | return self::rename($source, $target); |
@@ -230,35 +230,35 @@ discard block |
||
| 230 | 230 | $path = self::getRealPath($path); |
| 231 | 231 | $output = array(); |
| 232 | 232 | |
| 233 | - if(substr($path, -1) != '/') |
|
| 233 | + if (substr($path, -1) != '/') |
|
| 234 | 234 | { |
| 235 | 235 | $path .= '/'; |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - if(!is_dir($path)) |
|
| 238 | + if (!is_dir($path)) |
|
| 239 | 239 | { |
| 240 | 240 | return $output; |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | $files = scandir($path); |
| 244 | - foreach($files as $file) |
|
| 244 | + foreach ($files as $file) |
|
| 245 | 245 | { |
| 246 | - if($file{0} == '.' || ($filter && !preg_match($filter, $file))) |
|
| 246 | + if ($file{0} == '.' || ($filter && !preg_match($filter, $file))) |
|
| 247 | 247 | { |
| 248 | 248 | continue; |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - if($to_lower) |
|
| 251 | + if ($to_lower) |
|
| 252 | 252 | { |
| 253 | 253 | $file = strtolower($file); |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - if($filter) |
|
| 256 | + if ($filter) |
|
| 257 | 257 | { |
| 258 | 258 | $file = preg_replace($filter, '$1', $file); |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | - if($concat_prefix) |
|
| 261 | + if ($concat_prefix) |
|
| 262 | 262 | { |
| 263 | 263 | $file = sprintf('%s%s', str_replace(_XE_PATH_, '', $path), $file); |
| 264 | 264 | } |
@@ -279,12 +279,12 @@ discard block |
||
| 279 | 279 | */ |
| 280 | 280 | function makeDir($path_string) |
| 281 | 281 | { |
| 282 | - if(self::exists($path_string) !== FALSE) |
|
| 282 | + if (self::exists($path_string) !== FALSE) |
|
| 283 | 283 | { |
| 284 | 284 | return TRUE; |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | - if(!ini_get('safe_mode')) |
|
| 287 | + if (!ini_get('safe_mode')) |
|
| 288 | 288 | { |
| 289 | 289 | @mkdir($path_string, 0755, TRUE); |
| 290 | 290 | @chmod($path_string, 0755); |
@@ -295,35 +295,35 @@ discard block |
||
| 295 | 295 | static $oFtp = NULL; |
| 296 | 296 | |
| 297 | 297 | $ftp_info = Context::getFTPInfo(); |
| 298 | - if($oFtp == NULL) |
|
| 298 | + if ($oFtp == NULL) |
|
| 299 | 299 | { |
| 300 | - if(!Context::isFTPRegisted()) |
|
| 300 | + if (!Context::isFTPRegisted()) |
|
| 301 | 301 | { |
| 302 | 302 | return; |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | require_once(_XE_PATH_ . 'libs/ftp.class.php'); |
| 306 | 306 | $oFtp = new ftp(); |
| 307 | - if(!$ftp_info->ftp_host) |
|
| 307 | + if (!$ftp_info->ftp_host) |
|
| 308 | 308 | { |
| 309 | 309 | $ftp_info->ftp_host = "127.0.0.1"; |
| 310 | 310 | } |
| 311 | - if(!$ftp_info->ftp_port) |
|
| 311 | + if (!$ftp_info->ftp_port) |
|
| 312 | 312 | { |
| 313 | 313 | $ftp_info->ftp_port = 21; |
| 314 | 314 | } |
| 315 | - if(!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) |
|
| 315 | + if (!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) |
|
| 316 | 316 | { |
| 317 | 317 | return; |
| 318 | 318 | } |
| 319 | - if(!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
| 319 | + if (!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
| 320 | 320 | { |
| 321 | 321 | $oFtp->ftp_quit(); |
| 322 | 322 | return; |
| 323 | 323 | } |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - if(!($ftp_path = $ftp_info->ftp_root_path)) |
|
| 326 | + if (!($ftp_path = $ftp_info->ftp_root_path)) |
|
| 327 | 327 | { |
| 328 | 328 | $ftp_path = DIRECTORY_SEPARATOR; |
| 329 | 329 | } |
@@ -332,16 +332,16 @@ discard block |
||
| 332 | 332 | $path_list = explode(DIRECTORY_SEPARATOR, $path_string); |
| 333 | 333 | |
| 334 | 334 | $path = _XE_PATH_; |
| 335 | - for($i = 0, $c = count($path_list); $i < $c; $i++) |
|
| 335 | + for ($i = 0, $c = count($path_list); $i < $c; $i++) |
|
| 336 | 336 | { |
| 337 | - if(!$path_list[$i]) |
|
| 337 | + if (!$path_list[$i]) |
|
| 338 | 338 | { |
| 339 | 339 | continue; |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | $path .= $path_list[$i] . DIRECTORY_SEPARATOR; |
| 343 | 343 | $ftp_path .= $path_list[$i] . DIRECTORY_SEPARATOR; |
| 344 | - if(!is_dir($path)) |
|
| 344 | + if (!is_dir($path)) |
|
| 345 | 345 | { |
| 346 | 346 | $oFtp->ftp_mkdir($ftp_path); |
| 347 | 347 | $oFtp->ftp_site("CHMOD 777 " . $ftp_path); |
@@ -360,23 +360,23 @@ discard block |
||
| 360 | 360 | */ |
| 361 | 361 | function removeDir($path) |
| 362 | 362 | { |
| 363 | - if(($path = self::isDir($path)) === FALSE) |
|
| 363 | + if (($path = self::isDir($path)) === FALSE) |
|
| 364 | 364 | { |
| 365 | 365 | return; |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | - if(self::isDir($path)) |
|
| 368 | + if (self::isDir($path)) |
|
| 369 | 369 | { |
| 370 | 370 | $files = array_diff(scandir($path), array('..', '.')); |
| 371 | 371 | |
| 372 | - foreach($files as $file) |
|
| 372 | + foreach ($files as $file) |
|
| 373 | 373 | { |
| 374 | - if(($target = self::getRealPath($path . DIRECTORY_SEPARATOR . $file)) === FALSE) |
|
| 374 | + if (($target = self::getRealPath($path . DIRECTORY_SEPARATOR . $file)) === FALSE) |
|
| 375 | 375 | { |
| 376 | 376 | continue; |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | - if(is_dir($target)) |
|
| 379 | + if (is_dir($target)) |
|
| 380 | 380 | { |
| 381 | 381 | self::removeDir($target); |
| 382 | 382 | } |
@@ -401,22 +401,22 @@ discard block |
||
| 401 | 401 | */ |
| 402 | 402 | function removeBlankDir($path) |
| 403 | 403 | { |
| 404 | - if(($path = self::isDir($path)) === FALSE) |
|
| 404 | + if (($path = self::isDir($path)) === FALSE) |
|
| 405 | 405 | { |
| 406 | 406 | return; |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | $files = array_diff(scandir($path), array('..', '.')); |
| 410 | 410 | |
| 411 | - if(count($files) < 1) |
|
| 411 | + if (count($files) < 1) |
|
| 412 | 412 | { |
| 413 | 413 | rmdir($path); |
| 414 | 414 | return; |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | - foreach($files as $file) |
|
| 417 | + foreach ($files as $file) |
|
| 418 | 418 | { |
| 419 | - if(($target = self::isDir($path . DIRECTORY_SEPARATOR . $file)) === FALSE) |
|
| 419 | + if (($target = self::isDir($path . DIRECTORY_SEPARATOR . $file)) === FALSE) |
|
| 420 | 420 | { |
| 421 | 421 | continue; |
| 422 | 422 | } |
@@ -435,23 +435,23 @@ discard block |
||
| 435 | 435 | */ |
| 436 | 436 | function removeFilesInDir($path) |
| 437 | 437 | { |
| 438 | - if(($path = self::getRealPath($path)) === FALSE) |
|
| 438 | + if (($path = self::getRealPath($path)) === FALSE) |
|
| 439 | 439 | { |
| 440 | 440 | return; |
| 441 | 441 | } |
| 442 | 442 | |
| 443 | - if(is_dir($path)) |
|
| 443 | + if (is_dir($path)) |
|
| 444 | 444 | { |
| 445 | 445 | $files = array_diff(scandir($path), array('..', '.')); |
| 446 | 446 | |
| 447 | - foreach($files as $file) |
|
| 447 | + foreach ($files as $file) |
|
| 448 | 448 | { |
| 449 | - if(($target = self::getRealPath($path . DIRECTORY_SEPARATOR . $file)) === FALSE) |
|
| 449 | + if (($target = self::getRealPath($path . DIRECTORY_SEPARATOR . $file)) === FALSE) |
|
| 450 | 450 | { |
| 451 | 451 | continue; |
| 452 | 452 | } |
| 453 | 453 | |
| 454 | - if(is_dir($target)) |
|
| 454 | + if (is_dir($target)) |
|
| 455 | 455 | { |
| 456 | 456 | self::removeFilesInDir($target); |
| 457 | 457 | } |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | } |
| 464 | 464 | else |
| 465 | 465 | { |
| 466 | - if(self::exists($path)) unlink($path); |
|
| 466 | + if (self::exists($path)) unlink($path); |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | } |
@@ -477,22 +477,22 @@ discard block |
||
| 477 | 477 | */ |
| 478 | 478 | function filesize($size) |
| 479 | 479 | { |
| 480 | - if(!$size) |
|
| 480 | + if (!$size) |
|
| 481 | 481 | { |
| 482 | 482 | return '0Byte'; |
| 483 | 483 | } |
| 484 | 484 | |
| 485 | - if($size === 1) |
|
| 485 | + if ($size === 1) |
|
| 486 | 486 | { |
| 487 | 487 | return '1Byte'; |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | - if($size < 1024) |
|
| 490 | + if ($size < 1024) |
|
| 491 | 491 | { |
| 492 | 492 | return $size . 'Bytes'; |
| 493 | 493 | } |
| 494 | 494 | |
| 495 | - if($size >= 1024 && $size < 1024 * 1024) |
|
| 495 | + if ($size >= 1024 && $size < 1024 * 1024) |
|
| 496 | 496 | { |
| 497 | 497 | return sprintf("%0.1fKB", $size / 1024); |
| 498 | 498 | } |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | require_once('HTTP/Request.php'); |
| 524 | 524 | |
| 525 | 525 | $parsed_url = parse_url(__PROXY_SERVER__); |
| 526 | - if($parsed_url["host"]) |
|
| 526 | + if ($parsed_url["host"]) |
|
| 527 | 527 | { |
| 528 | 528 | $oRequest = new HTTP_Request(__PROXY_SERVER__); |
| 529 | 529 | $oRequest->setMethod('POST'); |
@@ -533,49 +533,49 @@ discard block |
||
| 533 | 533 | { |
| 534 | 534 | $oRequest = new HTTP_Request($url); |
| 535 | 535 | |
| 536 | - if(count($request_config) && method_exists($oRequest, 'setConfig')) |
|
| 536 | + if (count($request_config) && method_exists($oRequest, 'setConfig')) |
|
| 537 | 537 | { |
| 538 | - foreach($request_config as $key=>$val) |
|
| 538 | + foreach ($request_config as $key=>$val) |
|
| 539 | 539 | { |
| 540 | 540 | $oRequest->setConfig($key, $val); |
| 541 | 541 | } |
| 542 | 542 | } |
| 543 | 543 | |
| 544 | - if(count($headers) > 0) |
|
| 544 | + if (count($headers) > 0) |
|
| 545 | 545 | { |
| 546 | - foreach($headers as $key => $val) |
|
| 546 | + foreach ($headers as $key => $val) |
|
| 547 | 547 | { |
| 548 | 548 | $oRequest->addHeader($key, $val); |
| 549 | 549 | } |
| 550 | 550 | } |
| 551 | - if($cookies[$host]) |
|
| 551 | + if ($cookies[$host]) |
|
| 552 | 552 | { |
| 553 | - foreach($cookies[$host] as $key => $val) |
|
| 553 | + foreach ($cookies[$host] as $key => $val) |
|
| 554 | 554 | { |
| 555 | 555 | $oRequest->addCookie($key, $val); |
| 556 | 556 | } |
| 557 | 557 | } |
| 558 | - if(count($post_data) > 0) |
|
| 558 | + if (count($post_data) > 0) |
|
| 559 | 559 | { |
| 560 | - foreach($post_data as $key => $val) |
|
| 560 | + foreach ($post_data as $key => $val) |
|
| 561 | 561 | { |
| 562 | 562 | $oRequest->addPostData($key, $val); |
| 563 | 563 | } |
| 564 | 564 | } |
| 565 | - if(!$content_type) |
|
| 565 | + if (!$content_type) |
|
| 566 | 566 | $oRequest->addHeader('Content-Type', 'text/html'); |
| 567 | 567 | else |
| 568 | 568 | $oRequest->addHeader('Content-Type', $content_type); |
| 569 | 569 | $oRequest->setMethod($method); |
| 570 | - if($body) |
|
| 570 | + if ($body) |
|
| 571 | 571 | $oRequest->setBody($body); |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | - if(method_exists($oRequest, 'setConfig')) |
|
| 574 | + if (method_exists($oRequest, 'setConfig')) |
|
| 575 | 575 | { |
| 576 | 576 | $oRequest->setConfig('timeout', $timeout); |
| 577 | 577 | } |
| 578 | - elseif(property_exists($oRequest, '_timeout')) |
|
| 578 | + elseif (property_exists($oRequest, '_timeout')) |
|
| 579 | 579 | { |
| 580 | 580 | $oRequest->_timeout = $timeout; |
| 581 | 581 | } |
@@ -585,25 +585,25 @@ discard block |
||
| 585 | 585 | $code = $oRequest->getResponseCode(); |
| 586 | 586 | $header = $oRequest->getResponseHeader(); |
| 587 | 587 | $response = $oRequest->getResponseBody(); |
| 588 | - if($c = $oRequest->getResponseCookies()) |
|
| 588 | + if ($c = $oRequest->getResponseCookies()) |
|
| 589 | 589 | { |
| 590 | - foreach($c as $k => $v) |
|
| 590 | + foreach ($c as $k => $v) |
|
| 591 | 591 | { |
| 592 | 592 | $cookies[$host][$v['name']] = $v['value']; |
| 593 | 593 | } |
| 594 | 594 | } |
| 595 | 595 | |
| 596 | - if($code > 300 && $code < 399 && $header['location']) |
|
| 596 | + if ($code > 300 && $code < 399 && $header['location']) |
|
| 597 | 597 | { |
| 598 | 598 | return self::getRemoteResource($header['location'], $body, $timeout, $method, $content_type, $headers, $cookies, $post_data); |
| 599 | 599 | } |
| 600 | 600 | |
| 601 | - if($code != 200) |
|
| 601 | + if ($code != 200) |
|
| 602 | 602 | return; |
| 603 | 603 | |
| 604 | 604 | return $response; |
| 605 | 605 | } |
| 606 | - catch(Exception $e) |
|
| 606 | + catch (Exception $e) |
|
| 607 | 607 | { |
| 608 | 608 | return NULL; |
| 609 | 609 | } |
@@ -623,7 +623,7 @@ discard block |
||
| 623 | 623 | */ |
| 624 | 624 | function getRemoteFile($url, $target_filename, $body = null, $timeout = 3, $method = 'GET', $content_type = null, $headers = array(), $cookies = array(), $post_data = array(), $request_config = array()) |
| 625 | 625 | { |
| 626 | - if(!($body = self::getRemoteResource($url, $body, $timeout, $method, $content_type, $headers,$cookies,$post_data,$request_config))) |
|
| 626 | + if (!($body = self::getRemoteResource($url, $body, $timeout, $method, $content_type, $headers, $cookies, $post_data, $request_config))) |
|
| 627 | 627 | { |
| 628 | 628 | return FALSE; |
| 629 | 629 | } |
@@ -642,7 +642,7 @@ discard block |
||
| 642 | 642 | function returnBytes($val) |
| 643 | 643 | { |
| 644 | 644 | $unit = strtoupper(substr($val, -1)); |
| 645 | - $val = (float)$val; |
|
| 645 | + $val = (float) $val; |
|
| 646 | 646 | |
| 647 | 647 | switch ($unit) |
| 648 | 648 | { |
@@ -665,13 +665,13 @@ discard block |
||
| 665 | 665 | $K64 = 65536; |
| 666 | 666 | $TWEAKFACTOR = 2.0; |
| 667 | 667 | $channels = $imageInfo['channels']; |
| 668 | - if(!$channels) |
|
| 668 | + if (!$channels) |
|
| 669 | 669 | { |
| 670 | 670 | $channels = 6; //for png |
| 671 | 671 | } |
| 672 | - $memoryNeeded = round(($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $channels / 8 + $K64 ) * $TWEAKFACTOR); |
|
| 672 | + $memoryNeeded = round(($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $channels / 8 + $K64) * $TWEAKFACTOR); |
|
| 673 | 673 | $availableMemory = self::returnBytes(ini_get('memory_limit')) - memory_get_usage(); |
| 674 | - if($availableMemory < $memoryNeeded) |
|
| 674 | + if ($availableMemory < $memoryNeeded) |
|
| 675 | 675 | { |
| 676 | 676 | return FALSE; |
| 677 | 677 | } |
@@ -698,30 +698,30 @@ discard block |
||
| 698 | 698 | } |
| 699 | 699 | |
| 700 | 700 | $target_file = self::getRealPath($target_file); |
| 701 | - if(!$resize_width) |
|
| 701 | + if (!$resize_width) |
|
| 702 | 702 | { |
| 703 | 703 | $resize_width = 100; |
| 704 | 704 | } |
| 705 | 705 | |
| 706 | - if(!$resize_height) |
|
| 706 | + if (!$resize_height) |
|
| 707 | 707 | { |
| 708 | 708 | $resize_height = $resize_width; |
| 709 | 709 | } |
| 710 | 710 | |
| 711 | 711 | // retrieve source image's information |
| 712 | 712 | $imageInfo = getimagesize($source_file); |
| 713 | - if(!self::checkMemoryLoadImage($imageInfo)) |
|
| 713 | + if (!self::checkMemoryLoadImage($imageInfo)) |
|
| 714 | 714 | { |
| 715 | 715 | return FALSE; |
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | list($width, $height, $type, $attrs) = $imageInfo; |
| 719 | - if($width < 1 || $height < 1) |
|
| 719 | + if ($width < 1 || $height < 1) |
|
| 720 | 720 | { |
| 721 | 721 | return; |
| 722 | 722 | } |
| 723 | 723 | |
| 724 | - switch($type) |
|
| 724 | + switch ($type) |
|
| 725 | 725 | { |
| 726 | 726 | case '1' : |
| 727 | 727 | $type = 'gif'; |
@@ -739,7 +739,7 @@ discard block |
||
| 739 | 739 | return; |
| 740 | 740 | } |
| 741 | 741 | |
| 742 | - if(!$target_type) |
|
| 742 | + if (!$target_type) |
|
| 743 | 743 | { |
| 744 | 744 | $target_type = $type; |
| 745 | 745 | } |
@@ -750,7 +750,7 @@ discard block |
||
| 750 | 750 | $height_per = ($resize_height > 0 && $height >= $resize_height) ? $resize_height / $height : 1; |
| 751 | 751 | |
| 752 | 752 | $per = NULL; |
| 753 | - if($thumbnail_type == 'ratio') |
|
| 753 | + if ($thumbnail_type == 'ratio') |
|
| 754 | 754 | { |
| 755 | 755 | $per = ($width_per > $height_per) ? $height_per : $width_per; |
| 756 | 756 | $resize_width = $width * $per; |
@@ -763,16 +763,16 @@ discard block |
||
| 763 | 763 | |
| 764 | 764 | // create temporary image with target size |
| 765 | 765 | $thumb = NULL; |
| 766 | - if(function_exists('imagecreateTRUEcolor')) |
|
| 766 | + if (function_exists('imagecreateTRUEcolor')) |
|
| 767 | 767 | { |
| 768 | 768 | $thumb = imagecreateTRUEcolor($resize_width, $resize_height); |
| 769 | 769 | } |
| 770 | - else if(function_exists('imagecreate')) |
|
| 770 | + else if (function_exists('imagecreate')) |
|
| 771 | 771 | { |
| 772 | 772 | $thumb = imagecreate($resize_width, $resize_height); |
| 773 | 773 | } |
| 774 | 774 | |
| 775 | - if(!$thumb) |
|
| 775 | + if (!$thumb) |
|
| 776 | 776 | { |
| 777 | 777 | return FALSE; |
| 778 | 778 | } |
@@ -781,37 +781,37 @@ discard block |
||
| 781 | 781 | |
| 782 | 782 | // create temporary image having original type |
| 783 | 783 | $source = NULL; |
| 784 | - switch($type) |
|
| 784 | + switch ($type) |
|
| 785 | 785 | { |
| 786 | 786 | case 'gif' : |
| 787 | - if(function_exists('imagecreatefromgif')) |
|
| 787 | + if (function_exists('imagecreatefromgif')) |
|
| 788 | 788 | { |
| 789 | 789 | $source = @imagecreatefromgif($source_file); |
| 790 | 790 | } |
| 791 | 791 | break; |
| 792 | 792 | case 'jpeg' : |
| 793 | 793 | case 'jpg' : |
| 794 | - if(function_exists('imagecreatefromjpeg')) |
|
| 794 | + if (function_exists('imagecreatefromjpeg')) |
|
| 795 | 795 | { |
| 796 | 796 | $source = @imagecreatefromjpeg($source_file); |
| 797 | 797 | } |
| 798 | 798 | break; |
| 799 | 799 | case 'png' : |
| 800 | - if(function_exists('imagecreatefrompng')) |
|
| 800 | + if (function_exists('imagecreatefrompng')) |
|
| 801 | 801 | { |
| 802 | 802 | $source = @imagecreatefrompng($source_file); |
| 803 | 803 | } |
| 804 | 804 | break; |
| 805 | 805 | case 'wbmp' : |
| 806 | 806 | case 'bmp' : |
| 807 | - if(function_exists('imagecreatefromwbmp')) |
|
| 807 | + if (function_exists('imagecreatefromwbmp')) |
|
| 808 | 808 | { |
| 809 | 809 | $source = @imagecreatefromwbmp($source_file); |
| 810 | 810 | } |
| 811 | 811 | break; |
| 812 | 812 | } |
| 813 | 813 | |
| 814 | - if(!$source) |
|
| 814 | + if (!$source) |
|
| 815 | 815 | { |
| 816 | 816 | imagedestroy($thumb); |
| 817 | 817 | return FALSE; |
@@ -823,13 +823,13 @@ discard block |
||
| 823 | 823 | |
| 824 | 824 | $x = 0; |
| 825 | 825 | $y = 0; |
| 826 | - if($thumbnail_type == 'crop') |
|
| 826 | + if ($thumbnail_type == 'crop') |
|
| 827 | 827 | { |
| 828 | 828 | $x = (int) ($resize_width / 2 - $new_width / 2); |
| 829 | 829 | $y = (int) ($resize_height / 2 - $new_height / 2); |
| 830 | 830 | } |
| 831 | 831 | |
| 832 | - if(function_exists('imagecopyresampled')) |
|
| 832 | + if (function_exists('imagecopyresampled')) |
|
| 833 | 833 | { |
| 834 | 834 | imagecopyresampled($thumb, $source, $x, $y, 0, 0, $new_width, $new_height, $width, $height); |
| 835 | 835 | } |
@@ -843,30 +843,30 @@ discard block |
||
| 843 | 843 | |
| 844 | 844 | // write into the file |
| 845 | 845 | $output = NULL; |
| 846 | - switch($target_type) |
|
| 846 | + switch ($target_type) |
|
| 847 | 847 | { |
| 848 | 848 | case 'gif' : |
| 849 | - if(function_exists('imagegif')) |
|
| 849 | + if (function_exists('imagegif')) |
|
| 850 | 850 | { |
| 851 | 851 | $output = imagegif($thumb, $target_file); |
| 852 | 852 | } |
| 853 | 853 | break; |
| 854 | 854 | case 'jpeg' : |
| 855 | 855 | case 'jpg' : |
| 856 | - if(function_exists('imagejpeg')) |
|
| 856 | + if (function_exists('imagejpeg')) |
|
| 857 | 857 | { |
| 858 | 858 | $output = imagejpeg($thumb, $target_file, 100); |
| 859 | 859 | } |
| 860 | 860 | break; |
| 861 | 861 | case 'png' : |
| 862 | - if(function_exists('imagepng')) |
|
| 862 | + if (function_exists('imagepng')) |
|
| 863 | 863 | { |
| 864 | 864 | $output = imagepng($thumb, $target_file, 9); |
| 865 | 865 | } |
| 866 | 866 | break; |
| 867 | 867 | case 'wbmp' : |
| 868 | 868 | case 'bmp' : |
| 869 | - if(function_exists('imagewbmp')) |
|
| 869 | + if (function_exists('imagewbmp')) |
|
| 870 | 870 | { |
| 871 | 871 | $output = imagewbmp($thumb, $target_file, 100); |
| 872 | 872 | } |
@@ -876,7 +876,7 @@ discard block |
||
| 876 | 876 | imagedestroy($thumb); |
| 877 | 877 | imagedestroy($source); |
| 878 | 878 | |
| 879 | - if(!$output) |
|
| 879 | + if (!$output) |
|
| 880 | 880 | { |
| 881 | 881 | return FALSE; |
| 882 | 882 | } |
@@ -894,12 +894,12 @@ discard block |
||
| 894 | 894 | */ |
| 895 | 895 | function readIniFile($filename) |
| 896 | 896 | { |
| 897 | - if(($filename = self::exists($filename)) === FALSE) |
|
| 897 | + if (($filename = self::exists($filename)) === FALSE) |
|
| 898 | 898 | { |
| 899 | 899 | return FALSE; |
| 900 | 900 | } |
| 901 | 901 | $arr = parse_ini_file($filename, TRUE); |
| 902 | - if(is_array($arr) && count($arr) > 0) |
|
| 902 | + if (is_array($arr) && count($arr) > 0) |
|
| 903 | 903 | { |
| 904 | 904 | return $arr; |
| 905 | 905 | } |
@@ -925,7 +925,7 @@ discard block |
||
| 925 | 925 | */ |
| 926 | 926 | function writeIniFile($filename, $arr) |
| 927 | 927 | { |
| 928 | - if(!is_array($arr) || count($arr) == 0) |
|
| 928 | + if (!is_array($arr) || count($arr) == 0) |
|
| 929 | 929 | { |
| 930 | 930 | return FALSE; |
| 931 | 931 | } |
@@ -942,19 +942,19 @@ discard block |
||
| 942 | 942 | function _makeIniBuff($arr) |
| 943 | 943 | { |
| 944 | 944 | $return = array(); |
| 945 | - foreach($arr as $key => $val) |
|
| 945 | + foreach ($arr as $key => $val) |
|
| 946 | 946 | { |
| 947 | 947 | // section |
| 948 | - if(is_array($val)) |
|
| 948 | + if (is_array($val)) |
|
| 949 | 949 | { |
| 950 | 950 | $return[] = sprintf("[%s]", $key); |
| 951 | - foreach($val as $k => $v) |
|
| 951 | + foreach ($val as $k => $v) |
|
| 952 | 952 | { |
| 953 | 953 | $return[] = sprintf("%s=\"%s\"", $k, $v); |
| 954 | 954 | } |
| 955 | 955 | // value |
| 956 | 956 | } |
| 957 | - else if(is_object($val)) |
|
| 957 | + else if (is_object($val)) |
|
| 958 | 958 | { |
| 959 | 959 | continue; |
| 960 | 960 | } |
@@ -1029,7 +1029,7 @@ discard block |
||
| 1029 | 1029 | function isWritableDir($path) |
| 1030 | 1030 | { |
| 1031 | 1031 | $path = self::getRealPath($path); |
| 1032 | - if(is_dir($path)==FALSE) |
|
| 1032 | + if (is_dir($path) == FALSE) |
|
| 1033 | 1033 | { |
| 1034 | 1034 | return FALSE; |
| 1035 | 1035 | } |
@@ -1037,7 +1037,7 @@ discard block |
||
| 1037 | 1037 | $checkFile = $path . '/_CheckWritableDir'; |
| 1038 | 1038 | |
| 1039 | 1039 | $fp = fopen($checkFile, 'w'); |
| 1040 | - if(!is_resource($fp)) |
|
| 1040 | + if (!is_resource($fp)) |
|
| 1041 | 1041 | { |
| 1042 | 1042 | return FALSE; |
| 1043 | 1043 | } |
@@ -74,14 +74,12 @@ discard block |
||
| 74 | 74 | if(is_dir($source_dir . $file)) |
| 75 | 75 | { |
| 76 | 76 | self::copyDir($source_dir . $file, $target_dir . $file, $type); |
| 77 | - } |
|
| 78 | - else |
|
| 77 | + } else |
|
| 79 | 78 | { |
| 80 | 79 | if($type == 'force') |
| 81 | 80 | { |
| 82 | 81 | @unlink($target_dir . $file); |
| 83 | - } |
|
| 84 | - else |
|
| 82 | + } else |
|
| 85 | 83 | { |
| 86 | 84 | if(!file_exists($target_dir . $file)) |
| 87 | 85 | { |
@@ -379,15 +377,13 @@ discard block |
||
| 379 | 377 | if(is_dir($target)) |
| 380 | 378 | { |
| 381 | 379 | self::removeDir($target); |
| 382 | - } |
|
| 383 | - else |
|
| 380 | + } else |
|
| 384 | 381 | { |
| 385 | 382 | unlink($target); |
| 386 | 383 | } |
| 387 | 384 | } |
| 388 | 385 | rmdir($path); |
| 389 | - } |
|
| 390 | - else |
|
| 386 | + } else |
|
| 391 | 387 | { |
| 392 | 388 | unlink($path); |
| 393 | 389 | } |
@@ -454,16 +450,16 @@ discard block |
||
| 454 | 450 | if(is_dir($target)) |
| 455 | 451 | { |
| 456 | 452 | self::removeFilesInDir($target); |
| 457 | - } |
|
| 458 | - else |
|
| 453 | + } else |
|
| 459 | 454 | { |
| 460 | 455 | unlink($target); |
| 461 | 456 | } |
| 462 | 457 | } |
| 463 | - } |
|
| 464 | - else |
|
| 458 | + } else |
|
| 465 | 459 | { |
| 466 | - if(self::exists($path)) unlink($path); |
|
| 460 | + if(self::exists($path)) { |
|
| 461 | + unlink($path); |
|
| 462 | + } |
|
| 467 | 463 | } |
| 468 | 464 | |
| 469 | 465 | } |
@@ -528,8 +524,7 @@ discard block |
||
| 528 | 524 | $oRequest = new HTTP_Request(__PROXY_SERVER__); |
| 529 | 525 | $oRequest->setMethod('POST'); |
| 530 | 526 | $oRequest->addPostData('arg', serialize(array('Destination' => $url, 'method' => $method, 'body' => $body, 'content_type' => $content_type, "headers" => $headers, "post_data" => $post_data))); |
| 531 | - } |
|
| 532 | - else |
|
| 527 | + } else |
|
| 533 | 528 | { |
| 534 | 529 | $oRequest = new HTTP_Request($url); |
| 535 | 530 | |
@@ -562,20 +557,21 @@ discard block |
||
| 562 | 557 | $oRequest->addPostData($key, $val); |
| 563 | 558 | } |
| 564 | 559 | } |
| 565 | - if(!$content_type) |
|
| 566 | - $oRequest->addHeader('Content-Type', 'text/html'); |
|
| 567 | - else |
|
| 568 | - $oRequest->addHeader('Content-Type', $content_type); |
|
| 560 | + if(!$content_type) { |
|
| 561 | + $oRequest->addHeader('Content-Type', 'text/html'); |
|
| 562 | + } else { |
|
| 563 | + $oRequest->addHeader('Content-Type', $content_type); |
|
| 564 | + } |
|
| 569 | 565 | $oRequest->setMethod($method); |
| 570 | - if($body) |
|
| 571 | - $oRequest->setBody($body); |
|
| 566 | + if($body) { |
|
| 567 | + $oRequest->setBody($body); |
|
| 568 | + } |
|
| 572 | 569 | } |
| 573 | 570 | |
| 574 | 571 | if(method_exists($oRequest, 'setConfig')) |
| 575 | 572 | { |
| 576 | 573 | $oRequest->setConfig('timeout', $timeout); |
| 577 | - } |
|
| 578 | - elseif(property_exists($oRequest, '_timeout')) |
|
| 574 | + } elseif(property_exists($oRequest, '_timeout')) |
|
| 579 | 575 | { |
| 580 | 576 | $oRequest->_timeout = $timeout; |
| 581 | 577 | } |
@@ -598,12 +594,12 @@ discard block |
||
| 598 | 594 | return self::getRemoteResource($header['location'], $body, $timeout, $method, $content_type, $headers, $cookies, $post_data); |
| 599 | 595 | } |
| 600 | 596 | |
| 601 | - if($code != 200) |
|
| 602 | - return; |
|
| 597 | + if($code != 200) { |
|
| 598 | + return; |
|
| 599 | + } |
|
| 603 | 600 | |
| 604 | 601 | return $response; |
| 605 | - } |
|
| 606 | - catch(Exception $e) |
|
| 602 | + } catch(Exception $e) |
|
| 607 | 603 | { |
| 608 | 604 | return NULL; |
| 609 | 605 | } |
@@ -755,8 +751,7 @@ discard block |
||
| 755 | 751 | $per = ($width_per > $height_per) ? $height_per : $width_per; |
| 756 | 752 | $resize_width = $width * $per; |
| 757 | 753 | $resize_height = $height * $per; |
| 758 | - } |
|
| 759 | - else |
|
| 754 | + } else |
|
| 760 | 755 | { |
| 761 | 756 | $per = ($width_per < $height_per) ? $height_per : $width_per; |
| 762 | 757 | } |
@@ -766,8 +761,7 @@ discard block |
||
| 766 | 761 | if(function_exists('imagecreateTRUEcolor')) |
| 767 | 762 | { |
| 768 | 763 | $thumb = imagecreateTRUEcolor($resize_width, $resize_height); |
| 769 | - } |
|
| 770 | - else if(function_exists('imagecreate')) |
|
| 764 | + } else if(function_exists('imagecreate')) |
|
| 771 | 765 | { |
| 772 | 766 | $thumb = imagecreate($resize_width, $resize_height); |
| 773 | 767 | } |
@@ -832,8 +826,7 @@ discard block |
||
| 832 | 826 | if(function_exists('imagecopyresampled')) |
| 833 | 827 | { |
| 834 | 828 | imagecopyresampled($thumb, $source, $x, $y, 0, 0, $new_width, $new_height, $width, $height); |
| 835 | - } |
|
| 836 | - else |
|
| 829 | + } else |
|
| 837 | 830 | { |
| 838 | 831 | imagecopyresized($thumb, $source, $x, $y, 0, 0, $new_width, $new_height, $width, $height); |
| 839 | 832 | } |
@@ -902,8 +895,7 @@ discard block |
||
| 902 | 895 | if(is_array($arr) && count($arr) > 0) |
| 903 | 896 | { |
| 904 | 897 | return $arr; |
| 905 | - } |
|
| 906 | - else |
|
| 898 | + } else |
|
| 907 | 899 | { |
| 908 | 900 | return array(); |
| 909 | 901 | } |
@@ -953,12 +945,10 @@ discard block |
||
| 953 | 945 | $return[] = sprintf("%s=\"%s\"", $k, $v); |
| 954 | 946 | } |
| 955 | 947 | // value |
| 956 | - } |
|
| 957 | - else if(is_object($val)) |
|
| 948 | + } else if(is_object($val)) |
|
| 958 | 949 | { |
| 959 | 950 | continue; |
| 960 | - } |
|
| 961 | - else |
|
| 951 | + } else |
|
| 962 | 952 | { |
| 963 | 953 | $return[] = sprintf("%s=\"%s\"", $key, $val); |
| 964 | 954 | } |
@@ -393,7 +393,7 @@ |
||
| 393 | 393 | * Arrage css index |
| 394 | 394 | * |
| 395 | 395 | * @param string $dirName First directory name of css path |
| 396 | - * @param array $file file info. |
|
| 396 | + * @param stdClass $file file info. |
|
| 397 | 397 | * @return void |
| 398 | 398 | */ |
| 399 | 399 | function _arrangeCssIndex($dirName, &$file) |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | * Check SSL |
| 51 | 51 | * |
| 52 | 52 | * @return bool If using ssl returns true, otherwise returns false. |
| 53 | - * @deprecated |
|
| 53 | + * @deprecated |
|
| 54 | 54 | */ |
| 55 | 55 | function isSsl() |
| 56 | 56 | {
|
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | function isSsl() |
| 56 | 56 | {
|
| 57 | - if(!is_null(self::$isSSL)) |
|
| 57 | + if (!is_null(self::$isSSL)) |
|
| 58 | 58 | {
|
| 59 | 59 | return self::$isSSL; |
| 60 | 60 | } |
@@ -88,30 +88,30 @@ discard block |
||
| 88 | 88 | * */ |
| 89 | 89 | function loadFile($args) |
| 90 | 90 | {
|
| 91 | - if(!is_array($args)) |
|
| 91 | + if (!is_array($args)) |
|
| 92 | 92 | {
|
| 93 | 93 | $args = array($args); |
| 94 | 94 | } |
| 95 | 95 | $file = $this->getFileInfo($args[0], $args[2], $args[1]); |
| 96 | 96 | |
| 97 | 97 | $availableExtension = array('css' => 1, 'js' => 1);
|
| 98 | - if(!isset($availableExtension[$file->fileExtension])) |
|
| 98 | + if (!isset($availableExtension[$file->fileExtension])) |
|
| 99 | 99 | {
|
| 100 | 100 | return; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | $file->index = (int) $args[3]; |
| 104 | 104 | |
| 105 | - if($file->fileExtension == 'css') |
|
| 105 | + if ($file->fileExtension == 'css') |
|
| 106 | 106 | {
|
| 107 | 107 | $map = &$this->cssMap; |
| 108 | 108 | $mapIndex = &$this->cssMapIndex; |
| 109 | 109 | |
| 110 | 110 | $this->_arrangeCssIndex($pathInfo['dirname'], $file); |
| 111 | 111 | } |
| 112 | - else if($file->fileExtension == 'js') |
|
| 112 | + else if ($file->fileExtension == 'js') |
|
| 113 | 113 | {
|
| 114 | - if($args[1] == 'body') |
|
| 114 | + if ($args[1] == 'body') |
|
| 115 | 115 | {
|
| 116 | 116 | $map = &$this->jsBodyMap; |
| 117 | 117 | $mapIndex = &$this->jsBodyMapIndex; |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | (is_null($file->index)) ? $file->index = 0 : $file->index = $file->index; |
| 127 | - if(!isset($mapIndex[$file->key]) || $mapIndex[$file->key] > $file->index) |
|
| 127 | + if (!isset($mapIndex[$file->key]) || $mapIndex[$file->key] > $file->index) |
|
| 128 | 128 | {
|
| 129 | 129 | $this->unloadFile($args[0], $args[2], $args[1]); |
| 130 | 130 | $map[$file->index][$file->key] = $file; |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | {
|
| 145 | 145 | static $existsInfo = array(); |
| 146 | 146 | |
| 147 | - if(isset($existsInfo[$existsKey])) |
|
| 147 | + if (isset($existsInfo[$existsKey])) |
|
| 148 | 148 | {
|
| 149 | 149 | return $existsInfo[$existsKey]; |
| 150 | 150 | } |
@@ -159,14 +159,14 @@ discard block |
||
| 159 | 159 | $file->keyName = implode('.', array($file->fileNameNoExt, $file->fileExtension));
|
| 160 | 160 | $file->cdnPath = $this->_normalizeFilePath($pathInfo['dirname']); |
| 161 | 161 | |
| 162 | - if(strpos($file->filePath, '://') === FALSE) |
|
| 162 | + if (strpos($file->filePath, '://') === FALSE) |
|
| 163 | 163 | {
|
| 164 | - if(!__DEBUG__ && __XE_VERSION_STABLE__) |
|
| 164 | + if (!__DEBUG__ && __XE_VERSION_STABLE__) |
|
| 165 | 165 | {
|
| 166 | 166 | // if no debug mode, load minifed file |
| 167 | 167 | $minifiedFileName = implode('.', array($file->fileNameNoExt, 'min', $file->fileExtension));
|
| 168 | 168 | $minifiedRealPath = implode('/', array($file->fileRealPath, $minifiedFileName));
|
| 169 | - if(file_exists($minifiedRealPath)) |
|
| 169 | + if (file_exists($minifiedRealPath)) |
|
| 170 | 170 | {
|
| 171 | 171 | $file->fileName = $minifiedFileName; |
| 172 | 172 | } |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | else |
| 175 | 175 | {
|
| 176 | 176 | // Remove .min |
| 177 | - if(file_exists(implode('/', array($file->fileRealPath, $file->keyName))))
|
|
| 177 | + if (file_exists(implode('/', array($file->fileRealPath, $file->keyName))))
|
|
| 178 | 178 | {
|
| 179 | 179 | $file->fileName = $file->keyName; |
| 180 | 180 | } |
@@ -183,16 +183,16 @@ discard block |
||
| 183 | 183 | |
| 184 | 184 | $file->targetIe = $targetIe; |
| 185 | 185 | |
| 186 | - if($file->fileExtension == 'css') |
|
| 186 | + if ($file->fileExtension == 'css') |
|
| 187 | 187 | {
|
| 188 | 188 | $file->media = $media; |
| 189 | - if(!$file->media) |
|
| 189 | + if (!$file->media) |
|
| 190 | 190 | {
|
| 191 | 191 | $file->media = 'all'; |
| 192 | 192 | } |
| 193 | 193 | $file->key = $file->filePath . $file->keyName . "\t" . $file->targetIe . "\t" . $file->media; |
| 194 | 194 | } |
| 195 | - else if($file->fileExtension == 'js') |
|
| 195 | + else if ($file->fileExtension == 'js') |
|
| 196 | 196 | {
|
| 197 | 197 | $file->key = $file->filePath . $file->keyName . "\t" . $file->targetIe; |
| 198 | 198 | } |
@@ -212,9 +212,9 @@ discard block |
||
| 212 | 212 | {
|
| 213 | 213 | $file = $this->getFileInfo($fileName, $targetIe, $media); |
| 214 | 214 | |
| 215 | - if($file->fileExtension == 'css') |
|
| 215 | + if ($file->fileExtension == 'css') |
|
| 216 | 216 | {
|
| 217 | - if(isset($this->cssMapIndex[$file->key])) |
|
| 217 | + if (isset($this->cssMapIndex[$file->key])) |
|
| 218 | 218 | {
|
| 219 | 219 | $index = $this->cssMapIndex[$file->key]; |
| 220 | 220 | unset($this->cssMap[$index][$file->key], $this->cssMapIndex[$file->key]); |
@@ -222,12 +222,12 @@ discard block |
||
| 222 | 222 | } |
| 223 | 223 | else |
| 224 | 224 | {
|
| 225 | - if(isset($this->jsHeadMapIndex[$file->key])) |
|
| 225 | + if (isset($this->jsHeadMapIndex[$file->key])) |
|
| 226 | 226 | {
|
| 227 | 227 | $index = $this->jsHeadMapIndex[$file->key]; |
| 228 | 228 | unset($this->jsHeadMap[$index][$file->key], $this->jsHeadMapIndex[$file->key]); |
| 229 | 229 | } |
| 230 | - if(isset($this->jsBodyMapIndex[$file->key])) |
|
| 230 | + if (isset($this->jsBodyMapIndex[$file->key])) |
|
| 231 | 231 | {
|
| 232 | 232 | $index = $this->jsBodyMapIndex[$file->key]; |
| 233 | 233 | unset($this->jsBodyMap[$index][$file->key], $this->jsBodyMapIndex[$file->key]); |
@@ -243,13 +243,13 @@ discard block |
||
| 243 | 243 | */ |
| 244 | 244 | function unloadAllFiles($type = 'all') |
| 245 | 245 | {
|
| 246 | - if($type == 'css' || $type == 'all') |
|
| 246 | + if ($type == 'css' || $type == 'all') |
|
| 247 | 247 | {
|
| 248 | 248 | $this->cssMap = array(); |
| 249 | 249 | $this->cssMapIndex = array(); |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - if($type == 'js' || $type == 'all') |
|
| 252 | + if ($type == 'js' || $type == 'all') |
|
| 253 | 253 | {
|
| 254 | 254 | $this->jsHeadMap = array(); |
| 255 | 255 | $this->jsBodyMap = array(); |
@@ -271,9 +271,9 @@ discard block |
||
| 271 | 271 | $this->_sortMap($map, $mapIndex); |
| 272 | 272 | |
| 273 | 273 | $result = array(); |
| 274 | - foreach($map as $indexedMap) |
|
| 274 | + foreach ($map as $indexedMap) |
|
| 275 | 275 | {
|
| 276 | - foreach($indexedMap as $file) |
|
| 276 | + foreach ($indexedMap as $file) |
|
| 277 | 277 | {
|
| 278 | 278 | $noneCache = (is_readable($file->cdnPath . '/' . $file->fileName)) ? '?' . date('YmdHis', filemtime($file->cdnPath . '/' . $file->fileName)) : '';
|
| 279 | 279 | $fullFilePath = $file->filePath . '/' . $file->fileName . $noneCache; |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | */ |
| 294 | 294 | function getJsFileList($type = 'head') |
| 295 | 295 | {
|
| 296 | - if($type == 'head') |
|
| 296 | + if ($type == 'head') |
|
| 297 | 297 | {
|
| 298 | 298 | $map = &$this->jsHeadMap; |
| 299 | 299 | $mapIndex = &$this->jsHeadMapIndex; |
@@ -307,9 +307,9 @@ discard block |
||
| 307 | 307 | $this->_sortMap($map, $mapIndex); |
| 308 | 308 | |
| 309 | 309 | $result = array(); |
| 310 | - foreach($map as $indexedMap) |
|
| 310 | + foreach ($map as $indexedMap) |
|
| 311 | 311 | {
|
| 312 | - foreach($indexedMap as $file) |
|
| 312 | + foreach ($indexedMap as $file) |
|
| 313 | 313 | {
|
| 314 | 314 | $noneCache = (is_readable($file->cdnPath . '/' . $file->fileName)) ? '?' . date('YmdHis', filemtime($file->cdnPath . '/' . $file->fileName)) : '';
|
| 315 | 315 | $fullFilePath = $file->filePath . '/' . $file->fileName . $noneCache; |
@@ -341,18 +341,18 @@ discard block |
||
| 341 | 341 | */ |
| 342 | 342 | function _normalizeFilePath($path) |
| 343 | 343 | {
|
| 344 | - if(strpos($path, '://') === FALSE && $path{0} != '/' && $path{0} != '.')
|
|
| 344 | + if (strpos($path, '://') === FALSE && $path{0} != '/' && $path{0} != '.')
|
|
| 345 | 345 | {
|
| 346 | 346 | $path = './' . $path; |
| 347 | 347 | } |
| 348 | - elseif(!strncmp($path, '//', 2)) |
|
| 348 | + elseif (!strncmp($path, '//', 2)) |
|
| 349 | 349 | {
|
| 350 | 350 | return preg_replace('#^//+#', '//', $path);
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | $path = preg_replace('@/\./|(?<!:)\/\/@', '/', $path);
|
| 354 | 354 | |
| 355 | - while(strpos($path, '/../')) |
|
| 355 | + while (strpos($path, '/../')) |
|
| 356 | 356 | {
|
| 357 | 357 | $path = preg_replace('/\/([^\/]+)\/\.\.\//s', '/', $path, 1);
|
| 358 | 358 | } |
@@ -370,9 +370,9 @@ discard block |
||
| 370 | 370 | {
|
| 371 | 371 | $path = $this->_normalizeFilePath($path); |
| 372 | 372 | |
| 373 | - if(strpos($path, './') === 0) |
|
| 373 | + if (strpos($path, './') === 0) |
|
| 374 | 374 | {
|
| 375 | - if(dirname($_SERVER['SCRIPT_NAME']) == '/' || dirname($_SERVER['SCRIPT_NAME']) == '\\') |
|
| 375 | + if (dirname($_SERVER['SCRIPT_NAME']) == '/' || dirname($_SERVER['SCRIPT_NAME']) == '\\') |
|
| 376 | 376 | {
|
| 377 | 377 | $path = '/' . substr($path, 2); |
| 378 | 378 | } |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | $path = dirname($_SERVER['SCRIPT_NAME']) . '/' . substr($path, 2); |
| 382 | 382 | } |
| 383 | 383 | } |
| 384 | - else if(strpos($file, '../') === 0) |
|
| 384 | + else if (strpos($file, '../') === 0) |
|
| 385 | 385 | {
|
| 386 | 386 | $path = $this->_normalizeFilePath(dirname($_SERVER['SCRIPT_NAME']) . "/{$path}");
|
| 387 | 387 | } |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | */ |
| 399 | 399 | function _arrangeCssIndex($dirName, &$file) |
| 400 | 400 | {
|
| 401 | - if($file->index !== 0) |
|
| 401 | + if ($file->index !== 0) |
|
| 402 | 402 | {
|
| 403 | 403 | return; |
| 404 | 404 | } |
@@ -108,15 +108,13 @@ discard block |
||
| 108 | 108 | $mapIndex = &$this->cssMapIndex; |
| 109 | 109 | |
| 110 | 110 | $this->_arrangeCssIndex($pathInfo['dirname'], $file); |
| 111 | - } |
|
| 112 | - else if($file->fileExtension == 'js') |
|
| 111 | + } else if($file->fileExtension == 'js') |
|
| 113 | 112 | {
|
| 114 | 113 | if($args[1] == 'body') |
| 115 | 114 | {
|
| 116 | 115 | $map = &$this->jsBodyMap; |
| 117 | 116 | $mapIndex = &$this->jsBodyMapIndex; |
| 118 | - } |
|
| 119 | - else |
|
| 117 | + } else |
|
| 120 | 118 | {
|
| 121 | 119 | $map = &$this->jsHeadMap; |
| 122 | 120 | $mapIndex = &$this->jsHeadMapIndex; |
@@ -170,8 +168,7 @@ discard block |
||
| 170 | 168 | {
|
| 171 | 169 | $file->fileName = $minifiedFileName; |
| 172 | 170 | } |
| 173 | - } |
|
| 174 | - else |
|
| 171 | + } else |
|
| 175 | 172 | {
|
| 176 | 173 | // Remove .min |
| 177 | 174 | if(file_exists(implode('/', array($file->fileRealPath, $file->keyName))))
|
@@ -191,8 +188,7 @@ discard block |
||
| 191 | 188 | $file->media = 'all'; |
| 192 | 189 | } |
| 193 | 190 | $file->key = $file->filePath . $file->keyName . "\t" . $file->targetIe . "\t" . $file->media; |
| 194 | - } |
|
| 195 | - else if($file->fileExtension == 'js') |
|
| 191 | + } else if($file->fileExtension == 'js') |
|
| 196 | 192 | {
|
| 197 | 193 | $file->key = $file->filePath . $file->keyName . "\t" . $file->targetIe; |
| 198 | 194 | } |
@@ -219,8 +215,7 @@ discard block |
||
| 219 | 215 | $index = $this->cssMapIndex[$file->key]; |
| 220 | 216 | unset($this->cssMap[$index][$file->key], $this->cssMapIndex[$file->key]); |
| 221 | 217 | } |
| 222 | - } |
|
| 223 | - else |
|
| 218 | + } else |
|
| 224 | 219 | {
|
| 225 | 220 | if(isset($this->jsHeadMapIndex[$file->key])) |
| 226 | 221 | {
|
@@ -297,8 +292,7 @@ discard block |
||
| 297 | 292 | {
|
| 298 | 293 | $map = &$this->jsHeadMap; |
| 299 | 294 | $mapIndex = &$this->jsHeadMapIndex; |
| 300 | - } |
|
| 301 | - else |
|
| 295 | + } else |
|
| 302 | 296 | {
|
| 303 | 297 | $map = &$this->jsBodyMap; |
| 304 | 298 | $mapIndex = &$this->jsBodyMapIndex; |
@@ -344,8 +338,7 @@ discard block |
||
| 344 | 338 | if(strpos($path, '://') === FALSE && $path{0} != '/' && $path{0} != '.')
|
| 345 | 339 | {
|
| 346 | 340 | $path = './' . $path; |
| 347 | - } |
|
| 348 | - elseif(!strncmp($path, '//', 2)) |
|
| 341 | + } elseif(!strncmp($path, '//', 2)) |
|
| 349 | 342 | {
|
| 350 | 343 | return preg_replace('#^//+#', '//', $path);
|
| 351 | 344 | } |
@@ -375,13 +368,11 @@ discard block |
||
| 375 | 368 | if(dirname($_SERVER['SCRIPT_NAME']) == '/' || dirname($_SERVER['SCRIPT_NAME']) == '\\') |
| 376 | 369 | {
|
| 377 | 370 | $path = '/' . substr($path, 2); |
| 378 | - } |
|
| 379 | - else |
|
| 371 | + } else |
|
| 380 | 372 | {
|
| 381 | 373 | $path = dirname($_SERVER['SCRIPT_NAME']) . '/' . substr($path, 2); |
| 382 | 374 | } |
| 383 | - } |
|
| 384 | - else if(strpos($file, '../') === 0) |
|
| 375 | + } else if(strpos($file, '../') === 0) |
|
| 385 | 376 | {
|
| 386 | 377 | $path = $this->_normalizeFilePath(dirname($_SERVER['SCRIPT_NAME']) . "/{$path}");
|
| 387 | 378 | } |
@@ -51,7 +51,7 @@ |
||
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * Mether to add key/value pair to the HTTP request header |
| 54 | - * @param int|string $key HTTP header element |
|
| 54 | + * @param string $key HTTP header element |
|
| 55 | 55 | * @param string $value value string for HTTP header element |
| 56 | 56 | * @return void |
| 57 | 57 | */ |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * constructor |
| 42 | 42 | * @return void |
| 43 | 43 | */ |
| 44 | - function XEHttpRequest($host, $port, $scheme='') |
|
| 44 | + function XEHttpRequest($host, $port, $scheme = '') |
|
| 45 | 45 | { |
| 46 | 46 | $this->m_host = $host; |
| 47 | 47 | $this->m_port = $port; |
@@ -76,11 +76,11 @@ discard block |
||
| 76 | 76 | $this->addToHeader('Connection', 'close'); |
| 77 | 77 | |
| 78 | 78 | $method = strtoupper($method); |
| 79 | - if(!$allow_methods) |
|
| 79 | + if (!$allow_methods) |
|
| 80 | 80 | { |
| 81 | 81 | $allow_methods = explode(' ', 'GET POST PUT'); |
| 82 | 82 | } |
| 83 | - if(!in_array($method, $allow_methods)) |
|
| 83 | + if (!in_array($method, $allow_methods)) |
|
| 84 | 84 | { |
| 85 | 85 | $method = $allow_methods[0]; |
| 86 | 86 | } |
@@ -89,12 +89,12 @@ discard block |
||
| 89 | 89 | $timout = max((int) $timeout, 0); |
| 90 | 90 | |
| 91 | 91 | // list of post variables |
| 92 | - if(!is_array($post_vars)) |
|
| 92 | + if (!is_array($post_vars)) |
|
| 93 | 93 | { |
| 94 | 94 | $post_vars = array(); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - if(FALSE && is_callable('curl_init')) |
|
| 97 | + if (FALSE && is_callable('curl_init')) |
|
| 98 | 98 | { |
| 99 | 99 | return $this->sendWithCurl($target, $method, $timeout, $post_vars); |
| 100 | 100 | } |
@@ -117,28 +117,28 @@ discard block |
||
| 117 | 117 | static $crlf = "\r\n"; |
| 118 | 118 | |
| 119 | 119 | $scheme = ''; |
| 120 | - if($this->m_scheme=='https') |
|
| 120 | + if ($this->m_scheme == 'https') |
|
| 121 | 121 | { |
| 122 | 122 | $scheme = 'ssl://'; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | $sock = @fsockopen($scheme . $this->m_host, $this->m_port, $errno, $errstr, $timeout); |
| 126 | - if(!$sock) |
|
| 126 | + if (!$sock) |
|
| 127 | 127 | { |
| 128 | 128 | return new Object(-1, 'socket_connect_failed'); |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | $headers = $this->m_headers + array(); |
| 132 | - if(!isset($headers['Accept-Encoding'])) |
|
| 132 | + if (!isset($headers['Accept-Encoding'])) |
|
| 133 | 133 | { |
| 134 | 134 | $headers['Accept-Encoding'] = 'identity'; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | // post body |
| 138 | 138 | $post_body = ''; |
| 139 | - if($method == 'POST' && count($post_vars)) |
|
| 139 | + if ($method == 'POST' && count($post_vars)) |
|
| 140 | 140 | { |
| 141 | - foreach($post_vars as $key => $value) |
|
| 141 | + foreach ($post_vars as $key => $value) |
|
| 142 | 142 | { |
| 143 | 143 | $post_body .= urlencode($key) . '=' . urlencode($value) . '&'; |
| 144 | 144 | } |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | $request = "$method $target HTTP/1.1$crlf"; |
| 152 | - foreach($headers as $equiv => $content) |
|
| 152 | + foreach ($headers as $equiv => $content) |
|
| 153 | 153 | { |
| 154 | 154 | $request .= "$equiv: $content$crlf"; |
| 155 | 155 | } |
@@ -160,24 +160,24 @@ discard block |
||
| 160 | 160 | |
| 161 | 161 | // read response headers |
| 162 | 162 | $is_chunked = FALSE; |
| 163 | - while(strlen(trim($line = fgets($sock)))) |
|
| 163 | + while (strlen(trim($line = fgets($sock)))) |
|
| 164 | 164 | { |
| 165 | 165 | list($equiv, $content) = preg_split('/ *: */', rtrim($line), 2); |
| 166 | - if(!strcasecmp($equiv, 'Transfer-Encoding') && $content == 'chunked') |
|
| 166 | + if (!strcasecmp($equiv, 'Transfer-Encoding') && $content == 'chunked') |
|
| 167 | 167 | { |
| 168 | 168 | $is_chunked = TRUE; |
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | $body = ''; |
| 173 | - while(!feof($sock)) |
|
| 173 | + while (!feof($sock)) |
|
| 174 | 174 | { |
| 175 | - if($is_chunked) |
|
| 175 | + if ($is_chunked) |
|
| 176 | 176 | { |
| 177 | 177 | $chunk_size = hexdec(fgets($sock)); |
| 178 | - if($chunk_size) |
|
| 178 | + if ($chunk_size) |
|
| 179 | 179 | { |
| 180 | - $body .= fgets($sock, $chunk_size+1); |
|
| 180 | + $body .= fgets($sock, $chunk_size + 1); |
|
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | else |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); |
| 220 | 220 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); |
| 221 | 221 | |
| 222 | - switch($method) |
|
| 222 | + switch ($method) |
|
| 223 | 223 | { |
| 224 | 224 | case 'GET': curl_setopt($ch, CURLOPT_HTTPGET, true); |
| 225 | 225 | break; |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | $arr_headers = array(); |
| 235 | - foreach($headers as $key => $value) |
|
| 235 | + foreach ($headers as $key => $value) |
|
| 236 | 236 | { |
| 237 | 237 | $arr_headers[] = "$key: $value"; |
| 238 | 238 | } |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | curl_setopt($ch, CURLOPT_HTTPHEADER, $arr_headers); |
| 241 | 241 | |
| 242 | 242 | $body = curl_exec($ch); |
| 243 | - if(curl_errno($ch)) |
|
| 243 | + if (curl_errno($ch)) |
|
| 244 | 244 | { |
| 245 | 245 | return new Object(-1, 'socket_connect_failed'); |
| 246 | 246 | } |
@@ -25,8 +25,7 @@ discard block |
||
| 25 | 25 | { |
| 26 | 26 | $mskin = 'default'; |
| 27 | 27 | $template_path = sprintf('%sm.skins/%s', $this->module_path, $mskin); |
| 28 | - } |
|
| 29 | - else |
|
| 28 | + } else |
|
| 30 | 29 | { |
| 31 | 30 | $template_path = sprintf('%sm.skins/%s', $this->module_path, $mskin); |
| 32 | 31 | } |
@@ -40,8 +39,7 @@ discard block |
||
| 40 | 39 | if(!$this->memberInfo) |
| 41 | 40 | { |
| 42 | 41 | Context::set('member_srl',''); |
| 43 | - } |
|
| 44 | - else |
|
| 42 | + } else |
|
| 45 | 43 | { |
| 46 | 44 | Context::set('member_info',$this->memberInfo); |
| 47 | 45 | } |