Zubrag.com
February 07, 2012, 06:34:08 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: cPanel db creator  (Read 3656 times)
smithster
Simply Web Host
Newbie
*
Posts: 27


WWW
« on: July 16, 2007, 11:19:47 am »

I have had cURL enabled by my host but the db script I cannot get it to work.  I have no idea why!!  I have filled out the script with every detail correct.  I have even replaced the variables in the $result links with actual strings to see if it made a difference.  For some reason it just will not work.

Logged

Shared and Reseller Fantastico cPanel Hosting available at

http://www.simplywebhost.com
smithster
Simply Web Host
Newbie
*
Posts: 27


WWW
« Reply #1 on: July 20, 2007, 11:03:55 pm »

Well I manadged to get this script to work in the end.  Seams parts of the original were stopping this from working.

At the moment, when the script is executed, nothing is echoed.

Here's the script....

<?php

// cPanel username
$cpanel_user = "*****";

// cPanel password
$cpanel_password = "******";

// cPanel host
$cpanel_host = "******";  //I noticed this works with using just "localhost"

// cPanel theme/skin, usually "x"

$cpanel_skin = "x";
$db_name = "******";

//database user account
$db_user = "******";
$db_pass = "********";

// Path to cURL on your server
$curl_path = "/usr/bin/curl";

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

//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
$database = exec("$curl_path 'http://$cpanel_user:$cpanel_password@$cpanel_host:2082/frontend/$cpanel_skin/sql/adddb.html?db=$db_name'");
$adduser = exec("$curl_path 'http://$cpanel_user:$cpanel_password@$cpanel_host:2082/frontend/$cpanel_skin/sql/adduser.html?user=$db_user&pass=$db_pass'");
$asignuser = exec("$curl_path 'http://$cpanel_user:$cpanel_password@$cpanel_host:2082/frontend/$cpanel_skin/sql/addusertodb.html?user=$cpanel_user_$db_user&db=$cpanel_user_$db_name&SELECT=SELECT&CREATE=CREATE&INSERT=INSERT&ALTER=ALTER&UPDATE=UPDATE&DROP=DROP&LOCKTABLES=LOCK&INDEX=INDEX&REFERENCES=REFERENCES&CREATETEMPORARYTABLES=TEMPORARY'");

?>

Hope this helps others.  The code bits that I blocked out were lines that stopped the script from working.
Logged

Shared and Reseller Fantastico cPanel Hosting available at

http://www.simplywebhost.com
zubrag
Administrator
Hero Member
*****
Posts: 745


WWW
« Reply #2 on: July 23, 2007, 10:01:23 am »

Hi. Thanks for sharing! What was the db name? Did it contain some "special" chars like underscore (non alphanumeric)?
Logged
smithster
Simply Web Host
Newbie
*
Posts: 27


WWW
« Reply #3 on: July 27, 2007, 05:30:58 am »

No, when testing scripts, I always keep things simple to eliminate possible causes.  Always standard letters when testing. Smiley
Logged

Shared and Reseller Fantastico cPanel Hosting available at

http://www.simplywebhost.com
Pages: [1]
  Print  
 
Jump to:  

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