Zubrag.com
September 21, 2018, 04:17:34 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Create NewDb  (Read 5337 times)
Ganz
Newbie
*
Posts: 3


« on: June 02, 2012, 11:26:56 AM »

I Set up my scripts like this

<?php

###############################################################
# cPanel Database Creator 1.2
###############################################################
# Visit http://www.zubrag.com/scripts/ for updates
###############################################################

// cPanel username (you use to login to cPanel)
$cpanel_user = "xxxx";

// cPanel password (you use to login to cPanel)
$cpanel_password = "xxxxx";

// cPanel domain (example: mysite.com)
$cpanel_host = "localhost";

// cPanel theme/skin, usually "x"
// Check http://www.zubrag.com/articles/determine-cpanel-skin.php
// to know it for sure
$cpanel_skin = "x";
$db_name ="Baby";

// Script will add user to database if these values are not empty
// User wil have ALL permissions
$db_username = 'xxxx';
$db_userpass = 'xxxxx';

// Update this only if you are experienced user or if script does not work
// Path to cURL on your server. Usually /usr/bin/curl
$curl_path = "";

//////////////////////////////////////
/* Code below should not be changed */
//////////////////////////////////////

function execCommand($command) {
  global $curl_path;

  if (!empty($curl_path)) {
    return exec("$curl_path '$command'");
  }
  else {
    return file_get_contents($command);
  }
}

if(isset($_GET['db']) && !empty($_GET['db'])) {
  // escape db name
  $db_name = escapeshellarg($_GET['db']);

  // will return empty string on success, error message on error
  $result = execCommand("http://$cpanel_user:$cpanel_password@$cpanel_host:2082/frontend/$cpanel_skin/sql/adddb.html?db=$db_name");

  if(isset($_GET['user']) && !empty($_GET['user'])) {
    $db_username = $_GET['user'];
    $db_userpass = $_GET['pass'];
  }

  if (!empty($db_username)) {
    // create user
    $result .= execCommand("http://$cpanel_user:$cpanel_password@$cpanel_host:2082/frontend/$cpanel_skin/sql/adduser.html?user={$db_username}&pass={$db_userpass}");
    // assign user to database
    $result .= execCommand("http://$cpanel_user:$cpanel_password@$cpanel_host:2082/frontend/$cpanel_skin/sql/addusertodb.html?user={$cpanel_user}_{$db_username}&db={$cpanel_user}_{$db_name}&ALL=ALL");
  }

  // output result
  echo $result;
}
else {
  echo "Usage: cpanel_create_db.php?db=databasename&user=username&pass=password";
}

?>

My output is this

Usage: cpanel_create_db.php?db=databasename&user=username&pass=password


Where did I go wrong please help!

Logged
Ganz
Newbie
*
Posts: 3


« Reply #1 on: June 02, 2012, 12:42:17 PM »

If i go on my browser

http://$cpanel_user:$cpanel_password@$cpanel_host:2082/frontend/$cpanel_skin/sql/addb.html?db=$db_name

it works!!.
So where above on my script is wrong?
Logged
Ganz
Newbie
*
Posts: 3


« Reply #2 on: June 02, 2012, 01:22:17 PM »

Sorry Guys!

I figure it out. Thank you Zubrag
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC