diff --git a/public/installer/Admin.php b/public/installer/Admin.php new file mode 100755 index 000000000..f48b48de3 --- /dev/null +++ b/public/installer/Admin.php @@ -0,0 +1,130 @@ + + + + +
+
+

Admin Details

+ +
+
+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+
+
+ +
+
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/public/installer/AdminConfig.php b/public/installer/AdminConfig.php new file mode 100755 index 000000000..cfb17829b --- /dev/null +++ b/public/installer/AdminConfig.php @@ -0,0 +1,112 @@ +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 . "
" . $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); \ No newline at end of file diff --git a/public/installer/CSS/style.css b/public/installer/CSS/style.css new file mode 100755 index 000000000..db093a41a --- /dev/null +++ b/public/installer/CSS/style.css @@ -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; +} diff --git a/public/installer/Classes/Requirement.php b/public/installer/Classes/Requirement.php new file mode 100755 index 000000000..e6ecf5160 --- /dev/null +++ b/public/installer/Classes/Requirement.php @@ -0,0 +1,161 @@ + [ + '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(); + } +} diff --git a/public/installer/Classes/Welcome.php b/public/installer/Classes/Welcome.php new file mode 100755 index 000000000..a18c507fa --- /dev/null +++ b/public/installer/Classes/Welcome.php @@ -0,0 +1,17 @@ + $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); \ No newline at end of file diff --git a/public/installer/Environment.php b/public/installer/Environment.php new file mode 100755 index 000000000..74b9cbf60 --- /dev/null +++ b/public/installer/Environment.php @@ -0,0 +1,202 @@ + + + + +
+
+

Environment Configuration

+ +
+
+
+
+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+
+
+ +
+ back +
+
+
+ +
+
+ + + + + + + + + diff --git a/public/installer/Finish.php b/public/installer/Finish.php new file mode 100755 index 000000000..7ccf136ed --- /dev/null +++ b/public/installer/Finish.php @@ -0,0 +1,34 @@ + + + + +
+
+

Finish Installment

+
+
+ + Bagisto is successfully installed on your system. Click the below button to launch Admin Panel. + +
+
+ + + +
+
+ + + + + + \ No newline at end of file diff --git a/public/installer/Images/favicon.ico b/public/installer/Images/favicon.ico new file mode 100755 index 000000000..e9c217bb3 Binary files /dev/null and b/public/installer/Images/favicon.ico differ diff --git a/public/installer/Images/green-check.svg b/public/installer/Images/green-check.svg new file mode 100755 index 000000000..25fbb6ab7 --- /dev/null +++ b/public/installer/Images/green-check.svg @@ -0,0 +1,19 @@ + + + + Check-Accent + Created with Sketch. + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/installer/Images/left-side.svg b/public/installer/Images/left-side.svg new file mode 100755 index 000000000..891572fc3 --- /dev/null +++ b/public/installer/Images/left-side.svg @@ -0,0 +1,23 @@ + + + + feature-bg-2 copy + Created with Sketch. + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/installer/Images/logo.svg b/public/installer/Images/logo.svg new file mode 100755 index 000000000..412899b60 --- /dev/null +++ b/public/installer/Images/logo.svg @@ -0,0 +1,19 @@ + + + + Logo+Text + Created with Sketch. + + + + + + + + + + \ No newline at end of file diff --git a/public/installer/Images/red-check.svg b/public/installer/Images/red-check.svg new file mode 100755 index 000000000..6911d37d2 --- /dev/null +++ b/public/installer/Images/red-check.svg @@ -0,0 +1,20 @@ + + + + Check-Accent Copy + Created with Sketch. + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/installer/Images/right-side.svg b/public/installer/Images/right-side.svg new file mode 100755 index 000000000..a45fd2f75 --- /dev/null +++ b/public/installer/Images/right-side.svg @@ -0,0 +1,20 @@ + + + + feature-bg-2 + Created with Sketch. + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/installer/JS/script b/public/installer/JS/script new file mode 100755 index 000000000..b2662e77d --- /dev/null +++ b/public/installer/JS/script @@ -0,0 +1,83 @@ + \ No newline at end of file diff --git a/public/installer/Migration.php b/public/installer/Migration.php new file mode 100755 index 000000000..b2620d893 --- /dev/null +++ b/public/installer/Migration.php @@ -0,0 +1,227 @@ + + + + + + +
+
+

Migration & Seed

+ +
+
+ +
+
+
+
+
+
+
+
+
+
+
+ +
+
+ Click the below button to run following : +
+
+ Database Migartion +
+
+ Database Seeder +
+
+ Publishing Vendor +
+
+ Generating Application Key +
+
+ + Checking Composer Dependency + Migrating Database + Seeding Data +
+ +
+
+ + +
+
+ back +
+
+ +
+
+ + + + + + \ No newline at end of file diff --git a/public/installer/MigrationRun.php b/public/installer/MigrationRun.php new file mode 100755 index 000000000..fcb9bb1c1 --- /dev/null +++ b/public/installer/MigrationRun.php @@ -0,0 +1,14 @@ +&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); \ No newline at end of file diff --git a/public/installer/Views/requirements.blade.php b/public/installer/Views/requirements.blade.php new file mode 100755 index 000000000..a746ac2a4 --- /dev/null +++ b/public/installer/Views/requirements.blade.php @@ -0,0 +1,70 @@ + + + + + + +
+
+

Requirement

+ +
+
+ Please wait while we are checking the requirements +
+ +
+ + + + PHP + ( or Higher) +
+ + $require): ?> + + $enabled) : ?> +
+ + + + + ( Required) +
+ + + + + + + + Composer + + + +
+ + + +
+ +
+ + +
+ +
+ + + +
+
+ + + + diff --git a/public/installer/Views/welcome.blade.php b/public/installer/Views/welcome.blade.php new file mode 100755 index 000000000..4230adedd --- /dev/null +++ b/public/installer/Views/welcome.blade.php @@ -0,0 +1,44 @@ + + + + +
+
+

Welcome to Bagisto

+ +
+
+ + 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 + + +
+ INTRODUCTION +
+ + + 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 + +
+
+ +
+ +
+
+
+ + + + + + + + + + + + + + + diff --git a/public/installer/index.php b/public/installer/index.php new file mode 100755 index 000000000..46853c3f3 --- /dev/null +++ b/public/installer/index.php @@ -0,0 +1,139 @@ + + + + + + + Bagisto Installer + + + + + + + + +
+
+ +
+ + +
+ + 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"); + } + ?> + + + diff --git a/public/installer/install.php b/public/installer/install.php new file mode 100755 index 000000000..4378aacef --- /dev/null +++ b/public/installer/install.php @@ -0,0 +1,88 @@ +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; + } +?> + + +