insertion of installer

This commit is contained in:
rahul shukla 2019-06-03 16:32:50 +05:30
parent fc456c785f
commit 642a5a8ce3
23 changed files with 1778 additions and 0 deletions

130
public/installer/Admin.php Executable file
View File

@ -0,0 +1,130 @@
<html>
<body>
<div class="container admin" id="admin">
<div class="initial-display">
<p>Admin Details</p>
<form action="AdminConfig.php" method= "POST" id="admin-form">
<div class="content">
<div class="form-container" style="padding: 10%; padding-top: 35px">
<div class="control-group" id="admin_name">
<label for="admin_name" class="required">Name</label>
<input type="text" name="admin_name" class="control"
data-validation="required length" data-validation-length="max50">
</div>
<div class="control-group" id="admin_email">
<label for="admin_email" class="required">Email</label>
<input type="text" name="admin_email" class="control"
data-validation="required email length" data-validation-length="max50">
</div>
<div class="control-group" id="admin_password">
<label for="admin_password" class="required">Password</label>
<input type="password" name="admin_password" class="control"
data-validation="length required" data-validation-length="min6">
</div>
<div class="control-group" id="admin_re_password">
<label for="admin_re_password" class="required">Re-Password</label>
<input type="password" name="admin_re_password" class="control"
data-validation="length required" data-validation-length="min6">
</div>
</div>
</div>
<div>
<button class="prepare-btn" id="admin-check">Continue</button>
</div>
</form>
</div>
</div>
</body>
</html>
<script>
$.validate({});
</script>
<script>
$(document).ready(function() {
// process the form
$('#admin-form').submit(function(event) {
$('.control-group').removeClass('has-error'); // remove the error class
$('.form-error').remove(); // remove the error text
// get the form data
var formData = {
'admin_email' : $('input[name=admin_email]').val(),
'admin_name' : $('input[name=admin_name]').val(),
'admin_password' : $('input[name=admin_password]').val(),
'admin_re_password' : $('input[name=admin_re_password]').val(),
};
var adminTarget = window.location.href.concat('/AdminConfig.php');
// process the form
$.ajax({
type : 'POST', // define the type of HTTP verb we want to use (POST for our form)
url : adminTarget, // the url where we want to POST
data : formData, // our data object
dataType : 'json', // what type of data do we expect back from the server
encode : true
})
// using the done promise callback
.done(function(data) {
if (!data.success) {
// handle errors
if (data.errors.admin_email) {
$('#admin_email').addClass('has-error');
$('#admin_email').append('<div class="form-error">' + data.errors.admin_email + '</div>');
}
if (data.errors.admin_name) {
$('#admin_name').addClass('has-error');
$('#admin_name').append('<div class="form-error">' + data.errors.admin_name + '</div>');
}
if (data.errors.admin_password) {
$('#admin_password').addClass('has-error');
$('#admin_password').append('<div class="form-error">' + data.errors.admin_password + '</div>');
}
if (data.errors.admin_re_password) {
$('#admin_re_password').addClass('has-error');
$('#admin_re_password').append('<div class="form-error">' + data.errors.admin_re_password + '</div>');
}
if (data.errors.password_match) {
$('#admin_re_password').addClass('has-error');
$('#admin_password').addClass('has-error');
$('#admin_re_password').append('<div class="form-error">' + data.errors.password_match + '</div>');
$('#admin_password').append('<div class="form-error">' + data.errors.password_match + '</div>');
}
} else {
// error handling for database
// connection error
if (data['connection']) {
alert(data['connection']);
}
// insert error
if (data['insert_fail']) {
alert(data['insert_fail']);
}
// Database support error
if (data['support_error']) {
result = confirm(data['support_error']);
if (result) {
$('#admin').hide();
$('#finish').show();
}
}
if (!data['connection'] && !data['insert_fail'] && !data['support_error']) {
$('#admin').hide();
$('#finish').show();
}
}
});
// stop the form from submitting the normal way and refreshing the page
event.preventDefault();
});
});
</script>

112
public/installer/AdminConfig.php Executable file
View File

@ -0,0 +1,112 @@
<?php
// array to hold validation errors
$errors = array();
// array to pass back data
$data = array();
// validate the variables
// if any of these variables don't exist, add an error to our $errors array
if (empty($_POST['admin_email']))
$errors['admin_email'] = 'Email is required.';
if (empty($_POST['admin_name']))
$errors['admin_name'] = 'Name is required.';
if (empty($_POST['admin_password']))
$errors['admin_password'] = 'Password is required.';
if (empty($_POST['admin_re_password']))
$errors['admin_re_password'] = 'Re-Password is required.';
if ($_POST['admin_re_password'] !== $_POST['admin_password'])
$errors['password_match'] = 'Password & Re-Password did not match';
// return a response
// if there are any errors in our errors array, return a success boolean of false
if ( ! empty($errors)) {
// if there are items in our errors array, return those errors
$data['success'] = false;
$data['errors'] = $errors;
} else {
$location = str_replace('\\', '/', getcwd());
$currentLocation = explode("/", $location);
array_pop($currentLocation);
array_pop($currentLocation);
$desiredLocation = implode("/", $currentLocation);
$envFile = $desiredLocation . '/' . '.env';
// reading env content
$data = file($envFile);
$databaseArray = ['DB_HOST', 'DB_DATABASE', 'DB_USERNAME', 'DB_PASSWORD', 'DB_CONNECTION'];
$key = $value = [];
if ($data) {
foreach ($data as $line) {
$line = preg_replace('/\s+/', '', $line);
$rowValues = explode('=', $line);
if (strlen($line) !== 0) {
if (in_array($rowValues[0], $databaseArray)) {
$key[] = $rowValues[0];
$value[] = $rowValues[1];
}
}
}
}
$databaseData = array_combine($key, $value);
// getting database info
$servername = $databaseData['DB_HOST'];
$username = $databaseData['DB_USERNAME'];
$password = $databaseData['DB_PASSWORD'];
$dbname = $databaseData['DB_DATABASE'];
$connection = $databaseData['DB_CONNECTION'];
if ($connection == 'mysql' ) {
// Create connection
@$conn = new mysqli($servername, $username, $password, $dbname);
// check connection
if ($conn->connect_error) {
$data['connection'] = $conn->connect_error;
}
$email = $_POST['admin_email'];
$name = $_POST['admin_name'];
$password = password_hash($_POST['admin_password'], PASSWORD_BCRYPT, ['cost' => 10]);
// Deleting migrated admin
$deleteAdmin = "DELETE FROM admins WHERE id=1";
$conn->query($deleteAdmin);
// query for insertion
$sql = "INSERT INTO admins (name, email, password, role_id, status)
VALUES ('".$name."', '".$email."', '".$password."', '1', '1')";
if ($conn->query($sql) === TRUE) {
$data['insert_success'] = 'Data Successfully inserted into database';
} else {
$data['insert_fail'] = "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
} else {
$data['support_error'] = 'Bagisto currently support MySQL only. Press OK to still continue or change you DB connection to MySQL';
}
$storage_output = exec('cd ../.. && php artisan storage:link 2>&1');
// if there are no errors process our form, then return a message
// show a message of success and provide a true success variable
$data['success'] = true;
$data['message'] = 'Success!';
}
// return all our data to an AJAX call
echo json_encode($data);

191
public/installer/CSS/style.css vendored Executable file
View File

@ -0,0 +1,191 @@
body {
margin: 0;
font-size: 16px;
font-family: "Montserrat", sans-serif;
color: #000311;
text-align: center;
background: white;
position: relative;
height: 100%;
}
.initial-display .logo {
width: 150px;
}
.initial-display p {
font-size: 24px;
color: #333333;
text-align: center;
font-weight: 600;
margin-top: 50px;
}
.prepare-btn {
box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.2), 0 0 8px 0 rgba(0, 0, 0, 0.1);
border-radius: 3px;
border: none;
cursor: pointer;
font: inherit;
display: inline-block;
background: #0041FF;
color: #ffffff;
padding: 10px 20px;
margin-top: 20px;
}
.footer {
bottom: 0;
position: absolute;
width: 100%;
padding-bottom: 20px;
}
.left-patern {
position: absolute;
left: 0;
bottom: 0;
}
.right-patern {
position: absolute;
right: 0;
bottom: 0;
}
.content {
border: 1px solid #979797;
border-radius: 3px;
width: 600px;
height: 392px;
margin-left: calc(50% - 300px);
text-align: left;
overflow-x: scroll;
}
.title {
font-size: 16px;
color: #151515;
line-height: 30px;
text-align: left;
margin-top: 30px;
margin-bottom: 10px;
}
span {
font-size: 16px;
color: #333333;
line-height: 30px;
}
.welcome, .environment, .migration, .permission, .admin, .finish {
display : none;
}
.control-group {
display: block;
margin-bottom: 25px;
font-size: 15px;
color: #333333;
width: 750px;
max-width: 100%;
position: relative;
}
.control-group label {
display: block;
color: #3a3a3a;
}
.control-group .control {
background: #fff;
border: 2px solid #C7C7C7;
border-radius: 3px;
width: 100%;
height: 36px;
display: inline-block;
vertical-align: middle;
-webkit-transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
padding: 0px 10px;
font-size: 15px;
margin-top: 10px;
margin-bottom: 5px;
}
.control-group label.required::after {
content: "*";
color: #FC6868;
font-weight: 700;
display: inline-block;
}
.form-error {
color: #ff5656 !important;
}
.control-group.has-error .control {
border-color: #FC6868 !important;
}
pre.bash {
background-color: black;
color: white;
font-size: medium ;
font-family: Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New, monospace;
width: 100%;
display: inline-block;
height: 100%;
}
.cp-round:before {
border-radius: 50%;
content: " ";
width: 48px;
height: 48px;
display: inline-block;
box-sizing: border-box;
border-top: solid 6px #bababa;
border-right: solid 6px #bababa;
border-bottom: solid 6px #bababa;
border-left: solid 6px #bababa;
position: absolute;
top: calc(50% - 24px);
left: calc(50% - 24px);
}
.check {
line-height: 40px;
}
.cp-round:after {
border-radius: 50%;
content: " ";
width: 48px;
height: 48px;
display: inline-block;
box-sizing: border-box;
border-top: solid 6px #0041FF;
border-right: solid 6px #bababa;
border-bottom: solid 6px #bababa;
border-left: solid 6px #bababa;
position: absolute;
top: calc(50% - 24px);
left: calc(50% - 24px);
animation: spin 1s ease-in-out infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.composer {
position: absolute;
top: calc(50% + 24px);
display: none;
}
.message {
padding-left: 140px;
}

View File

@ -0,0 +1,161 @@
<?php
class Requirement {
/**
* Check for the server requirements.
*
* @param array $requirements
* @return array
*/
public function checkRequirements()
{
// Server Requirements
$requirements = [
'php' => [
'openssl',
'pdo',
'mbstring',
'tokenizer',
'JSON',
'cURL',
],
// 'apache' => [
// 'mod_rewrite',
// ]
];
$results = [];
foreach($requirements as $type => $requirement)
{
switch ($type) {
// check php requirements
case 'php':
foreach($requirements[$type] as $requirement)
{
$results['requirements'][$type][$requirement] = true;
if(!extension_loaded($requirement))
{
$results['requirements'][$type][$requirement] = false;
$results['errors'] = true;
}
}
break;
// check apache requirements
// case 'apache':
// foreach ($requirements[$type] as $requirement) {
// // if function doesn't exist we can't check apache modules
// if(function_exists('apache_get_modules'))
// {
// $results['requirements'][$type][$requirement] = true;
// if(!in_array($requirement,apache_get_modules()))
// {
// $results['requirements'][$type][$requirement] = false;
// $results['errors'] = true;
// }
// }
// }
//break;
}
}
return $results;
}
/**
* Check PHP version requirement.
*
* @return array
*/
public function checkPHPversion()
{
/**
* Minimum PHP Version Supported (Override is in installer.php config file).
*
* @var _minPhpVersion
*/
$_minPhpVersion = '7.1.17';
$currentPhpVersion = $this->getPhpVersionInfo();
$supported = false;
if (version_compare($currentPhpVersion['version'], $_minPhpVersion) >= 0) {
$supported = true;
}
$phpStatus = [
'full' => $currentPhpVersion['full'],
'current' => $currentPhpVersion['version'],
'minimum' => $_minPhpVersion,
'supported' => $supported
];
return $phpStatus;
}
/**
* Get current Php version information
*
* @return array
*/
private static function getPhpVersionInfo()
{
$currentVersionFull = PHP_VERSION;
preg_match("#^\d+(\.\d+)*#", $currentVersionFull, $filtered);
$currentVersion = $filtered[0];
return [
'full' => $currentVersionFull,
'version' => $currentVersion
];
}
/**
* Check composer installation.
*
* @return array
*/
public function composerInstall()
{
$location = str_replace('\\', '/', getcwd());
$currentLocation = explode("/", $location);
array_pop($currentLocation);
array_pop($currentLocation);
$desiredLocation = implode("/", $currentLocation);
$autoLoadFile = $desiredLocation . '/' . 'vendor' . '/' . 'autoload.php';
if (file_exists($autoLoadFile)) {
$data['composer_install'] = 0;
} else {
$data['composer_install'] = 1;
$data['composer'] = 'Composer dependencies is not Installed.Go to root of project, run "composer install" command to install composer dependencies & refresh page again.';
}
return $data;
}
/**
* Render view for class.
*
*/
public function render()
{
$requirements = $this->checkRequirements();
$phpVersion = $this->checkPHPversion();
$composerInstall = $this->composerInstall();
ob_start();
include __DIR__ . '/../Views/requirements.blade.php';
return ob_get_clean();
}
}

View File

@ -0,0 +1,17 @@
<?php
class Welcome {
/**
* Render view for class.
*
*/
public function render()
{
ob_start();
include __DIR__ . '/../Views/welcome.blade.php';
return ob_get_clean();
}
}

7
public/installer/Composer.php Executable file
View File

@ -0,0 +1,7 @@
<?php
$data = array();
$data['install'] = 0;
echo json_encode($data);

140
public/installer/EnvConfig.php Executable file
View File

@ -0,0 +1,140 @@
<?php
// array to hold validation errors
$errors = array();
// array to pass back data
$data = array();
// validate the variables
// if any of these variables don't exist, add an error to our $errors array
if (empty($_POST['app_url']))
$errors['app_url'] = 'App Url is required.';
if (empty($_POST['app_name']))
$errors['app_name'] = 'App Name is required.';
if (empty($_POST['host_name']))
$errors['host_name'] = 'Host Name is required.';
if (empty($_POST['database_name']))
$errors['database_name'] = 'Database Name is required.';
if (empty($_POST['user_name']))
$errors['user_name'] = 'User Name is required.';
if (empty($_POST['port_name']))
$errors['port_name'] = 'Port Name is required.';
if (preg_match('/\s/', $_POST['app_url']))
$errors['app_url_space'] = 'There should be no space in App URL ';
if (preg_match('/\s/', $_POST['app_name']))
$errors['app_name_space'] = 'There should be no space in App Name.';
if (preg_match('/\s/', $_POST['host_name']))
$errors['host_name_space'] = 'There should be no space in Host Name.';
if (preg_match('/\s/', $_POST['database_name']))
$errors['database_name_space'] = 'There should be no space in Database Name.';
if (preg_match('/\s/', $_POST['user_name']))
$errors['user_name_space'] = 'There should be no space in User Name.';
if (preg_match('/\s/', $_POST['user_password']))
$errors['user_password_space'] = 'There should be no space in User Password.';
if (preg_match('/\s/', $_POST['port_name']))
$errors['port_name_space'] = 'There should be no space in Port Name.';
//return a response
// if there are any errors in our errors array, return a success boolean of false
if ( ! empty($errors)) {
// if there are items in our errors array, return those errors
$data['success'] = false;
$data['errors'] = $errors;
} else {
// if there are no errors process our form, then return a message
// getting env file location
$location = str_replace('\\', '/', getcwd());
$currentLocation = explode("/", $location);
array_pop($currentLocation);
array_pop($currentLocation);
$desiredLocation = implode("/", $currentLocation);
$envFile = $desiredLocation . '/' . '.env';
$envExampleFile = $desiredLocation . '/' . '.env.example';
if (!file_exists($envFile)) {
if (file_exists($envExampleFile)) {
copy($envExampleFile, $envFile);
} else {
touch($envFile);
}
}
// reading env content
$data = file($envFile);
$keyValueData = [];
if ($data) {
foreach ($data as $line) {
$line = preg_replace('/\s+/', '', $line);
$rowValues = explode('=', $line);
if (strlen($line) !== 0) {
$keyValueData[$rowValues[0]] = $rowValues[1];
}
}
}
// inserting form data to empty array
$keyValueData['DB_HOST'] = $_POST["host_name"];
$keyValueData['DB_DATABASE'] = $_POST["database_name"];
$keyValueData['DB_USERNAME'] = $_POST["user_name"];
$keyValueData['DB_PASSWORD'] = $_POST["user_password"];
$keyValueData['APP_NAME'] = $_POST["app_name"];
$keyValueData['APP_URL'] = $_POST["app_url"];
$keyValueData['DB_CONNECTION'] = $_POST["database_connection"];
$keyValueData['DB_PORT'] = $_POST["port_name"];
// making key/value pair with form-data for env
$changedData = [];
foreach ($keyValueData as $key => $value) {
$changedData[] = $key . '=' . $value;
}
// inserting new form-data to env
$changedData = implode(PHP_EOL, $changedData);
file_put_contents($envFile, $changedData);
// checking database connection(mysql only)
if ($_POST["database_connection"] == 'mysql') {
// Create connection
@$conn = new mysqli($_POST["host_name"], $_POST["user_name"], $_POST["user_password"], $_POST["database_name"]);
// check connection
if ($conn->connect_error) {
$errors['database_error'] = $conn->connect_error;
$data['errors'] = $errors;
$data['success'] = false;
} else {
$data['success'] = true;
$data['message'] = 'Success!';
}
} else {
$data['success'] = true;
$data['message'] = 'Success!';
}
// show a message of success and provide a true success variable
}
// return all our data to an AJAX call
echo json_encode($data);

202
public/installer/Environment.php Executable file
View File

@ -0,0 +1,202 @@
<html>
<body>
<div class="container environment" id="environment">
<div class="initial-display">
<p>Environment Configuration</p>
<form action="EnvConfig.php" method="POST" id="environment-form">
<div class="content">
<div class="databse-error" style="text-align: center; padding-top: 10px" id="database_error">
</div>
<div class="form-container" style="padding: 10%; padding-top: 35px">
<div class="control-group" id="app_name">
<label for="app_name" class="required">App Name</label>
<input type = "text" name = "app_name" class = "control"
value = "Bagisto_"
data-validation="required length" data-validation-length="max50"
>
</div>
<div class="control-group" id="app_url">
<label for="app_url" class="required">App URL</label>
<input type="text" name="app_url" class="control"
placeholder="http://localhost"
data-validation="required length" data-validation-length="max50">
</div>
<div class="control-group">
<label for="database_connection" class="required">
Database Connection
</label>
<select name="database_connection" id="database_connection" class="control">
<option value="mysql" selected>Mysql</option>
<option value="sqlite">SQlite</option>
<option value="pgsql">pgSQL</option>
<option value="sqlsrv">SQLSRV</option>
</select>
</div>
<div class="control-group" id="port_name">
<label for="port_name" class="required">Database Port</label>
<input type="text" name="port_name" class="control"
placeholder="3306"
data-validation="required alphanumeric number length" data-validation-length="max4">
</div>
<div class="control-group" id="host_name">
<label for="host_name" class="required">Database Host</label>
<input type="text" name="host_name" class="control"
placeholder="127.0.0.1"
data-validation="required length" data-validation-length="max50">
</div>
<div class="control-group" id="database_name">
<label for="database_name" class="required">Database Name</label>
<input type="text" name="database_name" class="control"
placeholder="database name"
data-validation="length required" data-validation-length="max50">
</div>
<div class="control-group" id="user_name">
<label for="user_name" class="required">User Name</label>
<input type="text" name="user_name" class="control"
value = "bagisto_"
data-validation="length required" data-validation-length="max50">
</div>
<div class="control-group" id="user_password">
<label for="user_password" class="required">User Password</label>
<input type="text" name="user_password" class="control"
placeholder="database password">
</div>
</div>
</div>
<div>
<button class="prepare-btn" id="environment-check">Save & Continue</button>
<div style="cursor: pointer; margin-top:10px">
<span id="envronment-back">back</span>
</div>
</div>
</form>
</div>
</div>
</body>
</html>
<script>
$.validate({});
</script>
<script>
$(document).ready(function() {
// process the form
$('#environment-form').submit(function(event) {
$('.control-group').removeClass('has-error'); // remove the error class
$('.form-error').remove(); // remove the error text
// get the form data
var formData = {
'app_name' : $('input[name=app_name]').val(),
'app_url' : $('input[name=app_url]').val(),
'host_name' : $('input[name=host_name]').val(),
'port_name' : $('input[name=port_name]').val(),
'database_name' : $('input[name=database_name]').val(),
'user_name' : $('input[name=user_name]').val(),
'user_password' : $('input[name=user_password]').val(),
'database_connection' : $("#database_connection" ).val(),
};
var target = window.location.href.concat('/EnvConfig.php');
// process the form
$.ajax({
type : 'POST',
url : target,
data : formData,
dataType : 'json',
encode : true
})
// using the done promise callback
.done(function(data) {
if (!data.success) {
// handle errors
if (data.errors.app_name) {
$('#app_name').addClass('has-error');
$('#app_name').append('<div class="form-error">' + data.errors.app_name + '</div>');
}
if (data.errors.app_url) {
$('#app_url').addClass('has-error');
$('#app_url').append('<div class="form-error">' + data.errors.app_url + '</div>');
}
if (data.errors.host_name) {
$('#host_name').addClass('has-error');
$('#host_name').append('<div class="form-error">' + data.errors.host_name + '</div>');
}
if (data.errors.port_name) {
$('#port_name').addClass('has-error');
$('#port_name').append('<div class="form-error">' + data.errors.port_name + '</div>');
}
if (data.errors.user_name) {
$('#user_name').addClass('has-error');
$('#user_name').append('<div class="form-error">' + data.errors.user_name + '</div>');
}
if (data.errors.database_name) {
$('#database_name').addClass('has-error');
$('#database_name').append('<div class="form-error">' + data.errors.database_name + '</div>');
}
if (data.errors.user_password) {
$('#user_password').addClass('has-error');
$('#user_password').append('<div class="form-error">' + data.errors.user_password + '</div>');
}
if (data.errors.app_url_space) {
$('#app_url').addClass('has-error');
$('#app_url').append('<div class="form-error">' + data.errors.app_url_space + '</div>');
}
if (data.errors.app_name_space) {
$('#app_name').addClass('has-error');
$('#app_name').append('<div class="form-error">' + data.errors.app_name_space + '</div>');
}
if (data.errors.host_name_space) {
$('#host_name').addClass('has-error');
$('#host_name').append('<div class="form-error">' + data.errors.host_name_space + '</div>');
}
if (data.errors.port_name_space) {
$('#port_name').addClass('has-error');
$('#port_name').append('<div class="form-error">' + data.errors.port_name_space + '</div>');
}
if (data.errors.user_name_space) {
$('#user_name').addClass('has-error');
$('#user_name').append('<div class="form-error">' + data.errors.user_name_space + '</div>');
}
if (data.errors.database_name_space) {
$('#database_name').addClass('has-error');
$('#database_name').append('<div class="form-error">' + data.errors.database_name_space + '</div>');
}
if (data.errors.user_password_space) {
$('#user_password').addClass('has-error');
$('#user_password').append('<div class="form-error">' + data.errors.user_password_space + '</div>');
}
if (data.errors.database_error) {
$('#database_error').append('<div class="form-error">' + data.errors.database_error + '</div>');
}
} else {
$('#environment').hide();
$('#migration').show();
}
});
// stop the form from submitting the normal way and refreshing the page
event.preventDefault();
});
});
</script>

34
public/installer/Finish.php Executable file
View File

@ -0,0 +1,34 @@
<html>
<body>
<div class="container finish" id="finish">
<div class="initial-display">
<p>Finish Installment</p>
<div class="content">
<div class="content-container" style="padding: 20px">
<span>
Bagisto is successfully installed on your system. Click the below button to launch Admin Panel.
</span>
</div>
</div>
<button class="prepare-btn" onclick="finish()">Finish</button>
</div>
</div>
</body>
</html>
<script>
function finish() {
lastIndex = window.location.href.lastIndexOf("/");
secondlast = window.location.href.slice(0, lastIndex).lastIndexOf("/");
next = window.location.href.slice(0, secondlast);
next = next.concat('/admin/login');
window.location.href = next;
}
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="17px" height="13px" viewBox="0 0 17 13" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 51.1 (57501) - http://www.bohemiancoding.com/sketch -->
<title>Check-Accent</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Desktop" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="requirment" transform="translate(-488.000000, -266.000000)">
<g id="Group-3" transform="translate(486.000000, 253.000000)">
<g id="Group-2" transform="translate(0.000000, 10.000000)">
<g id="Check-Accent">
<rect id="Rectangle-4" fill-rule="nonzero" x="0" y="0" width="20" height="20"></rect>
<polyline id="Path-2" stroke="#4CAF50" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" points="4 10 8 14 17 5"></polyline>
</g>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="216px" height="469px" viewBox="0 0 216 469" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 51.1 (57501) - http://www.bohemiancoding.com/sketch -->
<title>feature-bg-2 copy</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Desktop" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="setup" transform="translate(0.000000, -321.000000)">
<g id="installation" transform="translate(-312.000000, 321.000000)">
<g id="feature-bg-2-copy">
<path d="M410.51882,469 L351,350 L410.51882,350 L410.51882,469 Z M467.609149,350.309935 L527,350.309935 L467.609149,468.904085 L467.609149,350.309935 Z" id="Combined-Shape" fill="#0041FF"></path>
<path d="M483.511111,261.037313 L396.488889,261.037313 L417.511111,219 L462.488889,219 L483.511111,261.037313 Z M506,306.007463 L528,350 L352,350 L374,306.007463 L506,306.007463 Z" id="Combined-Shape" fill="#000DBB"></path>
<path d="M294.962601,235.592166 L352,350 L294.962601,350 L294.962601,235.592166 Z M235.326798,350 L176,350 L235.326798,231 L235.326798,350 Z" id="Combined-Shape" fill="#000DBB"></path>
<polygon id="Combined-Shape" fill="#000DBB" points="411 469 293 469 322.012679 411 381.987321 411"></polygon>
<path d="M352.037313,174 L310,174 L310,84.0674157 L352.037313,0 L352.037313,174 Z M397.007463,174 L397.007463,86.0224719 L441,174 L397.007463,174 Z" id="Combined-Shape" fill="#000DBB"></path>
<path d="M323.155556,292.311111 L380.844444,292.311111 L352,350 L323.155556,292.311111 Z M293.337654,232.675308 L264,174 L440,174 L410.662346,232.675308 L293.337654,232.675308 Z" id="Combined-Shape" fill="#0041FF"></path>
<path d="M220.488889,88.9626866 L307.511111,88.9626866 L286.488889,131 L241.511111,131 L220.488889,88.9626866 Z M198,43.9925373 L176,0 L352,0 L330,43.9925373 L198,43.9925373 Z" id="Combined-Shape" fill="#0041FF"></path>
<path d="M221.488889,438.962687 L308.511111,438.962687 L287.488889,481 L242.511111,481 L221.488889,438.962687 Z M199,393.992537 L177,350 L353,350 L331,393.992537 L199,393.992537 Z" id="Combined-Shape" fill="#0041FF"></path>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="13px" height="13px" viewBox="0 0 13 13" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 51.1 (57501) - http://www.bohemiancoding.com/sketch -->
<title>Check-Accent Copy</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Desktop" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="requirment" transform="translate(-492.000000, -507.000000)">
<g id="Group-3" transform="translate(486.000000, 253.000000)">
<g id="Group-2" transform="translate(0.000000, 10.000000)">
<g id="Check-Accent-Copy" transform="translate(2.000000, 241.000000)">
<rect id="Rectangle-4-Copy-2" fill-rule="nonzero" x="0" y="0" width="20" height="20"></rect>
<path d="M6,14 L15,5" id="Path-2" stroke="#F44336" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"></path>
<path d="M6,5 L15,14" id="Path-2" stroke="#F44336" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"></path>
</g>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="235px" height="348px" viewBox="0 0 235 348" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 51.1 (57501) - http://www.bohemiancoding.com/sketch -->
<title>feature-bg-2</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Desktop" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="setup" transform="translate(-1069.000000, -442.000000)">
<g id="installation" transform="translate(-312.000000, 321.000000)">
<g id="feature-bg-2" transform="translate(1381.000000, 121.000000)">
<polygon id="Combined-Shape" fill="#0041FF" points="131.511111 260 88 173 264 173 220.488889 260"></polygon>
<path d="M206.962601,59.592166 L264,174 L206.962601,174 L206.962601,59.592166 Z M147.326798,174 L88,174 L147.326798,55 L147.326798,174 Z" id="Combined-Shape" fill="#000DBB"></path>
<path d="M131.511111,260.037313 L44.4888889,260.037313 L65.5111111,218 L110.488889,218 L131.511111,260.037313 Z M154,305.007463 L176,349 L0,349 L22,305.007463 L154,305.007463 Z" id="Combined-Shape" fill="#000DBB"></path>
<path d="M294.962601,235.592166 L352,350 L294.962601,350 L294.962601,235.592166 Z M235.326798,350 L176,350 L235.326798,231 L235.326798,350 Z" id="Combined-Shape" fill="#000DBB"></path>
<path d="M220.488889,88.9626866 L307.511111,88.9626866 L286.488889,131 L241.511111,131 L220.488889,88.9626866 Z M198,43.9925373 L176,0 L352,0 L330,43.9925373 L198,43.9925373 Z" id="Combined-Shape" fill="#0041FF"></path>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

83
public/installer/JS/script Executable file
View File

@ -0,0 +1,83 @@
<script>
window.onload = function() {
var welcome = document.getElementById('welcome');
var requirement = document.getElementById('requirement');
var permission = document.getElementById('permission');
var environment = document.getElementById('environment');
var migration = document.getElementById('migration');
var admin = document.getElementById('admin');
var welcomeCheck = document.getElementById('welcome-check');
var requirementCheck = document.getElementById('requirement-check');
var permisssionCheck = document.getElementById('permission-check');
var environmentCheck = document.getElementById('environment-check');
var continue_to_admin = document.getElementById('continue');
var permissionBack = document.getElementById('permission-back');
var requirementBack = document.getElementById('requirement-back');
var envBack = document.getElementById('envronment-back');
var migrationBack = document.getElementById('migration-back');
if (requirementCheck) {
requirementCheck.addEventListener('click', myFunction);
}
if (welcomeCheck) {
welcomeCheck.addEventListener('click', myFunction);
}
if (permisssionCheck) {
permisssionCheck.addEventListener('click', myFunction);
}
if (environmentCheck) {
environmentCheck.addEventListener('click', myFunction);
}
if (continue_to_admin) {
continue_to_admin.addEventListener('click', myFunction);
}
if (envBack) {
envBack.addEventListener('click', myFunction);
}
if (requirementBack) {
requirementBack.addEventListener('click', myFunction);
}
if (permissionBack) {
permissionBack.addEventListener('click', myFunction);
}
if (migrationBack) {
migrationBack.addEventListener('click', myFunction);
}
function myFunction() {
if(this.id == 'welcome-check') {
requirement.style.display = "block";
welcome.style.display = "none";
} else if (this.id == 'requirement-check') {
environment.style.display = "block";
requirement.style.display = "none";
} else if (this.id == 'continue') {
migration.style.display = "none";
admin.style.display ="block";
} else if (this.id == 'requirement-back') {
welcome.style.display = "block";
requirement.style.display = "none";
} else if (this.id == 'envronment-back') {
environment.style.display ="none";
requirement.style.display = "block";
} else if (this.id == 'migration-back') {
migration.style.display = "none";
environment.style.display ="block";
}
}
};
</script>

227
public/installer/Migration.php Executable file
View File

@ -0,0 +1,227 @@
<html>
<style>
.window {
background: #222;
color: #fff;
overflow: hidden;
position: relative;
margin: 0 auto;
width: 100%;
&:before {
content: ' ';
display: block;
height: 48px;
background: #C6C6C6;
}
&:after {
content: '. . .';
position: absolute;
left: 12px;
right: 0;
top: -3px;
font-family: "Times New Roman", Times, serif;
font-size: 96px;
color: #fff;
line-height: 0;
letter-spacing: -12px;
}
}
.terminal {
margin: 20px;
font-family: monospace;
font-size: 16px;
color: #22da26;
.command {
width: 0%;
white-space: nowrap;
overflow: hidden;
animation: write-command 5s both;
&:before {
content: '$ ';
color: #22da26;
}
}
</style>
<body>
<div class="container migration" id="migration">
<div class="initial-display">
<p>Migration & Seed</p>
<div class="cp-spinner cp-round" id="loader">
</div>
<div class="content" id="migration-result">
<div class="window" id="migrate">
</div>
<div class="window" id="key">
</div>
<div class="window" id="seed">
</div>
<div class="window" id="publish">
</div>
<div class="window" id="composer">
</div>
<div class="instructions" style="padding-top: 40px;" id="instructions">
<div style="text-align: center;">
<span> Click the below button to run following : </span>
</div>
<div class="message">
<span>Database Migartion </span>
</div>
<div class="message">
<span> Database Seeder </span>
</div>
<div class="message">
<span> Publishing Vendor </span>
</div>
<div class="message">
<span> Generating Application Key </span>
</div>
</div>
<span class="composer" id="comp" style="left: calc(50% - 135px);">Checking Composer Dependency</span>
<span class="composer" id="composer-migrate" style="left: calc(50% - 85px);">Migrating Database</span>
<span class="composer" id="composer-seed" style="left: calc(50% - 55px);">Seeding Data</span>
</div>
<form method="POST" id="migration-form">
<div>
<button class="prepare-btn" id="migrate-seed">Migrate & Seed</button>
<button class="prepare-btn" id="continue">Continue</button>
</div>
<div style="cursor: pointer; margin-top:10px">
<span id="migration-back">back</span>
</div>
</form>
</div>
</div>
</body>
</html>
<script>
$(document).ready(function() {
$('#continue').hide();
$('#loader').hide();
// process the form
$('#migration-form').submit(function(event) {
// showing loader & hiding migrate button
$('#loader').show();
$('#comp').show();
$('#instructions').hide();
$('#migrate-seed').hide();
$('#migration-back').hide();
$('#migrate').hide();
$('#seed').hide();
$('#publish').hide();
$('#storage').hide();
$('#composer').hide();
var composerTarget = window.location.href.concat('/Composer.php');
// process form
$.ajax({
type : 'POST',
url : composerTarget,
dataType : 'json',
encode : true
})
.done(function(data) {
if (data) {
$('#comp').hide();
$('#seed').show();
$('#publish').show();
$('#storage').show();
$('#composer').show();
if (data['install'] == 0) {
$('#composer-migrate').show();
var migrationTarget = window.location.href.concat('/MigrationRun.php');
// post the request again
$.ajax({
type : 'POST',
url : migrationTarget,
dataType : 'json',
encode : true
})
// using the done promise callback
.done(function(data) {
if(data) {
$('#composer-migrate').hide();
if (data['results'] == 0) {
$('#composer-seed').show();
var seederTarget = window.location.href.concat('/Seeder.php');
$.ajax({
type : 'POST',
url : seederTarget,
dataType : 'json',
encode : true
})
// using the done promise callback
.done(function(data) {
$('#composer-seed').hide();
if (data['seeder']) {
$('#seed').append('<div class="terminal">' + data['seeder'] + '</div>');
}
if (data['publish']) {
$('#publish').append('<div class="terminal">' + data['publish'] + '</div>');
}
if (data['key']) {
$('#key').append('<div class="terminal">' + data['key'] + '</div>');
}
if ((data['key_results'] == 0) && (data['seeder_results'] == 0) && (data['publish_results'] == 0)) {
$('#continue').show();
$('#migrate-seed').hide();
$('#loader').hide();
};
});
} else {
$('#migrate').show();
$('#loader').hide();
$('#migrate-seed').hide();
$('#migration-back').hide();
if (data['migrate']) {
$('#migrate').append('<div class="terminal">' + data['migrate'] + '</div>');
}
}
}
});
} else {
$('#loader').hide();
$('#composer-migrate').hide();
$('#migrate-seed').hide();
$('#migration-back').hide();
$('#composer').append('<div class="terminal">' + data['composer'] +'</div>');
}
}
});
// stop the form from submitting the normal way and refreshing the page
event.preventDefault();
});
});
</script>

View File

@ -0,0 +1,14 @@
<?php
ini_set('max_execution_time', 300);
// array to pass back data
$data = array();
// run command on terminal
$command = 'cd ../.. && php artisan migrate --force';
$last_line = exec($command, $data['migrate'], $data['results']);
// return a response
//return all our data to an AJAX call
echo json_encode($data);

18
public/installer/Seeder.php Executable file
View File

@ -0,0 +1,18 @@
<?php
// array to pass back data
$data = array();
// run command on terminal
$key = 'cd ../.. && php artisan key:generate 2>&1';
$seeder = 'cd ../.. && php artisan db:seed 2>&1';
$publish = 'cd ../.. && php artisan vendor:publish --all --force 2>&1';
$key_output = exec($key, $data['key'], $data['key_results']);
$seeder_output = exec($seeder, $data['seeder'], $data['seeder_results']);
$publish = exec($publish, $data['publish'], $data['publish_results']);
// return a response
//return all our data to an AJAX call
echo json_encode($data);

View File

@ -0,0 +1,70 @@
<html>
<?php
$actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$greenCheck = $actual_link .'/'. 'Images/green-check.svg';
$redCheck = $actual_link .'/'. 'Images/red-check.svg';
?>
<body>
<div class="container requirement" id="requirement">
<div class="initial-display">
<p>Requirement</p>
<div class="content">
<div class="title" style="text-align: center; margin-top: 10px">
Please wait while we are checking the requirements
</div>
<div class="check" style="margin-left: 25%">
<?php if($phpVersion['supported'] ? $src = $greenCheck : $src = $redCheck): ?>
<img src="<?php echo $src ?>">
<?php endif; ?>
<span style="margin-left: 10px"><b>PHP</b></span>
<span>(<?php echo $phpVersion['minimum'] ?> or Higher)</span>
</div>
<?php foreach($requirements['requirements'] as $type => $require): ?>
<?php foreach($requirements['requirements'][$type] as $extention => $enabled) : ?>
<div class="check" style="margin-left: 25%">
<?php if($enabled ? $src = $greenCheck : $src = $redCheck ): ?>
<img src="<?php echo $src ?>">
<?php endif; ?>
<span style="margin-left: 10px"><b><?php echo $extention ?></b></span>
<span>(<?php echo $extention ?> Required)</span>
</div>
<?php endforeach; ?>
<?php endforeach; ?>
<php class="check" style="margin-left: 25%">
<?php if(($composerInstall['composer_install'] == 0) ? $src = $greenCheck : $src = $redCheck ): ?>
<img src="<?php echo $src ?>">
<span style="margin-left: 10px"><b>Composer</b></span>
<?php endif; ?>
</php>
<div style="margin-left: 30%;">
<?php if(!($composerInstall['composer_install'] == 0)): ?>
<span style="margin-left: 10px; color: red;"><?php echo $composerInstall['composer'] ?></span>
<?php endif; ?>
</div>
</div>
<?php if(!isset($requirements['errors']) && ($phpVersion['supported'] && $composerInstall['composer_install'] == 0)): ?>
<div>
<button type="button" class="prepare-btn" id="requirement-check">Continue</button>
</div>
<?php endif; ?>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,44 @@
<html>
<body>
<div class="container welcome" id="welcome">
<div class="initial-display">
<p>Welcome to Bagisto</p>
<div class="content">
<div class="content-container" style="padding: 20px">
<span>
Have you ever heard of an old saying, “No man is an island”? We probably heard that a million times. That saying is actually true because when we became successful, we usually achieve that because someone has helped us. And our thank-you speech skills could be the best thing we can do in return. You may also see
</span>
<div class="title">
INTRODUCTION
</div>
<span>
Have you ever heard of an old saying, “No man is an island”? We probably heard that a million times. That saying is actually true because when we became successful, we usually achieve that because someone has helped us. And our thank-you speech skills could be the best thing we can do in return. You may also see
</span>
</div>
</div>
<div>
<button type="button" class="prepare-btn" id="welcome-check">Accept</button>
</div>
</div>
</div>
</body>
</html>

139
public/installer/index.php Executable file
View File

@ -0,0 +1,139 @@
<html>
<?php
$actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$cssUrl = $actual_link .'/'. 'CSS/style.css';
$logo = $actual_link .'/'. 'Images/logo.svg';
$leftIcon = $actual_link .'/'. 'Images/left-side.svg';
$rightIcon = $actual_link .'/'. 'Images/right-side.svg';
?>
<head>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Montserrat:400,500">
<title>Bagisto Installer</title>
<link rel="icon" sizes="16x16" href="Images/favicon.ico">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-form-validator/2.3.26/jquery.form-validator.min.js"></script>
<link rel="stylesheet" type="text/css" href= "<?php echo $cssUrl; ?> ">
</head>
<body>
<div class="container requirement">
<div class="initial-display" style="padding-top: 100px;">
<img class="logo" src= "<?php echo $logo; ?>" >
</div>
<div class="footer">
<img class="left-patern" src= "<?php echo $leftIcon; ?>" >
<img class="right-patern" src= "<?php echo $rightIcon; ?>" >
</div>
</div>
<?php
// getting env file
$location = str_replace('\\', '/', getcwd());
$currentLocation = explode("/", $location);
array_pop($currentLocation);
array_pop($currentLocation);
$desiredLocation = implode("/", $currentLocation);
$envFile = $desiredLocation . '/' . '.env';
$installed = false;
if (file_exists($envFile)) {
// reading env content
$data = file($envFile);
$databaseArray = ['DB_HOST', 'DB_DATABASE', 'DB_USERNAME', 'DB_PASSWORD', 'DB_CONNECTION','DB_PORT'];
$key = $value = [];
if ($data) {
foreach ($data as $line) {
$line = preg_replace('/\s+/', '', $line);
$rowValues = explode('=', $line);
if (strlen($line) !== 0) {
if (in_array($rowValues[0], $databaseArray)) {
$key[] = $rowValues[0];
$value[] = $rowValues[1];
}
}
}
}
$databaseData = array_combine($key, $value);
if (isset($databaseData['DB_HOST'])) {
$servername = $databaseData['DB_HOST'];
}
if (isset($databaseData['DB_USERNAME'])) {
$username = $databaseData['DB_USERNAME'];
}
if (isset($databaseData['DB_PASSWORD'])) {
$password = $databaseData['DB_PASSWORD'];
}
if (isset($databaseData['DB_DATABASE'])) {
$dbname = $databaseData['DB_DATABASE'];
}
if (isset($databaseData['DB_CONNECTION'])) {
$connection = $databaseData['DB_CONNECTION'];
}
if (isset($databaseData['DB_PORT'])) {
$port = $databaseData['DB_PORT'];
}
if (isset($connection) && $connection == 'mysql') {
@$conn = new mysqli($servername, $username, $password, $dbname, (int)$port);
if (!$conn->connect_error) {
// retrieving admin entry
$sql = "SELECT id, name FROM admins";
$result = $conn->query($sql);
if ($result) {
$installed = true;
}
}
$conn->close();
} else {
$installed = true;
}
}
if (!$installed) {
// including classes
include __DIR__ . '/Classes/Requirement.php';
// including php files
include __DIR__ . '/Environment.php';
include __DIR__ . '/Migration.php';
include __DIR__ . '/Admin.php';
include __DIR__ . '/Finish.php';
// including js
include __DIR__ . '/JS/script';
// object creation
$requirement = new Requirement();
echo $requirement->render();
} else {
// getting url
$actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$url = explode("/", $actual_link);
array_pop($url);
array_pop($url);
$url = implode("/", $url);
$url = $url . '/404';
// redirecting to 404 error page
header("Location: $url");
}
?>
</body>
</html>

88
public/installer/install.php Executable file
View File

@ -0,0 +1,88 @@
<?php
// getting env file
$location = str_replace('\\', '/', getcwd());
$currentLocation = explode("/", $location);
array_pop($currentLocation);
$desiredLocation = implode("/", $currentLocation);
$envFile = $desiredLocation . '/' . '.env';
$installed = false;
if (file_exists($envFile)) {
// reading env content
$data = file($envFile);
$databaseArray = ['DB_HOST', 'DB_DATABASE', 'DB_USERNAME', 'DB_PASSWORD', 'DB_CONNECTION','DB_PORT'];
$key = $value = [];
if ($data) {
foreach ($data as $line) {
$line = preg_replace('/\s+/', '', $line);
$rowValues = explode('=', $line);
if (strlen($line) !== 0) {
if (in_array($rowValues[0], $databaseArray)) {
$key[] = $rowValues[0];
$value[] = $rowValues[1];
}
}
}
}
$databaseData = array_combine($key, $value);
if (isset($databaseData['DB_HOST'])) {
$servername = $databaseData['DB_HOST'];
}
if (isset($databaseData['DB_USERNAME'])) {
$username = $databaseData['DB_USERNAME'];
}
if (isset($databaseData['DB_PASSWORD'])) {
$password = $databaseData['DB_PASSWORD'];
}
if (isset($databaseData['DB_DATABASE'])) {
$dbname = $databaseData['DB_DATABASE'];
}
if (isset($databaseData['DB_CONNECTION'])) {
$connection = $databaseData['DB_CONNECTION'];
}
if (isset($databaseData['DB_PORT'])) {
$port = $databaseData['DB_PORT'];
}
if (isset($connection) && $connection == 'mysql') {
@$conn = new mysqli($servername, $username, $password, $dbname, (int)$port);
if (!$conn->connect_error) {
// retrieving admin entry
$sql = "SELECT id, name FROM admins";
$result = $conn->query($sql);
if ($result) {
$installed = true;
}
}
$conn->close();
} else {
$installed = true;
}
}
if (!$installed) {
// getting url
$actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$url = explode("/", $actual_link);
array_pop($url);
$url = implode("/", $url);
$url = $url . '/installer';
return $url;
} else {
return null;
}
?>