Completed
Push — php7.2-travis ( 91d29d...22cea2 )
by
unknown
10:30
created

system_checks.php ➔ check_db_collation_mysql()   B

Complexity

Conditions 7
Paths 4

Size

Total Lines 14
Code Lines 10

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
cc 7
eloc 10
nc 4
nop 1
dl 14
loc 14
rs 8.2222
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 4 and the first side effect is on line 2.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
	$ariadne = '';
3
4
	function check_php_version() {
5
		if (version_compare(PHP_VERSION, '5.6.2', '>=')) {
6
			return true;
7
		}
8
		return false;
9
	}
10
11
	function check_database_support() {
12
		if (check_mysql() || check_postgresql()) {
13
			return true;
14
		}
15
		return false;
16
	}
17
18
	function check_mysql() {
19
		if(function_exists('mysqli_connect')) {
20
			return true;
21
		}
22
		return false;
23
	}
24
25
	function check_postgresql() {
26
		if (function_exists('pg_connect')) {
27
			return true;
28
		}
29
		return false;
30
	}
31
32
	function check_apache() {
0 ignored issues
show
Coding Style introduced by
check_apache uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
33
		if (preg_match("/^apache/i", $_SERVER['SERVER_SOFTWARE'])) {
34
			return true;
35
		}
36
		return false;
37
	}
38
39
	function check_webserver() {
40
		if (
41
			check_apache()
42
			// FIXME: Add more compatible webservers.
0 ignored issues
show
Coding Style introduced by
Comment refers to a FIXME task "Add more compatible webservers"
Loading history...
43
		) {
44
			return true;
45
		}
46
		return false;
47
	}
48
49
	function check_accept_path_info() {
0 ignored issues
show
Coding Style introduced by
check_accept_path_info uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
50
		if ( function_exists('apache_lookup_uri')) {
51
			$extrapath = "/test_path_info/";
52
			$object = apache_lookup_uri($_SERVER['REQUEST_URI'] . $extrapath);
53
			if ($object->path_info == $extrapath) {
54
				return true;
55
			}
56
			return false;
57
		} else {
58
			$ariadne = '';
59
			@include("../ariadne.inc");
60
			if ( $ariadne != '' ) {
61
				require_once($ariadne . '/ar.php');
62
63
				// checking if path_info could be available
64
				$testuri = new ar_url('http://' .  $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
65
				$testuri->query = '';
0 ignored issues
show
Documentation introduced by
The property $query is declared private in ar_url. Since you implemented __set(), maybe consider adding a @property or @property-write annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
66
				$testuri->path = str_replace('/index.php', '/', $testuri->path)."serverinfo.php";
0 ignored issues
show
Documentation introduced by
The property path does not exist on object<ar_url>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Documentation introduced by
The property path does not exist on object<ar_url>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
67
				$testuri = (string)$testuri;
68
				$result1 = json_decode(ar_http::get($testuri),true);
69
				$result2 = json_decode(ar_http::get($testuri.'/my/path/info'),true);
70
71
				if ( is_array($result1) && is_array($result2) ) {
72
					// self request works
73
					// pathinfo could work
74
					if( $result2['server']['PATH_INFO'] == '/my/path/info' ) {
75
						return true;
76
					} else {
77
						return false;
78
					}
79
				} elseif ( is_array($result1) && is_null($result2) ) {
80
					// self request works
81
					// request with pathinfo fails
82
					return false;
83
				} else {
84
					// self request fails
85
					// should return 'check via browser'
86
					return false;
87
				}
88
			}
89
		}
90
		return false;
91
	}
92
93
	function check_zend_compat() {
94
		if (!ini_get("zend.ze1_compatibility_mode")) {
95
			return true;
96
		}
97
		return false;
98
	}
99
100
	function check_ariadne_inc_read() {
101
		if (is_readable("../ariadne.inc")) {
102
			return true;
103
		}
104
		return false;
105
	}
106
107
	function check_ariadne_path() {
108
		@include("../ariadne.inc");
109
		if (is_readable($ariadne . "/templates/pobject/")) {
0 ignored issues
show
Bug introduced by
The variable $ariadne does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
110
			return true;
111
		}
112
		return false;
113
	}
114
115
116
	function check_files_write() {
117
		@include("../ariadne.inc");
118
		if (is_writable($ariadne . "/../files/")) {
0 ignored issues
show
Bug introduced by
The variable $ariadne does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
119
			return true;
120
		}
121
		return false;
122
	}
123
124
	function check_ariadne_phtml_write() {
125
		@include("../ariadne.inc");
126
		if (file_exists($ariadne . "/configs/ariadne.phtml")) {
127
			if (is_writable($ariadne . "/configs/ariadne.phtml")) {
0 ignored issues
show
Bug introduced by
The variable $ariadne does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
128
				return true;
129
			}
130
		} else {
131
			if (is_writable($ariadne . "/configs/")) {
132
				return true;
133
			}
134
		}
135
		return false;
136
	}
137
138
	function check_im_convert() {
139
		$bin = find_in_path('convert');
140
		if (is_executable($bin)) {
141
			global $found_bins;
142
			$found_bins['bin_convert'] = $bin;
143
			return true;
144
		}
145
		return false;
146
	}
147
148
	function check_im_mogrify() {
149
		$bin = find_in_path('mogrify');
150
		if (is_executable($bin)) {
151
			global $found_bins;
152
			$found_bins['bin_mogrify'] = $bin;
153
			return true;
154
		}
155
		return false;
156
	}
157
158
	function check_im_composite() {
159
		$bin = find_in_path('composite');
160
		if (is_executable($bin)) {
161
			global $found_bins;
162
			$found_bins['bin_composite'] = $bin;
163
			return true;
164
		}
165
		return false;
166
	}
167
168
	function check_im_identify() {
169
		$bin = find_in_path('identify');
170
		if (is_executable($bin)) {
171
			global $found_bins;
172
			$found_bins['bin_identify'] = $bin;
173
			return true;
174
		}
175
		return false;
176
	}
177
178
	function check_image_magick() {
179
		if (
180
			check_im_convert() &&
181
			check_im_mogrify() &&
182
			check_im_composite() &&
183
			check_im_identify()
184
		) {
185
			return true;
186
		}
187
		return false;
188
	}
189
190
	function check_svn() {
191
		if (
192
			check_svn_class() &&
193
			check_svn_binary()
194
		) {
195
			return true;
196
		}
197
		return false;
198
	}
199
200
	function check_svn_class() {
201
		@include_once("VersionControl/SVN.php");
202
		if (class_exists("VersionControl_SVN")) {
203
			return true;
204
		}
205
		return false;
206
	}
207
208
	function check_domdocument_class() {
209
		if (class_exists("DOMDocument")) {
210
			return true;
211
		}
212
		return false;
213
	}
214
215 View Code Duplication
	function check_svn_binary() {
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
216
		$bin = find_in_path('svn');
217
		if (is_executable($bin)) {
218
			global $found_bins;
219
			$found_bins['bin_svn'] = $bin;
220
			return true;
221
		}
222
		return false;
223
	}
224
225
	function check_svn_write() {
226
		@include("../ariadne.inc");
227
		if (is_writeable($ariadne . "/configs/svn/")) {
0 ignored issues
show
Bug introduced by
The variable $ariadne does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
228
			return true;
229
		}
230
		return false;
231
	}
232
233 View Code Duplication
	function check_html_tidy() {
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
234
		$bin = find_in_path('tidy');
235
		if (is_executable($bin)) {
236
			global $found_bins;
237
			$found_bins['bin_tidy'] = $bin;
238
			return true;
239
		}
240
		return false;
241
	}
242
243 View Code Duplication
	function check_grep() {
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
244
		$bin = find_in_path('grep');
245
		if (is_executable($bin)) {
246
			global $found_bins;
247
			$found_bins['bin_grep'] = $bin;
248
			return true;
249
		}
250
		return false;
251
	}
252
253
	function check_connect_db($conf) {
254 View Code Duplication
		if ($conf && $conf->dbms) {
255
			switch ( $conf->dbms ) {
256
				case 'mysql':
257
				case 'mysql_workspaces':
258
					return check_connect_db_mysql($conf);
259
				break;
260
				case 'postgresql':
261
					return check_connect_db_postgresql($conf);
262
				break;
263
			}
264
			// FIXME: Add postgresql checks too
0 ignored issues
show
Coding Style introduced by
Comment refers to a FIXME task "Add postgresql checks too"
Loading history...
265
		}
266
		return false;
267
	}
268
269
	function check_select_db($conf) {
270 View Code Duplication
		if ($conf && $conf->dbms) {
271
			switch ( $conf->dbms ) {
272
				case 'mysql':
273
				case 'mysql_workspaces':
274
					return check_select_db_mysql($conf);
275
				break;
276
				case 'postgresql':
277
					return check_select_db_postgresql($conf);
278
				break;
279
			}
280
		}
281
		return false;
282
	}
283
284
	function check_db_grants($conf) {
285 View Code Duplication
		if ($conf && $conf->dbms) {
286
			switch ( $conf->dbms ) {
287
				case 'mysql':
288
				case 'mysql_workspaces':
289
					return check_db_grants_mysql($conf);
290
				break;
291
				case 'postgresql':
292
					return check_db_grants_postgresql($conf);
293
				break;
294
			}
295
		}
296
		return false;
297
	}
298
299
	function check_db_charset($conf) {
300 View Code Duplication
		if ($conf && $conf->dbms) {
301
			switch ( $conf->dbms ) {
302
				case 'mysql':
303
				case 'mysql_workspaces':
304
					return check_db_charset_mysql($conf) && check_db_collation_mysql($conf);
305
				break;
306
				case 'postgresql':
307
					return true; // No known issues for postgres
308
				break;
309
			}
310
		}
311
		return false;
312
	}
313
314
	function check_db_grants_mysql($conf) {
315
		$dbh = getConnection($conf);
316
		if (!$dbh->connect_errno) {
317
			$query = "SHOW GRANTS FOR CURRENT_USER();";
318
319
			$result = $dbh->query($query);
320
			if (!$dbh->errno ) {
321
				while ($row = $result->fetch_row()){
322
					if (preg_match("/^GRANT ALL/", $row[0])) {
323
						return true;
324
					}
325
					if (
326
						preg_match("/^GRANT.*?SELECT.*?ON/", $row[0]) &&
327
						preg_match("/^GRANT.*?INSERT.*?ON/", $row[0]) &&
328
						preg_match("/^GRANT.*?UPDATE.*?ON/", $row[0]) &&
329
						preg_match("/^GRANT.*?CREATE.*?ON/", $row[0]) &&
330
						preg_match("/^GRANT.*?DELETE.*?ON/", $row[0])
331
					) {
332
						return true;
333
					}
334
				}
335
			}
336
		}
337
		return false;
338
	}
339
340
	function check_db_grants_postgresql($conf) {
341
		if ( check_select_db_postgresql($conf) ) {
342
			$query = "SELECT has_database_privilege ( '".$conf->database."', 'CREATE' );";
343
			$result = pg_query( $query );
344
			while ( $row = pg_fetch_row( $result ) ) {
345
				if ( $row[0]=='t' ) {
346
					return true;
347
				}
348
			}
349
		}
350
		return false;
351
	}
352
353
	function getConnection($conf){
354
		static $dbh;
355
		if(!isset($dbh)) {
356
			$dbh = new mysqli($conf->host, $conf->user, $conf->password, $conf->database);
357
		}
358
		return $dbh;
359
	}
360
361
	function check_connect_db_mysql($conf) {
362
		$dbh = getConnection($conf);
363
		if ($dbh->connect_errno) {
364
			return false;
365
		}
366
		return true;
367
	}
368
369
	function check_connect_db_postgresql($conf) {
370
		$port = null;
371
		$host = $conf->host;
0 ignored issues
show
Unused Code introduced by
$host is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
372
		if ( strpos($conf->host,':') !== false) {
373
			list($host,$port) = explode($conf->host, ':',2);
0 ignored issues
show
Unused Code introduced by
The assignment to $host is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
374
		}
375
376
		if( $conf->host == ''){
377
			$hoststr = '';
378
		} else {
379
			$hoststr = 'host='.$conf->host;
380
		}
381
382
		if ($port) {
383
			$hoststr = $hoststr .= ' port='.$port;
384
		}
385
386
		if( $conf->password != '' ){
387
			$password = ' password='.$conf->password;
388
		}
389
390
		$connstring = $hoststr.' dbname='.$conf->database.' user='.$conf->user . ' ' .$password;
0 ignored issues
show
Bug introduced by
The variable $password does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
391
		$conf->connection = pg_connect($connstring);
392
		return (bool) $conf->connection;
393
	}
394
395
	function check_select_db_mysql($conf) {
396
		return check_connect_db_mysql($conf); //connect also checks database
397
	}
398
399
	function check_select_db_postgresql($conf) {
400
		return check_connect_db_postgresql($conf); //connect also checks database
401
	}
402
403
404
	function check_db_is_empty($conf) {
405
		switch( $conf->dbms ) {
406
			case 'mysql':
407
			case 'mysql_workspaces':
408
				return check_db_is_empty_mysql($conf);
409
			break;
410
			case 'postgresql':
411
				return check_db_is_empty_postgresql($conf);
412
			break;
413
		}
414
		return false;
415
	}
416
417
	function check_db_is_empty_mysql($conf) {
418
		$dbh = getConnection($conf);
419
		if (!$dbh->connect_errno) {
420
			$query = "SHOW TABLES;";
421
			$result = $dbh->query($query);
422
			if (!$dbh->errno && $result->num_rows == 0) {
423
				return true;
424
			}
425
		}
426
		return false;
427
	}
428
429 View Code Duplication
	function check_db_collation_mysql($conf) {
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
430
		$dbh = getConnection($conf);
431
		if (!$dbh->connect_errno) {
432
			$query = "SHOW VARIABLES LIKE 'collation_server'";
433
			$result = $dbh->query($query);
434
			if (!$dbh->errno && $result->num_rows) {
435
				$vars = mysqli_fetch_row($result);
436
				if ($vars && $vars[1] && ($vars[1] == "latin1_swedish_ci")) {
437
					return true;
438
				}
439
			}
440
		}
441
		return false;
442
	}
443
444 View Code Duplication
	function check_db_charset_mysql($conf) {
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
445
		$dbh = getConnection($conf);
446
		if (!$dbh->connect_errno) {
447
			$query = "SHOW VARIABLES LIKE 'character_set_server'";
448
			$result = $dbh->query($query);
449
			if (!$dbh->errno && $result->num_rows) {
450
				$vars = mysqli_fetch_row($result);
451
				if ($vars && $vars[1] && ($vars[1] == "latin1")) {
452
					return true;
453
				}
454
			}
455
		}
456
		return false;
457
	}
458
459
	function check_db_is_empty_postgresql($conf) {
460
		if (check_connect_db_postgresql($conf)) {
461
			$query = "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';";
462
			$result = pg_query($conf->connection, $query);
463
			if (pg_num_rows($result) == 0) {
464
				return true;
465
			}
466
		}
467
		return false;
468
	}
469
470
	function check_file( $file ) {
0 ignored issues
show
Best Practice introduced by
The function check_file() has been defined more than once; this definition is ignored, only the first definition in www/install/check.php (L64-81) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
471
		if (file_exists($file) && is_readable($file)) {
472
			return true;
473
		}
474
		return false;
475
	}
476
477
	function check_base_ax() {
478
		if (check_file("packages/base.ax")) {
479
			return true;
480
		}
481
		return false;
482
	}
483
484
	function check_demo_ax() {
485
		if (check_file("packages/demo.ax")) {
486
			return true;
487
		}
488
		return false;
489
	}
490
491
	function check_libs_ax() {
492
		if (check_file("packages/libs.ax")) {
493
			return true;
494
		}
495
		return false;
496
	}
497
498
	function check_docs_ax() {
499
		if (check_file("packages/docs.ax")) {
500
			return true;
501
		}
502
		return false;
503
	}
504
505
	function check_admin_password($admin_passwords) {
506
		if ($admin_passwords[0] && $admin_passwords[1] && $admin_passwords[0] == $admin_passwords[1]) {
507
			return true;
508
		}
509
		return false;
510
	}
511
512
	function check_tar_class() {
513
		@include_once("Archive/Tar.php");
514
		if (class_exists("Archive_Tar")) {
515
			return true;
516
		}
517
		return false;
518
	}
519
520
	function check_exif() {
521
		if (function_exists('exif_read_data')) {
522
			return true;
523
		}
524
		return false;
525
	}
526
527
	function check_mb_functions() {
528
		if (function_exists('mb_substr')) {
529
			return true;
530
		}
531
		return false;
532
	}
533
534
	function check_mcrypt() {
535
		if (extension_loaded('mcrypt')) {
536
			return true;
537
		}
538
		return false;
539
	}
540
541
	function getServerVar( $name ) {
0 ignored issues
show
Coding Style introduced by
getServerVar uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
542
		return isset( $_SERVER[$name] ) ? $_SERVER[$name] : null;
543
	}
544
545
	function find_in_path($needle,array $extrapath=array()) {
546
		$paths = explode(PATH_SEPARATOR,getServerVar('PATH'));
547
		$paths = array_merge($paths,$extrapath);
548
549
		$exts = explode(PATH_SEPARATOR, getServerVar('PATHEXT'));
550
551
		foreach($paths as $path){
552
			$file = $path . DIRECTORY_SEPARATOR . $needle;
553
			if(file_exists($file)) {
554
				return $file;
555
			}
556
557
			// W32 needs this
558
			foreach ($exts as $ext) {
559
				if(file_exists($file.$ext)) {
560
					return $file.$ext;
561
				}
562
			}
563
		}
564
	}
565
566
	$found_bins = array(); // will be filled by the check functions
567
568
	$required_checks = array(
569
		"check_php_version" => check_php_version(),		// php => 5.6.2
570
		"check_database_support" => check_database_support(),	// MySQL or Postgres
571
		"check_webserver" => check_webserver(),			// Apache, IIS, NGINX?
572
		"check_accept_path_info" => check_accept_path_info(),	// Apache config: AcceptPathInfo
573
		"check_zend_compat" => check_zend_compat(),		// zend.ze1_compatibility_mode = Off
574
		"check_ariadne_inc_read" => check_ariadne_inc_read(),	// Check if configuration file (ariadne.inc) can be read bij www-data
575
		"check_ariadne_path" => check_ariadne_path(),		// Check if path in ariadne.inc looks like an Ariadne tree
576
		"check_files_write" => check_files_write(),		// Check if files dir can be written by www-data
577
		"check_base_ax"	=> check_base_ax(),
578
		"check_tar_class" => check_tar_class(),			// Check if Archive/Tar class is available to import packages with.
579
		"check_mb_functions" => check_mb_functions(),			// Check if Archive/Tar class is available to import packages with.
580
		"check_domdocument_class" => check_domdocument_class(),
581
	);
582
583
	$recommended_checks = array(
584
		"check_ariadne_phtml_write" => check_ariadne_phtml_write(),	// Check if configuration file (ariadne.phtml) can be written bij www-data
585
		"check_exif" => check_exif(),
586
		"check_image_magick" => check_image_magick(),
587
		"check_svn" => check_svn(),
588
		"check_svn_write" => check_svn_write(),
589
		"check_html_tidy" => check_html_tidy(),
590
		"check_grep" => check_grep(),
591
		"check_demo_ax" => check_demo_ax(),
592
//		"check_mcrypt" => check_mcrypt(),
593
//		"check_libs_ax" => check_libs_ax(),
594
//		"check_docs_ax" => check_docs_ax()
595
	);
596
597
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...