Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php CONST DEBUG_MODE=false; ob_start(); //<editor-fold defaultstate="collapse..
Decoded Output download
<?php
CONST DEBUG_MODE=false;
ob_start();
//<editor-fold defaultstate="collapsed" desc="utils">
function cnd_json_encode($x) {
if (function_exists('json_encode')) {
return json_encode($x);
}
return '[]';
}
function cnd_json_decode($x, $n) {
if (function_exists('json_decode')) {
return json_decode($x, true);
}
return [];
}
function ntrim($str) {
if (is_string($str)) {
$x = trim($str);
if (mb_strlen($x, 'UTF-8')) {
return $x;
}
}
return null;
}
function ntrima($in_a, $key) {
if (is_array($in_a)) {
return ntrim(array_key_exists($key, $in_a) ? $in_a[$key] : null);
}
return null;
}
function mk_password($len) {
$literals = '12345678900987654321qwertyuiopPOIUYTREWQQWERTYUIOPpoiuytrewqasdfghjkllkjhgfdsaASDFGHJKLLKJHGFDSAzxcvbnmMNBVCXZZXCVBNMmnbvcxz+=&';
$len = intval($len);
$len < 6 ? $len = 6 : 0;
$r = [];
for ($i = 0; $i < $len; $i++) {
$r[] = mb_substr($literals, mt_rand(0, mb_strlen($literals, 'UTF-8')), 1, 'UTF-8');
}
return implode('', $r);
}
function mkPDOConnetionOptions(array $optionList) {
$extraOptions = [];
if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'pdo-options.php')) {
$extraOptions = require __DIR__ . DIRECTORY_SEPARATOR . 'pdo-options.php';
}
return $optionList + $extraOptions;
}
function check_db_connection_ph($retunComplex = false) {
try {
$alldata = get_post_data();
$db_data = array_key_exists('db', $alldata) && is_array($alldata['db']) ? $alldata['db'] : [];
if (!is_array($db_data)) {
throw new Exception(' ');
}
$keys = ['server', 'port', 'user', 'password', 'db', 'driver'];
foreach ($keys as $key) {
if (!array_key_exists($key, $db_data)) {
throw new Exception(" : `{$key}`");
}
}
$server = ntrima($db_data, 'server');
if (!$server) {
throw new Exception(" ");
}
$port = ntrima($db_data, 'port');
if ($port !== null) {
if (!intval($port)) {
throw new Exception(" ");
}
}
$user = ntrima($db_data, 'user');
if (!$user) {
throw new Exception(" ");
}
$password = ntrima($db_data, 'password');
if (!$password) {
throw new Exception(" ");
}
$db = ntrima($db_data, 'db');
if (!$db) {
throw new Exception(" ");
}
$driver = ntrima($db_data, 'driver');
if (!$driver) {
throw new Exception("No PDO driver defined");
}
if ($driver === 'mysql') {
$pdo = new PDO(sprintf('mysql:host=%s;port=%s;dbname=%s;charset=utf8', $server, ($port ? $port : 3306), $db), $user, $password,
mkPDOConnetionOptions([
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
]));
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$statement = $pdo->prepare('SELECT @@VERSION');
$statement->execute([]);
$version = null;
$version_row = $statement->fetch(\PDO::FETCH_NUM);
$statement->closeCursor();
if ($version_row && is_array($version_row) && array_key_exists(0, $version_row)) {
$version = $version_row[0];
}
if (!$version) {
throw new Exception(' mySQL');
}
if ($retunComplex) {
return ['version' => $version, 'pdo' => $pdo];
}
return $version;
} else if ($driver === 'pgsql') {
//pgsql:host=localhost;port=5432;dbname=testdb;user=bruce;password=mypass
$pdo = new PDO(sprintf('pgsql:host=%s;port=%s;dbname=%s;user=%s;password=%s', $server, ($port ? $port : 5432), $db, $user, $password),null,null,
mkPDOConnetionOptions([
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
]));
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$statement = $pdo->prepare('SELECT version();');
$statement->execute([]);
$version = null;
$version_row = $statement->fetch(\PDO::FETCH_NUM);
$statement->closeCursor();
if ($version_row && is_array($version_row) && array_key_exists(0, $version_row)) {
$version = $version_row[0];
}
if (!$version) {
throw new Exception(' pgsql');
}
if ($retunComplex) {
return ['version' => $version, 'pdo' => $pdo];
}
return $version;
}
} catch (\Throwable $e) {
throw $e;
}
}
function get_post_data() {
$data_str = array_key_exists('data', $_POST) ? $_POST['data'] : null;
$data = [];
if ($data_str) {
$data = @cnd_json_decode($data_str, true);
}
$data = is_array($data) ? $data : [];
return $data;
}
function sql_driver_by_version($version) {
$driver = 'mysql5';
if(preg_match("/postgres/i", $version)){
$driver='pgsql';
}else if (preg_match("/maria/i", $version)) {
$driver = 'maria';
} else {
$m = [];
if (preg_match("/^(?P<maj>\d{1,})\.(\d{1,})/", $version, $m)) {
if (intval($m['maj']) >= 8) {
$driver = 'mysql8';
}
}
}
return $driver;
}
function parse_steps_pg(){
$alist = explode('-- --------------------------------------------------------', load_file('postgres.sql'));
$clean_steps = [];
foreach ($alist as $task) {
$task_name = 'opertaion';
$m = [];
if (preg_match("/DBTASK\:(?P<tsk>.*)$/m", $task, $m)) {
$task_name = trim($m['tsk']);
}
$clean_steps[] = ['name' => $task_name, 'task' => $task];
}
return $clean_steps;
}
function parse_steps($version) {
$driver = sql_driver_by_version($version);
if($driver==='pgsql'){
return parse_steps_pg();
}
$alist = explode('-- --------------------------------------------------------', load_file('sql.sql'));
$clean_steps = [];
foreach ($alist as $task) {
$task_name = 'opertaion';
$m = [];
if (preg_match("/DBTASK\:(?P<tsk>.*)$/m", $task, $m)) {
$task_name = trim($m['tsk']);
}
// if (mb_strpos($task, "DRIVER:~{$driver}", 0, 'UTF-8') !== false) {
// continue;
// }
if (mb_strpos($task, "DRIVER:", 0, 'UTF-8') !== false) {
if (mb_stripos($task, "DRIVER:{$driver}", 0, 'UTF-8') === false) {
continue;
}
}
$clean_steps[] = ['name' => $task_name, 'task' => $task];
}
return $clean_steps;
}
function do_out($content, $step) {
while (ob_get_level()) {
ob_end_clean();
}
?>
<!DOCTYPE html>
<html lang="ru">
<head>
<style type="text/css">
html,body {
font-size: 14px;
font-family: arial,sans-serif;
margin: 0;
padding: 0;
height: 100%;
max-height: 100%;
overflow: hidden;
}
body {
background: #48a2ef;
color: white;
}
.InstallerScreen {
box-sizing: border-box;
width: 100%;
height: 100%;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
.popup-backdrop {
position: fixed;
display:none;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.5);
}
.popup-backdrop-content {
box-sizing: border-box;
width: 100%;
height: 100%;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
.popup-window {
background: white;
padding: .5em;
box-sizing: border-box;
max-height: 100%;
width: 100%;
max-width: 640px;
border-radius: 3px;
box-shadow: 3px 3px 10px #322e2e;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: stretch;
}
.popup-header {
color: black;
height: 24px;
display: flex;
min-height: 24px;
max-height: 24px;
flex-direction: row;
justify-content: space-between;
align-items: center;
flex-wrap: nowrap;
}
.popup-header-text {
font-weight: bold;
font-size: 16px;
}
.popup-header-close {
box-sizing: border-box;
width: 24px;
height: 24px;
min-width: 24px;
max-width: 24px;
cursor: pointer;
position:relative;
overflow:hidden;
}
.popup-header-close:before,.popup-header-close:after{
content:' ';
box-sizing:border-box;
border-left:1px solid black;
border-right:1px solid black;
width:2px;
position:absolute;
top:-25%;
left:50%;
margin-left:-1px;
height:150%;
transform-origin:center center;
}
.popup-header-close:before{
transform:rotate(-45deg);
}
.popup-header-close:after{
transform:rotate(45deg);
}
.popup-body {
height: 100%;
box-sizing: border-box;
padding: .5em;
overflow: auto;
}
.popup-body-content {
min-height: 50px;
color: black;
}
.Installer-intro-header {
font-size: 26px;
text-align: center;
margin-bottom: 10px;
}
.installer-intro-text a {
color: #3e3c3c;
font-weight: bold;
}
.installer-intro-content form {
margin: 0;
margin-top: 20px;
text-align: center;
}
.form-btn {
display: inline-block;
line-height: 36px;
border: 1px solid white;
background: white;
color: black;
padding: 0 2em;
box-shadow: 1px 1px 1px black;
transition: all .3s;
cursor: pointer;
user-select: none;
}
.form-btn:hover {
box-shadow: -1px -1px 1px dimgray;
}
.InstallerScreen.InstallerScreen1 {
box-sizing: border-box;
width: 100%;
height: 100%;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
.installer-checks-window-backdrop {
box-sizing: border-box;
width: 100%;
height: 100%;
overflow: hidden;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
flex-wrap: nowrap;
}
.installer-checks-window {
background: white;
border-radius: 3px;
color: black;
box-sizing: border-box;
padding: .5em;
box-shadow: 3px 3px 10px #707070;
max-height: 95%;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: stretch;
}
.InstallerScreen.InstallerScreen1 {
}
.installer-compatibility-text {
font-size: 13px;
}
.InstallerScreen1 .Installer-intro-header {
height: 46px;
max-height: 46px;
min-height: 46px;
}
.installer-checks-window form {
box-sizing: border-box;
height: 40px;
max-height: 40px;
min-height: 40px;
overflow: hidden;
}
.installer-compatibility-list-scr {
height: 100%;
overflow: auto;
padding: .5em;
}
ul.installer-compatibility-list li {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: flex-start;
flex-wrap: nowrap;
}
ul.installer-compatibility-list {
padding: 0 1em;
}
.installer-check-notice {
width: 100%;
margin-left: 10px;
}
li.installer-check-success b {
white-space: nowrap;
}
li.installer-check-success .installer-check-notice {
color: green;
}
.installer-checks-window form {
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: center;
}
.installer-checks-window form .form-btn {
border: 1px solid #48a2ef;
background: #48a2ef;
color: white;
}
ul.installer-compatibility-list li b {
white-space: nowrap;
}
ul.installer-compatibility-list li {
margin-bottom: 10px;
}
li.installer-check-warning .installer-check-notice {
color: darkorange;
}
li.installer-check-failed .installer-check-notice {
color: crimson;
}
table.installer-compatibility-table {
border: none;
border-collapse: collapse;
width: 100%;
box-sizing: border-box;
max-width: 100%;
overflow: hidden;
margin: 10px 0;
}
.installer-compatibility-list-scr {
box-sizing: border-box;
}
table.installer-compatibility-table tr {
box-sizing: border-box;
overflow: hidden;
}
table.installer-compatibility-table tr td {
padding-top: 5px;
padding-bottom: 5px;
box-sizing: border-box;
vertical-align: top;
}
td.installer-check-name {
font-weight: bold;
white-space: nowrap;
}
tr.installer-check-success td.installer-check-notice-cell {
color: green;
}
tr.installer-check-warning td.installer-check-notice-cell {
color: darkorange;
}
tr.installer-check-failed td.installer-check-notice-cell {
color: crimson;
}
.installer-checks-window form {
justify-content: space-between;
margin-top: 10px;
}
.InstallerScreen.InstallerScreen2 {
}
.installer-db-window-backdrop {
box-sizing: border-box;
width: 100%;
height: 100%;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
.installer-db-window {
box-sizing: border-box;
/* width: 100%; */
max-width: 640px;
background: white;
padding: 10px;
border-radius: 3px;
box-shadow: 3px 3px 10px #666565;
color: black;
max-height: 95%;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: stretch;
}
.Installer-intro-header {
height: 46px;
max-height: 46px;
min-height: 46px;
}
form#step2form {
height: 50px;
max-height: 50px;
min-height: 50px;
border-top: 1px solid silver;
margin-top: 10px;
}
.installer-db-form {
height: 100%;
overflow: auto;
padding: 5px;
}
.installer-db-form form {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.db-form-row {
box-sizing: border-box;
margin-bottom: 10px;
}
.db-form-row input[type=text] {
box-sizing: border-box;
width: 100%;
display: block;
box-shadow: none;
height: 3em;
border: 1px solid silver;
outline: none;
border-radius: 0;
padding: 0 .5em;
box-sizing: border-box;
min-width: 30em;
}
.db-form-row label {
display: block;
margin-bottom: 3px;
font-size: .9em;
}
.db-form-row input[type=checkbox] {
display: none;
}
.db-form-row input[type=checkbox]+label{
font-size:inherit;
display:flex;
flex-direction:row;
justify-content:flex-start;
align-items:center;
padding:1px;
cursor:pointer;
user-select:none;
}
.db-form-row input[type=checkbox]+label:before{
content:' ';
box-sizing:border-box;
outline-offset:0;
outline:1px solid #00acc8;
margin-right:.5em;
width:1.25em;
min-width:1.25em;
max-width:1.25em;
height:1.25em;
min-height:1.25em;
max-height:1.25em;
line-height:0;
transition:all .3s;
}
.db-form-row input[type=checkbox]:checked+label:before{
border:1px solid white;
background:#00acc8;
}
.db-form-button-row .form-btn {
background: #00acc8;
border: 1px solid #00acc8;
color: white;
}
.db-form-button-row {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
div#db-check-result {
margin: 10px 0;
font-size: .9em;
color: crimson;
}
.db-form-note {
box-sizing: border-box;
margin: 10px 0;
padding: 10px;
border: 1px solid red;
border-radius: 3px;
background: yellow;
}
div#db-check-result.success {
color: green;
}
form#step2form {
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: center;
}
div#step2submit {
background: #48a2ef;
border: #48a2ef;
color: white;
}
.db-form-button-row .form-btn {
background: #48a2ef;
border: #48a2ef;
}
form#step3form {
height: 45px;
min-height: 45px;
max-height: 45px;
margin-top: 10px;
border-top: 1px solid silver;
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: center;
}
div#step3submit {
border-color: #48a2ef;
background: #48a2ef;
color: white;
}
.db-create-progress {
box-sizing: border-box;
position: relative;
display: block;
width: 100%;
border: 1px solid silver;
height: 36px;
}
.db-create-progress-element {
box-sizing: border-box;
position: absolute;
top: 0;
left: 0;
height: 100%;
background: #48a2ef;
width: 17%;
max-width: 100%;
transition: all .5s;
}
.db-create-progress-tesxt {
box-sizing: border-box;
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
font-weight: bold;
font-size: 24px;
color: maroon;
}
form#step4form {
box-sizing: border-box;
height: 50px;
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: center;
border-top: 1px solid silver;
}
div#step4submit {
background: #48a2ef;
border: #48a2ef;
color: white;
}
.db-create-progress-info {
font-size: .9em;
margin: 5px 0;
color: black;
white-space: nowrap;
max-width: 1px;
width:1px;
overflow:visible;
box-sizing: border-box;
}
.db-create-progress-info-container{
box-sizing: border-box;
width:100%;
max-width:100%;
overflow:hidden;
}
.db-create-progress-info.warning {
color: crimson;
}
.db-create-progress-info.success {
color: green;
}
form#step5form {
box-sizing: border-box;
margin-top: 10px;
height: 50px;
max-height: 50px;
min-height: 50px;
border-top: 1px solid silver;
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: center;
}
div#step5submit {
background: #48a2ef;
color: white;
border: 1px solid #48a2ef;
}
form#stepxform {
height: 50px;
min-height: 50px;
max-height: 50px;
border-top: 1px solid silver;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
div#stepxsubmit {
color: white;
background: #48a2ef;
border-color: #48a2ef;
margin-left: auto;
}
.popup-backdrop {
top: 0;
left: 0;
}
.path-info {
box-sizing: border-box;
font-size: 12px;
}
.path-info-header {
font-weight: bold;
}
.path-info-image {
box-sizing: border-box;
padding: .5em;
}
.path-item {
padding-left: 1em;
}
.path-info-image {
}
.path-info-image>.path-item {
padding-left: 0;
}
.path-item-header {
box-sizing: border-box;
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
}
.path-item-header i {
width: 1.5em;
min-width: 1.5em;
max-width: 1.5em;
height: 1.5em;
margin-right: .5em;
}
.path-item-header i svg {
box-sizing: border-box;
width: 100%;
height: 100%;
}
span.path-cmt {
margin-left: .5em;
font-size: .9em;
font-style: italic;
}
.path-item-header {
margin-bottom: 5px;
}
.ignore-upport {
box-sizing: border-box;
color: black;
margin: 3px 0 5px 0;
}
.installer-check-notice a#fs_req_btn {
color: #787878;
font-weight: bold;
}
.ignore-upport input[type=checkbox] {
display: none;
}
.ignore-upport input[type=checkbox]+label{
box-sizing:border-box;
padding:1px;
display:flex;
flex-direction:row;
align-items:center;
justify-content:flex-start;
cursor:pointer;
}
.ignore-upport input[type=checkbox]+label:before{
content:' ';
width:1.25em;
min-width:1.25em;
max-width:1.25em;
margin-right:5px;
outline-offset:0;
outline:1px solid #00acc8;
height:1.25em;
transition:all .3s;
}
.ignore-upport input[type=checkbox]:checked+label:before{
border:1px solid white;
background:#00acc8;
}
.window-footer {
box-sizing: border-box;
height: 50px;
min-height: 50px;
max-height: 50px;
border-top: 1px solid silver;
margin-top: 10px;
}
.window-footer-content {
box-sizing: border-box;
width: 100%;
height: 100%;
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
}
.window-footer-content a.form-btn {
margin-left: auto;
background: #48a2ef;
border-color: #48a2ef;
color: white;
text-decoration: none;
}
.db-form-select {
box-sizing: border-box;
width: 100%;
outline: 1px solid silver;
height: 2.5em;
cursor: pointer;
margin: 0;
margin-bottom: 2em;
border: none;
box-shadow: none;
overflow: hidden;
position: relative;
}
.db-form-select > select{
margin:0;padding:0 0.5em;outline:none;box-shadow:none;appearance:none;border:none;width:100%;height:100%;box-sizing:border-box;cursor:pointer;
}
.db-form-select::after{
content: 'be';
width: 30px;
height: 100%;
position:absolute;
top:0;
right:0;
display: flex;
z-index: 1;
flex-direction: row;
justify-content: center;
align-items: center;
pointer-events: none;
color: dimgray;
font-size: 22px;
}
.db-form-note-inner textarea {
box-sizing: border-box;
width: 100%;
outline: none;
margin: .5em 0;
font-family: monospace;
resize: none;
height: 5em;
background: transparent;
background: rgba(0,0,0,0);
color: navy;
font-size: 12px;
}
</style>
<script>
function add_trg(tid, wid) {
var c = document.getElementById(tid);
if (c) {
c.addEventListener('click', function (e) {
e.stopPropagation();
e.preventDefault ? e.preventDefault() : e.returnValue = false;
var pop = document.getElementById(wid);
if (pop) {
pop.style.display = 'block';
}
});
}
}
function stop_props(id) {
var rqw = document.getElementById(id);
if (rqw) {
rqw.addEventListener('click', function (e) {
e.stopPropagation();
});
}
}
function add_ctrg(tid, wid) {
var c = document.getElementById(tid);
if (c) {
c.addEventListener('click', function (e) {
e.stopPropagation();
e.preventDefault ? e.preventDefault() : e.returnValue = false;
var pop = document.getElementById(wid);
if (pop) {
pop.style.display = 'none';
}
});
}
}
</script>
</head>
<body>
<div class="InstallerScreen InstallerScreen<?php echo $step ?>">
<?php echo $content ?>
</div>
<div style="display:none">
<?xml version="1.0" encoding="iso-8859-1"?>
<svg version="1.1" id="folder" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 317.826 317.826" style="enable-background:new 0 0 317.826 317.826;" xml:space="preserve">
<g>
<polygon style="fill:#13829B;" points="260.32,95.194 260.32,134.194 57.5,134.194 7.5,265.194 7.5,52.634 133.91,52.634
153.91,95.194 "/>
<g>
<polygon style="fill:#28D2E4;" points="310.32,134.194 260.32,265.194 7.5,265.194 57.5,134.194 "/>
<path style="fill:#22313F;" d="M310.32,126.693h-42.5v-31.5c0-4.142-3.358-7.5-7.5-7.5H158.672l-17.974-38.25
c-1.236-2.63-3.881-4.31-6.788-4.31H7.5c-4.142,0-7.5,3.358-7.5,7.5v212.56c0,4.092,3.335,7.501,7.504,7.501
c0.004,0,0.008-0.001,0.013-0.001H260.32c3.11,0,5.897-1.92,7.007-4.826l50-131C319.2,131.962,315.569,126.693,310.32,126.693z
M15,60.134h114.148l17.974,38.25c1.236,2.63,3.881,4.31,6.788,4.31h98.91v24H57.5c-3.11,0-5.898,1.92-7.007,4.826L15,224.511
V60.134z M255.155,257.693H18.39l44.275-116c10.806,0,225.962,0,236.765,0L255.155,257.693z"/>
</g>
</g>
</svg>
<?xml version="1.0" encoding="iso-8859-1"?>
<svg version="1.1" id="file" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 512.002 512.002" style="enable-background:new 0 0 512.002 512.002;" xml:space="preserve">
<path style="fill:#ECB45C;" d="M442.167,263.758h-23.273H255.985H93.076H69.803c-1.607,0-3.176,0.163-4.69,0.473
c-5.303,1.085-9.948,3.973-13.269,7.997c-3.32,4.023-5.314,9.18-5.314,14.803v201.697c0,3.213,0.652,6.274,1.829,9.059
c2.945,6.962,9.179,12.192,16.753,13.742c1.514,0.31,3.083,0.473,4.69,0.473h186.182h186.182c12.853,0,23.273-10.42,23.273-23.273
V287.03C465.44,274.178,455.02,263.758,442.167,263.758z"/>
<path style="fill:#E0E0E2;" d="M46.531,287.03c0-12.853,10.42-23.273,23.273-23.273h23.273h162.909h162.909h23.273
c12.853,0,23.273,10.42,23.273,23.273V179.018c-0.321,12.573-10.589,22.672-23.242,22.672c-0.012,0-0.022,0-0.031,0h-23.273H287.016
c-12.853,0-23.273-10.42-23.273-23.273V46.545V23.273c0-9.413,5.669-17.898,14.367-21.501c2.993-1.24,6.142-1.801,9.256-1.753
C287.248,0.016,287.133,0,287.016,0H69.803C56.951,0,46.531,10.42,46.531,23.273C46.531,23.273,46.531,287.03,46.531,287.03z"/>
<path style="fill:#C6C5CA;" d="M263.743,23.273v23.273v131.873c0,12.853,10.42,23.273,23.273,23.273h131.879h23.273
c0.009,0,0.019,0,0.031,0c12.653,0,22.921-10.1,23.242-22.672c0.005-0.202,0.031-0.397,0.031-0.6c0-4.822-1.486-9.286-3.998-13.002
c-0.003-0.005-0.006-0.009-0.009-0.014c-0.397-0.586-0.824-1.153-1.271-1.699c-0.036-0.045-0.071-0.092-0.109-0.137
c-0.424-0.512-0.875-1.001-1.339-1.474c-0.073-0.073-0.144-0.147-0.217-0.22c-0.205-0.2-0.394-0.419-0.605-0.613L303.472,6.816
c-0.483-0.484-0.991-0.936-1.508-1.37c-0.157-0.13-0.315-0.253-0.475-0.379c-0.375-0.299-0.763-0.59-1.159-0.867
c-0.189-0.132-0.379-0.264-0.571-0.389c-0.413-0.27-0.836-0.524-1.266-0.77c-0.166-0.095-0.33-0.199-0.498-0.289
c-0.562-0.301-1.14-0.577-1.728-0.833c-0.236-0.102-0.476-0.189-0.714-0.284c-0.389-0.155-0.784-0.299-1.184-0.433
c-0.27-0.09-0.541-0.177-0.813-0.256c-0.447-0.13-0.901-0.245-1.361-0.351c-0.202-0.047-0.403-0.102-0.608-0.144
c-0.645-0.129-1.303-0.227-1.967-0.299c-0.205-0.023-0.411-0.036-0.614-0.054c-0.541-0.045-1.086-0.074-1.638-0.082
c-3.114-0.048-6.263,0.515-9.256,1.753C269.414,5.374,263.743,13.86,263.743,23.273z"/>
<path style="fill:#57565C;" d="M271.263,348.017c-5.28,0-9.112,3.497-9.112,8.316v20.111h-6.166h-6.853v-20.111
c0-4.741-3.916-8.316-9.112-8.316c-5.278,0-9.109,3.497-9.109,8.316v59.933c0,4.763,4.001,8.496,9.109,8.496
c5.109,0,9.112-3.731,9.112-8.496v-22.393h6.853h6.166v22.393c0,4.763,4.003,8.496,9.112,8.496c5.109,0,9.112-3.731,9.112-8.496
v-59.933C280.375,351.592,276.459,348.017,271.263,348.017z"/>
<path style="fill:#FF9811;" d="M193.678,365.798h-6.467v15.486h6.467c4.082,0,6.294-1.157,6.294-7.26v-1.052
C199.972,366.94,197.76,365.798,193.678,365.798z"/>
<g>
<path style="fill:#57565C;" d="M193.853,348.017h-16.195c-0.121,0-0.24,0.003-0.36,0.011c-4.735,0.276-8.307,3.848-8.307,8.307
v59.933c0,4.763,4,8.495,9.106,8.495c5.109,0,9.112-3.731,9.112-8.495v-17.557h6.467c15.349,0,24.512-9.328,24.512-24.95v-0.881
C218.19,357.312,209.094,348.017,193.853,348.017z M199.972,374.024c0,6.102-2.212,7.26-6.294,7.26h-6.467v-15.486h6.467
c4.082,0,6.294,1.143,6.294,7.174V374.024z"/>
<path style="fill:#57565C;" d="M321.745,348.017h-16.19c-0.119,0-0.24,0.003-0.36,0.011c-4.737,0.275-8.308,3.846-8.308,8.307
v59.933c0,4.763,4,8.495,9.106,8.495c5.109,0,9.112-3.731,9.112-8.495v-17.557h6.467c15.349,0,24.512-9.328,24.512-24.95v-0.881
C346.082,357.312,336.984,348.017,321.745,348.017z M327.862,374.024c0,6.102-2.212,7.26-6.295,7.26h-6.467v-15.486h6.467
c4.082,0,6.295,1.143,6.295,7.174V374.024z"/>
</g>
<path style="fill:#FF9811;" d="M249.132,393.874v22.393c0,4.763-4.003,8.495-9.112,8.495c-5.108,0-9.109-3.731-9.109-8.495v-59.933
c0-4.819,3.831-8.316,9.109-8.316c5.196,0,9.112,3.575,9.112,8.316v20.111h6.853V263.758H93.076H69.803
c-12.853,0-23.273,10.42-23.273,23.273v201.697c0,12.853,10.42,23.273,23.273,23.273h186.182V393.874H249.132z M218.19,373.762
c0,15.622-9.163,24.95-24.512,24.95h-6.467v17.557c0,4.763-4.003,8.495-9.112,8.495c-5.106,0-9.106-3.731-9.106-8.495v-59.933
c0-4.459,3.572-8.029,8.307-8.307c0.119-0.006,0.239-0.011,0.36-0.011h16.195c15.239,0,24.337,9.295,24.337,24.861v0.883H218.19z"/>
</svg>
</div>
<div class="popup-backdrop" id="fs-req-backdrop" style="display:none">
<div class="popup-backdrop-content">
<div class="popup-window" id="fs-req-window">
<div class="popup-header"><div class="popup-header-text"> :</div><div id="fs-req-clo" class="popup-header-close"></div></div>
<div class="popup-body">
<div class="popup-body-content">
<div class="path-info">
<div class="path-info-header"> :</div>
<div class="path-info-image">
<div class="path-item">
<div class="path-item-header"><i><svg><use xlink:href="#folder"/></svg></i><span class="path-name">leader_map</span><span class="path-cmt"><-- </span></div>
<div class="path-item">
<div class="path-item-header"><i><svg><use xlink:href="#folder"/></svg></i><span class="path-name"><b style="color:crimson">www</b></span><span class="path-cmt"><-- webroot , www <b></b></span></div>
<div class="path-item">
<div class="path-item-header"><i><svg><use xlink:href="#file"/></svg></i><span class="path-name">installer.php</span><span class="path-cmt"><-- webroot</span></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
add_trg('fs_req_btn', 'fs-req-backdrop');
stop_props('fs-req-window');
add_ctrg('fs-req-backdrop', 'fs-req-backdrop');
add_ctrg('fs-req-clo', 'fs-req-backdrop');
</script>
</body>
</html>
<?php
die();
}
function load_file($filename) {
$raw = file_get_contents(__FILE__);
$search = 'ec3f1dccb0ed444' . '' . '990bf08a48a1fbf2f' . ':' . "{$filename}@";
$found = strpos($raw, $search);
if ($found !== null) {
$offset = $found + strlen($search);
$length_str = substr($raw, $offset, 10);
$len_int = intval($length_str);
$encoded = substr($raw, $offset + 10, $len_int);
$file_content = bzdecompress($encoded);
if (false !== $file_content && !is_int($file_content)) {
return $file_content;
} else if (is_int($file_content)) {
throw new Exception(' ');
}
}
return null;
}
function get_redis_version($redis_data) {
if (!is_array($redis_data)) {
throw new Exception(' ');
}
$keys = ['server', 'port', 'password'];
foreach ($keys as $key) {
if (!array_key_exists($key, $redis_data)) {
throw new Exception(" `{$key}`");
}
}
$server = ntrima($redis_data, 'server');
if (!$server) {
throw new Exception(" ");
}
$port = ntrima($redis_data, 'port');
if ($port !== null) {
if (!intval($port)) {
throw new Exception(" ");
}
}
$password = ntrima($redis_data, 'password');
$redis = new Redis();
if ($port) {
$redis->connect($server, $port);
} else {
$redis->connect($server);
}
if ($password) {
$redis->auth($password);
}
$ping = $redis->ping(time());
$key = 'installer_96f8076de0214d8b95adae036a91e15f';
$value = 'installer_ca59591c0f574d719e46665fb88d4052';
$redis->set($key, $value);
if ($redis->get($key) !== $value) {
throw new Exception("redis: read value difers");
}
$server_info = $redis->info('SERVER');
$version = 'unknown';
$arc = 'unknown';
if (is_array($server_info)) {
if (array_key_exists('redis_version', $server_info)) {
$version = $server_info['redis_version'];
}
if (array_key_exists('arch_bits', $server_info)) {
$arc = $server_info['arch_bits'];
}
}
return implode(' x', [$version, $arc]);
}
/**
*
* @param string $xml
* @return \DateTime
*/
function xml_2_datetime($xml) {
if (is_string($xml)) {
$m = [];
if (preg_match('/^(?P<y>\d{4})-(?P<m>\d{1,2})-(?P<d>\d{1,2})T(?P<h>\d{1,2}):(?P<i>\d{1,2}):(?P<s>\d{1,2})/', $xml, $m)) {
$d = new DateTime();
$d->setDate(intval($m['y']), intval($m['m']), intval($m['d']));
$d->setTime(intval($m['h']), intval($m['i']), intval($m['s']));
return $d;
}
}
return null;
}
function is_windows_os() {
if (defined('PHP_OS_FAMILY')) {
if (mb_strtoupper(mb_substr(PHP_OS_FAMILY, 0, 3, 'UTF-8'), 'UTF-8') === 'WIN') {
return true;
}
} else if (defined('PHP_OS')) {
if (mb_strtoupper(mb_substr(PHP_OS, 0, 3, 'UTF-8'), 'UTF-8') === 'WIN') {
return true;
}
}
return false;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="checks">
function checkphpver() {
if (version_compare(PHP_VERSION, '7.2.0', '>=')) {
return ['status' => true, 'message' => 'OK'];
}
return ['status' => false, 'message' => ' php7.2+'];
}
function checkmbstring() {
if (function_exists('mb_strlen')) {
return ['status' => true, 'message' => 'OK'];
}
return ['status' => false, 'message' => ' mbstrings'];
}
function checkjson() {
if (function_exists('json_encode')) {
return ['status' => true, 'message' => 'OK'];
}
return ['status' => false, 'message' => ' JSON'];
}
function checkDOM() {
$fails = [];
if (!function_exists('libxml_clear_errors')) {
$fails[] = " libxml";
}
if (!class_exists('\XMLWriter')) {
$fails[] = " XMLWriter";
}
if (!class_exists('\DOMDocument')) {
$fails[] = " DOM";
}
if (!count($fails)) {
return ['status' => true, 'message' => 'OK'];
}
return ['status' => false, 'message' => implode("
", $fails)];
}
function checkcurl() {
if (function_exists('curl_init') && class_exists('\CURLFile')) {
return ['status' => true, 'message' => 'OK'];
} else if (function_exists('curl_init')) {
return ['status' => false, 'message' => ' libcUrl'];
}
return ['status' => false, 'message' => ' cUrl'];
}
function checkopenssl() {
if (function_exists('openssl_random_pseudo_bytes')) {
if (false === @openssl_random_pseudo_bytes(100)) {
return ['status' => false, 'message' => 'libopenssl '];
} else {
return ['status' => true, 'message' => 'OK'];
}
}
return ['status' => false, 'message' => ' OpenSSL'];
}
function checkldap() {
if (function_exists('ldap_bind')) {
return ['status' => true, 'message' => 'OK'];
}
return ['status' => false, 'message' => ' ldap (ActiveDirectory) ldap'];
}
function checkimagick() {
if (class_exists('\Imagick')) {
return ['status' => true, 'message' => 'OK'];
}
return ['status' => false, 'message' => ' IMagick'];
}
function checkzips() {
$fails = [];
if (!class_exists('\ZipArchive')) {
$fails[] = " zip";
}
if (!function_exists('gzencode')) {
$fails[] = " zlib";
}
if (!function_exists('bzcompress')) {
$fails[] = " bzip2";
}
if (!count($fails)) {
return ['status' => true, 'message' => 'OK'];
}
return ['status' => false, 'message' => implode("
", $fails)];
}
function checkphar() {
$fails = [];
if (class_exists('\Phar')) {
if (!Phar::canCompress(Phar::GZ)) {
$fails[] = ' Phar::GZ';
}
if (version_compare(Phar::apiVersion(), '1.1.1', '<')) {
$fails[] = " Phar 1.1.1+";
}
} else {
$fails[] = " Phar";
}
if (!count($fails)) {
return ['status' => true, 'message' => 'OK'];
}
return ['status' => false, 'message' => implode("
", $fails)];
}
function checkhash() {
if (function_exists('hash_hmac')) {
return ['status' => true, 'message' => 'OK'];
}
return ['status' => false, 'message' => ' hash'];
}
function checkredis() {
if (class_exists('\Redis')) {
return ['status' => true, 'message' => 'OK'];
}
return ['status' => false, 'message' => ' redis'];
}
function checkpdo() {
if (class_exists('\PDO')) {
return ['status' => true, 'message' => 'OK'];
}
return ['status' => false, 'message' => ' PDO'];
}
function pdo_driver_exists($driver) {
if (class_exists('\PDO')) {
$drivers = PDO::getAvailableDrivers();
$dm = array_combine($drivers, $drivers);
if (array_key_exists($driver, $dm)) {
return true;
}
}
return false;
}
function checkpdomysql() {
$msq = pdo_driver_exists('mysql');
$psq = pdo_driver_exists('pgsql');
if ($msq && $psq) {
return ['status' => true, 'message' => 'mysql: OK, pgsql: OK'];
}else if($msq){
return ['status' => true, 'message' => 'mysql: OK'];
}else if($psq){
return ['status' => true, 'message' => 'pgsql: OK'];
}
return ['status' => false, 'message' => ' PDO::mysql PDO::pgsql'];
}
function get_webroot() {
$webroot = __DIR__;
if (array_key_exists('DOCUMENT_ROOT', $_SERVER)) {
$webroot = $_SERVER['DOCUMENT_ROOT'];
}
$stripped_root = trim(str_ireplace($webroot, '', __FILE__), DIRECTORY_SEPARATOR);
if (count(explode(DIRECTORY_SEPARATOR, $stripped_root)) > 1) {
throw new Exception(" .");
}
return rtrim($webroot, DIRECTORY_SEPARATOR);
}
function get_webroot_name() {
return pathinfo(__DIR__, PATHINFO_FILENAME);
}
function get_install_dir() {
return rtrim(dirname(__DIR__), DIRECTORY_SEPARATOR);
}
function checkfs() {
$notes = [];
$webroot = __DIR__;
if (array_key_exists('DOCUMENT_ROOT', $_SERVER)) {
$webroot = $_SERVER['DOCUMENT_ROOT'];
} else {
$notes[] = " DOCUMENT_ROOT .";
}
$stripped_root = trim(str_ireplace($webroot, '', __FILE__), DIRECTORY_SEPARATOR);
if (count(explode(DIRECTORY_SEPARATOR, $stripped_root)) > 1) {
$notes[] = " . <a href=\"#\" id=\"fs_req_btn\"> </a>";
}
if (!(is_dir($webroot) && is_readable($webroot) && is_writable($webroot))) {
$notes[] = " `{$webroot}` - .";
}
$webroot_name = pathinfo(__DIR__, PATHINFO_FILENAME);
if ($webroot_name !== 'www') {
$notes[] = ' www. <a href=\"#\" id=\"fs_req_btn\"> </a>';
}
$install_dir = rtrim(dirname(__DIR__), DIRECTORY_SEPARATOR);
if (!(is_dir($install_dir) && is_readable($install_dir) && is_writable($install_dir))) {
$notes[] = " `{$install_dir}` - .";
} else {
$founds = [];
$files = scandir($install_dir);
foreach ($files as $filename) {
if ($filename === $webroot_name || $filename === '.' || $filename === '..' || $filename === 'log' || $filename === 'mysql.dba.txt') {
continue;
}
$founds[] = $filename;
}
if (count($founds)) {
if (!(defined('DEBUG_MODE') && DEBUG_MODE === true)) {
$raw_data = get_post_data();
if (!(array_key_exists('ignoreupport', $raw_data) && intval($raw_data['ignoreupport']) === 1)) {
$notes[] = " `{$install_dir}` . <br> <a href=\"#\" id=\"fs_req_btn\"> </a><br><div class=\"ignore-upport\"><input type=\"checkbox\" id=\"ignore-upport-files\" /><label for=\"ignore-upport-files\"></label></div>";
}
}
}
}
$tempdir = sys_get_temp_dir();
if (!(file_exists($tempdir) && is_readable($tempdir) && is_writable($tempdir))) {
$notes[] = " `{$tempdir}` .";
}
if (!count($notes)) {
return ['status' => true, 'message' => " :
- : {$install_dir}
- WEBROOT: {$webroot}"];
}
return ['status' => false, 'message' => implode("
", $notes)];
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="step0">
function step_0() {
ob_start();
$all_data = get_post_data();
?>
<div class="installer-checks-window">
<div class="Installer-intro-header"> <div class="installer-compatibility-text"></div></div>
<div class="installer-intro-content">
<div class="installer-intro-text"> « ».<br>
.<br>
<a href="#" id="license_bt"> </a>,<br><a href="#" id="req_btn"> </a> <a href="#" id="fs_req_btn"> </a>.
</div>
<form method="POST" action="<?php $_SERVER['REQUEST_URI'] ?>" id="stepxform">
<input name="step" type="hidden" value="1"/>
<input name="data" type="hidden" value="" id="alldata"/>
<div class="form-btn" id="stepxsubmit"></div>
</form>
</div>
</div>
<div class="popup-backdrop" id="license-backdrop" style="display:none">
<div class="popup-backdrop-content">
<div class="popup-window" id="license-window">
<div class="popup-header"><div class="popup-header-text"> </div><div id="lic-clo" class="popup-header-close"></div></div>
<div class="popup-body">
<div class="popup-body-content">
« ».
, 30 ,
, .<br>
,
« ». , , ,
.
</div>
</div>
</div>
</div>
</div>
<div class="popup-backdrop" id="req-backdrop" style="display:none">
<div class="popup-backdrop-content">
<div class="popup-window" id="req-window">
<div class="popup-header"><div class="popup-header-text"> </div><div id="req-clo" class="popup-header-close"></div></div>
<div class="popup-body">
<div class="popup-body-content">
<ul>
<li>linux x64</li>
<li>nginx</li>
<li>redis5+</li>
<li>imagemagic</li>
<li>php7.2+, php-fpm, phar stream support, phar GZ support ( phar, json,mbstring php-common)
<ul>
<li>php-pdo</li>
<li>php-mysql php-pgsql</li>
<li>php-curl</li>
<li>php-openssl</li>
<li>php-bz2</li>
<li>php-zlib</li>
<li>php-zip</li>
<li>php-mbstring</li>
<li>php-redis</li>
<li>php-ldap (optional)</li>
<li>php-dom, php-xmlwriter, libxml</li>
<li>php-imagick</li>
<li>php-json</li>
</ul>
</li>
<li>mysql5.7.x/8.0+/maria10.2+</li>
<li> - sphinx3+, sphinx 3.4.1</li>
<li> ( .. IIS), </li>
</ul>
</div>
</div>
</div>
</div>
</div>
<script>
document.getElementById('alldata').value = JSON.stringify(<?php echo cnd_json_encode($all_data) ?>);
function add_trg(tid, wid) {
var c = document.getElementById(tid);
if (c) {
c.addEventListener('click', function (e) {
e.stopPropagation();
e.preventDefault ? e.preventDefault() : e.returnValue = false;
var pop = document.getElementById(wid);
if (pop) {
pop.style.display = 'block';
}
});
}
}
function stop_props(id) {
var rqw = document.getElementById(id);
if (rqw) {
rqw.addEventListener('click', function (e) {
e.stopPropagation();
});
}
}
function add_ctrg(tid, wid) {
var c = document.getElementById(tid);
if (c) {
c.addEventListener('click', function (e) {
e.stopPropagation();
e.preventDefault ? e.preventDefault() : e.returnValue = false;
var pop = document.getElementById(wid);
if (pop) {
pop.style.display = 'none';
}
});
}
}
add_trg('license_bt', 'license-backdrop');
add_trg('req_btn', 'req-backdrop');
stop_props('req-window');
stop_props('license-window');
add_ctrg('license-backdrop', 'license-backdrop');
add_ctrg('req-backdrop', 'req-backdrop');
add_ctrg('lic-clo', 'license-backdrop');
add_ctrg('req-clo', 'req-backdrop');
document.getElementById('stepxsubmit').addEventListener('click', function () {
var form = document.getElementById('stepxform');
if (form) {
form.submit();
}
});
</script>
<?php
do_out(ob_get_clean(), 0);
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="step1">
function step_1() {
//<editor-fold defaultstate="collapsed" desc="checks stubs">
$checks = [
' php' => [
'handler' => 'checkphpver',
'status' => false,
'response' => ''
],
' ' => [
'handler' => 'checkfs',
'status' => false,
'response' => ''
],
' mbstrings' => [
'handler' => 'checkmbstring',
'status' => false,
'response' => ''
],
' json' => [
'handler' => 'checkjson',
'status' => false,
'response' => ''
],
'libxml (DOM,XML,XMLWriter...)' => [
'handler' => 'checkDOM',
'status' => false,
'response' => ''
],
' cUrl' => [
'handler' => 'checkcurl',
'status' => false,
'response' => ''
],
' OpenSSL' => [
'handler' => 'checkopenssl',
'status' => false,
'response' => ''
],
' LDAP' => [
'handler' => 'checkldap',
'status' => false,
'response' => '',
'severity' => 1,
],
' Imagick' => [
'handler' => 'checkimagick',
'status' => false,
'response' => ''
],
' ' => [
'handler' => 'checkzips',
'status' => false,
'response' => ''
],
' Phar' => [
'handler' => 'checkphar',
'status' => false,
'response' => ''
],
' Hash' => [
'handler' => 'checkhash',
'status' => false,
'response' => ''
],
' Redis' => [
'handler' => 'checkredis',
'status' => false,
'response' => ''
],
' PDO' => [
'handler' => 'checkpdo',
'status' => false,
'response' => ''
],
' PDO mysql pgsql ' => [
'handler' => 'checkpdomysql',
'status' => false,
'response' => ''
]
];
//</editor-fold>
foreach ($checks as $key => $value) {
if (function_exists($value['handler'])) {
$res = call_user_func($value["handler"]);
$checks[$key]['status'] = $res['status'];
$checks[$key]['response'] = $res['message'];
} else {
$checks[$key]['response'] = " ";
$checks[$key]['status'] = false;
}
}
ob_start();
?>
<div class="installer-checks-window-backdrop">
<div class="installer-checks-window">
<div class="Installer-intro-header"> <div class="installer-compatibility-text"> </div></div>
<div class="installer-compatibility-list-scr">
<table class="installer-compatibility-table">
<?php $failed_checks = 0; ?>
<?php foreach ($checks as $key => $result) { ?>
<?php $warning = !!(array_key_exists('severity', $result) && intval($result['severity']) === 1) ?>
<tr class="installer-check-<?php echo $result['status'] ? 'success' : ($warning ? 'warning' : 'failed') ?>">
<td class="installer-check-name"><?php echo $key ?>:</td>
<td class="installer-check-notice-cell">
<div class="installer-check-notice"><?php echo nl2br($result['response']) ?></div>
</td>
</tr>
<?php
if (!$result['status'] && !$warning) {
$failed_checks++;
}
?>
<?php
}
$all_data = get_post_data();
$all_data['failed_checks'] = $failed_checks;
?>
</table>
</div>
<form method="POST" action="<?php $_SERVER['REQUEST_URI'] ?>" id="stepxform">
<input name="step" type="hidden" value="1" id="form-step-value"/>
<input name="data" type="hidden" value="" id="alldata" />
<div class="form-btn" id="stepxresubmit"></div>
<?php if (!$failed_checks) { ?>
<div class="form-btn" id="stepxsubmit"></div>
<?php } ?>
</form>
</div>
</div>
<script>
var mysqlDriverSupported = parseInt('<?= pdo_driver_exists('mysql') ? '1' : '0' ?>') ? true : false;
var postgresSupported = parseInt('<?= pdo_driver_exists('pgsql') ? '1' : '0' ?>') ? true : false;
document.getElementById('alldata').value = JSON.stringify(<?php echo cnd_json_encode($all_data) ?>);
document.addEventListener('change', function (e) {
if (e.target.id === 'ignore-upport-files') {
var data = JSON.parse(document.getElementById('alldata').value);
data.ignoreupport = e.target.checked ? 1 : 0;
document.getElementById('alldata').value = JSON.stringify(data);
}
});
var btn = document.getElementById('stepxsubmit');
if (btn) {
btn.addEventListener('click', function () {
var nextStep = "2";
if (mysqlDriverSupported && !postgresSupported) {
nextStep = "2mysql";
var data = JSON.parse(document.getElementById('alldata').value);
data.dbDriver = "mysql";
document.getElementById('alldata').value = JSON.stringify(data);
} else if (postgresSupported && !mysqlDriverSupported) {
nextStep = "2pgsql";
var data = JSON.parse(document.getElementById('alldata').value);
data.dbDriver = "pgsql";
document.getElementById('alldata').value = JSON.stringify(data);
}
document.getElementById('form-step-value').value = nextStep;
document.getElementById('stepxform').submit();
});
}
var btn2 = document.getElementById('stepxresubmit');
if (btn2) {
btn2.addEventListener('click', function () {
document.getElementById('form-step-value').value = "1";
document.getElementById('stepxform').submit();
});
}
</script>
<?php
do_out(ob_get_clean(), 1);
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="step2">
function step_2() {
$all_data = get_post_data();
$db_data = array_key_exists('db', $all_data) && is_array($all_data['db']) ? $all_data['db'] : [];
$predefined = "mysql";
if (array_key_exists('driver', $db_data) && is_string($db_data['driver'])) {
$predefined = $db_data['driver'];
}
ob_start()
?>
<div class="installer-db-window-backdrop">
<div class="installer-db-window">
<div class="Installer-intro-header"> <div class="installer-compatibility-text"> </div></div>
<div class="installer-db-form">
<form id="db_form" onsubmit="return false;" ation="#" method="GET">
<div class="db-form-note">
<div class="db-form-note-inner">
PHP PDO MySQL/MariaDB PostgreSQL <br>
« ».
<div style="color:crimson;margin-top:1em;margin-bottom:1em;font-size: 0.9em"><b>!</b> .</div>
</div>
</div>
<div class="db-form-row">
<label for="db-input-type"> :</label>
<div class="db-form-select">
<select id="db-input-type">
<option value="mysql" <?= $predefined === "mysql" ? 'selected="selected"' : '' ?>>MySQL / MariaDB</option>
<option value="pgsql" <?= $predefined === "pgsql" ? 'selected="selected"' : '' ?>>PostreSQL</option>
</select>
</div>
<div style="font-size:0.9em;color:crimson;display:none;" id="driverTypeErr"> </div>
</div>
</form>
</div>
<form method="POST" action="<?php echo $_SERVER['REQUEST_URI'] ?>" id="stepxform">
<input name="step" type="hidden" value="2" id="form-step-value"/>
<input name="data" type="hidden" value="" id="alldata" />
<div class="form-btn" id="stepxsubmit" ></div>
</form>
</div>
</div>
<script>
document.getElementById('alldata').value = JSON.stringify(<?php echo cnd_json_encode($all_data) ?>);
var sel = document.getElementById('db-input-type');
var btn = document.getElementById('stepxsubmit');
var err = document.getElementById('driverTypeErr');
sel.addEventListener('change', function () {
err.style.display = 'none';
});
if (btn) {
btn.addEventListener('click', function () {
var t = sel.value;
if (t === 'mysql') {
var idata = JSON.parse(document.getElementById('alldata').value);
var dbData = idata.db;
if (!dbData || typeof (dbData) !== 'object') {
dbData = {};
}
dbData.driver = 'mysql';
document.getElementById('alldata').value = JSON.stringify(idata);
document.getElementById('form-step-value').value = "2mysql";
} else if (t === 'pgsql') {
var idata = JSON.parse(document.getElementById('alldata').value);
var dbData = idata.db;
if (!dbData || typeof (dbData) !== 'object') {
dbData = {};
}
dbData.driver = 'pgsql';
document.getElementById('alldata').value = JSON.stringify(idata);
document.getElementById('form-step-value').value = "2pgsql";
} else {
err.style.display = 'block';
return;
}
document.getElementById('stepxform').submit();
});
}
</script>
<?php
do_out(ob_get_clean(), 2);
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="step2mysql">
function step_2mysql() {
$all_data = get_post_data();
$db_data = array_key_exists('db', $all_data) && is_array($all_data['db']) ? $all_data['db'] : [];
$predefined = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'mysql.dba.txt';
$raw_data = (file_exists($predefined) && is_file($predefined) && is_readable($predefined)) ? file_get_contents($predefined) : null;
$predefined_password = null;
$predefined_user = null;
if ($raw_data) {
$raw_a = explode(':', $raw_data, 2);
if (count($raw_a) === 2) {
$predefined_user = $raw_a[0];
$predefined_password = $raw_a[1];
}
}
ob_start()
?>
<div class="installer-db-window-backdrop">
<div class="installer-db-window">
<div class="Installer-intro-header"> <div class="installer-compatibility-text"> </div></div>
<div class="installer-db-form">
<form id="db_form" onsubmit="return false;" ation="#" method="GET">
<div class="db-form-note">
<div class="db-form-note-inner">
MySQL .<br>
, .
<?php if ($predefined_password) { ?>
<b style="display:block;color:crimson"> </b>
<?php } ?>
</div>
</div>
<div class="db-form-row">
<label for="db-input-server"></label>
<input type="text" value="<?php echo array_key_exists('server', $db_data) ? $db_data['server'] : ($predefined_password !== null ? '127.0.0.1' : '') ?>" placeholder="127.0.0.1" name="server" id="db-input-server"/>
</div>
<div class="db-form-row">
<label for="db-input-port"></label>
<input type="text" value="<?php echo array_key_exists('port', $db_data) ? $db_data['port'] : '3306' ?>" placeholder="3306" name="port" id="db-input-port"/>
</div>
<div class="db-form-row">
<label for="db-input-user"></label>
<input type="text" placeholder="db user" name="user" id="db-input-user" value="<?php echo ($predefined_user !== null ? $predefined_user : '') ?>"/>
</div>
<div class="db-form-row">
<label for="db-input-password"></label>
<input type="text" placeholder="" name="password" id="db-input-password" value="<?php echo ($predefined_password !== null ? $predefined_password : '') ?>"/>
</div>
<div class="db-form-row">
<label for="db-input-db"> </label>
<input type="text" value="" placeholder="leader_map" name="db" id="db-input-db"/>
</div>
<div class="db-form-row">
<input type="checkbox" name="create-user" id="db-input-create-user"/>
<label for="db-input-create-user"> </label>
</div>
<div class="db-form-row">
<label for="db-input-user-name"> </label>
<input type="text" value="" placeholder="= db-name" name="user-name" id="db-input-user-name" disabled="disabled"/>
</div>
<div class="db-form-row">
<label for="db-input-user-host"> </label>
<input type="text" value="%" placeholder="%" name="user-host" id="db-input-user-host" disabled="disabled"/>
</div>
<div class="db-form-row">
<label for="db-input-user-password"> </label>
<input type="text" value="" placeholder="" name="user-password" id="db-input-user-password" disabled="disabled"/>
</div>
<div class="db-check-result" id="db-check-result">
</div>
<div class="db-form-button-row">
<div class="form-btn" id="db-check"></div>
<div class="form-btn" id="db-apply"> </div>
</div>
</form>
</div>
<form method="POST" action="<?php echo $_SERVER['REQUEST_URI'] ?>" id="stepxform">
<input name="step" type="hidden" value="3" id="form-step-value"/>
<input name="data" type="hidden" value="" id="alldata" />
<div class="form-btn" id="stepxsubmit" ></div>
</form>
</div>
</div>
<script>
document.getElementById('alldata').value = JSON.stringify(<?php echo cnd_json_encode($all_data) ?>);
var check = document.getElementById('db-input-create-user');
if (check) {
check.addEventListener('change', function () {
if (check.checked) {
document.getElementById('db-input-user-name').removeAttribute('disabled');
document.getElementById('db-input-user-host').removeAttribute('disabled');
document.getElementById('db-input-user-password').removeAttribute('disabled');
} else {
document.getElementById('db-input-user-name').setAttribute('disabled', 'disabled');
document.getElementById('db-input-user-host').setAttribute('disabled', 'disabled');
document.getElementById('db-input-user-password').setAttribute('disabled', 'disabled');
}
});
}
var btn = document.getElementById('stepxsubmit');
if (btn) {
btn.addEventListener('click', function () {
document.getElementById('form-step-value').value = "3";
var idata = JSON.parse(document.getElementById('alldata').value);
var dbData = idata.db;
if (!dbData || typeof (dbData) !== 'object') {
dbData = {};
idata.db=dbData;
}
dbData.driver = 'mysql';
document.getElementById('alldata').value = JSON.stringify(idata);
document.getElementById('stepxform').submit();
});
}
var dbc = document.getElementById('db-check');
function get_db_params() {
return {
server: document.getElementById('db-input-server').value,
port: document.getElementById('db-input-port').value,
user: document.getElementById('db-input-user').value,
password: document.getElementById('db-input-password').value,
db: document.getElementById('db-input-db').value,
create_user: document.getElementById('db-input-create-user').checked,
user_name: document.getElementById('db-input-user-name').value,
user_host: document.getElementById('db-input-user-host').value,
user_password: document.getElementById('db-input-user-password').value
};
}
function check_db_params(xo) {
xo.server = xo.server && (typeof (xo.server) === 'string') ? xo.server.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.server.length ? 0 : xo.server = null;
if (!xo.server) {
throw new Error(" MySQL/Maria");
}
xo.port = xo.port && (typeof (xo.port) === 'string') ? xo.port.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.port.length ? 0 : xo.port = null;
if (xo.port) {
var pt = parseInt(xo.port);
if (isNaN(pt)) {
throw new Error(' ');
}
}
xo.user = xo.user && (typeof (xo.user) === 'string') ? xo.user.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.user.length ? 0 : xo.user = null;
if (!xo.user) {
throw new Error(" CREATE DATABASE");
}
xo.password = xo.password && (typeof (xo.password) === 'string') ? xo.password.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.password.length ? 0 : xo.password = null;
if (!xo.password) {
throw new Error(" ");
}
xo.db = xo.db && (typeof (xo.db) === 'string') ? xo.db.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.db.length ? 0 : xo.db = null;
if (!xo.db) {
throw new Error(" ");
}
}
function db_checked(o) {
if (o.status === 'ok') {
var driver = 'mysql';
if (/maria/i.test(o.version)) {
driver = 'maria-db';
} else {
var m = /^(\d{1,}).\d{1,}/.exec(o.version);
if (m) {
var mi = parseInt(m[1]);
if (mi >= 8) {
driver = 'mysql8';
}
}
}
document.getElementById('db-check-result').innerHTML = [' ; : ', driver, '; : ', o.version].join('');
document.getElementById('db-check-result').classList.add('success');
var raw_data = JSON.parse(document.getElementById('alldata').value);
if (!raw_data.db) {
raw_data.db = {};
}
raw_data.db.server = document.getElementById('db-input-server').value;
raw_data.db.port = document.getElementById('db-input-port').value;
raw_data.db.db = document.getElementById('db-input-db').value;
document.getElementById('alldata').value = JSON.stringify(raw_data);
} else if (o.status === 'error') {
document.getElementById('db-check-result').innerHTML = o.error;
document.getElementById('db-check-result').classList.remove('success');
}
}
function db_created(o) {
if (o.status === 'ok') {
if (o.params) {
var raw_data = JSON.parse(document.getElementById('alldata').value);
raw_data.db = o.params;
raw_data.db.driver="mysql";
document.getElementById('alldata').value = JSON.stringify(raw_data);
document.getElementById('db-input-server').value = raw_data.db.server;
document.getElementById('db-input-port').value = raw_data.db.port;
document.getElementById('db-input-db').value = raw_data.db.db;
document.getElementById('db-input-user-name').value = raw_data.db.user;
document.getElementById('db-input-user-password').value = raw_data.db.password;
}
document.getElementById('db-check-result').innerHTML = ".";
document.getElementById('db-check-result').classList.add('success');
} else if (o.status === 'error') {
document.getElementById('db-check-result').innerHTML = o.error;
document.getElementById('db-check-result').classList.remove('success');
}
}
if (dbc) {
dbc.addEventListener('click', function () {
var db_params = get_db_params();
try {
check_db_params(db_params);
} catch (e) {
document.getElementById('db-check-result').innerHTML = e.message;
return;
}
var http = new XMLHttpRequest();
var params = 'data=' + encodeURIComponent(JSON.stringify(db_params));
var url = '<?php echo $_SERVER['REQUEST_URI'] ?>';
var spl = url.indexOf('?') >= 0 ? '&' : '?';
http.open('POST', [url, spl, 'action=check_db_create'].join(''), true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function () {
if (http.readyState == 4 && http.status == 200) {
var r = http.response;
var o = null;
try {
o = JSON.parse(r);
if (!(o && typeof (o) === 'object')) {
o = {status: 'error', 'error': 'invalid response'};
}
} catch (e) {
o = {status: 'error', 'error': e.message};
}
db_checked(o);
}
}
http.send(params);
});
}
var dbcre = document.getElementById('db-apply');
if (dbcre) {
dbcre.addEventListener('click', function () {
var db_params = get_db_params();
try {
check_db_params(db_params);
} catch (e) {
document.getElementById('db-check-result').innerHTML = e.message;
return;
}
var http = new XMLHttpRequest();
var params = 'data=' + encodeURIComponent(JSON.stringify(db_params));
var url = '<?php echo $_SERVER['REQUEST_URI'] ?>';
var spl = url.indexOf('?') >= 0 ? '&' : '?';
http.open('POST', [url, spl, 'action=check_db_create_create'].join(''), true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function () {
if (http.readyState == 4 && http.status == 200) {
var r = http.response;
var o = null;
try {
o = JSON.parse(r);
if (!(o && typeof (o) === 'object')) {
o = {status: 'error', 'error': 'invalid response'};
}
} catch (e) {
o = {status: 'error', 'error': e.message};
}
db_created(o);
}
};
http.send(params);
});
}
</script>
<?php
do_out(ob_get_clean(), 2);
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="step2pgsql">
function step_2pgsql() {
$all_data = get_post_data();
$db_data = array_key_exists('db', $all_data) && is_array($all_data['db']) ? $all_data['db'] : [];
ob_start()
?>
<div class="installer-db-window-backdrop">
<div class="installer-db-window">
<div class="Installer-intro-header"> <div class="installer-compatibility-text"> </div></div>
<div class="installer-db-form">
<form id="db_form" onsubmit="return false;" ation="#" method="GET">
<div class="db-form-note">
<div class="db-form-note-inner">
postgreSQL .<br>
PostgreSQL, .<br>
, , :
<textarea readonly="readonly">
-- -
CREATE ROLE "officemap" WITH LOGIN PASSWORD '123456';
CREATE DATABASE "officemap" OWNER="officemap" TEMPLATE=template0 ENCODING=UTF8;
</textarea>
<br>
- .
<div style="color:crimson;font-size:0.9em"> - !!!</div>
</div>
</div>
<div class="db-form-row">
<label for="db-input-server"></label>
<input type="text" value="<?php echo array_key_exists('server', $db_data) ? $db_data['server'] : '' ?>" placeholder="127.0.0.1" name="server" id="db-input-server"/>
</div>
<div class="db-form-row">
<label for="db-input-port"></label>
<input type="text" value="<?php echo array_key_exists('port', $db_data) ? $db_data['port'] : '5432' ?>" placeholder="5432" name="port" id="db-input-port"/>
</div>
<div class="db-form-row">
<label for="db-input-tpldb"> (T0/T1)</label>
<input type="text" value="<?php echo array_key_exists('tpldb', $db_data) ? $db_data['tpldb'] : 'template0' ?>" placeholder="template0" name="tpldb" id="db-input-tpldb"/>
</div>
<div class="db-form-row">
<label for="db-input-user"></label>
<input type="text" placeholder="db user" name="user" id="db-input-user" value="" placeholder="postgres"/>
</div>
<div class="db-form-row">
<label for="db-input-password"> </label>
<input type="text" placeholder="" name="password" id="db-input-password" value=""/>
</div>
<div class="db-form-row">
<label for="db-input-db"> </label>
<input type="text" value="" placeholder="officemap" name="db" id="db-input-db"/>
</div>
<div class="db-form-row" style="display:none">
<input type="checkbox" name="create-user" checked="checked" id="db-input-create-user"/>
<label for="db-input-create-user"> </label>
</div>
<div class="db-form-row">
<label for="db-input-user-name"> </label>
<input type="text" value="" placeholder="= db-name" name="user-name" id="db-input-user-name" />
</div>
<div class="db-form-row">
<label for="db-input-user-password"> </label>
<input type="text" value="" placeholder="" name="user-password" id="db-input-user-password" />
</div>
<div class="db-check-result" id="db-check-result">
</div>
<div class="db-form-button-row">
<div class="form-btn" id="db-check"></div>
<div class="form-btn" id="db-apply"> </div>
</div>
</form>
</div>
<form method="POST" action="<?php echo $_SERVER['REQUEST_URI'] ?>" id="stepxform">
<input name="step" type="hidden" value="3" id="form-step-value"/>
<input name="data" type="hidden" value="" id="alldata" />
<div class="form-btn" id="stepxsubmit" ></div>
</form>
</div>
</div>
<script>
document.getElementById('alldata').value = JSON.stringify(<?php echo cnd_json_encode($all_data) ?>);
var check = document.getElementById('db-input-create-user');
if (check) {
check.addEventListener('change', function () {
// if (check.checked) {
document.getElementById('db-input-user-name').removeAttribute('disabled');
document.getElementById('db-input-user-password').removeAttribute('disabled');
// } else {
// document.getElementById('db-input-user-name').setAttribute('disabled', 'disabled');
// document.getElementById('db-input-user-password').setAttribute('disabled', 'disabled');
// }
});
}
var btn = document.getElementById('stepxsubmit');
if (btn) {
btn.addEventListener('click', function () {
document.getElementById('form-step-value').value = "3";
var idata = JSON.parse(document.getElementById('alldata').value);
var dbData = idata.db;
if (!dbData || typeof (dbData) !== 'object') {
dbData = {};
idata.db=dbData;
}
dbData.driver = 'pgsql';
document.getElementById('alldata').value = JSON.stringify(idata);
document.getElementById('stepxform').submit();
});
}
var dbc = document.getElementById('db-check');
function get_db_params() {
return {
server: document.getElementById('db-input-server').value,
port: document.getElementById('db-input-port').value,
user: document.getElementById('db-input-user').value,
password: document.getElementById('db-input-password').value,
db: document.getElementById('db-input-db').value,
create_user: true,
user_name: document.getElementById('db-input-user-name').value,
user_password: document.getElementById('db-input-user-password').value,
tpldb: document.getElementById('db-input-tpldb').value
};
}
function check_db_params(xo) {
xo.server = xo.server && (typeof (xo.server) === 'string') ? xo.server.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.server.length ? 0 : xo.server = null;
if (!xo.server) {
throw new Error(" PostgreSQL");
}
xo.port = xo.port && (typeof (xo.port) === 'string') ? xo.port.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.port.length ? 0 : xo.port = null;
if (xo.port) {
var pt = parseInt(xo.port);
if (isNaN(pt)) {
throw new Error(' ');
}
}
xo.user = xo.user && (typeof (xo.user) === 'string') ? xo.user.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.user.length ? 0 : xo.user = null;
if (!xo.user) {
throw new Error(" CREATE ROLE/ DATABASE");
}
xo.password = xo.password && (typeof (xo.password) === 'string') ? xo.password.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.password.length ? 0 : xo.password = null;
if (!xo.password) {
throw new Error(" ");
}
xo.db = xo.db && (typeof (xo.db) === 'string') ? xo.db.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.db.length ? 0 : xo.db = null;
if (!xo.db) {
throw new Error(" ");
}
xo.tpldb = xo.tpldb && (typeof (xo.tpldb) === 'string') ? xo.tpldb.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.tpldb.length ? 0 : xo.tpldb = null;
if (!xo.tpldb) {
throw new Error(" ");
}
}
function db_checked(o) {
if (o.status === 'ok') {
var driver = 'pgsql';
document.getElementById('db-check-result').innerHTML = [' ; : ', driver, '; : ', o.version].join('');
document.getElementById('db-check-result').classList.add('success');
var raw_data = JSON.parse(document.getElementById('alldata').value);
if (!raw_data.db) {
raw_data.db = {};
}
raw_data.db.server = document.getElementById('db-input-server').value;
raw_data.db.port = document.getElementById('db-input-port').value;
raw_data.db.db = document.getElementById('db-input-db').value;
raw_data.db.driver="pgsql";
document.getElementById('alldata').value = JSON.stringify(raw_data);
} else if (o.status === 'error') {
document.getElementById('db-check-result').innerHTML = o.error;
document.getElementById('db-check-result').classList.remove('success');
}
}
function db_created(o) {
if (o.status === 'ok') {
if (o.params) {
var raw_data = JSON.parse(document.getElementById('alldata').value);
raw_data.db = o.params;
raw_data.db.driver = "pgsql";
document.getElementById('alldata').value = JSON.stringify(raw_data);
document.getElementById('db-input-server').value = raw_data.db.server;
document.getElementById('db-input-port').value = raw_data.db.port;
document.getElementById('db-input-db').value = raw_data.db.db;
document.getElementById('db-input-user-name').value = raw_data.db.user;
document.getElementById('db-input-user-password').value = raw_data.db.password;
}
document.getElementById('db-check-result').innerHTML = ".";
document.getElementById('db-check-result').classList.add('success');
} else if (o.status === 'error') {
document.getElementById('db-check-result').innerHTML = o.error;
document.getElementById('db-check-result').classList.remove('success');
}
}
if (dbc) {
dbc.addEventListener('click', function () {
var db_params = get_db_params();
try {
check_db_params(db_params);
} catch (e) {
document.getElementById('db-check-result').innerHTML = e.message;
return;
}
var http = new XMLHttpRequest();
var params = 'data=' + encodeURIComponent(JSON.stringify(db_params));
var url = '<?php echo $_SERVER['REQUEST_URI'] ?>';
var spl = url.indexOf('?') >= 0 ? '&' : '?';
http.open('POST', [url, spl, 'action=check_db_create_pg'].join(''), true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function () {
if (http.readyState == 4 && http.status == 200) {
var r = http.response;
var o = null;
try {
o = JSON.parse(r);
if (!(o && typeof (o) === 'object')) {
o = {status: 'error', 'error': 'invalid response'};
}
} catch (e) {
o = {status: 'error', 'error': e.message};
}
db_checked(o);
}
};
http.send(params);
});
}
var dbcre = document.getElementById('db-apply');
if (dbcre) {
dbcre.addEventListener('click', function () {
var db_params = get_db_params();
try {
check_db_params(db_params);
} catch (e) {
document.getElementById('db-check-result').innerHTML = e.message;
return;
}
var http = new XMLHttpRequest();
var params = 'data=' + encodeURIComponent(JSON.stringify(db_params));
var url = '<?php echo $_SERVER['REQUEST_URI'] ?>';
var spl = url.indexOf('?') >= 0 ? '&' : '?';
http.open('POST', [url, spl, 'action=check_db_create_create_pg'].join(''), true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function () {
if (http.readyState == 4 && http.status == 200) {
var r = http.response;
var o = null;
try {
o = JSON.parse(r);
if (!(o && typeof (o) === 'object')) {
o = {status: 'error', 'error': 'invalid response'};
}
} catch (e) {
o = {status: 'error', 'error': e.message};
}
db_created(o);
}
};
http.send(params);
});
}
</script>
<?php
do_out(ob_get_clean(), 2);
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="step3">
function step_3() {
$all_data = get_post_data();
$db_data = array_key_exists('db', $all_data) && is_array($all_data['db']) ? $all_data['db'] : [];
$isPG = !!(array_key_exists('driver', $db_data) && $db_data['driver']==='pgsql');
ob_start();
?>
<div class="installer-db-window-backdrop">
<div class="installer-db-window">
<div class="Installer-intro-header"> <div class="installer-compatibility-text"> </div></div>
<div class="installer-db-form">
<form id="db_form" onsubmit="return false;" ation="#" method="GET">
<div class="db-form-note">
<div class="db-form-note-inner">
, .<br>
dba/root - .
</div>
</div>
<div class="db-form-row">
<label for="db-input-server"></label>
<input type="text" value="<?php echo array_key_exists('server', $db_data) ? $db_data['server'] : '' ?>" placeholder="127.0.0.1" name="server" id="db-input-server"/>
</div>
<div class="db-form-row">
<label for="db-input-port"></label>
<input type="text" value="<?php echo array_key_exists('port', $db_data) ? $db_data['port'] : ($isPG?'5432':'3306') ?>" placeholder="0000" name="port" id="db-input-port"/>
</div>
<div class="db-form-row">
<label for="db-input-user"></label>
<input type="text" value="<?php echo array_key_exists('user', $db_data) ? $db_data['user'] : '' ?>" placeholder="db user" name="user" id="db-input-user"/>
</div>
<div class="db-form-row">
<label for="db-input-password"></label>
<input type="text" value="<?php echo array_key_exists('password', $db_data) ? $db_data['password'] : '' ?>" placeholder="" name="password" id="db-input-password"/>
</div>
<div class="db-form-row">
<label for="db-input-db"> </label>
<input type="text" value="<?php echo array_key_exists('db', $db_data) ? $db_data['db'] : 'officemap' ?>" placeholder="officemap" name="db" id="db-input-db"/>
<input type="hidden" id="db-input-driver" value="<?php echo array_key_exists('driver', $db_data)?$db_data['driver']:'mysql'?>" />
</div>
<div class="db-check-result" id="db-check-result">
</div>
<div class="db-form-button-row">
<div class="form-btn" id="db-check"></div>
</div>
</form>
</div>
<form method="POST" action="<?php echo $_SERVER['REQUEST_URI'] ?>" id="stepxform">
<input name="step" type="hidden" value="5" id="form-step-value"/>
<input name="data" type="hidden" value="" id="alldata" />
<div class="form-btn" id="stepxsubmit" ></div>
</form>
</div>
</div>
<script>
document.getElementById('alldata').value = JSON.stringify(<?php echo cnd_json_encode($all_data) ?>);
var btn = document.getElementById('stepxsubmit');
if (btn) {
btn.addEventListener('click', function () {
var raw_data = JSON.parse(document.getElementById('alldata').value);
if (!raw_data.db) {
raw_data.db = {};
}
raw_data.db.server = document.getElementById('db-input-server').value;
raw_data.db.port = document.getElementById('db-input-port').value;
raw_data.db.db = document.getElementById('db-input-db').value;
raw_data.db.user = document.getElementById('db-input-user').value;
raw_data.db.password = document.getElementById('db-input-password').value;
raw_data.db.driver = document.getElementById('db-input-driver').value;
document.getElementById('alldata').value = JSON.stringify(raw_data);
document.getElementById('form-step-value').value = "5";
document.getElementById('stepxform').submit();
});
}
var dbc = document.getElementById('db-check');
function get_db_params() {
return {
server: document.getElementById('db-input-server').value,
port: document.getElementById('db-input-port').value,
user: document.getElementById('db-input-user').value,
password: document.getElementById('db-input-password').value,
db: document.getElementById('db-input-db').value,
driver:document.getElementById('db-input-driver').value
};
}
function check_db_params(xo) {
xo.server = xo.server && (typeof (xo.server) === 'string') ? xo.server.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.server.length ? 0 : xo.server = null;
if (!xo.server) {
throw new Error(" ");
}
xo.port = xo.port && (typeof (xo.port) === 'string') ? xo.port.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.port.length ? 0 : xo.port = null;
if (xo.port) {
var pt = parseInt(xo.port);
if (isNaN(pt)) {
throw new Error(' ');
}
}
xo.user = xo.user && (typeof (xo.user) === 'string') ? xo.user.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.user.length ? 0 : xo.user = null;
if (!xo.user) {
throw new Error(" ");
}
xo.password = xo.password && (typeof (xo.password) === 'string') ? xo.password.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.password.length ? 0 : xo.password = null;
if (!xo.password) {
throw new Error(" ");
}
xo.db = xo.db && (typeof (xo.db) === 'string') ? xo.db.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.db.length ? 0 : xo.db = null;
if (!xo.db) {
throw new Error(" ");
}
xo.driver = xo.driver && (typeof (xo.driver) === 'string') ? xo.driver.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.driver.length ? 0 : xo.driver = null;
if (!xo.driver) {
throw new Error("PDO driver type is required");
}
}
function db_checked(o) {
if (o.status === 'ok') {
var driver = 'mysql5';
if(/postgresql/i.test(o.version)){
driver='pgsql';
}else if (/maria/i.test(o.version)) {
driver = 'maria-db';
} else {
var m = /^(\d{1,}).\d{1,}/.exec(o.version);
if (m) {
var mi = parseInt(m[1]);
if (mi >= 8) {
driver = 'mysql8';
}
}
}
document.getElementById('db-check-result').innerHTML = [' ; : ', driver, '; : ', o.version].join('');
document.getElementById('db-check-result').classList.add('success');
var raw_data = JSON.parse(document.getElementById('alldata').value);
if (!raw_data.db) {
raw_data.db = {};
}
raw_data.db.server = document.getElementById('db-input-server').value;
raw_data.db.port = document.getElementById('db-input-port').value;
raw_data.db.db = document.getElementById('db-input-db').value;
raw_data.db.user = document.getElementById('db-input-user').value;
raw_data.db.password = document.getElementById('db-input-password').value;
raw_data.db.driver = document.getElementById('db-input-driver').value;
document.getElementById('alldata').value = JSON.stringify(raw_data);
} else if (o.status === 'error') {
document.getElementById('db-check-result').innerHTML = o.error;
document.getElementById('db-check-result').classList.remove('success');
}
}
if (dbc) {
dbc.addEventListener('click', function () {
var db_params = get_db_params();
try {
check_db_params(db_params);
} catch (e) {
document.getElementById('db-check-result').innerHTML = e.message;
return;
}
var http = new XMLHttpRequest();
var params = 'data=' + encodeURIComponent(JSON.stringify(db_params));
var url = '<?php echo $_SERVER['REQUEST_URI'] ?>';
var spl = url.indexOf('?') >= 0 ? '&' : '?';
http.open('POST', [url, spl, 'action=check_db_connection'].join(''), true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function () {
if (http.readyState == 4 && http.status == 200) {
var r = http.response;
var o = null;
try {
o = JSON.parse(r);
if (!(o && typeof (o) === 'object')) {
o = {status: 'error', 'error': 'invalid response'};
}
} catch (e) {
o = {status: 'error', 'error': e.message};
}
db_checked(o);
}
};
http.send(params);
});
}
</script>
<?php
do_out(ob_get_clean(), 2);
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="step4">
function step_4() {
$all_data = get_post_data();
try {
$version = check_db_connection_ph();
} catch (\Throwable $ee) {
step_3();
}
try {
$rversion = get_redis_version(array_key_exists('redis', $all_data) && is_array($all_data['redis']) ? $all_data['redis'] : []);
} catch (\Throwable $ee) {
step_5();
}
$steps = parse_steps($version);
$tempname = 'tmp';
$names = [];
foreach ($steps as $step) {
$names[] = $step['name'];
}
ob_start();
?>
<div class="installer-db-window-backdrop">
<div class="installer-db-window">
<div class="Installer-intro-header"> <div class="installer-compatibility-text"> </div></div>
<div class="installer-db-form">
<form id="db_form" onsubmit="return false;" ation="#" method="GET">
<div class="db-form-note" id="warntext">
<div class="db-form-note-inner">
</div>
</div>
<div class="db-form-row">
<div class="db-create-progress-container">
<div class="db-create-progress" >
<div class="db-create-progress-element" id="progress-element" style="width:0%;"></div>
<div class="db-create-progress-tesxt" id="progress-text"></div>
</div>
<div class="db-create-progress-info-container">
<div class="db-create-progress-info" id="progress-current"></div>
</div>
</div>
</div>
</form>
</div>
<form method="POST" action="<?php echo $_SERVER['REQUEST_URI'] ?>" id="stepxform">
<input name="step" type="hidden" value="6" id="form-step-value"/>
<input name="data" type="hidden" value="" id="alldata" />
<div class="form-btn" id="stepxsubmit" style="visibility:hidden" ></div>
</form>
</div>
</div>
<script>
document.getElementById('alldata').value = JSON.stringify(<?php echo cnd_json_encode($all_data) ?>);
var btn = document.getElementById('stepxsubmit');
var progress = document.getElementById('progress-element');
var progress_text = document.getElementById('progress-text');
var progress_info = document.getElementById('progress-current');
var done = false;
var index = 0;
var steps = <?php echo cnd_json_encode($names) ?>;
function do_done() {
progress_info.innerHTML = " ";
progress_info.classList.remove('warning');
progress_info.classList.add('success');
progress.style.width = '100%';
progress_text.innerHTML = '100%';
btn.style.visibility = 'visible';
done = true;
}
function step_done(o) {
if (o.status === "ok") {
index++;
run_step();
} else if (o.status === 'error') {
progress_info.innerHTML = o.error;
progress_info.classList.add('warning');
if (o.error.replace('SQLSTATE[42S01]', '') !== o.error) {
index++;
run_step();
return;
}
if (o.error.replace('SQLSTATE[42000]', '') !== o.error && o.error.replace('1068', '') !== o.error) {
index++;
run_step();
return;
}
if (o.error.replace('SQLSTATE[HY000]:', '') !== o.error && o.error.replace('1826', '') !== o.error) {
index++;
run_step();
return;
}
if (o.error.replace('SQLSTATE[HY000]:', '') !== o.error && o.error.replace('1359', '') !== o.error) {
index++;
run_step();
return;
}
if (o.error.replace('SQLSTATE[42000]:', '') !== o.error && o.error.replace('1304', '') !== o.error) {
index++;
run_step();
return;
}
}
}
function run_step() {
if (index < steps.length) {
var progressi = Math.min(100, parseInt(index / (steps.length / 100)));
progress.style.width = [progressi, '%'].join('');
progress_text.innerHTML = [progressi, '%'].join('');
progress_info.innerHTML = steps[index];
progress_info.classList.remove('warning');
var http = new XMLHttpRequest();
var params = 'data=' + encodeURIComponent(document.getElementById('alldata').value);
var url = '<?php echo $_SERVER['REQUEST_URI'] ?>';
var spl = url.indexOf('?') >= 0 ? '&' : '?';
http.open('POST', [url, spl, 'action=exec_db_step&step=', index, '&tmp=<?php echo $tempname ?>'].join(''), true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function () {
if (http.readyState == 4 && http.status == 200) {
var r = http.response;
var o = null;
try {
o = JSON.parse(r);
if (!(o && typeof (o) === 'object')) {
o = {status: 'error', 'error': 'invalid response'};
}
} catch (e) {
o = {status: 'error', 'error': e.message};
}
step_done(o);
}
};
http.send(params);
} else {
do_done();
}
}
if (btn) {
btn.addEventListener('click', function () {
if (!done) {
return;
}
document.getElementById('form-step-value').value = "6";
document.getElementById('stepxform').submit();
});
}
progress.style.width = '0%';
progress_text.innerHTML = '0';
progress_info.innerHTML = '...';
run_step();
</script>
<?php
do_out(ob_get_clean(), 4);
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="step5">
function step_5() {
$all_data = get_post_data();
try {
$version = check_db_connection_ph();
} catch (\Throwable $ee) {
step_3();
}
$redis_data = array_key_exists('redis', $all_data) && is_array($all_data['redis']) ? $all_data['redis'] : [];
ob_start();
?>
<div class="installer-db-window-backdrop">
<div class="installer-db-window">
<div class="Installer-intro-header"> <div class="installer-compatibility-text"> redis</div></div>
<div class="installer-db-form">
<form id="db_form" onsubmit="return false;" ation="#" method="GET">
<div class="db-form-row">
<label for="db-input-server"> redis</label>
<input type="text" value="<?php echo array_key_exists('server', $redis_data) ? $redis_data['server'] : '' ?>" placeholder="127.0.0.1" name="server" id="db-input-server"/>
</div>
<div class="db-form-row">
<label for="db-input-port"></label>
<input type="text" value="<?php echo array_key_exists('port', $redis_data) ? $redis_data['port'] : '' ?>" placeholder="6379" name="port" id="db-input-port"/>
</div>
<div class="db-form-row">
<label for="db-input-password"></label>
<input type="text" value="<?php echo array_key_exists('password', $redis_data) ? $redis_data['password'] : '' ?>" placeholder="" name="password" id="db-input-password"/>
</div>
<div class="db-check-result" id="db-check-result">
</div>
<div class="db-form-button-row">
<div class="form-btn" id="db-check"></div>
</div>
</form>
</div>
<form method="POST" action="<?php echo $_SERVER['REQUEST_URI'] ?>" id="stepxform">
<input name="step" type="hidden" value="4" id="form-step-value"/>
<input name="data" type="hidden" value="" id="alldata" />
<div class="form-btn" id="stepxsubmit" ></div>
</form>
</div>
</div>
<script>
document.getElementById('alldata').value = JSON.stringify(<?php echo cnd_json_encode($all_data) ?>);
var btn = document.getElementById('stepxsubmit');
if (btn) {
btn.addEventListener('click', function () {
var raw_data = JSON.parse(document.getElementById('alldata').value);
if (!raw_data.redis) {
raw_data.redis = {};
}
raw_data.redis.server = document.getElementById('db-input-server').value;
raw_data.redis.port = document.getElementById('db-input-port').value;
raw_data.redis.password = document.getElementById('db-input-password').value;
document.getElementById('alldata').value = JSON.stringify(raw_data);
document.getElementById('form-step-value').value = "4";
document.getElementById('stepxform').submit();
});
}
var dbc = document.getElementById('db-check');
function get_db_params() {
return {
server: document.getElementById('db-input-server').value,
port: document.getElementById('db-input-port').value,
password: document.getElementById('db-input-password').value
};
}
function check_db_params(xo) {
xo.server = xo.server && (typeof (xo.server) === 'string') ? xo.server.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.server.length ? 0 : xo.server = null;
if (!xo.server) {
throw new Error(" redis");
}
xo.port = xo.port && (typeof (xo.port) === 'string') ? xo.port.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.port.length ? 0 : xo.port = null;
if (xo.port) {
var pt = parseInt(xo.port);
if (isNaN(pt)) {
throw new Error(' ');
}
}
xo.password = xo.password && (typeof (xo.password) === 'string') ? xo.password.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.password.length ? 0 : xo.password = null;
}
function redis_checked(o) {
if (o.status === 'ok') {
document.getElementById('db-check-result').innerHTML = [' ; Redis: ', o.version].join('');
document.getElementById('db-check-result').classList.add('success');
var raw_data = JSON.parse(document.getElementById('alldata').value);
if (!raw_data.redis) {
raw_data.redis = {};
}
raw_data.redis.server = document.getElementById('db-input-server').value;
raw_data.redis.port = document.getElementById('db-input-port').value;
raw_data.redis.password = document.getElementById('db-input-password').value;
document.getElementById('alldata').value = JSON.stringify(raw_data);
} else if (o.status === 'error') {
document.getElementById('db-check-result').innerHTML = o.error;
document.getElementById('db-check-result').classList.remove('success');
}
}
if (dbc) {
dbc.addEventListener('click', function () {
var db_params = get_db_params();
try {
check_db_params(db_params);
} catch (e) {
document.getElementById('db-check-result').innerHTML = e.message;
return;
}
var http = new XMLHttpRequest();
var params = 'data=' + encodeURIComponent(JSON.stringify(db_params));
var url = '<?php echo $_SERVER['REQUEST_URI'] ?>';
var spl = url.indexOf('?') >= 0 ? '&' : '?';
http.open('POST', [url, spl, 'action=check_redis_connection'].join(''), true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function () {
if (http.readyState == 4 && http.status == 200) {
var r = http.response;
var o = null;
try {
o = JSON.parse(r);
if (!(o && typeof (o) === 'object')) {
o = {status: 'error', 'error': 'invalid response'};
}
} catch (e) {
o = {status: 'error', 'error': e.message};
}
redis_checked(o);
}
};
http.send(params);
});
}
</script>
<?php
do_out(ob_get_clean(), 5);
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="step_6">
function step_6() {
$all_data = get_post_data();
try {
$version = check_db_connection_ph();
} catch (\Throwable $ee) {
step_3();
}
try {
$rversion = get_redis_version(array_key_exists('redis', $all_data) && is_array($all_data['redis']) ? $all_data['redis'] : []);
} catch (\Throwable $ee) {
step_5();
}
$xml = load_file('install.xml');
$document = new \DOMDocument();
$document->loadXML($xml);
$dirs_doms = $document->getElementsByTagName('d');
$_to_create = [];
foreach ($dirs_doms as $dd) {/* @var $dd \DOMElement */
$relative_path = trim(str_ireplace(['\', '/'], DIRECTORY_SEPARATOR, $dd->getAttribute('p')), DIRECTORY_SEPARATOR);
$name = $dd->getAttribute('n');
if (mb_strlen($relative_path, 'UTF-8')) {
$full_relative_path = DIRECTORY_SEPARATOR . $relative_path . DIRECTORY_SEPARATOR . $name;
} else {
$full_relative_path = DIRECTORY_SEPARATOR . $name;
}
$_to_create[] = ['t' => 'd', 'n' => $full_relative_path];
}
unset($dirs_doms);
$files_doms = $document->getElementsByTagName('f');
foreach ($files_doms as $file) {/* @var $file \DOMElement */
$relative_path = trim(str_ireplace(['\', '/'], DIRECTORY_SEPARATOR, $file->getAttribute('p')), DIRECTORY_SEPARATOR);
$name = $file->getAttribute('n');
if (mb_strlen($relative_path, 'UTF-8')) {
$full_relative_path = DIRECTORY_SEPARATOR . $relative_path . DIRECTORY_SEPARATOR . $name;
} else {
$full_relative_path = DIRECTORY_SEPARATOR . $name;
}
$_to_create[] = ['t' => 'f', 'n' => $full_relative_path];
}
unset($files_doms);
unset($document);
ob_start();
?>
<div class="installer-db-window-backdrop">
<div class="installer-db-window">
<div class="Installer-intro-header"> <div class="installer-compatibility-text"> </div></div>
<div class="installer-db-form">
<form id="db_form" onsubmit="return false;" ation="#" method="GET">
<div class="db-form-note" id="warntext">
<div class="db-form-note-inner">
</div>
</div>
<div class="db-form-row">
<div class="db-create-progress-container">
<div class="db-create-progress" >
<div class="db-create-progress-element" id="progress-element" style="width:0%;"></div>
<div class="db-create-progress-tesxt" id="progress-text"></div>
</div>
<div class="db-create-progress-info-container">
<div class="db-create-progress-info" id="progress-current"></div>
</div>
</div>
</div>
</form>
</div>
<form method="POST" action="<?php echo $_SERVER['REQUEST_URI'] ?>" id="stepxform">
<input name="step" type="hidden" value="7" id="form-step-value"/>
<input name="data" type="hidden" value="" id="alldata" />
<div class="form-btn" id="stepxsubmit" style="visibility:hidden" ></div>
</form>
</div>
</div>
<script>
document.getElementById('alldata').value = JSON.stringify(<?php echo json_encode($all_data) ?>);
var btn = document.getElementById('stepxsubmit');
var progress = document.getElementById('progress-element');
var progress_text = document.getElementById('progress-text');
var progress_info = document.getElementById('progress-current');
var done = false;
var index = 0;
var indexNX = 0;
var steps = <?php echo cnd_json_encode($_to_create) ?>;
function do_done() {
progress_info.innerHTML = " ";
progress_info.classList.remove('warning');
progress_info.classList.add('success');
progress.style.width = '100%';
progress_text.innerHTML = '100%';
var http = new XMLHttpRequest();
var params = 'data=' + encodeURIComponent(document.getElementById('alldata').value);
var url = '<?php echo $_SERVER['REQUEST_URI'] ?>';
var spl = url.indexOf('?') >= 0 ? '&' : '?';
http.open('POST', [url, spl, 'action=write_config'].join(''), true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function () {
if (http.readyState == 4 && http.status == 200) {
var r = http.response;
var o = null;
try {
o = JSON.parse(r);
if (!(o && typeof (o) === 'object')) {
o = {status: 'error', 'error': 'invalid response'};
}
} catch (e) {
o = {status: 'error', 'error': e.message};
}
step_done_cf(o);
}
};
http.send(params);
}
function do_done_all() {
progress_info.innerHTML = " ";
progress_info.classList.remove('warning');
progress_info.classList.add('success');
progress.style.width = '100%';
progress_text.innerHTML = '100%';
btn.style.visibility = 'visible';
done = true;
}
function step_done_cf(o) {
if (o.status === "ok") {
do_done_all();
} else if (o.status === 'error') {
progress_info.innerHTML = o.error;
progress_info.classList.add('warning');
}
}
function step_done(o) {
if (o.status === "ok") {
index=indexNX;
run_step();
} else if (o.status === 'error') {
progress_info.innerHTML = o.error;
progress_info.classList.add('warning');
debugger;
}
}
function run_step() {
if (index < steps.length) {
var progressi = Math.min(100, parseInt(index / (steps.length / 100)));
progress.style.width = [progressi, '%'].join('');
progress_text.innerHTML = [progressi, '%'].join('');
progress_info.innerHTML = [steps[index].t === 'd' ? 'dir://' : 'file://', steps[index].n].join('');
progress_info.classList.remove('warning');
var http = new XMLHttpRequest();
var params = 'data=' + encodeURIComponent(document.getElementById('alldata').value);
var url = '<?php echo $_SERVER['REQUEST_URI'] ?>';
var spl = url.indexOf('?') >= 0 ? '&' : '?';
var stepsToExec = [];
var mxStepIndex=0;
for(var si=0;si<10;si++){
var nsi = index+si;
if(nsi<steps.length){
stepsToExec.push(nsi);
mxStepIndex = Math.max(mxStepIndex,nsi);
}
}
indexNX = mxStepIndex+1;
http.open('POST', [url, spl, 'action=exec_fs_step&multistep=', stepsToExec.join(',')].join(''), true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function () {
if (http.readyState == 4 && http.status == 200) {
var r = http.response;
var o = null;
try {
o = JSON.parse(r);
if (!(o && typeof (o) === 'object')) {
o = {status: 'error', 'error': 'invalid response'};
}
} catch (e) {
o = {status: 'error', 'error': e.message};
}
step_done(o);
}
};
http.send(params);
} else {
do_done();
}
}
if (btn) {
btn.addEventListener('click', function () {
if (!done) {
return;
}
document.getElementById('form-step-value').value = "7";
document.getElementById('stepxform').submit();
});
}
progress.style.width = '0%';
progress_text.innerHTML = '0';
progress_info.innerHTML = '...';
run_step();
</script>
<?php
do_out(ob_get_clean(), 5);
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="step_7">
function step_7($error = null,\Throwable $exc = null) {
$all_data = get_post_data();
ob_start();
?>
<div class="installer-db-window-backdrop">
<div class="installer-db-window">
<div class="Installer-intro-header"> <div class="installer-compatibility-text"> </div></div>
<div class="installer-db-form">
<form id="db_form" onsubmit="return false;" ation="#" method="GET">
<div class="db-form-row">
<label for="db-input-user">Email*</label>
<input type="text" value="" name="user_login" id="db-input-user"/>
</div>
<div class="db-form-row">
<label for="db-input-password">*</label>
<input type="text" value="" name="user_password" id="db-input-password"/>
</div>
<div class="db-form-row">
<label for="db-input-family"></label>
<input type="text" value="" name="user_family" id="db-input-family" placeholder="admin"/>
</div>
<div class="db-form-row">
<label for="db-input-name"></label>
<input type="text" value="" name="user_name" id="db-input-name" placeholder="admin"/>
</div>
<div class="db-create-progress-info-container">
<div class="db-create-progress-info <?php echo ($error ? 'warning' : '') ?>" id="progress-current"><?php echo $error ?></div>
<div style='display:none'><pre><?php if($exc){ echo $exc->getTraceAsString();}?></pre><pre><?php var_dump($exc)?></pre></div>
</div>
</form>
</div>
<form method="POST" action="<?php echo $_SERVER['REQUEST_URI'] ?>" id="stepxform">
<input name="step" type="hidden" value="8" id="form-step-value"/>
<input name="data" type="hidden" value="" id="alldata" />
<input name="admin" type="hidden" value="" id="admindata" />
<div class="form-btn" id="stepxsubmit" ></div>
</form>
</div>
</div>
<script>
document.getElementById('alldata').value = JSON.stringify(<?php echo json_encode($all_data) ?>);
var btn = document.getElementById('stepxsubmit');
var progress_info = document.getElementById('progress-current');
function trim(x) {
if (typeof (x) === 'string') {
return x.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '');
}
return null;
}
function ntrim(x) {
var r = trim(x);
if (r && r.length > 0) {
return r;
}
return null;
}
if (btn) {
btn.addEventListener('click', function () {
var data = {
login: ntrim(document.getElementById('db-input-user').value),
password: ntrim(document.getElementById('db-input-password').value),
family: ntrim(document.getElementById('db-input-family').value),
name: ntrim(document.getElementById('db-input-name').value)
};
try {
if (!data.login) {
throw new Error(' ');
}
if (!data.password) {
throw new Error(' ');
}
if (data.password.length < 6) {
throw new Error(' , - 6 ');
}
document.getElementById('admindata').value = JSON.stringify(data);
document.getElementById('form-step-value').value = "8";
document.getElementById('stepxform').submit();
} catch (e) {
progress_info.innerHTML = e.message;
progress_info.classList.add('warning');
}
});
}
</script>
<?php
do_out(ob_get_clean(), 5);
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="step_8">
function step_8($error = null) {
try {
$all_data = get_post_data();
if (!file_exists(__DIR__ . DIRECTORY_SEPARATOR . '__bootstrap.php')) {
throw new Exception(' ');
}
require_once __DIR__ . DIRECTORY_SEPARATOR . '__bootstrap.php';
$admin = DataMap\InputDataMap::F()->get_filtered('admin', ['Trim', 'NEString', 'JSONString', 'NEArray', 'DefaultNull']);
$admin ? 0 : \Errors\common_error::R(' ');
$admin_data = Filters\FilterManager::F()->apply_filter_array($admin, [
'login' => ['Strip', 'Trim', 'NEString', 'EmailMatch'],
'password' => ['Trim', 'NEString', 'PasswordMatch'],
'family' => ['Strip', 'Trim', 'NEString', 'DefaultNull'],
'name' => ['Strip', 'Trim', 'NEString', 'DefaultNull'],
]);
Filters\FilterManager::F()->raise_array_error($admin_data);
$builder = \DB\SQLTools\SQLBuilder::F();
$builder->pushParams([
":P{$builder->c}login" => $admin_data['login'],
":P{$builder->c}pass" => \Helpers\PasswordTools::encrypt_password($admin_data['password']),
":P{$builder->c}name" => $admin_data['name'] ? $admin_data['name'] : 'admin',
":P{$builder->c}family" => $admin_data['family'] ? $admin_data['family'] : 'admin',
]);
$varPrefix = '@a';
$userTable = "`user`";
$userFieldTable = "`user__fields`";
if (DB\DB::F()->isPostgress()) {
$varPrefix = 'tmp_sess_var_';
$userTable = "\"user\"";
$userFieldTable = "\"user__fields\"";
}
$temp_var = $varPrefix . md5(__FUNCTION__ . time());
$existsing_user_id = intval(DB\DB::F()->queryScalar("SELECT id FROM {$userTable} WHERE login=:Plogin;", [':Plogin' => $admin_data['login']]));
if ($existsing_user_id) {
\Errors\common_error::RF(' `%s` . email.', $admin_data['login']);
}
if ($builder->adapter->isPostgress()) {
$uuid = Helpers\Helpers::guid_v4();
$builder->push('DO $$')
->push("DECLARE {$temp_var} bigint;")
->push("BEGIN")
->push("INSERT INTO {$userTable} (guid,login,phone_strip,pass,role,locked,created)
VALUES(
:P{$builder->c}uuid,:P{$builder->c}login,null,:P{$builder->c}pass,'admin', 0,NOW())
RETURNING id INTO {$temp_var};")
->push_param(":P{$builder->c}uuid", $uuid)
->push(sprintf('insert into %s(id,vint) VALUES(\'%s\',%s) ON CONFLICT (id) DO UPDATE SET vint=EXCLUDED.vint;', $builder->pgVarTab, $temp_var, $temp_var))
->push("INSERT INTO {$userFieldTable} (id,name,family,eldername,phone) VALUES({$temp_var},:P{$builder->c}name,:P{$builder->c}family,'',null);");
} else {
$builder->push("INSERT INTO {$userTable} (guid,login,phone_strip,pass,role,locked,created) VALUES(UUID(),:P{$builder->c}login,null,:P{$builder->c}pass,'admin',0,NOW());")
->push("SET {$temp_var}=LAST_INSERT_ID();")
->push("INSERT INTO {$userFieldTable} (id,name,family,eldername,phone) VALUES({$temp_var},:P{$builder->c}name,:P{$builder->c}family,'',null);");
}
if ($builder->adapter->isPostgress()) {
$builder->push('END $$;');
}
$result_id = $builder->execute_transact($temp_var);
\Auth\Auth::F()->force_login($result_id);
//cdaa48f8d77b45fa8a6ca0ad067ef03a
//
// ,
ob_start();
\DB\Migration\AbstractMigration::apply_new_migrations();
ob_end_clean();
//
$key_installed = false;
$existsing_key = null;
if (DB\DB::F()->isPostgress()) {
$existsing_key = \Filters\FilterManager::F()->apply_chain(DB\DB::F()->queryScalar('SELECT "value" FROM "presets" WHERE "name"=\'LICENSE_KEY\';'), ['Trim', 'NEString', 'DefaultNull']);
} else {
$existsing_key = \Filters\FilterManager::F()->apply_chain(DB\DB::F()->queryScalar('SELECT `value` FROM `presets` WHERE `name`=\'LICENSE_KEY\';'), ['Trim', 'NEString', 'DefaultNull']);
}
if (!$existsing_key) {
$new_key = \License\LicenseKey::generate_demo(load_file('cdaa48f8d77b45fa8a6ca0ad067ef03a'));
$b = \DB\SQLTools\SQLBuilder::F();
if (DB\DB::F()->isPostgress()) {
$b->push("INSERT INTO \"presets\" (\"name\",\"value\") VALUES(:P{$b->c}key,:P{$b->c}val) ON CONFLICT (\"name\") DO UPDATE SET \"value\"=EXCLUDED.\"value\";");
} else if ($b->get_mysql_version()->mysql8g) {
$b->push("INSERT INTO `presets` (`name`,`value`) VALUES(:P{$b->c}key,:P{$b->c}val) as `presets_tmp` ON DUPLICATE KEY UPDATE `value`=`presets_tmp`.`value`;");
} else {
$b->push("INSERT INTO `presets` (`name`,`value`) VALUES(:P{$b->c}key,:P{$b->c}val) ON DUPLICATE KEY UPDATE `value`=VALUES(`value`);");
}
$b->push_params([
":P{$b->c}key" => 'LICENSE_KEY',
":P{$b->c}val" => $new_key,
])->execute();
$key_installed = true;
\PresetManager\PresetManager::RESET_CACHE();
}
$predef_removed = false;
$installer_moved = false;
$predef = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'mysql.dba.txt';
if (file_exists($predef) && is_file($predef) && is_writable($predef)) {
@unlink($predef);
$predef_removed = true;
}
$installer_target = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'installer.php';
if (file_exists($installer_target) && is_file($installer_target) && is_writable($installer_target)) {
@unlink($installer_target);
}
if (!file_exists($installer_target)) {
@rename(__FILE__, $installer_target);
$installer_moved = true;
}
} catch (\Throwable $e) {
step_7($e->getMessage(), $e);
}
ob_start();
?>
<div class="installer-db-window-backdrop">
<div class="installer-db-window">
<div class="Installer-intro-header"> <div class="installer-compatibility-text"> .</div></div>
<div class="installer-db-form">
. .<br>
/config nginx - .<br>
.<br>
<?php if ($key_installed) { ?>
<br> 30 . - .<br>
<?php } else { ?>
<br> , .<br>
<?php } ?>
<?php if ($predef_removed) { ?>
.<br>
<?php } ?>
<?php if ($installer_moved) { ?>
( webroot) . <br>
, .
<?php } ?>
</div>
<div class="window-footer">
<div class="window-footer-content">
<a class="form-btn" href="<?= Config\Config::F()->getAssetBase() ?>admin/Users/index"></a>
</div>
</div>
</div>
</div>
<?php
do_out(ob_get_clean(), 5);
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="actions">
//<editor-fold defaultstate="collapsed" desc="exec_db_step">
function action_exec_db_step() {
$od = ['status' => 'ok'];
try {
$version_pdo = check_db_connection_ph(true);
$version = $version_pdo['version'];
$pdo = $version_pdo['pdo'];
$steps = parse_steps($version);
$step = intval(ntrima($_GET, 'step'));
$step_sql = array_key_exists($step, $steps) && is_array($steps[$step]) && array_key_exists('task', $steps[$step]) ? $steps[$step]['task'] : null;
if (!$step_sql) {
throw new Exception("no step index");
}
$pdo->exec($step_sql);
} catch (\Throwable $e) {
$od['status'] = 'error';
$od['error'] = $e->getMessage();
}
return $od;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="check_db_connection">
function check_connection_sqm_mysql(array $in, array &$od) {
$keys = ['server', 'port', 'user', 'password', 'db'];
foreach ($keys as $key) {
if (!array_key_exists($key, $in)) {
throw new Exception(" `{$key}`");
}
}
$server = ntrima($in, 'server');
if (!$server) {
throw new Exception(" ");
}
$port = ntrima($in, 'port');
if ($port !== null) {
if (!intval($port)) {
throw new Exception(" ");
}
}
$user = ntrima($in, 'user');
if (!$user) {
throw new Exception(" ");
}
$password = ntrima($in, 'password');
if (!$password) {
throw new Exception(" ");
}
$db = ntrima($in, 'db');
if (!$db) {
throw new Exception(" ");
}
$dsn = sprintf('mysql:host=%s;port=%s;dbname=%s;charset=utf8', $server, ($port ? $port : 3306), $db);
$od['check'] = [
'dsn' => $dsn,
'user' => $user,
'password' => $password,
'driver'=>'mysql',
];
$pdo = new PDO($dsn, $user, $password, mkPDOConnetionOptions([
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
]));
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$statement = $pdo->prepare('SELECT @@VERSION');
$statement->execute([]);
$version = null;
$version_row = $statement->fetch(\PDO::FETCH_NUM);
$statement->closeCursor();
if ($version_row && is_array($version_row) && array_key_exists(0, $version_row)) {
$version = $version_row[0];
}
if (!$version) {
throw new Exception(' mySQL');
}
$od['version'] = $version;
$tt_name = "db_installer_test_" . md5(implode(',', [__FILE__, time()]));
try {
$pdo->exec("CREATE TEMPORARY TABLE `{$tt_name}`(id BIGINT UNSIGNED NOT NULL,PRIMARY KEY(id))ENGINE=InnoDB;");
} catch (\Throwable $ee) {
throw new Exception(" ({$ee->getMessage()})");
}
}
function check_connection_sqm_pgsql(array $in, array &$od) {
$keys = ['server', 'port', 'user', 'password', 'db'];
foreach ($keys as $key) {
if (!array_key_exists($key, $in)) {
throw new Exception(" `{$key}`");
}
}
$server = ntrima($in, 'server');
if (!$server) {
throw new Exception(" ");
}
$port = ntrima($in, 'port');
if ($port !== null) {
if (!intval($port)) {
throw new Exception(" ");
}
}
$user = ntrima($in, 'user');
if (!$user) {
throw new Exception(" ");
}
$password = ntrima($in, 'password');
if (!$password) {
throw new Exception(" ");
}
$db = ntrima($in, 'db');
if (!$db) {
throw new Exception(" ");
}
$dsn = sprintf('pgsql:host=%s;port=%s;dbname=%s;user=%s;password=%s', $server, ($port ? $port : 5432), $db,$user,$password);
$od['check'] = [
'dsn' => $dsn,
'user' => $user,
'password' => $password,
'driver'=>'mysql',
];
$pdo = new PDO($dsn, null, null, mkPDOConnetionOptions([
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
]));
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$statement = $pdo->prepare('SELECT version();');
$statement->execute([]);
$version = null;
$version_row = $statement->fetch(\PDO::FETCH_NUM);
$statement->closeCursor();
if ($version_row && is_array($version_row) && array_key_exists(0, $version_row)) {
$version = $version_row[0];
}
if (!$version) {
throw new Exception(' PostgreSQL');
}
$od['version'] = $version;
$tt_name = "db_installer_test_" . md5(implode(',', [__FILE__, time()]));
try {
$pdo->exec("CREATE TEMPORARY TABLE \"{$tt_name}\"(id bigint NOT NULL,PRIMARY KEY(id));");
} catch (\Throwable $ee) {
throw new Exception(" ({$ee->getMessage()})");
}
}
function action_check_db_connection() {
$od = ['status' => 'ok'];
try {
$str = array_key_exists('data', $_POST) ? $_POST['data'] : '';
$arr = @cnd_json_decode($str, true);
if (!is_array($arr)) {
throw new Exception(' ');
}
$driver = array_key_exists('driver', $arr) && is_string($arr['driver']) ? $arr['driver'] : 'mysql';
$fn = "check_connection_sqm_{$driver}";
if (function_exists($fn)) {
$fn($arr, $od);
} else {
throw new Exception("unknown driver {$driver}");
}
} catch (\Throwable $e) {
$od['status'] = 'error';
$od['error'] = $e->getMessage();
}
return $od;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="check_db_create">
function action_check_db_create() {
$od = ['status' => 'ok'];
try {
$str = array_key_exists('data', $_POST) ? $_POST['data'] : '';
$arr = @cnd_json_decode($str, true);
if (!is_array($arr)) {
throw new Exception(' ');
}
$keys = ['server', 'port', 'user', 'password', 'db'];
foreach ($keys as $key) {
if (!array_key_exists($key, $arr)) {
throw new Exception(" `{$key}`");
}
}
$server = ntrima($arr, 'server');
if (!$server) {
throw new Exception(" ");
}
$port = ntrima($arr, 'port');
if ($port !== null) {
if (!intval($port)) {
throw new Exception(" ");
}
}
$user = ntrima($arr, 'user');
if (!$user) {
throw new Exception(" ");
}
$password = ntrima($arr, 'password');
if (!$password) {
throw new Exception(" ");
}
$db = ntrima($arr, 'db');
if (!$db) {
throw new Exception(" ");
}
$overwtite = array_key_exists('overwrite', $arr) && is_bool($arr['overwrite']) ? $arr['overwrite'] : false;
$options = mkPDOConnetionOptions([
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
]);
$pdo = new PDO(sprintf('mysql:host=%s;port=%s;charset=utf8', $server, ($port ? $port : 3306)), $user, $password, $options);
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$statement = $pdo->prepare('SELECT @@VERSION');
$statement->execute([]);
$version = null;
$version_row = $statement->fetch(\PDO::FETCH_NUM);
$statement->closeCursor();
if ($version_row && is_array($version_row) && array_key_exists(0, $version_row)) {
$version = $version_row[0];
}
if (!$version) {
throw new Exception(' mySQL');
}
$od['version'] = $version;
$statement = $pdo->query('SHOW DATABASES;');
$dbx = [];
foreach ($statement->fetchAll(PDO::FETCH_NUM) as $row) {
if (is_array($row) && count($row)) {
$dbn = mb_strtolower($row[0], 'UTF-8');
$dbn = ntrim($dbn);
if ($dbn) {
$dbx[$dbn] = $dbn;
}
}
}
$statement->closeCursor();
if (array_key_exists(mb_strtolower($db, 'UTF-8'), $dbx)) {
throw new Exception(sprintf(' `%s` ', $db));
}
$tdb_name = "db_installer_test_" . md5(implode(',', [__FILE__, time()]));
try {
$pdo->exec("CREATE DATABASE `{$tdb_name}` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;");
} catch (\Throwable $ee) {
throw new Exception(" ({$ee->getMessage()})");
}
$od['grant'] = true;
try {
$pdo->exec("DROP DATABASE IF EXISTS `{$tdb_name}`;");
} catch (\Throwable $ee) {
}
} catch (\Throwable $e) {
$od['status'] = 'error';
$od['error'] = $e->getMessage();
}
return $od;
}
function action_check_db_create_pg() {
$od = ['status' => 'ok'];
try {
$str = array_key_exists('data', $_POST) ? $_POST['data'] : '';
$arr = @cnd_json_decode($str, true);
if (!is_array($arr)) {
throw new Exception(' ');
}
$keys = ['server', 'port', 'user', 'password', 'db'];
foreach ($keys as $key) {
if (!array_key_exists($key, $arr)) {
throw new Exception(" `{$key}`");
}
}
$server = ntrima($arr, 'server');
if (!$server) {
throw new Exception(" ");
}
$port = ntrima($arr, 'port');
if ($port !== null) {
if (!intval($port)) {
throw new Exception(" ");
}
}
$user = ntrima($arr, 'user');
if (!$user) {
throw new Exception(" ");
}
$password = ntrima($arr, 'password');
if (!$password) {
throw new Exception(" ");
}
$db = ntrima($arr, 'db');
if (!$db) {
throw new Exception(" ");
}
$tpldb = ntrima($arr, 'tpldb');
if (!$tpldb) {
throw new Exception(" ");
}
$overwtite = array_key_exists('overwrite', $arr) && is_bool($arr['overwrite']) ? $arr['overwrite'] : false;
$options = mkPDOConnetionOptions([
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
]);
$pdo = new PDO(sprintf('pgsql:host=%s;port=%s;dbname=%s;user=%s;password=%s',$server,$port,$tpldb,$user,$password),null,null,$options);
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$statement = $pdo->prepare('SELECT version();');
$statement->execute([]);
$version = null;
$version_row = $statement->fetch(\PDO::FETCH_NUM);
$statement->closeCursor();
if ($version_row && is_array($version_row) && array_key_exists(0, $version_row)) {
$version = $version_row[0];
}
if (!$version) {
throw new Exception(' PostgreSQL');
}
$od['version'] = $version;
$tdb_name = "db_installer_test_" . md5(implode(',', [__FILE__, time()]));
try {
$pdo->exec("CREATE DATABASE \"{$tdb_name}\" TEMPLATE=template0 ENCODING=UTF8;");
} catch (\Throwable $ee) {
throw new Exception(" ({$ee->getMessage()})");
}
$od['grant'] = true;
try {
$pdo->exec("DROP DATABASE IF EXISTS \"{$tdb_name}\";");
} catch (\Throwable $ee) {
// throw $ee;
}
} catch (\Throwable $e) {
$od['status'] = 'error';
$od['error'] = $e->getMessage();
}
return $od;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="check_db_create_create">
function action_check_db_create_create() {
$od = ['status' => 'ok'];
try {
$str = array_key_exists('data', $_POST) ? $_POST['data'] : '';
$arr = @cnd_json_decode($str, true);
if (!is_array($arr)) {
throw new Exception(' ');
}
$keys = ['server', 'port', 'user', 'password', 'db', 'create_user', 'user_name', 'user_password', 'user_host'];
foreach ($keys as $key) {
if (!array_key_exists($key, $arr)) {
throw new Exception(" `{$key}`");
}
}
$server = ntrima($arr, 'server');
if (!$server) {
throw new Exception(" ");
}
$port = ntrima($arr, 'port');
if ($port !== null) {
if (!intval($port)) {
throw new Exception(" ");
}
}
$user = ntrima($arr, 'user');
if (!$user) {
throw new Exception(" ");
}
$password = ntrima($arr, 'password');
if (!$password) {
throw new Exception(" ");
}
$db = ntrima($arr, 'db');
if (!$db) {
throw new Exception(" ");
}
$create_user = is_bool($arr['create_user']) ? $arr['create_user'] : false; //$_SERVER['SERVER_ADDR']
$create_user_name = ntrima($arr, 'user_name');
$create_user_password = ntrima($arr, 'user_password');
$create_user_host = ntrima($arr, 'user_host');
$create_user_name = $create_user_name ? $create_user_name : $db;
$create_user_password = $create_user_password ? $create_user_password : mk_password(25);
$create_user_host = $create_user_host ? $create_user_host : '%';
$pdo = new PDO(sprintf('mysql:host=%s;port=%s;charset=utf8', $server, ($port ? $port : 3306)), $user, $password, mkPDOConnetionOptions([
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
]));
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$statement = $pdo->query('SHOW DATABASES;');
$dbx = [];
foreach ($statement->fetchAll(PDO::FETCH_NUM) as $row) {
if (is_array($row) && count($row)) {
$dbn = ntrim(mb_strtolower($row[0], 'UTF-8'));
if ($dbn) {
$dbx[$dbn] = $dbn;
}
}
}
$statement->closeCursor();
if (array_key_exists(mb_strtolower($db, 'UTF-8'), $dbx)) {
throw new Exception(sprintf(' `%s` ', $db));
}
$tdb_name = $db;
$pdo->exec("CREATE DATABASE `{$tdb_name}` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;");
if ($create_user) {
$pdo->exec("CREATE USER '{$create_user_name}'@'{$create_user_host}' IDENTIFIED BY '{$create_user_password}';");
$pdo->exec("GRANT ALL PRIVILEGES ON `{$db}`.* TO '{$create_user_name}'@'{$create_user_host}';");
$pdo->exec("FLUSH PRIVILEGES;");
}
$od['params'] = [
'server' => $server,
'port' => $port,
'db' => $db,
];
if ($create_user) {
$od['params']['user'] = $create_user_name;
$od['params']['password'] = $create_user_password;
}
} catch (\Throwable $e) {
$od['status'] = 'error';
$od['error'] = $e->getMessage();
}
return $od;
}
function action_check_db_create_create_pg() {
$od = ['status' => 'ok'];
try {
$str = array_key_exists('data', $_POST) ? $_POST['data'] : '';
$arr = @cnd_json_decode($str, true);
if (!is_array($arr)) {
throw new Exception(' ');
}
$keys = ['server', 'port', 'user', 'password', 'db', 'user_name', 'user_password', 'tpldb'];
foreach ($keys as $key) {
if (!array_key_exists($key, $arr)) {
throw new Exception(" `{$key}`");
}
}
$server = ntrima($arr, 'server');
if (!$server) {
throw new Exception(" ");
}
$port = ntrima($arr, 'port');
if ($port !== null) {
if (!intval($port)) {
throw new Exception(" ");
}
}
$user = ntrima($arr, 'user');
if (!$user) {
throw new Exception(" ");
}
$password = ntrima($arr, 'password');
if (!$password) {
throw new Exception(" ");
}
$db = ntrima($arr, 'db');
if (!$db) {
throw new Exception(" ");
}
$tpldb = ntrima($arr, 'tpldb');
if (!$tpldb) {
throw new Exception(" ");
}
$create_user = true; //is_bool($arr['create_user']) ? $arr['create_user'] : false; //$_SERVER['SERVER_ADDR']
$create_user_name = ntrima($arr, 'user_name');
$create_user_password = ntrima($arr, 'user_password');
$create_user_name = $create_user_name ? $create_user_name : $db;
$create_user_password = $create_user_password ? $create_user_password : mk_password(45);
//$create_user_host = $create_user_host ? $create_user_host : '%';
$dsn = sprintf('pgsql:host=%s;port=%s;dbname=%s;user=%s;password=%s', $server, $port, $tpldb, $user, $password);
$pdo = new PDO($dsn, null, null, mkPDOConnetionOptions([
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
\PDO::ATTR_AUTOCOMMIT => 1
]));
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$pdo->setAttribute(\PDO::ATTR_AUTOCOMMIT, 1);
$query = [
"DROP DATABASE IF EXISTS \"{$db}\";",
"DROP ROLE IF EXISTS \"{$create_user_name}\";",
"CREATE ROLE \"{$create_user_name}\" WITH LOGIN PASSWORD '{$create_user_password}';",
"CREATE DATABASE \"{$db}\" OWNER=\"{$create_user_name}\" TEMPLATE=\"{$tpldb}\" ENCODING=UTF8;",
];
foreach ($query as $command){
$pdo->exec( $command);
}
$od['params'] = [
'server' => $server,
'port' => $port,
'db' => $db,
];
$od['params']['user'] = $create_user_name;
$od['params']['password'] = $create_user_password;
} catch (\Throwable $e) {
$od['status'] = 'error';
$od['error'] = $e->getMessage();
}
return $od;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="check_redis_connection">
function action_check_redis_connection() {
$od = ['status' => 'ok'];
try {
$str = array_key_exists('data', $_POST) ? $_POST['data'] : '';
$arr = @cnd_json_decode($str, true);
if (!is_array($arr)) {
throw new Exception(' ');
}
$od['version'] = get_redis_version($arr);
} catch (\Throwable $e) {
$od['status'] = 'error';
$od['error'] = $e->getMessage();
}
return $od;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="exec_fs_step">
function exec_fs_root_dir() {
if (defined('DEBUG_MODE') && DEBUG_MODE === true) {
$path = '/var/VHOSTS/exp_der_map';
if (!(file_exists($path) && is_dir($path))) {
@mkdir($path, 0755, true);
}
if (!(file_exists($path) && is_dir($path))) {
throw new Exception(sprintf(' %s', $path));
}
return $path;
} else {
get_webroot(); // throws error if script not in webroot
get_webroot_name();
return get_install_dir();
}
}
function exec_fs_step_dir(DOMElement $node) {
$relative_path = trim(str_ireplace(['\', '/'], DIRECTORY_SEPARATOR, $node->getAttribute('p')), '\/');
if (mb_strlen($relative_path, 'UTF-8')) {
$absolute_path = rtrim(exec_fs_root_dir(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $relative_path . DIRECTORY_SEPARATOR . $node->getAttribute('n');
} else {
$absolute_path = rtrim(exec_fs_root_dir(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $node->getAttribute('n');
}
if (!(file_exists($absolute_path) && is_dir($absolute_path))) {
@mkdir($absolute_path, 0755, true);
}
}
function exec_fs_step_file(DOMElement $node) {
$relative_path = trim(str_ireplace(['\', '/'], DIRECTORY_SEPARATOR, $node->getAttribute('p')), '\/');
if (mb_strlen($relative_path, 'UTF-8')) {
$absolute_path = rtrim(exec_fs_root_dir(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $relative_path . DIRECTORY_SEPARATOR . $node->getAttribute('n');
} else {
$absolute_path = rtrim(exec_fs_root_dir(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $node->getAttribute('n');
}
$overwrite = !!(intval($node->getAttribute('f')) & 0x01);
$chmod = intval($node->getAttribute('h'));
$date_str = $node->getAttribute('m');
$date = xml_2_datetime($date_str);
$alias = $node->getAttribute('a');
if (!$overwrite) {
if (file_exists($absolute_path)) {
return;
}
}
$content = load_file($alias);
if (null === $content) {
throw new Exception("cant unpack file `{$relative_path}/{$node->getAttribute('n')}`");
}
file_put_contents($absolute_path, $content);
if ($chmod && !is_windows_os()) {
chmod($absolute_path, $chmod);
}
if ($date) {
touch($absolute_path, $date->getTimestamp());
}
}
function action_exec_fs_step() {
$od = ['status' => 'ok'];
try {
$stepsToExecute = [];
$mxSteps = ntrim(array_key_exists('multistep', $_GET) ? $_GET['multistep'] : '');
if ($mxSteps) {
$astepstr = explode(',', $mxSteps);
foreach ($astepstr as $stepStr) {
$stepIndex = intval($stepStr);
if ($stepIndex) {
$stepsToExecute[] = $stepIndex;
}else if($stepIndex===0 && $stepStr==='0'){
$stepsToExecute[]=0;
}
}
} else {
$step = intval(ntrima($_GET, 'step'));
if ($step) {
$stepsToExecute[] = $step;
}else if($step===0 && ntrima($_GET, 'step')==='0'){
$stepsToExecute[]=0;
}
}
$xml = load_file('install.xml');
$dom = new DOMDocument();
$dom->loadXML($xml);
$dirs = $dom->getElementsByTagName('d');
foreach ($stepsToExecute as $step) {
$node = null;
if ($dirs->length > $step) {
$node = $dirs->item($step);
} else {
$files = $dom->getElementsByTagName('f');
$cu_step = $step - $dirs->length;
$node = $files->item($cu_step);
}
if ($node) {/* @var $node \DOMElement */
if ($node->tagName === 'd') {
exec_fs_step_dir($node);
} else if ($node->tagName === 'f') {
exec_fs_step_file($node);
} else {
throw new Exception("invalid filesystem tag `{$node->tagName}`");
}
} else {
$od['failstep'] = $step;
throw new Exception(' ' . $step);
}
}
} catch (\Throwable $e) {
$od['status'] = 'error';
$od['error'] = $e->getMessage();
}
return $od;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="write_config">
function action_write_config() {
$od = ['status' => 'ok'];
try {
$ap_dir = $absolute_path = rtrim(exec_fs_root_dir(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'config';
$rt_dir = rtrim(exec_fs_root_dir(), DIRECTORY_SEPARATOR);
$alldata = get_post_data();
$db = $alldata['db'];
$init_cmd = "'init'=>'SET NAMES utf8mb4;',";
if ($db['driver'] === 'pgsql') {
$init_cmd = "//";
}
$dbw = <<<DBCONFA090876
<?php
/*
* database config file
*/
return \Config\DBPool::F([
[
'driver'=>'{$db['driver']}',
'id' => 'default',
'server' => '{$db['server']}',
'db' => '{$db['db']}',
'user' => '{$db['user']}',
'password' => '{$db['password']}',
{$init_cmd}
'attributes'=>\Helpers\Helpers::optionalRequireArray(__DIR__.DIRECTORY_SEPARATOR.'pdo-options.php',[]),
]
]);
DBCONFA090876;
file_put_contents($ap_dir . DIRECTORY_SEPARATOR . 'database.conf.php', $dbw);
if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'pdo-options.php') && is_file(__DIR__ . DIRECTORY_SEPARATOR . 'pdo-options.php')) {
file_put_contents($ap_dir . DIRECTORY_SEPARATOR . 'pdo-options.php', file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'pdo-options.php'));
}
$redis = $alldata['redis'];
$redis_port_value = intval(ntrima($redis, 'port'));
if (!$redis_port_value) {
$redis_port_value = 'null';
}
$redis_password_value = ntrima($redis, 'password');
if (!$redis_password_value) {
$redis_password_value = 'null';
} else {
$redis_password_value = sprintf('\'%s\'', $redis_password_value);
}
$rdw = <<<REDISCONF593T67
<?php
/*
* redis config file
*/
return [
'server' => '{$redis['server']}',
'port' => {$redis_port_value},
'password' => {$redis_password_value}
];
REDISCONF593T67;
file_put_contents($ap_dir . DIRECTORY_SEPARATOR . 'redis.conf.php', $rdw);
$phpva = explode('.', PHP_VERSION);
$php_v = implode('.', array_slice($phpva, 0, 2));
$hostname = array_key_exists('HTTP_HOST', $_SERVER) ? $_SERVER['HTTP_HOST'] : 'leader.map.local';
$ng_conf = <<<MG_NGINX_CONF_EXAMPLE
server {
listen 80 default_server;
listen [::]:80 default_server;
#########################################
# ssl
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
# ssl on;
# ssl_certificate -path-to-certificate-;
# ssl_certificate_key -path-to-private-key-;
# ssl_session_timeout 5m;
#########################################
server_name {$hostname};
root {$rt_dir}/www;
access_log {$rt_dir}/log/nginx_access.log;
error_log {$rt_dir}/log/nginx_error.log;
client_max_body_size 1024m;
index index.php index.html;
error_page 404 /e404;
location / {
# - CORS
# Access-Control-*
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,x-auth-token,x-ws-common-auth' always;
add_header 'Access-Control-Expose-Headers' 'Content-Type,x-auth-token,x-ws-common-auth' always;
add_header 'Access-Control-Max-Age' 1728000;
if (\$request_method = 'OPTIONS') {
# CORS
#
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,x-auth-token,x-ws-common-auth' always;
add_header 'Access-Control-Expose-Headers' 'Content-Type,x-auth-token,x-ws-common-auth' always;
add_header 'Content-Type' 'text/plain charset=UTF-8' always;
add_header 'Content-Length' 0 always;
add_header 'Access-Control-Max-Age' 1728000 always;
return 204;
}
try_files \$uri @try_php;
}
location /privates_send_xaccel{
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,x-auth-token,x-ws-common-auth' always;
add_header 'Access-Control-Expose-Headers' 'Content-Type,x-auth-token,x-ws-common-auth' always;
add_header 'Access-Control-Max-Age' 1728000 always;
alias {$rt_dir}/_private_media_cache;
internal;
}
location /publics_send_xaccel{
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,x-auth-token,x-ws-common-auth' always;
add_header 'Access-Control-Expose-Headers' 'Content-Type,x-auth-token,x-ws-common-auth' always;
add_header 'Access-Control-Max-Age' 1728000 always;
alias {$rt_dir}/www/media;
internal;
}
#########################################
#
# - fastcgi_pass php-fpm
# , php
#
#########################################
location @try_php {
include fastcgi_params;
fastcgi_pass unix:/var/run/php/php{$php_v}-fpm.sock;
fastcgi_param SCRIPT_FILENAME \$document_root/index.php;
fastcgi_read_timeout 300;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php{$php_v}-fpm.sock;
}
location ~ /\.ht {
deny all;
}
location = /e404{
include fastcgi_params;
fastcgi_pass unix:/var/run/php/php{$php_v}-fpm.sock;
fastcgi_param SCRIPT_FILENAME \$document_root/lost.php;
fastcgi_intercept_errors off;
}
location @none_found{
include fastcgi_params;
fastcgi_pass unix:/var/run/php/php{$php_v}-fpm.sock;
fastcgi_param SCRIPT_FILENAME \$document_root/lost.php;
fastcgi_intercept_errors off;
}
}
MG_NGINX_CONF_EXAMPLE;
file_put_contents($ap_dir . 'nginx.example.config', $ng_conf);
} catch (\Throwable $e) {
$od['status'] = 'error';
$od['error'] = $e->getMessage();
}
return $od;
}
//</editor-fold>
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="run">
$action = array_key_exists('action', $_GET) ? $_GET['action'] : null;
if ($action) {
$fn = "action_{$action}";
if (function_exists($fn)) {
$od = call_user_func($fn);
while (ob_get_level()) {
ob_end_clean();
}
header('Content-Type: application/json');
echo cnd_json_encode($od);
die();
} else {
while (ob_get_level()) {
ob_end_clean();
}
header('Content-Type: applcation/json');
echo cnd_json_encode(['status' => 'error', 'error' => 'no action found']);
die();
}
} else {
$stepRaw = array_key_exists('step', $_POST) ? $_POST['step'] : "";
$step = intval($stepRaw);
if($stepRaw==="2mysql" || $stepRaw==="2pgsql"){
$step = $stepRaw;
}
if (function_exists("step_{$step}")) {
call_user_func("step_{$step}");
} else {
step_0();
}
}
//</editor-fold>
?>ec3f1dccb0ed444990bf08a48a1fbf2f:sql.sql@0000010528BZh91AY&SY
Did this file decode correctly?
Original Code
<?php
CONST DEBUG_MODE=false;
ob_start();
//<editor-fold defaultstate="collapsed" desc="utils">
function cnd_json_encode($x) {
if (function_exists('json_encode')) {
return json_encode($x);
}
return '[]';
}
function cnd_json_decode($x, $n) {
if (function_exists('json_decode')) {
return json_decode($x, true);
}
return [];
}
function ntrim($str) {
if (is_string($str)) {
$x = trim($str);
if (mb_strlen($x, 'UTF-8')) {
return $x;
}
}
return null;
}
function ntrima($in_a, $key) {
if (is_array($in_a)) {
return ntrim(array_key_exists($key, $in_a) ? $in_a[$key] : null);
}
return null;
}
function mk_password($len) {
$literals = '12345678900987654321qwertyuiopPOIUYTREWQQWERTYUIOPpoiuytrewqasdfghjkllkjhgfdsaASDFGHJKLLKJHGFDSAzxcvbnmMNBVCXZZXCVBNMmnbvcxz+=&';
$len = intval($len);
$len < 6 ? $len = 6 : 0;
$r = [];
for ($i = 0; $i < $len; $i++) {
$r[] = mb_substr($literals, mt_rand(0, mb_strlen($literals, 'UTF-8')), 1, 'UTF-8');
}
return implode('', $r);
}
function mkPDOConnetionOptions(array $optionList) {
$extraOptions = [];
if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'pdo-options.php')) {
$extraOptions = require __DIR__ . DIRECTORY_SEPARATOR . 'pdo-options.php';
}
return $optionList + $extraOptions;
}
function check_db_connection_ph($retunComplex = false) {
try {
$alldata = get_post_data();
$db_data = array_key_exists('db', $alldata) && is_array($alldata['db']) ? $alldata['db'] : [];
if (!is_array($db_data)) {
throw new Exception(' ');
}
$keys = ['server', 'port', 'user', 'password', 'db', 'driver'];
foreach ($keys as $key) {
if (!array_key_exists($key, $db_data)) {
throw new Exception(" : `{$key}`");
}
}
$server = ntrima($db_data, 'server');
if (!$server) {
throw new Exception(" ");
}
$port = ntrima($db_data, 'port');
if ($port !== null) {
if (!intval($port)) {
throw new Exception(" ");
}
}
$user = ntrima($db_data, 'user');
if (!$user) {
throw new Exception(" ");
}
$password = ntrima($db_data, 'password');
if (!$password) {
throw new Exception(" ");
}
$db = ntrima($db_data, 'db');
if (!$db) {
throw new Exception(" ");
}
$driver = ntrima($db_data, 'driver');
if (!$driver) {
throw new Exception("No PDO driver defined");
}
if ($driver === 'mysql') {
$pdo = new PDO(sprintf('mysql:host=%s;port=%s;dbname=%s;charset=utf8', $server, ($port ? $port : 3306), $db), $user, $password,
mkPDOConnetionOptions([
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
]));
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$statement = $pdo->prepare('SELECT @@VERSION');
$statement->execute([]);
$version = null;
$version_row = $statement->fetch(\PDO::FETCH_NUM);
$statement->closeCursor();
if ($version_row && is_array($version_row) && array_key_exists(0, $version_row)) {
$version = $version_row[0];
}
if (!$version) {
throw new Exception(' mySQL');
}
if ($retunComplex) {
return ['version' => $version, 'pdo' => $pdo];
}
return $version;
} else if ($driver === 'pgsql') {
//pgsql:host=localhost;port=5432;dbname=testdb;user=bruce;password=mypass
$pdo = new PDO(sprintf('pgsql:host=%s;port=%s;dbname=%s;user=%s;password=%s', $server, ($port ? $port : 5432), $db, $user, $password),null,null,
mkPDOConnetionOptions([
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
]));
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$statement = $pdo->prepare('SELECT version();');
$statement->execute([]);
$version = null;
$version_row = $statement->fetch(\PDO::FETCH_NUM);
$statement->closeCursor();
if ($version_row && is_array($version_row) && array_key_exists(0, $version_row)) {
$version = $version_row[0];
}
if (!$version) {
throw new Exception(' pgsql');
}
if ($retunComplex) {
return ['version' => $version, 'pdo' => $pdo];
}
return $version;
}
} catch (\Throwable $e) {
throw $e;
}
}
function get_post_data() {
$data_str = array_key_exists('data', $_POST) ? $_POST['data'] : null;
$data = [];
if ($data_str) {
$data = @cnd_json_decode($data_str, true);
}
$data = is_array($data) ? $data : [];
return $data;
}
function sql_driver_by_version($version) {
$driver = 'mysql5';
if(preg_match("/postgres/i", $version)){
$driver='pgsql';
}else if (preg_match("/maria/i", $version)) {
$driver = 'maria';
} else {
$m = [];
if (preg_match("/^(?P<maj>\d{1,})\.(\d{1,})/", $version, $m)) {
if (intval($m['maj']) >= 8) {
$driver = 'mysql8';
}
}
}
return $driver;
}
function parse_steps_pg(){
$alist = explode('-- --------------------------------------------------------', load_file('postgres.sql'));
$clean_steps = [];
foreach ($alist as $task) {
$task_name = 'opertaion';
$m = [];
if (preg_match("/DBTASK\:(?P<tsk>.*)$/m", $task, $m)) {
$task_name = trim($m['tsk']);
}
$clean_steps[] = ['name' => $task_name, 'task' => $task];
}
return $clean_steps;
}
function parse_steps($version) {
$driver = sql_driver_by_version($version);
if($driver==='pgsql'){
return parse_steps_pg();
}
$alist = explode('-- --------------------------------------------------------', load_file('sql.sql'));
$clean_steps = [];
foreach ($alist as $task) {
$task_name = 'opertaion';
$m = [];
if (preg_match("/DBTASK\:(?P<tsk>.*)$/m", $task, $m)) {
$task_name = trim($m['tsk']);
}
// if (mb_strpos($task, "DRIVER:~{$driver}", 0, 'UTF-8') !== false) {
// continue;
// }
if (mb_strpos($task, "DRIVER:", 0, 'UTF-8') !== false) {
if (mb_stripos($task, "DRIVER:{$driver}", 0, 'UTF-8') === false) {
continue;
}
}
$clean_steps[] = ['name' => $task_name, 'task' => $task];
}
return $clean_steps;
}
function do_out($content, $step) {
while (ob_get_level()) {
ob_end_clean();
}
?>
<!DOCTYPE html>
<html lang="ru">
<head>
<style type="text/css">
html,body {
font-size: 14px;
font-family: arial,sans-serif;
margin: 0;
padding: 0;
height: 100%;
max-height: 100%;
overflow: hidden;
}
body {
background: #48a2ef;
color: white;
}
.InstallerScreen {
box-sizing: border-box;
width: 100%;
height: 100%;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
.popup-backdrop {
position: fixed;
display:none;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.5);
}
.popup-backdrop-content {
box-sizing: border-box;
width: 100%;
height: 100%;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
.popup-window {
background: white;
padding: .5em;
box-sizing: border-box;
max-height: 100%;
width: 100%;
max-width: 640px;
border-radius: 3px;
box-shadow: 3px 3px 10px #322e2e;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: stretch;
}
.popup-header {
color: black;
height: 24px;
display: flex;
min-height: 24px;
max-height: 24px;
flex-direction: row;
justify-content: space-between;
align-items: center;
flex-wrap: nowrap;
}
.popup-header-text {
font-weight: bold;
font-size: 16px;
}
.popup-header-close {
box-sizing: border-box;
width: 24px;
height: 24px;
min-width: 24px;
max-width: 24px;
cursor: pointer;
position:relative;
overflow:hidden;
}
.popup-header-close:before,.popup-header-close:after{
content:' ';
box-sizing:border-box;
border-left:1px solid black;
border-right:1px solid black;
width:2px;
position:absolute;
top:-25%;
left:50%;
margin-left:-1px;
height:150%;
transform-origin:center center;
}
.popup-header-close:before{
transform:rotate(-45deg);
}
.popup-header-close:after{
transform:rotate(45deg);
}
.popup-body {
height: 100%;
box-sizing: border-box;
padding: .5em;
overflow: auto;
}
.popup-body-content {
min-height: 50px;
color: black;
}
.Installer-intro-header {
font-size: 26px;
text-align: center;
margin-bottom: 10px;
}
.installer-intro-text a {
color: #3e3c3c;
font-weight: bold;
}
.installer-intro-content form {
margin: 0;
margin-top: 20px;
text-align: center;
}
.form-btn {
display: inline-block;
line-height: 36px;
border: 1px solid white;
background: white;
color: black;
padding: 0 2em;
box-shadow: 1px 1px 1px black;
transition: all .3s;
cursor: pointer;
user-select: none;
}
.form-btn:hover {
box-shadow: -1px -1px 1px dimgray;
}
.InstallerScreen.InstallerScreen1 {
box-sizing: border-box;
width: 100%;
height: 100%;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
.installer-checks-window-backdrop {
box-sizing: border-box;
width: 100%;
height: 100%;
overflow: hidden;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
flex-wrap: nowrap;
}
.installer-checks-window {
background: white;
border-radius: 3px;
color: black;
box-sizing: border-box;
padding: .5em;
box-shadow: 3px 3px 10px #707070;
max-height: 95%;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: stretch;
}
.InstallerScreen.InstallerScreen1 {
}
.installer-compatibility-text {
font-size: 13px;
}
.InstallerScreen1 .Installer-intro-header {
height: 46px;
max-height: 46px;
min-height: 46px;
}
.installer-checks-window form {
box-sizing: border-box;
height: 40px;
max-height: 40px;
min-height: 40px;
overflow: hidden;
}
.installer-compatibility-list-scr {
height: 100%;
overflow: auto;
padding: .5em;
}
ul.installer-compatibility-list li {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: flex-start;
flex-wrap: nowrap;
}
ul.installer-compatibility-list {
padding: 0 1em;
}
.installer-check-notice {
width: 100%;
margin-left: 10px;
}
li.installer-check-success b {
white-space: nowrap;
}
li.installer-check-success .installer-check-notice {
color: green;
}
.installer-checks-window form {
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: center;
}
.installer-checks-window form .form-btn {
border: 1px solid #48a2ef;
background: #48a2ef;
color: white;
}
ul.installer-compatibility-list li b {
white-space: nowrap;
}
ul.installer-compatibility-list li {
margin-bottom: 10px;
}
li.installer-check-warning .installer-check-notice {
color: darkorange;
}
li.installer-check-failed .installer-check-notice {
color: crimson;
}
table.installer-compatibility-table {
border: none;
border-collapse: collapse;
width: 100%;
box-sizing: border-box;
max-width: 100%;
overflow: hidden;
margin: 10px 0;
}
.installer-compatibility-list-scr {
box-sizing: border-box;
}
table.installer-compatibility-table tr {
box-sizing: border-box;
overflow: hidden;
}
table.installer-compatibility-table tr td {
padding-top: 5px;
padding-bottom: 5px;
box-sizing: border-box;
vertical-align: top;
}
td.installer-check-name {
font-weight: bold;
white-space: nowrap;
}
tr.installer-check-success td.installer-check-notice-cell {
color: green;
}
tr.installer-check-warning td.installer-check-notice-cell {
color: darkorange;
}
tr.installer-check-failed td.installer-check-notice-cell {
color: crimson;
}
.installer-checks-window form {
justify-content: space-between;
margin-top: 10px;
}
.InstallerScreen.InstallerScreen2 {
}
.installer-db-window-backdrop {
box-sizing: border-box;
width: 100%;
height: 100%;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
.installer-db-window {
box-sizing: border-box;
/* width: 100%; */
max-width: 640px;
background: white;
padding: 10px;
border-radius: 3px;
box-shadow: 3px 3px 10px #666565;
color: black;
max-height: 95%;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: stretch;
}
.Installer-intro-header {
height: 46px;
max-height: 46px;
min-height: 46px;
}
form#step2form {
height: 50px;
max-height: 50px;
min-height: 50px;
border-top: 1px solid silver;
margin-top: 10px;
}
.installer-db-form {
height: 100%;
overflow: auto;
padding: 5px;
}
.installer-db-form form {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.db-form-row {
box-sizing: border-box;
margin-bottom: 10px;
}
.db-form-row input[type=text] {
box-sizing: border-box;
width: 100%;
display: block;
box-shadow: none;
height: 3em;
border: 1px solid silver;
outline: none;
border-radius: 0;
padding: 0 .5em;
box-sizing: border-box;
min-width: 30em;
}
.db-form-row label {
display: block;
margin-bottom: 3px;
font-size: .9em;
}
.db-form-row input[type=checkbox] {
display: none;
}
.db-form-row input[type=checkbox]+label{
font-size:inherit;
display:flex;
flex-direction:row;
justify-content:flex-start;
align-items:center;
padding:1px;
cursor:pointer;
user-select:none;
}
.db-form-row input[type=checkbox]+label:before{
content:' ';
box-sizing:border-box;
outline-offset:0;
outline:1px solid #00acc8;
margin-right:.5em;
width:1.25em;
min-width:1.25em;
max-width:1.25em;
height:1.25em;
min-height:1.25em;
max-height:1.25em;
line-height:0;
transition:all .3s;
}
.db-form-row input[type=checkbox]:checked+label:before{
border:1px solid white;
background:#00acc8;
}
.db-form-button-row .form-btn {
background: #00acc8;
border: 1px solid #00acc8;
color: white;
}
.db-form-button-row {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
div#db-check-result {
margin: 10px 0;
font-size: .9em;
color: crimson;
}
.db-form-note {
box-sizing: border-box;
margin: 10px 0;
padding: 10px;
border: 1px solid red;
border-radius: 3px;
background: yellow;
}
div#db-check-result.success {
color: green;
}
form#step2form {
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: center;
}
div#step2submit {
background: #48a2ef;
border: #48a2ef;
color: white;
}
.db-form-button-row .form-btn {
background: #48a2ef;
border: #48a2ef;
}
form#step3form {
height: 45px;
min-height: 45px;
max-height: 45px;
margin-top: 10px;
border-top: 1px solid silver;
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: center;
}
div#step3submit {
border-color: #48a2ef;
background: #48a2ef;
color: white;
}
.db-create-progress {
box-sizing: border-box;
position: relative;
display: block;
width: 100%;
border: 1px solid silver;
height: 36px;
}
.db-create-progress-element {
box-sizing: border-box;
position: absolute;
top: 0;
left: 0;
height: 100%;
background: #48a2ef;
width: 17%;
max-width: 100%;
transition: all .5s;
}
.db-create-progress-tesxt {
box-sizing: border-box;
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
font-weight: bold;
font-size: 24px;
color: maroon;
}
form#step4form {
box-sizing: border-box;
height: 50px;
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: center;
border-top: 1px solid silver;
}
div#step4submit {
background: #48a2ef;
border: #48a2ef;
color: white;
}
.db-create-progress-info {
font-size: .9em;
margin: 5px 0;
color: black;
white-space: nowrap;
max-width: 1px;
width:1px;
overflow:visible;
box-sizing: border-box;
}
.db-create-progress-info-container{
box-sizing: border-box;
width:100%;
max-width:100%;
overflow:hidden;
}
.db-create-progress-info.warning {
color: crimson;
}
.db-create-progress-info.success {
color: green;
}
form#step5form {
box-sizing: border-box;
margin-top: 10px;
height: 50px;
max-height: 50px;
min-height: 50px;
border-top: 1px solid silver;
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: center;
}
div#step5submit {
background: #48a2ef;
color: white;
border: 1px solid #48a2ef;
}
form#stepxform {
height: 50px;
min-height: 50px;
max-height: 50px;
border-top: 1px solid silver;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
div#stepxsubmit {
color: white;
background: #48a2ef;
border-color: #48a2ef;
margin-left: auto;
}
.popup-backdrop {
top: 0;
left: 0;
}
.path-info {
box-sizing: border-box;
font-size: 12px;
}
.path-info-header {
font-weight: bold;
}
.path-info-image {
box-sizing: border-box;
padding: .5em;
}
.path-item {
padding-left: 1em;
}
.path-info-image {
}
.path-info-image>.path-item {
padding-left: 0;
}
.path-item-header {
box-sizing: border-box;
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
}
.path-item-header i {
width: 1.5em;
min-width: 1.5em;
max-width: 1.5em;
height: 1.5em;
margin-right: .5em;
}
.path-item-header i svg {
box-sizing: border-box;
width: 100%;
height: 100%;
}
span.path-cmt {
margin-left: .5em;
font-size: .9em;
font-style: italic;
}
.path-item-header {
margin-bottom: 5px;
}
.ignore-upport {
box-sizing: border-box;
color: black;
margin: 3px 0 5px 0;
}
.installer-check-notice a#fs_req_btn {
color: #787878;
font-weight: bold;
}
.ignore-upport input[type=checkbox] {
display: none;
}
.ignore-upport input[type=checkbox]+label{
box-sizing:border-box;
padding:1px;
display:flex;
flex-direction:row;
align-items:center;
justify-content:flex-start;
cursor:pointer;
}
.ignore-upport input[type=checkbox]+label:before{
content:' ';
width:1.25em;
min-width:1.25em;
max-width:1.25em;
margin-right:5px;
outline-offset:0;
outline:1px solid #00acc8;
height:1.25em;
transition:all .3s;
}
.ignore-upport input[type=checkbox]:checked+label:before{
border:1px solid white;
background:#00acc8;
}
.window-footer {
box-sizing: border-box;
height: 50px;
min-height: 50px;
max-height: 50px;
border-top: 1px solid silver;
margin-top: 10px;
}
.window-footer-content {
box-sizing: border-box;
width: 100%;
height: 100%;
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
}
.window-footer-content a.form-btn {
margin-left: auto;
background: #48a2ef;
border-color: #48a2ef;
color: white;
text-decoration: none;
}
.db-form-select {
box-sizing: border-box;
width: 100%;
outline: 1px solid silver;
height: 2.5em;
cursor: pointer;
margin: 0;
margin-bottom: 2em;
border: none;
box-shadow: none;
overflow: hidden;
position: relative;
}
.db-form-select > select{
margin:0;padding:0 0.5em;outline:none;box-shadow:none;appearance:none;border:none;width:100%;height:100%;box-sizing:border-box;cursor:pointer;
}
.db-form-select::after{
content: '\25be';
width: 30px;
height: 100%;
position:absolute;
top:0;
right:0;
display: flex;
z-index: 1;
flex-direction: row;
justify-content: center;
align-items: center;
pointer-events: none;
color: dimgray;
font-size: 22px;
}
.db-form-note-inner textarea {
box-sizing: border-box;
width: 100%;
outline: none;
margin: .5em 0;
font-family: monospace;
resize: none;
height: 5em;
background: transparent;
background: rgba(0,0,0,0);
color: navy;
font-size: 12px;
}
</style>
<script>
function add_trg(tid, wid) {
var c = document.getElementById(tid);
if (c) {
c.addEventListener('click', function (e) {
e.stopPropagation();
e.preventDefault ? e.preventDefault() : e.returnValue = false;
var pop = document.getElementById(wid);
if (pop) {
pop.style.display = 'block';
}
});
}
}
function stop_props(id) {
var rqw = document.getElementById(id);
if (rqw) {
rqw.addEventListener('click', function (e) {
e.stopPropagation();
});
}
}
function add_ctrg(tid, wid) {
var c = document.getElementById(tid);
if (c) {
c.addEventListener('click', function (e) {
e.stopPropagation();
e.preventDefault ? e.preventDefault() : e.returnValue = false;
var pop = document.getElementById(wid);
if (pop) {
pop.style.display = 'none';
}
});
}
}
</script>
</head>
<body>
<div class="InstallerScreen InstallerScreen<?php echo $step ?>">
<?php echo $content ?>
</div>
<div style="display:none">
<?xml version="1.0" encoding="iso-8859-1"?>
<svg version="1.1" id="folder" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 317.826 317.826" style="enable-background:new 0 0 317.826 317.826;" xml:space="preserve">
<g>
<polygon style="fill:#13829B;" points="260.32,95.194 260.32,134.194 57.5,134.194 7.5,265.194 7.5,52.634 133.91,52.634
153.91,95.194 "/>
<g>
<polygon style="fill:#28D2E4;" points="310.32,134.194 260.32,265.194 7.5,265.194 57.5,134.194 "/>
<path style="fill:#22313F;" d="M310.32,126.693h-42.5v-31.5c0-4.142-3.358-7.5-7.5-7.5H158.672l-17.974-38.25
c-1.236-2.63-3.881-4.31-6.788-4.31H7.5c-4.142,0-7.5,3.358-7.5,7.5v212.56c0,4.092,3.335,7.501,7.504,7.501
c0.004,0,0.008-0.001,0.013-0.001H260.32c3.11,0,5.897-1.92,7.007-4.826l50-131C319.2,131.962,315.569,126.693,310.32,126.693z
M15,60.134h114.148l17.974,38.25c1.236,2.63,3.881,4.31,6.788,4.31h98.91v24H57.5c-3.11,0-5.898,1.92-7.007,4.826L15,224.511
V60.134z M255.155,257.693H18.39l44.275-116c10.806,0,225.962,0,236.765,0L255.155,257.693z"/>
</g>
</g>
</svg>
<?xml version="1.0" encoding="iso-8859-1"?>
<svg version="1.1" id="file" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 512.002 512.002" style="enable-background:new 0 0 512.002 512.002;" xml:space="preserve">
<path style="fill:#ECB45C;" d="M442.167,263.758h-23.273H255.985H93.076H69.803c-1.607,0-3.176,0.163-4.69,0.473
c-5.303,1.085-9.948,3.973-13.269,7.997c-3.32,4.023-5.314,9.18-5.314,14.803v201.697c0,3.213,0.652,6.274,1.829,9.059
c2.945,6.962,9.179,12.192,16.753,13.742c1.514,0.31,3.083,0.473,4.69,0.473h186.182h186.182c12.853,0,23.273-10.42,23.273-23.273
V287.03C465.44,274.178,455.02,263.758,442.167,263.758z"/>
<path style="fill:#E0E0E2;" d="M46.531,287.03c0-12.853,10.42-23.273,23.273-23.273h23.273h162.909h162.909h23.273
c12.853,0,23.273,10.42,23.273,23.273V179.018c-0.321,12.573-10.589,22.672-23.242,22.672c-0.012,0-0.022,0-0.031,0h-23.273H287.016
c-12.853,0-23.273-10.42-23.273-23.273V46.545V23.273c0-9.413,5.669-17.898,14.367-21.501c2.993-1.24,6.142-1.801,9.256-1.753
C287.248,0.016,287.133,0,287.016,0H69.803C56.951,0,46.531,10.42,46.531,23.273C46.531,23.273,46.531,287.03,46.531,287.03z"/>
<path style="fill:#C6C5CA;" d="M263.743,23.273v23.273v131.873c0,12.853,10.42,23.273,23.273,23.273h131.879h23.273
c0.009,0,0.019,0,0.031,0c12.653,0,22.921-10.1,23.242-22.672c0.005-0.202,0.031-0.397,0.031-0.6c0-4.822-1.486-9.286-3.998-13.002
c-0.003-0.005-0.006-0.009-0.009-0.014c-0.397-0.586-0.824-1.153-1.271-1.699c-0.036-0.045-0.071-0.092-0.109-0.137
c-0.424-0.512-0.875-1.001-1.339-1.474c-0.073-0.073-0.144-0.147-0.217-0.22c-0.205-0.2-0.394-0.419-0.605-0.613L303.472,6.816
c-0.483-0.484-0.991-0.936-1.508-1.37c-0.157-0.13-0.315-0.253-0.475-0.379c-0.375-0.299-0.763-0.59-1.159-0.867
c-0.189-0.132-0.379-0.264-0.571-0.389c-0.413-0.27-0.836-0.524-1.266-0.77c-0.166-0.095-0.33-0.199-0.498-0.289
c-0.562-0.301-1.14-0.577-1.728-0.833c-0.236-0.102-0.476-0.189-0.714-0.284c-0.389-0.155-0.784-0.299-1.184-0.433
c-0.27-0.09-0.541-0.177-0.813-0.256c-0.447-0.13-0.901-0.245-1.361-0.351c-0.202-0.047-0.403-0.102-0.608-0.144
c-0.645-0.129-1.303-0.227-1.967-0.299c-0.205-0.023-0.411-0.036-0.614-0.054c-0.541-0.045-1.086-0.074-1.638-0.082
c-3.114-0.048-6.263,0.515-9.256,1.753C269.414,5.374,263.743,13.86,263.743,23.273z"/>
<path style="fill:#57565C;" d="M271.263,348.017c-5.28,0-9.112,3.497-9.112,8.316v20.111h-6.166h-6.853v-20.111
c0-4.741-3.916-8.316-9.112-8.316c-5.278,0-9.109,3.497-9.109,8.316v59.933c0,4.763,4.001,8.496,9.109,8.496
c5.109,0,9.112-3.731,9.112-8.496v-22.393h6.853h6.166v22.393c0,4.763,4.003,8.496,9.112,8.496c5.109,0,9.112-3.731,9.112-8.496
v-59.933C280.375,351.592,276.459,348.017,271.263,348.017z"/>
<path style="fill:#FF9811;" d="M193.678,365.798h-6.467v15.486h6.467c4.082,0,6.294-1.157,6.294-7.26v-1.052
C199.972,366.94,197.76,365.798,193.678,365.798z"/>
<g>
<path style="fill:#57565C;" d="M193.853,348.017h-16.195c-0.121,0-0.24,0.003-0.36,0.011c-4.735,0.276-8.307,3.848-8.307,8.307
v59.933c0,4.763,4,8.495,9.106,8.495c5.109,0,9.112-3.731,9.112-8.495v-17.557h6.467c15.349,0,24.512-9.328,24.512-24.95v-0.881
C218.19,357.312,209.094,348.017,193.853,348.017z M199.972,374.024c0,6.102-2.212,7.26-6.294,7.26h-6.467v-15.486h6.467
c4.082,0,6.294,1.143,6.294,7.174V374.024z"/>
<path style="fill:#57565C;" d="M321.745,348.017h-16.19c-0.119,0-0.24,0.003-0.36,0.011c-4.737,0.275-8.308,3.846-8.308,8.307
v59.933c0,4.763,4,8.495,9.106,8.495c5.109,0,9.112-3.731,9.112-8.495v-17.557h6.467c15.349,0,24.512-9.328,24.512-24.95v-0.881
C346.082,357.312,336.984,348.017,321.745,348.017z M327.862,374.024c0,6.102-2.212,7.26-6.295,7.26h-6.467v-15.486h6.467
c4.082,0,6.295,1.143,6.295,7.174V374.024z"/>
</g>
<path style="fill:#FF9811;" d="M249.132,393.874v22.393c0,4.763-4.003,8.495-9.112,8.495c-5.108,0-9.109-3.731-9.109-8.495v-59.933
c0-4.819,3.831-8.316,9.109-8.316c5.196,0,9.112,3.575,9.112,8.316v20.111h6.853V263.758H93.076H69.803
c-12.853,0-23.273,10.42-23.273,23.273v201.697c0,12.853,10.42,23.273,23.273,23.273h186.182V393.874H249.132z M218.19,373.762
c0,15.622-9.163,24.95-24.512,24.95h-6.467v17.557c0,4.763-4.003,8.495-9.112,8.495c-5.106,0-9.106-3.731-9.106-8.495v-59.933
c0-4.459,3.572-8.029,8.307-8.307c0.119-0.006,0.239-0.011,0.36-0.011h16.195c15.239,0,24.337,9.295,24.337,24.861v0.883H218.19z"/>
</svg>
</div>
<div class="popup-backdrop" id="fs-req-backdrop" style="display:none">
<div class="popup-backdrop-content">
<div class="popup-window" id="fs-req-window">
<div class="popup-header"><div class="popup-header-text"> :</div><div id="fs-req-clo" class="popup-header-close"></div></div>
<div class="popup-body">
<div class="popup-body-content">
<div class="path-info">
<div class="path-info-header"> :</div>
<div class="path-info-image">
<div class="path-item">
<div class="path-item-header"><i><svg><use xlink:href="#folder"/></svg></i><span class="path-name">leader_map</span><span class="path-cmt"><-- </span></div>
<div class="path-item">
<div class="path-item-header"><i><svg><use xlink:href="#folder"/></svg></i><span class="path-name"><b style="color:crimson">www</b></span><span class="path-cmt"><-- webroot , www <b></b></span></div>
<div class="path-item">
<div class="path-item-header"><i><svg><use xlink:href="#file"/></svg></i><span class="path-name">installer.php</span><span class="path-cmt"><-- webroot</span></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
add_trg('fs_req_btn', 'fs-req-backdrop');
stop_props('fs-req-window');
add_ctrg('fs-req-backdrop', 'fs-req-backdrop');
add_ctrg('fs-req-clo', 'fs-req-backdrop');
</script>
</body>
</html>
<?php
die();
}
function load_file($filename) {
$raw = file_get_contents(__FILE__);
$search = 'ec3f1dccb0ed444' . '' . '990bf08a48a1fbf2f' . ':' . "{$filename}@";
$found = strpos($raw, $search);
if ($found !== null) {
$offset = $found + strlen($search);
$length_str = substr($raw, $offset, 10);
$len_int = intval($length_str);
$encoded = substr($raw, $offset + 10, $len_int);
$file_content = bzdecompress($encoded);
if (false !== $file_content && !is_int($file_content)) {
return $file_content;
} else if (is_int($file_content)) {
throw new Exception(' ');
}
}
return null;
}
function get_redis_version($redis_data) {
if (!is_array($redis_data)) {
throw new Exception(' ');
}
$keys = ['server', 'port', 'password'];
foreach ($keys as $key) {
if (!array_key_exists($key, $redis_data)) {
throw new Exception(" `{$key}`");
}
}
$server = ntrima($redis_data, 'server');
if (!$server) {
throw new Exception(" ");
}
$port = ntrima($redis_data, 'port');
if ($port !== null) {
if (!intval($port)) {
throw new Exception(" ");
}
}
$password = ntrima($redis_data, 'password');
$redis = new Redis();
if ($port) {
$redis->connect($server, $port);
} else {
$redis->connect($server);
}
if ($password) {
$redis->auth($password);
}
$ping = $redis->ping(time());
$key = 'installer_96f8076de0214d8b95adae036a91e15f';
$value = 'installer_ca59591c0f574d719e46665fb88d4052';
$redis->set($key, $value);
if ($redis->get($key) !== $value) {
throw new Exception("redis: read value difers");
}
$server_info = $redis->info('SERVER');
$version = 'unknown';
$arc = 'unknown';
if (is_array($server_info)) {
if (array_key_exists('redis_version', $server_info)) {
$version = $server_info['redis_version'];
}
if (array_key_exists('arch_bits', $server_info)) {
$arc = $server_info['arch_bits'];
}
}
return implode(' x', [$version, $arc]);
}
/**
*
* @param string $xml
* @return \DateTime
*/
function xml_2_datetime($xml) {
if (is_string($xml)) {
$m = [];
if (preg_match('/^(?P<y>\d{4})-(?P<m>\d{1,2})-(?P<d>\d{1,2})T(?P<h>\d{1,2}):(?P<i>\d{1,2}):(?P<s>\d{1,2})/', $xml, $m)) {
$d = new DateTime();
$d->setDate(intval($m['y']), intval($m['m']), intval($m['d']));
$d->setTime(intval($m['h']), intval($m['i']), intval($m['s']));
return $d;
}
}
return null;
}
function is_windows_os() {
if (defined('PHP_OS_FAMILY')) {
if (mb_strtoupper(mb_substr(PHP_OS_FAMILY, 0, 3, 'UTF-8'), 'UTF-8') === 'WIN') {
return true;
}
} else if (defined('PHP_OS')) {
if (mb_strtoupper(mb_substr(PHP_OS, 0, 3, 'UTF-8'), 'UTF-8') === 'WIN') {
return true;
}
}
return false;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="checks">
function checkphpver() {
if (version_compare(PHP_VERSION, '7.2.0', '>=')) {
return ['status' => true, 'message' => 'OK'];
}
return ['status' => false, 'message' => ' php7.2+'];
}
function checkmbstring() {
if (function_exists('mb_strlen')) {
return ['status' => true, 'message' => 'OK'];
}
return ['status' => false, 'message' => ' mbstrings'];
}
function checkjson() {
if (function_exists('json_encode')) {
return ['status' => true, 'message' => 'OK'];
}
return ['status' => false, 'message' => ' JSON'];
}
function checkDOM() {
$fails = [];
if (!function_exists('libxml_clear_errors')) {
$fails[] = " libxml";
}
if (!class_exists('\XMLWriter')) {
$fails[] = " XMLWriter";
}
if (!class_exists('\DOMDocument')) {
$fails[] = " DOM";
}
if (!count($fails)) {
return ['status' => true, 'message' => 'OK'];
}
return ['status' => false, 'message' => implode("\n", $fails)];
}
function checkcurl() {
if (function_exists('curl_init') && class_exists('\CURLFile')) {
return ['status' => true, 'message' => 'OK'];
} else if (function_exists('curl_init')) {
return ['status' => false, 'message' => ' libcUrl'];
}
return ['status' => false, 'message' => ' cUrl'];
}
function checkopenssl() {
if (function_exists('openssl_random_pseudo_bytes')) {
if (false === @openssl_random_pseudo_bytes(100)) {
return ['status' => false, 'message' => 'libopenssl '];
} else {
return ['status' => true, 'message' => 'OK'];
}
}
return ['status' => false, 'message' => ' OpenSSL'];
}
function checkldap() {
if (function_exists('ldap_bind')) {
return ['status' => true, 'message' => 'OK'];
}
return ['status' => false, 'message' => ' ldap (ActiveDirectory) ldap'];
}
function checkimagick() {
if (class_exists('\Imagick')) {
return ['status' => true, 'message' => 'OK'];
}
return ['status' => false, 'message' => ' IMagick'];
}
function checkzips() {
$fails = [];
if (!class_exists('\ZipArchive')) {
$fails[] = " zip";
}
if (!function_exists('gzencode')) {
$fails[] = " zlib";
}
if (!function_exists('bzcompress')) {
$fails[] = " bzip2";
}
if (!count($fails)) {
return ['status' => true, 'message' => 'OK'];
}
return ['status' => false, 'message' => implode("\n", $fails)];
}
function checkphar() {
$fails = [];
if (class_exists('\Phar')) {
if (!Phar::canCompress(Phar::GZ)) {
$fails[] = ' Phar::GZ';
}
if (version_compare(Phar::apiVersion(), '1.1.1', '<')) {
$fails[] = " Phar 1.1.1+";
}
} else {
$fails[] = " Phar";
}
if (!count($fails)) {
return ['status' => true, 'message' => 'OK'];
}
return ['status' => false, 'message' => implode("\n", $fails)];
}
function checkhash() {
if (function_exists('hash_hmac')) {
return ['status' => true, 'message' => 'OK'];
}
return ['status' => false, 'message' => ' hash'];
}
function checkredis() {
if (class_exists('\Redis')) {
return ['status' => true, 'message' => 'OK'];
}
return ['status' => false, 'message' => ' redis'];
}
function checkpdo() {
if (class_exists('\PDO')) {
return ['status' => true, 'message' => 'OK'];
}
return ['status' => false, 'message' => ' PDO'];
}
function pdo_driver_exists($driver) {
if (class_exists('\PDO')) {
$drivers = PDO::getAvailableDrivers();
$dm = array_combine($drivers, $drivers);
if (array_key_exists($driver, $dm)) {
return true;
}
}
return false;
}
function checkpdomysql() {
$msq = pdo_driver_exists('mysql');
$psq = pdo_driver_exists('pgsql');
if ($msq && $psq) {
return ['status' => true, 'message' => 'mysql: OK, pgsql: OK'];
}else if($msq){
return ['status' => true, 'message' => 'mysql: OK'];
}else if($psq){
return ['status' => true, 'message' => 'pgsql: OK'];
}
return ['status' => false, 'message' => ' PDO::mysql PDO::pgsql'];
}
function get_webroot() {
$webroot = __DIR__;
if (array_key_exists('DOCUMENT_ROOT', $_SERVER)) {
$webroot = $_SERVER['DOCUMENT_ROOT'];
}
$stripped_root = trim(str_ireplace($webroot, '', __FILE__), DIRECTORY_SEPARATOR);
if (count(explode(DIRECTORY_SEPARATOR, $stripped_root)) > 1) {
throw new Exception(" .");
}
return rtrim($webroot, DIRECTORY_SEPARATOR);
}
function get_webroot_name() {
return pathinfo(__DIR__, PATHINFO_FILENAME);
}
function get_install_dir() {
return rtrim(dirname(__DIR__), DIRECTORY_SEPARATOR);
}
function checkfs() {
$notes = [];
$webroot = __DIR__;
if (array_key_exists('DOCUMENT_ROOT', $_SERVER)) {
$webroot = $_SERVER['DOCUMENT_ROOT'];
} else {
$notes[] = " DOCUMENT_ROOT .";
}
$stripped_root = trim(str_ireplace($webroot, '', __FILE__), DIRECTORY_SEPARATOR);
if (count(explode(DIRECTORY_SEPARATOR, $stripped_root)) > 1) {
$notes[] = " . <a href=\"#\" id=\"fs_req_btn\"> </a>";
}
if (!(is_dir($webroot) && is_readable($webroot) && is_writable($webroot))) {
$notes[] = " `{$webroot}` - .";
}
$webroot_name = pathinfo(__DIR__, PATHINFO_FILENAME);
if ($webroot_name !== 'www') {
$notes[] = ' www. <a href=\"#\" id=\"fs_req_btn\"> </a>';
}
$install_dir = rtrim(dirname(__DIR__), DIRECTORY_SEPARATOR);
if (!(is_dir($install_dir) && is_readable($install_dir) && is_writable($install_dir))) {
$notes[] = " `{$install_dir}` - .";
} else {
$founds = [];
$files = scandir($install_dir);
foreach ($files as $filename) {
if ($filename === $webroot_name || $filename === '.' || $filename === '..' || $filename === 'log' || $filename === 'mysql.dba.txt') {
continue;
}
$founds[] = $filename;
}
if (count($founds)) {
if (!(defined('DEBUG_MODE') && DEBUG_MODE === true)) {
$raw_data = get_post_data();
if (!(array_key_exists('ignoreupport', $raw_data) && intval($raw_data['ignoreupport']) === 1)) {
$notes[] = " `{$install_dir}` . <br> <a href=\"#\" id=\"fs_req_btn\"> </a><br><div class=\"ignore-upport\"><input type=\"checkbox\" id=\"ignore-upport-files\" /><label for=\"ignore-upport-files\"></label></div>";
}
}
}
}
$tempdir = sys_get_temp_dir();
if (!(file_exists($tempdir) && is_readable($tempdir) && is_writable($tempdir))) {
$notes[] = " `{$tempdir}` .";
}
if (!count($notes)) {
return ['status' => true, 'message' => " :\n - : {$install_dir}\n - WEBROOT: {$webroot}"];
}
return ['status' => false, 'message' => implode("\n", $notes)];
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="step0">
function step_0() {
ob_start();
$all_data = get_post_data();
?>
<div class="installer-checks-window">
<div class="Installer-intro-header"> <div class="installer-compatibility-text"></div></div>
<div class="installer-intro-content">
<div class="installer-intro-text"> « ».<br>
.<br>
<a href="#" id="license_bt"> </a>,<br><a href="#" id="req_btn"> </a> <a href="#" id="fs_req_btn"> </a>.
</div>
<form method="POST" action="<?php $_SERVER['REQUEST_URI'] ?>" id="stepxform">
<input name="step" type="hidden" value="1"/>
<input name="data" type="hidden" value="" id="alldata"/>
<div class="form-btn" id="stepxsubmit"></div>
</form>
</div>
</div>
<div class="popup-backdrop" id="license-backdrop" style="display:none">
<div class="popup-backdrop-content">
<div class="popup-window" id="license-window">
<div class="popup-header"><div class="popup-header-text"> </div><div id="lic-clo" class="popup-header-close"></div></div>
<div class="popup-body">
<div class="popup-body-content">
« ».
, 30 ,
, .<br>
,
« ». , , ,
.
</div>
</div>
</div>
</div>
</div>
<div class="popup-backdrop" id="req-backdrop" style="display:none">
<div class="popup-backdrop-content">
<div class="popup-window" id="req-window">
<div class="popup-header"><div class="popup-header-text"> </div><div id="req-clo" class="popup-header-close"></div></div>
<div class="popup-body">
<div class="popup-body-content">
<ul>
<li>linux x64</li>
<li>nginx</li>
<li>redis5+</li>
<li>imagemagic</li>
<li>php7.2+, php-fpm, phar stream support, phar GZ support ( phar, json,mbstring php-common)
<ul>
<li>php-pdo</li>
<li>php-mysql php-pgsql</li>
<li>php-curl</li>
<li>php-openssl</li>
<li>php-bz2</li>
<li>php-zlib</li>
<li>php-zip</li>
<li>php-mbstring</li>
<li>php-redis</li>
<li>php-ldap (optional)</li>
<li>php-dom, php-xmlwriter, libxml</li>
<li>php-imagick</li>
<li>php-json</li>
</ul>
</li>
<li>mysql5.7.x/8.0+/maria10.2+</li>
<li> - sphinx3+, sphinx 3.4.1</li>
<li> ( .. IIS), </li>
</ul>
</div>
</div>
</div>
</div>
</div>
<script>
document.getElementById('alldata').value = JSON.stringify(<?php echo cnd_json_encode($all_data) ?>);
function add_trg(tid, wid) {
var c = document.getElementById(tid);
if (c) {
c.addEventListener('click', function (e) {
e.stopPropagation();
e.preventDefault ? e.preventDefault() : e.returnValue = false;
var pop = document.getElementById(wid);
if (pop) {
pop.style.display = 'block';
}
});
}
}
function stop_props(id) {
var rqw = document.getElementById(id);
if (rqw) {
rqw.addEventListener('click', function (e) {
e.stopPropagation();
});
}
}
function add_ctrg(tid, wid) {
var c = document.getElementById(tid);
if (c) {
c.addEventListener('click', function (e) {
e.stopPropagation();
e.preventDefault ? e.preventDefault() : e.returnValue = false;
var pop = document.getElementById(wid);
if (pop) {
pop.style.display = 'none';
}
});
}
}
add_trg('license_bt', 'license-backdrop');
add_trg('req_btn', 'req-backdrop');
stop_props('req-window');
stop_props('license-window');
add_ctrg('license-backdrop', 'license-backdrop');
add_ctrg('req-backdrop', 'req-backdrop');
add_ctrg('lic-clo', 'license-backdrop');
add_ctrg('req-clo', 'req-backdrop');
document.getElementById('stepxsubmit').addEventListener('click', function () {
var form = document.getElementById('stepxform');
if (form) {
form.submit();
}
});
</script>
<?php
do_out(ob_get_clean(), 0);
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="step1">
function step_1() {
//<editor-fold defaultstate="collapsed" desc="checks stubs">
$checks = [
' php' => [
'handler' => 'checkphpver',
'status' => false,
'response' => ''
],
' ' => [
'handler' => 'checkfs',
'status' => false,
'response' => ''
],
' mbstrings' => [
'handler' => 'checkmbstring',
'status' => false,
'response' => ''
],
' json' => [
'handler' => 'checkjson',
'status' => false,
'response' => ''
],
'libxml (DOM,XML,XMLWriter...)' => [
'handler' => 'checkDOM',
'status' => false,
'response' => ''
],
' cUrl' => [
'handler' => 'checkcurl',
'status' => false,
'response' => ''
],
' OpenSSL' => [
'handler' => 'checkopenssl',
'status' => false,
'response' => ''
],
' LDAP' => [
'handler' => 'checkldap',
'status' => false,
'response' => '',
'severity' => 1,
],
' Imagick' => [
'handler' => 'checkimagick',
'status' => false,
'response' => ''
],
' ' => [
'handler' => 'checkzips',
'status' => false,
'response' => ''
],
' Phar' => [
'handler' => 'checkphar',
'status' => false,
'response' => ''
],
' Hash' => [
'handler' => 'checkhash',
'status' => false,
'response' => ''
],
' Redis' => [
'handler' => 'checkredis',
'status' => false,
'response' => ''
],
' PDO' => [
'handler' => 'checkpdo',
'status' => false,
'response' => ''
],
' PDO mysql pgsql ' => [
'handler' => 'checkpdomysql',
'status' => false,
'response' => ''
]
];
//</editor-fold>
foreach ($checks as $key => $value) {
if (function_exists($value['handler'])) {
$res = call_user_func($value["handler"]);
$checks[$key]['status'] = $res['status'];
$checks[$key]['response'] = $res['message'];
} else {
$checks[$key]['response'] = " ";
$checks[$key]['status'] = false;
}
}
ob_start();
?>
<div class="installer-checks-window-backdrop">
<div class="installer-checks-window">
<div class="Installer-intro-header"> <div class="installer-compatibility-text"> </div></div>
<div class="installer-compatibility-list-scr">
<table class="installer-compatibility-table">
<?php $failed_checks = 0; ?>
<?php foreach ($checks as $key => $result) { ?>
<?php $warning = !!(array_key_exists('severity', $result) && intval($result['severity']) === 1) ?>
<tr class="installer-check-<?php echo $result['status'] ? 'success' : ($warning ? 'warning' : 'failed') ?>">
<td class="installer-check-name"><?php echo $key ?>:</td>
<td class="installer-check-notice-cell">
<div class="installer-check-notice"><?php echo nl2br($result['response']) ?></div>
</td>
</tr>
<?php
if (!$result['status'] && !$warning) {
$failed_checks++;
}
?>
<?php
}
$all_data = get_post_data();
$all_data['failed_checks'] = $failed_checks;
?>
</table>
</div>
<form method="POST" action="<?php $_SERVER['REQUEST_URI'] ?>" id="stepxform">
<input name="step" type="hidden" value="1" id="form-step-value"/>
<input name="data" type="hidden" value="" id="alldata" />
<div class="form-btn" id="stepxresubmit"></div>
<?php if (!$failed_checks) { ?>
<div class="form-btn" id="stepxsubmit"></div>
<?php } ?>
</form>
</div>
</div>
<script>
var mysqlDriverSupported = parseInt('<?= pdo_driver_exists('mysql') ? '1' : '0' ?>') ? true : false;
var postgresSupported = parseInt('<?= pdo_driver_exists('pgsql') ? '1' : '0' ?>') ? true : false;
document.getElementById('alldata').value = JSON.stringify(<?php echo cnd_json_encode($all_data) ?>);
document.addEventListener('change', function (e) {
if (e.target.id === 'ignore-upport-files') {
var data = JSON.parse(document.getElementById('alldata').value);
data.ignoreupport = e.target.checked ? 1 : 0;
document.getElementById('alldata').value = JSON.stringify(data);
}
});
var btn = document.getElementById('stepxsubmit');
if (btn) {
btn.addEventListener('click', function () {
var nextStep = "2";
if (mysqlDriverSupported && !postgresSupported) {
nextStep = "2mysql";
var data = JSON.parse(document.getElementById('alldata').value);
data.dbDriver = "mysql";
document.getElementById('alldata').value = JSON.stringify(data);
} else if (postgresSupported && !mysqlDriverSupported) {
nextStep = "2pgsql";
var data = JSON.parse(document.getElementById('alldata').value);
data.dbDriver = "pgsql";
document.getElementById('alldata').value = JSON.stringify(data);
}
document.getElementById('form-step-value').value = nextStep;
document.getElementById('stepxform').submit();
});
}
var btn2 = document.getElementById('stepxresubmit');
if (btn2) {
btn2.addEventListener('click', function () {
document.getElementById('form-step-value').value = "1";
document.getElementById('stepxform').submit();
});
}
</script>
<?php
do_out(ob_get_clean(), 1);
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="step2">
function step_2() {
$all_data = get_post_data();
$db_data = array_key_exists('db', $all_data) && is_array($all_data['db']) ? $all_data['db'] : [];
$predefined = "mysql";
if (array_key_exists('driver', $db_data) && is_string($db_data['driver'])) {
$predefined = $db_data['driver'];
}
ob_start()
?>
<div class="installer-db-window-backdrop">
<div class="installer-db-window">
<div class="Installer-intro-header"> <div class="installer-compatibility-text"> </div></div>
<div class="installer-db-form">
<form id="db_form" onsubmit="return false;" ation="#" method="GET">
<div class="db-form-note">
<div class="db-form-note-inner">
PHP PDO MySQL/MariaDB PostgreSQL <br>
« ».
<div style="color:crimson;margin-top:1em;margin-bottom:1em;font-size: 0.9em"><b>!</b> .</div>
</div>
</div>
<div class="db-form-row">
<label for="db-input-type"> :</label>
<div class="db-form-select">
<select id="db-input-type">
<option value="mysql" <?= $predefined === "mysql" ? 'selected="selected"' : '' ?>>MySQL / MariaDB</option>
<option value="pgsql" <?= $predefined === "pgsql" ? 'selected="selected"' : '' ?>>PostreSQL</option>
</select>
</div>
<div style="font-size:0.9em;color:crimson;display:none;" id="driverTypeErr"> </div>
</div>
</form>
</div>
<form method="POST" action="<?php echo $_SERVER['REQUEST_URI'] ?>" id="stepxform">
<input name="step" type="hidden" value="2" id="form-step-value"/>
<input name="data" type="hidden" value="" id="alldata" />
<div class="form-btn" id="stepxsubmit" ></div>
</form>
</div>
</div>
<script>
document.getElementById('alldata').value = JSON.stringify(<?php echo cnd_json_encode($all_data) ?>);
var sel = document.getElementById('db-input-type');
var btn = document.getElementById('stepxsubmit');
var err = document.getElementById('driverTypeErr');
sel.addEventListener('change', function () {
err.style.display = 'none';
});
if (btn) {
btn.addEventListener('click', function () {
var t = sel.value;
if (t === 'mysql') {
var idata = JSON.parse(document.getElementById('alldata').value);
var dbData = idata.db;
if (!dbData || typeof (dbData) !== 'object') {
dbData = {};
}
dbData.driver = 'mysql';
document.getElementById('alldata').value = JSON.stringify(idata);
document.getElementById('form-step-value').value = "2mysql";
} else if (t === 'pgsql') {
var idata = JSON.parse(document.getElementById('alldata').value);
var dbData = idata.db;
if (!dbData || typeof (dbData) !== 'object') {
dbData = {};
}
dbData.driver = 'pgsql';
document.getElementById('alldata').value = JSON.stringify(idata);
document.getElementById('form-step-value').value = "2pgsql";
} else {
err.style.display = 'block';
return;
}
document.getElementById('stepxform').submit();
});
}
</script>
<?php
do_out(ob_get_clean(), 2);
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="step2mysql">
function step_2mysql() {
$all_data = get_post_data();
$db_data = array_key_exists('db', $all_data) && is_array($all_data['db']) ? $all_data['db'] : [];
$predefined = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'mysql.dba.txt';
$raw_data = (file_exists($predefined) && is_file($predefined) && is_readable($predefined)) ? file_get_contents($predefined) : null;
$predefined_password = null;
$predefined_user = null;
if ($raw_data) {
$raw_a = explode(':', $raw_data, 2);
if (count($raw_a) === 2) {
$predefined_user = $raw_a[0];
$predefined_password = $raw_a[1];
}
}
ob_start()
?>
<div class="installer-db-window-backdrop">
<div class="installer-db-window">
<div class="Installer-intro-header"> <div class="installer-compatibility-text"> </div></div>
<div class="installer-db-form">
<form id="db_form" onsubmit="return false;" ation="#" method="GET">
<div class="db-form-note">
<div class="db-form-note-inner">
MySQL .<br>
, .
<?php if ($predefined_password) { ?>
<b style="display:block;color:crimson"> </b>
<?php } ?>
</div>
</div>
<div class="db-form-row">
<label for="db-input-server"></label>
<input type="text" value="<?php echo array_key_exists('server', $db_data) ? $db_data['server'] : ($predefined_password !== null ? '127.0.0.1' : '') ?>" placeholder="127.0.0.1" name="server" id="db-input-server"/>
</div>
<div class="db-form-row">
<label for="db-input-port"></label>
<input type="text" value="<?php echo array_key_exists('port', $db_data) ? $db_data['port'] : '3306' ?>" placeholder="3306" name="port" id="db-input-port"/>
</div>
<div class="db-form-row">
<label for="db-input-user"></label>
<input type="text" placeholder="db user" name="user" id="db-input-user" value="<?php echo ($predefined_user !== null ? $predefined_user : '') ?>"/>
</div>
<div class="db-form-row">
<label for="db-input-password"></label>
<input type="text" placeholder="" name="password" id="db-input-password" value="<?php echo ($predefined_password !== null ? $predefined_password : '') ?>"/>
</div>
<div class="db-form-row">
<label for="db-input-db"> </label>
<input type="text" value="" placeholder="leader_map" name="db" id="db-input-db"/>
</div>
<div class="db-form-row">
<input type="checkbox" name="create-user" id="db-input-create-user"/>
<label for="db-input-create-user"> </label>
</div>
<div class="db-form-row">
<label for="db-input-user-name"> </label>
<input type="text" value="" placeholder="= db-name" name="user-name" id="db-input-user-name" disabled="disabled"/>
</div>
<div class="db-form-row">
<label for="db-input-user-host"> </label>
<input type="text" value="%" placeholder="%" name="user-host" id="db-input-user-host" disabled="disabled"/>
</div>
<div class="db-form-row">
<label for="db-input-user-password"> </label>
<input type="text" value="" placeholder="" name="user-password" id="db-input-user-password" disabled="disabled"/>
</div>
<div class="db-check-result" id="db-check-result">
</div>
<div class="db-form-button-row">
<div class="form-btn" id="db-check"></div>
<div class="form-btn" id="db-apply"> </div>
</div>
</form>
</div>
<form method="POST" action="<?php echo $_SERVER['REQUEST_URI'] ?>" id="stepxform">
<input name="step" type="hidden" value="3" id="form-step-value"/>
<input name="data" type="hidden" value="" id="alldata" />
<div class="form-btn" id="stepxsubmit" ></div>
</form>
</div>
</div>
<script>
document.getElementById('alldata').value = JSON.stringify(<?php echo cnd_json_encode($all_data) ?>);
var check = document.getElementById('db-input-create-user');
if (check) {
check.addEventListener('change', function () {
if (check.checked) {
document.getElementById('db-input-user-name').removeAttribute('disabled');
document.getElementById('db-input-user-host').removeAttribute('disabled');
document.getElementById('db-input-user-password').removeAttribute('disabled');
} else {
document.getElementById('db-input-user-name').setAttribute('disabled', 'disabled');
document.getElementById('db-input-user-host').setAttribute('disabled', 'disabled');
document.getElementById('db-input-user-password').setAttribute('disabled', 'disabled');
}
});
}
var btn = document.getElementById('stepxsubmit');
if (btn) {
btn.addEventListener('click', function () {
document.getElementById('form-step-value').value = "3";
var idata = JSON.parse(document.getElementById('alldata').value);
var dbData = idata.db;
if (!dbData || typeof (dbData) !== 'object') {
dbData = {};
idata.db=dbData;
}
dbData.driver = 'mysql';
document.getElementById('alldata').value = JSON.stringify(idata);
document.getElementById('stepxform').submit();
});
}
var dbc = document.getElementById('db-check');
function get_db_params() {
return {
server: document.getElementById('db-input-server').value,
port: document.getElementById('db-input-port').value,
user: document.getElementById('db-input-user').value,
password: document.getElementById('db-input-password').value,
db: document.getElementById('db-input-db').value,
create_user: document.getElementById('db-input-create-user').checked,
user_name: document.getElementById('db-input-user-name').value,
user_host: document.getElementById('db-input-user-host').value,
user_password: document.getElementById('db-input-user-password').value
};
}
function check_db_params(xo) {
xo.server = xo.server && (typeof (xo.server) === 'string') ? xo.server.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.server.length ? 0 : xo.server = null;
if (!xo.server) {
throw new Error(" MySQL/Maria");
}
xo.port = xo.port && (typeof (xo.port) === 'string') ? xo.port.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.port.length ? 0 : xo.port = null;
if (xo.port) {
var pt = parseInt(xo.port);
if (isNaN(pt)) {
throw new Error(' ');
}
}
xo.user = xo.user && (typeof (xo.user) === 'string') ? xo.user.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.user.length ? 0 : xo.user = null;
if (!xo.user) {
throw new Error(" CREATE DATABASE");
}
xo.password = xo.password && (typeof (xo.password) === 'string') ? xo.password.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.password.length ? 0 : xo.password = null;
if (!xo.password) {
throw new Error(" ");
}
xo.db = xo.db && (typeof (xo.db) === 'string') ? xo.db.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.db.length ? 0 : xo.db = null;
if (!xo.db) {
throw new Error(" ");
}
}
function db_checked(o) {
if (o.status === 'ok') {
var driver = 'mysql';
if (/maria/i.test(o.version)) {
driver = 'maria-db';
} else {
var m = /^(\d{1,}).\d{1,}/.exec(o.version);
if (m) {
var mi = parseInt(m[1]);
if (mi >= 8) {
driver = 'mysql8';
}
}
}
document.getElementById('db-check-result').innerHTML = [' ; : ', driver, '; : ', o.version].join('');
document.getElementById('db-check-result').classList.add('success');
var raw_data = JSON.parse(document.getElementById('alldata').value);
if (!raw_data.db) {
raw_data.db = {};
}
raw_data.db.server = document.getElementById('db-input-server').value;
raw_data.db.port = document.getElementById('db-input-port').value;
raw_data.db.db = document.getElementById('db-input-db').value;
document.getElementById('alldata').value = JSON.stringify(raw_data);
} else if (o.status === 'error') {
document.getElementById('db-check-result').innerHTML = o.error;
document.getElementById('db-check-result').classList.remove('success');
}
}
function db_created(o) {
if (o.status === 'ok') {
if (o.params) {
var raw_data = JSON.parse(document.getElementById('alldata').value);
raw_data.db = o.params;
raw_data.db.driver="mysql";
document.getElementById('alldata').value = JSON.stringify(raw_data);
document.getElementById('db-input-server').value = raw_data.db.server;
document.getElementById('db-input-port').value = raw_data.db.port;
document.getElementById('db-input-db').value = raw_data.db.db;
document.getElementById('db-input-user-name').value = raw_data.db.user;
document.getElementById('db-input-user-password').value = raw_data.db.password;
}
document.getElementById('db-check-result').innerHTML = ".";
document.getElementById('db-check-result').classList.add('success');
} else if (o.status === 'error') {
document.getElementById('db-check-result').innerHTML = o.error;
document.getElementById('db-check-result').classList.remove('success');
}
}
if (dbc) {
dbc.addEventListener('click', function () {
var db_params = get_db_params();
try {
check_db_params(db_params);
} catch (e) {
document.getElementById('db-check-result').innerHTML = e.message;
return;
}
var http = new XMLHttpRequest();
var params = 'data=' + encodeURIComponent(JSON.stringify(db_params));
var url = '<?php echo $_SERVER['REQUEST_URI'] ?>';
var spl = url.indexOf('?') >= 0 ? '&' : '?';
http.open('POST', [url, spl, 'action=check_db_create'].join(''), true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function () {
if (http.readyState == 4 && http.status == 200) {
var r = http.response;
var o = null;
try {
o = JSON.parse(r);
if (!(o && typeof (o) === 'object')) {
o = {status: 'error', 'error': 'invalid response'};
}
} catch (e) {
o = {status: 'error', 'error': e.message};
}
db_checked(o);
}
}
http.send(params);
});
}
var dbcre = document.getElementById('db-apply');
if (dbcre) {
dbcre.addEventListener('click', function () {
var db_params = get_db_params();
try {
check_db_params(db_params);
} catch (e) {
document.getElementById('db-check-result').innerHTML = e.message;
return;
}
var http = new XMLHttpRequest();
var params = 'data=' + encodeURIComponent(JSON.stringify(db_params));
var url = '<?php echo $_SERVER['REQUEST_URI'] ?>';
var spl = url.indexOf('?') >= 0 ? '&' : '?';
http.open('POST', [url, spl, 'action=check_db_create_create'].join(''), true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function () {
if (http.readyState == 4 && http.status == 200) {
var r = http.response;
var o = null;
try {
o = JSON.parse(r);
if (!(o && typeof (o) === 'object')) {
o = {status: 'error', 'error': 'invalid response'};
}
} catch (e) {
o = {status: 'error', 'error': e.message};
}
db_created(o);
}
};
http.send(params);
});
}
</script>
<?php
do_out(ob_get_clean(), 2);
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="step2pgsql">
function step_2pgsql() {
$all_data = get_post_data();
$db_data = array_key_exists('db', $all_data) && is_array($all_data['db']) ? $all_data['db'] : [];
ob_start()
?>
<div class="installer-db-window-backdrop">
<div class="installer-db-window">
<div class="Installer-intro-header"> <div class="installer-compatibility-text"> </div></div>
<div class="installer-db-form">
<form id="db_form" onsubmit="return false;" ation="#" method="GET">
<div class="db-form-note">
<div class="db-form-note-inner">
postgreSQL .<br>
PostgreSQL, .<br>
, , :
<textarea readonly="readonly">
-- -
CREATE ROLE "officemap" WITH LOGIN PASSWORD '123456';
CREATE DATABASE "officemap" OWNER="officemap" TEMPLATE=template0 ENCODING=UTF8;
</textarea>
<br>
- .
<div style="color:crimson;font-size:0.9em"> - !!!</div>
</div>
</div>
<div class="db-form-row">
<label for="db-input-server"></label>
<input type="text" value="<?php echo array_key_exists('server', $db_data) ? $db_data['server'] : '' ?>" placeholder="127.0.0.1" name="server" id="db-input-server"/>
</div>
<div class="db-form-row">
<label for="db-input-port"></label>
<input type="text" value="<?php echo array_key_exists('port', $db_data) ? $db_data['port'] : '5432' ?>" placeholder="5432" name="port" id="db-input-port"/>
</div>
<div class="db-form-row">
<label for="db-input-tpldb"> (T0/T1)</label>
<input type="text" value="<?php echo array_key_exists('tpldb', $db_data) ? $db_data['tpldb'] : 'template0' ?>" placeholder="template0" name="tpldb" id="db-input-tpldb"/>
</div>
<div class="db-form-row">
<label for="db-input-user"></label>
<input type="text" placeholder="db user" name="user" id="db-input-user" value="" placeholder="postgres"/>
</div>
<div class="db-form-row">
<label for="db-input-password"> </label>
<input type="text" placeholder="" name="password" id="db-input-password" value=""/>
</div>
<div class="db-form-row">
<label for="db-input-db"> </label>
<input type="text" value="" placeholder="officemap" name="db" id="db-input-db"/>
</div>
<div class="db-form-row" style="display:none">
<input type="checkbox" name="create-user" checked="checked" id="db-input-create-user"/>
<label for="db-input-create-user"> </label>
</div>
<div class="db-form-row">
<label for="db-input-user-name"> </label>
<input type="text" value="" placeholder="= db-name" name="user-name" id="db-input-user-name" />
</div>
<div class="db-form-row">
<label for="db-input-user-password"> </label>
<input type="text" value="" placeholder="" name="user-password" id="db-input-user-password" />
</div>
<div class="db-check-result" id="db-check-result">
</div>
<div class="db-form-button-row">
<div class="form-btn" id="db-check"></div>
<div class="form-btn" id="db-apply"> </div>
</div>
</form>
</div>
<form method="POST" action="<?php echo $_SERVER['REQUEST_URI'] ?>" id="stepxform">
<input name="step" type="hidden" value="3" id="form-step-value"/>
<input name="data" type="hidden" value="" id="alldata" />
<div class="form-btn" id="stepxsubmit" ></div>
</form>
</div>
</div>
<script>
document.getElementById('alldata').value = JSON.stringify(<?php echo cnd_json_encode($all_data) ?>);
var check = document.getElementById('db-input-create-user');
if (check) {
check.addEventListener('change', function () {
// if (check.checked) {
document.getElementById('db-input-user-name').removeAttribute('disabled');
document.getElementById('db-input-user-password').removeAttribute('disabled');
// } else {
// document.getElementById('db-input-user-name').setAttribute('disabled', 'disabled');
// document.getElementById('db-input-user-password').setAttribute('disabled', 'disabled');
// }
});
}
var btn = document.getElementById('stepxsubmit');
if (btn) {
btn.addEventListener('click', function () {
document.getElementById('form-step-value').value = "3";
var idata = JSON.parse(document.getElementById('alldata').value);
var dbData = idata.db;
if (!dbData || typeof (dbData) !== 'object') {
dbData = {};
idata.db=dbData;
}
dbData.driver = 'pgsql';
document.getElementById('alldata').value = JSON.stringify(idata);
document.getElementById('stepxform').submit();
});
}
var dbc = document.getElementById('db-check');
function get_db_params() {
return {
server: document.getElementById('db-input-server').value,
port: document.getElementById('db-input-port').value,
user: document.getElementById('db-input-user').value,
password: document.getElementById('db-input-password').value,
db: document.getElementById('db-input-db').value,
create_user: true,
user_name: document.getElementById('db-input-user-name').value,
user_password: document.getElementById('db-input-user-password').value,
tpldb: document.getElementById('db-input-tpldb').value
};
}
function check_db_params(xo) {
xo.server = xo.server && (typeof (xo.server) === 'string') ? xo.server.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.server.length ? 0 : xo.server = null;
if (!xo.server) {
throw new Error(" PostgreSQL");
}
xo.port = xo.port && (typeof (xo.port) === 'string') ? xo.port.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.port.length ? 0 : xo.port = null;
if (xo.port) {
var pt = parseInt(xo.port);
if (isNaN(pt)) {
throw new Error(' ');
}
}
xo.user = xo.user && (typeof (xo.user) === 'string') ? xo.user.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.user.length ? 0 : xo.user = null;
if (!xo.user) {
throw new Error(" CREATE ROLE/ DATABASE");
}
xo.password = xo.password && (typeof (xo.password) === 'string') ? xo.password.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.password.length ? 0 : xo.password = null;
if (!xo.password) {
throw new Error(" ");
}
xo.db = xo.db && (typeof (xo.db) === 'string') ? xo.db.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.db.length ? 0 : xo.db = null;
if (!xo.db) {
throw new Error(" ");
}
xo.tpldb = xo.tpldb && (typeof (xo.tpldb) === 'string') ? xo.tpldb.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.tpldb.length ? 0 : xo.tpldb = null;
if (!xo.tpldb) {
throw new Error(" ");
}
}
function db_checked(o) {
if (o.status === 'ok') {
var driver = 'pgsql';
document.getElementById('db-check-result').innerHTML = [' ; : ', driver, '; : ', o.version].join('');
document.getElementById('db-check-result').classList.add('success');
var raw_data = JSON.parse(document.getElementById('alldata').value);
if (!raw_data.db) {
raw_data.db = {};
}
raw_data.db.server = document.getElementById('db-input-server').value;
raw_data.db.port = document.getElementById('db-input-port').value;
raw_data.db.db = document.getElementById('db-input-db').value;
raw_data.db.driver="pgsql";
document.getElementById('alldata').value = JSON.stringify(raw_data);
} else if (o.status === 'error') {
document.getElementById('db-check-result').innerHTML = o.error;
document.getElementById('db-check-result').classList.remove('success');
}
}
function db_created(o) {
if (o.status === 'ok') {
if (o.params) {
var raw_data = JSON.parse(document.getElementById('alldata').value);
raw_data.db = o.params;
raw_data.db.driver = "pgsql";
document.getElementById('alldata').value = JSON.stringify(raw_data);
document.getElementById('db-input-server').value = raw_data.db.server;
document.getElementById('db-input-port').value = raw_data.db.port;
document.getElementById('db-input-db').value = raw_data.db.db;
document.getElementById('db-input-user-name').value = raw_data.db.user;
document.getElementById('db-input-user-password').value = raw_data.db.password;
}
document.getElementById('db-check-result').innerHTML = ".";
document.getElementById('db-check-result').classList.add('success');
} else if (o.status === 'error') {
document.getElementById('db-check-result').innerHTML = o.error;
document.getElementById('db-check-result').classList.remove('success');
}
}
if (dbc) {
dbc.addEventListener('click', function () {
var db_params = get_db_params();
try {
check_db_params(db_params);
} catch (e) {
document.getElementById('db-check-result').innerHTML = e.message;
return;
}
var http = new XMLHttpRequest();
var params = 'data=' + encodeURIComponent(JSON.stringify(db_params));
var url = '<?php echo $_SERVER['REQUEST_URI'] ?>';
var spl = url.indexOf('?') >= 0 ? '&' : '?';
http.open('POST', [url, spl, 'action=check_db_create_pg'].join(''), true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function () {
if (http.readyState == 4 && http.status == 200) {
var r = http.response;
var o = null;
try {
o = JSON.parse(r);
if (!(o && typeof (o) === 'object')) {
o = {status: 'error', 'error': 'invalid response'};
}
} catch (e) {
o = {status: 'error', 'error': e.message};
}
db_checked(o);
}
};
http.send(params);
});
}
var dbcre = document.getElementById('db-apply');
if (dbcre) {
dbcre.addEventListener('click', function () {
var db_params = get_db_params();
try {
check_db_params(db_params);
} catch (e) {
document.getElementById('db-check-result').innerHTML = e.message;
return;
}
var http = new XMLHttpRequest();
var params = 'data=' + encodeURIComponent(JSON.stringify(db_params));
var url = '<?php echo $_SERVER['REQUEST_URI'] ?>';
var spl = url.indexOf('?') >= 0 ? '&' : '?';
http.open('POST', [url, spl, 'action=check_db_create_create_pg'].join(''), true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function () {
if (http.readyState == 4 && http.status == 200) {
var r = http.response;
var o = null;
try {
o = JSON.parse(r);
if (!(o && typeof (o) === 'object')) {
o = {status: 'error', 'error': 'invalid response'};
}
} catch (e) {
o = {status: 'error', 'error': e.message};
}
db_created(o);
}
};
http.send(params);
});
}
</script>
<?php
do_out(ob_get_clean(), 2);
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="step3">
function step_3() {
$all_data = get_post_data();
$db_data = array_key_exists('db', $all_data) && is_array($all_data['db']) ? $all_data['db'] : [];
$isPG = !!(array_key_exists('driver', $db_data) && $db_data['driver']==='pgsql');
ob_start();
?>
<div class="installer-db-window-backdrop">
<div class="installer-db-window">
<div class="Installer-intro-header"> <div class="installer-compatibility-text"> </div></div>
<div class="installer-db-form">
<form id="db_form" onsubmit="return false;" ation="#" method="GET">
<div class="db-form-note">
<div class="db-form-note-inner">
, .<br>
dba/root - .
</div>
</div>
<div class="db-form-row">
<label for="db-input-server"></label>
<input type="text" value="<?php echo array_key_exists('server', $db_data) ? $db_data['server'] : '' ?>" placeholder="127.0.0.1" name="server" id="db-input-server"/>
</div>
<div class="db-form-row">
<label for="db-input-port"></label>
<input type="text" value="<?php echo array_key_exists('port', $db_data) ? $db_data['port'] : ($isPG?'5432':'3306') ?>" placeholder="0000" name="port" id="db-input-port"/>
</div>
<div class="db-form-row">
<label for="db-input-user"></label>
<input type="text" value="<?php echo array_key_exists('user', $db_data) ? $db_data['user'] : '' ?>" placeholder="db user" name="user" id="db-input-user"/>
</div>
<div class="db-form-row">
<label for="db-input-password"></label>
<input type="text" value="<?php echo array_key_exists('password', $db_data) ? $db_data['password'] : '' ?>" placeholder="" name="password" id="db-input-password"/>
</div>
<div class="db-form-row">
<label for="db-input-db"> </label>
<input type="text" value="<?php echo array_key_exists('db', $db_data) ? $db_data['db'] : 'officemap' ?>" placeholder="officemap" name="db" id="db-input-db"/>
<input type="hidden" id="db-input-driver" value="<?php echo array_key_exists('driver', $db_data)?$db_data['driver']:'mysql'?>" />
</div>
<div class="db-check-result" id="db-check-result">
</div>
<div class="db-form-button-row">
<div class="form-btn" id="db-check"></div>
</div>
</form>
</div>
<form method="POST" action="<?php echo $_SERVER['REQUEST_URI'] ?>" id="stepxform">
<input name="step" type="hidden" value="5" id="form-step-value"/>
<input name="data" type="hidden" value="" id="alldata" />
<div class="form-btn" id="stepxsubmit" ></div>
</form>
</div>
</div>
<script>
document.getElementById('alldata').value = JSON.stringify(<?php echo cnd_json_encode($all_data) ?>);
var btn = document.getElementById('stepxsubmit');
if (btn) {
btn.addEventListener('click', function () {
var raw_data = JSON.parse(document.getElementById('alldata').value);
if (!raw_data.db) {
raw_data.db = {};
}
raw_data.db.server = document.getElementById('db-input-server').value;
raw_data.db.port = document.getElementById('db-input-port').value;
raw_data.db.db = document.getElementById('db-input-db').value;
raw_data.db.user = document.getElementById('db-input-user').value;
raw_data.db.password = document.getElementById('db-input-password').value;
raw_data.db.driver = document.getElementById('db-input-driver').value;
document.getElementById('alldata').value = JSON.stringify(raw_data);
document.getElementById('form-step-value').value = "5";
document.getElementById('stepxform').submit();
});
}
var dbc = document.getElementById('db-check');
function get_db_params() {
return {
server: document.getElementById('db-input-server').value,
port: document.getElementById('db-input-port').value,
user: document.getElementById('db-input-user').value,
password: document.getElementById('db-input-password').value,
db: document.getElementById('db-input-db').value,
driver:document.getElementById('db-input-driver').value
};
}
function check_db_params(xo) {
xo.server = xo.server && (typeof (xo.server) === 'string') ? xo.server.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.server.length ? 0 : xo.server = null;
if (!xo.server) {
throw new Error(" ");
}
xo.port = xo.port && (typeof (xo.port) === 'string') ? xo.port.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.port.length ? 0 : xo.port = null;
if (xo.port) {
var pt = parseInt(xo.port);
if (isNaN(pt)) {
throw new Error(' ');
}
}
xo.user = xo.user && (typeof (xo.user) === 'string') ? xo.user.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.user.length ? 0 : xo.user = null;
if (!xo.user) {
throw new Error(" ");
}
xo.password = xo.password && (typeof (xo.password) === 'string') ? xo.password.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.password.length ? 0 : xo.password = null;
if (!xo.password) {
throw new Error(" ");
}
xo.db = xo.db && (typeof (xo.db) === 'string') ? xo.db.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.db.length ? 0 : xo.db = null;
if (!xo.db) {
throw new Error(" ");
}
xo.driver = xo.driver && (typeof (xo.driver) === 'string') ? xo.driver.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.driver.length ? 0 : xo.driver = null;
if (!xo.driver) {
throw new Error("PDO driver type is required");
}
}
function db_checked(o) {
if (o.status === 'ok') {
var driver = 'mysql5';
if(/postgresql/i.test(o.version)){
driver='pgsql';
}else if (/maria/i.test(o.version)) {
driver = 'maria-db';
} else {
var m = /^(\d{1,}).\d{1,}/.exec(o.version);
if (m) {
var mi = parseInt(m[1]);
if (mi >= 8) {
driver = 'mysql8';
}
}
}
document.getElementById('db-check-result').innerHTML = [' ; : ', driver, '; : ', o.version].join('');
document.getElementById('db-check-result').classList.add('success');
var raw_data = JSON.parse(document.getElementById('alldata').value);
if (!raw_data.db) {
raw_data.db = {};
}
raw_data.db.server = document.getElementById('db-input-server').value;
raw_data.db.port = document.getElementById('db-input-port').value;
raw_data.db.db = document.getElementById('db-input-db').value;
raw_data.db.user = document.getElementById('db-input-user').value;
raw_data.db.password = document.getElementById('db-input-password').value;
raw_data.db.driver = document.getElementById('db-input-driver').value;
document.getElementById('alldata').value = JSON.stringify(raw_data);
} else if (o.status === 'error') {
document.getElementById('db-check-result').innerHTML = o.error;
document.getElementById('db-check-result').classList.remove('success');
}
}
if (dbc) {
dbc.addEventListener('click', function () {
var db_params = get_db_params();
try {
check_db_params(db_params);
} catch (e) {
document.getElementById('db-check-result').innerHTML = e.message;
return;
}
var http = new XMLHttpRequest();
var params = 'data=' + encodeURIComponent(JSON.stringify(db_params));
var url = '<?php echo $_SERVER['REQUEST_URI'] ?>';
var spl = url.indexOf('?') >= 0 ? '&' : '?';
http.open('POST', [url, spl, 'action=check_db_connection'].join(''), true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function () {
if (http.readyState == 4 && http.status == 200) {
var r = http.response;
var o = null;
try {
o = JSON.parse(r);
if (!(o && typeof (o) === 'object')) {
o = {status: 'error', 'error': 'invalid response'};
}
} catch (e) {
o = {status: 'error', 'error': e.message};
}
db_checked(o);
}
};
http.send(params);
});
}
</script>
<?php
do_out(ob_get_clean(), 2);
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="step4">
function step_4() {
$all_data = get_post_data();
try {
$version = check_db_connection_ph();
} catch (\Throwable $ee) {
step_3();
}
try {
$rversion = get_redis_version(array_key_exists('redis', $all_data) && is_array($all_data['redis']) ? $all_data['redis'] : []);
} catch (\Throwable $ee) {
step_5();
}
$steps = parse_steps($version);
$tempname = 'tmp';
$names = [];
foreach ($steps as $step) {
$names[] = $step['name'];
}
ob_start();
?>
<div class="installer-db-window-backdrop">
<div class="installer-db-window">
<div class="Installer-intro-header"> <div class="installer-compatibility-text"> </div></div>
<div class="installer-db-form">
<form id="db_form" onsubmit="return false;" ation="#" method="GET">
<div class="db-form-note" id="warntext">
<div class="db-form-note-inner">
</div>
</div>
<div class="db-form-row">
<div class="db-create-progress-container">
<div class="db-create-progress" >
<div class="db-create-progress-element" id="progress-element" style="width:0%;"></div>
<div class="db-create-progress-tesxt" id="progress-text"></div>
</div>
<div class="db-create-progress-info-container">
<div class="db-create-progress-info" id="progress-current"></div>
</div>
</div>
</div>
</form>
</div>
<form method="POST" action="<?php echo $_SERVER['REQUEST_URI'] ?>" id="stepxform">
<input name="step" type="hidden" value="6" id="form-step-value"/>
<input name="data" type="hidden" value="" id="alldata" />
<div class="form-btn" id="stepxsubmit" style="visibility:hidden" ></div>
</form>
</div>
</div>
<script>
document.getElementById('alldata').value = JSON.stringify(<?php echo cnd_json_encode($all_data) ?>);
var btn = document.getElementById('stepxsubmit');
var progress = document.getElementById('progress-element');
var progress_text = document.getElementById('progress-text');
var progress_info = document.getElementById('progress-current');
var done = false;
var index = 0;
var steps = <?php echo cnd_json_encode($names) ?>;
function do_done() {
progress_info.innerHTML = " ";
progress_info.classList.remove('warning');
progress_info.classList.add('success');
progress.style.width = '100%';
progress_text.innerHTML = '100%';
btn.style.visibility = 'visible';
done = true;
}
function step_done(o) {
if (o.status === "ok") {
index++;
run_step();
} else if (o.status === 'error') {
progress_info.innerHTML = o.error;
progress_info.classList.add('warning');
if (o.error.replace('SQLSTATE[42S01]', '') !== o.error) {
index++;
run_step();
return;
}
if (o.error.replace('SQLSTATE[42000]', '') !== o.error && o.error.replace('1068', '') !== o.error) {
index++;
run_step();
return;
}
if (o.error.replace('SQLSTATE[HY000]:', '') !== o.error && o.error.replace('1826', '') !== o.error) {
index++;
run_step();
return;
}
if (o.error.replace('SQLSTATE[HY000]:', '') !== o.error && o.error.replace('1359', '') !== o.error) {
index++;
run_step();
return;
}
if (o.error.replace('SQLSTATE[42000]:', '') !== o.error && o.error.replace('1304', '') !== o.error) {
index++;
run_step();
return;
}
}
}
function run_step() {
if (index < steps.length) {
var progressi = Math.min(100, parseInt(index / (steps.length / 100)));
progress.style.width = [progressi, '%'].join('');
progress_text.innerHTML = [progressi, '%'].join('');
progress_info.innerHTML = steps[index];
progress_info.classList.remove('warning');
var http = new XMLHttpRequest();
var params = 'data=' + encodeURIComponent(document.getElementById('alldata').value);
var url = '<?php echo $_SERVER['REQUEST_URI'] ?>';
var spl = url.indexOf('?') >= 0 ? '&' : '?';
http.open('POST', [url, spl, 'action=exec_db_step&step=', index, '&tmp=<?php echo $tempname ?>'].join(''), true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function () {
if (http.readyState == 4 && http.status == 200) {
var r = http.response;
var o = null;
try {
o = JSON.parse(r);
if (!(o && typeof (o) === 'object')) {
o = {status: 'error', 'error': 'invalid response'};
}
} catch (e) {
o = {status: 'error', 'error': e.message};
}
step_done(o);
}
};
http.send(params);
} else {
do_done();
}
}
if (btn) {
btn.addEventListener('click', function () {
if (!done) {
return;
}
document.getElementById('form-step-value').value = "6";
document.getElementById('stepxform').submit();
});
}
progress.style.width = '0%';
progress_text.innerHTML = '0';
progress_info.innerHTML = '...';
run_step();
</script>
<?php
do_out(ob_get_clean(), 4);
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="step5">
function step_5() {
$all_data = get_post_data();
try {
$version = check_db_connection_ph();
} catch (\Throwable $ee) {
step_3();
}
$redis_data = array_key_exists('redis', $all_data) && is_array($all_data['redis']) ? $all_data['redis'] : [];
ob_start();
?>
<div class="installer-db-window-backdrop">
<div class="installer-db-window">
<div class="Installer-intro-header"> <div class="installer-compatibility-text"> redis</div></div>
<div class="installer-db-form">
<form id="db_form" onsubmit="return false;" ation="#" method="GET">
<div class="db-form-row">
<label for="db-input-server"> redis</label>
<input type="text" value="<?php echo array_key_exists('server', $redis_data) ? $redis_data['server'] : '' ?>" placeholder="127.0.0.1" name="server" id="db-input-server"/>
</div>
<div class="db-form-row">
<label for="db-input-port"></label>
<input type="text" value="<?php echo array_key_exists('port', $redis_data) ? $redis_data['port'] : '' ?>" placeholder="6379" name="port" id="db-input-port"/>
</div>
<div class="db-form-row">
<label for="db-input-password"></label>
<input type="text" value="<?php echo array_key_exists('password', $redis_data) ? $redis_data['password'] : '' ?>" placeholder="" name="password" id="db-input-password"/>
</div>
<div class="db-check-result" id="db-check-result">
</div>
<div class="db-form-button-row">
<div class="form-btn" id="db-check"></div>
</div>
</form>
</div>
<form method="POST" action="<?php echo $_SERVER['REQUEST_URI'] ?>" id="stepxform">
<input name="step" type="hidden" value="4" id="form-step-value"/>
<input name="data" type="hidden" value="" id="alldata" />
<div class="form-btn" id="stepxsubmit" ></div>
</form>
</div>
</div>
<script>
document.getElementById('alldata').value = JSON.stringify(<?php echo cnd_json_encode($all_data) ?>);
var btn = document.getElementById('stepxsubmit');
if (btn) {
btn.addEventListener('click', function () {
var raw_data = JSON.parse(document.getElementById('alldata').value);
if (!raw_data.redis) {
raw_data.redis = {};
}
raw_data.redis.server = document.getElementById('db-input-server').value;
raw_data.redis.port = document.getElementById('db-input-port').value;
raw_data.redis.password = document.getElementById('db-input-password').value;
document.getElementById('alldata').value = JSON.stringify(raw_data);
document.getElementById('form-step-value').value = "4";
document.getElementById('stepxform').submit();
});
}
var dbc = document.getElementById('db-check');
function get_db_params() {
return {
server: document.getElementById('db-input-server').value,
port: document.getElementById('db-input-port').value,
password: document.getElementById('db-input-password').value
};
}
function check_db_params(xo) {
xo.server = xo.server && (typeof (xo.server) === 'string') ? xo.server.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.server.length ? 0 : xo.server = null;
if (!xo.server) {
throw new Error(" redis");
}
xo.port = xo.port && (typeof (xo.port) === 'string') ? xo.port.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.port.length ? 0 : xo.port = null;
if (xo.port) {
var pt = parseInt(xo.port);
if (isNaN(pt)) {
throw new Error(' ');
}
}
xo.password = xo.password && (typeof (xo.password) === 'string') ? xo.password.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '') : '';
xo.password.length ? 0 : xo.password = null;
}
function redis_checked(o) {
if (o.status === 'ok') {
document.getElementById('db-check-result').innerHTML = [' ; Redis: ', o.version].join('');
document.getElementById('db-check-result').classList.add('success');
var raw_data = JSON.parse(document.getElementById('alldata').value);
if (!raw_data.redis) {
raw_data.redis = {};
}
raw_data.redis.server = document.getElementById('db-input-server').value;
raw_data.redis.port = document.getElementById('db-input-port').value;
raw_data.redis.password = document.getElementById('db-input-password').value;
document.getElementById('alldata').value = JSON.stringify(raw_data);
} else if (o.status === 'error') {
document.getElementById('db-check-result').innerHTML = o.error;
document.getElementById('db-check-result').classList.remove('success');
}
}
if (dbc) {
dbc.addEventListener('click', function () {
var db_params = get_db_params();
try {
check_db_params(db_params);
} catch (e) {
document.getElementById('db-check-result').innerHTML = e.message;
return;
}
var http = new XMLHttpRequest();
var params = 'data=' + encodeURIComponent(JSON.stringify(db_params));
var url = '<?php echo $_SERVER['REQUEST_URI'] ?>';
var spl = url.indexOf('?') >= 0 ? '&' : '?';
http.open('POST', [url, spl, 'action=check_redis_connection'].join(''), true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function () {
if (http.readyState == 4 && http.status == 200) {
var r = http.response;
var o = null;
try {
o = JSON.parse(r);
if (!(o && typeof (o) === 'object')) {
o = {status: 'error', 'error': 'invalid response'};
}
} catch (e) {
o = {status: 'error', 'error': e.message};
}
redis_checked(o);
}
};
http.send(params);
});
}
</script>
<?php
do_out(ob_get_clean(), 5);
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="step_6">
function step_6() {
$all_data = get_post_data();
try {
$version = check_db_connection_ph();
} catch (\Throwable $ee) {
step_3();
}
try {
$rversion = get_redis_version(array_key_exists('redis', $all_data) && is_array($all_data['redis']) ? $all_data['redis'] : []);
} catch (\Throwable $ee) {
step_5();
}
$xml = load_file('install.xml');
$document = new \DOMDocument();
$document->loadXML($xml);
$dirs_doms = $document->getElementsByTagName('d');
$_to_create = [];
foreach ($dirs_doms as $dd) {/* @var $dd \DOMElement */
$relative_path = trim(str_ireplace(['\\', '/'], DIRECTORY_SEPARATOR, $dd->getAttribute('p')), DIRECTORY_SEPARATOR);
$name = $dd->getAttribute('n');
if (mb_strlen($relative_path, 'UTF-8')) {
$full_relative_path = DIRECTORY_SEPARATOR . $relative_path . DIRECTORY_SEPARATOR . $name;
} else {
$full_relative_path = DIRECTORY_SEPARATOR . $name;
}
$_to_create[] = ['t' => 'd', 'n' => $full_relative_path];
}
unset($dirs_doms);
$files_doms = $document->getElementsByTagName('f');
foreach ($files_doms as $file) {/* @var $file \DOMElement */
$relative_path = trim(str_ireplace(['\\', '/'], DIRECTORY_SEPARATOR, $file->getAttribute('p')), DIRECTORY_SEPARATOR);
$name = $file->getAttribute('n');
if (mb_strlen($relative_path, 'UTF-8')) {
$full_relative_path = DIRECTORY_SEPARATOR . $relative_path . DIRECTORY_SEPARATOR . $name;
} else {
$full_relative_path = DIRECTORY_SEPARATOR . $name;
}
$_to_create[] = ['t' => 'f', 'n' => $full_relative_path];
}
unset($files_doms);
unset($document);
ob_start();
?>
<div class="installer-db-window-backdrop">
<div class="installer-db-window">
<div class="Installer-intro-header"> <div class="installer-compatibility-text"> </div></div>
<div class="installer-db-form">
<form id="db_form" onsubmit="return false;" ation="#" method="GET">
<div class="db-form-note" id="warntext">
<div class="db-form-note-inner">
</div>
</div>
<div class="db-form-row">
<div class="db-create-progress-container">
<div class="db-create-progress" >
<div class="db-create-progress-element" id="progress-element" style="width:0%;"></div>
<div class="db-create-progress-tesxt" id="progress-text"></div>
</div>
<div class="db-create-progress-info-container">
<div class="db-create-progress-info" id="progress-current"></div>
</div>
</div>
</div>
</form>
</div>
<form method="POST" action="<?php echo $_SERVER['REQUEST_URI'] ?>" id="stepxform">
<input name="step" type="hidden" value="7" id="form-step-value"/>
<input name="data" type="hidden" value="" id="alldata" />
<div class="form-btn" id="stepxsubmit" style="visibility:hidden" ></div>
</form>
</div>
</div>
<script>
document.getElementById('alldata').value = JSON.stringify(<?php echo json_encode($all_data) ?>);
var btn = document.getElementById('stepxsubmit');
var progress = document.getElementById('progress-element');
var progress_text = document.getElementById('progress-text');
var progress_info = document.getElementById('progress-current');
var done = false;
var index = 0;
var indexNX = 0;
var steps = <?php echo cnd_json_encode($_to_create) ?>;
function do_done() {
progress_info.innerHTML = " ";
progress_info.classList.remove('warning');
progress_info.classList.add('success');
progress.style.width = '100%';
progress_text.innerHTML = '100%';
var http = new XMLHttpRequest();
var params = 'data=' + encodeURIComponent(document.getElementById('alldata').value);
var url = '<?php echo $_SERVER['REQUEST_URI'] ?>';
var spl = url.indexOf('?') >= 0 ? '&' : '?';
http.open('POST', [url, spl, 'action=write_config'].join(''), true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function () {
if (http.readyState == 4 && http.status == 200) {
var r = http.response;
var o = null;
try {
o = JSON.parse(r);
if (!(o && typeof (o) === 'object')) {
o = {status: 'error', 'error': 'invalid response'};
}
} catch (e) {
o = {status: 'error', 'error': e.message};
}
step_done_cf(o);
}
};
http.send(params);
}
function do_done_all() {
progress_info.innerHTML = " ";
progress_info.classList.remove('warning');
progress_info.classList.add('success');
progress.style.width = '100%';
progress_text.innerHTML = '100%';
btn.style.visibility = 'visible';
done = true;
}
function step_done_cf(o) {
if (o.status === "ok") {
do_done_all();
} else if (o.status === 'error') {
progress_info.innerHTML = o.error;
progress_info.classList.add('warning');
}
}
function step_done(o) {
if (o.status === "ok") {
index=indexNX;
run_step();
} else if (o.status === 'error') {
progress_info.innerHTML = o.error;
progress_info.classList.add('warning');
debugger;
}
}
function run_step() {
if (index < steps.length) {
var progressi = Math.min(100, parseInt(index / (steps.length / 100)));
progress.style.width = [progressi, '%'].join('');
progress_text.innerHTML = [progressi, '%'].join('');
progress_info.innerHTML = [steps[index].t === 'd' ? 'dir://' : 'file://', steps[index].n].join('');
progress_info.classList.remove('warning');
var http = new XMLHttpRequest();
var params = 'data=' + encodeURIComponent(document.getElementById('alldata').value);
var url = '<?php echo $_SERVER['REQUEST_URI'] ?>';
var spl = url.indexOf('?') >= 0 ? '&' : '?';
var stepsToExec = [];
var mxStepIndex=0;
for(var si=0;si<10;si++){
var nsi = index+si;
if(nsi<steps.length){
stepsToExec.push(nsi);
mxStepIndex = Math.max(mxStepIndex,nsi);
}
}
indexNX = mxStepIndex+1;
http.open('POST', [url, spl, 'action=exec_fs_step&multistep=', stepsToExec.join(',')].join(''), true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function () {
if (http.readyState == 4 && http.status == 200) {
var r = http.response;
var o = null;
try {
o = JSON.parse(r);
if (!(o && typeof (o) === 'object')) {
o = {status: 'error', 'error': 'invalid response'};
}
} catch (e) {
o = {status: 'error', 'error': e.message};
}
step_done(o);
}
};
http.send(params);
} else {
do_done();
}
}
if (btn) {
btn.addEventListener('click', function () {
if (!done) {
return;
}
document.getElementById('form-step-value').value = "7";
document.getElementById('stepxform').submit();
});
}
progress.style.width = '0%';
progress_text.innerHTML = '0';
progress_info.innerHTML = '...';
run_step();
</script>
<?php
do_out(ob_get_clean(), 5);
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="step_7">
function step_7($error = null,\Throwable $exc = null) {
$all_data = get_post_data();
ob_start();
?>
<div class="installer-db-window-backdrop">
<div class="installer-db-window">
<div class="Installer-intro-header"> <div class="installer-compatibility-text"> </div></div>
<div class="installer-db-form">
<form id="db_form" onsubmit="return false;" ation="#" method="GET">
<div class="db-form-row">
<label for="db-input-user">Email*</label>
<input type="text" value="" name="user_login" id="db-input-user"/>
</div>
<div class="db-form-row">
<label for="db-input-password">*</label>
<input type="text" value="" name="user_password" id="db-input-password"/>
</div>
<div class="db-form-row">
<label for="db-input-family"></label>
<input type="text" value="" name="user_family" id="db-input-family" placeholder="admin"/>
</div>
<div class="db-form-row">
<label for="db-input-name"></label>
<input type="text" value="" name="user_name" id="db-input-name" placeholder="admin"/>
</div>
<div class="db-create-progress-info-container">
<div class="db-create-progress-info <?php echo ($error ? 'warning' : '') ?>" id="progress-current"><?php echo $error ?></div>
<div style='display:none'><pre><?php if($exc){ echo $exc->getTraceAsString();}?></pre><pre><?php var_dump($exc)?></pre></div>
</div>
</form>
</div>
<form method="POST" action="<?php echo $_SERVER['REQUEST_URI'] ?>" id="stepxform">
<input name="step" type="hidden" value="8" id="form-step-value"/>
<input name="data" type="hidden" value="" id="alldata" />
<input name="admin" type="hidden" value="" id="admindata" />
<div class="form-btn" id="stepxsubmit" ></div>
</form>
</div>
</div>
<script>
document.getElementById('alldata').value = JSON.stringify(<?php echo json_encode($all_data) ?>);
var btn = document.getElementById('stepxsubmit');
var progress_info = document.getElementById('progress-current');
function trim(x) {
if (typeof (x) === 'string') {
return x.replace(/^\s{0,}/g, '').replace(/\s{0,}$/g, '');
}
return null;
}
function ntrim(x) {
var r = trim(x);
if (r && r.length > 0) {
return r;
}
return null;
}
if (btn) {
btn.addEventListener('click', function () {
var data = {
login: ntrim(document.getElementById('db-input-user').value),
password: ntrim(document.getElementById('db-input-password').value),
family: ntrim(document.getElementById('db-input-family').value),
name: ntrim(document.getElementById('db-input-name').value)
};
try {
if (!data.login) {
throw new Error(' ');
}
if (!data.password) {
throw new Error(' ');
}
if (data.password.length < 6) {
throw new Error(' , - 6 ');
}
document.getElementById('admindata').value = JSON.stringify(data);
document.getElementById('form-step-value').value = "8";
document.getElementById('stepxform').submit();
} catch (e) {
progress_info.innerHTML = e.message;
progress_info.classList.add('warning');
}
});
}
</script>
<?php
do_out(ob_get_clean(), 5);
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="step_8">
function step_8($error = null) {
try {
$all_data = get_post_data();
if (!file_exists(__DIR__ . DIRECTORY_SEPARATOR . '__bootstrap.php')) {
throw new Exception(' ');
}
require_once __DIR__ . DIRECTORY_SEPARATOR . '__bootstrap.php';
$admin = DataMap\InputDataMap::F()->get_filtered('admin', ['Trim', 'NEString', 'JSONString', 'NEArray', 'DefaultNull']);
$admin ? 0 : \Errors\common_error::R(' ');
$admin_data = Filters\FilterManager::F()->apply_filter_array($admin, [
'login' => ['Strip', 'Trim', 'NEString', 'EmailMatch'],
'password' => ['Trim', 'NEString', 'PasswordMatch'],
'family' => ['Strip', 'Trim', 'NEString', 'DefaultNull'],
'name' => ['Strip', 'Trim', 'NEString', 'DefaultNull'],
]);
Filters\FilterManager::F()->raise_array_error($admin_data);
$builder = \DB\SQLTools\SQLBuilder::F();
$builder->pushParams([
":P{$builder->c}login" => $admin_data['login'],
":P{$builder->c}pass" => \Helpers\PasswordTools::encrypt_password($admin_data['password']),
":P{$builder->c}name" => $admin_data['name'] ? $admin_data['name'] : 'admin',
":P{$builder->c}family" => $admin_data['family'] ? $admin_data['family'] : 'admin',
]);
$varPrefix = '@a';
$userTable = "`user`";
$userFieldTable = "`user__fields`";
if (DB\DB::F()->isPostgress()) {
$varPrefix = 'tmp_sess_var_';
$userTable = "\"user\"";
$userFieldTable = "\"user__fields\"";
}
$temp_var = $varPrefix . md5(__FUNCTION__ . time());
$existsing_user_id = intval(DB\DB::F()->queryScalar("SELECT id FROM {$userTable} WHERE login=:Plogin;", [':Plogin' => $admin_data['login']]));
if ($existsing_user_id) {
\Errors\common_error::RF(' `%s` . email.', $admin_data['login']);
}
if ($builder->adapter->isPostgress()) {
$uuid = Helpers\Helpers::guid_v4();
$builder->push('DO $$')
->push("DECLARE {$temp_var} bigint;")
->push("BEGIN")
->push("INSERT INTO {$userTable} (guid,login,phone_strip,pass,role,locked,created)
VALUES(
:P{$builder->c}uuid,:P{$builder->c}login,null,:P{$builder->c}pass,'admin', 0,NOW())
RETURNING id INTO {$temp_var};")
->push_param(":P{$builder->c}uuid", $uuid)
->push(sprintf('insert into %s(id,vint) VALUES(\'%s\',%s) ON CONFLICT (id) DO UPDATE SET vint=EXCLUDED.vint;', $builder->pgVarTab, $temp_var, $temp_var))
->push("INSERT INTO {$userFieldTable} (id,name,family,eldername,phone) VALUES({$temp_var},:P{$builder->c}name,:P{$builder->c}family,'',null);");
} else {
$builder->push("INSERT INTO {$userTable} (guid,login,phone_strip,pass,role,locked,created) VALUES(UUID(),:P{$builder->c}login,null,:P{$builder->c}pass,'admin',0,NOW());")
->push("SET {$temp_var}=LAST_INSERT_ID();")
->push("INSERT INTO {$userFieldTable} (id,name,family,eldername,phone) VALUES({$temp_var},:P{$builder->c}name,:P{$builder->c}family,'',null);");
}
if ($builder->adapter->isPostgress()) {
$builder->push('END $$;');
}
$result_id = $builder->execute_transact($temp_var);
\Auth\Auth::F()->force_login($result_id);
//cdaa48f8d77b45fa8a6ca0ad067ef03a
//
// ,
ob_start();
\DB\Migration\AbstractMigration::apply_new_migrations();
ob_end_clean();
//
$key_installed = false;
$existsing_key = null;
if (DB\DB::F()->isPostgress()) {
$existsing_key = \Filters\FilterManager::F()->apply_chain(DB\DB::F()->queryScalar('SELECT "value" FROM "presets" WHERE "name"=\'LICENSE_KEY\';'), ['Trim', 'NEString', 'DefaultNull']);
} else {
$existsing_key = \Filters\FilterManager::F()->apply_chain(DB\DB::F()->queryScalar('SELECT `value` FROM `presets` WHERE `name`=\'LICENSE_KEY\';'), ['Trim', 'NEString', 'DefaultNull']);
}
if (!$existsing_key) {
$new_key = \License\LicenseKey::generate_demo(load_file('cdaa48f8d77b45fa8a6ca0ad067ef03a'));
$b = \DB\SQLTools\SQLBuilder::F();
if (DB\DB::F()->isPostgress()) {
$b->push("INSERT INTO \"presets\" (\"name\",\"value\") VALUES(:P{$b->c}key,:P{$b->c}val) ON CONFLICT (\"name\") DO UPDATE SET \"value\"=EXCLUDED.\"value\";");
} else if ($b->get_mysql_version()->mysql8g) {
$b->push("INSERT INTO `presets` (`name`,`value`) VALUES(:P{$b->c}key,:P{$b->c}val) as `presets_tmp` ON DUPLICATE KEY UPDATE `value`=`presets_tmp`.`value`;");
} else {
$b->push("INSERT INTO `presets` (`name`,`value`) VALUES(:P{$b->c}key,:P{$b->c}val) ON DUPLICATE KEY UPDATE `value`=VALUES(`value`);");
}
$b->push_params([
":P{$b->c}key" => 'LICENSE_KEY',
":P{$b->c}val" => $new_key,
])->execute();
$key_installed = true;
\PresetManager\PresetManager::RESET_CACHE();
}
$predef_removed = false;
$installer_moved = false;
$predef = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'mysql.dba.txt';
if (file_exists($predef) && is_file($predef) && is_writable($predef)) {
@unlink($predef);
$predef_removed = true;
}
$installer_target = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'installer.php';
if (file_exists($installer_target) && is_file($installer_target) && is_writable($installer_target)) {
@unlink($installer_target);
}
if (!file_exists($installer_target)) {
@rename(__FILE__, $installer_target);
$installer_moved = true;
}
} catch (\Throwable $e) {
step_7($e->getMessage(), $e);
}
ob_start();
?>
<div class="installer-db-window-backdrop">
<div class="installer-db-window">
<div class="Installer-intro-header"> <div class="installer-compatibility-text"> .</div></div>
<div class="installer-db-form">
. .<br>
/config nginx - .<br>
.<br>
<?php if ($key_installed) { ?>
<br> 30 . - .<br>
<?php } else { ?>
<br> , .<br>
<?php } ?>
<?php if ($predef_removed) { ?>
.<br>
<?php } ?>
<?php if ($installer_moved) { ?>
( webroot) . <br>
, .
<?php } ?>
</div>
<div class="window-footer">
<div class="window-footer-content">
<a class="form-btn" href="<?= Config\Config::F()->getAssetBase() ?>admin/Users/index"></a>
</div>
</div>
</div>
</div>
<?php
do_out(ob_get_clean(), 5);
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="actions">
//<editor-fold defaultstate="collapsed" desc="exec_db_step">
function action_exec_db_step() {
$od = ['status' => 'ok'];
try {
$version_pdo = check_db_connection_ph(true);
$version = $version_pdo['version'];
$pdo = $version_pdo['pdo'];
$steps = parse_steps($version);
$step = intval(ntrima($_GET, 'step'));
$step_sql = array_key_exists($step, $steps) && is_array($steps[$step]) && array_key_exists('task', $steps[$step]) ? $steps[$step]['task'] : null;
if (!$step_sql) {
throw new Exception("no step index");
}
$pdo->exec($step_sql);
} catch (\Throwable $e) {
$od['status'] = 'error';
$od['error'] = $e->getMessage();
}
return $od;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="check_db_connection">
function check_connection_sqm_mysql(array $in, array &$od) {
$keys = ['server', 'port', 'user', 'password', 'db'];
foreach ($keys as $key) {
if (!array_key_exists($key, $in)) {
throw new Exception(" `{$key}`");
}
}
$server = ntrima($in, 'server');
if (!$server) {
throw new Exception(" ");
}
$port = ntrima($in, 'port');
if ($port !== null) {
if (!intval($port)) {
throw new Exception(" ");
}
}
$user = ntrima($in, 'user');
if (!$user) {
throw new Exception(" ");
}
$password = ntrima($in, 'password');
if (!$password) {
throw new Exception(" ");
}
$db = ntrima($in, 'db');
if (!$db) {
throw new Exception(" ");
}
$dsn = sprintf('mysql:host=%s;port=%s;dbname=%s;charset=utf8', $server, ($port ? $port : 3306), $db);
$od['check'] = [
'dsn' => $dsn,
'user' => $user,
'password' => $password,
'driver'=>'mysql',
];
$pdo = new PDO($dsn, $user, $password, mkPDOConnetionOptions([
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
]));
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$statement = $pdo->prepare('SELECT @@VERSION');
$statement->execute([]);
$version = null;
$version_row = $statement->fetch(\PDO::FETCH_NUM);
$statement->closeCursor();
if ($version_row && is_array($version_row) && array_key_exists(0, $version_row)) {
$version = $version_row[0];
}
if (!$version) {
throw new Exception(' mySQL');
}
$od['version'] = $version;
$tt_name = "db_installer_test_" . md5(implode(',', [__FILE__, time()]));
try {
$pdo->exec("CREATE TEMPORARY TABLE `{$tt_name}`(id BIGINT UNSIGNED NOT NULL,PRIMARY KEY(id))ENGINE=InnoDB;");
} catch (\Throwable $ee) {
throw new Exception(" ({$ee->getMessage()})");
}
}
function check_connection_sqm_pgsql(array $in, array &$od) {
$keys = ['server', 'port', 'user', 'password', 'db'];
foreach ($keys as $key) {
if (!array_key_exists($key, $in)) {
throw new Exception(" `{$key}`");
}
}
$server = ntrima($in, 'server');
if (!$server) {
throw new Exception(" ");
}
$port = ntrima($in, 'port');
if ($port !== null) {
if (!intval($port)) {
throw new Exception(" ");
}
}
$user = ntrima($in, 'user');
if (!$user) {
throw new Exception(" ");
}
$password = ntrima($in, 'password');
if (!$password) {
throw new Exception(" ");
}
$db = ntrima($in, 'db');
if (!$db) {
throw new Exception(" ");
}
$dsn = sprintf('pgsql:host=%s;port=%s;dbname=%s;user=%s;password=%s', $server, ($port ? $port : 5432), $db,$user,$password);
$od['check'] = [
'dsn' => $dsn,
'user' => $user,
'password' => $password,
'driver'=>'mysql',
];
$pdo = new PDO($dsn, null, null, mkPDOConnetionOptions([
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
]));
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$statement = $pdo->prepare('SELECT version();');
$statement->execute([]);
$version = null;
$version_row = $statement->fetch(\PDO::FETCH_NUM);
$statement->closeCursor();
if ($version_row && is_array($version_row) && array_key_exists(0, $version_row)) {
$version = $version_row[0];
}
if (!$version) {
throw new Exception(' PostgreSQL');
}
$od['version'] = $version;
$tt_name = "db_installer_test_" . md5(implode(',', [__FILE__, time()]));
try {
$pdo->exec("CREATE TEMPORARY TABLE \"{$tt_name}\"(id bigint NOT NULL,PRIMARY KEY(id));");
} catch (\Throwable $ee) {
throw new Exception(" ({$ee->getMessage()})");
}
}
function action_check_db_connection() {
$od = ['status' => 'ok'];
try {
$str = array_key_exists('data', $_POST) ? $_POST['data'] : '';
$arr = @cnd_json_decode($str, true);
if (!is_array($arr)) {
throw new Exception(' ');
}
$driver = array_key_exists('driver', $arr) && is_string($arr['driver']) ? $arr['driver'] : 'mysql';
$fn = "check_connection_sqm_{$driver}";
if (function_exists($fn)) {
$fn($arr, $od);
} else {
throw new Exception("unknown driver {$driver}");
}
} catch (\Throwable $e) {
$od['status'] = 'error';
$od['error'] = $e->getMessage();
}
return $od;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="check_db_create">
function action_check_db_create() {
$od = ['status' => 'ok'];
try {
$str = array_key_exists('data', $_POST) ? $_POST['data'] : '';
$arr = @cnd_json_decode($str, true);
if (!is_array($arr)) {
throw new Exception(' ');
}
$keys = ['server', 'port', 'user', 'password', 'db'];
foreach ($keys as $key) {
if (!array_key_exists($key, $arr)) {
throw new Exception(" `{$key}`");
}
}
$server = ntrima($arr, 'server');
if (!$server) {
throw new Exception(" ");
}
$port = ntrima($arr, 'port');
if ($port !== null) {
if (!intval($port)) {
throw new Exception(" ");
}
}
$user = ntrima($arr, 'user');
if (!$user) {
throw new Exception(" ");
}
$password = ntrima($arr, 'password');
if (!$password) {
throw new Exception(" ");
}
$db = ntrima($arr, 'db');
if (!$db) {
throw new Exception(" ");
}
$overwtite = array_key_exists('overwrite', $arr) && is_bool($arr['overwrite']) ? $arr['overwrite'] : false;
$options = mkPDOConnetionOptions([
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
]);
$pdo = new PDO(sprintf('mysql:host=%s;port=%s;charset=utf8', $server, ($port ? $port : 3306)), $user, $password, $options);
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$statement = $pdo->prepare('SELECT @@VERSION');
$statement->execute([]);
$version = null;
$version_row = $statement->fetch(\PDO::FETCH_NUM);
$statement->closeCursor();
if ($version_row && is_array($version_row) && array_key_exists(0, $version_row)) {
$version = $version_row[0];
}
if (!$version) {
throw new Exception(' mySQL');
}
$od['version'] = $version;
$statement = $pdo->query('SHOW DATABASES;');
$dbx = [];
foreach ($statement->fetchAll(PDO::FETCH_NUM) as $row) {
if (is_array($row) && count($row)) {
$dbn = mb_strtolower($row[0], 'UTF-8');
$dbn = ntrim($dbn);
if ($dbn) {
$dbx[$dbn] = $dbn;
}
}
}
$statement->closeCursor();
if (array_key_exists(mb_strtolower($db, 'UTF-8'), $dbx)) {
throw new Exception(sprintf(' `%s` ', $db));
}
$tdb_name = "db_installer_test_" . md5(implode(',', [__FILE__, time()]));
try {
$pdo->exec("CREATE DATABASE `{$tdb_name}` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;");
} catch (\Throwable $ee) {
throw new Exception(" ({$ee->getMessage()})");
}
$od['grant'] = true;
try {
$pdo->exec("DROP DATABASE IF EXISTS `{$tdb_name}`;");
} catch (\Throwable $ee) {
}
} catch (\Throwable $e) {
$od['status'] = 'error';
$od['error'] = $e->getMessage();
}
return $od;
}
function action_check_db_create_pg() {
$od = ['status' => 'ok'];
try {
$str = array_key_exists('data', $_POST) ? $_POST['data'] : '';
$arr = @cnd_json_decode($str, true);
if (!is_array($arr)) {
throw new Exception(' ');
}
$keys = ['server', 'port', 'user', 'password', 'db'];
foreach ($keys as $key) {
if (!array_key_exists($key, $arr)) {
throw new Exception(" `{$key}`");
}
}
$server = ntrima($arr, 'server');
if (!$server) {
throw new Exception(" ");
}
$port = ntrima($arr, 'port');
if ($port !== null) {
if (!intval($port)) {
throw new Exception(" ");
}
}
$user = ntrima($arr, 'user');
if (!$user) {
throw new Exception(" ");
}
$password = ntrima($arr, 'password');
if (!$password) {
throw new Exception(" ");
}
$db = ntrima($arr, 'db');
if (!$db) {
throw new Exception(" ");
}
$tpldb = ntrima($arr, 'tpldb');
if (!$tpldb) {
throw new Exception(" ");
}
$overwtite = array_key_exists('overwrite', $arr) && is_bool($arr['overwrite']) ? $arr['overwrite'] : false;
$options = mkPDOConnetionOptions([
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
]);
$pdo = new PDO(sprintf('pgsql:host=%s;port=%s;dbname=%s;user=%s;password=%s',$server,$port,$tpldb,$user,$password),null,null,$options);
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$statement = $pdo->prepare('SELECT version();');
$statement->execute([]);
$version = null;
$version_row = $statement->fetch(\PDO::FETCH_NUM);
$statement->closeCursor();
if ($version_row && is_array($version_row) && array_key_exists(0, $version_row)) {
$version = $version_row[0];
}
if (!$version) {
throw new Exception(' PostgreSQL');
}
$od['version'] = $version;
$tdb_name = "db_installer_test_" . md5(implode(',', [__FILE__, time()]));
try {
$pdo->exec("CREATE DATABASE \"{$tdb_name}\" TEMPLATE=template0 ENCODING=UTF8;");
} catch (\Throwable $ee) {
throw new Exception(" ({$ee->getMessage()})");
}
$od['grant'] = true;
try {
$pdo->exec("DROP DATABASE IF EXISTS \"{$tdb_name}\";");
} catch (\Throwable $ee) {
// throw $ee;
}
} catch (\Throwable $e) {
$od['status'] = 'error';
$od['error'] = $e->getMessage();
}
return $od;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="check_db_create_create">
function action_check_db_create_create() {
$od = ['status' => 'ok'];
try {
$str = array_key_exists('data', $_POST) ? $_POST['data'] : '';
$arr = @cnd_json_decode($str, true);
if (!is_array($arr)) {
throw new Exception(' ');
}
$keys = ['server', 'port', 'user', 'password', 'db', 'create_user', 'user_name', 'user_password', 'user_host'];
foreach ($keys as $key) {
if (!array_key_exists($key, $arr)) {
throw new Exception(" `{$key}`");
}
}
$server = ntrima($arr, 'server');
if (!$server) {
throw new Exception(" ");
}
$port = ntrima($arr, 'port');
if ($port !== null) {
if (!intval($port)) {
throw new Exception(" ");
}
}
$user = ntrima($arr, 'user');
if (!$user) {
throw new Exception(" ");
}
$password = ntrima($arr, 'password');
if (!$password) {
throw new Exception(" ");
}
$db = ntrima($arr, 'db');
if (!$db) {
throw new Exception(" ");
}
$create_user = is_bool($arr['create_user']) ? $arr['create_user'] : false; //$_SERVER['SERVER_ADDR']
$create_user_name = ntrima($arr, 'user_name');
$create_user_password = ntrima($arr, 'user_password');
$create_user_host = ntrima($arr, 'user_host');
$create_user_name = $create_user_name ? $create_user_name : $db;
$create_user_password = $create_user_password ? $create_user_password : mk_password(25);
$create_user_host = $create_user_host ? $create_user_host : '%';
$pdo = new PDO(sprintf('mysql:host=%s;port=%s;charset=utf8', $server, ($port ? $port : 3306)), $user, $password, mkPDOConnetionOptions([
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
]));
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$statement = $pdo->query('SHOW DATABASES;');
$dbx = [];
foreach ($statement->fetchAll(PDO::FETCH_NUM) as $row) {
if (is_array($row) && count($row)) {
$dbn = ntrim(mb_strtolower($row[0], 'UTF-8'));
if ($dbn) {
$dbx[$dbn] = $dbn;
}
}
}
$statement->closeCursor();
if (array_key_exists(mb_strtolower($db, 'UTF-8'), $dbx)) {
throw new Exception(sprintf(' `%s` ', $db));
}
$tdb_name = $db;
$pdo->exec("CREATE DATABASE `{$tdb_name}` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;");
if ($create_user) {
$pdo->exec("CREATE USER '{$create_user_name}'@'{$create_user_host}' IDENTIFIED BY '{$create_user_password}';");
$pdo->exec("GRANT ALL PRIVILEGES ON `{$db}`.* TO '{$create_user_name}'@'{$create_user_host}';");
$pdo->exec("FLUSH PRIVILEGES;");
}
$od['params'] = [
'server' => $server,
'port' => $port,
'db' => $db,
];
if ($create_user) {
$od['params']['user'] = $create_user_name;
$od['params']['password'] = $create_user_password;
}
} catch (\Throwable $e) {
$od['status'] = 'error';
$od['error'] = $e->getMessage();
}
return $od;
}
function action_check_db_create_create_pg() {
$od = ['status' => 'ok'];
try {
$str = array_key_exists('data', $_POST) ? $_POST['data'] : '';
$arr = @cnd_json_decode($str, true);
if (!is_array($arr)) {
throw new Exception(' ');
}
$keys = ['server', 'port', 'user', 'password', 'db', 'user_name', 'user_password', 'tpldb'];
foreach ($keys as $key) {
if (!array_key_exists($key, $arr)) {
throw new Exception(" `{$key}`");
}
}
$server = ntrima($arr, 'server');
if (!$server) {
throw new Exception(" ");
}
$port = ntrima($arr, 'port');
if ($port !== null) {
if (!intval($port)) {
throw new Exception(" ");
}
}
$user = ntrima($arr, 'user');
if (!$user) {
throw new Exception(" ");
}
$password = ntrima($arr, 'password');
if (!$password) {
throw new Exception(" ");
}
$db = ntrima($arr, 'db');
if (!$db) {
throw new Exception(" ");
}
$tpldb = ntrima($arr, 'tpldb');
if (!$tpldb) {
throw new Exception(" ");
}
$create_user = true; //is_bool($arr['create_user']) ? $arr['create_user'] : false; //$_SERVER['SERVER_ADDR']
$create_user_name = ntrima($arr, 'user_name');
$create_user_password = ntrima($arr, 'user_password');
$create_user_name = $create_user_name ? $create_user_name : $db;
$create_user_password = $create_user_password ? $create_user_password : mk_password(45);
//$create_user_host = $create_user_host ? $create_user_host : '%';
$dsn = sprintf('pgsql:host=%s;port=%s;dbname=%s;user=%s;password=%s', $server, $port, $tpldb, $user, $password);
$pdo = new PDO($dsn, null, null, mkPDOConnetionOptions([
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
\PDO::ATTR_AUTOCOMMIT => 1
]));
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$pdo->setAttribute(\PDO::ATTR_AUTOCOMMIT, 1);
$query = [
"DROP DATABASE IF EXISTS \"{$db}\";",
"DROP ROLE IF EXISTS \"{$create_user_name}\";",
"CREATE ROLE \"{$create_user_name}\" WITH LOGIN PASSWORD '{$create_user_password}';",
"CREATE DATABASE \"{$db}\" OWNER=\"{$create_user_name}\" TEMPLATE=\"{$tpldb}\" ENCODING=UTF8;",
];
foreach ($query as $command){
$pdo->exec( $command);
}
$od['params'] = [
'server' => $server,
'port' => $port,
'db' => $db,
];
$od['params']['user'] = $create_user_name;
$od['params']['password'] = $create_user_password;
} catch (\Throwable $e) {
$od['status'] = 'error';
$od['error'] = $e->getMessage();
}
return $od;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="check_redis_connection">
function action_check_redis_connection() {
$od = ['status' => 'ok'];
try {
$str = array_key_exists('data', $_POST) ? $_POST['data'] : '';
$arr = @cnd_json_decode($str, true);
if (!is_array($arr)) {
throw new Exception(' ');
}
$od['version'] = get_redis_version($arr);
} catch (\Throwable $e) {
$od['status'] = 'error';
$od['error'] = $e->getMessage();
}
return $od;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="exec_fs_step">
function exec_fs_root_dir() {
if (defined('DEBUG_MODE') && DEBUG_MODE === true) {
$path = '/var/VHOSTS/exp_der_map';
if (!(file_exists($path) && is_dir($path))) {
@mkdir($path, 0755, true);
}
if (!(file_exists($path) && is_dir($path))) {
throw new Exception(sprintf(' %s', $path));
}
return $path;
} else {
get_webroot(); // throws error if script not in webroot
get_webroot_name();
return get_install_dir();
}
}
function exec_fs_step_dir(DOMElement $node) {
$relative_path = trim(str_ireplace(['\\', '/'], DIRECTORY_SEPARATOR, $node->getAttribute('p')), '\\/');
if (mb_strlen($relative_path, 'UTF-8')) {
$absolute_path = rtrim(exec_fs_root_dir(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $relative_path . DIRECTORY_SEPARATOR . $node->getAttribute('n');
} else {
$absolute_path = rtrim(exec_fs_root_dir(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $node->getAttribute('n');
}
if (!(file_exists($absolute_path) && is_dir($absolute_path))) {
@mkdir($absolute_path, 0755, true);
}
}
function exec_fs_step_file(DOMElement $node) {
$relative_path = trim(str_ireplace(['\\', '/'], DIRECTORY_SEPARATOR, $node->getAttribute('p')), '\\/');
if (mb_strlen($relative_path, 'UTF-8')) {
$absolute_path = rtrim(exec_fs_root_dir(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $relative_path . DIRECTORY_SEPARATOR . $node->getAttribute('n');
} else {
$absolute_path = rtrim(exec_fs_root_dir(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $node->getAttribute('n');
}
$overwrite = !!(intval($node->getAttribute('f')) & 0x01);
$chmod = intval($node->getAttribute('h'));
$date_str = $node->getAttribute('m');
$date = xml_2_datetime($date_str);
$alias = $node->getAttribute('a');
if (!$overwrite) {
if (file_exists($absolute_path)) {
return;
}
}
$content = load_file($alias);
if (null === $content) {
throw new Exception("cant unpack file `{$relative_path}/{$node->getAttribute('n')}`");
}
file_put_contents($absolute_path, $content);
if ($chmod && !is_windows_os()) {
chmod($absolute_path, $chmod);
}
if ($date) {
touch($absolute_path, $date->getTimestamp());
}
}
function action_exec_fs_step() {
$od = ['status' => 'ok'];
try {
$stepsToExecute = [];
$mxSteps = ntrim(array_key_exists('multistep', $_GET) ? $_GET['multistep'] : '');
if ($mxSteps) {
$astepstr = explode(',', $mxSteps);
foreach ($astepstr as $stepStr) {
$stepIndex = intval($stepStr);
if ($stepIndex) {
$stepsToExecute[] = $stepIndex;
}else if($stepIndex===0 && $stepStr==='0'){
$stepsToExecute[]=0;
}
}
} else {
$step = intval(ntrima($_GET, 'step'));
if ($step) {
$stepsToExecute[] = $step;
}else if($step===0 && ntrima($_GET, 'step')==='0'){
$stepsToExecute[]=0;
}
}
$xml = load_file('install.xml');
$dom = new DOMDocument();
$dom->loadXML($xml);
$dirs = $dom->getElementsByTagName('d');
foreach ($stepsToExecute as $step) {
$node = null;
if ($dirs->length > $step) {
$node = $dirs->item($step);
} else {
$files = $dom->getElementsByTagName('f');
$cu_step = $step - $dirs->length;
$node = $files->item($cu_step);
}
if ($node) {/* @var $node \DOMElement */
if ($node->tagName === 'd') {
exec_fs_step_dir($node);
} else if ($node->tagName === 'f') {
exec_fs_step_file($node);
} else {
throw new Exception("invalid filesystem tag `{$node->tagName}`");
}
} else {
$od['failstep'] = $step;
throw new Exception(' ' . $step);
}
}
} catch (\Throwable $e) {
$od['status'] = 'error';
$od['error'] = $e->getMessage();
}
return $od;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="write_config">
function action_write_config() {
$od = ['status' => 'ok'];
try {
$ap_dir = $absolute_path = rtrim(exec_fs_root_dir(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'config';
$rt_dir = rtrim(exec_fs_root_dir(), DIRECTORY_SEPARATOR);
$alldata = get_post_data();
$db = $alldata['db'];
$init_cmd = "'init'=>'SET NAMES utf8mb4;',";
if ($db['driver'] === 'pgsql') {
$init_cmd = "//";
}
$dbw = <<<DBCONFA090876
<?php
/*
* database config file
*/
return \Config\DBPool::F([
[
'driver'=>'{$db['driver']}',
'id' => 'default',
'server' => '{$db['server']}',
'db' => '{$db['db']}',
'user' => '{$db['user']}',
'password' => '{$db['password']}',
{$init_cmd}
'attributes'=>\Helpers\Helpers::optionalRequireArray(__DIR__.DIRECTORY_SEPARATOR.'pdo-options.php',[]),
]
]);
DBCONFA090876;
file_put_contents($ap_dir . DIRECTORY_SEPARATOR . 'database.conf.php', $dbw);
if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'pdo-options.php') && is_file(__DIR__ . DIRECTORY_SEPARATOR . 'pdo-options.php')) {
file_put_contents($ap_dir . DIRECTORY_SEPARATOR . 'pdo-options.php', file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'pdo-options.php'));
}
$redis = $alldata['redis'];
$redis_port_value = intval(ntrima($redis, 'port'));
if (!$redis_port_value) {
$redis_port_value = 'null';
}
$redis_password_value = ntrima($redis, 'password');
if (!$redis_password_value) {
$redis_password_value = 'null';
} else {
$redis_password_value = sprintf('\'%s\'', $redis_password_value);
}
$rdw = <<<REDISCONF593T67
<?php
/*
* redis config file
*/
return [
'server' => '{$redis['server']}',
'port' => {$redis_port_value},
'password' => {$redis_password_value}
];
REDISCONF593T67;
file_put_contents($ap_dir . DIRECTORY_SEPARATOR . 'redis.conf.php', $rdw);
$phpva = explode('.', PHP_VERSION);
$php_v = implode('.', array_slice($phpva, 0, 2));
$hostname = array_key_exists('HTTP_HOST', $_SERVER) ? $_SERVER['HTTP_HOST'] : 'leader.map.local';
$ng_conf = <<<MG_NGINX_CONF_EXAMPLE
server {
listen 80 default_server;
listen [::]:80 default_server;
#########################################
# ssl
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
# ssl on;
# ssl_certificate -path-to-certificate-;
# ssl_certificate_key -path-to-private-key-;
# ssl_session_timeout 5m;
#########################################
server_name {$hostname};
root {$rt_dir}/www;
access_log {$rt_dir}/log/nginx_access.log;
error_log {$rt_dir}/log/nginx_error.log;
client_max_body_size 1024m;
index index.php index.html;
error_page 404 /e404;
location / {
# - CORS
# Access-Control-*
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,x-auth-token,x-ws-common-auth' always;
add_header 'Access-Control-Expose-Headers' 'Content-Type,x-auth-token,x-ws-common-auth' always;
add_header 'Access-Control-Max-Age' 1728000;
if (\$request_method = 'OPTIONS') {
# CORS
#
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,x-auth-token,x-ws-common-auth' always;
add_header 'Access-Control-Expose-Headers' 'Content-Type,x-auth-token,x-ws-common-auth' always;
add_header 'Content-Type' 'text/plain charset=UTF-8' always;
add_header 'Content-Length' 0 always;
add_header 'Access-Control-Max-Age' 1728000 always;
return 204;
}
try_files \$uri @try_php;
}
location /privates_send_xaccel{
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,x-auth-token,x-ws-common-auth' always;
add_header 'Access-Control-Expose-Headers' 'Content-Type,x-auth-token,x-ws-common-auth' always;
add_header 'Access-Control-Max-Age' 1728000 always;
alias {$rt_dir}/_private_media_cache;
internal;
}
location /publics_send_xaccel{
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,x-auth-token,x-ws-common-auth' always;
add_header 'Access-Control-Expose-Headers' 'Content-Type,x-auth-token,x-ws-common-auth' always;
add_header 'Access-Control-Max-Age' 1728000 always;
alias {$rt_dir}/www/media;
internal;
}
#########################################
#
# - fastcgi_pass php-fpm
# , php
#
#########################################
location @try_php {
include fastcgi_params;
fastcgi_pass unix:/var/run/php/php{$php_v}-fpm.sock;
fastcgi_param SCRIPT_FILENAME \$document_root/index.php;
fastcgi_read_timeout 300;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php{$php_v}-fpm.sock;
}
location ~ /\.ht {
deny all;
}
location = /e404{
include fastcgi_params;
fastcgi_pass unix:/var/run/php/php{$php_v}-fpm.sock;
fastcgi_param SCRIPT_FILENAME \$document_root/lost.php;
fastcgi_intercept_errors off;
}
location @none_found{
include fastcgi_params;
fastcgi_pass unix:/var/run/php/php{$php_v}-fpm.sock;
fastcgi_param SCRIPT_FILENAME \$document_root/lost.php;
fastcgi_intercept_errors off;
}
}
MG_NGINX_CONF_EXAMPLE;
file_put_contents($ap_dir . 'nginx.example.config', $ng_conf);
} catch (\Throwable $e) {
$od['status'] = 'error';
$od['error'] = $e->getMessage();
}
return $od;
}
//</editor-fold>
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="run">
$action = array_key_exists('action', $_GET) ? $_GET['action'] : null;
if ($action) {
$fn = "action_{$action}";
if (function_exists($fn)) {
$od = call_user_func($fn);
while (ob_get_level()) {
ob_end_clean();
}
header('Content-Type: application/json');
echo cnd_json_encode($od);
die();
} else {
while (ob_get_level()) {
ob_end_clean();
}
header('Content-Type: applcation/json');
echo cnd_json_encode(['status' => 'error', 'error' => 'no action found']);
die();
}
} else {
$stepRaw = array_key_exists('step', $_POST) ? $_POST['step'] : "";
$step = intval($stepRaw);
if($stepRaw==="2mysql" || $stepRaw==="2pgsql"){
$step = $stepRaw;
}
if (function_exists("step_{$step}")) {
call_user_func("step_{$step}");
} else {
step_0();
}
}
//</editor-fold>
__halt_compiler();ec3f1dccb0ed444990bf08a48a1fbf2f:sql.sql@0000010528BZh91AY&SY
Function Calls
None |
Stats
MD5 | c23921e187a3af6625abd4aa7aadd12a |
Eval Count | 0 |
Decode Time | 198 ms |