-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathmain.php
151 lines (113 loc) · 4.61 KB
/
main.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?php
// About
define('global_project_name', 'phpMyReservation');
define('global_project_version', '1.0');
define('global_project_website', 'http://www.olejon.net/code/phpmyreservation/');
// Include necessary files
include_once('db.php');
include_once('config.php');
include_once('functions.php');
// MySQL
//mysql_connect(global_mysql_server, global_mysql_user, global_mysql_password)or die('<span class="error_span"><u>MySQL error:</u> ' . htmlspecialchars(mysql_error()) . '</span>');
//mysql_select_db(global_mysql_database)or die('<span class="error_span"><u>MySQL error:</u> ' . htmlspecialchars(mysql_error()) . '</span>');
//mysql_set_charset('utf8');
define('global_mysql_configuration_table', 'phpmyreservation_configuration');
define('global_mysql_users_table', 'phpmyreservation_users');
define('global_mysql_reservations_table', 'phpmyreservation_reservations');
// Cookies
define('global_cookie_prefix', 'phpmyreservation');
// Start session
session_start();
// Configuration
define('global_price', get_configuration('price'));
// Date
/**
* Set the default time zone.
*
* @see http://inducidoframework.org/guide/using.configuration
* @see http://php.net/timezones
*/
date_default_timezone_set('Europe/Paris');
//todo ici il faudrait fr_FR
setlocale(LC_ALL, 'fr_FR.utf-8');
//For debian/ubuntu, don't forget the charset UFT8.
setlocale(LC_ALL, 'fr_FR.UTF8', 'fr.UTF8', 'fr_FR.UTF-8', 'fr.UTF-8');
// http://www.finalclap.com/faq/81-php-afficher-date-heure-francais
setlocale(LC_TIME, 'fra_fra');
define('global_year', date('Y'));
//define('global_week_number', ltrim(date('W'), '0')); //week number of year
define('global_week_number', 26 ); //week number of year
define('global_day_number', date('N')); //1 (for Monday) through 7 (for Sunday)
define('global_day_name', date('l')); //Sunday through Saturday
class DateTimeFrench extends DateTime
{
public function format($format)
{
$english_days = array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday');
$french_days = array('Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi', 'Dimanche');
$english_months = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'Décember');
$french_months = array('Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre');
return str_replace($english_months, $french_months, str_replace($english_days, $french_days, parent::format($format)));
}
}
// User agent
if(isset($_SERVER['HTTP_USER_AGENT']))
{
define('global_ua', $_SERVER['HTTP_USER_AGENT']);
}
else
{
define('global_ua', 'CLI');
}
if(strstr(global_ua, 'iPhone') || strstr(global_ua, 'iPod') || strstr(global_ua, 'iPad') || strstr(global_ua, 'Android'))
{
if(strstr(global_ua, 'AppleWebKit'))
{
if(strstr(global_ua, 'OS 5_') || strstr(global_ua, 'Android 2.3') || strstr(global_ua, 'Android 3') || strstr(global_ua, 'Android 4'))
{
define('global_css_animations', '1');
}
}
}
elseif(strstr(global_ua, 'Chrome') || strstr(global_ua, 'Safari') && strstr(global_ua, 'Macintosh') || strstr(global_ua, 'Safari') && strstr(global_ua, 'Windows') || strstr(global_ua, 'Firefox') || strstr(global_ua, 'Opera') || strstr(global_ua, 'MSIE 10'))
{
define('global_css_animations', '1');
}
else
{
define('global_css_animations', '0');
}
// Check stuff
if(strlen(global_salt) != 9)
{
echo '<script type="text/javascript">window.location.replace(\'error.php?error_code=1\');</script>';
exit;
}
if(isset($_GET['day_number']))
{
echo date('N');
}
elseif(isset($_GET['latest_version']))
{
$latest_version_url = global_project_website . 'latest-version.php?version=' . urlencode(global_project_version);
$latest_version_url_context = stream_context_create(array('http'=>array('timeout'=>5)));
@$latest_version = file_get_contents($latest_version_url, false, $latest_version_url_context);
$latest_version = trim($latest_version);
if(empty($latest_version) || !is_numeric($latest_version))
{
echo '<span class="error_span">Could not get latest version</span>';
}
else
{
echo 'Latest version: ' . $latest_version;
}
}
function filter_string($field)
{
//si la variable est pas définie on renvoie true
if(!isset($field))return $field;
// Using the filter_var function introduced in PHP 5.2.0
if(($field = filter_var($field,FILTER_SANITIZE_STRING))===false)
return null;
return filter_var($field,FILTER_SANITIZE_MAGIC_QUOTES);
}