Close #468 : Add remove option in backend
This commit is contained in:
parent
4d7c3dbbc5
commit
24bc73c3ad
6 changed files with 70 additions and 5 deletions
|
@ -7,6 +7,7 @@ if (session_status() === PHP_SESSION_NONE) {
|
|||
}
|
||||
|
||||
use App\DataBase\DataBase;
|
||||
use App\Utils\DeleteGen;
|
||||
use App\Utils\Page;
|
||||
use App\Utils\ShowImg;
|
||||
use Noodlehaus\Config;
|
||||
|
@ -66,6 +67,13 @@ class Backend {
|
|||
exit();
|
||||
}
|
||||
|
||||
if (!empty($params->deleteGen)) {
|
||||
$deleteGen = new DeleteGen();
|
||||
$deleteGen->deleteGen($params->deleteGen);
|
||||
$reset = new DataBase();
|
||||
$reset->reset($params->deleteGen);
|
||||
}
|
||||
|
||||
$this->conf = $conf;
|
||||
$this->params = $params;
|
||||
|
||||
|
|
|
@ -192,6 +192,38 @@ class DataBase {
|
|||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset .
|
||||
*
|
||||
* This method prepares an SQL UPDATE statement using the provided parameters, and
|
||||
* executes it to update a record in the "soshot" table in the database.
|
||||
*
|
||||
* @param string $update The value to update in the type column of the record.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function reset(string $id) {
|
||||
|
||||
$resetParam = [];
|
||||
|
||||
$updateParams = $this->params;
|
||||
unset($updateParams['id'], $updateParams['url'], $updateParams['created']);
|
||||
|
||||
foreach ($updateParams as $key => $value) {
|
||||
$resetParam[] = $key . ' = null';
|
||||
}
|
||||
|
||||
$strUpdateParam = implode(',', $resetParam);
|
||||
|
||||
$stmt = $this->db->prepare("UPDATE soshot
|
||||
SET $strUpdateParam
|
||||
WHERE id=:id;");
|
||||
|
||||
$result = $stmt->execute([
|
||||
':id' => $id
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a record with the given ID exists in the database.
|
||||
*
|
||||
|
|
18
app/Utils/DeleteGen.php
Normal file
18
app/Utils/DeleteGen.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace App\Utils;
|
||||
|
||||
class DeleteGen {
|
||||
|
||||
function deleteGen(string $hashFile) {
|
||||
$dir = __DIR__ . '/../../cache/img/' . substr($hashFile, 0, 4) . '/';
|
||||
if (is_dir($dir)) {
|
||||
$listFile = glob($dir . '*');
|
||||
foreach ($listFile as $file) {
|
||||
if (is_file($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,7 +17,7 @@ class ShowImg {
|
|||
echo file_get_contents($img);
|
||||
} else {
|
||||
// todo not gen
|
||||
echo file_get_contents(__DIR__ . '/../../src/images/error_thumb.png');
|
||||
echo file_get_contents(__DIR__ . '/../../src/images/hd_generation_in_progress.jpg');
|
||||
}
|
||||
exit();
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ $router = new Router();
|
|||
$router->addRoute(['/', '/index.php', '/index'], 'App\Controllers\Home', 'GET');
|
||||
$router->addRoute('/api', 'App\Controllers\Result', 'GET');
|
||||
$router->addRoute('/hmac', 'App\Controllers\GenHmac', 'GET');
|
||||
//$router->addRoute('/debug', 'App\Bin\ThumbShoter', 'GET');
|
||||
$router->addRoute('/debug', 'App\Bin\ThumbShoter', 'GET');
|
||||
$router->addRoute('/backend', 'App\Controllers\Backend', 'GET');
|
||||
$router->addRoute('/logout', 'App\Controllers\Logout', 'GET');
|
||||
|
||||
|
|
|
@ -37,7 +37,14 @@ use App\Utils\Domains;
|
|||
<tbody>
|
||||
<?php foreach ($genList as $value) : ?>
|
||||
<tr>
|
||||
<td><a href="#" class="linkDetail" data-hmac="<?= $value->id; ?>" data-href="<?= $value->url; ?>"><?= Domains::getDomain($value->url); ?></a></td>
|
||||
<td>
|
||||
<span class="w3-left ">
|
||||
<a href="#" class="linkDetail" data-hmac="<?= $value->id; ?>" data-href="<?= $value->url; ?>"><?= Domains::getDomain($value->url); ?></a>
|
||||
</span>
|
||||
<span class="w3-right" style="width:40px">
|
||||
<a href="?page=infos&deleteGen=<?= $value->id; ?>"><i class="fa fa-trash-o w3-text-red" aria-hidden="true"></i></a>
|
||||
</span>
|
||||
</td>
|
||||
<td><?= $value->created; ?></td>
|
||||
<td><?= ConvertStatus::convertToIcon($value->complete); ?></td>
|
||||
<td><?= ConvertStatus::convertToIcon($value->full); ?></td>
|
||||
|
@ -67,7 +74,7 @@ use App\Utils\Domains;
|
|||
<div id="detail" class="w3-modal">
|
||||
<div class="w3-modal-content w3-animate-opacity">
|
||||
<div class="w3-container">
|
||||
<span onclick="document.getElementById('detail').style.display='none'" class="w3-button w3-display-topright">×</span>
|
||||
<span onclick="document.getElementById('detail').style.display='none'" class="w3-button w3-display-topright w3-xxlarge">×</span>
|
||||
<p>
|
||||
<img src="" id="fav" height="32px">
|
||||
<a href="" id="titlePreview" target="_blanck"></a>
|
||||
|
|
Loading…
Reference in a new issue