Subversion Repositories oidplus

Rev

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