Skip to content

Commit 1f77c33

Browse files
committed
Add check_php_build.php from phpipam/phpipam repository
We are re-using code from phpipam/phpipam that requires php5.4+ and 64bit OS.
1 parent 83cbdd7 commit 1f77c33

File tree

3 files changed

+71
-1
lines changed

3 files changed

+71
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ phpipam-agent is a scanning agent for phpipam server to be deployed to remote se
55
phpipam is released under the GPL v3 license, see misc/gpl-3.0.txt.
66

77
## Requirements
8-
- PHP version 5.3+ with following modules
8+
- 64bit PHP version 5.4+ with following modules
99
- pdo, pdo_mysql : Adds support for mysql connections (if type=mysql)
1010
- gmp : Adds support for dev-libs/gmp (GNU MP library) -> to calculate IPv6 networks
1111
- json : Adds supports for JSON data-interexchange format

functions/checks/check_php_build.php

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
3+
/**
4+
*
5+
* Script to check if all required extensions are compiled and loaded in PHP
6+
*
7+
*
8+
* We need the following mudules:
9+
* - session
10+
* - gmp
11+
* - json
12+
* - gettext
13+
* - PDO
14+
* - pdo_mysql
15+
*
16+
************************************/
17+
18+
19+
# Required extensions
20+
$requiredExt = array("PDO", "pdo_mysql", "mbstring", "iconv", "ctype", "gettext", "gmp", "json", "filter");
21+
22+
# Available extensions
23+
$availableExt = get_loaded_extensions();
24+
25+
# Empty missing array to prevent errors
26+
$missingExt[0] = "";
27+
28+
# if not all are present create array of missing ones
29+
foreach ($requiredExt as $extension) {
30+
if (!in_array($extension, $availableExt)) {
31+
$missingExt[] = $extension;
32+
}
33+
}
34+
35+
# check for PEAR functions
36+
if ((@include_once 'PEAR.php') != true) {
37+
$missingExt[] = "php PEAR support";
38+
}
39+
40+
# if any extension is missing print error and die!
41+
if (sizeof($missingExt) != 1 || (phpversion() < "5.4") || PHP_INT_SIZE==4) {
42+
43+
/* remove dummy 0 line */
44+
unset($missingExt[0]);
45+
46+
/* Extensions error */
47+
if(sizeof($missingExt)>0) {
48+
$error[] = _('The following required PHP extensions are missing');
49+
foreach ($missingExt as $missing) {
50+
$error[] = $missing;
51+
}
52+
$error[] = _('Please recompile PHP to include missing extensions.');
53+
}
54+
/* php version error */
55+
elseif(phpversion() < "5.4") {
56+
$error[] = _('Unsupported PHP version');
57+
$error[] = _('From release 1.3.2+, at least PHP version 5.4 is required!');
58+
$error[] = _("Detected PHP version: ").phpversion();
59+
}
60+
/* 32-bit systems */
61+
else {
62+
$error[] = _('From phpIPAM release 1.4 onwards, 64bit system is required!');
63+
}
64+
65+
$error[] = "";
66+
67+
die(implode("\n", $error));
68+
}

functions/functions.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
require( dirname(__FILE__) . '/checks/check_php_build.php' );
4+
35
/* @config file ------------------ */
46
require_once( dirname(__FILE__) . '/classes/class.Config.php' );
57
$config = Config::ValueOf('config');

0 commit comments

Comments
 (0)