From 54760730bf7f51ce3d66c995091a640f8cf3233f Mon Sep 17 00:00:00 2001 From: Knah Tsaeb Date: Mon, 14 Oct 2013 12:30:24 +0200 Subject: [PATCH] [add] fix manual generation and preview --- inc/admin.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/inc/admin.php b/inc/admin.php index 78ab1a2..73f968a 100644 --- a/inc/admin.php +++ b/inc/admin.php @@ -82,7 +82,9 @@ function manualGen($hash, $log) { $line = explode(' --- ', $line); $hash = sha1($GLOBALS['config']['salt'].rawurldecode($line[1])); file_put_contents('cache/tmp/manual.txt', $line[1]); - exec('bin/thumb_server.sh manual '.escapeshellarg($hash).' '.escapeshellarg($line[3]).' '.escapeshellarg($line[4]).' 0 1', $result); + chdir('bin/'); + exec('bash thumb_server.sh manual '.escapeshellarg($hash).' '.escapeshellarg($line[3]).' '.escapeshellarg($line[4]).' 0 1', $result); + chdir('../'); if ((int)$result[0] === 1) { $res['success'] = 1; $res['filePath'] = pathForFile($line[4], $hash).'.png'; @@ -108,10 +110,13 @@ function tryRootDomain($hash, $log) { $parts = parse_url($line[1]); $url = $parts['scheme'].'://'.trim($parts['host']); file_put_contents('cache/tmp/manual.txt', $url); - exec('bin/thumb_server.sh manual '.escapeshellarg($hash).' '.escapeshellarg($line[3]).' '.escapeshellarg($line[4]).' 0 1', $result); + chdir('bin/'); + exec('bash thumb_server.sh manual '.escapeshellarg($hash).' '.escapeshellarg($line[3]).' '.escapeshellarg($line[4]).' 0 1', $result); + chdir('../'); 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'])); return $res; } } @@ -155,7 +160,7 @@ echo '
'; -if ($ui['ac'] === 'delete') { +if (isset($ui['ac']) && $ui['ac'] === 'delete') { if (isset($ui['deleteUrl']) && testValidUrl($ui['deleteUrl']) !== true) { unset($ui['deleteUrl']); echo '
Not a valid url.
'; @@ -197,7 +202,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'; } @@ -211,6 +216,7 @@ if (isset($ui['log']) && ($ui['log'] === 'suspect' || $ui['log'] === 'retry' || } if (isset($ui['cache']) && (int)$ui['cache'] === 1) { $success['filePath'] = pathForFile($ui['s'], $ui['hash']).'.png'; + $success['base64'] = 'data:image/png;base64,'.base64_encode(file_get_contents($success['filePath'])); if (!file_exists($success['filePath'])) { $success['base64'] = 'data:image/png;base64,'.base64_encode(file_get_contents('bin/error.png')); }