* Purpose: Allow setup process for new installations
* Created: Nov 28, 2017
*
* Copyright 2017: Cyber Perspective, LLC, All rights reserved
* Released under the Apache v2.0 License
*
* See license.txt for details
*
* Change Log:
* - Nov 28, 2017 - File created
* - Dec 27, 2017 - Added check for local mysql server and empty root password, updated include path to display root path
* - Apr 29, 2018 - Updated 3rd party libraries
* - May 10, 2018 - Added root confirmation password validation (bug #412)
*/
set_time_limit(0);
include_once 'helper.inc';
/**
* check for PHP settings
* 1. is openssl installed and running?
* 2. is mysqli installed and running?
* 3. is ZipArchive class installed?
* 4. is the request_order set correctly? GPCS?
* 5. is root, inc, and classes folders in include_path
*/
$fail = false;
$config = file_get_contents(dirname(__FILE__) . "/config.inc");
if (version_compare(PHP_VERSION, '7.1') < 0) {
print "The minimum version of PHP necessary is 7.1, please upgrade to continue
";
$fail = true;
}
if (!is_writable(dirname(__FILE__))) {
print <<
EOO;
$fail = true;
}
else {
$algorithms = ["aes-256-cbc-hmac-sha256", "aec-256-cbc-hmac-sha1", "aes-256-cbc"];
$ciphers = array_map('strtolower', openssl_get_cipher_methods());
if (in_array($algorithms[0], $ciphers)) {
$idx = 0;
}
elseif (in_array($algorithms[1], $ciphers)) {
$idx = 1;
}
elseif (in_array($algorithms[2], $ciphers)) {
$idx = 2;
}
else {
print <<
EOO;
$fail = true;
}
if (!class_exists('ZipArchive')) {
print <<
EOO;
$fail = true;
}
if (strtolower(substr(PHP_OS, 0, 3)) == "win" && !class_exists("COM")) {
print <<
EOO;
$fail = true;
}
if (strtolower(substr(PHP_OS, 0, 3)) == 'win') {
$delim = ';';
}
else {
$delim = ':';
}
$inc_path = explode($delim, ini_get('include_path'));
$doc_root = realpath(dirname(__FILE__));
$classes = realpath("{$doc_root}/classes");
$inc = realpath("{$doc_root}/inc");
$root = realpath(dirname(__FILE__));
if (!in_array($inc, $inc_path) || !in_array($classes, $inc_path) || !in_array($root, $inc_path)) {
print <<
Current include_path:
EOO;
print ini_get('include_path') . "
";
$fail = true;
}
$mem_limit = return_bytes(ini_get("memory_limit"));
$gig = return_bytes('1G');
if ($mem_limit < $gig) {
print <<
EOO;
}
if (!ini_get("file_uploads")) {
print "File uploads are currently turned off by the file_uploads directive in php.ini. Please turn them back on if you wish to upload files through the user interfaces
";
}
else {
$upload_file_max = return_bytes(ini_get('upload_max_filesize'));
$post_max_size = return_bytes(ini_get('post_max_size'));
if ($upload_file_max != $post_max_size) {
print <<
EOO;
}
}
if ($fail) {
die;
}
$is_online = ping("cyberperspectives.com");
$step = filter_input(INPUT_GET, 'step', FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE);
$blank_root = false;
$mysql_host = '';
mysqli_report(MYSQLI_REPORT_STRICT);
try {
$db = new mysqli("localhost", "root", "");
if (!$db->connect_errno) {
$blank_root = true;
$mysql_host = 'localhost';
}
}
catch (Exception $e) {
}
if (strtolower(substr(PHP_OS, 0, 3)) == 'win') {
$mysql_host = 'localhost';
}
?>