Zubrag.com :: Forum

zubrag.com => cPanel Scripts => Topic started by: smithster on July 16, 2007, 11:19:47 AM



Title: cPanel db creator
Post by: smithster 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.


Title: Re: cPanel db creator
Post by: smithster 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.


Title: Re: cPanel db creator
Post by: zubrag 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)?


Title: Re: cPanel db creator
Post by: smithster 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. :)