<?xml version="1.0" encoding="UTF-8"?><rss version="2.0">
<channel>
<title>automation</title>
<link>http://www.computersight.com/tags/automation</link>
<description>New posts about automation</description>
<item>
<title>Cpanel Automation</title>
<link>http://www.computersight.com/Programming/PHP/Cpanel-Automation.80002</link>
<description>
<![CDATA[																																																<p>Are you running or planning on running a community website? If so how would you like to give every user automatically an email address, a sub domain and a ftp account? You might think that you need a special server in order to do this. But you are wrong. If your Hosting Control Panel is CPanel then you can still do this easily.</p>
 
<p>Before you look at the code and start playing with it you need to remember a few things.</p>
 
<ul>
<li>Never trust the input of your users and always validate their input</li>
<li>Nothing is 100% secure</li>
<li>Always test, test, test, test before releasing new functionality to users</li>
</ul>
<p>In order to set up this automatization you need a few things.</p>
 
<ul>
<li>CPanel username</li>
<li>CPanel password</li>
<li>Your domain</li>
<li>CPanel port</li>
<li>CPanel theme</li>
</ul>
<p>You should know your username and password already. If not you need to contact your hosting company. If you log into your CPanel and look at the address bar in your browser you can easily find out the rest of the information.</p>
 
<p>Sample URL</p>
 <p>http://www.yourdomain.com:2082/frontend/x/index.html www.yourdomain.com = Your domain2082 = CPanel portx = CPanel theme</p> 
<p>With this information you can now use the php class below. It is very easy. It has the following features</p>
 Features
 
 
<p><strong>Emails: </strong></p>
 
<ul>
<li>Create Email addresses </li>
<li>Delete Email addresses</li>
<li>Change Email address Password</li>
<li>Change Quota of Email address in box</li>
</ul>
<p><strong>FTP:</strong></p>
 
<ul>
<li>Create FTP account</li>
<li>Delete FTP account</li>
<li>Change FTP account Quota </li>
<li>Change FTP account Password</li>
</ul>
<p><strong>Subdomain:</strong></p>
 
<ul>
<li>Create Subdomain</li>
<li>Delete Subdomain </li>
<li>Create Redirection for a subdomain</li>
<li>Delete Redirection of a subdomain</li>
</ul>
<h3>PHP Class</h3>
 
<p>Simply copy the code below into a file and call it anything you want ie cpanel.php</p>
 
<p> </p>
 
<p></p>
<pre>class cpanel {
 
 	var $cpanel_username = "user";
 	var $cpanel_password = "pass";
 	var $your_domain = "www.domain.com";
 	var $port = "2082";
 	var $cpanel_theme ='x';
 	var $url = '';
 
 	function cpanel () {
 	 $this->url = "http://".$this->cpanel_username.':'.$this->cpanel_password. '@'.$this->your_domain.':'.$this->port.'/frontend/'.$this-> cpanel_theme;	
 	}
 
 	// email
 	function CreateEmail($user,$domain,$password,$quota) {
         @file($this->url.'/mail/doaddpop.html?email='.$user.'&amp;domain='. $domain.'&amp;password='.$password.'&amp;quota='.$quota);
     }
 
     function DeleteEmail($user,$domain) {
         @file($this->url.'/mail/realdelpop.html?email='.$user.' &amp;domain=' .$domain);
     } 
 
     function UpdateEmailQuota($user,$domain,$quota) {
         @file($this->url.'/mail/doeditquota.html?email='.$user.' &amp;domain= '.$domain.'&amp;quota='.$quota);
     } 
 
     function UpdateEmailPassword($user,$domain,$password) {
 	 @file($this->url.'/mail/dopasswdpop.html?email='.$user.' &amp;domain= '.$domain.'&amp;password='.$password);
 	}
 
 	// ftp
 	function CreateFTP($login,$password,$homedir,$quota) {
         @file($this->url.'/ftp/doaddftp.html?login='.$login.'&amp;password=' .$password.'&amp;homedir='.$homedir.'&amp;quota='.$quota);
     }
 
     function DeleteFTP($login) {
         @file($this->url.'/ftp/realdodelftp.html?login='.$login);
     }
 
     function UpdateFTPQuota($login,$quota) {
 	 @file($this->url.'/ftp/doeditquota.html?acct='.$login.'&amp;quota='. $quota);
 	}
 
     function UpdateFTPPassword($login,$password) {
 	 @file($this->url.'/ftp/dopasswdftp.html?acct='.$login.'&amp;password ='.$password);
 	}
 
 	// subdomains
 	function CreateSubDomain ($domain,$root) {
 	 @file($this->url.'/subdomain/doadddomain.html?domain='.$domain. '&amp;rootdomain='.$root);
 	}
 
 	function DeleteSubDomain ($domain,$root) {
 	 @file($this->url.'/subdomain/dodeldomain.html?domain='.$domain. '_'.$root);
 	}
 
 	function CreateRedirect ($domain,$root,$url) {
 	 @file($this->url.'/subdomain/saveredirect.html?domain='.$domain. '_'.$root.'&amp;url='.urlencode($url));	
 	}
 
 	function DeleteRedirect ($domain,$root) {
 	 @file($this->url.'/subdomain/donoredirect.html?domain='.$domain. '_'.$root);	
 	}
 }
 
 
 ?></pre>
 
<h3>How to use the class</h3>
 
<p>First you must include the class</p>
<p>include('cpanel.php');
 
 Then you must create a new object
 
 $cpanel = new cpanel();</p>
 
<p>Lets go quickly through the different functions</p>
<p>CreateEmail($user,$domain,$password,$quota)
 $user: The username before the @
 $domain: After the @ (without the www.)
 $password: Password for the email account
 $quota: How much space you give the email account (0=unlimited)</p>
 
<p>Example:</p>
<p>$cpanel->CreateEmail('Mark','mydomain.com','password','10');
 
 DeleteEmail($user,$domain)
 $user: The username before the @
 $domain: After the @ (without the www.)</p>
 
<p>Example:</p>
<p>$cpanel->DeleteEmail('Mark','mydomain.com');
 
 UpdateEmailQuota($user,$domain,$quota)
 $user: The username before the @
 $domain: After the @ (without the www.)
 $quota: How much space you give the email account (0=unlimited)</p>
 
<p>Example:</p>
<p>$cpanel->UpdateEmailQuota('Mark','mydomain.com','0');
 
 UpdateEmailPassword($user,$domain,$password)
 $user: The username before the @
 $domain: After the @ (without the www.)
 $password: Password for the email account</p>
 
<p>Example:</p>
<p>$cpanel->UpdateEmailPassword('Mark','mydomain.com','newpassword');
 
 CreateFTP($login,$password,$homedir,$quota)
 $login: This will be the username. Usually it will get the domain name added ie @yourdomain.com
 $password: Password for the email account (always from your rot directory)
 $homedir: Which directory he can access. (!!carefull don't give them access to your root directory.)
 $quota: How much space you give the ftp account (0=unlimited)</p>
 
<p>Example:</p>
<p>$cpanel->CreateFTP('Mark','password','/Mark','100');
 
 DeleteFTP($login)
 $login: This will be the username without the @yourdomain.com</p>
 
<p>Example:</p>
<p>$cpanel->DeleteFTP('Mark');
 
 UpdateFTPQuota($login,$quota)
 $login: This will be the username without the @yourdomain.com
 $quota: How much space you give the ftp account (0=unlimited)</p>
 
<p>Example:</p>
<p>$cpanel->UpdateFTPQuota('Mark','200');
 
 UpdateFTPPassword($login,$password)
 $login: This will be the username without the @yourdomain.com
 $quota: How much space you give the ftp account (0=unlimited)</p>
 
<p>Example:</p>
<p>$cpanel->UpdateFTPPassword('Mark','newpassword');
 
 CreateSubDomain ($domain,$root)
 $domain: the subdomain name i.e. Mark
 $root: the domain i.e. yourdomain.com</p>
 
<p>Example:</p>
<p>$cpanel->CreateSubDomain('Mark','mydomain.com',);
 
 DeleteSubDomain ($domain,$root)
 $domain: the subdomain name i.e. Mark
 $root: the domain i.e. yourdomain.com</p>
 
<p>Example:</p>
<p>$cpanel->DeleteSubDomain('Mark','mydomain.com');
 
 CreateRedirect ($domain,$root,$url)
 $domain: the subdomain name i.e. Mark
 $root: the domain i.e. yourdomain.com
 $url: where you which to redirect the user to i.e. http://www.yournewdomain.com</p>
 
<p>Example:</p>
<p>$cpanel->CreateRedirect('Mark','mydomain.com',
'http://www.mynewdomain.com');
 
 DeleteRedirect ($domain,$root)
 $domain: the subdomain name i.e. Mark
 $root: the domain i.e. yourdomain.com</p>
 
<p>Example:</p>
<p>$cpanel->DeleteRedirect('Mark','mydomain.com');</p>
 
<p>So I hope this will help you and please remember that you need to test loads before you can release this functionality to your users. You need to make sure that it is safe which I can guarantee. Just imagine if something goes wrong and you give one of your users access to your root directory.</p>
 
<p>Enjoy</p>																																										<a href="http://www.pheedo.com/click.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FProgramming%2FPHP%2FCpanel-Automation.80002"><img src="http://www.pheedo.com/img.phdo?x=&u=http%3A%2F%2Fwww.computersight.com%2FProgramming%2FPHP%2FCpanel-Automation.80002" border="0"/></a>]]></description>
<pubDate>Mon, 04 Feb 2008 11:03:43 PST</pubDate></item>
</channel>
</rss>
