Files
sls/requests.php
2024-04-06 11:55:24 +02:00

203 lines
6.3 KiB
PHP

<!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='css/lc_lightbox.min.css' />
<link rel='stylesheet' href='css/open_close_fx.css' />
<link rel='stylesheet' href='css/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" />
<?php include 'functions.php';
session_start();
if($_SESSION['Active'] == false){ /* Redirects user to login.php if not logged in */
header("location:admin/login.php");
exit;
}
$domain = 'sentier';
localize($domain);
?>
<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('View database'); ?></h1>
<?php
$base = 'db_photo.sqlite3';
$conn = new PDO("sqlite:db_photo.sqlite3");
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$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 <> ""'
);
$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++;
}
//_pr($select);
/*
try {
$query = $conn->query('SELECT DISTINCT lens FROM photos WHERE lens <> "" ORDER BY lens');
$lens = $query->fetchAll(PDO::FETCH_ASSOC);
$lens = array_column($lens,'lens');
$query = $conn->query('SELECT DISTINCT model FROM photos WHERE model <> "" ORDER BY model');
$model = $query->fetchAll(PDO::FETCH_ASSOC);
$model = array_column($model,'model');
$query = $conn->query('SELECT DISTINCT iso FROM photos WHERE iso <> "" ORDER BY iso');
$iso = $query->fetchAll(PDO::FETCH_ASSOC);
$iso = array_column($iso,'iso');
$query = $conn->query('SELECT DISTINCT speed FROM photos WHERE speed <> "" ORDER BY speed');
$speed = $query->fetchAll(PDO::FETCH_ASSOC);
$speed = array_column($speed,'speed');
$query = $conn->query('SELECT DISTINCT keywords FROM photos WHERE keywords <> ""');
$keywords = $query->fetchAll(PDO::FETCH_ASSOC);
$keywords = array_column($keywords,'keywords');
$conn = null;
}
catch(PDOException $e) {
echo $e->getMessage();
}
//_pr($keywords);
$mc = array();
foreach($keywords 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'
echo count($motcles);
*/
/*
https://www.csscodelab.com/pure-css-custom-select-box-dropdown-styling/
*/
?>
<div class="myForm">
<form id="keywordSelect" name="keywordSelect" action="index.php" method="get" >
<select name="keyword" id="keyword" class="classic">
<option value=""><?php echo gettext('keywords'); ?></option>
<?php
for( $i = 0; $i < count($select[4]); $i++) {
echo '<option value="">' . $select[4]["$i"] . '</option>';
}
?>
</select>
<button type="submit" class="myButton">Ok</button>
</form>
</div>
<div class="myForm">
<form name="modelSelect" action="index.php" method="get" >
<select name="model" id="model" class="classic">
<option value=""><?php echo gettext('model'); ?></option>
<?php
for( $i = 0; $i < count($select[1]); $i++) {
echo '<option value="">' . $select[1]["$i"] . '</option>';
}
?>
</select>
<button type="submit" class="myButton">Ok</button>
</form>
</div>
<div class="myForm">
<form name="lensSelect" action="index.php" method="get" >
<select name="lens" id="lens" class="classic">
<option value=""><?php echo gettext('lens'); ?></option>
<?php
for( $i = 0; $i < count($select[0]); $i++) {
echo '<option value="">' . $select[0]["$i"] . '</option>';
}
?>
</select>
<button type="submit" class="myButton">Ok</button>
</form>
</div>
<div class="myForm">
<form name="isoSelect" action="index.php" method="get" >
<select name="iso" id="iso" class="classic">
<option value=""><?php echo gettext('iso'); ?></option>
<?php
for( $i = 0; $i < count($select[2]); $i++) {
echo '<option value="">' . $select[2]["$i"] . '</option>';
}
?>
</select>
<button type="submit" class="myButton">Ok</button>
</form>
</div>
<div class="myForm">
<form name="speedSelect" action="index.php" method="get" >
<select name="speed" id="speed" class="classic">
<option value=""><?php echo gettext('speed'); ?></option>
<?php
for( $i = 0; $i < count($select[3]); $i++) {
echo '<option value="">' . $select[3]["$i"] . '</option>';
}
?>
</select>
<button type="submit" class="myButton">Ok</button>
</form>
</div>
<p class="navPage"><a href="index.php" title="<?php echo gettext("Home"); ?>"><?php echo gettext("Home"); ?></a> | <a href="maps.php" title="<?php echo gettext("Maps"); ?>"><?php echo gettext("Maps"); ?></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="admin/index.php" title="<?php echo gettext("Admin"); ?>"><?php echo gettext("Admin"); ?></a></p>
<p><em><small>&copy; 2013-<?php echo date('Y'); ?> sur-le-sentier.fr</small></em></p>
<script src='js/lc_lightbox.min.js' type='text/javascript'></script>
<script src='js/alloy_finger.min.js' type='text/javascript'></script>
</body>
</html>