Guest User

Untitled

a guest
Nov 4th, 2017
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.95 KB | None | 0 0
  1. <?php
  2.     ini_set('display_errors',1);
  3.    
  4.     $username = $password = $domain = $address = $phone = "";
  5.    
  6.     if(isset($_POST['username']) && strlen($_POST['username']) <= 100) {
  7.         $username = stripslashes(strip_tags(trim($_POST['username'])));
  8.     }
  9.  
  10.     if(isset($_POST['password']) && strlen($_POST['password']) <= 100) {
  11.         $password = stripslashes(strip_tags(trim($_POST['password'])));
  12.     }
  13.  
  14.     if(isset($_POST['domain']) && strlen($_POST['domain']) <= 100) {
  15.         $domain = stripslashes(strip_tags(trim($_POST['domain'])));
  16.     }
  17.    
  18.     if(isset($_POST['address']) && strlen($_POST['address']) <= 100) {
  19.         $address = stripslashes(strip_tags(trim($_POST['address'])));
  20.     }
  21.    
  22.     if(isset($_POST['phone']) && strlen($_POST['phone']) <= 100) {
  23.         $phone = stripslashes(strip_tags(trim($_POST['phone'])));
  24.     }
  25.    
  26.     //Create AD user
  27.     $cmd = 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -Noninteractive -command ". C:\inetpub\wwwroot\adduser.ps1 \'' . $username .  '\' \''  . $password . '\' \'' . $address . '\'  \'' . $phone . '\';"';
  28.     if($a=exec($cmd)) {
  29.         echo "ok";
  30.     }
  31.    
  32.     //Create DNS record
  33.     $cmd = 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -Noninteractive -command ". C:\inetpub\wwwroot\setdns.ps1 \''  . $username . '\';"';
  34.     if($a=exec($cmd)) {
  35.         echo "ok";
  36.     }
  37.        
  38.     //Create MySQL user
  39.     $db = $username;
  40.     $conn  = mysql_connect('192.168.0.10', 'creator', 'J_Magill');
  41.     mysql_query("CREATE USER '$username'@'localhost' IDENTIFIED BY '$password';");
  42.     mysql_query("CREATE USER '$username'@'%' IDENTIFIED BY '$password';");
  43.     mysql_query("GRANT ALL ON $db.* TO '$username'@'localhost' IDENTIFIED BY '$password';");
  44.     mysql_query("GRANT ALL ON $db.* TO '$username'@'%' IDENTIFIED BY '$password';");
  45.    
  46.     //Create MySQL database
  47.     $retval = mysql_query("CREATE DATABASE $db;");
  48.     if(! $retval){
  49.         die("Could not create database: " . mysql_error());
  50.     } else {
  51.         echo "Database $db created successfully\n";
  52.     }
  53.    
  54.     mysql_close($conn);
  55. ?>
Add Comment
Please, Sign In to add comment