[add] now can generate thumbshot of entire page

This commit is contained in:
Knah Tsaeb 2015-07-09 17:21:32 +02:00
parent d742fe8b3e
commit 9ae1fbbb06
4 changed files with 131 additions and 83 deletions

View File

@ -1,5 +1,5 @@
var page = new WebPage(), var page = require('webpage').create(),
address, output, size; address, output;
if (phantom.args.length < 2) { if (phantom.args.length < 2) {
//console.log('Usage: rasterize.js URL filename'); //console.log('Usage: rasterize.js URL filename');
@ -8,7 +8,7 @@ if (phantom.args.length < 2) {
address = phantom.args[0]; address = phantom.args[0];
output = phantom.args[1]; output = phantom.args[1];
page.settings.userAgent = 'SoShot Agent'; page.settings.userAgent = 'SoShot Agent';
page.viewportSize = { width: 1280, height: 1024 }; page.viewportSize = { width: 1280, height:1024};
page.open(address, function (status) { page.open(address, function (status) {
if (status !== 'success') { if (status !== 'success') {

View File

@ -4,10 +4,10 @@
# All info at http://forge.leslibres.org/projects/soshot # All info at http://forge.leslibres.org/projects/soshot
site=$1 # url for thumbshot site=$1 # url for thumbshot
hashUrl=$2 # hash(url) is the name of final image hashUrl=$2 # hash(url) is the name of final image
thumbSize=$3 # size of thumb widthxheight ex : 190x90 thumbSize=$3 # size of thumb widthxheight ex : 190x90
sizeNameDir=$4 # name of size dir sizeNameDir=$4 # name of size dir
onlyThumb=$5 # make only thumbshot no full size image renderType=$5 # make only thumbshot / thumbshot + realSize / thumbshot + complete / thumbshot + complete + realSize
waitForResult=$6 # if true we try to make soon as possible or add to queue waitForResult=$6 # if true we try to make soon as possible or add to queue
########################################## ##########################################
@ -26,7 +26,7 @@ firstLevel=${hashUrl:0:2}
secondLevel=${hashUrl:2:2} secondLevel=${hashUrl:2:2}
startPath=$sizeNameDir/$firstLevel/$secondLevel/ startPath=$sizeNameDir/$firstLevel/$secondLevel/
getArch=$(getconf LONG_BIT) getArch=$(getconf LONG_BIT)
echo $getArch #echo $getArch
if [ $site == "manual" ] if [ $site == "manual" ]
then then
site=$(cat "../cache/tmp/manual.txt") site=$(cat "../cache/tmp/manual.txt")
@ -56,17 +56,16 @@ fi
start_time=`date +%s` start_time=`date +%s`
if [ $getArch -eq 64 ] if [ $getArch -eq 64 ]
then then
timeout $timeOut ./phantomjs_x64 --disk-cache=false --local-storage-path=bin/ --ignore-ssl-errors=true rasterize.js "$site" "../cache/tmp/$hashUrl.png" timeout $timeOut ./phantomjs_x64 --disk-cache=false --local-storage-path=bin/ --ignore-ssl-errors=true rasterize.js "$site" "../cache/tmp/$hashUrl.png"
else else
timeout $timeOut ./phantomjs_x86 --disk-cache=false --local-storage-path=bin/ --ignore-ssl-errors=true rasterize.js "$site" "../cache/tmp/$hashUrl.png" timeout $timeOut ./phantomjs_x86 --disk-cache=false --local-storage-path=bin/ --ignore-ssl-errors=true rasterize.js "$site" "../cache/tmp/$hashUrl.png"
fi fi
if [ ! -f "../cache/tmp/$hashUrl.png" ] if [ ! -f "../cache/tmp/$hashUrl.png" ]
then then
echo 0 echo 0
errorCode=`echo $(curl -k --write-out %{http_code} --silent -S --connect-timeout $timeOut \--no-keepalive --output /dev/null $site)` errorCode=`echo $(curl -k --write-out %{http_code} --silent -S --connect-timeout $timeOut \--no-keepalive --output /dev/null $site)`
if [ $site == 'manual' ] if [ $site == 'manual' ]
then then
errorCode='manual' errorCode='manual'
@ -90,39 +89,73 @@ then
fi fi
exit exit
fi fi
if [ $onlyThumb == 1 ]
then
case $renderType in
# thumbnail only
t)
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 ] if [ $optimizeTool ]
then then
eval $optimizeTool "../cache/img/$startPath""$hashUrl""_thumb.png" eval $optimizeTool "../cache/img/$startPath""$hashUrl""_thumb.png"
fi fi
else rm "../cache/tmp/$hashUrl.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"
fi
fi
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 then
echo 1 echo 1
else else
echo 0 echo 0
fi fi
else ;;
if [[ -f "../cache/img/$startPath""$hashUrl""_thumb.png" && -f "../cache/img/$startPath""$hashUrl.png" ]] # thumbnail + complete
tc)
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" "../cache/tmp/$hashUrl.png"
fi
mv "../cache/tmp/$hashUrl.png" "../cache/img/$startPath""$hashUrl""_complete.png"
if [[ -f "../cache/img/$startPath""$hashUrl""_thumb.png" && -f "../cache/img/$startPath""$hashUrl""_complete.png" ]]
then then
echo 1 echo 1
else else
echo 0 echo 0
fi fi
fi ;;
# thumbnail + realsize
tr)
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"
fi
rm "../cache/tmp/$hashUrl.png"
if [[ -f "../cache/img/$startPath""$hashUrl""_thumb.png" && -f "../cache/img/$startPath""$hashUrl.png" ]]
then
echo 1
else
echo 0
fi
;;
# thumbnail + realsize + complete
trc)
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" "../cache/tmp/$hashUrl.png"
fi
mv "../cache/tmp/$hashUrl.png" "../cache/img/$startPath""$hashUrl""_complete.png"
if [[ -f "../cache/img/$startPath""$hashUrl""_thumb.png" && -f "../cache/img/$startPath""$hashUrl.png" && -f "../cache/img/$startPath""$hashUrl""_complete.png" ]]
then
echo 1
else
echo 0
fi
;;
esac
if $log if $log
then then
end_time=`date +%s` end_time=`date +%s`

View File

@ -34,8 +34,11 @@ if (!empty($success)) {
echo '<h3>This image will be removed in ', $GLOBALS['config']['expireCache'], 'h</h3>'; echo '<h3>This image will be removed in ', $GLOBALS['config']['expireCache'], 'h</h3>';
echo '<img src="data:image/png;base64,',base64_encode(file_get_contents($success['thumb'])), '"/>'; echo '<img src="data:image/png;base64,',base64_encode(file_get_contents($success['thumb'])), '"/>';
echo '<p><label>Thumbshot</label><input type="text" value="http://', $_SERVER['SERVER_NAME'], '/', $success['thumb'], '" onclick="this.select()"/>'; echo '<p><label>Thumbshot</label><input type="text" value="http://', $_SERVER['SERVER_NAME'], '/', $success['thumb'], '" onclick="this.select()"/>';
if ($GLOBALS['config']['onlyThumb'] === false) { if ($GLOBALS['config']['activeFullSize'] === true) {
echo '<p><label>1280x1024</label><input type="text" value="http://', $_SERVER['SERVER_NAME'], '/', $success['thumb'], '" onclick="this.select()"/></p>'; echo '<p><label>1280x1024</label><input type="text" value="http://', $_SERVER['SERVER_NAME'], '/', $success['normal'], '" onclick="this.select()"/></p>';
}
if ($GLOBALS['config']['activeComplete'] === true) {
echo '<p><label>Complete</label><input type="text" value="http://', $_SERVER['SERVER_NAME'], '/', $success['complete'], '" onclick="this.select()"/></p>';
} }
echo '</div>'; echo '</div>';
} }

122
index.php
View File

@ -1,6 +1,5 @@
<?php <?php
session_start(); session_start();
if (empty($_SESSION['login'])) { if (empty($_SESSION['login'])) {
$_SESSION['login'] = false; $_SESSION['login'] = false;
} }
@ -18,8 +17,6 @@ $GLOBALS['config']['banTime'] = 60;
$GLOBALS['config']['defaultUrl'] = 'https://duckduckgo.com/'; $GLOBALS['config']['defaultUrl'] = 'https://duckduckgo.com/';
// default size for thumbnail // default size for thumbnail
$GLOBALS['config']['defaultThumbSize'] = '120x90'; $GLOBALS['config']['defaultThumbSize'] = '120x90';
// generate only thumbnail or generate thumbnail + 1280x1024 image
$GLOBALS['config']['onlyThumb'] = false;
// list of available size for thumb // list of available size for thumb
$GLOBALS['config']['thumbSize'] = array( $GLOBALS['config']['thumbSize'] = array(
's' => '120x90', 's' => '120x90',
@ -28,17 +25,19 @@ $GLOBALS['config']['thumbSize'] = array(
'xl' => '400x320', 'xl' => '400x320',
'xxl' => '500x400' 'xxl' => '500x400'
); );
// create thumshot 1280x1024
$GLOBALS['config']['activeFullSize'] = false;
// create thumbshot of complete page
$GLOBALS['config']['activeComplete'] = false;
// Remove image older than 12 hours // Remove image older than 12 hours
$GLOBALS['config']['expireCache'] = 12; $GLOBALS['config']['expireCache'] = 12;
// Disable exec command and use cron task // Disable exec command and use cron task
$GLOBALS['config']['disableExec'] = true; $GLOBALS['config']['disableExec'] = true;
// Enable log for success, suspect, error // Enable log for success, suspect, error
$GLOBALS['config']['log'] = false; $GLOBALS['config']['log'] = true;
if (file_exists('cache/config/options.php')) { if (file_exists('cache/config/options.php')) {
require 'cache/config/options.php'; require 'cache/config/options.php';
} }
if (get_magic_quotes_gpc()) { if (get_magic_quotes_gpc()) {
function stripslashes_deep($value) { function stripslashes_deep($value) {
$value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value); $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
@ -49,7 +48,6 @@ if (get_magic_quotes_gpc()) {
$_GET = array_map('stripslashes_deep', $_GET); $_GET = array_map('stripslashes_deep', $_GET);
$_COOKIE = array_map('stripslashes_deep', $_COOKIE); $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
} }
if (!empty($_POST)) { if (!empty($_POST)) {
$ui = $_POST; $ui = $_POST;
$ui['request'] = 'form'; $ui['request'] = 'form';
@ -61,60 +59,65 @@ if (!empty($_GET)) {
$ui['request'] = 'api'; $ui['request'] = 'api';
unset($_GET); unset($_GET);
} }
if (empty($ui['request'])) { if (empty($ui['request'])) {
$ui['request'] = ''; $ui['request'] = '';
} }
if (empty($ui['p'])) { if (empty($ui['p'])) {
$ui['p'] = 'index'; $ui['p'] = 'index';
} }
if (empty($ui['fr'])) { if (empty($ui['fr'])) {
$ui['fr'] = ''; $ui['fr'] = '';
} }
if (empty($ui['t'])) {
$ui['t'] = 't';
}
if (isset($ui['logout']) && (int)$ui['logout'] === 1) { if (isset($ui['logout']) && (int)$ui['logout'] === 1) {
session_destroy(); session_destroy();
header("Location:?"); header("Location:?");
exit(); exit();
} }
if (!file_exists('cache/config/genConf.php')) { if (!file_exists('cache/config/genConf.php')) {
$serverKey = install(); $serverKey = install();
$ui['p'] = 'install'; $ui['p'] = 'install';
} }
require 'cache/config/genConf.php'; require 'cache/config/genConf.php';
if ($GLOBALS['config']['pwd'] === 'install' && $ui['p'] !== 'install') { if ($GLOBALS['config']['pwd'] === 'install' && $ui['p'] !== 'install') {
reloadInstall(); reloadInstall();
header("Location:?"); header("Location:?");
} }
if (($GLOBALS['config']['onlyLocalServer'] === true && $_SERVER['REMOTE_ADDR'] !== '127.0.0.1') || checkIfBan() === true) { if (($GLOBALS['config']['onlyLocalServer'] === true && $_SERVER['REMOTE_ADDR'] !== '127.0.0.1') || checkIfBan() === true) {
header("HTTP/1.0 404 Not Found"); header("HTTP/1.0 404 Not Found");
echo "<h1>404 Not Found</h1>"; echo "<h1>404 Not Found</h1>";
echo "The page that you have requested could not be found."; echo "The page that you have requested could not be found.";
exit(); exit();
} }
if ($GLOBALS['config']['NoWebPage'] === true && empty($_GET)) { if ($GLOBALS['config']['NoWebPage'] === true && empty($_GET)) {
header("HTTP/1.0 404 Not Found"); header("HTTP/1.0 404 Not Found");
echo "<h1>404 Not Found</h1>"; echo "<h1>404 Not Found</h1>";
echo "The page that you have requested could not be found."; echo "The page that you have requested could not be found.";
exit(); exit();
} }
function testExistImg($file) { function testExistImg($file) {
if ($GLOBALS['config']['onlyThumb'] === true) { if ($GLOBALS['config']['activeFullSize'] && $GLOBALS['config']['activeComplete']) {
if (file_exists($file.'_thumb.png')) { if (file_exists($file.'_thumb.png') && file_exists($file.'.png') && file_exists($file.'_complete.png')) {
return true;
} else {
return false;
}
} elseif ($GLOBALS['config']['activeFullSize']) {
if (file_exists($file.'_thumb.png') && file_exists($file.'.png')) {
return true;
} else {
return false;
}
} elseif ($GLOBALS['config']['activeComplete']) {
if (file_exists($file.'_thumb.png') && file_exists($file.'_complete.png')) {
return true; return true;
} else { } else {
return false; return false;
} }
} else { } else {
if (file_exists($file.'_thumb.png') && file_exists($file.'.png')) { if (file_exists($file.'_thumb.png')) {
return true; return true;
} else { } else {
return false; return false;
@ -134,37 +137,40 @@ function testExistImg($file) {
* @param $waitForResult (bool) * @param $waitForResult (bool)
* @return * @return
*/ */
function launchScript($url, $hashUrl, $width, $size, $onlyThumb, $waitForResult = false) { function launchScript($url, $hashUrl, $width, $size, $waitForResult = false) {
$hashUrl = escapeshellarg($hashUrl); $hashUrl = escapeshellarg($hashUrl);
$url = escapeshellarg($url); $url = escapeshellarg($url);
$width = escapeshellarg($width); $width = escapeshellarg($width);
if ($GLOBALS['config']['onlyThumb'] === true) { if ($GLOBALS['config']['activeFullSize'] && $GLOBALS['config']['activeComplete']) {
$onlyThumb = 1; $renderType = 'trc';
} elseif ($GLOBALS['config']['activeFullSize']) {
$renderType = 'tr';
} elseif ($GLOBALS['config']['activeComplete']) {
$renderType = 'tc';
} else { } else {
$onlyThumb = 0; $renderType = 't';
} }
if ($GLOBALS['config']['disableExec'] === false) { if ($GLOBALS['config']['disableExec'] === false) {
chdir('bin/'); chdir('bin/');
if ($waitForResult === false) { if ($waitForResult === false) {
exec('bash thumb_server.sh '.$url.' '.$hashUrl.' '.$width.' '.$size.' '.$onlyThumb.' > /dev/null &', $result); exec('bash thumb_server.sh '.$url.' '.$hashUrl.' '.$width.' '.$size.' '.$renderType.' > /dev/null &', $result);
} else { } else {
exec('bash thumb_server.sh '.$url.' '.$hashUrl.' '.$width.' '.$size.' '.$onlyThumb.' 1', $result); exec('bash thumb_server.sh '.$url.' '.$hashUrl.' '.$width.' '.$size.' '.$renderType.' 1', $result);
} }
chdir('../'); chdir('../');
} else { } else {
makeQueueFile($url, $hashUrl, $width, $size, $onlyThumb); makeQueueFile($url, $hashUrl, $width, $size, $renderType);
$result = 0; $result = 0;
} }
return $result; return $result;
} }
function makeQueueFile($url, $hashUrl, $width, $size, $onlyThumb) { function makeQueueFile($url, $hashUrl, $width, $size, $renderType) {
$url = str_replace('\'', '', $url); $url = str_replace('\'', '', $url);
$hashUrl = str_replace('\'', '', $hashUrl); $hashUrl = str_replace('\'', '', $hashUrl);
$width = str_replace('\'', '', $width); $width = str_replace('\'', '', $width);
if (!file_exists('cache/cronTask/'.$hashUrl.'.hash')) { if (!file_exists('cache/cronTask/'.$hashUrl.'.hash')) {
$data = $url.' '.$hashUrl.' '.$width.' '.$size.' '.$onlyThumb. "\n"; $data = $url.' '.$hashUrl.' '.$width.' '.$size.' '.$renderType."\n";
file_put_contents('cache/cronTask/'.$hashUrl.'.hash', $data); file_put_contents('cache/cronTask/'.$hashUrl.'.hash', $data);
} }
} }
@ -263,7 +269,6 @@ function install() {
$salt = sha1(uniqid(rand(), true).'_'.mt_rand()); $salt = sha1(uniqid(rand(), true).'_'.mt_rand());
$serverKey = substr(sha1(uniqid(rand(), true).'_'.mt_rand().$salt), 0, 12); $serverKey = substr(sha1(uniqid(rand(), true).'_'.mt_rand().$salt), 0, 12);
$encryptServerKey = sha1($serverKey.$salt); $encryptServerKey = sha1($serverKey.$salt);
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\$GLOBALS['config']['pwd'] = 'install';\n?>"); file_put_contents('cache/config/genConf.php', "<?php\n\$GLOBALS['config']['serverKey'] = '$encryptServerKey';\n\$GLOBALS['config']['salt'] = '$salt';\n\$GLOBALS['config']['pwd'] = 'install';\n?>");
} }
@ -386,20 +391,30 @@ function n_print($data, $name = '') {
echo '<h2>', $name, '</h2>'; echo '<h2>', $name, '</h2>';
echo '<fieldset style="border: 1px solid orange; padding: 5px;color: #333; background-color: #fff;">'; echo '<fieldset style="border: 1px solid orange; padding: 5px;color: #333; background-color: #fff;">';
echo '<legend style="border:1px solid orange;padding: 1px;background-color:#eee;color:orange;"> echo '<legend style="border:1px solid orange;padding: 1px;background-color:#eee;color:orange;">
', basename($aBackTrace[0]['file']), ' ligne => ', $aBackTrace[0]['line'], ' ', basename($aBackTrace[0]['file']), ' ligne => ', $aBackTrace[0]['line'], '
</legend>'; </legend>';
echo '<pre>', htmlentities(print_r($data, 1)), '</pre>'; echo '<pre>', htmlentities(print_r($data, 1)), '</pre>';
echo ' echo '
</fieldset> </fieldset>
<br /> <br />
'; ';
} }
function printThumbShot($file) { function printThumbShot($file, $renderType) {
ob_end_clean(); ob_end_clean();
header("Content-type: image/png"); header("Content-type: image/png");
header('Expires: ', gmdate('D, d M Y H:i:s', time()).' GMT'); header('Expires: ', gmdate('D, d M Y H:i:s', time()).' GMT');
echo file_get_contents($file.'_thumb.png'); switch ($renderType) {
case 'c' :
echo file_get_contents($file.'_complete.png');
break;
case 'r' :
echo file_get_contents($file.'.png');
break;
default :
echo file_get_contents($file.'_thumb.png');
break;
}
exit(); exit();
} }
@ -430,11 +445,10 @@ function testIfImg($url) {
} }
} }
function makeImgThumb($url, $ext, $hashUrl, $width, $path, $onlyThumb) { function makeImgThumb($url, $ext, $hashUrl, $width, $path, $renderType) {
if (!function_exists('imagecreatefromjpeg')) { if (!function_exists('imagecreatefromjpeg')) {
return false; return false;
} }
$image = file_get_contents($url); $image = file_get_contents($url);
$fullSize = file_put_contents('cache/tmp/'.$hashUrl.'.'.$ext, $image); $fullSize = file_put_contents('cache/tmp/'.$hashUrl.'.'.$ext, $image);
if ($ext === 'jpg' || $ext === 'jpeg') { if ($ext === 'jpg' || $ext === 'jpeg') {
@ -450,7 +464,6 @@ function makeImgThumb($url, $ext, $hashUrl, $width, $path, $onlyThumb) {
unlink('cache/tmp/'.$hashUrl.'.'.$ext); unlink('cache/tmp/'.$hashUrl.'.'.$ext);
return false; return false;
} }
$w = imagesx($tmpImg); $w = imagesx($tmpImg);
$h = imagesy($tmpImg); $h = imagesy($tmpImg);
$ystart = 0; $ystart = 0;
@ -485,17 +498,14 @@ function makeImgThumb($url, $ext, $hashUrl, $width, $path, $onlyThumb) {
*/ */
checkInstall(); checkInstall();
removeOlderThan(); removeOlderThan();
if (empty($defUrl)) { if (empty($defUrl)) {
$defUrl = $GLOBALS['config']['defaultUrl']; $defUrl = $GLOBALS['config']['defaultUrl'];
} }
if (isset($ui['s']) && array_key_exists($ui['s'], $GLOBALS['config']['thumbSize'])) { if (isset($ui['s']) && array_key_exists($ui['s'], $GLOBALS['config']['thumbSize'])) {
$width = $GLOBALS['config']['thumbSize'][$ui['s']]; $width = $GLOBALS['config']['thumbSize'][$ui['s']];
} else { } else {
$width = $GLOBALS['config']['defaultThumbSize']; $width = $GLOBALS['config']['defaultThumbSize'];
} }
// Generate or return img // Generate or return img
if (!empty($ui['request']) && $ui['p'] !== 'install' && $ui['p'] !== 'login' && $ui['p'] !== 'admin') { if (!empty($ui['request']) && $ui['p'] !== 'install' && $ui['p'] !== 'login' && $ui['p'] !== 'admin') {
if (empty($ui['url'])) { if (empty($ui['url'])) {
@ -512,15 +522,15 @@ if (!empty($ui['request']) && $ui['p'] !== 'install' && $ui['p'] !== 'login' &&
$file = 'cache/img/shortLive/'.$startPath.$hashUrl; $file = 'cache/img/shortLive/'.$startPath.$hashUrl;
$file = 'cache/img/shortLive/'.$startPath.$hashUrl; $file = 'cache/img/shortLive/'.$startPath.$hashUrl;
} }
if (testExistImg($file) === true && (int)$ui['fr'] !== 1) { if (testExistImg($file) === true && (int)$ui['fr'] !== 1) {
if ($ui['request'] === 'api') { if ($ui['request'] === 'api') {
printThumbShot($file); printThumbShot($file, $ui['t']);
} }
if ($ui['request'] === 'form') { if ($ui['request'] === 'form') {
$success = array( $success = array(
'normal' => $file.'.png', 'normal' => $file.'.png',
'thumb' => $file.'_thumb.png' 'thumb' => $file.'_thumb.png',
'complete' => $file.'_complete.png'
); );
} }
} else { } else {
@ -537,14 +547,15 @@ if (!empty($ui['request']) && $ui['p'] !== 'install' && $ui['p'] !== 'login' &&
} }
if ($testUrl !== true) { if ($testUrl !== true) {
if (!file_exists('cache/logs/'.$hashUrl.'log')) { if (!file_exists('cache/logs/'.$hashUrl.'log')) {
file_put_contents('cache/logs/suspect/'.$hashUrl.'.log', $_SERVER['REMOTE_ADDR'].' --- '.$ui['url'].' --- '.$hashUrl.' --- '.$width.' --- '.$ui['s'].' --- '.$GLOBALS['config']['onlyThumb'].' --- true'."\n"); file_put_contents('cache/logs/suspect/'.$hashUrl.'.log', $_SERVER['REMOTE_ADDR'].' --- '.$ui['url'].' --- '.$hashUrl.' --- '.$width.' --- '.$ui['s'].' --- '.$renderType.' --- true'."\n");
} }
if ($ui['request'] === 'api') { if ($ui['request'] === 'api') {
printThumbShot('bin/error'); printThumbShot('bin/error');
} else { } else {
$success = array( $success = array(
'normal' => 'bin/error.png', 'normal' => 'bin/error.png',
'thumb' => 'bin/error_thumb.png' 'thumb' => 'bin/error_thumb.png',
'complete' => 'bin/error.png'
); );
} }
} else { } else {
@ -552,11 +563,10 @@ if (!empty($ui['request']) && $ui['p'] !== 'install' && $ui['p'] !== 'login' &&
if ($ext !== false) { if ($ext !== false) {
$genWidth = explode("x", $width); $genWidth = explode("x", $width);
if ($ui['request'] === 'api') { if ($ui['request'] === 'api') {
$makeImg = makeImgThumb($ui['url'], $ext, $hashUrl, $genWidth[0], 'cache/img/'.$ui['s'].'/'.$startPath, $GLOBALS['config']['onlyThumb']); $makeImg = makeImgThumb($ui['url'], $ext, $hashUrl, $genWidth[0], 'cache/img/'.$ui['s'].'/'.$startPath, $ui['t']);
} else { } else {
$makeImg = makeImgThumb($ui['url'], $ext, $hashUrl, $genWidth[0], 'cache/img/shortLive/'.$startPath, $GLOBALS['config']['onlyThumb']); $makeImg = makeImgThumb($ui['url'], $ext, $hashUrl, $genWidth[0], 'cache/img/shortLive/'.$startPath, $ui['t']);
} }
if ($makeImg === true) { if ($makeImg === true) {
$GLOBALS['config']['disableExec'] = true; $GLOBALS['config']['disableExec'] = true;
if ($ui['request'] === 'api') { if ($ui['request'] === 'api') {
@ -564,17 +574,18 @@ if (!empty($ui['request']) && $ui['p'] !== 'install' && $ui['p'] !== 'login' &&
} else { } else {
$success = array( $success = array(
'normal' => $file.'.png', 'normal' => $file.'.png',
'thumb' => $file.'_thumb.png' 'thumb' => $file.'_thumb.png',
'complete' => $file.'_complete.png'
); );
} }
} }
} }
if ((isset($ui['iw']) && (int)$ui['iw'] === 1 && $ui['request'] === 'api')) { if ((isset($ui['iw']) && (int)$ui['iw'] === 1 && $ui['request'] === 'api')) {
$res = launchScript($defUrl, $hashUrl, $width, $ui['s'], $GLOBALS['config']['onlyThumb'], true); $res = launchScript($defUrl, $hashUrl, $width, $ui['s'], true);
} elseif (isset($ui['iw']) && (int)$ui['iw'] === 1 && $ui['request'] === 'form') { } elseif (isset($ui['iw']) && (int)$ui['iw'] === 1 && $ui['request'] === 'form') {
$res = launchScript($defUrl, $hashUrl, $width, 'shortLive', $GLOBALS['config']['onlyThumb'], true); $res = launchScript($defUrl, $hashUrl, $width, 'shortLive', true);
} else { } else {
$res = launchScript($defUrl, $hashUrl, $width, $ui['s'], $GLOBALS['config']['onlyThumb'], false); $res = launchScript($defUrl, $hashUrl, $width, $ui['s'], false);
} }
if ($ui['request'] === 'api') { if ($ui['request'] === 'api') {
$file = 'bin/loadingGen'; $file = 'bin/loadingGen';
@ -585,7 +596,8 @@ if (!empty($ui['request']) && $ui['p'] !== 'install' && $ui['p'] !== 'login' &&
} }
$success = array( $success = array(
'normal' => $file.'.png', 'normal' => $file.'.png',
'thumb' => $file.'_thumb.png' 'thumb' => $file.'_thumb.png',
'complete' => $file.'_complete.png'
); );
} }
} }
@ -602,7 +614,7 @@ if (!empty($ui['request']) && $ui['p'] !== 'install' && $ui['p'] !== 'login' &&
</head> </head>
<body> <body>
<?php <?php
require getPage($ui['p']); require getPage($ui['p']);
?> ?>
</body> </body>
</html> </html>