Subversion Repositories oidplus

Rev

Rev 480 | Rev 597 | 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 - 2021 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. function oidplus_get_missing_dependencies() {
  21.         $missing_dependencies = array();
  22.  
  23.         if (!function_exists('gmp_init')) {
  24.                 // GMP Required for includes/uuid_functions.inc.php
  25.                 //                  includes/ipv6_functions.inc.php
  26.                 //                  plugins/adminPages/400_oidinfo_export/oidinfo_api.inc.php (if GMP is not available, BC will be used)
  27.                 // Note that gmp_supplement.inc.php will implement the GMP functions if BCMath is present.
  28.                 // This is the reason why we use function_exists('gmp_init') instead of extension_loaded('gmp')
  29.                 if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
  30.                         $install_hint1 = _L('On Windows, install it by enabling the line %1 in your PHP.ini',
  31.                                 'extension=php_gmp.dll');
  32.                         $install_hint2 = _L('On Windows, it should be installed by default');
  33.                 } else {
  34.                         $install_hint1 = _L('On Linux, install it by running e.g. %1, and then restart your webserver service, e.g. by running %2',
  35.                                 '<code>sudo apt-get update && sudo apt-get install php-gmp</code>',
  36.                                 '<code>sudo service apache2 restart</code>');
  37.                         $install_hint2 = _L('On Linux, install it by running e.g. %1, and then restart your webserver service, e.g. by running %2',
  38.                                 '<code>sudo apt-get update && sudo apt-get install php-bcmath</code>',
  39.                                 '<code>sudo service apache2 restart</code>');
  40.                 }
  41.                 $missing_dependencies[] = 'GMP ('.$install_hint1.')'.
  42.                                           '<br>'._L('or alternatively').'<br>' .
  43.                                           'BCMath ('.$install_hint2.')';
  44.         }
  45.  
  46.         if (!function_exists('mb_substr')) {
  47.                 // Required for includes/classes/OIDplusSessionHandler.class.php
  48.                 //              includes/oid_utils.inc.php
  49.                 //              3p/minify/path-converter/Converter.php
  50.                 //              3p/0xbb/Sha3.class.php
  51.                 // Note that mbstring_supplement.inc.php will implement the MBString functions if iconv is present.
  52.                 // This is the reason why we use function_exists('mb_substr') instead of extension_loaded('mbstring')
  53.                 if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
  54.                         $install_hint1 = _L('On Windows, install it by enabling the line %1 in your PHP.ini',
  55.                                 'extension=php_mbstring.dll');
  56.                         $install_hint2 = _L('On Windows, it should be installed by default');
  57.                 } else {
  58.                         $install_hint1 = _L('On Linux, install it by running e.g. %1, and then restart your webserver service, e.g. by running %2',
  59.                                 '<code>sudo apt-get update && sudo apt-get install php-mbstring</code>',
  60.                                 '<code>sudo service apache2 restart</code>');
  61.                         $install_hint2 = _L('On Linux, it should be installed by default');
  62.                 }
  63.                 $missing_dependencies[] = 'MBString ('.$install_hint1.')'.
  64.                                           '<br>'._L('or alternatively').'<br>' .
  65.                                           'iconv ('.$install_hint2.')';
  66.         }
  67.  
  68.         if (!function_exists('simplexml_load_file')) {
  69.                 // Required for includes/classes/OIDplusPluginManifest.class.php (Plugins)
  70.                 //              includes/classes/OIDplus.class.php (Translation)
  71.                 //              plugins/adminPages/400_oidinfo_export/OIDplusPageAdminOIDInfoExport.class.php (Import OID from oid-info.com)
  72.                 //              dev/translation/*.phps (only for developers)
  73.                 // Note: This should not happen because of simplexml_supplement.inc.php
  74.                 if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
  75.                         $install_hint = _L('On Windows, it should be installed by default');
  76.                 } else {
  77.                         $install_hint = _L('On Linux, install it by running e.g. %1, and then restart your webserver service, e.g. by running %2',
  78.                                 '<code>sudo apt-get update && sudo apt-get install php-xml</code>',
  79.                                 '<code>sudo service apache2 restart</code>');
  80.                 }
  81.                 $missing_dependencies[] = 'SimpleXML ('.$install_hint.')';
  82.         }
  83.  
  84.         return $missing_dependencies;
  85. }
  86.