Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- echo "<h3> PHP List All Session Variables</h3>";
- foreach ($_SESSION as $key=>$val)
- echo $key." => ".$val."<br/>";
- session_start();
- $message = '';
- if(isset($_POST['connect'])) {
- $adress = 'localhost';
- $mysql = $_POST['mysql'];
- $dbuser = $_POST['dbuser'];
- $dbpass = $_POST['dbpass'];
- $dbtest= new PDO("mysql:host=$adress;dbname=$mysql", $dbuser, $dbpass);
- $dbtest->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $_SESSION['install'] = '1';
- if ($dbtest) {
- echo '
- <script>
- $(document).ready(function(){
- $("#step1").toggle(function(){
- $("#step1").hide();
- });
- $("#step2").toggle(function(){
- $("#step2").show();
- });
- });
- </script>
- ';
- } else {
- $message = 'Connection Failed. Please try agian';
- }
- }
- if (isset($_POST['settings'])) {
- $_SESSION['settingsname'] = $_POST['name'];
- $_SESSION['settingsicon'] = $_POST['icon'];
- $_SESSION['settingsmetadesc'] = $_POST['metadesc'];
- $_SESSION['settingsmetakey'] = $_POST['metakey'];
- $_SESSION['settingsfacebook'] = $_POST['facebook'];
- $_SESSION['settingstwitter'] = $_POST['twitter'];
- $_SESSION['settingsinstagram'] = $_POST['instagram'];
- $_SESSION['settingsgoogle'] = $_POST['google'];
- $_SESSION['install'] = '2';
- echo "<h3> PHP List All Session Variables</h3>";
- foreach ($_SESSION as $key=>$val)
- echo $key." => ".$val."<br/>";
- echo '
- <script>
- $(document).ready(function(){
- $("#step2").toggle(function(){
- $("#step1").hide();
- $("#step2").hide();
- });
- $("#step3").toggle(function(){
- $("#step3").show();
- });
- </script>
- ';
- }
- if(isset($_POST['users'])) {
- $userusername = $_POST['username'];
- $userpassword = $_POST['password'];
- $useremail = $_POST['email'];
- $userrank = $_POST['rank'];
- $userdate = date("d/m/Y");
- $_SESSION['userusername'] = $userusername;
- $_SESSION['userpassword'] = $userpassword;
- $_SESSION['useremail'] = $useremail;
- $_SESSION['userrank'] = $userrank;
- $_SESSION['userdate'] = $userdate;
- $_SESSION['install'] = '3';
- echo '
- <script>
- $(document).ready(function(){
- $("#step3").toggle(function(){
- $("#step1").hide();
- $("#step2").hide();
- $("#step3").hide();
- });
- $("#step4").toggle(function(){
- $("#step4").show();
- });
- });
- </script>
- ';
- }
- if (isset($_GET['install'])) {
- $complete = $_GET['install'];
- if ($complete == 'complete') {
- $filename = (getenv("DOCUMENT_ROOT")."/inc/db.php");
- $data = '
- <?php
- $servername = "localhost";
- $username = "test";
- $password = "";
- $dbname = "clientcp";
- $db = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
- $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- ?>
- ';
- if(!is_file($filename)) {
- $fp = fopen($filename,"x");
- fwrite($fp,$data);
- fclose($fp);
- } else {
- $fp = fopen($filename,"w");
- fwrite($fp,$data);
- fclose($fp);
- }
- }
- if (file_exists($filename)) {
- require_once(getenv("DOCUMENT_ROOT")."/inc/db.php");
- try { // CREATE ALL TABLES
- $stmt1 = $db->prepare("
- CREATE TABLE settings (
- id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
- tag VARCHAR(128) NOT NULL,
- name VARCHAR(30) NOT NULL,
- favicon BLOB NOT NULL,
- metadesc VARCHAR(160) NOT NULL,
- metakey VARCHAR(256) NOT NULL,
- facebook VARCHAR(256) NOT NULL,
- twitter VARCHAR(256) NOT NULL,
- instagram VARCHAR(256) NOT NULL,
- google VARCHAR(256) NOT NULL
- )
- ");
- $stmt1->execute();
- $stmt2 = $db->prepare("
- CREATE TABLE contenttags (
- id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
- name VARCHAR(256) NOT NULL,
- tag VARCHAR(256) NOT NULL
- )
- ");
- $stmt2->execute();
- $stmt3 = $db->prepare("
- CREATE TABLE content (
- id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
- tag VARCHAR(128) NOT NULL,
- title VARCHAR(30) NOT NULL,
- image BLOB NOT NULL,
- tag VARCHAR(256) NOT NULL,
- page VARCHAR(256) NOT NULL
- )
- ");
- $stmt3->execute();
- $stmt4 = $db->prepare("
- CREATE TABLE users (
- id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
- name VARCHAR(30) NOT NULL,
- password VARCHAR(256) NOT NULL,
- email VARCHAR(256) NOT NULL,
- rank VARCHAR(256) NOT NULL,
- date VARCHAR(256) NOT NULL
- )
- ");
- $stmt4->execute();
- }
- catch(PDOException $e) {
- $message = "Something went wrong when creating tables: " . $e->getMessage();
- }
- try { // PUT CONTENT INTO TABLES
- $stmt1 = $db->prepare("
- INSERT into settings
- (tag, name, favicon, metadesc, metakey, facebook, twitter, instagram, google)
- VALUES
- (:tag, :name, :icon, :metadesc, :metakey, facebook, :twitter, :instagram, :google);
- ");
- $stmt1->execute(array(
- ':name' => $_SESSION['settingsname'],
- ':tag' => $_SESSION['settingstag'],
- ':icon' => $_SESSION['settingsicon'],
- ':metadesc' => $_SESSION['settingsmetadesc'],
- ':metakey' => $_SESSION['settingsmetakey'],
- ':facebook' => $_SESSION['settingsfacebook'],
- ':twitter' => $_SESSION['settingstwitter'],
- ':instagram' => $_SESSION['settingsinstagram'],
- ':google' => $_SESSION['settingsgoogle']
- ));
- $stmt2 = $db->prepare("
- INSERT INTO contenttags
- (name, tag)
- VALUES
- ('carousel', 'image'),
- ('image', 'image'),
- ('video', 'link'),
- ('header', 'text'),
- ('title', 'text'),
- ('post', 'text'),
- ('date', 'text'),
- ('link', 'text'),
- ('page', 'text')
- ");
- $stmt2->execute();
- $contenttitle = 'First post';
- $contenttext = 'This is an example of your first post';
- $contenttag = 'text';
- $contentpage = 'home';
- $contentimage = '';
- $contentdate = date(d/n/Y);
- $stmt3 = $db->prepare("
- INSERT INTO content
- (title, text, image, tag, page, date)
- VALUES
- (:title, :text, :image, :tag, :page, :date)
- ");
- $stmt3->execute(array(
- ':name' => $contenttitle,
- ':text' => $contenttext,
- ':image' => $contentimage,
- ':tag' => $contenttag,
- ':page' => $contentpage,
- ':date' => $contentdate
- ));
- $stmt4 = $db->prepare("
- INSERT into users
- (name, password, email, rank, date)
- VALUES
- (:name, :password, :email, :rank, :date)
- ");
- $stmt4->execute(array(
- ':name' => $_SESSION['userusername'],
- ':password' => $_SESSION['userpassword'],
- ':email' => $_SESSION['useremail'],
- ':rank' => $_SESSION['userrank'],
- ':date' => $_SESSION['userdate']
- ));
- }
- catch(PDOException $e) {
- $message = "Something went wrong while populating tables: " . $e->getMessage();
- }
- } else {
- $message = "Something went wrong when creating database file. ";
- }
- $_SESSION['install'] = '5';
- header('Location: /');
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>Client Panel</title>
- <meta charset="utf-8">
- <meta name="description" content="">
- <meta name="keywords" content="">
- <meta name="author" content="">
- <meta content="width=device-width, initial-scale=1" name="viewport"/>
- <link rel="shortcut icon" href="template/images/favicon.ico" type="image/x-icon"/>
- <link rel="stylesheet" href="/template/css/style.css">
- <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
- <script type='text/javascript' src='template/js/installation.js'></script>
- <script type='text/javascript' src='template/js/jquery-3.3.1.js'></script>
- </head>
- <body>
- <div class="installcms">
- <div id="step1" style="display:block;">
- <div class="installheader">
- <img src="template/images/logo.png">
- <h4>Please follow the next steps to install your website.</h4>
- </div>
- <div class="installbody">
- <h3>Connect to Database:</h3>
- <form name="connect" action="" method="post">
- <label for="mysql">MySQL Database:</label>
- <input type="text" name="mysql" required>
- <label for="dbuser">MySQL Username:</label>
- <input type="text" name="dbuser" required>
- <label for="dbpass">MySQL Password:</label>
- <input type="password" name="dbpass">
- <button type="submit" name="connect" class="button">Next Step</button>
- </form>
- </div>
- <?php if (!$message == '') {
- echo '
- <div class="under">
- <h4>'.$message.'</h4>
- </div>
- ';
- }
- ?>
- </div>
- <div id="step2" style="display:none;">
- <div class="installheader">
- <img src="template/images/logo.png">
- <h2>Website Settings and Social Media:</h2>
- </div>
- <div class="installbody">
- <h3></h3>
- <form name="settings" action="" method="post">
- <label for="name">Website Name: </label>
- <input type="text" name="name" placeholder="Website Name">
- <label for="icon">Favicon:</label>
- <input type="file" name="icon" id="icon">
- <label for="metadesc">Meta Description: <i class="far fa-question-circle" title="A description of your site in a clear sense. Maximum of 160 Charachters."></i></label>
- <input type="text" name="metadesc" placeholder="Meta Description">
- <label for="metakey">Meta Keywords: <i class="far fa-question-circle" title="A summary of the most important keywords or keywords that you use on a page. Maximum of 10 keyword phrases."></i></label>
- <input type="text" name="metakey" placeholder="Meta Keywords">
- <label for="facebook">Facebook:</label>
- <input type="text" name="facebook" placeholder="Facebook">
- <label for="twitter">Twitter:</label>
- <input type="text" name="twitter" placeholder="Twitter">
- <label for="instagram">Instagram:</label>
- <input type="text" name="instagram" placeholder="Instagram">
- <label for="google">Google+:</label>
- <input type="text" name="google" placeholder="Google+">
- <button type="submit" name="settings" class="button">Next Step</button>
- </form>
- </div>
- <?php if (!$message == '') {
- echo '
- <div class="under">
- <h4>'.$message.'</h4>
- </div>
- ';
- }
- ?>
- </div>
- <div id="step3" style="display:none;">
- <div class="installheader">
- <img src="template/images/logo.png">
- <h2>Add a user to your CMS:</h2>
- </div>
- <div class="installbody">
- <h3></h3>
- <p>*This is not required</p>
- <form name="users" action="" method="post">
- <label for="username">Username:</label>
- <input type="text" name="username">
- <label for="password">Password:</label>
- <input type="password" name="password">
- <label for="email">Email:</label>
- <input type="text" name="email">
- <div id="rank">
- <label for="rank">Rank: <i class="far fa-question-circle" title="
- Editor: Can manage content such as media files and heading texts.
- Admin: Grants full access to the CMS and can edit everything. Be cautious when giving this rank."></i></label>
- <select name="rank">
- <option value="editor">Editor</option>
- <option value="admin">Admin</option>
- </select>
- </div>
- <button type="submit" name="users" class="button">Last Step</button>
- </form>
- </div>
- <?php if (!$message == '') {
- echo '
- <div class="under">
- <h4>'.$message.'</h4>
- </div>
- ';
- }
- ?>
- </div>
- <div id="step4" style="display:none;">
- <div class="installheader">
- <img src="template/images/logo.png">
- <h2>Congratulations!</h2>
- <h3>You made it!</h3>
- </div>
- <div class="installbody">
- <h4>Your website CMS is not ready to de used!<br>
- You can now login and start creating content!</h4>
- <button href="?file=install&install=complete" type="submit" name="users" class="button">Complete Installation</button>
- </div>
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement