Rev 726 | Rev 1116 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
463 | daniel-mar | 1 | <?php |
2 | |||
3 | /* |
||
4 | * OIDplus 2.0 |
||
1069 | daniel-mar | 5 | * Copyright 2019 - 2022 Daniel Marschall, ViaThinkSoft |
463 | daniel-mar | 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 | |||
1069 | daniel-mar | 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 | |||
463 | daniel-mar | 23 | function oidplus_get_missing_dependencies() { |
24 | $missing_dependencies = array(); |
||
25 | |||
723 | daniel-mar | 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 | |||
722 | daniel-mar | 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 | |||
463 | daniel-mar | 63 | if (!function_exists('gmp_init')) { |
64 | // GMP Required for includes/uuid_functions.inc.php |
||
65 | // includes/ipv6_functions.inc.php |
||
635 | daniel-mar | 66 | // plugins/viathinksoft/adminPages/400_oidinfo_export/oidinfo_api.inc.php (if GMP is not available, BC will be used) |
724 | daniel-mar | 67 | // Note that vendor/danielmarschall/php_utils/gmp_supplement.inc.php will implement the GMP functions if BCMath is present. |
463 | daniel-mar | 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') { |
||
1069 | daniel-mar | 70 | $install_hint1 = sprintf('On Windows, install it by enabling the line %s in your PHP.ini', |
463 | daniel-mar | 71 | 'extension=php_gmp.dll'); |
1069 | daniel-mar | 72 | $install_hint2 = sprintf('On Windows, it should be installed by default'); |
463 | daniel-mar | 73 | } else { |
1069 | daniel-mar | 74 | $install_hint1 = sprintf('On Linux, install it by running e.g. %s, and then restart your webserver service, e.g. by running %s', |
463 | daniel-mar | 75 | '<code>sudo apt-get update && sudo apt-get install php-gmp</code>', |
76 | '<code>sudo service apache2 restart</code>'); |
||
1069 | daniel-mar | 77 | $install_hint2 = sprintf('On Linux, install it by running e.g. %s, and then restart your webserver service, e.g. by running %s', |
463 | daniel-mar | 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.')'. |
||
1069 | daniel-mar | 82 | '<br>'.sprintf('or alternatively').'<br>' . |
463 | daniel-mar | 83 | 'BCMath ('.$install_hint2.')'; |
84 | } |
||
85 | |||
725 | daniel-mar | 86 | if (!extension_loaded('mbstring') && !extension_loaded('iconv')) { |
463 | daniel-mar | 87 | // Required for includes/classes/OIDplusSessionHandler.class.php |
88 | // includes/oid_utils.inc.php |
||
597 | daniel-mar | 89 | // vendor/matthiasmullie/path-converter/src/Converter.php |
90 | // vendor/n-other/php-sha3/src/Sha3.php |
||
725 | daniel-mar | 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') |
||
463 | daniel-mar | 94 | if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
1069 | daniel-mar | 95 | $install_hint1 = sprintf('On Windows, install it by enabling the line %s in your PHP.ini', |
463 | daniel-mar | 96 | 'extension=php_mbstring.dll'); |
1069 | daniel-mar | 97 | $install_hint2 = sprintf('On Windows, it should be installed by default'); |
463 | daniel-mar | 98 | } else { |
1069 | daniel-mar | 99 | $install_hint1 = sprintf('On Linux, install it by running e.g. %s, and then restart your webserver service, e.g. by running %s', |
463 | daniel-mar | 100 | '<code>sudo apt-get update && sudo apt-get install php-mbstring</code>', |
101 | '<code>sudo service apache2 restart</code>'); |
||
1069 | daniel-mar | 102 | $install_hint2 = sprintf('On Linux, it should be installed by default'); // Alpine Linux: apk add php-iconv |
463 | daniel-mar | 103 | } |
467 | daniel-mar | 104 | $missing_dependencies[] = 'MBString ('.$install_hint1.')'. |
1069 | daniel-mar | 105 | '<br>'.sprintf('or alternatively').'<br>' . |
467 | daniel-mar | 106 | 'iconv ('.$install_hint2.')'; |
463 | daniel-mar | 107 | } |
108 | |||
109 | if (!function_exists('simplexml_load_file')) { |
||
468 | daniel-mar | 110 | // Required for includes/classes/OIDplusPluginManifest.class.php (Plugins) |
463 | daniel-mar | 111 | // includes/classes/OIDplus.class.php (Translation) |
635 | daniel-mar | 112 | // plugins/viathinksoft/adminPages/400_oidinfo_export/OIDplusPageAdminOIDInfoExport.class.php (Import OID from oid-info.com) |
468 | daniel-mar | 113 | // dev/translation/*.phps (only for developers) |
724 | daniel-mar | 114 | // Note: This should not happen because of vendor/danielmarschall/php_utils/simplexml_supplement.inc.php |
463 | daniel-mar | 115 | if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
1069 | daniel-mar | 116 | $install_hint = sprintf('On Windows, it should be installed by default'); |
463 | daniel-mar | 117 | } else { |
1069 | daniel-mar | 118 | $install_hint = sprintf('On Linux, install it by running e.g. %s, and then restart your webserver service, e.g. by running %s', |
463 | daniel-mar | 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 | } |