* 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 << Visit PHPInfo to double-check this. If you know it's installed, restart Apache and see if that works.

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 <<", $algorithms); $fail = true; } if (!$fail) { my_str_replace("{ALGORITHM}", $algorithms[$idx], $config); $salt = base64_encode(openssl_random_pseudo_bytes(32)); my_str_replace("{SALT}", $salt, $config); file_put_contents(dirname(__FILE__) . "/config.inc", $config); } } if (!class_exists('mysqli')) { print << Visit PHPInfo to double-check this. If you know it's installed, retstart Apache and try again

EOO; $fail = true; } if (!class_exists('ZipArchive')) { print << Visit PHPInfo to double-check this.

EOO; $fail = true; } if (strtolower(substr(PHP_OS, 0, 3)) == "win" && !class_exists("COM")) { print << Visit http://php.net/manual/en/book.com.php for more info EOO; $fail = true; } elseif (strtolower(substr(PHP_OS, 0, 3)) == 'win') { try { new COM("WScript.Shell"); } catch (Exception $e) { print << Open the php.ini file, search for request_order, and change it to either GPC or GPCS. After it's saved, you'll need to restart Apache

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 << Open the php.ini file, search for include_path (and make sure that the one for your OS) includes $root, $inc, & $classes
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 << To change this, open the php.ini file and look for 'memory_limit' and set to at least 1G
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 << To change this, open the php.ini file and change 'upload_max_filesize' and 'post_max_size'
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'; } ?> Sagacity Setup
"; print "Your current timezone is set to " . ini_get("date.timezone") . "
"; ?>

Database Configuration

  











  

Company Information

  







System Options