File: /home/assibfaf/customassignment.us/prox-install.php
<?php
/**
* @package Proxim
* @author Davison Pro <davisonpro.coder@gmail.com | https://davisonpro.dev>
* @copyright 2019 Proxim
* @version 1.0.0
* @since File available since Release 1.0.0
*/
// Short name
define('PROX_DS', DIRECTORY_SEPARATOR);
// Modes
define('PROX_IS_CLI_MODE', 'cli' === PHP_SAPI);
// Common end-of-line
define('PROX_EOL', PROX_IS_CLI_MODE ? "\n" : '<br />');
define('PROX_NAMESPACE', 'Proxim');
define('PROX_DIR', dirname(__FILE__));
define('PROX_DIR_ROOT', rtrim(PROX_DIR, PROX_DS) . PROX_DS);
define('PROX_DIR_CLASSES', PROX_DIR_ROOT . 'prox-classes' . PROX_DS);
define('PROX_DIR_CONTROLLERS', PROX_DIR_ROOT . 'prox-controllers' . PROX_DS);
define('PROX_DIR_CACHE', PROX_DIR_ROOT . 'prox-cache' . PROX_DS);
define('PROX_DIR_TEMPLATES', PROX_DIR_ROOT . 'prox-templates' . PROX_DS);
define('PROX_DIR_IMAGES', PROX_DIR_ROOT . 'prox-images' . PROX_DS);
define('PROX_DIR_MAIL', PROX_DIR_TEMPLATES . 'mail' . PROX_DS);
define('PROX_OS_WINDOWS', 'WIN' === strtoupper(substr(PHP_OS, 0, 3)));
define('PROX_IS_PHP_7', version_compare(PHP_VERSION, '7.0.0', '>='));
/**#@+
* Authentication Unique Keys and Salts.
*/
define( 'PROX_COOKIE_KEY', 'hcmy3vvdmgj1droykuyodzzz0f2kmisj9fjls8q4wonyx4hfiepgvefbsjlflw1c' );
define( 'PROX_COOKIE_IV', 'h2HHwDjqA2dJuU' );
// enviroment settings
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING));
if (!defined('PROX_MAGIC_QUOTES_GPC')) {
define('PROX_MAGIC_QUOTES_GPC', false);
}
if ( file_exists(PROX_DIR . PROX_DS . 'prox-vendor' . PROX_DS . 'autoload.php') ) {
require_once PROX_DIR . PROX_DS . 'prox-vendor' . PROX_DS . 'autoload.php';
}
require_once PROX_DIR_ROOT . 'prox-autoload.php';
require_once PROX_DIR_ROOT . 'prox-functions.php';
// check the config file
if(file_exists(PROX_DIR_ROOT . 'prox-config.php')) {
/* the config file exist -> start the system */
header('Location: /');
}
use Proxim\Application;
use Proxim\Tools;
use Proxim\Validate;
use Proxim\Util\ArrayUtils;
use Proxim\Util\DateUtils;
$app = new Application([
'mode' => 'production',
'debug' => false
]);
$payload = Tools::getAllValues();
function secureEscape($value) {
global $db;
/* Escape all (single-quote, double quote, backslash, NULs) */
if(get_magic_quotes_gpc()) {
$value = stripslashes($value);
}
/* Convert all applicable characters to HTML entities */
$value = htmlentities($value, ENT_QUOTES, 'utf-8');
// [2] Safe SQL
$value = $db->real_escape_string($value);
$value = (!empty($value))? "'".$value."'" : "''";
return $value;
}
if(ArrayUtils::has($payload, 'submit')) {
$db_server = ArrayUtils::get($payload, 'db_host');
$db_user = ArrayUtils::get($payload, 'db_username');
$db_password = ArrayUtils::get($payload, 'db_password');
$database = ArrayUtils::get($payload, 'db_name');
$admin_site_id = (int) ArrayUtils::get($payload, 'admin_site_id', 132457698);
$db = new mysqli(
$db_server,
$db_user,
$db_password,
$database
);
if(mysqli_connect_error()) {
$app->showError("DB_ERROR");
}
// [2] check admin data
$website_name = ArrayUtils::get($payload, 'website_name');
if ( $website_name && !Validate::isName($website_name) ) {
$app->showError("Error", "Enter a valid website name");
}
if ( Tools::strlen($website_name) < 3 ) {
$app->showError("Error", "Your website name must be at least 3 characters long. Please try another");
}
$website_email = ArrayUtils::get($payload, 'website_email');
if ( !$website_email || !Validate::isEmail($website_email) ) {
$app->showError("Error", "Enter a valid email address");
}
$result = $db->query("SELECT * FROM prox_site ORDER BY site_id DESC LIMIT 1");
if($result->num_rows > 0) {
$site_id = $result->fetch_row()[0]+20;
} else {
$site_id = Tools::randomGen(9, 'NUMERIC');
}
$domain = $app->base_uri;
$date = DateUtils::now();
// [3] Add the site
/* insert */
$db->query(sprintf("
INSERT INTO `prox_site` (`site_id`, `name`, `email`, `domain`, `date_upd`, `date_add`)
VALUES (%s, %s, %s, %s, %s, %s)
", secureEscape($site_id), secureEscape($website_name), secureEscape($website_email), secureEscape($domain), secureEscape($date), secureEscape($date)) ) or $app->showError("Error", $db->error);
// [4] update system settings
$db->query(sprintf("
INSERT INTO `prox_configuration` (`site_id`, `name`, `value`, `date_add`, `date_upd`) VALUES (%s, 'SITE_ID', %s, %s, %s)
", $site_id, (int) $site_id, secureEscape($date), secureEscape($date)) ) or $app->showError("Error", $db->error);
$db->query(sprintf("
INSERT INTO `prox_configuration` (`site_id`, `name`, `value`, `date_add`, `date_upd`) VALUES (%s, 'SITE_DOMAIN', %s, %s, %s)
", $site_id, secureEscape($domain), secureEscape($date), secureEscape($date)) ) or $app->showError("Error", $db->error);
$db->query(sprintf("
INSERT INTO `prox_configuration` (`site_id`, `name`, `value`, `date_add`, `date_upd`) VALUES (%s, 'SITE_NAME', %s, %s, %s)
", $site_id, secureEscape($website_name), secureEscape($date), secureEscape($date)) ) or $app->showError("Error", $db->error);
$db->query(sprintf("
INSERT INTO `prox_configuration` (`site_id`, `name`, `value`, `date_add`, `date_upd`) VALUES (%s, 'SITE_EMAIL', %s, %s, %s)
", $site_id, secureEscape($website_email), secureEscape($date), secureEscape($date)) ) or $app->showError("Error", $db->error);
// [4] create config file
$config_string = "<?php
/**
* The base configuration for Proxim
* @package Proxim
* @author Davison Pro <davisonpro.coder@gmail.com | https://davisonpro.dev>
* @copyright 2019 Proxim
* @version 1.0.0
* @since File available since Release 1.0.0
*/
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for Proxim */
define( 'PROX_DB_NAME', '".$database."' );
/** MySQL database username */
define( 'PROX_DB_USER', '".$db_user."' );
/** MySQL database password */
define( 'PROX_DB_PASSWORD', '".$db_password."' );
/** MySQL hostname */
define( 'PROX_DB_SERVER', '".$db_server."' );
/** 9 characters Unique Identifier for this site */
define( 'PROX_SITE_ID', '".$site_id."' );
/** Admin site ID */
define( 'PROX_ADMIN_SITE_ID', '".$admin_site_id."' );
/** MySQL database prefix */
define( 'PROX_DB_PREFIX', 'prox_' );
define( 'PROX_DEBUG', true );
define( 'PROX_ENVIRONMENT', 'development');
define( 'PROX_CACHING_SYSTEM', 'CacheMemcached' );
/* SQL Replication management */
define( 'PROX_USE_SQL_SLAVE', false );
/** uploads folder */
define('PROX_DIR_UPLOADS', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR);
/**#@+
* Authentication Unique Keys and Salts.
*/
define( 'PROX_COOKIE_KEY', '".PROX_COOKIE_KEY."' );
define( 'PROX_COOKIE_IV', '".PROX_COOKIE_IV."' );
/* That's all, stop editing! Happy writing . */
?>
";
$config_file = PROX_DIR_ROOT . 'prox-config.php';
$handle = fopen($config_file, 'w') or $app->showError("Error", "Proxim intsaller wizard cannot create the config file");
fwrite($handle, $config_string);
fclose($handle);
// [5] start the system
header('Location: /order');
}
?>
<!DOCTYPE html>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Proxim › Installer</title>
<link rel="stylesheet" type="text/css" href="/static/installer/installer.css" />
<script src="/static/installer/modernizr.custom.js"></script>
</head>
<body>
<div class="container">
<div class="fs-form-wrap" id="fs-form-wrap">
<div class="fs-title">
<h1>Proxim Installer</h1>
</div>
<form id="myform" class="fs-form fs-form-full" autocomplete="off" action="" method="post">
<ol class="fs-fields">
<li>
<p class="fs-field-label fs-anim-upper">
Welcome to <strong>Proxim</strong> installation process! Just fill in the information below and start your own academic writing service.
</p>
</li>
<li>
<label class="fs-field-label fs-anim-upper" for="db_name" data-info="The name of the database you want to run Proxim in">What's Database Name?</label>
<input autocomplete="off" class="fs-anim-lower" id="db_name" name="db_name" type="text" placeholder="Proxim" required/>
</li>
<li>
<label class="fs-field-label fs-anim-upper" for="db_username" data-info="Your MySQL username">What's Database Username?</label>
<input autocomplete="off" class="fs-anim-lower" id="db_username" name="db_username" type="text" placeholder="username" required/>
</li>
<li>
<label class="fs-field-label fs-anim-upper" for="db_password" data-info="Your MySQL password">What's Database Password?</label>
<input autocomplete="off" class="fs-anim-lower" id="db_password" name="db_password" type="text" placeholder="password"/>
</li>
<li>
<label class="fs-field-label fs-anim-upper" for="db_host" data-info="You should be able to get this info from your web host, if localhost does not work">What's Database Host?</label>
<input autocomplete="off" class="fs-anim-lower" id="db_host" name="db_host" type="text" placeholder="localhost" required/>
</li>
<li>
<label class="fs-field-label fs-anim-upper" for="website_email" data-info="Double-check your website email address before continuing.">Your website E-mail</label>
<input autocomplete="off" class="fs-anim-lower" id="website_email" name="website_email" type="email" placeholder="support@website.com" required/>
</li>
<li>
<label class="fs-field-label fs-anim-upper" for="website_name" data-info="Your website name">Your website name</label>
<input autocomplete="off" class="fs-anim-lower" id="website_name" name="website_name" type="text" placeholder="Essay Shark" required/>
</li>
<li>
<label class="fs-field-label fs-anim-upper" for="admin_site_id" data-info="Your administrator site ID">Administrator Site ID</label>
<input autocomplete="off" class="fs-anim-lower" id="admin_site_id" name="admin_site_id" type="text" placeholder="132457698" required/>
</li>
</ol>
<button class="fs-submit" name="submit" type="submit">Install</button>
</form>
</div>
</div>
<script src="/static/installer/classie.js"></script>
<script src="/static/installer/fullscreenForm.js"></script>
<script>
(function() {
var formWrap = document.getElementById( 'fs-form-wrap' );
new FForm( formWrap, {
onReview : function() {
classie.add( document.body, 'overview' );
}
} );
})();
</script>
</body>
</html>