diff --git a/README.md b/README.md index d258030..68cb2f0 100644 --- a/README.md +++ b/README.md @@ -169,6 +169,7 @@ See LICENSE file for more detail. - [W3c](https://www.w3schools.com/w3css/) for w3.css - [Fork Awesome](https://forkaweso.me/Fork-Awesome/) for icon + - [Iconify.design](https://icon-sets.iconify.design/iconamoon/star-off/) for default favicon - [embed/embed](https://github.com/oscarotero/Embed) for embed (fav and og) - [hassankhan/config](https://github.com/hassankhan/config) for config (config mananger) - [chrome-php/chrome](https://github.com/chrome-php/chrome) for chrome-php (wrapper for chrome dev-tool) diff --git a/app/Controllers/Backend.php b/app/Controllers/Backend.php index f09e107..87612bd 100644 --- a/app/Controllers/Backend.php +++ b/app/Controllers/Backend.php @@ -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; @@ -22,6 +23,7 @@ class Backend { private $conf; private $title = 'Settings'; private $passwordRequired = false; + private $search = null; /** * Handles the index action for the controller. @@ -65,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; @@ -107,6 +116,15 @@ class Backend { * @return void */ private function showInfos() { + if (!empty($this->params->search)) { + $search = htmlspecialchars(trim($this->params->search)); + if (!empty($search)) { + $this->search = $search; + } else { + $this->search = null; + } + } + if (!empty($this->params->start)) { $this->start = $this->params->start; } @@ -116,21 +134,23 @@ class Backend { } $conx = new DataBase(); - $genList = $conx->getList($this->start, $this->end); + $genList = $conx->getList($this->start, $this->end, $this->search); $total = $conx->getTotal(); $inError = $conx->getInError(); $inQueue = $this->getInQueue(); $start = $this->start; + $max = $this->max; $next = $start + $max; $previous = $start - ($max); + $search = $this->search; if (count($genList) < $this->max) { $next = $start; } if ($previous < 0) { - $previous = 0; + $previous = null; } require __DIR__ . '/../../tpl/infos.php'; diff --git a/app/Controllers/GenHmac.php b/app/Controllers/GenHmac.php index 3f6059e..072fcd5 100644 --- a/app/Controllers/GenHmac.php +++ b/app/Controllers/GenHmac.php @@ -3,6 +3,6 @@ namespace App\Controllers; class GenHmac { function index($params, $conf) { - echo hash_hmac('sha1', $params->url, $conf['key']); + echo hash_hmac('sha1', $params->url, $conf->key); } } \ No newline at end of file diff --git a/app/DataBase/DataBase.php b/app/DataBase/DataBase.php index 7df577e..5543808 100644 --- a/app/DataBase/DataBase.php +++ b/app/DataBase/DataBase.php @@ -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. * @@ -264,8 +296,12 @@ class DataBase { * * @return array An array of objects representing the records in the "soshot" table. */ - public function getList(int $start, int $end) { - $stmt = $this->db->prepare("SELECT * FROM soshot ORDER BY created DESC limit :start, :end;"); + public function getList(int $start, int $end, string $search = null) { + if ($search != null) { + $stmt = $this->db->prepare("SELECT * FROM soshot WHERE url like '%$search%' ORDER BY created DESC limit :start, :end;"); + } else { + $stmt = $this->db->prepare("SELECT * FROM soshot ORDER BY created DESC limit :start, :end;"); + } $stmt->execute(array(':start' => $start, ':end' => $end)); $result = $stmt->fetchAll(PDO::FETCH_OBJ); return $result; diff --git a/app/Soshot/GetFav.php b/app/Soshot/GetFav.php index febc379..7f6625a 100644 --- a/app/Soshot/GetFav.php +++ b/app/Soshot/GetFav.php @@ -33,18 +33,18 @@ class GetFav extends GetThumb { if (!is_null($info->favicon)) { if (!$favicon = @file_get_contents($info->favicon)) { - copy(__DIR__ . '/../../src/images/error_fav.' . $this->fileFormat, $this->demande->requestImg); + copy(__DIR__ . '/../../src/images/error_fav.png', $this->demande->requestImg); $this->db->addUpdate(2, $this->type); return true; } } elseif (!is_null($info->icon)) { if (!$favicon = @file_get_contents($info->icon)) { - copy(__DIR__ . '/../../src/images/error_fav.' . $this->fileFormat, $this->demande->requestImg); + copy(__DIR__ . '/../../src/images/error_fav.png', $this->demande->requestImg); $this->db->addUpdate(2, $this->type); return true; } } else { - copy(__DIR__ . '/../../src/images/error_fav.' . $this->fileFormat, $this->demande->requestImg); + copy(__DIR__ . '/../../src/images/error_fav.png', $this->demande->requestImg); $this->db->addUpdate(2, $this->type); return true; } @@ -95,7 +95,6 @@ class GetFav extends GetThumb { if (!file_exists($this->requestImg) && $this->type === 'fav') { $this->makeFavicon(); } - //echo ''; header("Content-type: image/$this->fileFormat"); header('Expires: ', gmdate('D, d M Y H:i:s', time()) . ' GMT'); echo file_get_contents($this->requestImg); diff --git a/app/Utils/DeleteGen.php b/app/Utils/DeleteGen.php new file mode 100644 index 0000000..1d880cf --- /dev/null +++ b/app/Utils/DeleteGen.php @@ -0,0 +1,18 @@ +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'); diff --git a/src/images/error_fav.png b/src/images/error_fav.png index 069194d..21368c1 100644 Binary files a/src/images/error_fav.png and b/src/images/error_fav.png differ diff --git a/tpl/infos.php b/tpl/infos.php index 0d49cc2..baa1dce 100644 --- a/tpl/infos.php +++ b/tpl/infos.php @@ -3,7 +3,6 @@ use App\Utils\ConvertStatus; use App\Utils\Domains; -//require_once 'nav.php'; ?>
@@ -15,6 +14,11 @@ use App\Utils\Domains;
  • Error :
  • +
    + + +
    + @@ -33,7 +37,14 @@ use App\Utils\Domains; - + @@ -50,8 +61,12 @@ use App\Utils\Domains;
    - « Previous - Next » + 0) : ?> + « Previous + + + Next » +
    @@ -59,17 +74,17 @@ use App\Utils\Domains;
    - × + ×

    - - - - - - + + + + + +
    @@ -127,8 +142,8 @@ use App\Utils\Domains; }); }); - function showDetail(el) { - + function fullNewtab(imgSrc) { + window.open(imgSrc); } // Get the modal @@ -140,4 +155,4 @@ use App\Utils\Domains; modal.style.display = "none"; } } - + \ No newline at end of file
    url); ?> + + url); ?> + + + + + created; ?> complete); ?> full); ?>