Merge branch 'dev'
This commit is contained in:
commit
06656d4142
11 changed files with 118 additions and 25 deletions
|
@ -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)
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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) {
|
||||
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;
|
||||
|
|
|
@ -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 '<img src="data:image/png;base64,'.base64_encode(file_get_contents($this->requestImg)).'">';
|
||||
header("Content-type: image/$this->fileFormat");
|
||||
header('Expires: ', gmdate('D, d M Y H:i:s', time()) . ' GMT');
|
||||
echo file_get_contents($this->requestImg);
|
||||
|
|
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();
|
||||
}
|
||||
|
|
|
@ -99,6 +99,10 @@ form label {
|
|||
width: 48%;
|
||||
}
|
||||
|
||||
.zoom {
|
||||
cursor: zoom-in;
|
||||
}
|
||||
|
||||
@media (max-width:768px) {
|
||||
|
||||
#mySidebar {
|
||||
|
|
|
@ -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');
|
||||
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 1.4 KiB |
|
@ -3,7 +3,6 @@
|
|||
use App\Utils\ConvertStatus;
|
||||
use App\Utils\Domains;
|
||||
|
||||
//require_once 'nav.php';
|
||||
?>
|
||||
<div class="w3-row soshot-main w3-margin-bottom">
|
||||
<div class="w3-container">
|
||||
|
@ -15,6 +14,11 @@ use App\Utils\Domains;
|
|||
<li>Error : <?= $inError; ?></li>
|
||||
</ul>
|
||||
|
||||
<form>
|
||||
<input type="text" name="search" value="<?= $search; ?>">
|
||||
<input type="submit" value="Rechercher">
|
||||
</form>
|
||||
|
||||
<table class="w3-table-all w3-hoverable">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -33,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>
|
||||
|
@ -50,8 +61,12 @@ use App\Utils\Domains;
|
|||
|
||||
<div class="w3-center w3-margin-top">
|
||||
<div class="w3-bar">
|
||||
<?php if ($start > 0) : ?>
|
||||
<a href="?page=infos&start=<?= $previous; ?>" class="w3-teal w3-button">« Previous</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($next != $start) :; ?>
|
||||
<a href="?page=infos&start=<?= $next; ?>" class="w3-teal w3-button">Next » </a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -59,17 +74,17 @@ 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>
|
||||
</p>
|
||||
<img class="w3-border w3c-margin" src="" id="complete" width="45%">
|
||||
<img class="w3-border w3c-margin" src="" id="full" width="35%">
|
||||
<img class="w3-border w3c-margin" src="" id="hd" width="30%">
|
||||
<img class="w3-border w3c-margin" src="" id="og" width="25%">
|
||||
<img class="w3-border w3c-margin" src="" id="nhd" width="20%">
|
||||
<img class="w3-border w3c-margin" src="" id="thumb" width="15%">
|
||||
<img class="w3-border w3c-margin zoom" src="" id="complete" width="45%" onclick="fullNewtab(this.src);">
|
||||
<img class="w3-border w3c-margin zoom" src="" id="full" width="35%" onclick="fullNewtab(this.src);">
|
||||
<img class="w3-border w3c-margin zoom" src="" id="hd" width="30%" onclick="fullNewtab(this.src);">
|
||||
<img class="w3-border w3c-margin zoom" src="" id="og" width="25%" onclick="fullNewtab(this.src);">
|
||||
<img class="w3-border w3c-margin zoom" src="" id="nhd" width="20%" onclick="fullNewtab(this.src);">
|
||||
<img class="w3-border w3c-margin zoom" src="" id="thumb" width="15%" onclick="fullNewtab(this.src);">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -127,8 +142,8 @@ use App\Utils\Domains;
|
|||
});
|
||||
});
|
||||
|
||||
function showDetail(el) {
|
||||
|
||||
function fullNewtab(imgSrc) {
|
||||
window.open(imgSrc);
|
||||
}
|
||||
|
||||
// Get the modal
|
||||
|
|
Loading…
Reference in a new issue