diff --git a/bin/cronTask.sh b/bin/cronTask.sh new file mode 100644 index 0000000..b070ea2 --- /dev/null +++ b/bin/cronTask.sh @@ -0,0 +1,14 @@ +#!/bin/bash +queueDir="../cache/cronTask/" + +for file in $queueDir*.hash +do + if [ -f $file ]; + then + while read site hashUrl thumbSize sizeNameDir onlyThumb + do + bash thumb_server.sh "$site" "$hashUrl" "$thumbSize" "$sizeNameDir" "$onlyThumb" "0" + rm $file + done < $file + fi +done diff --git a/bin/thumb_server.sh b/bin/thumb_server.sh index 26e8561..b6e316f 100755 --- a/bin/thumb_server.sh +++ b/bin/thumb_server.sh @@ -9,9 +9,11 @@ thumbSize=$3 # size of thumb widthxheight ex : 190x90 sizeNameDir=$4 # name of size dir onlyThumb=$5 # make only thumbshot no full size image waitForResult=$6 # if true we try to make soon as possible or add to queue + ########################################## ##### DON'T EDIT THIS PARAM USE ##### ##### cache/config/serverOptions.php ##### +##### for overwrite options ##### ########################################## maxThread=1 # max parralle work. For me the best is nb core - 1 timeOut=60 # default time out, after this time the site are declared in error @@ -26,15 +28,15 @@ startPath=$sizeNameDir/$firstLevel/$secondLevel/ if [ $site == "manual" ] then - site=$(cat "cache/tmp/manual.txt") - echo '' > "cache/tmp/manual.txt" + site=$(cat "../cache/tmp/manual.txt") + echo '' > "../cache/tmp/manual.txt" fi -mkdir -p "cache/img/$startPath" +mkdir -p "../cache/img/$startPath" -if [ -f "cache/config/serverOptions.php" ] +if [ -f "../cache/config/serverOptions.php" ] then - source "cache/config/serverOptions.php" + source "../cache/config/serverOptions.php" fi if [ $currentProcess -gt $maxQueue ] @@ -52,9 +54,9 @@ then fi start_time=`date +%s` -timeout $timeOut ./bin/phantomjs --disk-cache=false --local-storage-path=/bin/ --ignore-ssl-errors=true /bin/rasterize.js "$site" "cache/tmp/$hashUrl.png" +timeout $timeOut ./phantomjs --disk-cache=false --local-storage-path=bin/ --ignore-ssl-errors=true rasterize.js "$site" "../cache/tmp/$hashUrl.png" -if [ ! -f "cache/tmp/$hashUrl.png" ] +if [ ! -f "../cache/tmp/$hashUrl.png" ] then echo 0 errorCode=`echo $(curl -k --write-out %{http_code} --silent -S --connect-timeout $timeOut \--no-keepalive --output /dev/null $site)` @@ -63,10 +65,10 @@ then errorCode='manual' fi case $errorCode in - 000) cp "bin/000.png" "cache/img/$startPath""$hashUrl""_thumb.png" && cp "bin/000.png" "cache/img/$startPath""$hashUrl.png" ;; - 200) cp "bin/error.png" "cache/img/$startPath""$hashUrl""_thumb.png" && cp "bin/error.png" "cache/img/$startPath""$hashUrl.png" ;; - 404) cp "bin/404.png" "cache/img/$startPath""$hashUrl""_thumb.png" && cp "bin/404.png" "cache/img/$startPath""$hashUrl.png" ;; - *) cp "bin/error.png" "cache/img/$startPath""$hashUrl""_thumb.png" && cp "bin/error.png" "cache/img/$startPath""$hashUrl.png" ;; + 000) cp "../bin/000.png" "../cache/img/$startPath""$hashUrl""_thumb.png" && cp "../bin/000.png" "../cache/img/$startPath""$hashUrl.png" ;; + 200) cp "../bin/error.png" "../cache/img/$startPath""$hashUrl""_thumb.png" && cp "../bin/error.png" "../cache/img/$startPath""$hashUrl.png" ;; + 404) cp "../bin/404.png" "../cache/img/$startPath""$hashUrl""_thumb.png" && cp "../bin/404.png" "../cache/img/$startPath""$hashUrl.png" ;; + *) cp "..bin/error.png" "../cache/img/$startPath""$hashUrl""_thumb.png" && cp "../bin/error.png" "../cache/img/$startPath""$hashUrl.png" ;; esac if $log then @@ -74,40 +76,40 @@ then logDate=`date +'[%a %d %b %Y] [%H:%M:%S]'` if [ $errorCode == 200 ] then - echo "none --- "$site" --- "$hashUrl" --- "$thumbSize" --- "$sizeNameDir" --- "$onlyThumb" --- true --- "$errorCode > "cache/logs/retry/"$hashUrl".log" + echo "none --- "$site" --- "$hashUrl" --- "$thumbSize" --- "$sizeNameDir" --- "$onlyThumb" --- true --- "$errorCode > "../cache/logs/retry/"$hashUrl".log" else - echo "none --- "$site" --- "$hashUrl" --- "$thumbSize" --- "$sizeNameDir" --- "$onlyThumb" --- true --- "$errorCode > "cache/logs/other/"$hashUrl".log" + echo "none --- "$site" --- "$hashUrl" --- "$thumbSize" --- "$sizeNameDir" --- "$onlyThumb" --- true --- "$errorCode > "../cache/logs/other/"$hashUrl".log" fi fi exit fi if [ $onlyThumb == 1 ] then - convert "cache/tmp/$hashUrl.png" -crop 1280x1024+0+0 -filter Lanczos -thumbnail "$thumbSize" "cache/img/$startPath""$hashUrl""_thumb.png" + convert "../cache/tmp/$hashUrl.png" -crop 1280x1024+0+0 -filter Lanczos -thumbnail "$thumbSize" "../cache/img/$startPath""$hashUrl""_thumb.png" if [ $optimizeTool ] then - eval $optimizeTool "cache/img/$startPath""$hashUrl""_thumb.png" + eval $optimizeTool "../cache/img/$startPath""$hashUrl""_thumb.png" fi else - convert "cache/tmp/$hashUrl.png" -crop 1280x1024+0+0 "cache/img/$startPath""$hashUrl.png" - convert "cache/img/$startPath""$hashUrl.png" -filter Lanczos -thumbnail "$thumbSize" "cache/img/$startPath""$hashUrl""_thumb.png" + convert "../cache/tmp/$hashUrl.png" -crop 1280x1024+0+0 "../cache/img/$startPath""$hashUrl.png" + convert "../cache/img/$startPath""$hashUrl.png" -filter Lanczos -thumbnail "$thumbSize" "../cache/img/$startPath""$hashUrl""_thumb.png" if [ $optimizeTool ] then - eval $optimizeTool "cache/img/$startPath""$hashUrl""_thumb.png" "cache/img/$startPath""$hashUrl.png" + eval $optimizeTool "../cache/img/$startPath""$hashUrl""_thumb.png" "../cache/img/$startPath""$hashUrl.png" fi fi -rm "cache/tmp/$hashUrl.png" +rm "../cache/tmp/$hashUrl.png" if [ $onlyThumb ] then - if [[ -f "cache/img/$startPath""$hashUrl""_thumb.png" ]] + if [[ -f "../cache/img/$startPath""$hashUrl""_thumb.png" ]] then echo 1 else echo 0 fi else - if [[ -f "cache/img/$startPath""$hashUrl""_thumb.png" && -f "cache/img/$startPath""$hashUrl.png" ]] + if [[ -f "../cache/img/$startPath""$hashUrl""_thumb.png" && -f "../cache/img/$startPath""$hashUrl.png" ]] then echo 1 else @@ -118,5 +120,5 @@ if $log then end_time=`date +%s` logDate=`date +'[%a %d %b %Y] [%H:%M:%S]'` - echo $logDate `expr $end_time - $start_time`s >> 'cache/logs/success.txt' + echo $logDate `expr $end_time - $start_time`s >> '../cache/logs/success.txt' fi diff --git a/inc/.htaccess b/inc/.htaccess new file mode 100644 index 0000000..b584d98 --- /dev/null +++ b/inc/.htaccess @@ -0,0 +1,2 @@ +Allow from none +Deny from all diff --git a/inc/admin.php b/inc/admin.php index 9541cb5..6daef1f 100644 --- a/inc/admin.php +++ b/inc/admin.php @@ -14,7 +14,7 @@ if (isset($ui['log']) && !in_array($ui['log'], $acceptParam['log']) || $_SESSION die('Tell me, Mr Anderson, what good is a phone call if you\'re unable to speak ?'); } -if (empty($ui['log'])) { +if (empty($ui['log']) && empty($ui['ac'])) { $ui['log'] = 'success'; } @@ -123,8 +123,16 @@ function keepThisThumb($hash, $log) { if (isset($ui['clear']) && (int)$ui['clear'] === 1) { clearLog($ui['log']); } -?> -