"; _pr($_SESSION); //echo $_SESSION['query']; $domain = 'sentier'; localize($domain); ?>

close session "; if (!isset($_GET['page'])) $page = 1; else $page = intval($_GET['page']); echo "_POST
"; _pr($_POST); if (!empty($_POST)) { $_SESSION['query'] = $_POST; echo "post query non vide"; echo gettype($_POST); echo gettype($_SESSION['query']); } echo "_SESSION['query']
"; _pr($_SESSION['query']); $gps = (isset($_SESSION['query']['gps'])) ? $_SESSION['query']['gps'] : "off"; echo $gps; // form option $dir = (new AdvancedFilesystemIterator('photos/img/'))->match('/heic|HEIC|jpg|jpeg|JPG|JPEG|webp|WEBP$/'); echo '

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

'; $conn = new PDO("sqlite:db_photo.sqlite3"); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Construction des requêtes # SELECT * FROM photos WHERE dateoriginal LIKe '2021%' # SELECT * FROM photos WHERE strftime('%Y', dateoriginal) = '2021' ORDER BY dateoriginal # SELECT * FROM photos WHERE strftime('%Y', dateoriginal) = '2015' ORDER BY dateoriginal # SELECT DISTINCT strftime('%Y', dateoriginal) FROM photos WHERE dateoriginal <> "" ORDER BY dateoriginal $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' ); /* $req = 'SELECT DISTINCT strftime("%Y", dateoriginal) FROM photos WHERE dateoriginal <> "" ORDER BY dateoriginal'; $query = $conn->query($req); $res = $query->fetchAll(PDO::FETCH_ASSOC); preprint($res); $res = array_column($res,'strftime("%Y", dateoriginal)'); preprint($res); */ $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++; } //preprint($select); // 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'; // 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 /* if (isset($_POST['lens'])) $req = "WHERE lens = '" . $_POST['lens'] . "' "; elseif (isset($_POST['model'])) $req = "WHERE model = '" . $_POST['model'] . "' "; elseif (isset($_POST['iso'])) $req = "WHERE iso = '" . $_POST['iso'] . "' "; elseif (isset($_POST['speed'])) $req = "WHERE speed = '" . $_POST['speed'] . "' "; elseif (isset($_POST['keyword'])) $req = "WHERE keywords LIKE '%" . str_replace("'","''", $_POST['keyword']) . "%' "; else $req = ""; */ $req1 = ""; $req2 = ""; $req3 = ""; $req4 = ""; $req5 = ""; $req6 = ""; $req7 = ""; if (!empty($_SESSION['query']['lens'])) $req1 = "lens = '" . $_SESSION['query']['lens'] . "'"; if (!empty($_SESSION['query']['model'])) $req2 = "model = '" . $_SESSION['query']['model'] . "'"; if (!empty($_SESSION['query']['iso'])) $req3 = "iso = '" . $_SESSION['query']['iso'] . "'"; if (!empty($_SESSION['query']['speed'])) $req4 = "speed = '" . $_SESSION['query']['speed'] . "'"; if (!empty($_SESSION['query']['keyword'])) $req5 = "keywords LIKE '%" . str_replace("'","''", $_SESSION['query']['keyword']) . "%'"; if (!empty($_SESSION['query']['all']) && ($_SESSION['query']['all'] == "all")) $req = ""; if (isset($_SESSION['query']['operator'])) $operator = " " . $_SESSION['query']['operator'] . " "; if (!empty($_SESSION['query']['gps'])) $req6 = "lat != '' AND long != ''"; if (!empty($_SESSION['query']['date'])) $req7 = "strftime('%Y', dateoriginal) = '" . $_SESSION['query']['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)); } // add elseif ($req6 != "") { $req = "WHERE " . $req6 . " "; } elseif ($req7 != "") { $req = "WHERE " . $req7 . " "; } // else $req = ""; //echo '
' . $req . '
'; $query = "SELECT * FROM photos " . $req . "ORDER BY " . $column . " " . $sort_order . " " . "LIMIT ? OFFSET ?"; echo '
' . $query . '
'; $offset = $perpage * ($page -1); $stmt = $conn->prepare($query); $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"; //$result = $stmt->fetchAll(PDO::FETCH_ASSOC); //$count = $rows['count(*)']; //echo count($result); //_pr($rows); $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 ''; $nRows = 0; while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $thumbnail = host() . str_replace("photos/img", "photos/thumb", $row['filename']); $full = host() . $row['filename']; echo ''; $nRows++; } if ($nRows == 0) echo ''; echo '
' . gettext('Id') . '' . gettext('Thumb') . '' . gettext('Filename') . '' . gettext('Date') . ' ' . gettext('Lens') . ' ' . gettext('Speed') . '' . gettext('Aperture') . '' . 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') . '' . gettext('Html') . '
' . $row['id'] . '' . '' . '' . $row['filename'] . '' . $row['dateoriginal'] . '' . $row['lens'] . '' . $row['speed'] . '' . $row['aperture'] . '' . $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'] . '' . $row['html'] . '
' . gettext("No image found !") .'
'; echo ''; //$stmt = $conn->reset(); //$conn = null; } catch(PDOException $e) { echo $e->getMessage(); } ?> prepare($query4); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); $numRows = $result['count']; $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 ''; } ?>

© 2013- sur-le-sentier.fr