Compare commits

..

No commits in common. "06656d414239b4a0f4bc47da040162c7c4178a35" and "41fef540bf40afb37a7913b2527377e5f79a5169" have entirely different histories.

11 changed files with 25 additions and 118 deletions

View file

@ -169,7 +169,6 @@ 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)

View file

@ -7,7 +7,6 @@ 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;
@ -23,7 +22,6 @@ class Backend {
private $conf;
private $title = 'Settings';
private $passwordRequired = false;
private $search = null;
/**
* Handles the index action for the controller.
@ -67,13 +65,6 @@ 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;
@ -116,15 +107,6 @@ 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;
}
@ -134,23 +116,21 @@ class Backend {
}
$conx = new DataBase();
$genList = $conx->getList($this->start, $this->end, $this->search);
$genList = $conx->getList($this->start, $this->end);
$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 = null;
$previous = 0;
}
require __DIR__ . '/../../tpl/infos.php';

View file

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

View file

@ -192,38 +192,6 @@ 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.
*
@ -296,12 +264,8 @@ class DataBase {
*
* @return array An array of objects representing the records in the "soshot" table.
*/
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;");
}
public function getList(int $start, int $end) {
$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;

View file

@ -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.png', $this->demande->requestImg);
copy(__DIR__ . '/../../src/images/error_fav.' . $this->fileFormat, $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.png', $this->demande->requestImg);
copy(__DIR__ . '/../../src/images/error_fav.' . $this->fileFormat, $this->demande->requestImg);
$this->db->addUpdate(2, $this->type);
return true;
}
} else {
copy(__DIR__ . '/../../src/images/error_fav.png', $this->demande->requestImg);
copy(__DIR__ . '/../../src/images/error_fav.' . $this->fileFormat, $this->demande->requestImg);
$this->db->addUpdate(2, $this->type);
return true;
}
@ -95,6 +95,7 @@ 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);

View file

@ -1,18 +0,0 @@
<?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);
}
}
}
}
}

View file

@ -17,7 +17,7 @@ class ShowImg {
echo file_get_contents($img);
} else {
// todo not gen
echo file_get_contents(__DIR__ . '/../../src/images/hd_generation_in_progress.jpg');
echo file_get_contents(__DIR__ . '/../../src/images/error_thumb.png');
}
exit();
}

View file

@ -99,10 +99,6 @@ form label {
width: 48%;
}
.zoom {
cursor: zoom-in;
}
@media (max-width:768px) {
#mySidebar {

View file

@ -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: 1.4 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View file

@ -3,6 +3,7 @@
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">
@ -14,11 +15,6 @@ 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>
@ -37,14 +33,7 @@ use App\Utils\Domains;
<tbody>
<?php foreach ($genList as $value) : ?>
<tr>
<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><a href="#" class="linkDetail" data-hmac="<?= $value->id; ?>" data-href="<?= $value->url; ?>"><?= Domains::getDomain($value->url); ?></a></td>
<td><?= $value->created; ?></td>
<td><?= ConvertStatus::convertToIcon($value->complete); ?></td>
<td><?= ConvertStatus::convertToIcon($value->full); ?></td>
@ -61,12 +50,8 @@ 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">&laquo; Previous</a>
<?php endif; ?>
<?php if ($next != $start) :; ?>
<a href="?page=infos&start=<?= $next; ?>" class="w3-teal w3-button">Next &raquo; </a>
<?php endif; ?>
<a href="?page=infos&start=<?= $previous; ?>" class="w3-teal w3-button">&laquo; Previous</a>
<a href="?page=infos&start=<?= $next; ?>" class="w3-teal w3-button">Next &raquo; </a>
</div>
</div>
</div>
@ -74,17 +59,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 w3-xxlarge">&times;</span>
<span onclick="document.getElementById('detail').style.display='none'" class="w3-button w3-display-topright">&times;</span>
<p>
<img src="" id="fav" height="32px">
<a href="" id="titlePreview" target="_blanck"></a>
</p>
<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);">
<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%">
</div>
</div>
</div>
@ -142,8 +127,8 @@ use App\Utils\Domains;
});
});
function fullNewtab(imgSrc) {
window.open(imgSrc);
function showDetail(el) {
}
// Get the modal
@ -155,4 +140,4 @@ use App\Utils\Domains;
modal.style.display = "none";
}
}
</script>
</script>