diff --git a/bin/thumb_server.sh b/bin/thumb_server.sh index ffba1cd..53a1820 100755 --- a/bin/thumb_server.sh +++ b/bin/thumb_server.sh @@ -10,12 +10,17 @@ onlyThumb=$4 # make only thumbshot no full size image waitForResult=$5 # if true we try to make soon as possible or add to queue maxThread=3 # 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 -log=true # log all generation success and error +log=false # log all generation success and error randomSleep=`echo $((RANDOM%20))` optimizeTool='' # external tool form optimize png maxQueue=50 # max process in queue currentProcess=$(ps -e | grep -v grep | grep thumb_ | wc -l) +if [ ! -f "cache/tmp/$md5Site.png" ] +then + source "../cache/config/serverOptions.php" +fi + if [ $currentProcess -gt $maxQueue ] then exit diff --git a/index.php b/index.php index 0df6f38..682e63d 100644 --- a/index.php +++ b/index.php @@ -69,6 +69,19 @@ function testExistImg($file) { } } + +/** + * Run the bash script for generate thumbnail + * + * @author Knah Tsaeb + * @date 2013-02-12 + * @param $url (string) url for thumbshot + * @param $md5Url (md5) md5($url) + * @param $width (string) size of thumbnail 190x90 + * @param $onlyThumb (bool) + * @param $waiForResult (bool) + * @return + */ function launchScript($url, $md5Url, $width, $onlyThumb, $waitForResult = false) { $md5Url = escapeshellarg($md5Url); $url = escapeshellarg($url); @@ -168,11 +181,17 @@ function install() { if (!is_file('cache/config/genConf.php')) { file_put_contents('cache/config/genConf.php', ""); } + if (!is_file('cache/config/serverOptions.php')) { + touch('cache/config/serverOptions.php'); + } + if (!is_file('cache/config/options.php')) { + file_put_contents('cache/config/options.php', ""); + } if (!is_file('cache/logs/banUser.php')) { file_put_contents('cache/logs/banUser.php', ""); } - if (!is_file('cache/logs/log.php')) { - touch('cache/logs/log.php'); + if (!is_file('cache/logs/log.txt')) { + touch('cache/logs/log.txt'); } echo '
This is the key for generate thumbnail whith GET method. Save it, this key is secret, don\'t share it.

', $serverKey, '

'; checkInstall(); @@ -226,9 +245,9 @@ if ($_GET) { if (testExistImg($file) !== true || isset($ui['fr']) && (int)$ui['fr'] === 1) { if (isset($ui['iw']) && (int)$ui['iw'] === 1) { - launchScript($defUrl, $md5Url, $width, true); + launchScript($defUrl, $md5Url, $width, $GLOBALS['config']['onlyThumb'], true); } else { - $res = launchScript($defUrl, $md5Url, $width); + $res = launchScript($defUrl, $md5Url, $width, $GLOBALS['config']['onlyThumb'], false); header("Content-type: image/png"); header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); echo file_get_contents('bin/loadingGen.png'); @@ -327,7 +346,7 @@ if (empty($width)) { '; - echo ''; + echo ''; echo '

'; if ($GLOBALS['config']['onlyThumb'] === false) { echo '

';