Add clean_bpp.php page
This commit is contained in:
@@ -47,13 +47,13 @@
|
||||
<p><a href="../insert_bdd.php">Insert_bdd</a></p>
|
||||
|
||||
<h4>Viewing</h4>
|
||||
<p><a href="../insert_bdd.php">View_bdd</a></p>
|
||||
<p><a href="../view_bdd.php">View_bdd</a></p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-lg-6">
|
||||
<h4>Cleaning</h4>
|
||||
<p><a href="../insert_bdd.php">Clean_bdd</a></p>
|
||||
<p><a href="../clean_bdd.php">Clean_bdd</a></p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
174
clean_bdd.php
Normal file
174
clean_bdd.php
Normal file
@@ -0,0 +1,174 @@
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title><?php gettext('Clean photos in Sqlite base'); ?></title>
|
||||
|
||||
<link rel="stylesheet" href="css/sls.css" />
|
||||
<link rel='stylesheet' href='css/lc_lightbox.min.css' />
|
||||
<link rel='stylesheet' href='css/open_close_fx.css' />
|
||||
<link rel='stylesheet' href='css/minimal.css' />
|
||||
|
||||
<?php include 'functions.php';
|
||||
session_start();
|
||||
if($_SESSION['Active'] == false){ /* Redirects user to login.php if not logged in */
|
||||
header("location:admin/login.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$domain = 'sentier';
|
||||
localize($domain);
|
||||
?>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<?php
|
||||
|
||||
$base = 'db_photo.sqlite3';
|
||||
|
||||
// Taille des vignettes
|
||||
$th_w = 300;
|
||||
$th_h = 300;
|
||||
// Chemins
|
||||
$img_path = "photos/img/";
|
||||
$thumb_path = "photos/thumb/";
|
||||
|
||||
//$dir = (new AdvancedFilesystemIterator('photos/img/'))->match('/heic|HEIC|jpg|jpeg|JPG|JPEG|webp|WEBP$/');
|
||||
|
||||
//echo '<h3>' . count($dir) . gettext(' images found in folder') . ' <i>photos/img/</i> ...</h3>';
|
||||
|
||||
//_pr($dir);
|
||||
|
||||
|
||||
/*
|
||||
foreach($dir as $file){
|
||||
|
||||
//$file->getFilename()
|
||||
//$file->getpathName()
|
||||
|
||||
$file = $file->getpathName();
|
||||
|
||||
$x = in_bdd($file);
|
||||
|
||||
if ($x == false) { //false
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
$originals = array_map('basename', glob('photos/img/*.{jpg,jpeg,JPG,JPEG,heic,HEIC,webp,WEBP}', GLOB_BRACE));
|
||||
$thumbs = array_map('basename', glob('photos/thumb/*.{jpg,jpeg,JPG,JPEG,heic,HEIC,webp,WEBP}', GLOB_BRACE));
|
||||
|
||||
$missing_thumbs = array_diff($originals, $thumbs);
|
||||
$a = count($missing_thumbs);
|
||||
echo '<h3>' . gettext('Missing thumbs: ') . $a . '</h3>';
|
||||
if ($a > 0) {
|
||||
echo '<h4>' . gettext('Create missing thumbs...') . '</h4>';
|
||||
|
||||
foreach($missing_thumbs as $img){
|
||||
$file = $img_path . $img;
|
||||
create_thumb($th_w, $th_h, $file);
|
||||
echo gettext('Thumb for ') . $img . gettext(' was successfully created!') . '<br>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$missing_originals = array_diff($thumbs, $originals);
|
||||
$b = count($missing_originals);
|
||||
echo '<h3>' . gettext('Extra thumbs: ') . $b . '</h3>';
|
||||
if ($b > 0) {
|
||||
echo '<h4>' . gettext('Delete extra thumbs...') . '</h4>';
|
||||
|
||||
foreach($missing_originals as $thumb){
|
||||
$file = $thumb_path . $thumb;
|
||||
if (unlink($file)) {
|
||||
echo $thumb . gettext(' was deleted successfully!') . '<br>';
|
||||
} else {
|
||||
echo gettext('There was a error deleting the file ') . $thumb;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_pr($missing_thumbs);
|
||||
_pr($missing_originals);
|
||||
|
||||
echo '<h3>' . gettext('Compare folder img and daatabase...') . '</h3>';
|
||||
|
||||
try {
|
||||
$conn = new PDO("sqlite:db_photo.sqlite3");
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
$query = "SELECT filename FROM photos";
|
||||
|
||||
$stmt = $conn->prepare($query);
|
||||
$stmt->execute();// (1,3...) 1=1ere valeur 3=valeur
|
||||
|
||||
$result = $stmt->fetchAll(PDO::FETCH_CLASS);
|
||||
$rowcount = count($result);
|
||||
|
||||
//$conn = null;
|
||||
}
|
||||
catch(PDOException $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
//_pr($result);
|
||||
$bdd = array();
|
||||
|
||||
foreach($result as $file) {
|
||||
//$img = $file->filename;
|
||||
$bdd[] = $file->filename;
|
||||
}
|
||||
|
||||
$base = array_map('basename', $bdd);
|
||||
$missing_originals = array_diff($base, $originals);
|
||||
$c = count($missing_originals);
|
||||
echo '<h3>' . gettext('Extra images in database: ') . $c . '</h3>';
|
||||
if ($c > 0) {
|
||||
echo '<h4>' . gettext('Delete extra images in database...') . '</h4>';
|
||||
|
||||
//foreach($missing_originals as $img){
|
||||
foreach($missing_originals as $key => $img){
|
||||
echo $key;
|
||||
$query2 = "DELETE FROM photos WHERE id=:id";
|
||||
|
||||
$stmt=$conn->prepare($query2);
|
||||
$stmt->bindParam(':id',$key,PDO::PARAM_INT, 5);
|
||||
|
||||
if($stmt->execute()){
|
||||
echo "Successfully deleted record ";
|
||||
} else {
|
||||
print_r($sql->errorInfo());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//_pr($bdd);
|
||||
|
||||
//_pr($base);
|
||||
|
||||
_pr($missing_originals);
|
||||
|
||||
/*
|
||||
foreach($fileList as $filename){
|
||||
echo $filename;
|
||||
}
|
||||
*/
|
||||
//_pr($fileList);
|
||||
?>
|
||||
|
||||
|
||||
<p><em><small>© 2013-<?php echo date('Y'); ?> sur-le-sentier.fr</small></em></p>
|
||||
|
||||
<script src='js/lc_lightbox.min.js' type='text/javascript'></script>
|
||||
<script src='js/alloy_finger.min.js' type='text/javascript'></script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -186,6 +186,11 @@ body {
|
||||
color: #ffffff;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.sort a:link, .sort a:visited, .sort a:hover {
|
||||
color: #ffffff !important;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.styled-table th, .styled-table td {
|
||||
padding: 12px 15px;
|
||||
|
||||
@@ -495,9 +495,9 @@ try {
|
||||
});
|
||||
</script>
|
||||
|
||||
<p class="navPage"><a href="index.php" title="<?php echo gettext("Home"); ?>"><?php echo gettext("Home"); ?></a> | <a href="maps.php" title="<?php echo gettext("Maps"); ?>"><?php echo gettext("Maps"); ?></a> | <a href="photo-du-mois.php" title="<?php echo gettext("Picture of the month"); ?>"><?php echo gettext("Picture of the month"); ?></a></p>
|
||||
<p class="navPage"><a href="index.php" title="<?php echo gettext("Home"); ?>"><?php echo gettext("Home"); ?></a> | <a href="maps.php" title="<?php echo gettext("Maps"); ?>"><?php echo gettext("Maps"); ?></a> | <a href="photo-du-mois.php" title="<?php echo gettext("Picture of the month"); ?>"><?php echo gettext("Picture of the month"); ?></a> | <a href="admin/index.php" title="<?php echo gettext("Admin"); ?>"><?php echo gettext("Admin"); ?></a></p>
|
||||
|
||||
<p><em><small>sur-le-sentier.fr@ 2022</small></em></p>
|
||||
<p><em><small>© 2013-<?php echo date('Y'); ?> sur-le-sentier.fr</small></em></p>
|
||||
|
||||
<script src='js/lc_lightbox.min.js' type='text/javascript'></script>
|
||||
<script src='js/alloy_finger.min.js' type='text/javascript'></script>
|
||||
|
||||
2
maps.php
2
maps.php
@@ -182,7 +182,7 @@
|
||||
|
||||
<p class="navPage"><a href="index.php"><?php echo gettext("Home"); ?></a> | <a href="photo-du-mois.php"><?php echo gettext("Picture of the month"); ?></a></p>
|
||||
|
||||
<p><em><small>@sur-le-sentier.fr 2022</small></em></p>
|
||||
<p><em><small>© 2013-<?php echo date('Y'); ?> sur-le-sentier.fr</small></em></p>
|
||||
|
||||
<script src='js/lc_lightbox.min.js'></script>
|
||||
<script src='js/alloy_finger.min.js'></script>
|
||||
|
||||
@@ -271,7 +271,7 @@ echo '</div>';
|
||||
|
||||
<p class="navPage"><a href="index.php" title="<?php echo gettext("Home"); ?>"><?php echo gettext("Home"); ?></a> | <a href="maps.php" title="<?php echo gettext("Maps"); ?>"><?php echo gettext("Maps"); ?></a></p>
|
||||
|
||||
<p><em><small>sur-le-sentier.fr@ 2022</small></em></p>
|
||||
<p><em><small>© 2013-<?php echo date('Y'); ?> sur-le-sentier.fr</small></em></p>
|
||||
|
||||
<script src='js/lc_lightbox.min.js' type='text/javascript'></script>
|
||||
<script src='js/alloy_finger.min.js' type='text/javascript'></script>
|
||||
|
||||
174
view_bdd.php
Normal file
174
view_bdd.php
Normal file
@@ -0,0 +1,174 @@
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title><?php gettext('View photos in Sqlite base'); ?></title>
|
||||
|
||||
<link rel="stylesheet" href="css/sls.css" />
|
||||
<link rel='stylesheet' href='css/lc_lightbox.min.css' />
|
||||
<link rel='stylesheet' href='css/open_close_fx.css' />
|
||||
<link rel='stylesheet' href='css/minimal.css' />
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" integrity="sha512-KfkfwYDsLkIlwQp6LFnl8zNdLGxu9YAA1QvwINks4PhcElQSvqcyVLLD9aMhXd13uQjoXtEKNosOWaZqXgel0g==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||
|
||||
<?php include 'functions.php';
|
||||
session_start();
|
||||
if($_SESSION['Active'] == false){ /* Redirects user to login.php if not logged in */
|
||||
header("location:admin/login.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$domain = 'sentier';
|
||||
localize($domain);
|
||||
?>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<?php
|
||||
|
||||
$base = 'db_photo.sqlite3';
|
||||
|
||||
|
||||
if (!isset($_GET['page'])) $page = 1;
|
||||
else $page = intval($_GET['page']);
|
||||
|
||||
|
||||
|
||||
$dir = (new AdvancedFilesystemIterator('photos/img/'))->match('/heic|HEIC|jpg|jpeg|JPG|JPEG|webp|WEBP$/');
|
||||
|
||||
echo '<h3>' . count($dir) . gettext(' images found in folder') . ' <i>photos/img/</i> ...</h3>';
|
||||
|
||||
$conn = new PDO("sqlite:db_photo.sqlite3");
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
try {
|
||||
$columns = array('date','lens','model','iso','lat');
|
||||
$column = isset($_GET['column']) && in_array($_GET['column'], $columns) ? $_GET['column'] : $columns[0];
|
||||
//$_SESSION['column'] = $column;
|
||||
$sort_order = isset($_GET['order']) && strtolower($_GET['order']) == 'desc' ? 'DESC' : 'ASC';
|
||||
//$_SESSION['sort_order'] = $sort_order;
|
||||
|
||||
$query4 = "SELECT id,filename, date, lens, speed, iso, width, height, html, aperture, model, lat, long, alt, legende, copyright, title, creator, keywords, metering, flash, focal, wb, program FROM photos ORDER BY " . $column . " " . $sort_order . " LIMIT ? OFFSET ?";
|
||||
|
||||
//$query4 = "SELECT id,filename, date, lens, speed, iso, width, height, html, aperture, model, lat, long, alt, legende, copyright, title, creator, keywords, metering, flash, focal, wb, program FROM photos ORDER BY date DESC LIMIT ? OFFSET ?";
|
||||
$perpage = 50;
|
||||
$offset = $perpage * ($page -1);
|
||||
|
||||
echo $query4 . "<br>";
|
||||
echo $perpage . " - " . $offset . "<br>";
|
||||
|
||||
$stmt = $conn->prepare($query4);
|
||||
$stmt->execute(array($perpage, $offset));// (1,3...) 1=1ere valeur 3=valeur
|
||||
# id 1 -> 3
|
||||
//$stmt->execute(array(1, 3)); // WHERE id >= ? AND id <= ? ORDER BY date DESC";
|
||||
$stmt->execute();
|
||||
|
||||
//$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
//_pr($result);
|
||||
//echo '<h3>' . gettext('Reading added photos') . ':</h3>';
|
||||
$up_or_down = str_replace(array('ASC','DESC'), array('up','down'), $sort_order);
|
||||
$asc_or_desc = $sort_order == 'ASC' ? 'desc' : 'asc';
|
||||
$add_class = ' class="highlight"';
|
||||
|
||||
/*
|
||||
<th>' . gettext('Date') . '</th>
|
||||
<th>' . gettext('Lens') . '</th>
|
||||
<th>' . gettext('Iso') . '</th>
|
||||
<th>' . gettext('Model') . '</th>
|
||||
<th>' . gettext('Latitude') . '</th>
|
||||
*/
|
||||
echo '<div id="view_bdd">';
|
||||
echo '<table class="styled-table">';
|
||||
echo '<thead>';
|
||||
echo '<th>' . gettext('Id') . '</th><th>' . gettext('Thumb') . '</th><th>' . gettext('Filename') . '</th><th><a class="sort" href="view_bdd.php?column=date&order=' . $asc_or_desc . '">' . gettext('Date') . ' <i class="fas fa-sort' . ($column == 'date' ? '-' . $up_or_down : '') . '"></i></a></th><th><a href="view_bdd.php?column=lens&order=' . $asc_or_desc . '">' . gettext('Lens') . ' <i class="fas fa-sort' . ($column == 'lens' ? '-' . $up_or_down : '') . '"></i></a></th><th>' . gettext('Speed') . '</th><th><a href="view_bdd.php?column=iso&order=' . $asc_or_desc . '">' . gettext('Iso') . ' <i class="fas fa-sort' . ($column == 'iso' ? '-' . $up_or_down : '') . '"></i></a></th><th>' . gettext('Width') . '</th><th>' . gettext('Height') . '</th><th>' . gettext('Html') . '</th>';
|
||||
echo '<th>' . gettext('Aperture') . '</th><th><a href="view_bdd.php?column=model&order=' . $asc_or_desc . '">' . gettext('Model') . ' <i class="fas fa-sort' . ($column == 'Model' ? '-' . $up_or_down : '') . '"></i></a></th><th><a href="view_bdd.php?column=lat&order=' . $asc_or_desc . '">' . gettext('Latitude') . ' <i class="fas fa-sort' . ($column == 'lat' ? '-' . $up_or_down : '') . '"></i></a></th><th>' . gettext('Longitude') . '</th><th>' . gettext('Alttitude') . '</th><th>' . gettext('Legende') . '</th><th>' . gettext('Copyright') . '</th><th>' . gettext('Title') . '</th>';
|
||||
echo '<th>' . gettext('Creator') . '</th><th>' . gettext('Keywords') . '</th><th>' . gettext('Metering') . '</th><th>' . gettext('Flash') . '</th><th>' . gettext('Focal') . '</th><th>' . gettext('Wb') . '</th><th>' . gettext('Program') . '</th>';
|
||||
echo '</thead>';
|
||||
echo '<tbody>';
|
||||
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
$thumbnail = host() . str_replace("photos/img", "photos/thumb", $row['filename']);
|
||||
$full = host() . $row['filename'];
|
||||
|
||||
echo '<tr><td>' . $row['id'] . '</td><td>' . '<a href="' . $full . '"><img src="'.$thumbnail.'" /></a>' . '</td><td>' . $row['filename'] . '</td><td>' . $row['date'] . '</td><td>' . $row['lens'] . '</td><td>' . $row['speed'] . '</td><td>' . $row['iso'] . '</td><td>' . $row['width'] . '</td><td>' . $row['height'] . '</td><td>' . $row['html'] . '</td><td>' . $row['aperture'] . '</td><td>' . $row['model'] . '</td><td>' . $row['lat'] . '</td><td>' . $row['long'] . '</td><td>' . $row['alt'] . '</td><td>' . $row['legende'] . '</td><td>' . $row['copyright'] . '</td><td>' . $row['title'] . '</td><td>' . $row['creator'] . '</td><td>' . $row['keywords'] . '</td><td>' . $row['metering'] . '</td><td>' . $row['flash'] . '</td><td>' . $row['focal'] . '</td><td>' . $row['wb'] . '</td><td>' . $row['program'] . '</td></tr>';
|
||||
}
|
||||
echo '</tbody></table>';
|
||||
echo '</div>';
|
||||
|
||||
$conn = null;
|
||||
}
|
||||
catch(PDOException $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
?>
|
||||
|
||||
<script type='text/javascript'>
|
||||
/*
|
||||
$(document).ready(function() {
|
||||
|
||||
var $obj = lc_lightbox('#view_bdd a', {
|
||||
open_close_time : 200,
|
||||
ol_time_diff : 100,
|
||||
wrap_class : 'lcl_zoomin_oc',
|
||||
skin : 'minimal',
|
||||
txt_hidden : true,
|
||||
fullscreen : false,
|
||||
fs_img_behavior : 'smart',
|
||||
browser_fs_mode : true,
|
||||
rclick_prevent : true,
|
||||
});
|
||||
|
||||
});
|
||||
*/
|
||||
</script>
|
||||
|
||||
<?php
|
||||
try {
|
||||
$conn4 = new PDO('sqlite:db_photo.sqlite3');
|
||||
$query4 = "SELECT COUNT(*) AS count FROM photos";
|
||||
|
||||
$stmt = $conn4->prepare($query4);
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$numRows = $result['count'];
|
||||
|
||||
$conn4 = null;
|
||||
}
|
||||
catch(PDOException $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
// calcul du nombre de pages (arrondi a l'entier supérieur)
|
||||
$nbpages = ceil($numRows / $perpage);
|
||||
$prec = $page - 1;
|
||||
$suiv = $page + 1;
|
||||
|
||||
echo '<div class="navPage">' . gettext("Page") . ': ';
|
||||
if ($page >= 2) echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$prec.'&column='.$column.'&order='.$sort_order.'" title="'.gettext("Previous Page").'">« '.gettext("prev").'</a> ';
|
||||
for ($i = 1; $i <= $nbpages; $i++) {
|
||||
if ($i != $page) {
|
||||
echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$i.'&column='.$column.'&order='.$sort_order.'" title="'.gettext("Page").' '.$i.'">'.$i.' </a> ';
|
||||
}
|
||||
else {
|
||||
echo "<span class='gras'>".$i."</span> ";
|
||||
}
|
||||
}
|
||||
if ($page < $nbpages) echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$suiv.'&column='.$column.'&order='.$sort_order.'" title="'.gettext("Next Page").'">'.gettext("next").' »</a> ';
|
||||
echo '</div>';
|
||||
?>
|
||||
|
||||
<p class="navPage"><a href="index.php" title="<?php echo gettext("Home"); ?>"><?php echo gettext("Home"); ?></a> | <a href="maps.php" title="<?php echo gettext("Maps"); ?>"><?php echo gettext("Maps"); ?></a> | <a href="photo-du-mois.php" title="<?php echo gettext("Picture of the month"); ?>"><?php echo gettext("Picture of the month"); ?></a> | <a href="admin/index.php" title="<?php echo gettext("Admin"); ?>"><?php echo gettext("Admin"); ?></a></p>
|
||||
|
||||
<p><em><small>© 2013-<?php echo date('Y'); ?> sur-le-sentier.fr</small></em></p>
|
||||
|
||||
<script src='js/lc_lightbox.min.js' type='text/javascript'></script>
|
||||
<script src='js/alloy_finger.min.js' type='text/javascript'></script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
174
view_bdd_get.php
Normal file
174
view_bdd_get.php
Normal file
@@ -0,0 +1,174 @@
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title><?php gettext('View photos in Sqlite base'); ?></title>
|
||||
|
||||
<link rel="stylesheet" href="css/sls.css" />
|
||||
<link rel='stylesheet' href='css/lc_lightbox.min.css' />
|
||||
<link rel='stylesheet' href='css/open_close_fx.css' />
|
||||
<link rel='stylesheet' href='css/minimal.css' />
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" integrity="sha512-KfkfwYDsLkIlwQp6LFnl8zNdLGxu9YAA1QvwINks4PhcElQSvqcyVLLD9aMhXd13uQjoXtEKNosOWaZqXgel0g==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||
|
||||
<?php include 'functions.php';
|
||||
session_start();
|
||||
if($_SESSION['Active'] == false){ /* Redirects user to login.php if not logged in */
|
||||
header("location:admin/login.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$domain = 'sentier';
|
||||
localize($domain);
|
||||
?>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<?php
|
||||
|
||||
$base = 'db_photo.sqlite3';
|
||||
|
||||
|
||||
if (!isset($_GET['page'])) $page = 1;
|
||||
else $page = intval($_GET['page']);
|
||||
|
||||
|
||||
|
||||
$dir = (new AdvancedFilesystemIterator('photos/img/'))->match('/heic|HEIC|jpg|jpeg|JPG|JPEG|webp|WEBP$/');
|
||||
|
||||
echo '<h3>' . count($dir) . gettext(' images found in folder') . ' <i>photos/img/</i> ...</h3>';
|
||||
|
||||
$conn = new PDO("sqlite:db_photo.sqlite3");
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
try {
|
||||
$columns = array('date','lens','model','iso','lat');
|
||||
$column = isset($_GET['column']) && in_array($_GET['column'], $columns) ? $_GET['column'] : $columns[0];
|
||||
//$_SESSION['column'] = $column;
|
||||
$sort_order = isset($_GET['order']) && strtolower($_GET['order']) == 'desc' ? 'DESC' : 'ASC';
|
||||
//$_SESSION['sort_order'] = $sort_order;
|
||||
|
||||
$query4 = "SELECT id,filename, date, lens, speed, iso, width, height, html, aperture, model, lat, long, alt, legende, copyright, title, creator, keywords, metering, flash, focal, wb, program FROM photos ORDER BY " . $column . " " . $sort_order . " LIMIT ? OFFSET ?";
|
||||
|
||||
//$query4 = "SELECT id,filename, date, lens, speed, iso, width, height, html, aperture, model, lat, long, alt, legende, copyright, title, creator, keywords, metering, flash, focal, wb, program FROM photos ORDER BY date DESC LIMIT ? OFFSET ?";
|
||||
$perpage = 50;
|
||||
$offset = $perpage * ($page -1);
|
||||
|
||||
echo $query4 . "<br>";
|
||||
echo $perpage . " - " . $offset . "<br>";
|
||||
|
||||
$stmt = $conn->prepare($query4);
|
||||
$stmt->execute(array($perpage, $offset));// (1,3...) 1=1ere valeur 3=valeur
|
||||
# id 1 -> 3
|
||||
//$stmt->execute(array(1, 3)); // WHERE id >= ? AND id <= ? ORDER BY date DESC";
|
||||
$stmt->execute();
|
||||
|
||||
//$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
//_pr($result);
|
||||
//echo '<h3>' . gettext('Reading added photos') . ':</h3>';
|
||||
$up_or_down = str_replace(array('ASC','DESC'), array('up','down'), $sort_order);
|
||||
$asc_or_desc = $sort_order == 'ASC' ? 'desc' : 'asc';
|
||||
$add_class = ' class="highlight"';
|
||||
|
||||
/*
|
||||
<th>' . gettext('Date') . '</th>
|
||||
<th>' . gettext('Lens') . '</th>
|
||||
<th>' . gettext('Iso') . '</th>
|
||||
<th>' . gettext('Model') . '</th>
|
||||
<th>' . gettext('Latitude') . '</th>
|
||||
*/
|
||||
echo '<div id="view_bdd">';
|
||||
echo '<table class="styled-table">';
|
||||
echo '<thead>';
|
||||
echo '<th>' . gettext('Id') . '</th><th>' . gettext('Thumb') . '</th><th>' . gettext('Filename') . '</th><th><a class="sort" href="view_bdd.php?column=date&order=' . $asc_or_desc . '">' . gettext('Date') . ' <i class="fas fa-sort' . ($column == 'date' ? '-' . $up_or_down : '') . '"></i></a></th><th><a href="view_bdd.php?column=lens&order=' . $asc_or_desc . '">' . gettext('Lens') . ' <i class="fas fa-sort' . ($column == 'lens' ? '-' . $up_or_down : '') . '"></i></a></th><th>' . gettext('Speed') . '</th><th><a href="view_bdd.php?column=iso&order=' . $asc_or_desc . '">' . gettext('Iso') . ' <i class="fas fa-sort' . ($column == 'iso' ? '-' . $up_or_down : '') . '"></i></a></th><th>' . gettext('Width') . '</th><th>' . gettext('Height') . '</th><th>' . gettext('Html') . '</th>';
|
||||
echo '<th>' . gettext('Aperture') . '</th><th><a href="view_bdd.php?column=model&order=' . $asc_or_desc . '">' . gettext('Model') . ' <i class="fas fa-sort' . ($column == 'Model' ? '-' . $up_or_down : '') . '"></i></a></th><th><a href="view_bdd.php?column=lat&order=' . $asc_or_desc . '">' . gettext('Latitude') . ' <i class="fas fa-sort' . ($column == 'lat' ? '-' . $up_or_down : '') . '"></i></a></th><th>' . gettext('Longitude') . '</th><th>' . gettext('Alttitude') . '</th><th>' . gettext('Legende') . '</th><th>' . gettext('Copyright') . '</th><th>' . gettext('Title') . '</th>';
|
||||
echo '<th>' . gettext('Creator') . '</th><th>' . gettext('Keywords') . '</th><th>' . gettext('Metering') . '</th><th>' . gettext('Flash') . '</th><th>' . gettext('Focal') . '</th><th>' . gettext('Wb') . '</th><th>' . gettext('Program') . '</th>';
|
||||
echo '</thead>';
|
||||
echo '<tbody>';
|
||||
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
$thumbnail = host() . str_replace("photos/img", "photos/thumb", $row['filename']);
|
||||
$full = host() . $row['filename'];
|
||||
|
||||
echo '<tr><td>' . $row['id'] . '</td><td>' . '<a href="' . $full . '"><img src="'.$thumbnail.'" /></a>' . '</td><td>' . $row['filename'] . '</td><td>' . $row['date'] . '</td><td>' . $row['lens'] . '</td><td>' . $row['speed'] . '</td><td>' . $row['iso'] . '</td><td>' . $row['width'] . '</td><td>' . $row['height'] . '</td><td>' . $row['html'] . '</td><td>' . $row['aperture'] . '</td><td>' . $row['model'] . '</td><td>' . $row['lat'] . '</td><td>' . $row['long'] . '</td><td>' . $row['alt'] . '</td><td>' . $row['legende'] . '</td><td>' . $row['copyright'] . '</td><td>' . $row['title'] . '</td><td>' . $row['creator'] . '</td><td>' . $row['keywords'] . '</td><td>' . $row['metering'] . '</td><td>' . $row['flash'] . '</td><td>' . $row['focal'] . '</td><td>' . $row['wb'] . '</td><td>' . $row['program'] . '</td></tr>';
|
||||
}
|
||||
echo '</tbody></table>';
|
||||
echo '</div>';
|
||||
|
||||
$conn = null;
|
||||
}
|
||||
catch(PDOException $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
?>
|
||||
|
||||
<script type='text/javascript'>
|
||||
/*
|
||||
$(document).ready(function() {
|
||||
|
||||
var $obj = lc_lightbox('#view_bdd a', {
|
||||
open_close_time : 200,
|
||||
ol_time_diff : 100,
|
||||
wrap_class : 'lcl_zoomin_oc',
|
||||
skin : 'minimal',
|
||||
txt_hidden : true,
|
||||
fullscreen : false,
|
||||
fs_img_behavior : 'smart',
|
||||
browser_fs_mode : true,
|
||||
rclick_prevent : true,
|
||||
});
|
||||
|
||||
});
|
||||
*/
|
||||
</script>
|
||||
|
||||
<?php
|
||||
try {
|
||||
$conn4 = new PDO('sqlite:db_photo.sqlite3');
|
||||
$query4 = "SELECT COUNT(*) AS count FROM photos";
|
||||
|
||||
$stmt = $conn4->prepare($query4);
|
||||
$stmt->execute();
|
||||
|
||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$numRows = $result['count'];
|
||||
|
||||
$conn4 = null;
|
||||
}
|
||||
catch(PDOException $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
// calcul du nombre de pages (arrondi a l'entier supérieur)
|
||||
$nbpages = ceil($numRows / $perpage);
|
||||
$prec = $page - 1;
|
||||
$suiv = $page + 1;
|
||||
|
||||
echo '<div class="navPage">' . gettext("Page") . ': ';
|
||||
if ($page >= 2) echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$prec.'&column='.$column.'&order='.$sort_order.'" title="'.gettext("Previous Page").'">« '.gettext("prev").'</a> ';
|
||||
for ($i = 1; $i <= $nbpages; $i++) {
|
||||
if ($i != $page) {
|
||||
echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$i.'&column='.$column.'&order='.$sort_order.'" title="'.gettext("Page").' '.$i.'">'.$i.' </a> ';
|
||||
}
|
||||
else {
|
||||
echo "<span class='gras'>".$i."</span> ";
|
||||
}
|
||||
}
|
||||
if ($page < $nbpages) echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$suiv.'&column='.$column.'&order='.$sort_order.'" title="'.gettext("Next Page").'">'.gettext("next").' »</a> ';
|
||||
echo '</div>';
|
||||
?>
|
||||
|
||||
<p class="navPage"><a href="index.php" title="<?php echo gettext("Home"); ?>"><?php echo gettext("Home"); ?></a> | <a href="maps.php" title="<?php echo gettext("Maps"); ?>"><?php echo gettext("Maps"); ?></a> | <a href="photo-du-mois.php" title="<?php echo gettext("Picture of the month"); ?>"><?php echo gettext("Picture of the month"); ?></a> | <a href="admin/index.php" title="<?php echo gettext("Admin"); ?>"><?php echo gettext("Admin"); ?></a></p>
|
||||
|
||||
<p><em><small>© 2013-<?php echo date('Y'); ?> sur-le-sentier.fr</small></em></p>
|
||||
|
||||
<script src='js/lc_lightbox.min.js' type='text/javascript'></script>
|
||||
<script src='js/alloy_finger.min.js' type='text/javascript'></script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user