<?php
class cpsubdomain{
var $cpuser;
var $cppass;
var $cpdomain;
var $cpskin;
function cpsubdomain($cpuser,$cppass,$cpdomain,$cpskin='x'){
$this->cpuser=$cpuser;
$this->cppass=$cppass;
$this->cpdomain=$cpdomain;
$this->cpskin=$cpskin;
// See following URL to know how to determine your cPanel skin
// http://www.zubrag.com/articles/determine-cpanel-skin.php
}
function createSD($esubdomain){
$subdomain=$esubdomain.".".$this->cpdomain;
$path="http://".$this->cpuser.":".$this->cppass."@".$this->cpdomain.":2082/frontend/".$this->cpskin."/subdomain/index.html";
$f = fopen($path,"r");
if (!$f) {
return('Can\'t open cPanel');
}
while (!feof ($f)) {
$line = fgets ($f, 1024);
if (ereg ($subdomain, $line, $out)) {
return('Such subdomain already exists.');
}
}
fclose($f);
$path="http://".$this->cpuser.":".$this->cppass."@".$this->cpdomain.":2082/frontend/".$this->cpskin."/subdomain/doadddomain.html?domain=".$esubdomain."&rootdomain=".$this->cpdomain;
$f = fopen($path,"r");
if (!$f) {
return('Can\'t open cPanel.');
}
while (!feof ($f)) {
$line = fgets ($f, 1024);
if (ereg ("has been added.", $line, $out)) {
return('Subdomain created successfully');
}
}
fclose($f);
return "There may be some error while creating subdomain.";
}
}
?>