Subversion Repositories oidplus

Rev

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