Subversion Repositories oidplus

Rev

Rev 926 | Rev 1050 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. <?php
  2.  
  3. /*
  4.  * OIDplus 2.0
  5.  * Copyright 2019 - 2022 Daniel Marschall, ViaThinkSoft
  6.  *
  7.  * Licensed under the Apache License, Version 2.0 (the "License");
  8.  * you may not use this file except in compliance with the License.
  9.  * You may obtain a copy of the License at
  10.  *
  11.  *     http://www.apache.org/licenses/LICENSE-2.0
  12.  *
  13.  * Unless required by applicable law or agreed to in writing, software
  14.  * distributed under the License is distributed on an "AS IS" BASIS,
  15.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16.  * See the License for the specific language governing permissions and
  17.  * limitations under the License.
  18.  */
  19.  
  20. // Before we do ANYTHING, check for dependencies! Do not include anything (except the GMP supplement) yet.
  21.  
  22. define('INSIDE_OIDPLUS', true);
  23.  
  24. require_once __DIR__ . '/functions.inc.php'; // Required for _L()
  25.  
  26. if (version_compare(PHP_VERSION, '7.0.0') < 0) {
  27.         // More information about the required PHP version:
  28.         // doc/developer_notes/php7_compat.txt
  29.         echo '<!DOCTYPE HTML>';
  30.         echo '<html><head><title>'._L('OIDplus error').'</title></head><body>';
  31.         echo '<h1>'._L('OIDplus error').'</h1>';
  32.         echo '<p>'._L('OIDplus requires at least PHP version %1! You are currently using version %2','7.0',PHP_VERSION).'</p>'."\n";
  33.         echo '</body></html>';
  34.         die();
  35. }
  36.  
  37. require_once __DIR__ . '/../vendor/autoload.php';
  38.  
  39. include_once __DIR__ . '/../vendor/danielmarschall/php_utils/openssl_supplement.inc.php';
  40. include_once __DIR__ . '/../vendor/danielmarschall/php_utils/gmp_supplement.inc.php';
  41. include_once __DIR__ . '/../vendor/symfony/polyfill-mbstring/bootstrap.php';
  42. include_once __DIR__ . '/../vendor/danielmarschall/php_utils/simplexml_supplement.inc.php';
  43.  
  44. require_once __DIR__ . '/oidplus_dependency.inc.php';
  45.  
  46. $missing_dependencies = oidplus_get_missing_dependencies();
  47.  
  48. if (count($missing_dependencies) >= 1) {
  49.         echo '<!DOCTYPE HTML>';
  50.         echo '<html><head><title>'._L('OIDplus error').'</title></head><body>';
  51.         echo '<h1>'._L('OIDplus error').'</h1>';
  52.         echo '<p>'._L('The following PHP extensions need to be installed in order to run OIDplus:').'</p>';
  53.         echo '<ul>';
  54.         foreach ($missing_dependencies as $dependency) {
  55.                 echo '<li>'.$dependency.'<br><br></li>';
  56.         }
  57.         echo '</ul>';
  58.         echo '</body></html>';
  59.         die();
  60. }
  61.  
  62. unset($missing_dependencies);
  63.  
  64. // Now we can continue!
  65.  
  66. require_once __DIR__ . '/../vendor/danielmarschall/php_utils/oid_utils.inc.php';
  67. require_once __DIR__ . '/../vendor/danielmarschall/php_utils/xml_utils.inc.php';
  68. require_once __DIR__ . '/../vendor/danielmarschall/uuid_mac_utils/includes/uuid_utils.inc.php';
  69. require_once __DIR__ . '/../vendor/danielmarschall/php_utils/color_utils.inc.php';
  70. require_once __DIR__ . '/../vendor/danielmarschall/php_utils/ipv4_functions.inc.php';
  71. require_once __DIR__ . '/../vendor/danielmarschall/php_utils/ipv6_functions.inc.php';
  72. require_once __DIR__ . '/../vendor/danielmarschall/php_utils/anti_xss.inc.php';
  73. include_once __DIR__ . '/../vendor/danielmarschall/php_utils/git_utils.inc.php';
  74. include_once __DIR__ . '/../vendor/danielmarschall/php_utils/svn_utils.inc.php';
  75. include_once __DIR__ . '/../vendor/danielmarschall/php_utils/aid_decoder.inc.php';
  76. include_once __DIR__ . '/../vendor/danielmarschall/php_utils/misc_functions.inc.php';
  77.  
  78. // ---
  79.  
  80. spl_autoload_register(function ($class_name) {
  81.         static $class_refs = null;
  82.  
  83.         if (is_null($class_refs)) {
  84.                 $valid_plugin_folders = array(
  85.                         'adminPages',
  86.                         'auth',
  87.                         'database',
  88.                         'design',
  89.                         'language',
  90.                         'logger',
  91.                         'objectTypes',
  92.                         'publicPages',
  93.                         'raPages',
  94.                         'sqlSlang',
  95.                         'captcha'
  96.                 );
  97.  
  98.                 $func = function(&$class_refs, $class_files, $namespace='') {
  99.                         foreach ($class_files as $filename) {
  100.                                 $cn = strtolower(basename($filename));
  101.                                 $cn = preg_replace('@(\\.class){0,1}\\.phps{0,1}$@', '', $cn);
  102.                                 if (!empty($namespace)) {
  103.                                         if (substr($namespace,-1,1) !== '\\') $namespace .= '\\';
  104.                                         $cn = strtolower($namespace) . $cn;
  105.                                 }
  106.                                 if (!isset($class_refs[$cn])) {
  107.                                         $class_refs[$cn] = $filename;
  108.                                 }
  109.                         }
  110.                 };
  111.  
  112.                 $class_files = array();
  113.  
  114.                 // Global namespace / OIDplus
  115.                 // (the last has the highest priority)
  116.                 foreach ($valid_plugin_folders as $folder) {
  117.                         $class_files = array_merge($class_files, glob(__DIR__ . '/../plugins/'.'*'.'/'.$folder.'/'.'*'.'/'.'*'.'.class.php'));
  118.                 }
  119.                 $class_files = array_merge($class_files, glob(__DIR__ . '/classes/'.'*'.'.class.php'));
  120.                 $class_files = array_merge($class_files, glob(__DIR__ . '/../vendor/danielmarschall/fileformats/'.'*'.'.class.php'));
  121.                 $class_files = array_merge($class_files, glob(__DIR__ . '/../vendor/danielmarschall/php_utils/'.'*'.'.class.php'));
  122.                 $class_files = array_merge($class_files, glob(__DIR__ . '/../vendor/danielmarschall/oidconverter/php/'.'*'.'.class.phps'));
  123.                 $func($class_refs, $class_files);
  124.         }
  125.  
  126.         $class_name = strtolower($class_name);
  127.         if (isset($class_refs[$class_name])) {
  128.                 require $class_refs[$class_name];
  129.                 unset($class_refs[$class_name]); // this emulates a "require_once" and is faster
  130.         }
  131. });
  132.