[add] admin can delete thumbnail
This commit is contained in:
parent
04a2abeb97
commit
3d72e66ed3
3 changed files with 60 additions and 12 deletions
|
@ -14,7 +14,7 @@ if (isset($ui['log']) && !in_array($ui['log'], $acceptParam['log']) || $_SESSION
|
|||
die('Tell me, Mr Anderson, what good is a phone call if you\'re unable to speak ?');
|
||||
}
|
||||
|
||||
if (empty($ui['log'])) {
|
||||
if (empty($ui['log']) && empty($ui['ac'])) {
|
||||
$ui['log'] = 'success';
|
||||
}
|
||||
|
||||
|
@ -123,8 +123,16 @@ function keepThisThumb($hash, $log) {
|
|||
if (isset($ui['clear']) && (int)$ui['clear'] === 1) {
|
||||
clearLog($ui['log']);
|
||||
}
|
||||
?>
|
||||
<div class="hMenu">
|
||||
if (isset($ui['ac']) && $ui['ac'] === 'delete' && isset($ui['thumb']) && !empty($ui['thumb'])) {
|
||||
$imgUrl = pathForFile('m', $ui['thumb']);
|
||||
if (file_exists($_SERVER['DOCUMENT_ROOT'].'/'.$imgUrl.'.png')) {
|
||||
unlink($_SERVER['DOCUMENT_ROOT'].'/'.$imgUrl.'.png');
|
||||
}
|
||||
if (file_exists($imgUrl.'_thumb.png')) {
|
||||
unlink($_SERVER['DOCUMENT_ROOT'].'/'.$imgUrl.'_thumb.png');
|
||||
}
|
||||
}
|
||||
echo '<div class="hMenu">
|
||||
<ul>
|
||||
<li>
|
||||
<a href="?p=admin&log=success">Success</a>
|
||||
|
@ -138,14 +146,52 @@ if (isset($ui['clear']) && (int)$ui['clear'] === 1) {
|
|||
<li>
|
||||
<a href="?p=admin&log=other">Other error</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="?p=admin&ac=delete">Delete thumbshot</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="?logout=1">Logout</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="log">
|
||||
<?php
|
||||
if ($ui['log'] === 'success') {
|
||||
<div id="log">';
|
||||
if ($ui['ac'] === 'delete') {
|
||||
if (isset($ui['deleteUrl']) && testValidUrl($ui['deleteUrl']) !== true) {
|
||||
unset($ui['deleteUrl']);
|
||||
echo '<div>Not a valid url.</div>';
|
||||
}
|
||||
echo '
|
||||
<form method="post" action="?">
|
||||
<p>
|
||||
<label>Url </label>';
|
||||
if (empty($ui['deleteUrl'])) {
|
||||
echo '<input type="text" name="deleteUrl"/>';
|
||||
} else {
|
||||
echo '<input type="text" name="deleteUrl" value="', $ui['deleteUrl'], '"/>';
|
||||
}
|
||||
echo '</p>
|
||||
<p>
|
||||
<input type="hidden" name="p" value="admin"/>
|
||||
<input type="hidden" name="ac" value="delete"/>
|
||||
<input type="submit"/>
|
||||
</p>
|
||||
</form>';
|
||||
if (!empty($ui['deleteUrl'])) {
|
||||
$ui['deleteUrl'] = trim(rawurldecode($ui['deleteUrl']));
|
||||
$ui['deleteUrl'] = rtrim($ui['deleteUrl'], '/');
|
||||
$hashUrl = sha1($GLOBALS['config']['salt'].$ui['deleteUrl']);
|
||||
$imgUrl = pathForFile('m', $hashUrl);
|
||||
echo '</div>
|
||||
<div id="result">
|
||||
<p>
|
||||
<a href="', $imgUrl, '.png"><img src="', $imgUrl, '_thumb.png"/></a>
|
||||
</p>
|
||||
<a href="?p=admin&ac=delete&thumb=', $hashUrl, '">Delete this thumb</a>
|
||||
</div>';
|
||||
}
|
||||
|
||||
}
|
||||
if (isset($ui['log']) && $ui['log'] === 'success') {
|
||||
$logs = parseSuccessLog();
|
||||
if (!empty($logs)) {
|
||||
$nbThumb = 0;
|
||||
|
@ -157,7 +203,7 @@ if ($ui['log'] === 'success') {
|
|||
}
|
||||
echo '<p class="clear" ><a href="?p=admin&log=success&clear=1">Clear success log</a></p>';
|
||||
}
|
||||
if ($ui['log'] === 'suspect' || $ui['log'] === 'retry' || $ui['log'] === 'other') {
|
||||
if (isset($ui['log']) && ($ui['log'] === 'suspect' || $ui['log'] === 'retry' || $ui['log'] === 'other')) {
|
||||
if (isset($ui['hash']) && !empty($ui['hash'])) {
|
||||
$ui['hash'] = validHash($ui['hash']);
|
||||
if (isset($ui['root']) && (int)$ui['root'] === 1) {
|
||||
|
@ -165,6 +211,9 @@ if ($ui['log'] === 'suspect' || $ui['log'] === 'retry' || $ui['log'] === 'other'
|
|||
}
|
||||
if (isset($ui['cache']) && (int)$ui['cache'] === 1) {
|
||||
$success['filePath'] = pathForFile($ui['s'], $ui['hash']).'.png';
|
||||
if (!file_exists($success['filePath'])) {
|
||||
$success['filePath'] = 'data:image/png;base64,'.base64_encode(file_get_contents('bin/error.png'));
|
||||
}
|
||||
}
|
||||
if (isset($ui['keep']) && (int)$ui['keep'] === 1) {
|
||||
keepThisThumb($ui['hash'], $ui['log']);
|
||||
|
@ -184,7 +233,6 @@ if ($ui['log'] === 'suspect' || $ui['log'] === 'retry' || $ui['log'] === 'other'
|
|||
}
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
if (!empty($success)) {
|
||||
echo '<div id="result">';
|
||||
echo '<img src="', $success['filePath'], '?r=', time(), '" style="width:100%;"/>';
|
||||
|
|
|
@ -181,7 +181,7 @@ function testValidUrl($url) {
|
|||
}
|
||||
return true;
|
||||
} else {
|
||||
return array('msg' => 'Url are not valid.');
|
||||
return array('msg' => 'Not a valid url.');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ a:visited {
|
|||
form, #result, #header, .message, .hMenu, #log {
|
||||
padding: 1em;
|
||||
text-align: center;
|
||||
width: 50%;
|
||||
width: 60%;
|
||||
margin: 1em auto;
|
||||
background-color: #ffffff;
|
||||
border-radius: 5px;
|
||||
|
|
Loading…
Reference in a new issue