diff --git a/bin/rasterize.js b/bin/rasterize.js
index 7ce641e..50bbf74 100644
--- a/bin/rasterize.js
+++ b/bin/rasterize.js
@@ -7,7 +7,7 @@ if (phantom.args.length < 2) {
} else {
address = phantom.args[0];
output = phantom.args[1];
- page.settings.userAgent = 'SoShot Agent';
+ page.settings.userAgent = 'Mozilla/5.0 (X11; Linux x86_64; rv:39.0) Gecko/20100101 Firefox/39.0';
page.viewportSize = { width: 1280, height:1024};
page.open(address, function (status) {
diff --git a/bin/thumb_server.sh b/bin/thumb_server.sh
index bb76c4d..77a6491 100755
--- a/bin/thumb_server.sh
+++ b/bin/thumb_server.sh
@@ -62,6 +62,8 @@ else
timeout $timeOut ./phantomjs_x86 --disk-cache=false --local-storage-path=bin/ --ignore-ssl-errors=true rasterize.js "$site" "../cache/tmp/$hashUrl.png"
fi
+sleep 5
+
if [ ! -f "../cache/tmp/$hashUrl.png" ]
then
echo 0
diff --git a/inc/admin.php b/inc/admin.php
index 8ce693f..a98bc56 100644
--- a/inc/admin.php
+++ b/inc/admin.php
@@ -5,19 +5,15 @@ $acceptParam['log'] = array(
'other',
'retry'
);
-
if (isset($ui['pwd'])) {
checkAdmin($ui['pwd']);
}
-
if (isset($ui['log']) && !in_array($ui['log'], $acceptParam['log']) || $_SESSION['login'] !== true) {
die('Tell me, Mr Anderson, what good is a phone call if you\'re unable to speak ?');
}
-
if (empty($ui['log']) && empty($ui['ac'])) {
$ui['log'] = 'success';
}
-
function clearLog($log) {
if (file_exists('cache/logs/'.$log.'.txt') && is_file('cache/logs/'.$log.'.txt')) {
file_put_contents('cache/logs/'.$log.'.txt', '');
@@ -85,7 +81,7 @@ function manualGen($hash, $log) {
chdir('bin/');
exec('bash thumb_server.sh manual '.escapeshellarg($hash).' '.escapeshellarg($line[3]).' '.escapeshellarg($line[4]).' trc 1', $result);
chdir('../');
- if ((int)$result[0] === 1) {
+ if ((int)$result[0] == 1) {
$res['success'] = 1;
$res['filePath'] = pathForFile($line[4], $hash).'.png';
$res['base64'] = 'data:image/png;base64,'.base64_encode(file_get_contents($res['filePath']));
@@ -101,6 +97,9 @@ function delAndRegen($hash, $size) {
if (file_exists($path.'_thumb.png')) {
unlink($path.'_thumb.png');
}
+ if (file_exists($path.'_complete.png')) {
+ unlink($path.'_complete.png');
+ }
}
function tryRootDomain($hash, $log) {
@@ -162,6 +161,9 @@ echo '
';
if (isset($ui['ac']) && $ui['ac'] === 'delete') {
+ if($ui['delThumb']){
+ delAndRegen($ui['delThumb'], $size);
+ }
if (isset($ui['deleteUrl']) && testValidUrl($ui['deleteUrl']) !== true) {
unset($ui['deleteUrl']);
echo '
Not a valid url.
';
@@ -186,16 +188,15 @@ if (isset($ui['ac']) && $ui['ac'] === 'delete') {
$ui['deleteUrl'] = trim(rawurldecode($ui['deleteUrl']));
$ui['deleteUrl'] = rtrim($ui['deleteUrl'], '/');
$hashUrl = sha1($GLOBALS['config']['salt'].$ui['deleteUrl']);
- $imgUrl = pathForFile('m', $hashUrl);
+ $imgUrl = pathForFile('', $hashUrl);
echo '
';
}
-
}
if (isset($ui['log']) && $ui['log'] === 'success') {
$logs = parseSuccessLog();
@@ -203,7 +204,7 @@ if (isset($ui['log']) && $ui['log'] === 'success') {
$nbThumb = 0;
$nbThumb = count($logs['genTime']);
echo 'Total request : ', $nbThumb, '';
- echo 'Moyenne per request : ', round(array_sum($logs['genTime']) / $nbThumb, 2), 's (min (', min($logs['genTime']), 's) max (', max($logs['genTime']), 's))';
+ echo 'Moyenne per request : ', round(array_sum($logs['genTime']) / $nbThumb, 2), 's (min (', min($logs['genTime']), 's) max (', max($logs['genTime']), 's))';
} else {
echo 'No result';
}
@@ -227,12 +228,13 @@ if (isset($ui['log']) && ($ui['log'] === 'suspect' || $ui['log'] === 'retry' ||
}
if (isset($ui['mGen']) && (int)$ui['mGen'] === 1)
$success = manualGen($ui['hash'], $ui['log']);
+ $success['base64'] = 'data:image/png;base64,'.base64_encode(file_get_contents($success['filePath']));
}
$logs = parseFailLog($ui['log']);
if (!empty($logs)) {
echo '';
} else {
@@ -244,6 +246,7 @@ if (!empty($success)) {
echo '';
diff --git a/index.php b/index.php
index d221c9b..432b763 100644
--- a/index.php
+++ b/index.php
@@ -43,6 +43,7 @@ if (get_magic_quotes_gpc()) {
$value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
return $value;
}
+
$_POST = array_map('stripslashes_deep', $_POST);
$_GET = array_map('stripslashes_deep', $_GET);
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
@@ -327,10 +328,31 @@ function removeOlderThan($dir = 'cache/img/shortLive') {
function pathForFile($size, $hashUrl) {
$startPath = substr($hashUrl, 0, 2).'/'.substr($hashUrl, 2, 2).'/';
+ if(empty($size)){
+ $size = tryDetectSize($startPath.$hashUrl);
+ }
$file = 'cache/img/'.$size.'/'.$startPath.$hashUrl;
return $file;
}
+function tryDetectSize($file) {
+ if (is_file('cache/img/s/'.$file.'_thumb.png')) {
+ return 's';
+ }
+ if (is_file('cache/img/m/'.$file.'_thumb.png')) {
+ return 'm';
+ }
+ if (is_file('cache/img/l/'.$file.'_thumb.png')) {
+ return 'l';
+ }
+ if (is_file('cache/img/xl/'.$file.'_thumb.png')) {
+ return 'xl';
+ }
+ if (is_file('cache/img/xxl/'.$file.'_thumb.png')) {
+ return 'xxl';
+ }
+}
+
function validHash($hash) {
if (empty($hash)) {
die('You talking to me');
@@ -390,9 +412,9 @@ function n_print($data, $name = '') {
echo '', $name, '
';
echo '
@@ -613,7 +635,7 @@ if (!empty($ui['request']) && $ui['p'] !== 'install' && $ui['p'] !== 'login' &&