Advertisement
Guest User

Untitled

a guest
Aug 13th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.55 KB | None | 0 0
  1. <?php
  2.  
  3. class   mysqlFN{
  4.    
  5. /*CREATE USER 'test1'@'localhost' IDENTIFIED BY  '***';
  6. GRANT USAGE ON * . * TO  'test1'@'localhost' IDENTIFIED BY  '***' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
  7. CREATE DATABASE IF NOT EXISTS  `test1` ;
  8. GRANT ALL PRIVILEGES ON  `test1` . * TO  'test1'@'localhost';*/
  9.    
  10.     public $result;
  11.     private $user = null;
  12.     private $pass = null;
  13.     private $database = null;
  14.    
  15.     public function __construct(){
  16.        
  17.         $this->user = mysql_real_escape_string($_POST['usermysql']);
  18.         $this->pass = mysql_real_escape_string($_POST['passmysql']);
  19.         $this->database = mysql_real_escape_string($_POST['database']);
  20.        
  21.     }
  22.    
  23.     public function createUser(){
  24.        
  25.         /* CREERT GEBRUIKER */
  26.        
  27.         $sql    =   "CREATE USER '" . $this->user . "'@'localhost' IDENTIFIED BY 'PASSWORD(" . $this->pass . ")'";
  28.         $result = mysql_query($sql) or ($this->result   =   mysql_error());
  29.        
  30.     }
  31.     public function createdb(){
  32.        
  33.         /* CREERT DB MET DE RECHTEN DAAROP */
  34.        
  35.         $sql    =   "   GRANT USAGE ON * . * TO  '" . $this->user . "'@'localhost' IDENTIFIED BY  'PASSWORD(" . $this->pass . ")' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
  36.                         CREATE DATABASE IF NOT EXISTS '".$this->database."';
  37.                         GRANT ALL PRIVILEGES ON  '" . $this->database . "' . * TO  '" . $this->user . "'@'localhost';';
  38.                         ";
  39.         $result = mysql_query($sql) or ($this->result   =   mysql_error());
  40.    
  41.     }
  42.     public function result(){
  43.         print_r( $this->result );
  44.         print_r($this->sql);
  45.     }
  46.    
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement