Hi guys,
Im making used of PHP to add a user to a database via the cpanel account url. Unfortunatly, using the API isnt an option in this case, but it was working fine up until cpanel on the server was updated to 11.44. Now when calling addusertodb.html i get a 404.
part of the script:
looking in the x3/sql directory i see its not there:
so.. any idea where this has gone? I really dont like the paper lantern theme... so would like to avoid having to use it
Im making used of PHP to add a user to a database via the cpanel account url. Unfortunatly, using the API isnt an option in this case, but it was working fine up until cpanel on the server was updated to 11.44. Now when calling addusertodb.html i get a 404.
part of the script:
PHP:
function addUserToDb($cPanelUser,$cPanelPass,$userName,$dbName,$privileges) {
$host= gethostname(); //get the ip, so we force local only. Also good for negating dns issues
$ip = gethostbyname($host);
$domain = variable_get('system_area_set', '');
$theme = variable_get('system_style_set', '');
$buildRequest = "/frontend/".$theme."/sql/addusertodb.html?user=".$userName."&db=".$dbName.$privileges;
$ssl = variable_get('cp_sub_ssl_setting', 0);
if($ssl == 1){
$domain = "ssl://".$domain;
}
$openSocket = fsockopen($domain,variable_get('cPanel_sub_port', 2082));
if(!$openSocket) {
return "Socket error";
exit();
}
$authString = $cPanelUser . ":" . $cPanelPass;
$authPass = base64_encode($authString);
$buildHeaders = "GET " . $buildRequest ."\r\n";
$buildHeaders .= "HTTP/1.1\r\n";
$buildHeaders .= "Host:".$domain."\r\n";
$buildHeaders .= "Authorization: Basic " . $authPass . "\r\n";
$buildHeaders .= "\r\n";
fputs($openSocket, $buildHeaders);
while(!feof($openSocket)) {
fgets($openSocket,128);
}
$socketstatus = socket_strerror(socket_last_error());
fclose($openSocket);
if($socketstatus == 'Success'){
return FALSE; // successfull so return false. (no error)
} else {
return $socketstatus;
}
}
Code:
[email protected] [/usr/local/cpanel/base/frontend/x3/sql]# ls -l
total 140
drwxr-xr-x 2 root root 4096 Jun 23 00:15 ./
drwxr-xr-x 76 root root 4096 Jul 2 00:12 ../
-rw-r--r-- 1 root root 348 Oct 20 2013 PhpMyAdmin.html
-rw-r--r-- 1 root root 1235 Jun 23 00:09 addb.html
-rw-r--r-- 1 root root 628 Oct 20 2013 addhost.html
-rw-r--r-- 1 root root 1112 Jun 23 00:09 adduser.html
-rw-r--r-- 1 root root 640 Jun 23 00:09 changepasswd.auto.tmpl
lrwxrwxrwx 1 root root 22 Jun 23 00:15 changepasswd.html -> changepasswd.auto.tmpl
-rw-r--r-- 1 root root 716 Oct 20 2013 checkdb.html
-rw-r--r-- 1 root root 862 Mar 6 00:08 deldb.html
-rw-r--r-- 1 root root 810 Oct 20 2013 deldbconfirm.html
-rw-r--r-- 1 root root 610 Oct 20 2013 delhost.html
-rw-r--r-- 1 root root 871 Oct 20 2013 delhostconfirm.html
-rw-r--r-- 1 root root 565 Oct 20 2013 deluser.html
-rw-r--r-- 1 root root 848 Oct 20 2013 deluserconfirm.html
-rw-r--r-- 1 root root 212 Jun 23 00:09 deluserfromdbconfirm.html
-rw-r--r-- 1 root root 1051 Jun 23 00:09 deluserfromdbconfirm.tmpl
-rw-r--r-- 1 root root 771 Apr 9 00:09 dochangepassword.html
-rw-r--r-- 1 root root 1049 Feb 12 09:13 index.html
-rw-r--r-- 1 root root 783 Oct 20 2013 index_head.html
-rw-r--r-- 1 root root 14772 Jun 23 00:09 index_include.html
-rw-r--r-- 1 root root 2707 Mar 6 00:08 managehost.html
-rw-r--r-- 1 root root 708 Oct 20 2013 repairdb.html
-rw-r--r-- 1 root root 977 Oct 20 2013 repairdbconfirm.html
-rw-r--r-- 1 root root 1099 Oct 20 2013 user.html
-rw-r--r-- 1 root root 901 Jun 23 00:09 userrights.html
-rw-r--r-- 1 root root 1055 Jun 23 00:09 userrights.tmpl
-rw-r--r-- 1 root root 1635 Jun 23 00:09 userrights_include.tmpl
-rw-r--r-- 1 root root 2740 Jun 23 00:09 wizard1.html
-rw-r--r-- 1 root root 4304 Jun 23 00:09 wizard2.html
-rw-r--r-- 1 root root 1673 Jun 23 00:09 wizard3.html
-rw-r--r-- 1 root root 1986 Jun 23 00:09 wizard4.auto.tmpl
lrwxrwxrwx 1 root root 17 Jun 23 00:15 wizard4.html -> wizard4.auto.tmpl