Subversion Repositories oidplus

Rev

Rev 1301 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1301 Rev 1305
1
<?php
1
<?php
2
 
2
 
3
/*
3
/*
4
 * OIDplus 2.0
4
 * OIDplus 2.0
5
 * Copyright 2019 - 2022 Daniel Marschall, ViaThinkSoft
5
 * Copyright 2019 - 2022 Daniel Marschall, ViaThinkSoft
6
 *
6
 *
7
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with 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
9
 * You may obtain a copy of the License at
10
 *
10
 *
11
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 *
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
17
 * limitations under the License.
18
 */
18
 */
19
 
19
 
20
// Note that there are no translations _L() because if we get an error at this
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.
21
// stage, then we have no language plugins anyways.
22
 
22
 
23
/**
23
/**
24
 * @return array
24
 * @return array
25
 */
25
 */
26
function oidplus_get_missing_dependencies(): array {
26
function oidplus_get_missing_dependencies(): array {
27
        $missing_dependencies = array();
27
        $missing_dependencies = array();
28
 
28
 
29
        if (!extension_loaded('standard')) {
29
        if (!extension_loaded('standard')) {
30
                $missing_dependencies[] = 'standard';
30
                $missing_dependencies[] = 'standard';
31
        }
31
        }
32
 
32
 
33
        if (!extension_loaded('Core')) {
33
        if (!extension_loaded('Core')) {
34
                $missing_dependencies[] = 'Core';
34
                $missing_dependencies[] = 'Core';
35
        }
35
        }
36
 
36
 
37
        if (!extension_loaded('SPL')) {
37
        if (!extension_loaded('SPL')) {
38
                $missing_dependencies[] = 'SPL';
38
                $missing_dependencies[] = 'SPL';
39
        }
39
        }
40
 
40
 
41
        if (!extension_loaded('session')) {
41
        if (!extension_loaded('session')) {
42
                // Alpine Linux: apk add php-session
42
                // Alpine Linux: apk add php-session
43
                $missing_dependencies[] = 'session';
43
                $missing_dependencies[] = 'session';
44
        }
44
        }
45
 
45
 
46
        if (!extension_loaded('json')) {
46
        if (!extension_loaded('json')) {
47
                $missing_dependencies[] = 'json';
47
                $missing_dependencies[] = 'json';
48
        }
48
        }
49
 
49
 
50
        if (!extension_loaded('date')) {
50
        if (!extension_loaded('date')) {
51
                $missing_dependencies[] = 'date';
51
                $missing_dependencies[] = 'date';
52
        }
52
        }
53
 
53
 
54
        if (!extension_loaded('filter')) {
54
        if (!extension_loaded('filter')) {
55
                $missing_dependencies[] = 'filter';
55
                $missing_dependencies[] = 'filter';
56
        }
56
        }
57
 
57
 
58
        if (!extension_loaded('hash')) {
58
        if (!extension_loaded('hash')) {
59
                $missing_dependencies[] = 'hash';
59
                $missing_dependencies[] = 'hash';
60
        }
60
        }
61
 
61
 
62
        if (!extension_loaded('pcre')) {
62
        if (!extension_loaded('pcre')) {
63
                $missing_dependencies[] = 'pcre';
63
                $missing_dependencies[] = 'pcre';
64
        }
64
        }
65
 
65
 
66
        if (!function_exists('gmp_init')) {
66
        if (!function_exists('gmp_init')) {
67
                // GMP Required for includes/uuid_functions.inc.php
67
                // GMP Required for includes/uuid_functions.inc.php
68
                //                  includes/ipv6_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)
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.
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')
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') {
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',
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');
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';
75
                        $install_hint2 = 'On Windows, it should be installed by default';
76
                } else {
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',
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>',
78
                                '<code>sudo apt-get update && sudo apt-get install php-gmp</code>',
79
                                '<code>sudo service apache2 restart</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',
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>',
81
                                '<code>sudo apt-get update && sudo apt-get install php-bcmath</code>',
82
                                '<code>sudo service apache2 restart</code>');
82
                                '<code>sudo service apache2 restart</code>');
83
                }
83
                }
