[add] #462 : Config file for bash script
[fix] bad numbers paramters in launchScript function
This commit is contained in:
parent
7490983bb0
commit
9b79c38d87
2 changed files with 30 additions and 6 deletions
|
@ -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
|
||||
|
|
27
index.php
27
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', "<?php\n\$GLOBALS['config']['serverKey'] = '$encryptServerKey';\n\$GLOBALS['config']['salt'] = '$salt';\n?>");
|
||||
}
|
||||
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', "<?php\n\n?>");
|
||||
}
|
||||
if (!is_file('cache/logs/banUser.php')) {
|
||||
file_put_contents('cache/logs/banUser.php', "<?php\n\n?>");
|
||||
}
|
||||
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 '<div>This is the key for generate thumbnail whith GET method. Save it, this key is secret, don\'t share it. <p class="alert">', $serverKey, '</p></div>';
|
||||
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');
|
||||
|
|
Loading…
Reference in a new issue