Remove blank lines from PHP sources.

This commit is contained in:
Lars Jung 2016-01-14 00:36:25 +01:00
parent 11bab8d0a1
commit 5f265672ae
17 changed files with 1 additions and 166 deletions

View file

@ -1,11 +1,9 @@
<?php
class Bootstrap {
private static $autopaths = ['core', 'ext'];
public static function run() {
spl_autoload_register(['Bootstrap', 'autoload']);
putenv('LANG=en_US.UTF-8');
setlocale(LC_CTYPE, 'en_US.UTF-8');
@ -32,7 +30,6 @@ class Bootstrap {
}
public static function autoload($class_name) {
$filename = 'class-' . strtolower($class_name) . '.php';
foreach (Bootstrap::$autopaths as $path) {

View file

@ -1,20 +1,17 @@
<?php
class Api {
private $context;
private $request;
private $setup;
public function __construct($context) {
$this->context = $context;
$this->request = $context->get_request();
$this->setup = $context->get_setup();
}
public function apply() {
$action = $this->request->query('action');
$supported = ['download', 'get', 'login', 'logout'];
Util::json_fail(Util::ERR_UNSUPPORTED, 'unsupported action', !in_array($action, $supported));
@ -24,7 +21,6 @@ class Api {
}
private function on_download() {
Util::json_fail(Util::ERR_DISABLED, 'download disabled', !$this->context->query_option('download.enabled', false));
$as = $this->request->query('as');
@ -45,7 +41,6 @@ class Api {
}
private function on_get() {
$response = [];
foreach (['langs', 'options', 'types'] as $name) {
@ -57,58 +52,46 @@ class Api {
}
if ($this->request->query_boolean('setup', false)) {
$response['setup'] = $this->setup->to_jsono($this->context->is_admin());
}
if ($this->request->query_boolean('theme', false)) {
$theme = new Theme($this->context);
$response['theme'] = $theme->get_icons();
}
if ($this->request->query('items', false)) {
$href = $this->request->query('items.href');
$what = $this->request->query_numeric('items.what');
$response['items'] = $this->context->get_items($href, $what);
}
if ($this->request->query('custom', false)) {
Util::json_fail(Util::ERR_DISABLED, 'custom disabled', !$this->context->query_option('custom.enabled', false));
$href = $this->request->query('custom');
$custom = new Custom($this->context);
$response['custom'] = $custom->get_customizations($href);
}
if ($this->request->query('l10n', false)) {
Util::json_fail(Util::ERR_DISABLED, 'l10n disabled', !$this->context->query_option('l10n.enabled', false));
$iso_codes = $this->request->query_array('l10n');
$iso_codes = array_filter($iso_codes);
$response['l10n'] = $this->context->get_l10n($iso_codes);
}
if ($this->request->query('search', false)) {
Util::json_fail(Util::ERR_DISABLED, 'search disabled', !$this->context->query_option('search.enabled', false));
$href = $this->request->query('search.href');
$pattern = $this->request->query('search.pattern');
$search = new Search($this->context);
$response['search'] = $search->get_items($href, $pattern);
}
if ($this->request->query('thumbs', false)) {
Util::json_fail(Util::ERR_DISABLED, 'thumbnails disabled', !$this->context->query_option('thumbnails.enabled', false));
Util::json_fail(Util::ERR_UNSUPPORTED, 'thumbnails not supported', !$this->setup->get('HAS_PHP_JPEG'));
$thumbs = $this->request->query_array('thumbs');
$response['thumbs'] = $this->context->get_thumbs($thumbs);
}
@ -116,13 +99,11 @@ class Api {
}
private function on_login() {
$pass = $this->request->query('pass');
Util::json_exit(['asAdmin' => $this->context->login_admin($pass)]);
}
private function on_logout() {
Util::json_exit(['asAdmin' => $this->context->logout_admin()]);
}
}

View file

@ -1,7 +1,6 @@
<?php
class Context {
private static $DEFAULT_PASSHASH = 'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e';
private static $AS_ADMIN_SESSION_KEY = 'AS_ADMIN';
@ -12,7 +11,6 @@ class Context {
private $passhash;
public function __construct($session, $request, $setup) {
$this->session = $session;
$this->request = $request;
$this->setup = $setup;
@ -25,64 +23,52 @@ class Context {
}
public function get_session() {
return $this->session;
}
public function get_request() {
return $this->request;
}
public function get_setup() {
return $this->setup;
}
public function get_options() {
return $this->options;
}
public function query_option($keypath = '', $default = null) {
return Util::array_query($this->options, $keypath, $default);
}
public function get_types() {
return Json::load($this->setup->get('CONF_PATH') . '/types.json');
}
public function login_admin($pass) {
$this->session->set(Context::$AS_ADMIN_SESSION_KEY, strcasecmp(hash('sha512', $pass), $this->passhash) === 0);
return $this->session->get(Context::$AS_ADMIN_SESSION_KEY);
}
public function logout_admin() {
$this->session->set(Context::$AS_ADMIN_SESSION_KEY, false);
return $this->session->get(Context::$AS_ADMIN_SESSION_KEY);
}
public function is_admin() {
return $this->session->get(Context::$AS_ADMIN_SESSION_KEY);
}
public function is_api_request() {
return strtolower($this->setup->get('REQUEST_METHOD')) === 'post';
}
public function is_info_request() {
return Util::starts_with($this->setup->get('REQUEST_HREF') . '/', $this->setup->get('PUBLIC_HREF'));
}
public function to_href($path, $trailing_slash = true) {
$rel_path = substr($path, strlen($this->setup->get('ROOT_PATH')));
$parts = explode('/', $rel_path);
$encoded_parts = [];
@ -96,13 +82,11 @@ class Context {
}
public function to_path($href) {
$rel_href = substr($href, strlen($this->setup->get('ROOT_HREF')));
return Util::normalize_path($this->setup->get('ROOT_PATH') . '/' . rawurldecode($rel_href));
}
public function is_hidden($name) {
// always hide
if ($name === '.' || $name === '..') {
return true;
@ -119,7 +103,6 @@ class Context {
}
public function read_dir($path) {
$names = [];
if (is_dir($path)) {
foreach (scandir($path) as $name) {
@ -137,12 +120,10 @@ class Context {
}
public function is_managed_href($href) {
return $this->is_managed_path($this->to_path($href));
}
public function is_managed_path($path) {
if (!is_dir($path) || strpos($path, '../') !== false || strpos($path, '/..') !== false || $path === '..') {
return false;
}
@ -175,7 +156,6 @@ class Context {
}
public function get_current_path() {
$current_href = Util::normalize_path($this->setup->get('REQUEST_HREF'), true);
$current_path = $this->to_path($current_href);
@ -187,7 +167,6 @@ class Context {
}
public function get_items($href, $what) {
if (!$this->is_managed_href($href)) {
return [];
}
@ -219,7 +198,6 @@ class Context {
}
public function get_langs() {
$langs = [];
$l10n_path = $this->setup->get('CONF_PATH') . '/l10n';
if (is_dir($l10n_path)) {
@ -238,7 +216,6 @@ class Context {
}
public function get_l10n($iso_codes) {
$results = [];
foreach ($iso_codes as $iso_code) {
@ -251,7 +228,6 @@ class Context {
}
public function get_thumbs($requests) {
$hrefs = [];
foreach ($requests as $req) {
@ -263,7 +239,6 @@ class Context {
}
private function prefix_x_head_href($href) {
if (preg_match('@^(https?://|/)@i', $href)) {
return $href;
}
@ -272,7 +247,6 @@ class Context {
}
private function get_fonts_html() {
$fonts = $this->query_option('view.fonts', []);
$fonts_mono = $this->query_option('view.fontsMono', []);
@ -292,7 +266,6 @@ class Context {
}
public function get_x_head_html() {
$scripts = $this->query_option('resources.scripts', []);
$styles = $this->query_option('resources.styles', []);

View file

@ -1,16 +1,13 @@
<?php
class Fallback {
private $context;
public function __construct($context) {
$this->context = $context;
}
public function get_html($path = null) {
if (!$path) {
$path = $this->context->get_current_path();
}

View file

@ -1,15 +1,12 @@
<?php
class Filesize {
private $cache = [];
public function __construct() {
}
public function fseek($path) {
$size = 0;
$step = 1073741824;
@ -36,12 +33,10 @@ class Filesize {
}
public function filesize($path) {
return @filesize($path);
}
private function read_dir($path) {
$paths = [];
if (is_dir($path)) {
foreach (scandir($path) as $name) {
@ -54,7 +49,6 @@ class Filesize {
}
private function exec($cmdv) {
$cmd = implode(' ', array_map('escapeshellarg', $cmdv));
$lines = [];
$rc = null;
@ -63,7 +57,6 @@ class Filesize {
}
public function du_paths($paths) {
$cmdv = array_merge(['du', '-sk'], $paths);
$lines = $this->exec($cmdv);
@ -78,18 +71,15 @@ class Filesize {
}
public function du_dir($path) {
return $this->du_paths($this->read_dir($path));
}
public function du_path($path) {
$sizes = $this->du_paths([$path]);
return $sizes[$path];
}
public function add($path) {
$size = 0;
foreach ($this->read_dir($path) as $p) {
$size += $this->filesize($p);

View file

@ -1,9 +1,7 @@
<?php
class Item {
public static function cmp($item1, $item2) {
if ($item1->is_folder && !$item2->is_folder) {
return -1;
}
@ -15,7 +13,6 @@ class Item {
}
public static function get($context, $path, &$cache) {
if (!Util::starts_with($path, $context->get_setup()->get('ROOT_PATH'))) {
return null;
}
@ -41,7 +38,6 @@ class Item {
public $is_content_fetched;
private function __construct($context, $path) {
$this->context = $context;
$this->path = Util::normalize_path($path, false);
@ -53,7 +49,6 @@ class Item {
}
public function to_json_object() {
$obj = [
'href' => $this->href,
'time' => $this->date * 1000, // seconds (PHP) to milliseconds (JavaScript)
@ -69,7 +64,6 @@ class Item {
}
public function get_parent(&$cache) {
$parent_path = Util::normalize_path(dirname($this->path), false);
if ($parent_path !== $this->path && Util::starts_with($parent_path, $this->context->get_setup()->get('ROOT_PATH'))) {
return Item::get($this->context, $parent_path, $cache);
@ -78,7 +72,6 @@ class Item {
}
public function get_content(&$cache) {
$items = [];
if (!$this->context->is_managed_href($this->href)) {

View file

@ -1,12 +1,10 @@
<?php
class Json {
const SINGLE = 1;
const MULTI = 2;
public static function load($path) {
if (!is_readable($path)) {
return [];
}
@ -16,25 +14,21 @@ class Json {
}
public static function save($path, $obj) {
$json = json_encode($obj);
return file_put_contents($path, $json) !== false;
}
public static function decode($json) {
$json = Json::strip($json);
return json_decode($json, true);
}
public static function strip($commented_json) {
$insideString = false;
$insideComment = false;
$json = '';
for ($i = 0; $i < strlen($commented_json); $i += 1) {
$char = $commented_json[$i];
$charchar = $char . @$commented_json[$i + 1];
$prevChar = @$commented_json[$i - 1];

View file

@ -1,12 +1,10 @@
<?php
class Logger {
private static $start;
private static $prev;
public static function init() {
self::$start = self::time();
self::$prev = self::$start;
register_shutdown_function(function () { Logger::log('shutdown'); });
@ -14,12 +12,10 @@ class Logger {
}
private static function time() {
return microtime(true) * 1000; // sec * 1000 = ms
}
public static function log($message=null, $obj=null) {
$now = self::time();
$message = number_format($now - self::$start, 3) . ' ' . number_format($now - self::$prev, 3) . ' ' . $message;

View file

@ -1,16 +1,13 @@
<?php
class Request {
private $params;
public function __construct($params) {
$this->params = $params;
}
public function query($keypath = '', $default = Util::NO_DEFAULT) {
$value = Util::array_query($this->params, $keypath, Util::NO_DEFAULT);
if ($value === Util::NO_DEFAULT) {
@ -22,20 +19,17 @@ class Request {
}
public function query_boolean($keypath = '', $default = Util::NO_DEFAULT) {
$value = $this->query($keypath, $default);
return filter_var($value, FILTER_VALIDATE_BOOLEAN);
}
public function query_numeric($keypath = '', $default = Util::NO_DEFAULT) {
$value = $this->query($keypath, $default);
Util::json_fail(Util::ERR_ILLIGAL_PARAM, 'parameter \'' . $keypath . '\' is not numeric', !is_numeric($value));
return intval($value, 10);
}
public function query_array($keypath = '', $default = Util::NO_DEFAULT) {
$value = $this->query($keypath, $default);
Util::json_fail(Util::ERR_ILLIGAL_PARAM, 'parameter \'' . $keypath . '\' is no array', !is_array($value));
return $value;

View file

@ -1,24 +1,19 @@
<?php
class Session {
private static $KEY_PREFIX = '__H5AI__';
private $store;
public function __construct(&$store) {
$this->store = &$store;
}
public function set($key, $value) {
$key = Session::$KEY_PREFIX . $key;
$this->store[$key] = $value;
}
public function get($key, $default = null) {
$key = Session::$KEY_PREFIX . $key;
return array_key_exists($key, $this->store) ? $this->store[$key] : $default;
}

View file

@ -1,12 +1,10 @@
<?php
class Setup {
private $store;
private $refresh;
public function __construct($refresh = false) {
$this->store = [];
$this->refresh = $refresh;
@ -19,7 +17,6 @@ class Setup {
}
private function set($key, $value) {
if (array_key_exists($key, $this->store)) {
Logger::log('setup key already taken', [
'key' => $key,
@ -40,7 +37,6 @@ class Setup {
}
public function get($key) {
if (!array_key_exists($key, $this->store)) {
Logger::log('setup key not found', ['key' => $key]);
exit;
@ -50,7 +46,6 @@ class Setup {
}
private function add_globals_and_envs() {
$this->set('PHP_VERSION', PHP_VERSION);
$this->set('MIN_PHP_VERSION', MIN_PHP_VERSION);
@ -61,7 +56,6 @@ class Setup {
}
private function add_php_checks() {
$this->set('HAS_PHP_EXIF', function_exists('exif_thumbnail'));
$has_php_jpeg = false;
@ -73,14 +67,12 @@ class Setup {
}
private function add_app_metadata() {
$this->set('NAME', 'h5ai');
$this->set('VERSION', H5AI_VERSION);
$this->set('FILE_PREFIX', '_h5ai');
}
private function add_server_metadata_and_check() {
$server_software = $this->get('SERVER_SOFTWARE');
$server_name = null;
$server_version = null;
@ -96,7 +88,6 @@ class Setup {
}
private function add_paths() {
$script_name = $this->get('SCRIPT_NAME');
if ($this->get('SERVER_NAME') === 'lighttpd') {
$script_name = preg_replace('#^.*?//#', '/', $script_name);
@ -123,7 +114,6 @@ class Setup {
}
private function add_sys_cmd_checks() {
$cmds_cache_path = Util::normalize_path($this->get('CACHE_PRV_PATH') . '/cmds.json', false);
$cmds = Json::load($cmds_cache_path);
@ -150,7 +140,6 @@ class Setup {
}
public function to_jsono($as_admin = false) {
$keys = [
'PUBLIC_HREF',
'ROOT_HREF'

View file

@ -1,18 +1,14 @@
<?php
class Theme {
private static $EXTENSIONS = ['svg', 'png', 'jpg'];
private $context;
public function __construct($context) {
$this->context = $context;
}
public function get_icons() {
$public_path = $this->context->get_setup()->get('PUBLIC_PATH');
$theme = $this->context->query_option('view.theme', '-NONE-');
$theme_path = $public_path . '/images/themes/' . $theme;

View file

@ -1,7 +1,6 @@
<?php
class Util {
const ERR_MISSING_PARAM = 'ERR_MISSING_PARAM';
const ERR_ILLIGAL_PARAM = 'ERR_ILLIGAL_PARAM';
const ERR_FAILED = 'ERR_FAILED';
@ -11,27 +10,23 @@ class Util {
const RE_DELIMITER = '@';
public static function normalize_path($path, $trailing_slash = false) {
$path = preg_replace('#[\\\\/]+#', '/', $path);
return preg_match('#^(\w:)?/$#', $path) ? $path : (rtrim($path, '/') . ($trailing_slash ? '/' : ''));
}
public static function json_exit($obj = []) {
header('Content-type: application/json;charset=utf-8');
echo json_encode($obj);
exit;
}
public static function json_fail($err, $msg = '', $cond = true) {
if ($cond) {
Util::json_exit(['err' => $err, 'msg' => $msg]);
}
}
public static function array_query($array, $keypath = '', $default = Util::NO_DEFAULT) {
$value = $array;
$keys = array_filter(explode('.', $keypath));
@ -46,30 +41,25 @@ class Util {
}
public static function starts_with($sequence, $head) {
return substr($sequence, 0, strlen($head)) === $head;
}
public static function ends_with($sequence, $tail) {
$len = strlen($tail);
return $len === 0 ? true : substr($sequence, -$len) === $tail;
}
public static function wrap_pattern($pattern) {
return Util::RE_DELIMITER . str_replace(Util::RE_DELIMITER, '\\' . Util::RE_DELIMITER, $pattern) . Util::RE_DELIMITER;
}
public static function passthru_cmd($cmd) {
$rc = null;
passthru($cmd, $rc);
return $rc;
}
public static function exec_cmdv($cmdv) {
if (!is_array($cmdv)) {
$cmdv = func_get_args();
}
@ -82,7 +72,6 @@ class Util {
}
public static function exec_0($cmd) {
$lines = [];
$rc = null;
try {
@ -95,7 +84,6 @@ class Util {
private static $size_cache = [];
public static function filesize($context, $path) {
if (array_key_exists($path, Util::$size_cache)) {
return Util::$size_cache[$path];
}

View file

@ -1,7 +1,6 @@
<?php
class Archive {
const NULL_BYTE = "\0";
private static $SEGMENT_SIZE = 16777216; // 1024 * 1024 * 16 = 16MiB
@ -14,12 +13,10 @@ class Archive {
private $files;
public function __construct($context) {
$this->context = $context;
}
public function output($type, $base_href, $hrefs) {
$this->base_path = $this->context->to_path($base_href);
if (!$this->context->is_managed_path($this->base_path)) {
return false;
@ -39,22 +36,16 @@ class Archive {
}
if ($type === 'php-tar') {
return $this->php_tar($this->dirs, $this->files);
} else if ($type === 'shell-tar') {
return $this->shell_cmd(Archive::$TAR_PASSTHRU_CMD);
} else if ($type === 'shell-zip') {
return $this->shell_cmd(Archive::$ZIP_PASSTHRU_CMD);
}
return false;
}
private function shell_cmd($cmd) {
$cmd = str_replace('[ROOTDIR]', escapeshellarg($this->base_path), $cmd);
$cmd = str_replace('[DIRS]', count($this->dirs) ? implode(' ', array_map('escapeshellarg', $this->dirs)) : '', $cmd);
$cmd = str_replace('[FILES]', count($this->files) ? implode(' ', array_map('escapeshellarg', $this->files)) : '', $cmd);
@ -67,11 +58,9 @@ class Archive {
}
private function php_tar($dirs, $files) {
$filesizes = [];
$total_size = 512 * count($dirs);
foreach (array_keys($files) as $real_file) {
$size = filesize($real_file);
$filesizes[$real_file] = $size;
@ -84,11 +73,10 @@ class Archive {
header('Content-Length: ' . $total_size);
foreach ($dirs as $real_dir => $archived_dir) {
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) {
$size = $filesizes[$real_file];
echo $this->php_tar_header($archived_file, $size, @filemtime($real_file), 0);
@ -103,7 +91,6 @@ class Archive {
}
private function php_tar_header($filename, $size, $mtime, $type) {
$name = substr(basename($filename), -99);
$prefix = substr(Util::normalize_path(dirname($filename)), -154);
if ($prefix === '.') {
@ -136,7 +123,6 @@ class Archive {
}
private function print_file($file) {
// Send file content in segments to not hit PHP's memory limit (default: 128M)
if ($fd = fopen($file, 'rb')) {
while (!feof($fd)) {
@ -149,9 +135,7 @@ class Archive {
}
private function add_hrefs($hrefs) {
foreach ($hrefs as $href) {
if (trim($href) === '') {
continue;
}
@ -174,20 +158,17 @@ class Archive {
}
private function add_file($real_file, $archived_file) {
if (is_readable($real_file)) {
$this->files[$real_file] = $archived_file;
}
}
private function add_dir($real_dir, $archived_dir) {
if ($this->context->is_managed_path($real_dir)) {
$this->dirs[$real_dir] = $archived_dir;
$files = $this->context->read_dir($real_dir);
foreach ($files as $file) {
$real_file = $real_dir . '/' . $file;
$archived_file = $archived_dir . '/' . $file;

View file

@ -1,18 +1,14 @@
<?php
class Custom {
private static $EXTENSIONS = ['html', 'md'];
private $context;
public function __construct($context) {
$this->context = $context;
}
private function read_custom_file($path, $name, &$content, &$type) {
$file_prefix = $this->context->get_setup()->get('FILE_PREFIX');
foreach (Custom::$EXTENSIONS as $ext) {
@ -26,7 +22,6 @@ class Custom {
}
public function get_customizations($href) {
if (!$this->context->query_option('custom.enabled', false)) {
return [
'header' => ['content' => null, 'type' => null],
@ -46,14 +41,12 @@ class Custom {
$this->read_custom_file($path, 'footer', $footer, $footer_type);
while ($header === null || $footer === null) {
if ($header === null) {
$this->read_custom_file($path, 'headers', $header, $header_type);
}
if ($footer === null) {
$this->read_custom_file($path, 'footers', $footer, $footer_type);
}
if ($path === $root_path) {
break;
}

View file

@ -1,16 +1,13 @@
<?php
class Search {
private $context;
public function __construct($context) {
$this->context = $context;
}
public function get_paths($root, $pattern = null) {
$paths = [];
if ($pattern && $this->context->is_managed_path($root)) {
$re = Util::wrap_pattern($pattern);
@ -29,12 +26,10 @@ class Search {
}
public function get_items($href, $pattern = null) {
$cache = [];
$root = $this->context->to_path($href);
$paths = $this->get_paths($root, $pattern);
$items = array_map(function ($path) {
return Item::get($this->context, $path, $cache)->to_json_object();
}, $paths);
return $items;

View file

@ -1,7 +1,6 @@
<?php
class Thumb {
private static $FFMPEG_CMDV = ['ffmpeg', '-ss', '0:00:10', '-i', '[SRC]', '-an', '-vframes', '1', '[DEST]'];
private static $AVCONV_CMDV = ['avconv', '-ss', '0:00:10', '-i', '[SRC]', '-an', '-vframes', '1', '[DEST]'];
private static $CONVERT_CMDV = ['convert', '-density', '200', '-quality', '100', '-sharpen', '0x1.0', '-strip', '[SRC][0]', '[DEST]'];
@ -14,7 +13,6 @@ class Thumb {
private $thumbs_href;
public function __construct($context) {
$this->context = $context;
$this->setup = $context->get_setup();
$this->thumbs_path = $this->setup->get('CACHE_PUB_PATH') . '/' . Thumb::$THUMB_CACHE;
@ -26,7 +24,6 @@ class Thumb {
}
public function thumb($type, $source_href, $width, $height) {
$source_path = $this->context->to_path($source_href);
if (!file_exists($source_path) || Util::starts_with($source_path, $this->setup->get('CACHE_PUB_PATH'))) {
return null;
@ -53,7 +50,6 @@ class Thumb {
}
private function thumb_href($source_path, $width, $height) {
if (!file_exists($source_path)) {
return null;
}
@ -63,7 +59,6 @@ class Thumb {
$thumb_href = $this->thumbs_href . '/' . $name;
if (!file_exists($thumb_path) || filemtime($source_path) >= filemtime($thumb_path)) {
$image = new Image();
$et = false;
@ -86,7 +81,6 @@ class Thumb {
}
private function capture($cmdv, $source_path) {
if (!file_exists($source_path)) {
return null;
}
@ -94,7 +88,6 @@ class Thumb {
$capture_path = $this->thumbs_path . '/capture-' . sha1($source_path) . '.jpg';
if (!file_exists($capture_path) || filemtime($source_path) >= filemtime($capture_path)) {
foreach ($cmdv as &$arg) {
$arg = str_replace('[SRC]', $source_path, $arg);
$arg = str_replace('[DEST]', $capture_path, $arg);
@ -108,7 +101,6 @@ class Thumb {
}
class Image {
private $source_file;
private $source;
private $width;
@ -117,7 +109,6 @@ class Image {
private $dest;
public function __construct($filename = null) {
$this->source_file = null;
$this->source = null;
$this->width = null;
@ -130,13 +121,11 @@ class Image {
}
public function __destruct() {
$this->release_source();
$this->release_dest();
}
public function set_source($filename) {
$this->release_source();
$this->release_dest();
@ -160,7 +149,6 @@ class Image {
}
public function save_dest_jpeg($filename, $quality = 80) {
if (!is_null($this->dest)) {
@imagejpeg($this->dest, $filename, $quality);
@chmod($filename, 0775);
@ -168,7 +156,6 @@ class Image {
}
public function release_dest() {
if (!is_null($this->dest)) {
@imagedestroy($this->dest);
$this->dest = null;
@ -176,7 +163,6 @@ class Image {
}
public function release_source() {
if (!is_null($this->source)) {
@imagedestroy($this->source);
$this->source_file = null;
@ -188,7 +174,6 @@ class Image {
}
public function thumb($width, $height) {
if (is_null($this->source)) {
return;
}
@ -233,7 +218,6 @@ class Image {
}
public function rotate($angle) {
if (is_null($this->source) || ($angle !== 90 && $angle !== 180 && $angle !== 270)) {
return;
}
@ -245,7 +229,6 @@ class Image {
}
public function normalize_exif_orientation($exif_source_file = null) {
if (is_null($this->source) || !function_exists('exif_read_data')) {
return;
}