dolibarr 21.0.0-alpha
mymodule.js.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) ---Replace with your own copyright and developer email---
3 *
4 * This program 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 * This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
16 *
17 * Library javascript to enable Browser notifications
18 */
19
20if (!defined('NOREQUIREUSER')) {
21 define('NOREQUIREUSER', '1');
22}
23if (!defined('NOREQUIREDB')) {
24 define('NOREQUIREDB', '1');
25}
26if (!defined('NOREQUIRESOC')) {
27 define('NOREQUIRESOC', '1');
28}
29if (!defined('NOREQUIRETRAN')) {
30 define('NOREQUIRETRAN', '1');
31}
32if (!defined('NOCSRFCHECK')) {
33 define('NOCSRFCHECK', 1);
34}
35if (!defined('NOTOKENRENEWAL')) {
36 define('NOTOKENRENEWAL', 1);
37}
38if (!defined('NOLOGIN')) {
39 define('NOLOGIN', 1);
40}
41if (!defined('NOREQUIREMENU')) {
42 define('NOREQUIREMENU', 1);
43}
44if (!defined('NOREQUIREHTML')) {
45 define('NOREQUIREHTML', 1);
46}
47if (!defined('NOREQUIREAJAX')) {
48 define('NOREQUIREAJAX', '1');
49}
50
51
58// Load Dolibarr environment
59$res = 0;
60// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
61if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
62 $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
63}
64// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
65$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME'];
66$tmp2 = realpath(__FILE__);
67$i = strlen($tmp) - 1;
68$j = strlen($tmp2) - 1;
69while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
70 $i--;
71 $j--;
72}
73if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
74 $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
75}
76if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/../main.inc.php")) {
77 $res = @include substr($tmp, 0, ($i + 1))."/../main.inc.php";
78}
79// Try main.inc.php using relative path
80if (!$res && file_exists("../../main.inc.php")) {
81 $res = @include "../../main.inc.php";
82}
83if (!$res && file_exists("../../../main.inc.php")) {
84 $res = @include "../../../main.inc.php";
85}
86if (!$res) {
87 die("Include of main fails");
88}
89
90// Define js type
91header('Content-Type: application/javascript');
92// Important: Following code is to cache this file to avoid page request by browser at each Dolibarr page access.
93// You can use CTRL+F5 to refresh your browser cache.
94if (empty($dolibarr_nocache)) {
95 header('Cache-Control: max-age=3600, public, must-revalidate');
96} else {
97 header('Cache-Control: no-cache');
98}
99?>
100
101/* Javascript library of module MyModule */