diff --git a/bin/thumb_server.sh b/bin/thumb_server.sh index f3e93ad..a66707e 100755 --- a/bin/thumb_server.sh +++ b/bin/thumb_server.sh @@ -4,7 +4,7 @@ site=$1 md5Site=$2 thumbWidth=$3 -#thumbHeight=$5 +onlyThumb=$4 #firstLevel=${md5Site:0:2} #secondLevel=${md5Site:2:2} @@ -12,14 +12,28 @@ thumbWidth=$3 ./bin/phantomjs --ignore-ssl-errors=true /bin/rasterize.js "$site" "cache/tmp/$md5Site.png" #convert "cache/tmp/$md5Site.png" -crop 1280x1024+0+0 "cache/img/$firstLevel/$secondLevel/$md5Site.png" #convert "cache/img/$firstLevel/$secondLevel/$md5Site.png" -filter Lanczos -thumbnail "$thumbWidth" "cache/img/$firstLevel/$secondLevel/$md5Site""_thumb.png" -convert "cache/tmp/$md5Site.png" -crop 1280x1024+0+0 "cache/img/$md5Site.png" && -convert "cache/img/$md5Site.png" -filter Lanczos -thumbnail "$thumbWidth" "cache/img/$md5Site""_thumb.png" +if [ $onlyThumb ] +then + convert "cache/tmp/$md5Site.png" -crop 1280x1024+0+0 -filter Lanczos -thumbnail "$thumbWidth" "cache/img/$md5Site""_thumb.png" +else + convert "cache/tmp/$md5Site.png" -crop 1280x1024+0+0 "cache/img/$md5Site.png" && + convert "cache/img/$md5Site.png" -filter Lanczos -thumbnail "$thumbWidth" "cache/img/$md5Site""_thumb.png" +fi rm "cache/tmp/$md5Site.png" -#if [[ -f "cache/img/$firstLevel/$secondLevel/$md5Site""_thumb.png" && -f "cache/img/$firstLevel/$secondLevel/$md5Site.png" ]] -if [[ -f "cache/img/$md5Site""_thumb.png" && -f "cache/img/$md5Site.png" ]] +if [ $onlyThumb ] then - echo 1 + if [[ -f "cache/img/$md5Site""_thumb.png" ]] + then + echo 1 + else + echo 0 + fi else - echo 0 + if [[ -f "cache/img/$md5Site""_thumb.png" && -f "cache/img/$md5Site.png" ]] + then + echo 1 + else + echo 0 + fi fi diff --git a/index.php b/index.php index 6e177d6..c264e7b 100644 --- a/index.php +++ b/index.php @@ -9,6 +9,7 @@ $GLOBALS['config']['maxErrorBeforeBan'] = 3; $GLOBALS['config']['banTime'] = 60; $GLOBALS['config']['defaultUrl'] = 'https://google.com'; $GLOBALS['config']['defaultThumbSize'] = '120x90'; +$GLOBALS['config']['onlyThumb'] = true; $GLOBALS['config']['thumbSize'] = array(1 => '100x80', '120x90', '200x160', '300x240', '400x320', '500x400'); if (!file_exists('cache/config/genConf.php')) { @@ -44,11 +45,11 @@ function testExistImg($file) { } } -function launchScript($url, $md5Url, $width, $height = '') { +function launchScript($url, $md5Url, $width) { $md5Url = escapeshellarg($md5Url); $url = escapeshellarg($url); $width = escapeshellarg($width); - exec('bin/thumb_server.sh ' . $url . ' ' . $md5Url . ' ' . $width . ' ' . $height, $result); + exec('bin/thumb_server.sh ' . $url . ' ' . $md5Url . ' ' . $width . ' ' . (bool)$GLOBALS['config']['onlyThumb'], $result); return $result; }