Files
sls/edit_bdd.php
2024-12-10 11:39:15 +01:00

146 lines
6.3 KiB
PHP

<?php require ("3-protect.php");
include 'localize.php';
$domain = 'sentier';
localize($domain);
include 'functions.php';
$base = 'db_photo.sqlite3';
$conn = new PDO("sqlite:$base");
$msg = "";
$req_edit = "";
if (isset($_SESSION["user"])) {
if ((isset($_POST["edit"])) && ($_POST["edit"] == "edit")) {
if (isset($_POST['coche']) && (! empty($_POST['coche']))) {
$rr = "";
foreach($_POST['coche'] as $key => $value) {
$r = "id = '" . $value . "' OR ";
$rr .= $r;
}
$req = substr($rr, 0, -4);
$req_edit = "SELECT * FROM photos WHERE " . $req . " ORDER BY id";
}
else {
$url = "view_bdd.php?message=" . urlencode(gettext("No images select !"));
header("location: $url");
}
}
else {
$url = "view_bdd.php?message=" . urlencode(gettext("No images select !"));
header("location: $url");
}
}
else {
$url = "admin.php?message=" . urlencode(gettext("Please log in !"));
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 echo 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>
<?php
debug_to_console($_GET);
debug_to_console($req_edit);
$base = 'db_photo.sqlite3';
echo '<h1>' . gettext('Edit database') . ': ' . $base . '</h1><br />';
echo '<h3>' . $msg . '</h3>';
try {
$conn = new PDO('sqlite:db_photo.sqlite3');
$stmt = $conn->prepare($req_edit);
$stmt->execute();
?>
<?php
echo '<form id="editImage" name="editImage" action="modify_bdd.php" method="post" class="myForm" >';
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'];
echo '<tr><td>' . $row['id'] . '</td><td>' . '<a href="' . $full . '"><img src="'.$thumbnail.'" /></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='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>';
echo '<button type="submit" name="update" value="update" class="myButton all">' . gettext('Update') . '</button>';
echo '</form>';
$conn = null;
}
catch(PDOException $e) {
echo $e->getMessage();
}
?>
<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></p>
<p><em><small>&copy; 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>