Browse code

init witj jeedom template

louis.jonget authored on17/01/2023 08:47:47
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,39 @@
1
+<?php
2
+/* This file is part of Jeedom.
3
+ *
4
+ * Jeedom is free software: you can redistribute it and/or modify
5
+ * it under the terms of the GNU General Public License as published by
6
+ * the Free Software Foundation, either version 3 of the License, or
7
+ * (at your option) any later version.
8
+ *
9
+ * Jeedom is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with Jeedom. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+try {
19
+    require_once dirname(__FILE__) . '/../../../../core/php/core.inc.php';
20
+    include_file('core', 'authentification', 'php');
21
+
22
+    if (!isConnect('admin')) {
23
+        throw new Exception(__('401 - Accès non autorisé', __FILE__));
24
+    }
25
+
26
+  /* Fonction permettant l'envoi de l'entête 'Content-Type: application/json'
27
+    En V3 : indiquer l'argument 'true' pour contrôler le token d'accès Jeedom
28
+    En V4 : autoriser l'exécution d'une méthode 'action' en GET en indiquant le(s) nom(s) de(s) action(s) dans un tableau en argument
29
+  */
30
+    ajax::init();
31
+
32
+
33
+
34
+    throw new Exception(__('Aucune méthode correspondante à', __FILE__) . ' : ' . init('action'));
35
+    /*     * *********Catch exeption*************** */
36
+}
37
+catch (Exception $e) {
38
+    ajax::error(displayException($e), $e->getCode());
39
+}