Clean some PHP code.

This commit is contained in:
Lars Jung 2016-08-11 00:33:06 +02:00
parent c559edc208
commit b6b8d9f144
5 changed files with 17 additions and 17 deletions

View file

@ -17,7 +17,7 @@ class Bootstrap {
if ($context->is_api_request()) { if ($context->is_api_request()) {
(new Api($context))->apply(); (new Api($context))->apply();
} else if ($context->is_info_request()) { } elseif ($context->is_info_request()) {
$public_href = $setup->get('PUBLIC_HREF'); $public_href = $setup->get('PUBLIC_HREF');
$x_head_tags = $context->get_x_head_html(); $x_head_tags = $context->get_x_head_html();
$fallback_mode = false; $fallback_mode = false;

View file

@ -28,7 +28,7 @@ class Json {
$insideComment = false; $insideComment = false;
$json = ''; $json = '';
for ($i = 0; $i < strlen($commented_json); $i += 1) { for ($i = 0, $len = strlen($commented_json); $i < $len; $i += 1) {
$char = $commented_json[$i]; $char = $commented_json[$i];
$charchar = $char . @$commented_json[$i + 1]; $charchar = $char . @$commented_json[$i + 1];
$prevChar = @$commented_json[$i - 1]; $prevChar = @$commented_json[$i - 1];
@ -39,22 +39,22 @@ class Json {
if ($insideString) { if ($insideString) {
$json .= $char; $json .= $char;
} else if (!$insideComment && $charchar === '//') { } elseif (!$insideComment && $charchar === '//') {
$insideComment = Json::SINGLE; $insideComment = Json::SINGLE;
$i += 1; $i += 1;
} else if (!$insideComment && $charchar === '/*') { } elseif (!$insideComment && $charchar === '/*') {
$insideComment = Json::MULTI; $insideComment = Json::MULTI;
$i += 1; $i += 1;
} else if (!$insideComment) { } elseif (!$insideComment) {
$json .= $char; $json .= $char;
} else if ($insideComment === Json::SINGLE && $charchar === "\r\n") { } elseif ($insideComment === Json::SINGLE && $charchar === "\r\n") {
$insideComment = false; $insideComment = false;
$json .= $charchar; $json .= $charchar;
$i += 1; $i += 1;
} else if ($insideComment === Json::SINGLE && $char === "\n") { } elseif ($insideComment === Json::SINGLE && $char === "\n") {
$insideComment = false; $insideComment = false;
$json .= $char; $json .= $char;
} else if ($insideComment === Json::MULTI && $charchar === '*/') { } elseif ($insideComment === Json::MULTI && $charchar === '*/') {
$insideComment = false; $insideComment = false;
$i += 1; $i += 1;
} }

View file

@ -126,7 +126,7 @@ class Setup {
$cmd = false; $cmd = false;
if ($cmds['command']) { if ($cmds['command']) {
$cmd = 'command -v'; $cmd = 'command -v';
} else if ($cmds['which']) { } elseif ($cmds['which']) {
$cmd = 'which'; $cmd = 'which';
} }

View file

@ -37,9 +37,9 @@ class Archive {
if ($type === 'php-tar') { if ($type === 'php-tar') {
return $this->php_tar($this->dirs, $this->files); return $this->php_tar($this->dirs, $this->files);
} else if ($type === 'shell-tar') { } elseif ($type === 'shell-tar') {
return $this->shell_cmd(Archive::$TAR_PASSTHRU_CMD); return $this->shell_cmd(Archive::$TAR_PASSTHRU_CMD);
} else if ($type === 'shell-zip') { } elseif ($type === 'shell-zip') {
return $this->shell_cmd(Archive::$ZIP_PASSTHRU_CMD); return $this->shell_cmd(Archive::$ZIP_PASSTHRU_CMD);
} }
return false; return false;
@ -73,7 +73,7 @@ class Archive {
header('Content-Length: ' . $total_size); header('Content-Length: ' . $total_size);
foreach ($dirs as $real_dir => $archived_dir) { foreach ($dirs as $real_dir => $archived_dir) {
echo $this->php_tar_header($archived_dir, 0, @filemtime($real_dir . DIRECTORY_SEPARATOR . "."), 5); echo $this->php_tar_header($archived_dir, 0, @filemtime($real_dir . DIRECTORY_SEPARATOR . '.'), 5);
} }
foreach ($files as $real_file => $archived_file) { foreach ($files as $real_file => $archived_file) {

View file

@ -32,16 +32,16 @@ class Thumb {
$capture_path = $source_path; $capture_path = $source_path;
if ($type === 'img') { if ($type === 'img') {
$capture_path = $source_path; $capture_path = $source_path;
} else if ($type === 'mov') { } elseif ($type === 'mov') {
if ($this->setup->get('HAS_CMD_AVCONV')) { if ($this->setup->get('HAS_CMD_AVCONV')) {
$capture_path = $this->capture(Thumb::$AVCONV_CMDV, $source_path); $capture_path = $this->capture(Thumb::$AVCONV_CMDV, $source_path);
} else if ($this->setup->get('HAS_CMD_FFMPEG')) { } elseif ($this->setup->get('HAS_CMD_FFMPEG')) {
$capture_path = $this->capture(Thumb::$FFMPEG_CMDV, $source_path); $capture_path = $this->capture(Thumb::$FFMPEG_CMDV, $source_path);
} }
} else if ($type === 'doc') { } elseif ($type === 'doc') {
if ($this->setup->get('HAS_CMD_CONVERT')) { if ($this->setup->get('HAS_CMD_CONVERT')) {
$capture_path = $this->capture(Thumb::$CONVERT_CMDV, $source_path); $capture_path = $this->capture(Thumb::$CONVERT_CMDV, $source_path);
} else if ($this->setup->get('HAS_CMD_GM')) { } elseif ($this->setup->get('HAS_CMD_GM')) {
$capture_path = $this->capture(Thumb::$GM_CONVERT_CMDV, $source_path); $capture_path = $this->capture(Thumb::$GM_CONVERT_CMDV, $source_path);
} }
} }
@ -238,7 +238,7 @@ class Image {
} }
$exif = exif_read_data($exif_source_file); $exif = exif_read_data($exif_source_file);
switch(@$exif['Orientation']) { switch (@$exif['Orientation']) {
case 3: case 3:
$this->rotate(180); $this->rotate(180);
break; break;