this would be very useful for WEB Programmers
if you have a cpanel host, you know that you cannot create MySql DBs and you should do it just by CPanel.
by this code you can do it in your programs:
CODE
<?php
// cPanel username
$cpanel_user = "user";
// cPanel password
$cpanel_password = "password";
// cPanel host
$cpanel_host = "host";
// cPanel theme/skin, usually "x"
$cpanel_skin = "x";
// 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
$result = exec("$curl_path 'http://$cpanel_user:$cpanel_password@$cpanel_host:2082/frontend/$cpanel_skin/sql/adddb.html?db=$db_name'");
// output result
echo $result;
}
else {
echo "Usage: cpanel_create_db.php?db=databasename";
}
?>
// cPanel username
$cpanel_user = "user";
// cPanel password
$cpanel_password = "password";
// cPanel host
$cpanel_host = "host";
// cPanel theme/skin, usually "x"
$cpanel_skin = "x";
// 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
$result = exec("$curl_path 'http://$cpanel_user:$cpanel_password@$cpanel_host:2082/frontend/$cpanel_skin/sql/adddb.html?db=$db_name'");
// output result
echo $result;
}
else {
echo "Usage: cpanel_create_db.php?db=databasename";
}
?>
just replace change these values:
QUOTE
$cpanel_user
$cpanel_password
$cpanel_host
$cpanel_password
$cpanel_host

