[fix] manual delete

This commit is contained in:
Knah Tsaeb 2015-07-10 11:04:56 +02:00
parent 47df04fbfc
commit 2f1c5277e0
4 changed files with 41 additions and 14 deletions

View File

@ -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) {

View File

@ -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

View File

@ -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 '<div class="hMenu">
</div>
<div id="log">';
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 '<div>Not a valid url.</div>';
@ -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 '</div>
<div id="result">
<p>
<a href="', $imgUrl, '.png"><img src="', $imgUrl, '_thumb.png"/></a>
</p>
<a href="?p=admin&amp;ac=delete&amp;thumb=', $hashUrl, '">Delete this thumb</a>
<a href="?p=admin&amp;ac=delete&amp;delThumb=', $hashUrl, '">Delete this thumb</a>
</div>';
}
}
if (isset($ui['log']) && $ui['log'] === 'success') {
$logs = parseSuccessLog();
@ -227,6 +228,7 @@ 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)) {
@ -244,6 +246,7 @@ if (!empty($success)) {
echo '<div id="result">';
echo '<img src="', $success['base64'], '" style="width:100%;"/>';
echo '<p><input type="text" value="http://', $_SERVER['SERVER_NAME'], '/', $success['filePath'], '" onclick="this.select()"/></p>';
echo '<a href="?p=admin&log=', $ui['log'], '&hash=', $value['1'], '&mGen=1">manuel launch</a> / ';
echo '<a href="?p=admin&log=', $ui['log'], '&hash=', $ui['hash'], '&root=1">Try with root domain</a> / ';
echo '<a href="?p=admin&log=', $ui['log'], '&hash=', $ui['hash'], '&keep=1">Keep this thumbshot</a>';
echo '</div>';

View File

@ -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');