XOOPS  2.6.0
xoopsload.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
23 class XoopsLoad
24 {
30  protected static $map = array();
31 
40  public static function addMap(array $map)
41  {
42  XoopsLoad::$map = array_merge(XoopsLoad::$map, $map);
43 
44  return XoopsLoad::$map;
45  }
46 
52  public static function getMap()
53  {
54  return XoopsLoad::$map;
55  }
56 
65  public static function load($name, $type = "core")
66  {
67  static $loaded;
68 
69  $lname = strtolower($name);
70 
71  $type = empty($type) ? 'core' : $type;
72  if (isset($loaded[$type][$lname])) {
73  return $loaded[$type][$lname];
74  }
75 
76  if (class_exists($lname, false)) {
77  $loaded[$type][$lname] = true;
78 
79  return true;
80  }
81  switch ($type) {
82  case 'framework':
83  $isloaded = self::loadFramework($lname);
84  break;
85  case 'class':
86  case 'core':
87  $type = 'core';
88  if ($isloaded = self::loadClass($name)) {
89  break;
90  }
91  $isloaded = self::loadCore($lname);
92  break;
93  default:
94  $isloaded = self::loadModule($lname, $type);
95  break;
96  }
97  $loaded[$type][$lname] = $isloaded;
98 
99  return $loaded[$type][$lname];
100  }
101 
109  private static function loadCore($name)
110  {
111  $map = XoopsLoad::$map; //addMap(XoopsLoad::loadCoreConfig());
112  if (isset($map[$name])) {
113  //attempt loading from map
114  require $map[$name];
115  if (class_exists($name) && method_exists($name, '__autoload')) {
116  call_user_func(array($name, '__autoload'));
117  }
118 
119  return true;
120  } elseif (self::fileExists($file = \XoopsBaseConfig::get('root-path') . '/class/' . $name . '.php')) {
121  //attempt loading from file
122  include_once $file;
123  $class = 'Xoops' . ucfirst($name);
124  if (class_exists($class)) {
125  return $class;
126  } else {
127  trigger_error(
128  'Class ' . $name . ' not found in file ' . __FILE__ . 'at line ' . __LINE__,
129  E_USER_WARNING
130  );
131  }
132  }
133 
134  return false;
135  }
136 
144  private static function loadFramework($name)
145  {
146  if (!self::fileExists($file = \XoopsBaseConfig::get('root-path') . '/Frameworks/' . $name . '/xoops' . $name . '.php')) {
147  /*
148  trigger_error(
149  'File ' . str_replace(\XoopsBaseConfig::get('root-path'), '', $file)
150  . ' not found in file ' . __FILE__ . ' at line ' . __LINE__,
151  E_USER_WARNING
152  );
153  */
154  return false;
155  }
156  include $file;
157  $class = 'Xoops' . ucfirst($name);
158  if (class_exists($class, false)) {
159  return $class;
160  }
161 
162  return false;
163  }
164 
173  private static function loadModule($name, $dirname = null)
174  {
175  if (empty($dirname)) {
176  return false;
177  }
178  if (self::fileExists($file = \XoopsBaseConfig::get('root-path') . '/modules/' . $dirname . '/class/' . $name . '.php')) {
179  include $file;
180  if (class_exists(ucfirst($dirname) . ucfirst($name))) {
181  return true;
182  }
183  }
184 
185  return false;
186  }
187 
194  public static function loadCoreConfig()
195  {
197  return array(
198  'bloggerapi' => $xoops_root_path . '/class/xml/rpc/bloggerapi.php',
199  'criteria' => $xoops_root_path . '/class/criteria.php',
200  'criteriacompo' => $xoops_root_path . '/class/criteria.php',
201  'criteriaelement' => $xoops_root_path . '/class/criteria.php',
202  'formdhtmltextarea' => $xoops_root_path . '/class/xoopseditor/dhtmltextarea/dhtmltextarea.php',
203  'formtextarea' => $xoops_root_path . '/class/xoopseditor/textarea/textarea.php',
204  'metaweblogapi' => $xoops_root_path . '/class/xml/rpc/metaweblogapi.php',
205  'movabletypeapi' => $xoops_root_path . '/class/xml/rpc/movabletypeapi.php',
206  'mytextsanitizer' => $xoops_root_path . '/class/module.textsanitizer.php',
207  'mytextsanitizerextension' => $xoops_root_path . '/class/module.textsanitizer.php',
208  //'phpmailer' => $xoops_root_path . '/class/mail/phpmailer/class.phpmailer.php',
209  'rssauthorhandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php',
210  'rsscategoryhandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php',
211  'rsscommentshandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php',
212  'rsscopyrighthandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php',
213  'rssdescriptionhandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php',
214  'rssdocshandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php',
215  'rssgeneratorhandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php',
216  'rssguidhandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php',
217  'rssheighthandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php',
218  'rssimagehandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php',
219  'rssitemhandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php',
220  'rsslanguagehandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php',
221  'rsslastbuilddatehandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php',
222  'rsslinkhandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php',
223  'rssmanagingeditorhandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php',
224  'rssnamehandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php',
225  'rsspubdatehandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php',
226  'rsssourcehandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php',
227  'rsstextinputhandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php',
228  'rsstitlehandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php',
229  'rssttlhandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php',
230  'rssurlhandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php',
231  'rsswebmasterhandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php',
232  'rsswidthhandler' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php',
233  'saxparser' => $xoops_root_path . '/class/xml/saxparser.php',
234  //'smarty' => $xoops_root_path . '/smarty/Smarty.class.php',
235  'snoopy' => $xoops_root_path . '/class/snoopy.php',
236  'sqlutility' => $xoops_root_path . '/class/database/sqlutility.php',
237  'tar' => $xoops_root_path . '/class/class.tar.php',
238  'xmltaghandler' => $xoops_root_path . '/class/xml/xmltaghandler.php',
239  'xoopsadminthemefactory' => $xoops_root_path . '/class/theme.php',
240  'xoopsapi' => $xoops_root_path . '/class/xml/rpc/xoopsapi.php',
241  //'xoopsauth' => $xoops_root_path . '/class/auth/auth.php',
242  //'xoopsauthfactory' => $xoops_root_path . '/class/auth/authfactory.php',
243  //'xoopsauthads' => $xoops_root_path . '/class/auth/auth_ads.php',
244  //'xoopsauthldap' => $xoops_root_path . '/class/auth/auth_ldap.php',
245  //'xoopsauthprovisionning' => $xoops_root_path . '/class/auth/auth_provisionning.php',
246  //'xoopsauthxoops' => $xoops_root_path . '/class/auth/auth_xoops.php',
247  //'xoopsavatar' => $xoops_root_path . '/kernel/avatar.php',
248  //'xoopsavatarhandler' => $xoops_root_path . '/kernel/avatar.php',
249  //'xoopsavataruserlink' => $xoops_root_path . '/kernel/avataruserlink.php',
250  //'xoopsavataruserlinkhandler' => $xoops_root_path . '/kernel/avataruserlink.php',
251  'xoopsblock' => $xoops_root_path . '/kernel/block.php',
252  'xoopsblockform' => $xoops_root_path . '/class/xoopsform/blockform.php',
253  'xoopsblockhandler' => $xoops_root_path . '/kernel/block.php',
254  'xoopsblockmodulelink' => $xoops_root_path . '/kernel/blockmodulelink.php',
255  'xoopsblockmodulelinkhandler' => $xoops_root_path . '/kernel/blockmodulelink.php',
256  //'xoopscalendar' => $xoops_root_path . '/class/calendar/xoopscalendar.php',
257  'xoopscaptcha' => $xoops_root_path . '/class/captcha/xoopscaptcha.php',
258  'xoopscaptchamethod' => $xoops_root_path . '/class/captcha/xoopscaptchamethod.php',
259  'xoopscaptchaimage' => $xoops_root_path . '/class/captcha/image.php',
260  'xoopscaptcharecaptcha' => $xoops_root_path . '/class/captcha/recaptcha.php',
261  'xoopscaptchatext' => $xoops_root_path . '/class/captcha/text.php',
262  'xoopscaptchaimagehandler' => $xoops_root_path . '/class/captcha/image/scripts/imageclass.php',
263  //'xoopscomment' => $xoops_root_path . '/kernel/comment.php',
264  //'xoopscommenthandler' => $xoops_root_path . '/kernel/comment.php',
265  //'xoopscommentrenderer' => $xoops_root_path . '/class/commentrenderer.php',
266  //'xoopsconfigcategory' => $xoops_root_path . '/kernel/configcategory.php',
267  //'xoopsconfigcategoryhandler' => $xoops_root_path . '/kernel/configcategory.php',
268  'xoopsconfighandler' => $xoops_root_path . '/kernel/config.php',
269  'xoopsconfigitem' => $xoops_root_path . '/kernel/configitem.php',
270  'xoopsconfigitemhandler' => $xoops_root_path . '/kernel/configitem.php',
271  'xoopsconfigoption' => $xoops_root_path . '/kernel/configoption.php',
272  'xoopsconfigoptionhandler' => $xoops_root_path . '/kernel/configoption.php',
273  'xoopsdatabase' => $xoops_root_path . '/class/database/database.php',
274  //'xoopsconnection' => $xoops_root_path . '/class/database/connection.php',
275  //'xoopsquerybuilder' => $xoops_root_path . '/class/database/querybuilder.php',
276  'xoopsdatabasefactory' => $xoops_root_path . '/class/database/databasefactory.php',
277  'xoopsdatabasemanager' => $xoops_root_path . '/class/database/manager.php',
278  'xoopsdownloader' => $xoops_root_path . '/class/downloader.php',
279  'xoopsmysqldatabase' => $xoops_root_path . '/class/database/mysqldatabase.php',
280  'xoopsmysqldatabaseproxy' => $xoops_root_path . '/class/database/mysqldatabaseproxy.php',
281  'xoopsmysqldatabasesafe' => $xoops_root_path . '/class/database/mysqldatabasesafe.php',
282  'xoopsgroup' => $xoops_root_path . '/kernel/group.php',
283  'xoopsgrouphandler' => $xoops_root_path . '/kernel/group.php',
284  'xoopsgroupperm' => $xoops_root_path . '/kernel/groupperm.php',
285  'xoopsgrouppermhandler' => $xoops_root_path . '/kernel/groupperm.php',
286  //'xoopsimage' => $xoops_root_path . '/kernel/image.php',
287  //'xoopsimagecategory' => $xoops_root_path . '/kernel/imagecategory.php',
288  //'xoopsimagecategoryhandler' => $xoops_root_path . '/kernel/imagecategory.php',
289  //'xoopsimagehandler' => $xoops_root_path . '/kernel/image.php',
290  //'xoopsimageset' => $xoops_root_path . '/kernel/imageset.php',
291  //'xoopsimagesethandler' => $xoops_root_path . '/kernel/imageset.php',
292  //'xoopsimagesetimg' => $xoops_root_path . '/kernel/imagesetimg.php',
293  //'xoopsimagesetimghandler' => $xoops_root_path . '/kernel/imagesetimg.php',
294  'xoopslists' => $xoops_root_path . '/class/xoopslists.php',
295  //'xoopslocal' => $xoops_root_path . '/include/xoopslocal.php',
296  //'xoopslocalabstract' => $xoops_root_path . '/class/xoopslocal.php',
297  'xoopslogger' => $xoops_root_path . '/class/logger/xoopslogger.php',
298  'xoopseditor' => $xoops_root_path . '/class/xoopseditor/xoopseditor.php',
299  'xoopseditorhandler' => $xoops_root_path . '/class/xoopseditor/xoopseditor.php',
300  'xoopsfile' => $xoops_root_path . '/class/file/xoopsfile.php',
301  'xoopsfilehandler' => $xoops_root_path . '/class/file/file.php',
302  'xoopsfilterinput' => $xoops_root_path . '/class/xoopsfilterinput.php',
303  'xoopsfolderhandler' => $xoops_root_path . '/class/file/folder.php',
304  'xoopsform' => $xoops_root_path . '/class/xoopsform/form.php',
305  'xoopsformbutton' => $xoops_root_path . '/class/xoopsform/formbutton.php',
306  'xoopsformbuttontray' => $xoops_root_path . '/class/xoopsform/formbuttontray.php',
307  //'xoopsformcalendar' => $xoops_root_path . '/class/xoopsform/formcalendar.php',
308  'xoopsformcaptcha' => $xoops_root_path . '/class/xoopsform/formcaptcha.php',
309  'xoopsformcheckbox' => $xoops_root_path . '/class/xoopsform/formcheckbox.php',
310  'xoopsformcolorpicker' => $xoops_root_path . '/class/xoopsform/formcolorpicker.php',
311  'xoopsformcontainer' => $xoops_root_path . '/class/xoopsform/formcontainer.php',
312  'xoopsformdatetime' => $xoops_root_path . '/class/xoopsform/formdatetime.php',
313  'xoopsformdhtmltextarea' => $xoops_root_path . '/class/xoopsform/formdhtmltextarea.php',
314  'xoopsformeditor' => $xoops_root_path . '/class/xoopsform/formeditor.php',
315  'xoopsformelement' => $xoops_root_path . '/class/xoopsform/formelement.php',
316  'xoopsformelementtray' => $xoops_root_path . '/class/xoopsform/formelementtray.php',
317  'xoopsformfile' => $xoops_root_path . '/class/xoopsform/formfile.php',
318  'xoopsformhidden' => $xoops_root_path . '/class/xoopsform/formhidden.php',
319  'xoopsformhiddentoken' => $xoops_root_path . '/class/xoopsform/formhiddentoken.php',
320  'xoopsformlabel' => $xoops_root_path . '/class/xoopsform/formlabel.php',
321  'xoopsformloader' => $xoops_root_path . '/class/xoopsformloader.php',
322  'xoopsformpassword' => $xoops_root_path . '/class/xoopsform/formpassword.php',
323  'xoopsformradio' => $xoops_root_path . '/class/xoopsform/formradio.php',
324  'xoopsformradioyn' => $xoops_root_path . '/class/xoopsform/formradioyn.php',
325  'xoopsformraw' => $xoops_root_path . '/class/xoopsform/formraw.php',
326  'xoopsformselect' => $xoops_root_path . '/class/xoopsform/formselect.php',
327  'xoopsformselectcheckgroup' => $xoops_root_path . '/class/xoopsform/formselectcheckgroup.php',
328  'xoopsformselectcountry' => $xoops_root_path . '/class/xoopsform/formselectcountry.php',
329  'xoopsformselecteditor' => $xoops_root_path . '/class/xoopsform/formselecteditor.php',
330  'xoopsformselectgroup' => $xoops_root_path . '/class/xoopsform/formselectgroup.php',
331  'xoopsformselectlang' => $xoops_root_path . '/class/xoopsform/formselectlang.php',
332  'xoopsformselectlocale' => $xoops_root_path . '/class/xoopsform/formselectlocale.php',
333  'xoopsformselectmatchoption' => $xoops_root_path . '/class/xoopsform/formselectmatchoption.php',
334  'xoopsformselecttheme' => $xoops_root_path . '/class/xoopsform/formselecttheme.php',
335  'xoopsformselecttimezone' => $xoops_root_path . '/class/xoopsform/formselecttimezone.php',
336  'xoopsformselectuser' => $xoops_root_path . '/class/xoopsform/formselectuser.php',
337  'xoopsformtab' => $xoops_root_path . '/class/xoopsform/formtab.php',
338  'xoopsformtabtray' => $xoops_root_path . '/class/xoopsform/formtabtray.php',
339  'xoopsformtext' => $xoops_root_path . '/class/xoopsform/formtext.php',
340  'xoopsformtextarea' => $xoops_root_path . '/class/xoopsform/formtextarea.php',
341  'xoopsformtextdateselect' => $xoops_root_path . '/class/xoopsform/formtextdateselect.php',
342  'xoopsformmail' => $xoops_root_path . '/class/xoopsform/formmail.php',
343  'xoopsformurl' => $xoops_root_path . '/class/xoopsform/formurl.php',
344  'xoopsgroupformcheckbox' => $xoops_root_path . '/class/xoopsform/grouppermform.php',
345  'xoopsgrouppermform' => $xoops_root_path . '/class/xoopsform/grouppermform.php',
346  'xoopsguestuser' => $xoops_root_path . '/kernel/user.php',
347  'xoopsmailer' => $xoops_root_path . '/class/xoopsmailer.php',
348  'xoopsmediauploader' => $xoops_root_path . '/class/uploader.php',
349  'xoopsmemberhandler' => $xoops_root_path . '/kernel/member.php',
350  'xoopsmembership' => $xoops_root_path . '/kernel/membership.php',
351  'xoopsmembershiphandler' => $xoops_root_path . '/kernel/membership.php',
352  //'xoopsmodelfactory' => $xoops_root_path . '/class/model/xoopsmodel.php',
353  //'xoopsmoduleadmin' => $xoops_root_path . '/class/moduleadmin.php',
354  'xoopsmodule' => $xoops_root_path . '/kernel/module.php',
355  'xoopsmodulehandler' => $xoops_root_path . '/kernel/module.php',
356  'xoopsmultimailer' => $xoops_root_path . '/class/xoopsmultimailer.php',
357  //'xoopsnotification' => $xoops_root_path . '/kernel/notification.php',
358  //'xoopsnotificationhandler' => $xoops_root_path . '/kernel/notification.php',
359  'xoopsobject' => $xoops_root_path . '/kernel/object.php',
360  'xoopsobjecthandler' => $xoops_root_path . '/kernel/object.php',
361  'xoopsobjecttree' => $xoops_root_path . '/class/tree.php',
362  'xoopsonline' => $xoops_root_path . '/kernel/online.php',
363  'xoopsonlinehandler' => $xoops_root_path . '/kernel/online.php',
364  'xoopspagenav' => $xoops_root_path . '/class/pagenav.php',
365  'xoopspersistableobjecthandler' => $xoops_root_path . '/kernel/object.php',
366  'xoopspreload' => $xoops_root_path . '/class/preload.php',
367  'xoopspreloaditem' => $xoops_root_path . '/class/preload.php',
368  'xoopsprivmessage' => $xoops_root_path . '/kernel/privmessage.php',
369  'xoopsprivmessagehandler' => $xoops_root_path . '/kernel/privmessage.php',
370  'xoopsranks' => $xoops_root_path . '/kernel/ranks.php',
371  'xoopsrankshandler' => $xoops_root_path . '/kernel/ranks.php',
372  // 'xoopsregistry' => $xoops_root_path . '/class/registry.php',
373  'xoopsrequest' => $xoops_root_path . '/class/xoopsrequest.php',
374  // 'xoopssecurity' => $xoops_root_path . '/class/xoopssecurity.php',
375  // 'xoopssessionhandler' => $xoops_root_path . '/kernel/session.php',
376  'xoopssimpleform' => $xoops_root_path . '/class/xoopsform/simpleform.php',
377  'xoopstableform' => $xoops_root_path . '/class/xoopsform/tableform.php',
378  'xoopstardownloader' => $xoops_root_path . '/class/tardownloader.php',
379  'xoopstheme' => $xoops_root_path . '/class/theme.php',
380  'xoopsthemeblocksplugin' => $xoops_root_path . '/class/theme_blocks.php',
381  'xoopsthemefactory' => $xoops_root_path . '/class/theme.php',
382  'xoopsthemeform' => $xoops_root_path . '/class/xoopsform/themeform.php',
383  'xoopsthemeplugin' => $xoops_root_path . '/class/theme.php',
384  'xoopsthemesetparser' => $xoops_root_path . '/class/xml/themesetparser.php',
385  'xoopstpl' => $xoops_root_path . '/class/template.php',
386  'xoopstplfile' => $xoops_root_path . '/kernel/tplfile.php',
387  'xoopstplfilehandler' => $xoops_root_path . '/kernel/tplfile.php',
388  'xoopstplset' => $xoops_root_path . '/kernel/tplset.php',
389  'xoopstplsethandler' => $xoops_root_path . '/kernel/tplset.php',
390  'xoopsuser' => $xoops_root_path . '/kernel/user.php',
391  'xoopsuserhandler' => $xoops_root_path . '/kernel/user.php',
392  'xoopsuserutility' => $xoops_root_path . '/class/userutility.php',
393  'xoopsutility' => $xoops_root_path . '/class/utility/xoopsutility.php',
394  'xoopsxmlrpcapi' => $xoops_root_path . '/class/xml/rpc/xmlrpcapi.php',
395  'xoopsxmlrpcarray' => $xoops_root_path . '/class/xml/rpc/xmlrpctag.php',
396  'xoopsxmlrpcbase64'=> $xoops_root_path . '/class/xml/rpc/xmlrpctag.php',
397  'xoopsxmlrpcboolean' => $xoops_root_path . '/class/xml/rpc/xmlrpctag.php',
398  'xoopsxmlrpcdatetime' => $xoops_root_path . '/class/xml/rpc/xmlrpctag.php',
399  'xoopsxmlrpcdocument' => $xoops_root_path . '/class/xml/rpc/xmlrpctag.php',
400  'xoopsxmlrpcdouble' => $xoops_root_path . '/class/xml/rpc/xmlrpctag.php',
401  'xoopsxmlrpcfault' => $xoops_root_path . '/class/xml/rpc/xmlrpctag.php',
402  'xoopsxmlrpcint' => $xoops_root_path . '/class/xml/rpc/xmlrpctag.php',
403  'xoopsxmlrpcparser' => $xoops_root_path . '/class/xml/rpc/xmlrpcparser.php',
404  'xoopsxmlrpcrequest' => $xoops_root_path . '/class/xml/rpc/xmlrpctag.php',
405  'xoopsxmlrpcresponse' => $xoops_root_path . '/class/xml/rpc/xmlrpctag.php',
406  'xoopsxmlrpcstring' => $xoops_root_path . '/class/xml/rpc/xmlrpctag.php',
407  'xoopsxmlrpcstruct' => $xoops_root_path . '/class/xml/rpc/xmlrpctag.php',
408  'xoopsxmlrpctag' => $xoops_root_path . '/class/xml/rpc/xmlrpctag.php',
409  'xoopsxmlrss2parser' => $xoops_root_path . '/class/xml/rss/xmlrss2parser.php',
410  'xoopszipdownloader' => $xoops_root_path . '/class/zipdownloader.php',
411  'zipfile' => $xoops_root_path . '/class/class.zipfile.php',
412  );
413  }
414 
422  public static function loadConfig($data = null)
423  {
425  $configs = array();
426  if (is_array($data)) {
427  $configs = $data;
428  } else {
429  if (!empty($data)) {
430  $dirname = $data;
431  } elseif ($xoops->isModule()) {
432  $dirname = $xoops->module->getVar('dirname', 'n');
433  } else {
434  return false;
435  }
436  if (self::fileExists($file = \XoopsBaseConfig::get('root-path') . '/modules/' . $dirname . '/include/autoload.php')) {
437  if (!$configs = include $file) {
438  return false;
439  }
440  }
441  }
442 
443  return array_merge(XoopsLoad::loadCoreConfig(), $configs);
444  }
445 
454  public static function loadFile($file, $once = true)
455  {
456  self::securityCheck($file);
457  if (self::fileExists($file)) {
458  if ($once) {
459  include_once $file;
460  } else {
461  include $file;
462  }
463 
464  return true;
465  }
466 
467  return false;
468  }
469 
477  public static function loadClass($class)
478  {
479  if (class_exists($class, false) || interface_exists($class, false)) {
480  return true;
481  }
482 
483  $file = str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
484  if (!self::loadFile(\XoopsBaseConfig::get('lib-path') . DIRECTORY_SEPARATOR . $file)) {
485  return false;
486  }
487 
488  if (!class_exists($class, false) && !interface_exists($class, false)) {
489  return false;
490  }
491 
492  if (method_exists($class, '__autoload')) {
493  call_user_func(array($class, '__autoload'));
494  }
495 
496  return true;
497  }
498 
506  public static function fileExists($file)
507  {
508  static $included = array();
509  if (!isset($included[$file])) {
510  $included[$file] = file_exists($file);
511  }
512 
513  return $included[$file];
514  }
515 
523  protected static function securityCheck($filename)
524  {
528  if (preg_match('/[^a-z0-9\\/\\\\_.:-]/i', $filename)) {
529  exit('Security check: Illegal character in filename');
530  }
531  }
532 
540  public static function startAutoloader($path)
541  {
542  static $libPath = null;
543 
544  if ($libPath === null) {
545  $loaderPath = $path . '/vendor/autoload.php';
546  if (self::fileExists($loaderPath)) {
547  $libPath = $path;
548  include $loaderPath;
549  }
551  spl_autoload_register(array('XoopsLoad', 'load'));
552  }
553  }
554 }
$path
Definition: execute.php:31
static startAutoloader($path)
Definition: xoopsload.php:540
static getInstance()
Definition: Xoops.php:160
static loadConfig($data=null)
Definition: xoopsload.php:422
if(!isset($xoops->paths[$path_type])) if($path_type== 'var') $file
Definition: browse.php:55
static securityCheck($filename)
Definition: xoopsload.php:523
static $map
Definition: xoopsload.php:30
static loadCore($name)
Definition: xoopsload.php:109
exit
Definition: browse.php:104
defined('DS') or define('DS' DIRECTORY_SEPARATOR
Definition: common.php:41
static getMap()
Definition: xoopsload.php:52
$xoops
Definition: admin.php:25
if(DIRECTORY_SEPARATOR!="/") $xoops_root_path
Definition: config.php:7
static fileExists($file)
Definition: xoopsload.php:506
static loadClass($class)
Definition: xoopsload.php:477
static loadModule($name, $dirname=null)
Definition: xoopsload.php:173
static get($name)
$configs
Definition: config.php:27
static load($name, $type="core")
Definition: xoopsload.php:65
static loadCoreConfig()
Definition: xoopsload.php:194
$type
Definition: misc.php:33
$dirname
Definition: backend.php:38
static loadFile($file, $once=true)
Definition: xoopsload.php:454
static loadFramework($name)
Definition: xoopsload.php:144
static addMap(array $map)
Definition: xoopsload.php:40