-déplacement des fichiers d’admin dans un dossier admin -corrections dans la fonction data_for_lightbox($data). Celle-ci est maintenant toujours utilisé pour l’affichage des vignettes et des images dans la lightbox -les chemins sont nettoyés avec 2 variables: $chemin pour les images, $base pour la base Sqlite -corrections diverses
256 lines
10 KiB
PHP
256 lines
10 KiB
PHP
<?php
|
|
require ("3-protect.php");
|
|
//session_start();
|
|
include '../i18n_setup.php';
|
|
/*include 'localize.php';
|
|
$domain = 'sentier';
|
|
localize($domain);
|
|
*/
|
|
include '../functions.php';
|
|
|
|
$base = '../db_photo.sqlite3';
|
|
$conn = new PDO("sqlite:$base");
|
|
$msg = "";
|
|
|
|
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
|
|
//echo "<a href='close.php'> close session </a><br />";
|
|
|
|
/*
|
|
if (!empty($_POST)) {
|
|
_pr($_POST);
|
|
}
|
|
|
|
Array
|
|
(
|
|
[lens] => EF17-40mm f/4L USM
|
|
[keywords] => _vert_,neige,vigne
|
|
[titre] => Vignes
|
|
[creator] => Pesenti Bruno
|
|
[city] => Fixin
|
|
[department] => Côte d'Or
|
|
[code] => FR
|
|
[country] => France
|
|
[copyright] => © bruno@clicclac.info
|
|
[legende] => Vignes dans la neige
|
|
[id] => 77
|
|
[update] => update
|
|
)
|
|
*/
|
|
if (isset($_POST['update']) && $_POST['update'] === 'update') {
|
|
|
|
$w = filter_var_array($_POST['id'], FILTER_VALIDATE_INT);
|
|
$z = "";
|
|
$count = 0;
|
|
$requests = array();
|
|
|
|
foreach ($w as $key => $value) {
|
|
|
|
if (isset($_POST['id'][$key]) && (! empty($_POST['id'][$key]))) {
|
|
|
|
$id = filter_var($_POST['id'][$key], FILTER_VALIDATE_INT);
|
|
|
|
$lens = filter_var($_POST['lens'][$key], FILTER_SANITIZE_SPECIAL_CHARS);
|
|
$keywords = filter_var($_POST['keywords'][$key], FILTER_SANITIZE_SPECIAL_CHARS);
|
|
$title = filter_var($_POST['title'][$key], FILTER_SANITIZE_SPECIAL_CHARS);
|
|
$creator = filter_var($_POST['creator'][$key], FILTER_SANITIZE_SPECIAL_CHARS);
|
|
$city = filter_var($_POST['city'][$key], FILTER_SANITIZE_SPECIAL_CHARS);
|
|
$department = filter_var($_POST['department'][$key], FILTER_SANITIZE_SPECIAL_CHARS);
|
|
$code = filter_var($_POST['code'][$key], FILTER_SANITIZE_SPECIAL_CHARS);
|
|
$country = filter_var($_POST['country'][$key], FILTER_SANITIZE_SPECIAL_CHARS);
|
|
$copyright = filter_var($_POST['copyright'][$key], FILTER_SANITIZE_SPECIAL_CHARS);
|
|
$legende = filter_var($_POST['legende'][$key], FILTER_SANITIZE_SPECIAL_CHARS);
|
|
|
|
$z .= "id = '" . $id . "' OR ";
|
|
|
|
//echo $id . "----" . $lens. "----" . $keywords. "----" . $title. "----" . $creator. "----" . $city . "<br />";
|
|
//echo $department . "----" . $code. "----" . $country. "----" . $copyright. "----" . $legende . "<br /><br />";
|
|
/*
|
|
echo "id:$id--". "<br />";
|
|
echo "lens:$lens--". "<br />";
|
|
echo "keywords:$keywords--". "<br />";
|
|
echo "title:$title--". "<br />";
|
|
echo "creator:$creator--". "<br />";
|
|
echo "city :$city --". "<br />";
|
|
echo "department:$department--". "<br />";
|
|
echo "code:$code--". "<br />";
|
|
echo "country:$country--". "<br />";
|
|
echo "copyright:$copyright--". "<br />";
|
|
echo "legende:$legende--". "<br />". "<br />";
|
|
*/
|
|
/*
|
|
$id = $_POST['id'];
|
|
$lens = (isset($_POST['lens']) && (! empty($_POST['lens']))) ? $_POST['lens'] : '';
|
|
$keywords = (isset($_POST['keywords']) && (! empty($_POST['keywords']))) ? $_POST['keywords'] : '';
|
|
$title = (isset($_POST['title']) && (! empty($_POST['title']))) ? $_POST['title'] : '';
|
|
$creator = (isset($_POST['creator']) && (! empty($_POST['creator']))) ? $_POST['creator'] : '';
|
|
$city = (isset($_POST['city']) && (! empty($_POST['city']))) ? $_POST['city'] : '';
|
|
$department = (isset($_POST['department']) && (! empty($_POST['department']))) ? $_POST['department'] : '';
|
|
$code = (isset($_POST['code']) && (! empty($_POST['code']))) ? $_POST['code'] : '';
|
|
$country = (isset($_POST['country']) && (! empty($_POST['country']))) ? $_POST['country'] : '';
|
|
$copyright = (isset($_POST['copyright']) && (! empty($_POST['copyright']))) ? $_POST['copyright'] : '';
|
|
$legende = (isset($_POST['legende']) && (! empty($_POST['legende']))) ? $_POST['legende'] : '';
|
|
*/
|
|
|
|
$req = "UPDATE photos SET lens = :lens , keywords = :keywords , title = :title , creator = :creator ";
|
|
$req .= ", city = :city , department = :department , code = :code , country = :country ";
|
|
$req .= ", copyright = :copyright , legende = :legende WHERE id= :id";
|
|
|
|
// affichage requetes
|
|
$keys = array_keys($_POST);
|
|
$count_id = count($_POST["id"]);
|
|
|
|
for ($i = 0; $i < $count_id; $i++) {
|
|
|
|
foreach ($keys as $key => $value) {
|
|
if ($value != "update") {
|
|
$search = ":" . $value;
|
|
$replace = "'" . $_POST[$value][$i] . "'";
|
|
$replacements[$search] = $replace;
|
|
}
|
|
}
|
|
$requests[$i] = strtr($req, $replacements);
|
|
//$requests[$i] = wordwrap(strtr($req, $replacements), 120, "\n", true);
|
|
}
|
|
|
|
try {
|
|
$stmt = $conn->prepare($req);
|
|
|
|
$stmt->bindValue(':id', $id);
|
|
$stmt->bindValue(':lens', $lens);
|
|
$stmt->bindValue(':keywords', $keywords);
|
|
$stmt->bindValue(':title', $title);
|
|
$stmt->bindValue(':creator', $creator);
|
|
$stmt->bindValue(':city', $city);
|
|
$stmt->bindValue(':department', $department);
|
|
$stmt->bindValue(':code', $code);
|
|
$stmt->bindValue(':country', $country);
|
|
$stmt->bindValue(':copyright', $copyright);
|
|
$stmt->bindValue(':legende', $legende);
|
|
|
|
$stmt->execute();
|
|
|
|
$count = $count + $stmt->rowCount();
|
|
|
|
}
|
|
catch(PDOException $e) {
|
|
echo $e->getMessage();
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
$msg = "Updated $count rows with following request:";
|
|
$conn = null;
|
|
|
|
}
|
|
else {
|
|
$url = "view_bdd.php?message=" . urlencode(gettext("No image select !"));
|
|
header("location: $url");
|
|
}
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<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='../lc-lightbox/css/lc_lightbox.min.css' />
|
|
<link rel='stylesheet' href='../lc-lightbox/css/open_close_fx.css' />
|
|
<link rel='stylesheet' href='../lc-lightbox/skins/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" />
|
|
|
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<h1><?php echo gettext('Modify database'); ?></h1>
|
|
|
|
<?php
|
|
echo '<h3 class="greenstyle">' . $msg . '</h3>';
|
|
|
|
echo '<pre class="font10"><code>';
|
|
foreach ($requests as $request) {
|
|
echo $request . "<br />";
|
|
}
|
|
echo '</code></pre>';
|
|
|
|
|
|
$req = substr($z, 0, -4);
|
|
$req_edit = "SELECT * FROM photos WHERE " . $req . " ORDER BY id";
|
|
|
|
try {
|
|
$conn = new PDO("sqlite:../$base");
|
|
$stmt = $conn->prepare($req_edit);
|
|
$stmt->execute();
|
|
|
|
echo '<table class="styled-table">';
|
|
echo '<thead>';
|
|
echo '<th>' . gettext('Id') . '</th><th>' . gettext('Thumb') . '</th><th>' . gettext('Filename') . '</th><th>' . gettext('Date') . ' </th><th>' . gettext('Speed') . '</th><th>' . gettext('Iso') . '</th><th>' . gettext('Aperture') . '</th><th>' . gettext('Expo. correct') . '</th>';
|
|
echo '<th>' . gettext('Model') . '</th><th>' . gettext('Lens') . '</th><th>' . gettext('Focal') . '</th><th>' . gettext('Metering') . '</th><th>' . gettext('Program') . '</th><th>' . gettext('Wb') . '</th>';
|
|
|
|
echo '<th>' . gettext('Flash') . '</th><th>' . gettext('Software') . '</th><th>' . gettext('Keywords') . '</th><th>' . gettext('Title') . '</th><th>' . gettext('Creator') . '</th><th>' . gettext('City') . '</th><th>' . gettext('Department') . '</th><th>' . gettext('Code') . '</th><th>' . gettext('Country') . '</th><th>' . gettext('Copyright') . '</th><th>' . gettext('Legende') . '</th>';
|
|
echo '</thead>';
|
|
echo '<tbody>';
|
|
|
|
$nRows = 0;
|
|
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
//$thumbnail = host() . str_replace("photos/img", "photos/thumb", $row['filename']);
|
|
//$full = host() . $row['filename'];
|
|
$lb = data_for_lightbox($row);
|
|
|
|
//echo '<tr><td>' . $row['id'] . '</td><td>' . '<a href="' . $full . '"><img src="'.$thumbnail.'" /></a>' . '</td>';
|
|
echo '<tr><td>' . $row['id'] . '</td><td>' . '<a href="' . $lb['big'] . '"><img src="' . $lb['big'] . '" /></a>' . '</td>';
|
|
echo '<td>' . $row['filename'] . '</td><td>' . $row['dateoriginal'] . '</td>';
|
|
echo '<td>' . $row['speed'] . '</td><td>' . $row['iso'] . '</td><td>' . $row['aperture'] . '</td><td>' . $row['correctexpo'] . '</td>';
|
|
echo '<td>' . $row['model'] . '</td>';
|
|
echo '<td><input type="text" id="lens" name="lens" value="' . $row['lens'] . '" size=""></td>';
|
|
echo '<td>' . $row['focal'] . '</td><td>' . $row['metering'] . '</td><td>' . $row['program'] . '</td><td>' . $row['wb'] . '</td>';
|
|
echo '<td>' . $row['flash'] . '</td><td>' . $row['software'] . '</td>';
|
|
echo '<td><input type="text" id="keywords" name="keywords" value="' . $row['keywords'] . '" size=""></td>';
|
|
echo '<td><input type="text" id="title" name="title" value="' . $row['title'] . '" size=""></td>';
|
|
echo '<td><input type="text" id="creator" name="creator" value="' . $row['creator'] . '" size=""></td>';
|
|
|
|
echo '<td><input type="text" id="city" name="city" value="' . $row['city'] . '" size=""></td>';
|
|
echo '<td><input type="text" id="department" name="department" value="' . $row['department'] . '" size=""></td>';
|
|
echo '<td><input type="text" id="code" name="code" value="' . $row['code'] . '" size=""></td>';
|
|
echo '<td><input type="text" id="country" name="country" value="' . $row['country'] . '" size=""></td>';
|
|
|
|
echo '<td><input type="text" id="copyright" name="copyright" value="' . $row['copyright'] . '" size=""></td>';
|
|
echo '<td><input type="text" id="legende" name="legende" value="' . $row['legende'] . '" size=""></td></tr>';
|
|
|
|
echo '<input type="hidden" id="id" name="id" value="' . $row['id'] . '">';
|
|
|
|
$nRows++;
|
|
}
|
|
|
|
echo '</tbody></table>';
|
|
|
|
$conn = null;
|
|
|
|
}
|
|
catch(PDOException $e) {
|
|
echo $e->getMessage();
|
|
}
|
|
?>
|
|
|
|
<?php $logout = (isset($_SESSION["user"])) ? '<a class="" href="4-logout.php" role="button">' . gettext("Log out") . '</a>' : ''; ?>
|
|
|
|
<p class="navPage"><a href="../index.php" title="<?php echo gettext("Home"); ?>"><?php echo gettext("Home"); ?></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="../maps.php" title="<?php echo gettext("Maps"); ?>"><?php echo gettext("Maps"); ?></a> | <a href="admin.php" title="<?php echo gettext("Admin page"); ?>"><?php echo gettext("Admin page"); ?></a> | <?php echo $logout; ?></p>
|
|
|
|
<p><em><small>© 2013-<?php echo date('Y'); ?> sur-le-sentier.fr</small></em></p>
|
|
|
|
<script src='../lc-lightbox/js/lc_lightbox.min.js' type='text/javascript'></script>
|
|
<script src='../lc-lightbox/lib/AlloyFinger/alloy_finger.min.js' type='text/javascript'></script>
|
|
|
|
</body>
|
|
|
|
</html>
|