Subversion Repositories oidplus

Rev

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