Advertisement
Guest User

Untitled

a guest
May 26th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.67 KB | None | 0 0
  1. <?php
  2. ini_set('display_errors', 1);
  3. error_reporting(E_ALL);
  4. ob_start();
  5. session_start();
  6.         if(isset($_SESSION['username'])){
  7.         include("../includes/dbconnect.inc.php");
  8.         require("../includes.php");
  9.  
  10.         // fetch posts
  11.         $username = $_SESSION['username'];
  12.         $path = $_GET['path'];
  13.  
  14.         // security
  15.         $username = mysql_real_escape_string($username);
  16.         $path = mysql_real_escape_string($path);
  17.  
  18.         //check for vhost
  19.         $notsetup = file_exists("/etc/apache2/sites-enabled/".$path."");
  20.  
  21.         //Do error checks
  22.         if(empty($path)){
  23.                 header("location:../index.php?page=easysetup&error=1");
  24.         }
  25.         elseif (!$notsetup){
  26.                 header("location:../index.php?page=easysetup&error=2");
  27.         }
  28.         else{
  29.         //Create DB
  30.         mysql_query("CREATE DATABASE `".$username." _wordpress`;") OR DIE(mysql_error());
  31.         mysql_query("GRANT ALL PRIVILEGES ON `".$username." _wordpress` . * TO '$username'@'94.23.30.114' WITH GRANT OPTION ;");
  32.         mysql_query("FLUSH PRIVILEGES;") OR DIE(mysql_error());
  33.         mysql_query("INSERT INTO userdbs (`name`, `owner`, `added`) VALUES ('".$username." _wordpress', '$username', '$added')") or die(mysql_error());
  34.  
  35.         $query = mysql_query("SELECT passwd FROM ftpuser WHERE username=".$username."");
  36.         $password =  mysql_fetch_assoc($query);
  37.  
  38.         //Make Config File
  39.         $configfile = '
  40.        define('DB_NAME', '".$username." _wordpress');
  41.        define('DB_USER', '".$username."');
  42.        define('DB_PASSWORD', '".$password['password']."');
  43.        define('DB_HOST', 'ronon');
  44.        define('DB_CHARSET', 'utf8');
  45.        define('DB_COLLATE', '');
  46.  
  47.        define('AUTH_KEY', '".$password['password']."');
  48.        define('SECURE_AUTH_KEY', '".$password['password']."');
  49.        define('LOGGED_IN_KEY', '".$password['password']."');
  50.        define('NONCE_KEY', '".$password['password']."');
  51.        $table_prefix  = 'wp_';
  52.  
  53.        define ('WPLANG', 'en');
  54.  
  55.        if ( !defined('ABSPATH') )
  56.                define('ABSPATH', dirname(__FILE__) . '/');
  57.  
  58.        require_once(ABSPATH . 'wp-settings.php');
  59.        ';
  60.  
  61.         //Insert Config to file
  62.         $conf = "/home/www/".$username."/".$path."/wp-config.php";
  63.         $file = fopen ($conf, "w");
  64.         fwrite($conf, $configfile);
  65.         fclose($conf);
  66.  
  67.         //Insert JOB
  68.         mysql_query("INSERT INTO jobqueue(job, username, path) VALUES ('wordpress', '$username', '$path')") or die(mysql_error());
  69.         runDaemon();
  70.         header("location:../index.php?page=easysetup&wordpress=test.karbowiak.dk");
  71.         }
  72. }
  73. ob_end_flush();
  74. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement