Subversion Repositories oidplus

Rev

Rev 1069 | Rev 1130 | 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. // Note that there are no translations _L() because if we get an error at this
  21. // stage, then we have no language plugins anyways.
  22.  
  23. function oidplus_get_missing_dependencies() {
  24.         $missing_dependencies = array();
  25.  
  26.         if (!extension_loaded('standard')) {
  27.                 $missing_dependencies[] = 'standard';
  28.         }
  29.  
  30.         if (!extension_loaded('Core')) {
  31.                 $missing_dependencies[] = 'Core';
  32.         }
  33.  
  34.         if (!extension_loaded('SPL')) {
  35.                 $missing_dependencies[] = 'SPL';
  36.         }
  37.  
  38.         if (!extension_loaded('session')) {
  39.                 // Alpine Linux: apk add php-session
  40.                 $missing_dependencies[] = 'session';
  41.         }
  42.  
  43.         if (!extension_loaded('json')) {
  44.                 $missing_dependencies[] = 'json';
  45.         }
  46.  
  47.         if (!extension_loaded('date')) {
  48.                 $missing_dependencies[] = 'date';
  49.         }
  50.  
  51.         if (!extension_loaded('filter')) {
  52.                 $missing_dependencies[] = 'filter';
  53.         }
  54.  
  55.         if (!extension_loaded('hash')) {
  56.                 $missing_dependencies[] = 'hash';
  57.         }
  58.  
  59.         if (!extension_loaded('pcre')) {
  60.                 $missing_dependencies[] = 'pcre';
  61.         }
  62.  
  63.         if (!function_exists('gmp_init')) {
  64.                 // GMP Required for includes/uuid_functions.inc.php
  65.                 //                  includes/ipv6_functions.inc.php
  66.                 //                  plugins/viathinksoft/adminPages/400_oidinfo_export/oidinfo_api.inc.php (if GMP is not available, BC will be used)
  67.                 // Note that vendor/danielmarschall/php_utils/gmp_supplement.inc.php will implement the GMP functions if BCMath is present.
  68.                 // This is the reason why we use function_exists('gmp_init') instead of extension_loaded('gmp')
  69.                 if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
  70.                         $install_hint1 = sprintf('On Windows, install it by enabling the line %s in your PHP.ini',
  71.                                 'extension=php_gmp.dll');
  72.                         $install_hint2 = 'On Windows, it should be installed by default';
  73.                 } else {
  74.                         $install_hint1 = sprintf('On Linux, install it by running e.g. %s, and then restart your webserver service, e.g. by running %s',
  75.                                 '<code>sudo apt-get update && sudo apt-get install php-gmp</code>',
  76.                                 '<code>sudo service apache2 restart</code>');
  77.                         $install_hint2 = sprintf('On Linux, install it by running e.g. %s, and then restart your webserver service, e.g. by running %s',
  78.                                 '<code>sudo apt-get update && sudo apt-get install php-bcmath</code>',
  79.                                 '<code>sudo service apache2 restart</code>');
  80.                 }
  81.                 $missing_dependencies[] = 'GMP ('.$install_hint1.')'.
  82.                                           '<br>or alternatively<br>' .
  83.                                           'BCMath ('.$install_hint2.')';
  84.         }
  85.  
  86.         if (!extension_loaded('mbstring') && !extension_loaded('iconv')) {
  87.                 // Required for includes/classes/OIDplusSessionHandler.class.php
  88.                 //              includes/oid_utils.inc.php
  89.                 //              vendor/matthiasmullie/path-converter/src/Converter.php
  90.                 //              vendor/n-other/php-sha3/src/Sha3.php
  91.                 //              includes/functions.inc.php (convert_to_utf8_no_bom)
  92.                 // Note that vendor/symfony/polyfill-mbstring/ will always implement the MBString functions, but they only work if iconv is present.
  93.                 // This is the reason why we use extension_loaded('mbstring') instead of function_exists('mb_substr')
  94.                 if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
  95.                         $install_hint1 = sprintf('On Windows, install it by enabling the line %s in your PHP.ini',
  96.                                 'extension=php_mbstring.dll');
  97.                         $install_hint2 = 'On Windows, it should be installed by default';
  98.                 } else {
  99.                         $install_hint1 = sprintf('On Linux, install it by running e.g. %s, and then restart your webserver service, e.g. by running %s',
  100.                                 '<code>sudo apt-get update && sudo apt-get install php-mbstring</code>',
  101.                                 '<code>sudo service apache2 restart</code>');
  102.                         $install_hint2 = 'On Linux, it should be installed by default'; // Alpine Linux: apk add php-iconv
  103.                 }
  104.                 $missing_dependencies[] = 'MBString ('.$install_hint1.')'.
  105.                                           '<br>or alternatively<br>' .
  106.                                           'iconv ('.$install_hint2.')';
  107.         }
  108.  
  109.         if (!function_exists('simplexml_load_file')) {
  110.                 // Required for includes/classes/OIDplusPluginManifest.class.php (Plugins)
  111.                 //              includes/classes/OIDplus.class.php (Translation)
  112.                 //              plugins/viathinksoft/adminPages/400_oidinfo_export/OIDplusPageAdminOIDInfoExport.class.php (Import OID from oid-info.com)
  113.                 //              dev/translation/*.phps (only for developers)
  114.                 // Note: This should not happen because of vendor/danielmarschall/php_utils/simplexml_supplement.inc.php
  115.                 if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
  116.                         $install_hint = 'On Windows, it should be installed by default';
  117.                 } else {
  118.                         $install_hint = sprintf('On Linux, install it by running e.g. %s, and then restart your webserver service, e.g. by running %s',
  119.                                 '<code>sudo apt-get update && sudo apt-get install php-xml</code>',
  120.                                 '<code>sudo service apache2 restart</code>');
  121.                 }
  122.                 $missing_dependencies[] = 'SimpleXML ('.$install_hint.')';
  123.         }
  124.  
  125.         return $missing_dependencies;
  126. }
  127.