PHP cpanel scripts
Written by Codes Tips on June 1, 2009 – 8:50 am -Intro
To automate an action in PHP for cpanel it’s very easy. You just need to know some information about your cpanel. You can find this information on your browser link bar.
$cpanel_user - the username that you use to log into your cpanel
$cpanel_password - the password for cpanel.
$cpanel_host - your cpanel host. You can find this after you login to cpanel, right before ‘http://’ until ‘:’.
$cpanel_skin - cpanel skin. You can find this after ‘/frontend/’, default is ‘x’.
HTML Form
You can use this html forms to make the scripts for cpanel, you can add your own fields that you need.
<form action="cpaneladd.php" method="POST"> <table> <tr><td colspan="2" align="center"> <b>Cpanel info</b></td></tr><tr><td align="right">Cpanel host: </td><td align="left"> <input type="text" name="cpanelhost"></td></tr> <tr><td align="right">Cpanel username:</td><td align="left"> <input type="text" name="cpaneluser"></td></tr> <tr><td align="right">Cpanel password:</td><td align="left"> <input type="text" name="cpanelpass"></td></tr> <tr><td align="right">Cpanel skin:</td><td align="left"> <input type="text" name="cpanelskin" values="x"></td></tr> </table> </form>
I made a list with some useful functions that you can use for cpanel:
1. Adding a database in cpanel
$newdb = "db_name"; $curl = curl_init(); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($curl, CURLOPT_URL, "http://$cpanel_user: $cpanel_password@$cpanel_host:2082/frontend/$cpanel_skin /sql/adddb.html?db=$new_db"); $result=curl_exec ($curl); curl_close ($curl);
2. Adding a user to database in cpanel
$db_user = "dbuser"; $db = "database"; $curl = curl_init(); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($curl, CURLOPT_URL, "http://$cpanel_user: $cpanel_password@$cpanel_host:2082/frontend/$cpanel_skin/ sql/addusertodb.html?user={$cpanel_user}_{$db_user} &db={$cpanel_user}_{$db}&ALL=ALL"); $result=curl_exec ($curl); curl_close ($curl);
3. Delete a user in cpanel
$userdb="userdb"; $curl = curl_init(); curl_setopt ($curl, CURLOPT_URL, "http://$cpanel_user: $cpanel_password@$cpanel_host:2082/frontend/$cpanel_skin/ sql/deluser.html?user=".$cpanel_user."_".$userdb); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $result=curl_exec ($curl); curl_close ($curl);
4. Delete a database in cpanel
$db="db"; $curl = curl_init(); curl_setopt ($curl, CURLOPT_URL, "http://$cpanel_user: $cpanel_password@$cpanel_host:2082/frontend/$cpanel_skin /sql/deldb.html?db=".$cpanel_user."_".$db); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $result=curl_exec ($curl); curl_close ($curl);
Tags: Codes, PHP
Posted in Codes, PHP/MYSQL, Scripts |
Leave a Comment
You must be logged in to post a comment.


















