Subversion Repositories oidplus

Rev

Rev 930 | Rev 1068 | 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. require_once __DIR__ . '/functions.inc.php'; // Required for _L()
  23.  
  24. if (version_compare(PHP_VERSION, '7.0.0') < 0) {
  25.         // More information about the required PHP version:
  26.         // doc/developer_notes/php7_compat.txt
  27.         echo '<!DOCTYPE HTML>';
  28.         echo '<html><head><title>'._L('OIDplus error').'</title></head><body>';
  29.         echo '<h1>'._L('OIDplus error').'</h1>';
  30.         echo '<p>'._L('OIDplus requires at least PHP version %1! You are currently using version %2','7.0',PHP_VERSION).'</p>'."\n";
  31.         echo '</body></html>';
  32.         die();
  33. }
  34.  
  35. require_once __DIR__ . '/../vendor/autoload.php';
  36.  
  37. include_once __DIR__ . '/../vendor/danielmarschall/php_utils/openssl_supplement.inc.php';
  38. include_once __DIR__ . '/../vendor/danielmarschall/php_utils/gmp_supplement.inc.php';
  39. include_once __DIR__ . '/../vendor/symfony/polyfill-mbstring/bootstrap.php';
  40. include_once __DIR__ . '/../vendor/danielmarschall/php_utils/simplexml_supplement.inc.php';
  41.  
  42. require_once __DIR__ . '/oidplus_dependency.inc.php';
  43.  
  44. $missing_dependencies = oidplus_get_missing_dependencies();
  45.  
  46. if (count($missing_dependencies) >= 1) {
  47.         echo '<!DOCTYPE HTML>';
  48.         echo '<html><head><title>'._L('OIDplus error').'</title></head><body>';
  49.         echo '<h1>'._L('OIDplus error').'</h1>';
  50.         echo '<p>'._L('The following PHP extensions need to be installed in order to run OIDplus:').'</p>';
  51.         echo '<ul>';
  52.         foreach ($missing_dependencies as $dependency) {
  53.                 echo '<li>'.$dependency.'<br><br></li>';
  54.         }
  55.         echo '</ul>';
  56.         echo '</body></html>';
  57.         die();
  58. }
  59.  
  60. unset($missing_dependencies);
  61.  
  62. // Now we can continue!
  63.  
  64. require_once __DIR__ . '/../vendor/danielmarschall/php_utils/oid_utils.inc.php';
  65. require_once __DIR__ . '/../vendor/danielmarschall/php_utils/xml_utils.inc.php';
  66. require_once __DIR__ . '/../vendor/danielmarschall/uuid_mac_utils/includes/uuid_utils.inc.php';
  67. require_once __DIR__ . '/../vendor/danielmarschall/php_utils/color_utils.inc.php';
  68. require_once __DIR__ . '/../vendor/danielmarschall/php_utils/ipv4_functions.inc.php';
  69. require_once __DIR__ . '/../vendor/danielmarschall/php_utils/ipv6_functions.inc.php';
  70. require_once __DIR__ . '/../vendor/danielmarschall/php_utils/anti_xss.inc.php';
  71. include_once __DIR__ . '/../vendor/danielmarschall/php_utils/git_utils.inc.php';
  72. include_once __DIR__ . '/../vendor/danielmarschall/php_utils/svn_utils.inc.php';
  73. include_once __DIR__ . '/../vendor/danielmarschall/php_utils/aid_decoder.inc.php';
  74. include_once __DIR__ . '/../vendor/danielmarschall/php_utils/misc_functions.inc.php';
  75.  
  76. // ---
  77.  
  78. spl_autoload_register(function ($class_name) {
  79.         static $class_refs = null;
  80.  
  81.         // We only load based on the last element of the class name (ignore namespace)
  82.         // If there are multiple classes matching that name we just include all class files
  83.         $path = explode('\\',$class_name);
  84.         $class_name = end($path);
  85.  
  86.         if (is_null($class_refs)) {
  87.                 $valid_plugin_folders = array(
  88.                         'adminPages',
  89.                         'auth',
  90.                         'database',
  91.                         'design',
  92.                         'language',
  93.                         'logger',
  94.                         'objectTypes',
  95.                         'publicPages',
  96.                         'raPages',
  97.                         'sqlSlang',
  98.                         'captcha'
  99.                 );
  100.  
  101.                 $func = function(&$class_refs, $class_files, $namespace='') {
  102.                         foreach ($class_files as $filename) {
  103.                                 $cn = strtolower(basename($filename));
  104.                                 $cn = preg_replace('@(\\.class){0,1}\\.phps{0,1}$@', '', $cn);
  105.                                 if (!empty($namespace)) {
  106.                                         if (substr($namespace,-1,1) !== '\\') $namespace .= '\\';
  107.                                         $cn = strtolower($namespace) . $cn;
  108.                                 }
  109.                                 if (!isset($class_refs[$cn])) {
  110.                                         $class_refs[$cn] = array($filename);
  111.                                 } else {
  112.                                         $class_refs[$cn][] = $filename;;
  113.                                 }
  114.                         }
  115.                 };
  116.  
  117.                 $class_files = array();
  118.  
  119.                 // Global namespace / OIDplus
  120.                 // (the last has the highest priority)
  121.                 foreach ($valid_plugin_folders as $folder) {
  122.                         $class_files = array_merge($class_files, glob(__DIR__ . '/../plugins/'.'*'.'/'.$folder.'/'.'*'.'/'.'*'.'.class.php'));
  123.                 }
  124.                 $class_files = array_merge($class_files, glob(__DIR__ . '/classes/'.'*'.'.class.php'));
  125.                 $class_files = array_merge($class_files, glob(__DIR__ . '/../vendor/danielmarschall/fileformats/'.'*'.'.class.php'));
  126.                 $class_files = array_merge($class_files, glob(__DIR__ . '/../vendor/danielmarschall/php_utils/'.'*'.'.class.php'));
  127.                 $class_files = array_merge($class_files, glob(__DIR__ . '/../vendor/danielmarschall/oidconverter/php/'.'*'.'.class.phps'));
  128.                 $func($class_refs, $class_files);
  129.         }
  130.  
  131.         $class_name = strtolower($class_name);
  132.         if (isset($class_refs[$class_name])) {
  133.                 foreach ($class_refs[$class_name] as $inc) {
  134.                         require $inc;
  135.                 }
  136.                 unset($class_refs[$class_name]); // this emulates a "require_once" and is faster
  137.         }
  138. });
  139.