~xibo-maintainers/xibo/tempel

« back to all changes in this revision

Viewing changes to lib/Helper/Environment.php

  • Committer: Dan Garner
  • Date: 2015-09-29 15:16:59 UTC
  • mto: (454.2.11) (471.2.2)
  • mto: This revision was merged to the branch mainline in revision 468.
  • Revision ID: git-v1:ae24387a7b1397750b6ec86d0f286373da05eb16
Fixed Display Version Information Form (not showing media name)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
/*
3
 
 * Spring Signage Ltd - http://www.springsignage.com
4
 
 * Copyright (C) 2018 Spring Signage Ltd
5
 
 * (Environment.php)
6
 
 */
7
 
 
8
 
 
9
 
namespace Xibo\Helper;
10
 
 
11
 
 
12
 
class Environment
13
 
{
14
 
    public static $WEBSITE_VERSION_NAME = '1.8.6';
15
 
    public static $WEBSITE_VERSION = 137;
16
 
 
17
 
    public static $VERSION_REQUIRED = '5.5';
18
 
    public static $VERSION_UNSUPPORTED = '8.0';
19
 
 
20
 
    /**
21
 
     * Check FileSystem Permissions
22
 
     * @return bool
23
 
     */
24
 
    public static function checkFsPermissions()
25
 
    {
26
 
        return (is_writable(PROJECT_ROOT . "/web/settings.php") || is_writable(PROJECT_ROOT . "/cache"));
27
 
    }
28
 
 
29
 
    /**
30
 
     * Check PHP version is within the preset parameters
31
 
     * @return bool
32
 
     */
33
 
    public static function checkPHP()
34
 
    {
35
 
        return (version_compare(phpversion(), self::$VERSION_REQUIRED) != -1) && (version_compare(phpversion(), self::$VERSION_UNSUPPORTED) != 1);
36
 
    }
37
 
 
38
 
    /**
39
 
     * Check PHP has the PDO module installed (with MySQL driver)
40
 
     */
41
 
    public static function checkPDO()
42
 
    {
43
 
        return extension_loaded("pdo_mysql");
44
 
    }
45
 
 
46
 
    /**
47
 
     * Check PHP has the GetText module installed
48
 
     * @return bool
49
 
     */
50
 
    public static function checkGettext()
51
 
    {
52
 
        return extension_loaded("gettext");
53
 
    }
54
 
 
55
 
    /**
56
 
     * Check PHP has JSON module installed
57
 
     * @return bool
58
 
     */
59
 
    public static function checkJson()
60
 
    {
61
 
        return extension_loaded("json");
62
 
    }
63
 
 
64
 
    /**
65
 
     *
66
 
     * Check PHP has SOAP module installed
67
 
     * @return bool
68
 
     */
69
 
    public static function checkSoap()
70
 
    {
71
 
        return extension_loaded("soap");
72
 
    }
73
 
 
74
 
    /**
75
 
     * Check PHP has GD module installed
76
 
     * @return bool
77
 
     */
78
 
    public static function checkGd()
79
 
    {
80
 
        return extension_loaded("gd");
81
 
    }
82
 
 
83
 
    /**
84
 
     * Check PHP has the DOM XML functionality installed
85
 
     * @return bool
86
 
     */
87
 
    public static function checkDomXml()
88
 
    {
89
 
        return extension_loaded("dom");
90
 
    }
91
 
 
92
 
    /**
93
 
     * Check PHP has the Mcrypt functionality installed
94
 
     * @return bool
95
 
     */
96
 
    public static function checkMcrypt()
97
 
    {
98
 
        return extension_loaded("mcrypt");
99
 
    }
100
 
 
101
 
    /**
102
 
     * Check PHP has the DOM functionality installed
103
 
     * @return bool
104
 
     */
105
 
    public static function checkDom()
106
 
    {
107
 
        return class_exists("DOMDocument");
108
 
    }
109
 
 
110
 
    /**
111
 
     * Check PHP has session functionality installed
112
 
     * @return bool
113
 
     */
114
 
    public static function checkSession()
115
 
    {
116
 
        return extension_loaded("session");
117
 
    }
118
 
 
119
 
    /**
120
 
     * Check PHP has PCRE functionality installed
121
 
     * @return bool
122
 
     */
123
 
    public static function checkPCRE()
124
 
    {
125
 
        return extension_loaded("pcre");
126
 
    }
127
 
 
128
 
    /**
129
 
     * Check PHP has FileInfo functionality installed
130
 
     * @return bool
131
 
     */
132
 
    public static function checkFileInfo()
133
 
    {
134
 
        return extension_loaded("fileinfo");
135
 
    }
136
 
 
137
 
    public static function checkZip()
138
 
    {
139
 
        return extension_loaded('zip');
140
 
    }
141
 
 
142
 
    public static function checkIntlDateFormat()
143
 
    {
144
 
        return class_exists('IntlDateFormatter');
145
 
    }
146
 
 
147
 
 
148
 
    /**
149
 
     * Check to see if curl is installed
150
 
     */
151
 
    public static function checkCurlInstalled()
152
 
    {
153
 
        return function_exists('curl_version');
154
 
    }
155
 
 
156
 
    /**
157
 
     * Check PHP is setup for large file uploads
158
 
     * @return bool
159
 
     */
160
 
    public static function checkPHPUploads()
161
 
    {
162
 
        # Consider 0 - 128M warning / < 120 seconds
163
 
        # Variables to check:
164
 
        #    post_max_size
165
 
        #    upload_max_filesize
166
 
        #    max_execution_time
167
 
 
168
 
        $minSize = ByteFormatter::toBytes('128M');
169
 
 
170
 
        if (ByteFormatter::toBytes(ini_get('post_max_size')) < $minSize)
171
 
            return false;
172
 
 
173
 
        if (ByteFormatter::toBytes(ini_get('upload_max_filesize')) < $minSize)
174
 
            return false;
175
 
 
176
 
        if (ini_get('max_execution_time') < 120)
177
 
            return false;
178
 
 
179
 
        // All passed
180
 
        return true;
181
 
    }
182
 
 
183
 
    /**
184
 
     * @inheritdoc
185
 
     */
186
 
    public static function checkZmq()
187
 
    {
188
 
        return class_exists('ZMQSocket');
189
 
    }
190
 
 
191
 
 
192
 
    public static function getMaxUploadSize()
193
 
    {
194
 
        return ini_get('upload_max_filesize');
195
 
    }
196
 
 
197
 
    /**
198
 
     * Check open ssl is available
199
 
     * @return bool
200
 
     */
201
 
    public static function checkOpenSsl()
202
 
    {
203
 
        return extension_loaded('openssl');
204
 
    }
205
 
 
206
 
    /**
207
 
     * @inheritdoc
208
 
     * https://stackoverflow.com/a/45767760
209
 
     */
210
 
    public static function getMemoryLimitBytes()
211
 
    {
212
 
        return intval(str_replace(array('G', 'M', 'K'), array('000000000', '000000', '000'), ini_get('memory_limit')));
213
 
    }
214
 
 
215
 
    /**
216
 
     * @return bool
217
 
     */
218
 
    public static function checkTimezoneIdentifiers()
219
 
    {
220
 
        return function_exists('timezone_identifiers_list');
221
 
    }
222
 
 
223
 
    /**
224
 
     * @return bool
225
 
     */
226
 
    public static function checkAllowUrlFopen()
227
 
    {
228
 
        return ini_get('allow_url_fopen');
229
 
    }
230
 
 
231
 
    /**
232
 
     * @return bool
233
 
     */
234
 
    public static function checkSimpleXml()
235
 
    {
236
 
        return extension_loaded('simplexml');
237
 
    }
238
 
}
 
 
b'\\ No newline at end of file'