Subversion Repositories oidplus

Rev

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