forked from jeedom/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
99 lines (94 loc) · 3.54 KB
/
index.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
<?php
/* This file is part of Jeedom.
*
* Jeedom 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.
*
* Jeedom 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 Jeedom. If not, see <http://www.gnu.org/licenses/>.
*/
if (!file_exists(dirname(__FILE__) . '/core/config/common.config.php')) {
header("location: install/setup.php");
}
if (!isset($_GET['v'])) {
$useragent = (isset($_SERVER["HTTP_USER_AGENT"])) ? $_SERVER["HTTP_USER_AGENT"] : 'none';
$getParams = (stristr($useragent, "Android") || strpos($useragent, "iPod") || strpos($useragent, "iPhone") || strpos($useragent, "Mobile") || strpos($useragent, "WebOS") || strpos($useragent, "mobile") || strpos($useragent, "hp-tablet"))
? 'm' : 'd';
foreach ($_GET AS $var => $value) {
$getParams .= '&' . $var . '=' . $value;
}
$url = 'index.php?v=' . trim($getParams, '&');
if (headers_sent()) {
echo '<script type="text/javascript">';
echo "window.location.href='$url';";
echo '</script>';
} else {
exit(header('Location: ' . $url));
}
die();
}
require_once dirname(__FILE__) . "/core/php/core.inc.php";
function include_authenticated_file($_folder, $_fn, $_type, $_plugin, $alert_folder) {
include_file('core', 'authentification', 'php');
try {
if (!isConnect()) {
throw new Exception('{{401 - Accès non autorisé}}');
}
include_file($_folder, $_fn, $_type, $_plugin);
} catch (Exception $e) {
$_folder = 'desktop/modal';
if (init('plugin') != '') {
$_folder = 'plugins/' . init('plugin') . '/' . $_folder;
}
ob_end_clean(); //Clean pile after expetion (to prevent no-traduction)
echo '<div class="alert alert-danger div_alert">';
echo translate::exec(displayExeption($e), $alert_folder);
echo '</div>';
}
}
if (isset($_GET['v']) && $_GET['v'] == 'd') {
if (isset($_GET['modal'])) {
$alert_folder = 'desktop/modal/' . init('modal') . '.php';
if (init('plugin') != '') {
$alert_folder = 'plugins/' . init('plugin') . '/' . $alert_folder;
}
include_authenticated_file('desktop', init('modal'), 'modal', init('plugin'), $alert_folder);
} elseif (isset($_GET['configure'])) {
$alert_folder = 'plugin_info/configure.php';
if (init('plugin') != '') {
$alert_folder = 'plugins/' . init('plugin') . '/' . $alert_folder;
}
include_authenticated_file('plugin_info', 'configuration', 'configuration', init('plugin'), $alert_folder);
} elseif (isset($_GET['ajax']) && $_GET['ajax'] == 1) {
$alert_folder = 'desktop/php/' . init('modal') . '.php';
if (init('m') != '') {
$_folder = 'plugins/' . init('m') . '/' . $_folder;
}
include_authenticated_file('desktop', init('p'), 'php', init('m'), $alert_folder);
} else {
include_file('desktop', 'index', 'php');
}
} elseif (isset($_GET['v']) && $_GET['v'] == 'm') {
$_folder = 'mobile';
$_fn = 'index';
$_type = 'html';
$_plugin = '';
if (isset($_GET['modal'])) {
$_fn = init('modal');
$_type = 'modal';
$_plugin = init('plugin');
} elseif (isset($_GET['p']) && isset($_GET['ajax'])) {
$_fn = $_GET['p'];
$_plugin = isset($_GET['m']) ? $_GET['m'] : $_plugin;
}
include_file($_folder, $_fn, $_type, $_plugin);
} else {
echo "Erreur: veuillez contacter l'administrateur";
}