Fixes to OSB to work with KH 3.3

This commit is contained in:
Deon George
2012-11-10 10:13:57 +11:00
parent ea36639638
commit 6db02ae77d
238 changed files with 813 additions and 938 deletions

View File

@@ -0,0 +1,284 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides PLESK client support
*
* @package OSB
* @subpackage Plugins/Plesk
* @category Plugins
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Host_Plugin_Plesk_10 extends Host_Plugin_Plesk {
protected $protocol = '1.6.3.0';
// @todo Get these default "templates" values out of the DB
private $_template = array(
'client'=>array(
'gen_info'=>array(),
'stat'=>array(),
),
'domain'=>array(
'gen_info'=>array(),
'hosting'=>array(),
'limits'=>array(),
'stat'=>array(),
'prefs'=>array(),
'disk_usage'=>array(),
'performance'=>array(),
'subscriptions'=>array(),
'permissions'=>array(),
#'plan-items'=>array(), // protocol 1.6.3.1
),
'reseller'=>array(
'gen-info'=>array(),
'stat'=>array(),
),
);
/**
* Get a Client Configuration
*/
public function cmd_getclient(Model_Service $so) {
$this->init();
$items = array_keys($this->_template['client']);
$client = $this->packet->add_node('customer');
$get = $client->add_node('get');
$filter = $get->add_node('filter');
$filter->add_node('login',$so->plugin()->host_username);
$dataset = $get->add_node('dataset');
foreach ($items as $k)
$dataset->add_node($k);
return $this->server_command($this->xml);
}
/**
* Get a DNS Configuration
*/
public function cmd_getdns(Model_Service $so) {
$do = clone $this->cmd_getdomain($so);
$this->init();
$domain = $this->packet->add_node('dns');
$get = $domain->add_node('get_rec');
$filter = $get->add_node('filter');
$filter->add_node('site-id',$do->id->value());
return $this->server_command($this->xml);
}
/**
* Get Mail Configuration
*/
public function cmd_getmail(Model_Service $so) {
$do = clone $this->cmd_getdomain($so);
$this->init();
$domain = $this->packet->add_node('mail');
$get = $domain->add_node('get_prefs');
$filter = $get->add_node('filter');
$filter->add_node('site-id',$do->id->value());
return $this->server_command($this->xml);
}
/**
* Get a Domain Configuration
*/
public function cmd_getdomain(Model_Service $so) {
$this->init();
$items = array_keys($this->_template['domain']);
$domain = $this->packet->add_node('webspace');
$get = $domain->add_node('get');
$filter = $get->add_node('filter');
$filter->add_node('name',strtolower($so->plugin()->name()));
$dataset = $get->add_node('dataset');
foreach ($items as $k)
$dataset->add_node($k);
return $this->server_command($this->xml);
}
/**
* Get Reseller
*/
public function cmd_getreseller(Model_Service $so) {
$this->init();
$items = array_keys($this->_template['reseller']);
$hsao = ORM::factory('Host_Server_Affiliate',array('affiliate_id'=>$so->affiliate_id,'host_server_id'=>$so->plugin()->host_server_id))->find();
if (! $hsao->loaded())
return NULL;
$domain = $this->packet->add_node('reseller');
$get = $domain->add_node('get');
$filter = $get->add_node('filter');
$filter->add_node('login',strtolower($hsao->host_username));
$dataset = $get->add_node('dataset');
foreach ($items as $k)
$dataset->add_node($k);
return $this->server_command($this->xml);
}
/**
* Get Domain Traffic
*/
public function cmd_gettraffic(Model_Service $so) {
throw new Kohana_Exception('Not Implemented');
}
/**
* Disable Mail
*/
public function cmd_disablemail(Model_Service $so) {
$do = clone $this->cmd_getdomain($so);
$this->init();
$domain = $this->packet->add_node('mail');
$disable = $domain->add_node('disable');
$disable->add_node('site-id',$do->id->value());
return $this->server_command($this->xml);
}
/**
* Provision a hosting service
* @todo To implement
*/
public function provision(Model_Service $so) {
$ro = clone $this->cmd_getreseller($so);
// Make sure our reseller exists
if ($ro AND ! $ro->id->value())
throw new Kohana_Exception('Add Reseller - Not Implemented');
// @todo If client already exists, skip this part...
$result = $this->add_client($so);
if (! $result->loaded()) {
print_r(array('x'=>(string)$result->_xml,'o'=>(string)$result->_object));
throw new Kohana_Exception('Failed to Add Client?');
}
// Provision Domain
$result = $this->add_domain($so);
if (! $result->loaded()) {
print_r(array('x'=>(string)$result->_xml,'o'=>(string)$result->_object));
throw new Kohana_Exception('Failed to Add Domain?');
}
echo (string)$result->_object;
}
public function add_client(Model_Service $so) {
$ro = clone $this->cmd_getreseller($so);
$this->init();
$client = $this->packet->add_node('customer');
$add = $client->add_node('add');
$gen_info = $add->add_node('gen_info');
$gen_info->add_node('cname',$so->account->company);
$gen_info->add_node('pname',sprintf('%s %s',$so->account->first_name,$so->account->last_name));
$gen_info->add_node('login',$so->plugin()->host_username);
$gen_info->add_node('passwd',$so->plugin()->host_password);
$gen_info->add_node('status',0);
$gen_info->add_node('email',$so->account->email);
if ($ro->id)
$gen_info->add_node('owner-id',$ro->id->value());
return $this->server_command($this->xml);
}
public function add_dnsdata(Model_Service $so,XML $dns) {
$this->init();
$this->packet->import($dns);
return $this->server_command($this->xml);
}
public function add_domain(Model_Service $so) {
$plan = 'Default Domain'; //@todo Get from other means.
$co = clone $this->cmd_getclient($so);
$ip = '223.27.16.147'; //@todo Get from other means.
if (! $co->loaded())
throw new Kohana_Exception('Unable to load Plesk Customer?');
if (! $so->plugin()->ftp_username)
throw new KOhana_Exception('FTP Username cannot be blank');
$this->init();
$domain = $this->packet->add_node('webspace');
$add = $domain->add_node('add');
$gen_setup = $add->add_node('gen_setup');
$gen_setup->add_node('name',strtolower($so->name()));
$gen_setup->add_node('owner-id',$co->id->value());
$gen_setup->add_node('htype','vrt_hst');
$gen_setup->add_node('ip_address',$ip);
$gen_setup->add_node('status','0');
$hosting = $add->add_node('hosting');
$vrt_host = $hosting->add_node('vrt_hst');
$property = $vrt_host->add_node('property');
$property->add_node('name','ftp_login');
$property->add_node('value',$so->plugin()->ftp_username);
if ($so->plugin()->ftp_password) {
$property = $vrt_host->add_node('property');
$property->add_node('name','ftp_password');
$property->add_node('value',$so->plugin()->ftp_password);
}
$vrt_host->add_node('ip_address',$ip);
$add->add_node('plan-name',$plan);
return $this->server_command($this->xml);
}
public function newitem(Model_Service $so,$type) {
$this->init();
return $this->packet->add_node($type);
}
public function setexpire(Model_Service $so,$date=NULL) {
// @todo This should be a config item
$expbuffer = 14;
$this->init();
$site = $this->packet->add_node('webspace');
$set = $site->add_node('set');
$filter = $set->add_node('filter');
$filter->add_node('name',strtolower($so->plugin()->name()));
$values = $set->add_node('values');
$limits = $values->add_node('limits');
$limit = $limits->add_node('limit');
$limit->add_node('name','expiration');
$limit->add_node('value',(is_null($date) ? $so->plugin()->host_expire+$expbuffer*86400 : $date));
return $this->server_command($this->xml);
}
public function setpasswd(Model_Service $so,$pw) {
$this->init();
$client = $this->packet->add_node('customer');
$set = $client->add_node('set');
$filter = $set->add_node('filter');
$filter->add_node('login',$so->plugin()->host_username);
$values = $set->add_node('values');
$gen_info = $values->add_node('gen_info');
$gen_info->add_node('passwd',$pw);
return $this->server_command($this->xml);
}
}
?>

