-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.php
79 lines (66 loc) · 2.15 KB
/
search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
require_once 'myAutoloader.php';
session_start();
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
if (!isset($_SESSION['user']))
{
header('Location:access_refused.php');
exit;
}
$html = "";
try
{
$values = explode(" ", $_SESSION['values']);
$red = $values[0];
$green = $values[1];
$blue = $values[2];
$threshold = 10;
$prepare = myPDO::getInstance()->getConnection()->prepare
('select * from images join users on images.userId = users.id
where red between :red - :threshold and :red + :threshold
and green between :green - :threshold and :green + :threshold
and blue between :blue - :threshold and :blue + :threshold');
if ($prepare->execute(array('red' => $red,
'green' => $green,
'blue' => $blue, 'threshold' => $threshold)))
{
while ($image = $prepare->fetch(PDO::FETCH_OBJ))
{
$name = $image->name;
$html .= "<div class=\"grid-item\">\n";
$html .= "<figure class=\"effect-sadie\">\n";
$html .= '<img src="images//' . $image->login . '//' . $image->name .
"\" alt=\"" . $image->name . "\" class=\"img-fluid tm-img\">\n" .
"<figcaption>\n" .
"<h2 class=\"tm-figure-title\">$image->name</h2>" .
"</figcaption>\n</figure>\n</div>";
}
}
}
catch(Exception $e)
{
$html = "";
$_SESSION['error'] = 'Une erreur est survenue, veuillez réessayer ulterieurement.';
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>420px - Recherche</title>
<link rel="stylesheet" href="css/bulma.css">
<link rel="stylesheet" href="css/templatemo-style.css">
</head>
<body>
<?php
include "header.php";
include "error.php";
echo $html;
?>
</body>
</html>