Advertisement
Guest User

Untitled

a guest
May 3rd, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.37 KB | None | 0 0
  1. <?php
  2.  
  3.     if (!file_exists('config.php')) {
  4.         die("<p>The file 'config.php' not exists.</p></body></html>"); }
  5.  
  6.     include("config.php");
  7.     include('sources/Auth.php');
  8.     include('sources/core.php');
  9.     $db = new MySQL();
  10.     $db->connect($host,$username,$password,$database);
  11.     $hey = new Auth();
  12.  
  13.     $db->query("
  14.        CREATE TABLE `users` (
  15.            `id` INT (11) NOT NULL AUTO_INCREMENT,
  16.            `username` TEXT NOT NULL,
  17.            `password` TEXT NOT NULL,
  18.            `level` TEXT NOT NULL,
  19.            `email` TEXT NOT NULL,
  20.                 PRIMARY KEY (`id`)
  21.        );
  22.    ");
  23.  
  24.     $db->query("
  25.        CREATE TABLE `pages` (
  26.            `name` TEXT NOT NULL,
  27.            `content` TEXT NOT NULL,
  28.            `id` INT (11) NOT NULL AUTO_INCREMENT,
  29.                 PRIMARY KEY (`id`)
  30.        );
  31.    ");
  32.  
  33.     $db->query("
  34.        CREATE TABLE `articles` (
  35.            `name` TEXT NOT NULL,
  36.            `author` TEXT NOT NULL,
  37.            `content` TEXT NOT NULL,
  38.            `date` TEXT NOT NULL,
  39.            `hour` TEXT NOT NULL,
  40.            `id` INT (11) NOT NULL AUTO_INCREMENT,
  41.                 PRIMARY KEY (`id`)
  42.        );
  43.    ");
  44.  
  45.     $mode = $GET['mode'];
  46.     switch($mode)
  47.     {
  48.         case "register":
  49.  
  50.         print "<form action = 'install.php?mode=register' method = 'POST'>";
  51.         print "username: <input type = 'text' name = 'username'><br>";
  52.         print "password: <input type = 'password' name = 'password'><br>";
  53.         print "retype password: <input type = 'password' name = 'repeat'><br>";
  54.         print "<p>email admin: <input type = 'text' name = 'email'></p>";
  55.         print "<input type = 'submit' value = 'register'>";
  56.         print "</form>";
  57.  
  58.  
  59.         if(!empty($_POST['username']) && !empty($_POST['password']) && !empty($_POST['repeat']) && eregi("^[_a-z0-9+-]+(\.[_a-z0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$",$_POST['email']) )
  60.         {
  61.             $username = htmlentities($_POST['username']);
  62.             $password = htmlentities($_POST['password']);
  63.             $repeat   = htmlentities($_POST['repeat']);
  64.             $email    = $_POST['email'];
  65.             $level    = 'admin';
  66.  
  67.             if($password == $repeat)
  68.             {
  69.                 $hey->register($username,$password,$email,$level);
  70.             }
  71.  
  72.             else
  73.             {
  74.                 print "Passwords do not match";
  75.             }
  76.         }
  77.  
  78.         $db->close();
  79.         break;
  80.     }
  81. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement