setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); if (!isset($_GET['page'])) $page = 1; else $page = intval($_GET['page']); $gps = (isset($_SESSION['query']['gps'])) ? $_SESSION['query']['gps'] : "off"; $dir = (new AdvancedFilesystemIterator($chemin))->match('/heic|HEIC|jpg|jpeg|JPG|JPEG|webp|WEBP$/'); $request = array( 'lens' => 'SELECT DISTINCT lens FROM photos WHERE lens <> "" ORDER BY lens', 'model' => 'SELECT DISTINCT model FROM photos WHERE model <> "" ORDER BY model', 'iso' => 'SELECT DISTINCT iso FROM photos WHERE iso <> "" ORDER BY iso', 'speed' => 'SELECT DISTINCT speed FROM photos WHERE speed <> "" ORDER BY speed', 'keywords' => 'SELECT DISTINCT keywords FROM photos WHERE keywords <> ""', 'strftime("%Y", dateoriginal)' => 'SELECT DISTINCT strftime("%Y", dateoriginal) FROM photos WHERE dateoriginal <> "" ORDER BY dateoriginal DESC' ); $select = array(); $i = 0; foreach ($request as $key => $val){ $query = $conn->query($val); $select[$i] = $query->fetchAll(PDO::FETCH_ASSOC); $select[$i] = array_column($select[$i],$key); if ($i == 4){ $mc = array(); foreach($select[$i] as $row){ $x = explode(",", $row); foreach ($x as $y){ if ((! str_starts_with($y, "_")) && (! str_ends_with($y, "_"))) { $mc [] = $y; } } } $motcles = array_unique($mc); usort($motcles, 'strcasecmp'); // 'strcasecmp' $select[$i] = $motcles; } $i++; } ?> <?php echo gettext('View photos in Sqlite base'); ?> ' . gettext('View database') . ': ' . $base . '
'; // Affichage des photos try { $columns = array('dateoriginal','lens','model','iso','lat'); $column = isset($_GET['column']) && in_array($_GET['column'], $columns) ? $_GET['column'] : $columns[0]; $sort_order = isset($_GET['order']) && strtolower($_GET['order']) == 'desc' ? 'DESC' : 'ASC'; $req1 = ""; $req2 = ""; $req3 = ""; $req4 = ""; $req5 = ""; $req6 = ""; $req7 = ""; if (!empty($_POST['lens'])) $req1 = "lens = '" . $_POST['lens'] . "'"; if (!empty($_POST['model'])) $req2 = "model = '" . $_POST['model'] . "'"; if (!empty($_POST['iso'])) $req3 = "iso = '" . $_POST['iso'] . "'"; if (!empty($_POST['speed'])) $req4 = "speed = '" . $_POST['speed'] . "'"; if (!empty($_POST['keyword'])) $req5 = "keywords LIKE '%" . str_replace("'","''", $_POST['keyword']) . "%'"; if (!empty($_POST['all']) && ($_POST['all'] == "all")) $req = ""; if (isset($_POST['operator'])) $operator = " " . $_POST['operator'] . " "; if (!empty($_POST['gps'])) $req6 = "lat != '' AND long != ''"; if (!empty($_POST['date'])) $req7 = "strftime('%Y', dateoriginal) = '" . $_POST['date'] . "'"; if (($req1 != "") || ($req2 != "") || ($req3 != "") || ($req4 != "") || ($req5 != "")) { $req = "WHERE " . ($req1 != "" ? $req1 . $operator : "") . ($req2 != "" ? $req2 . $operator : "") . ($req3 != "" ? $req3 . $operator : "") . ($req4 != "" ? $req4 . $operator : "") . ($req5 != "" ? $req5 . $operator : ""); $req = substr_replace($req, " ", (strlen($req) - strlen($operator)), strlen($operator)); } elseif ($req6 != "") { $req = "WHERE " . $req6 . " "; } elseif ($req7 != "") { $req = "WHERE " . $req7 . " "; } else $req = ""; $query2 = "SELECT * FROM photos " . $req . "ORDER BY " . $column . " " . $sort_order . " " . "LIMIT ? OFFSET ?"; /* 1ere requete pour compter les resultats:*/ /* $sql = "SELECT COUNT(*) FROM photos " . $req; $statement = $conn->prepare($sql); $statement->execute(); $ct = $statement->fetch(PDO::FETCH_NUM); // Return array indexed by column number $count = $ct; reset($ct); // Resets array cursor and returns first value (the count) $count = current($ct); //$count = $count[0]; echo $count; */ $query ="WITH cnt(total) as (SELECT COUNT(*) from photos " . $req . ") SELECT * FROM photos,cnt " . $req . "ORDER BY " . $column . " " . $sort_order . " " . "LIMIT ? OFFSET ?"; // WITH cnt(total) as (SELECT COUNT(*) from photos WHERE speed = '1.6s' ) SELECT * FROM photos,cnt WHERE speed = '1.6s' ORDER BY dateoriginal ASC LIMIT ? OFFSET ? $offset = $perpage * ($page -1); $stmt = $conn->prepare($query); $stmt->execute(array($perpage, $offset)); // (1,3...) 1=1ere valeur 3=valeur // nb de resultats de la requete $count = $stmt->fetchColumn(34); // total => 35 $stmt->execute(array($perpage, $offset)); if (empty($_POST)) { echo '

' . count($dir) . gettext(' images found in folder') . ' photos/img/ ...

'; // Display request !! echo '
' . $query2 . '
'; } elseif ((isset($_POST['suppress'])) && ($_POST["suppress"] == "suppress")) { echo $msg; if (isset($_POST['coche']) && (! empty($_POST['coche']))) { echo '
' . $request_delete . '
'; } } else { $found = sprintf(ngettext("%d image found with the following query:","%d images found with the following query:", $count), $count); echo '

' . $found . '

'; //echo '

' . $count . gettext(' images founds with the following request:') . '

'; // Display request !! echo '
' . $query2 . '
'; } $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"'; ?>
APN
All
Divers
'; echo '

'; echo '
'; echo ''; //echo ''; echo ''; echo ''; echo ''; echo '' . ((isset($_SESSION["user"])) ? '' : '') . ''; echo ''; echo ''; echo ''; echo ''; $nRows = 0; while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $lb = data_for_lightbox($row); echo '' . ((isset($_SESSION["user"])) ? '' : '') . ''; $nRows++; } if ($nRows == 0) echo ''; echo '
' . gettext('Select') . '' . gettext('Id') . '' . gettext('Thumb') . '' . gettext('Filename') . ' (' . gettext('Size') . ')' . gettext('Date') . ' ' . gettext('Lens') . ' ' . gettext('Speed') . '' . gettext('Aperture') . '' . gettext('Exposure corr.') . '' . gettext('Iso') . ' ' . gettext('Width') . '' . gettext('Height') . '' . gettext('Model') . ' ' . gettext('Latitude') . ' ' . gettext('Longitude') . '' . gettext('Alttitude') . '' . gettext('Legende') . '' . gettext('Copyright') . '' . gettext('Title') . '' . gettext('Creator') . '' . gettext('Keywords') . '' . gettext('Metering') . '' . gettext('Flash') . '' . gettext('Focal') . '' . gettext('Wb') . '' . gettext('Program') . '
' . '' . '' . $row['id'] . '' . '' . htmlspecialchars($lb['title']) . '' . '' . $row['filename'] . '
(' . $row['filesize'] . ')
' . $row['dateoriginal'] . '' . $row['lens'] . '' . $row['speed'] . '' . $row['aperture'] . ' ' . $row['correctexpo'] . '' . $row['iso'] . '' . $row['width'] . '' . $row['height'] . '' . $row['model'] . '' . $row['lat'] . '' . $row['long'] . '' . $row['alt'] . '' . $row['legende'] . '' . $row['copyright'] . '' . $row['title'] . '' . $row['creator'] . '' . $row['keywords'] . '' . $row['metering'] . '' . $row['flash'] . '' . $row['focal'] . '' . $row['wb'] . '' . $row['program'] . '
' . gettext("No image found !") .'
'; if (isset($_SESSION["user"])) { echo ''; //echo ''; echo ''; } echo '
'; echo ''; } catch(PDOException $e) { echo $e->getMessage(); } ?> prepare($query4); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); $numRows = $result['count']; //$stmt = $conn->reset(); $conn = 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; if ($numRows > 0) { echo ''; } ?> ' . gettext("Log out") . '' : ''; ?>

© 2013- sur-le-sentier.fr