[add] fix manual generation and preview

This commit is contained in:
Knah Tsaeb 2013-10-14 12:30:24 +02:00
parent 1ef67023fe
commit 54760730bf

View file

@ -82,7 +82,9 @@ function manualGen($hash, $log) {
$line = explode(' --- ', $line); $line = explode(' --- ', $line);
$hash = sha1($GLOBALS['config']['salt'].rawurldecode($line[1])); $hash = sha1($GLOBALS['config']['salt'].rawurldecode($line[1]));
file_put_contents('cache/tmp/manual.txt', $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) { if ((int)$result[0] === 1) {
$res['success'] = 1; $res['success'] = 1;
$res['filePath'] = pathForFile($line[4], $hash).'.png'; $res['filePath'] = pathForFile($line[4], $hash).'.png';
@ -108,10 +110,13 @@ function tryRootDomain($hash, $log) {
$parts = parse_url($line[1]); $parts = parse_url($line[1]);
$url = $parts['scheme'].'://'.trim($parts['host']); $url = $parts['scheme'].'://'.trim($parts['host']);
file_put_contents('cache/tmp/manual.txt', $url); 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) { if ((int)$result[0] === 1) {
$res['success'] = 1; $res['success'] = 1;
$res['filePath'] = pathForFile($line[4], $hash).'.png'; $res['filePath'] = pathForFile($line[4], $hash).'.png';
$res['base64'] = 'data:image/png;base64,'.base64_encode(file_get_contents($res['filePath']));
return $res; return $res;
} }
} }
@ -155,7 +160,7 @@ echo '<div class="hMenu">
</ul> </ul>
</div> </div>
<div id="log">'; <div id="log">';
if ($ui['ac'] === 'delete') { if (isset($ui['ac']) && $ui['ac'] === 'delete') {
if (isset($ui['deleteUrl']) && testValidUrl($ui['deleteUrl']) !== true) { if (isset($ui['deleteUrl']) && testValidUrl($ui['deleteUrl']) !== true) {
unset($ui['deleteUrl']); unset($ui['deleteUrl']);
echo '<div>Not a valid url.</div>'; echo '<div>Not a valid url.</div>';
@ -211,6 +216,7 @@ if (isset($ui['log']) && ($ui['log'] === 'suspect' || $ui['log'] === 'retry' ||
} }
if (isset($ui['cache']) && (int)$ui['cache'] === 1) { if (isset($ui['cache']) && (int)$ui['cache'] === 1) {
$success['filePath'] = pathForFile($ui['s'], $ui['hash']).'.png'; $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'])) { if (!file_exists($success['filePath'])) {
$success['base64'] = 'data:image/png;base64,'.base64_encode(file_get_contents('bin/error.png')); $success['base64'] = 'data:image/png;base64,'.base64_encode(file_get_contents('bin/error.png'));
} }