delete_bdd.php (delete ; coche) edit; coche => edit_bdd.php => modify_bdd.php (modif sur la bdd) */ if (isset($_SESSION["user"])) { if ((isset($_POST["suppress"])) && ($_POST["suppress"] == "suppress")) { 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_suppress = "SELECT * FROM photos WHERE " . $req . " ORDER BY id"; } else { $url = "view_bdd.php?message=" . urlencode(gettext("No images select !")); header("location: $url"); } } elseif ((isset($_POST["delete"])) && ($_POST["delete"] == "delete")) { if (isset($_POST['id']) && (! empty($_POST['id']))) { $rr = ""; foreach($_POST['id'] as $key => $value) { $r = "id = '" . $value . "' OR "; $rr .= $r; } $req = substr($rr, 0, -4); /**/ $req_suppress = "SELECT id, filename FROM photos WHERE " . $req . " ORDER BY id"; // Pour supprimer les fichiers $stmt = $conn->prepare($req_suppress); $stmt->execute(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $ids[] = $row['id']; if (file_exists($file)) { $files[] = realpath('.') . "/" . $file; } else { //$msg .= "File $file doesn't exist !"; $msg .= sprintf( gettext("File %s doesn't exist !"), $file); } } //_pr($files); $req_delete = "DELETE FROM photos WHERE id in (".str_repeat("?,", count($ids) - 1)."?)"; // DELETE FROM photos WHERE id in (?,?) $stmt = $conn->prepare($req_delete); $stmt->execute($ids); $count = $stmt->rowCount(); if ($count = count($files)) { foreach ($files as $file) { if (unlink($file)) { //echo "File: " . $file . " deleted!" . "
"; $files_deleted .= sprintf( gettext("File: %s deleted!"), $file ) . "\n"; //echo $a; } } } } 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"); } ?> <?php echo gettext('View photos in Sqlite base'); ?> ' . gettext('Suppress images ') . ': ' . $base . '
'; if (($req_suppress != "") and ($req_delete == "")) { echo '

' . $msg . '

'; try { $conn3 = new PDO('sqlite:db_photo.sqlite3'); $stmt3 = $conn3->prepare($req_suppress); $stmt3->execute(); echo '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; while ($row = $stmt3->fetch(PDO::FETCH_ASSOC)) { $thumbnail = host() . str_replace("photos/img", "photos/thumb", $row['filename']); $full = host() . $row['filename']; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; //echo ''; echo ""; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } echo '
' . gettext('Id') . '' . gettext('Thumb') . '' . gettext('Filename') . '' . gettext('Date') . ' ' . gettext('Speed') . '' . gettext('Iso') . '' . gettext('Aperture') . '' . gettext('Expo. correct') . '' . gettext('Model') . '' . gettext('Lens') . '' . gettext('Focal') . '' . gettext('Metering') . '' . gettext('Program') . '' . gettext('Wb') . '' . gettext('Flash') . '' . gettext('Software') . '' . gettext('Keywords') . '' . gettext('Title') . '' . gettext('Creator') . '' . gettext('City') . '' . gettext('Department') . '' . gettext('Code') . '' . gettext('Country') . '' . gettext('Copyright') . '' . gettext('Legende') . '
' . $row['id'] . '' . '' . '' . $row['filename'] . '' . $row['dateoriginal'] . '' . $row['speed'] . '' . $row['iso'] . '' . $row['aperture'] . '' . $row['correctexpo'] . '' . $row['model'] . '' . $row['focal'] . '' . $row['metering'] . '' . $row['program'] . '' . $row['wb'] . '' . $row['flash'] . '' . $row['software'] . '
'; echo '

' . gettext('Clic on Delete button will delete the images in the database and the files on the server.') . '

'; echo ''; echo '
'; //$conn = null; } catch(PDOException $e) { echo $e->getMessage(); } $req_suppress = ""; } if ($req_delete != "") { //$msg = sprintf("Updated %d rows with following request:", $count); $msg = sprintf(gettext("%d rows deleted and the following files:"), $count); //$msg = $count . gettext(" rows deleted and the following files:"); echo '

' . $msg . '

'; echo '

' . nl2br($files_deleted) . '

'; //echo '
' . $req_delete . '
'; } ?>

© 2013- sur-le-sentier.fr