[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
|
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
|
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
|
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))`
|
randomSleep=`echo $((RANDOM%20))`
|
||||||
optimizeTool='' # external tool form optimize png
|
optimizeTool='' # external tool form optimize png
|
||||||
maxQueue=50 # max process in queue
|
maxQueue=50 # max process in queue
|
||||||
currentProcess=$(ps -e | grep -v grep | grep thumb_ | wc -l)
|
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 ]
|
if [ $currentProcess -gt $maxQueue ]
|
||||||
then
|
then
|
||||||
exit
|
exit
|
||||||
|
|
29
index.php
29
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) {
|
function launchScript($url, $md5Url, $width, $onlyThumb, $waitForResult = false) {
|
||||||
$md5Url = escapeshellarg($md5Url);
|
$md5Url = escapeshellarg($md5Url);
|
||||||
$url = escapeshellarg($url);
|
$url = escapeshellarg($url);
|
||||||
|
@ -168,11 +181,17 @@ function install() {
|
||||||
if (!is_file('cache/config/genConf.php')) {
|
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?>");
|
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')) {
|
if (!is_file('cache/logs/banUser.php')) {
|
||||||
file_put_contents('cache/logs/banUser.php', "<?php\n\n?>");
|
file_put_contents('cache/logs/banUser.php', "<?php\n\n?>");
|
||||||
}
|
}
|
||||||
if (!is_file('cache/logs/log.php')) {
|
if (!is_file('cache/logs/log.txt')) {
|
||||||
touch('cache/logs/log.php');
|
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>';
|
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();
|
checkInstall();
|
||||||
|
@ -226,9 +245,9 @@ if ($_GET) {
|
||||||
|
|
||||||
if (testExistImg($file) !== true || isset($ui['fr']) && (int)$ui['fr'] === 1) {
|
if (testExistImg($file) !== true || isset($ui['fr']) && (int)$ui['fr'] === 1) {
|
||||||
if (isset($ui['iw']) && (int)$ui['iw'] === 1) {
|
if (isset($ui['iw']) && (int)$ui['iw'] === 1) {
|
||||||
launchScript($defUrl, $md5Url, $width, true);
|
launchScript($defUrl, $md5Url, $width, $GLOBALS['config']['onlyThumb'], true);
|
||||||
} else {
|
} else {
|
||||||
$res = launchScript($defUrl, $md5Url, $width);
|
$res = launchScript($defUrl, $md5Url, $width, $GLOBALS['config']['onlyThumb'], false);
|
||||||
header("Content-type: image/png");
|
header("Content-type: image/png");
|
||||||
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
|
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
|
||||||
echo file_get_contents('bin/loadingGen.png');
|
echo file_get_contents('bin/loadingGen.png');
|
||||||
|
@ -327,7 +346,7 @@ if (empty($width)) {
|
||||||
<?php
|
<?php
|
||||||
if (!empty($success)) {
|
if (!empty($success)) {
|
||||||
echo '<div id="result">';
|
echo '<div id="result">';
|
||||||
echo '<img src="', $success['thumb'], '?r=', time(), '"/>';
|
echo '<img src="', $success['thumb'], '?r=', time(), '"/>';
|
||||||
echo '<p><label>', $width, '</label><input type="text" value="http://', $_SERVER['SERVER_NAME'], '/', $success['thumb'], '" onclick="this.select()"/></p>';
|
echo '<p><label>', $width, '</label><input type="text" value="http://', $_SERVER['SERVER_NAME'], '/', $success['thumb'], '" onclick="this.select()"/></p>';
|
||||||
if ($GLOBALS['config']['onlyThumb'] === false) {
|
if ($GLOBALS['config']['onlyThumb'] === false) {
|
||||||
echo '<p><label>1280x1024</label><input type="text" value="http://', $_SERVER['SERVER_NAME'], '/', $success['normal'], '" onclick="this.select()"/></p>';
|
echo '<p><label>1280x1024</label><input type="text" value="http://', $_SERVER['SERVER_NAME'], '/', $success['normal'], '" onclick="this.select()"/></p>';
|
||||||
|
|
Loading…
Reference in a new issue