84
                $missing_dependencies[] = 'GMP ('.$install_hint1.')'.
84
                $missing_dependencies[] = 'GMP ('.$install_hint1.')'.
85
                                          '<br>or alternatively<br>' .
85
                                          '<br>or alternatively<br>' .
86
                                          'BCMath ('.$install_hint2.')';
86
                                          'BCMath ('.$install_hint2.')';
87
        }
87
        }
88
 
88
 
89
        if (!extension_loaded('mbstring') && !extension_loaded('iconv')) {
89
        if (!extension_loaded('mbstring') && !extension_loaded('iconv')) {
90
                // Required for includes/classes/OIDplusAuthContentStoreSession.class.php
-
 
91
                //              includes/oid_utils.inc.php
90
                // Required for includes/oid_utils.inc.php
92
                //              vendor/matthiasmullie/path-converter/src/Converter.php
91
                //              vendor/matthiasmullie/path-converter/src/Converter.php
93
                //              vendor/n-other/php-sha3/src/Sha3.php
92
                //              vendor/n-other/php-sha3/src/Sha3.php
94
                //              includes/functions.inc.php (convert_to_utf8_no_bom)
93
                //              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.
94
                // 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')
95
                // 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') {
96
                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',
97
                        $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');
98
                                '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';
99
                        $install_hint2 = 'On Windows, it should be installed by default';
101
                } else {
100
                } 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',
101
                        $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>',
102
                                '<code>sudo apt-get update && sudo apt-get install php-mbstring</code>',
104
                                '<code>sudo service apache2 restart</code>');
103
                                '<code>sudo service apache2 restart</code>');
105
                        $install_hint2 = 'On Linux, it should be installed by default'; // Alpine Linux: apk add php-iconv
104
                        $install_hint2 = 'On Linux, it should be installed by default'; // Alpine Linux: apk add php-iconv
106
                }
105
                }
107
                $missing_dependencies[] = 'MBString ('.$install_hint1.')'.
106
                $missing_dependencies[] = 'MBString ('.$install_hint1.')'.
108
                                          '<br>or alternatively<br>' .
107
                                          '<br>or alternatively<br>' .
109
                                          'iconv ('.$install_hint2.')';
108
                                          'iconv ('.$install_hint2.')';
110
        }
109
        }
111
 
110
 
112
        if (!function_exists('simplexml_load_file')) {
111
        if (!function_exists('simplexml_load_file')) {
113
                // Required for includes/classes/OIDplusPluginManifest.class.php (Plugins)
112
                // Required for includes/classes/OIDplusPluginManifest.class.php (Plugins)
114
                //              includes/classes/OIDplus.class.php (Translation)
113
                //              includes/classes/OIDplus.class.php (Translation)
115
                //              plugins/viathinksoft/adminPages/400_oidinfo_export/OIDplusPageAdminOIDInfoExport.class.php (Import OID from oid-info.com)
114
                //              plugins/viathinksoft/adminPages/400_oidinfo_export/OIDplusPageAdminOIDInfoExport.class.php (Import OID from oid-info.com)
116
                //              dev/translation/*.phps (only for developers)
115
                //              dev/translation/*.phps (only for developers)
117
                // Note: This should not happen because of vendor/danielmarschall/php_utils/simplexml_supplement.inc.php
116
                // Note: This should not happen because of vendor/danielmarschall/php_utils/simplexml_supplement.inc.php
118
                if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
117
                if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
119
                        $install_hint = 'On Windows, it should be installed by default';
118
                        $install_hint = 'On Windows, it should be installed by default';
120
                } else {
119
                } 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',
120
                        $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>',
121
                                '<code>sudo apt-get update && sudo apt-get install php-xml</code>',
123
                                '<code>sudo service apache2 restart</code>');
122
                                '<code>sudo service apache2 restart</code>');
124
                }
123
                }
125
                $missing_dependencies[] = 'SimpleXML ('.$install_hint.')';
124
                $missing_dependencies[] = 'SimpleXML ('.$install_hint.')';
126
        }
125
        }
127
 
126
 
128
        return $missing_dependencies;
127
        return $missing_dependencies;
129
}
128
}
130
 
129