Subversion Repositories oidplus

Rev

Rev 726 | Rev 1116 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 726 Rev 1069
Line 1... Line 1...
1
<?php
1
<?php
2
 
2
 
3
/*
3
/*
4
 * OIDplus 2.0
4
 * OIDplus 2.0
5
 * Copyright 2019 - 2021 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
 *
Line 15... Line 15...
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
-
 
21
// stage, then we have no language plugins anyways.
-
 
22
 
20
function oidplus_get_missing_dependencies() {
23
function oidplus_get_missing_dependencies() {
21
        $missing_dependencies = array();
24
        $missing_dependencies = array();
22
 
25
 
23
        if (!extension_loaded('standard')) {
26
        if (!extension_loaded('standard')) {
24
                $missing_dependencies[] = 'standard';
27
                $missing_dependencies[] = 'standard';
Line 62... Line 65...
62
                //                  includes/ipv6_functions.inc.php
65
                //                  includes/ipv6_functions.inc.php
63
                //                  plugins/viathinksoft/adminPages/400_oidinfo_export/oidinfo_api.inc.php (if GMP is not available, BC will be used)
66
                //                  plugins/viathinksoft/adminPages/400_oidinfo_export/oidinfo_api.inc.php (if GMP is not available, BC will be used)
64
                // Note that vendor/danielmarschall/php_utils/gmp_supplement.inc.php will implement the GMP functions if BCMath is present.
67
                // Note that vendor/danielmarschall/php_utils/gmp_supplement.inc.php will implement the GMP functions if BCMath is present.
65
                // This is the reason why we use function_exists('gmp_init') instead of extension_loaded('gmp')
68
                // 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') {
69
                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',
70
                        $install_hint1 = sprintf('On Windows, install it by enabling the line %s in your PHP.ini',
68
                                'extension=php_gmp.dll');
71
                                'extension=php_gmp.dll');
69
                        $install_hint2 = _L('On Windows, it should be installed by default');
72
                        $install_hint2 = sprintf('On Windows, it should be installed by default');
70
                } else {
73
                } 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',
74
                        $install_hint1 = sprintf('On Linux, install it by running e.g. %s, and then restart your webserver service, e.g. by running %s',
72
                                '<code>sudo apt-get update && sudo apt-get install php-gmp</code>',
75
                                '<code>sudo apt-get update && sudo apt-get install php-gmp</code>',
73
                                '<code>sudo service apache2 restart</code>');
76
                                '<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',
77
                        $install_hint2 = sprintf('On Linux, install it by running e.g. %s, and then restart your webserver service, e.g. by running %s',
75
                                '<code>sudo apt-get update && sudo apt-get install php-bcmath</code>',
78
                                '<code>sudo apt-get update && sudo apt-get install php-bcmath</code>',
76
                                '<code>sudo service apache2 restart</code>');
79
                                '<code>sudo service apache2 restart</code>');
77
                }
80
                }
78
                $missing_dependencies[] = 'GMP ('.$install_hint1.')'.
81
                $missing_dependencies[] = 'GMP ('.$install_hint1.')'.
79
                                          '<br>'._L('or alternatively').'<br>' .
82
                                          '<br>'.sprintf('or alternatively').'<br>' .
80
                                          'BCMath ('.$install_hint2.')';
83
                                          'BCMath ('.$install_hint2.')';
81
        }
84
        }
82
 
85
 
83
        if (!extension_loaded('mbstring') && !extension_loaded('iconv')) {
86
        if (!extension_loaded('mbstring') && !extension_loaded('iconv')) {
84
                // Required for includes/classes/OIDplusSessionHandler.class.php
87
                // Required for includes/classes/OIDplusSessionHandler.class.php
Line 87... Line 90...
87
                //              vendor/n-other/php-sha3/src/Sha3.php
90
                //              vendor/n-other/php-sha3/src/Sha3.php
88
                //              includes/functions.inc.php (convert_to_utf8_no_bom)
91
                //              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.
92
                // 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')
93
                // This is the reason why we use extension_loaded('mbstring') instead of function_exists('mb_substr')
91
                if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
94
                if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
92
                        $install_hint1 = _L('On Windows, install it by enabling the line %1 in your PHP.ini',
95
                        $install_hint1 = sprintf('On Windows, install it by enabling the line %s in your PHP.ini',
93
                                'extension=php_mbstring.dll');
96
                                'extension=php_mbstring.dll');
94
                        $install_hint2 = _L('On Windows, it should be installed by default');
97
                        $install_hint2 = sprintf('On Windows, it should be installed by default');
95
                } else {
98
                } else {
96
                        $install_hint1 = _L('On Linux, install it by running e.g. %1, and then restart your webserver service, e.g. by running %2',
99
                        $install_hint1 = sprintf('On Linux, install it by running e.g. %s, and then restart your webserver service, e.g. by running %s',
97
                                '<code>sudo apt-get update && sudo apt-get install php-mbstring</code>',
100
                                '<code>sudo apt-get update && sudo apt-get install php-mbstring</code>',
98
                                '<code>sudo service apache2 restart</code>');
101
                                '<code>sudo service apache2 restart</code>');
99
                        $install_hint2 = _L('On Linux, it should be installed by default'); // Alpine Linux: apk add php-iconv
102
                        $install_hint2 = sprintf('On Linux, it should be installed by default'); // Alpine Linux: apk add php-iconv
100
                }
103
                }
101
                $missing_dependencies[] = 'MBString ('.$install_hint1.')'.
104
                $missing_dependencies[] = 'MBString ('.$install_hint1.')'.
102
                                          '<br>'._L('or alternatively').'<br>' .
105
                                          '<br>'.sprintf('or alternatively').'<br>' .
103
                                          'iconv ('.$install_hint2.')';
106
                                          'iconv ('.$install_hint2.')';
104
        }
107
        }
105
 
108
 
106
        if (!function_exists('simplexml_load_file')) {
109
        if (!function_exists('simplexml_load_file')) {
107
                // Required for includes/classes/OIDplusPluginManifest.class.php (Plugins)
110
                // Required for includes/classes/OIDplusPluginManifest.class.php (Plugins)
108
                //              includes/classes/OIDplus.class.php (Translation)
111
                //              includes/classes/OIDplus.class.php (Translation)
109
                //              plugins/viathinksoft/adminPages/400_oidinfo_export/OIDplusPageAdminOIDInfoExport.class.php (Import OID from oid-info.com)
112
                //              plugins/viathinksoft/adminPages/400_oidinfo_export/OIDplusPageAdminOIDInfoExport.class.php (Import OID from oid-info.com)
110
                //              dev/translation/*.phps (only for developers)
113
                //              dev/translation/*.phps (only for developers)
111
                // Note: This should not happen because of vendor/danielmarschall/php_utils/simplexml_supplement.inc.php
114
                // Note: This should not happen because of vendor/danielmarschall/php_utils/simplexml_supplement.inc.php
112
                if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
115
                if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
113
                        $install_hint = _L('On Windows, it should be installed by default');
116
                        $install_hint = sprintf('On Windows, it should be installed by default');
114
                } else {
117
                } 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',
118
                        $install_hint = sprintf('On Linux, install it by running e.g. %s, and then restart your webserver service, e.g. by running %s',
116
                                '<code>sudo apt-get update && sudo apt-get install php-xml</code>',
119
                                '<code>sudo apt-get update && sudo apt-get install php-xml</code>',
117
                                '<code>sudo service apache2 restart</code>');
120
                                '<code>sudo service apache2 restart</code>');
118
                }
121
                }
119
                $missing_dependencies[] = 'SimpleXML ('.$install_hint.')';
122
                $missing_dependencies[] = 'SimpleXML ('.$install_hint.')';
120
        }
123
        }