-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathincluder.inc
158 lines (147 loc) · 5.83 KB
/
includer.inc
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
152
153
154
155
156
157
158
<?php
////////////////////////////////////////////////////////////////////////////////
// File name : includer.inc //
// Version : 21.2 //
// Begin : 2020-09-02 //
// Last Change : 2021-03-30 //
// Author : FeRox Management Consulting GmbH & Co. KG //
// Adolf-Langer-Weg 11a, D-94036 Passau (Germany) //
// https://www.ferox.de - info@ferox.de //
// License : GNU-GPL v3 (https://opensource.org/licenses/GPL-3.0) //
// -------------------------------------------------------------------------- //
// fx-project - An open source PHP Project Managament Software //
// Copyright © FeRox Management Consulting GmbH & Co. KG //
// -------------------------------------------------------------------------- //
// This program 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. //
// //
// This program 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 this program. If not, see <https://www.gnu.org/licenses/>. //
// //
// See ../LICENSE.TXT file for more information. //
// -------------------------------------------------------------------------- //
// LICENSING ADDENDUM: //
// Programs in the SPP (Special Programs) subfolder are coded extensions of //
// the open source software fx-project. These programs are offered for sale //
// by the manufacturer FeRox Management Consulting GmbH & Co. KG and require //
// a valid key for execution. It is forbidden to resell these programs //
// and/or keys or to pass them on free of charge or use them without the //
// express written permission of FeRox Management Consulting GmbH & Co. KG. //
////////////////////////////////////////////////////////////////////////////////
/**
* @file
* Includer program to check if requested files exsist.
* - If a requested existing file has not been already included it will be included now.
* - If a requested existing file has already been included it will be skipped.
*
* The to be included files have to be added to the array $GLOBALS['__includer'] before calling this file.
*
* @author FeRox Management Consulting GmbH & Co. KG, Adolf-Langer-Weg 11a, D-94036 Passau (Germany)
* @version 21.2
*/
$GLOBALS['__loaded_'.basename(__FILE__)]=true;
// Search for and include "basics.inc" to set all definitions, variables and necessary dynamic paths
$__pnm='basics.inc';
if(!isset($GLOBALS['__loaded_'.$__pnm]))
{
$__prg=$__pnm;
$__pfc=0;
while(($__pfc < 10) && !file_exists($__prg))
{
$__pfc++;
$__prg='../'.$__prg;
}
if(file_exists($__prg))
{
require($__prg);
}
else
die('<div style="padding:8px;"><h1 style="padding:8px;color:red;background:#fff;border:2px solid red;box-shadow:4px 4px 4px rgba(0,0,0, 0.5);">fx-project - ERROR: Necessary file "'.$__pnm.'" not found!</h1></div>');
}
// Check programs that should be included
if(fxIsArray($GLOBALS['__includer']))
{
// Debug includer?
$__idl='';
if(!isset($__idb))
{
$__idb=0;
//$__idb=-1; // Log into error_log
//$__idb=1; // Log on screen
}
// Check program function pathes?
if(fxIsArray($_GET) && isset($_GET['__itr']))
$__itr=$_GET['__itr'];
if(!isset($__itr))
{
if(fxIsArray($GLOBALS['fxpglobals']) && isset($GLOBALS['fxpglobals']['tr']) && $GLOBALS['fxpglobals']['tr'])
$__itr=$GLOBALS['fxpglobals']['tr'];
else
$__itr=array();
}
// Pathes to check
$__ipa=fxf_fn_reqFilename('', $__itr);
// Check for file in pathes
$__pfxa=array('.inc', '.php', '.pfi');
foreach($GLOBALS['__includer'] as $__ifname => $__dummy)
{
$__iok=0;
if($__idb)
$__idl .= 'Check for: "'.$__ifname.'"<br />';
if(!isset($GLOBALS['__loaded_'.$__ifname]))
{
$__inc='';
foreach($__ipa as $__ip)
{
if($__idb)
$__idl .= ' ... in directory: "'.$__ip.'"<br />';
foreach($__pfxa as $__pfx)
{
$__fn=$__ifname;
if(substr($__fn,-4) != $__pfx)
$__fn .= $__pfx;
if($__idb)
$__idl .= ' ...... with prefix: "'.$__pfx.'"<br />';
$__ipfn=$__ip.$__fn;
//echo(__FILE__.' ('.__LINE__.') - Check for "'.$__ipfn.'" ...<br />');
if(file_exists($__ipfn))
{
$__inc=$__ipfn;
break;
}
}
}
if(strlen($__inc))
{
$GLOBALS['__loaded_'.$__ifname]=true;
if($__idb)
$__idl .= ' $rarr; <b>Found "'.$__inc.'"!</b> → Include<hr />';
$__iok=2;
include($__inc);
}
else if($__idb)
$__idl .= ' $rarr; <b>Not found!<hr />';
}
else if($__idb)
{
$__iok=1;
$__idl .= ' → <b>Already included!</b><hr />';
}
//echo(__FILE__.' ('.__LINE__.') - Status for "'.$__ifname.'": '.$__iok.'<br />');
}
if($__idb && strlen($__idl))
{
if($__idb > 0)
echo($__idl);
else
error_log($__idl);
}
}
?>