-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_db_galerie.php
82 lines (76 loc) · 2.59 KB
/
update_db_galerie.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
80
81
82
<?php
session_start();
if ($_SESSION['ID'] == "admin") {
include("managers/connect_bdd.php");
// When the directory is not empty:
function rrmdir($dir) {
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
if (filetype($dir."/".$object) == "dir") rrmdir($dir."/".$object); else unlink($dir."/".$object);
}
}
reset($objects);
rmdir($dir);
}
}
session_start();
$categorie = $_SESSION["categorie"];
if (isset($_SESSION['autre'] )) {
if ($_SESSION['autre']==true) {
$bdd->query("INSERT INTO galerie (theme) VALUES ('$categorie')");
$_SESSION['autre'] = false;
//echo("je suis dedans");
}
}
//echo($_SESSION["categorie"]);
$dir = "assets/images/portfolio/$categorie";
rrmdir("$dir/thumbnail");
$dh = opendir($dir);
while (false !== ($filename = readdir($dh))) {
$files[] = $filename;
}
sort($files);
//print_r($files);
foreach($files as $num=>$photos) {
if ($num==0 || $num==1) {
} else {
$produits[$num-2] = "assets/images/portfolio/$categorie/".$files[$num];
}
}
$photos_2 = serialize($produits);
$bdd->query("UPDATE `galerie` SET `photos` = '$photos_2' WHERE `theme` = '$categorie'");
//var_dump($produits);
} else {
header("location: index.php");
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<!--<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">-->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Blog Photographe amateur" />
<meta name="author" content="Brice Riou - Nicolas McClure" />
<title>World-Pictures - Update DB Galerie</title>
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<link href="assets/css/bootstrap-responsive.min.css" rel="stylesheet" type="text/css">
<link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="assets/css/main.css" />
</head>
<body>
<?php include("menu.php"); ?>
<div id="bloc_confirmation">
<ul class="span6 offset4">
<li>Mise à jour de la base de donnée avec succès!</li>
<li><a title="" data-original-title="" class="btn btn-primary" href="ajout_photos.php">Ajouter des photos</a></li>
</ul>
</div>
<?php include("footer.php"); ?>
<script src="http://code.jquery.com/jquery.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>