View File

@@ -0,0 +1,339 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides PLESK client support
*
* @package OSB
* @subpackage Plugins/Plesk
* @category Plugins
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Host_Plugin_Plesk_9 extends Host_Plugin_Plesk {
protected $protocol = '1.6.0.1';
// @todo Get these default "templates" values out of the DB
private $_template = array(
'client'=>array(
'gen_info'=>array(),
'stat'=>array(),
'permissions' => array(
'cp_access'=>TRUE,
'create_domains'=>FALSE,
'manage_phosting'=>FALSE,
'manage_php_safe_mode'=>FALSE,
'manage_sh_access'=>FALSE,
'manage_not_chroot_shell'=>FALSE,
'manage_quota'=>TRUE,
'manage_subdomains'=>TRUE,
'manage_domain_aliases'=>FALSE,
'manage_log'=>TRUE,
'manage_anonftp'=>FALSE,
'manage_crontab'=>FALSE,
'change_limits'=>FALSE,
'manage_dns'=>TRUE,
'manage_webapps'=>FALSE,
'manage_webstat'=>TRUE,
'manage_maillists'=>TRUE,
'manage_spamfilter'=>FALSE,
'manage_virusfilter'=>FALSE,
'allow_local_backups'=>FALSE,
'allow_ftp_backups'=>TRUE,
'remote_access_interface'=>FALSE,
'site_builder'=>FALSE,
'manage_performance'=>FALSE,
'manage_dashboard'=>TRUE,
'select_db_server'=>FALSE,
),
'limits' => array(
'resource-policy'=>'notify',
'max_dom'=>-1,
'max_subdom'=>-1,
'max_dom_aliases'=>-1,
'disk_space_soft'=>-1,
'disk_space'=>-1,
'max_traffic_soft'=>-1,
'max_traffic'=>-1,
'max_wu'=>-1,
'max_db'=>-1,
'max_box'=>-1,
'mbox_quota'=>51200000,
'max_redir'=>-1,
'max_mg'=>-1,
'max_resp'=>-1,
'max_maillists'=>-1,
'max_webapps'=>0,
'expiration'=>-1,
),
'ippool' => array(
'223.27.16.147'=>'shared',
),
),
'domain'=>array(
'gen_info'=>array(),
'hosting'=>array(),
'limits'=>array(),
'user'=>array(),
),
);
/**
* Get a Client Configuration
*/
public function cmd_getclient(Model_Service $so) {
$this->init();
$items = array_keys($this->_template['client']);
$client = $this->packet->add_node('client');
$get = $client->add_node('get');
$filter = $get->add_node('filter');
$filter->add_node('login',$so->plugin()->host_username);
$dataset = $get->add_node('dataset');
foreach ($items as $k)
$dataset->add_node($k);
return $this->server_command($this->xml);
}
/**
* Get a DNS Configuration
*/
public function cmd_getdns(Model_Service $so) {
$do = clone $this->cmd_getdomain($so);
$this->init();
$domain = $this->packet->add_node('dns');
$get = $domain->add_node('get_rec');
$filter = $get->add_node('filter');
$filter->add_node('domain_id',$do->id->value());
return $this->server_command($this->xml);
}
/**
* Get a Domain Configuration
*/
public function cmd_getdomain(Model_Service $so) {
$this->init();
$items = array_keys($this->_template['domain']);
$domain = $this->packet->add_node('domain');
$get = $domain->add_node('get');
$filter = $get->add_node('filter');
$filter->add_node('domain-name',strtolower($so->plugin()->name()));
$dataset = $get->add_node('dataset');
foreach ($items as $k)
$dataset->add_node($k);
return $this->server_command($this->xml);
}
/**
* Get Domain Traffic
*/
public function cmd_gettraffic(Model_Service $so) {
$this->init();
$client = $this->packet->add_node('domain');
$get = $client->add_node('get_traffic');
$filter = $get->add_node('filter');
$filter->add_node('domain-name',strtolower($so->plugin()->name()));
# $get->add_node('since_date','2012-04-01');
# $get->add_node('end_date','2012-04-02');
return $this->server_command($this->xml);
}
/**
* Provision a hosting service
* @todo To implement
*/
public function provision(Model_Service $so) {
throw new Kohana_Exception('Not Implemented');
/*
$result = $this->add_client($so);
// Next need to get the ID from the account call to set the IP
$result = $this->hs->setip(35); // @todo change this number
print_r((string)$result);
// Provision Domain
$result = $this->hs->add_service($so);
print_r((string)$result);
// Set Limits
$result = $this->hs->setlimits($so);
print_r((string)$result);
// Next need to get the ID for the domain to disable mail
$result = $this->hs->disablemail(43);
print_r((string)$result);
*/
}
/**
* Add a new client to the host server
* @todo To implement
*/
public function add_client(Model_Service $so) {
throw new Kohana_Exception('Not Implemented');
/*
$client_template = 'DefaultClient';
$reseller_id = $so->affiliate->host_server_affiliate->host_username;
$client = $this->packet->add_node('client');
$add = $client->add_node('add');
$gen_info = $add->add_node('gen_info');
$gen_info->add_node('cname',$so->account->company);
$gen_info->add_node('pname',sprintf('%s %s',$so->account->first_name,$so->account->last_name));
$gen_info->add_node('login',$so->plugin()->host_username);
$gen_info->add_node('passwd',$so->plugin()->host_password);
$gen_info->add_node('status',0);
$gen_info->add_node('email',$so->account->email);
if ($reseller_id)
$gen_info->add_node('owner-login',$reseller_id);
return $this->server_command($this->xml);
*/
}
// * @todo To implement
public function add_service(Model_Service $so) {
throw new Kohana_Exception('Not Implemented');
/*
// @todo This should come from the DB.
$host_ip = '223.27.16.147';
$domain_template = 'Default Domain';
$domain = $this->packet->add_node('domain');
$add = $domain->add_node('add');
$gen_setup = $add->add_node('gen_setup');
$gen_setup->add_node('name',strtolower($so->name()));
$gen_setup->add_node('owner-login',$so->plugin()->host_username);
$gen_setup->add_node('htype','vrt_hst');
$gen_setup->add_node('ip_address',$host_ip);
$gen_setup->add_node('status','0');
$hosting = $add->add_node('hosting');
$vrt_host = $hosting->add_node('vrt_hst');
$property = $vrt_host->add_node('property');
$property->add_node('name','ftp_login');
$property->add_node('value',$so->plugin()->ftp_username);
$property = $vrt_host->add_node('property');
$property->add_node('name','ftp_password');
$property->add_node('value',$so->plugin()->ftp_password);
$vrt_host->add_node('ip_address',$host_ip);
$add->add_node('template-name',$domain_template);
return $this->server_command($this->xml);
*/
}
// @todo not sure if this is actually working as desired
// * @todo To implement
public function setlimits(Model_Service $so) {
throw new Kohana_Exception('Not Implemented');
/*
$client = $this->packet->add_node('client');
// Permissions
$set = $client->add_node('set');
$filter = $set->add_node('filter');
$filter->add_node('login',$so->plugin()->host_username);
$values = $set->add_node('values');
$x = $values->add_node('permissions');
foreach ($this->permissions as $k=>$v) {
$l = $x->add_node('permission');
$l->add_node('name',$k);
$l->add_node('value',$v==TRUE?'true':'false');
}
// Limits
$set = $client->add_node('set');
$filter = $set->add_node('filter');
$filter->add_node('login',$so->plugin()->host_username);
$values = $set->add_node('values');
$x = $values->add_node('limits');
foreach ($this->limits as $k=>$v) {
$l = $x->add_node('limit');
$l->add_node('name',$k);
$l->add_node('value',$v);
}
return $this->server_command($this->xml);
*/
}
// @todo This is broken. $this->ippool is not existing
// * @todo To implement
public function setip($id) {
throw new Kohana_Exception('Not Implemented');
/*
$client = $this->packet->add_node('client');
$ip = $client->add_node('ippool_add_ip');
$ip->add_node('client_id',$id);
foreach ($this->ippool as $k=>$v)
$ip->add_node('ip_address',$k);
return $this->server_command($this->xml);
*/
}
// * @todo To implement
public function disablemail($id) {
throw new Kohana_Exception('Not Implemented');
/*
$client = $this->packet->add_node('mail');
$disable = $client->add_node('disable');
$disable->add_node('domain_id',$id);
return $this->server_command($this->xml);
*/
}
public function setexpire(Model_Service $so,$date=NULL) {
// @todo This should be a config item
$expbuffer = 14;
$this->init();
$domain = $this->packet->add_node('domain');
$set = $domain->add_node('set');
$filter = $set->add_node('filter');
$filter->add_node('domain-name',strtolower($so->plugin()->name()));
$values = $set->add_node('values');
$limits = $values->add_node('limits');
$limit = $limits->add_node('limit');
$limit->add_node('name','expiration');
$limit->add_node('value',(is_null($date) ? $so->plugin()->host_expire+$expbuffer*86400 : $date));
return $this->server_command($this->xml);
}
public function setpasswd(Model_Service $so,$pw) {
$this->init();
$client = $this->packet->add_node('client');
$set = $client->add_node('set');
$filter = $set->add_node('filter');
$filter->add_node('login',$so->plugin()->host_username);
$values = $set->add_node('values');
$gen_info = $values->add_node('gen_info');
$gen_info->add_node('passwd',$pw);
return $this->server_command($this->xml);
}
}
?>