-
Notifications
You must be signed in to change notification settings - Fork 2
/
header.php
127 lines (112 loc) · 3.44 KB
/
header.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
/*
* This file is part of Ezac.
*
* Ezac is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Ezac is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Ezac. If not, see <http://www.gnu.org/licenses/>.
*/
session_start();
include_once 'config/config-database.php';
function get_room_left($hote_id){
global $db_link;
$query = "SELECT COUNT(*) AS nb_room
FROM hebergement_invites
WHERE id_hote = '$hote_id'";
$result = mysql_query($query, $db_link) or die("Select invites query failed" . mysql_error());
$count = mysql_fetch_array($result);
$query = "SELECT nb_places
FROM hebergement_hotes
WHERE id = '$hote_id'";
//print $query;
$result = mysql_query($query, $db_link) or die("Select hote query failed" . mysql_error());
$nb_place = mysql_fetch_array($result);
return $nb_place["nb_places"]-$count["nb_room"];
}
function insert_invite($qui, $tel, $email, $hote_id)
{
global $db_link;
if(get_room_left($hote_id)>0){
$query="INSERT INTO hebergement_invites VALUES
(NULL,
'$qui',
'$tel',
'$email',
NOW(),
'$hote_id')";
//print $query;
mysql_query($query, $db_link) or die("Insert impossible in table hebergement_invites" . mysql_error());
}else{
print "<script type=\"text/javascript\">alert(\"Il n'y a plus de place chez cet hote.\");</script>";
}
}
function insert_hote($id_evenement, $qui, $adresse, $tel, $email, $nb_places, $couchage, $remarque)
{
global $db_link;
$query="INSERT INTO hebergement_hotes VALUES
(NULL,
'$id_evenement',
'$qui',
'$adresse',
'$tel',
'$email',
'$nb_places',
'$couchage',
'$remarque',
NOW())";
//print $query;
mysql_query($query, $db_link) or die("Insert impossible in table hebergement_hotes" . mysql_error());
}
/**
* fill an array with "evenement" data
* @param int $event_id ID of the wanted "evenement"
* return array
*/
function get_tab_evenement($event_id){
global $db_link;
$query_evenement = "SELECT * FROM hebergement_evenement WHERE id = '" . mysql_real_escape_string($event_id) . "';";
$res_evenement = mysql_query($query_evenement, $db_link);
if(!$res_evenement) return null;
$tab_evenement = mysql_fetch_array($res_evenement);
return $tab_evenement;
}
/**
* Select all invites from a host
* @param int $id
* return resource list of invites
*/
function get_invites($id, $event_id)
{
global $db_link;
$query="SELECT * FROM hebergement_invites WHERE id_hote=$id";
return mysql_query($query, $db_link);
}
//----------------------------------------------------------------------------------------------
//Récupère l'id d'événement qui nous intéresse
if(isset($_GET['id_evenement'])){
$event_id = $_GET['id_evenement'];
$_SESSION['id_evenement'] = $event_id;
}
elseif(isset($_SESSION['id_evenement'])){
$event_id = $_SESSION['id_evenement'];
}
else{
//$event_id = null;
//Evenement par défaut : disons que c'est funam'bals
$event_id = 2;
}
$tab_evenement = get_tab_evenement($event_id);
if(!$tab_evenement){
$_SESSION['id_evenement'] = null;
header('location: http://lacampanule.free.fr/');
die();
}