Open Source Billing
This commit is contained in:
79
modules/host/classes/Controller/Admin/Host.php
Normal file
79
modules/host/classes/Controller/Admin/Host.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides Host Server functions
|
||||
*
|
||||
* @package Host
|
||||
* @category Controllers/Admin
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_Admin_Host extends Controller_TemplateDefault_Admin {
|
||||
protected $secure_actions = array(
|
||||
'ajaxmanage'=>TRUE,
|
||||
'list'=>TRUE,
|
||||
'update'=>TRUE,
|
||||
);
|
||||
|
||||
public function action_ajaxmanage() {
|
||||
$this->auto_render = FALSE;
|
||||
|
||||
$hso = ORM::factory('Host_Server',$this->request->param('id'));
|
||||
$k = Session::instance()->get_once('manage_button');
|
||||
|
||||
$o = array(
|
||||
'u'=>$hso->manage_username ? $hso->manage_username : strtolower($hso->name),
|
||||
'p'=>(! $k OR ! $this->request->is_ajax() OR ! $hso->loaded() OR ! isset($_REQUEST['k']) OR $k != $_REQUEST['k']) ? Random::char() : $hso->manage_password,
|
||||
);
|
||||
|
||||
$this->response->headers('Content-Type','application/json');
|
||||
$this->response->body(json_encode($o));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a list of hosting servers
|
||||
*/
|
||||
public function action_list() {
|
||||
Block::add(array(
|
||||
'title'=>_('Customer Services'),
|
||||
'body'=>Table::display(
|
||||
ORM::factory('Host_Server')->find_all(),
|
||||
25,
|
||||
array(
|
||||
'id'=>array('label'=>'ID','url'=>URL::link('admin','host/update/')),
|
||||
'name'=>array('label'=>'Details'),
|
||||
),
|
||||
array(
|
||||
'page'=>TRUE,
|
||||
'type'=>'select',
|
||||
'form'=>URL::link('admin','host/update'),
|
||||
)),
|
||||
));
|
||||
}
|
||||
|
||||
public function action_update() {
|
||||
$hso = ORM::factory('Host_Server',$this->request->param('id'));
|
||||
$output = '';
|
||||
|
||||
if (! $hso->loaded())
|
||||
HTTP::redirect('welcome/index');
|
||||
|
||||
if ($_POST) {
|
||||
$hso->values($_POST);
|
||||
|
||||
if ($hso->changed() AND ! $hso->save())
|
||||
throw new Kohana_Exception('Unable to save record?');
|
||||
}
|
||||
|
||||
$output .= View::factory($this->viewpath())
|
||||
->set('hso',$hso)
|
||||
->set('plugin_form',$hso->admin_update());
|
||||
|
||||
Block::add(array(
|
||||
'title'=>sprintf('%s %s:%s',_('Update Host Server'),$hso->id,$hso->name),
|
||||
'body'=>$output,
|
||||
));
|
||||
}
|
||||
}
|
||||
?>
|
302
modules/host/classes/Controller/Task/Host.php
Normal file
302
modules/host/classes/Controller/Task/Host.php
Normal file
@@ -0,0 +1,302 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides Host Server functions
|
||||
*
|
||||
* @package Host
|
||||
* @category Controllers/Task
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_Task_Host extends Controller_Task {
|
||||
private $so; // Service Object
|
||||
private $hpo; //Host Server Object
|
||||
|
||||
public function __construct(Request $request, Response $response) {
|
||||
parent::__construct($request,$response);
|
||||
|
||||
// To make it easy for some methods, we'll load our service here
|
||||
switch (Request::current()->action()) {
|
||||
case 'getclient':
|
||||
case 'getdomain':
|
||||
case 'getdns':
|
||||
case 'getmail':
|
||||
case 'getreseller':
|
||||
case 'gettraffic':
|
||||
case 'migrate':
|
||||
case 'provision':
|
||||
case 'setdisablemail':
|
||||
case 'setexpire':
|
||||
case 'setpasswd':
|
||||
$this->so = ORM::factory('Service',$this->request->param('id'));
|
||||
|
||||
if (! $this->so->loaded())
|
||||
throw new Kohana_Exception('Unknown service :sid',array(':sid'=>$this->request->param('id')));
|
||||
|
||||
$this->hpo = $this->so->plugin()->host_server->plugin();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function save($index,$result) {
|
||||
$p = $this->so->plugin();
|
||||
|
||||
// We need to use a new var to avoid Indirect modification of overloaded property errors.
|
||||
$x = is_null($p->server_data) ? array() : $p->server_data;
|
||||
$x[$p->host_server_id][$index] = serialize($result);
|
||||
$p->server_data = $x;
|
||||
|
||||
$x = is_null($p->server_data_date) ? array() : $p->server_data_date;
|
||||
$x[$p->host_server_id][$index] = time();
|
||||
$p->server_data_date = $x;
|
||||
|
||||
return $p->save();
|
||||
}
|
||||
|
||||
private function verify($index,$result,$save=TRUE) {
|
||||
$p = $this->so->plugin();
|
||||
|
||||
if (! isset($p->server_data[$p->host_server_id][$index]) OR (md5($p->server_data[$p->host_server_id][$index]) != md5(serialize($result)))) {
|
||||
if ($save)
|
||||
$this->save('c',$result);
|
||||
|
||||
return FALSE;
|
||||
} else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Client Details from Host Server
|
||||
*/
|
||||
public function action_getclient() {
|
||||
$result = $this->hpo->cmd_getclient($this->so);
|
||||
|
||||
if ($result->loaded())
|
||||
$this->verify('c',$result);
|
||||
|
||||
echo (string)$result->_object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Client Details from Host Server
|
||||
*/
|
||||
public function action_getdomain() {
|
||||
$result = $this->hpo->cmd_getdomain($this->so);
|
||||
|
||||
if ($result->loaded())
|
||||
$this->verify('d',$result);
|
||||
|
||||
echo (string)$result->_object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get DNS Details from Host Server
|
||||
*/
|
||||
public function action_getdns() {
|
||||
$result = $this->hpo->cmd_getdns($this->so,'/tmp/z');
|
||||
|
||||
#if ($result->loaded())
|
||||
# $this->verify('d',$result);
|
||||
|
||||
echo (string)$result->_object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Mail Details from Host Server
|
||||
*/
|
||||
public function action_getmail() {
|
||||
$result = $this->hpo->cmd_getmail($this->so);
|
||||
|
||||
echo (string)$result->_xml;
|
||||
echo (string)$result->_object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Reseller
|
||||
*/
|
||||
public function action_getreseller() {
|
||||
$result = $this->hpo->cmd_getreseller($this->so);
|
||||
|
||||
echo (string)$result->_object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Domain Traffic
|
||||
*/
|
||||
public function action_gettraffic() {
|
||||
$result = $this->hpo->cmd_gettraffic($this->so);
|
||||
|
||||
echo (string)$result->_object;
|
||||
}
|
||||
|
||||
public function action_migrate() {
|
||||
if (! preg_match('/^[0-9]+:[0-9]+-[0-9]+$/',$ids=$this->request->param('id')))
|
||||
throw new Kohana_Exception('Need to specify 2 site for a service to migrate, ie: svc:a-b');
|
||||
|
||||
list($sid,$svrs) = preg_split('/:/',$ids,2);
|
||||
list($fsid,$tsid) = preg_split('/-/',$svrs,2);
|
||||
|
||||
$so = ORM::factory('Service',$sid);
|
||||
if (! $so->loaded())
|
||||
throw new Kohana_Exception('Service :sid doesnt exist?',array(':sid'=>$sid));
|
||||
|
||||
printf("Migrate: %s\n",$so->plugin()->name());
|
||||
|
||||
// Validation, make sure the target is as configured
|
||||
if ($so->plugin()->host_server_id != $tsid)
|
||||
throw new Kohana_Exception('Service :sid is defined to server :tsid?',array(':sid'=>$sid,':tsid'=>$tsid));
|
||||
|
||||
// Validation, make sure the target is defined
|
||||
$domain = clone $this->hpo->cmd_getdomain($this->so);
|
||||
if (! $domain->loaded())
|
||||
throw new Kohana_Exception('Service :sid is not on server :tsid?',array(':sid'=>$sid,':tsid'=>$tsid));
|
||||
|
||||
// Temporarily set our host_server_id to $fsid
|
||||
$hpo = ORM::factory('Host_Server',$fsid);
|
||||
if (! $hpo->loaded())
|
||||
throw new Kohana_Exception('Host server :fsid not defined?',array(':fsid'=>$fsid));
|
||||
|
||||
$result = $hpo->plugin()->cmd_getdns($this->so);
|
||||
|
||||
// During migration we are only interested in the data.
|
||||
$k = array(
|
||||
'host_plugin_plesk_10'=>array('type','host','value','opt'), // From PLESK 9.
|
||||
);
|
||||
|
||||
$t = array(
|
||||
'host_plugin_plesk_10'=>array('domain_id'=>array('site-id'=>'id')), // From PLESK 9.
|
||||
);
|
||||
|
||||
$f = array(
|
||||
'host_plugin_plesk_10'=>array('host'=>'NODOMAIN','value'=>'NOTRAILDOT'),
|
||||
);
|
||||
|
||||
$dns = $this->hpo->newitem($this->so,'dns');
|
||||
|
||||
foreach ($result->_object->get('result',FALSE) as $key => $o) {
|
||||
$rec = $o->data->collapse();
|
||||
|
||||
$add = $dns->add_node('add_rec');
|
||||
|
||||
// Translate old values to new ones.
|
||||
foreach ($t[strtolower(get_class($this->hpo))] as $a=>$b) {
|
||||
if (isset($rec[$a])) {
|
||||
unset($rec[$a]);
|
||||
|
||||
foreach ($b as $c=>$d) {
|
||||
$add->add_node($c,$domain->$d->value());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Import the values we are interested in
|
||||
foreach ($k[strtolower(get_class($this->hpo))] as $a=>$b)
|
||||
if (isset($rec[$b])) {
|
||||
if (isset($f[strtolower(get_class($this->hpo))][$b])) {
|
||||
switch ($f[strtolower(get_class($this->hpo))][$b]) {
|
||||
case 'NODOMAIN':
|
||||
$rec[$b] = preg_replace('/\.?'.$so->plugin()->name().'\.$/i','',$rec[$b]);
|
||||
break;
|
||||
|
||||
case 'NOTRAILDOT':
|
||||
$rec[$b] = preg_replace('/\.$/','',$rec[$b]);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Kohana_Exception('Unknown filter action :filter',array(':filter'=>$f[strtolower(get_class($this->hpo))][$b]));
|
||||
}
|
||||
}
|
||||
|
||||
$add->add_node($b,$rec[$b]);
|
||||
}
|
||||
}
|
||||
|
||||
printf("DNS: %s\n",(string)$dns);
|
||||
|
||||
$result = $this->hpo->add_dnsdata($this->so,$dns);
|
||||
|
||||
echo (string)$result->_object;
|
||||
}
|
||||
|
||||
/**
|
||||
* List services that need to be provisioned
|
||||
* @todo This needs to be reviewed for functionality
|
||||
*/
|
||||
public function action_provisionlist() {
|
||||
$mode = $this->request->param('id');
|
||||
$cats = array();
|
||||
|
||||
if ($mode)
|
||||
$cats = ORM::factory('Product_Category')->list_bylistgroup($mode);
|
||||
|
||||
foreach (ORM::Factory('service')->list_provision()->find_all() as $so) {
|
||||
$pc = array();
|
||||
|
||||
// Limit to show only those by the requested category.
|
||||
if ($cats) {
|
||||
if (! $so->product->avail_category OR ! preg_match('/^a:/',$so->product->avail_category))
|
||||
continue;
|
||||
|
||||
$pc = unserialize($so->product->avail_category);
|
||||
|
||||
if (! array_intersect($pc,array_keys($cats)))
|
||||
continue;
|
||||
}
|
||||
|
||||
echo $so->id();
|
||||
|
||||
switch ($mode) {
|
||||
case 'host':
|
||||
printf(' %s %s %s',$so->plugin(),$so->plugin()->host_server->name,$so->service_name());
|
||||
break;
|
||||
|
||||
default:
|
||||
}
|
||||
echo "\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provision a Hosting Service
|
||||
*/
|
||||
public function action_provision() {
|
||||
$result = $this->hpo->provision($this->so);
|
||||
$this->action_setexpire();
|
||||
|
||||
print_r((string)$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provision a Hosting Service
|
||||
*/
|
||||
public function action_setdisablemail() {
|
||||
$result = $this->hpo->cmd_disablemail($this->so);
|
||||
|
||||
echo (string)$result->_object;
|
||||
}
|
||||
|
||||
public function action_setexpire() {
|
||||
if (! ($result = $this->hpo->setexpire($this->so)) OR ! $result->loaded()) {
|
||||
echo ('Unable to set expire date.');
|
||||
echo (string)$result->_xml;
|
||||
echo (string)$result->_object;
|
||||
} else
|
||||
echo (string)$result->_object;
|
||||
}
|
||||
|
||||
public function action_setpasswd() {
|
||||
$pw = PWGen::get(TRUE);
|
||||
|
||||
$spho = $this->so->plugin();
|
||||
$spho->host_password = $pw;
|
||||
|
||||
if (! ($result = $this->hpo->setpasswd($this->so,$pw)) OR ! $result->loaded() OR ! $spho->save())
|
||||
throw new Kohana_Exception('Unable to set password.');
|
||||
|
||||
echo _('Password Reset Success');
|
||||
}
|
||||
}
|
||||
?>
|
50
modules/host/classes/Host/Plugin.php
Normal file
50
modules/host/classes/Host/Plugin.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides HOST Plugin Support
|
||||
*
|
||||
* @package Host
|
||||
* @category Plugins
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
abstract class Host_Plugin implements Serializable {
|
||||
protected $hso; // Our Host Serve Object
|
||||
protected $_object;
|
||||
|
||||
protected $curlopts = array(
|
||||
CURLOPT_CONNECTTIMEOUT => 60,
|
||||
CURLOPT_FAILONERROR => TRUE,
|
||||
CURLOPT_FOLLOWLOCATION => FALSE,
|
||||
CURLOPT_HEADER => FALSE,
|
||||
CURLOPT_HTTPPROXYTUNNEL => FALSE,
|
||||
CURLOPT_RETURNTRANSFER => TRUE,
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
CURLOPT_SSL_VERIFYHOST => FALSE,
|
||||
CURLOPT_SSL_VERIFYPEER => FALSE,
|
||||
CURLOPT_VERBOSE => FALSE,
|
||||
);
|
||||
|
||||
// Required abstract classes
|
||||
abstract public function __get($key);
|
||||
abstract public function admin_update();
|
||||
|
||||
abstract public function manage_button(Model_Service_Plugin_Host $spho,$t);
|
||||
abstract public function admin_manage_button(Model_Host_Server $hso,$t);
|
||||
abstract protected function render_button($t,$sid,$u,$p);
|
||||
|
||||
public function __construct(Model_Host_Server $hso) {
|
||||
$this->hso = $hso;
|
||||
}
|
||||
|
||||
public function value($key,$value=NULL) {
|
||||
// If value is NULL, we are a getter
|
||||
if (is_null($value))
|
||||
return isset($this->hso->provision_plugin_data[$key]) ? $this->hso->provision_plugin_data[$key] : NULL;
|
||||
else
|
||||
$this->hso->provision_plugin_data[$key] = $value;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
81
modules/host/classes/Host/Plugin/Cpanel.php
Normal file
81
modules/host/classes/Host/Plugin/Cpanel.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides CPANEL support
|
||||
*
|
||||
* @package Host
|
||||
* @category Plugins
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
abstract class Host_Plugin_Cpanel extends Host_Plugin {
|
||||
// Service Object
|
||||
# protected $protocol = '1.6.0.0';
|
||||
# protected $path = 'enterprise/control/agent.php';
|
||||
# protected $packet;
|
||||
# protected $xml;
|
||||
# protected $_loaded = FALSE;
|
||||
|
||||
// Manage UI Login Attributes
|
||||
protected $url = 'login';
|
||||
protected $login_acnt_field = '';
|
||||
protected $login_user_field = 'user';
|
||||
protected $login_pass_field = 'pass';
|
||||
|
||||
// Our required abstract classes
|
||||
public function serialize() {
|
||||
return (string)$this->_object;
|
||||
}
|
||||
public function unserialize($s) {
|
||||
$this->_object = XML::factory(NULL,NULL,$s);
|
||||
}
|
||||
|
||||
public function __get($index) {
|
||||
echo __METHOD__;die();
|
||||
}
|
||||
|
||||
public function admin_update() {
|
||||
echo __METHOD__;die();
|
||||
}
|
||||
|
||||
public function manage_button(Model_Service_Plugin_Host $spho,$t) {
|
||||
return $this->render_button($t,$spho->service_id,$spho->username_value(),substr(md5($spho->password_value()),0,8));
|
||||
}
|
||||
public function admin_manage_button(Model_Host_Server $hso,$t) {
|
||||
return $this->render_button($t,$hso->id,substr(md5($hso->manage_username),0,8),substr(md5($hso->manage_password),0,8));
|
||||
}
|
||||
|
||||
protected function render_button($t,$sid,$u,$p) {
|
||||
$debug = FALSE;
|
||||
$output = '';
|
||||
|
||||
$output .= Form::open(
|
||||
$debug ? 'debug/site' : sprintf('%s/%s',$this->hso->manage_url,$this->url),
|
||||
array('target'=>'w24','method'=>'post','id'=>sprintf('id_%s_%s',$sid,$t))
|
||||
);
|
||||
$output .= Form::input($this->login_user_field,$u,array('type'=>'hidden','id'=>sprintf('u_%s_%s',$sid,$t)));
|
||||
$output .= Form::input($this->login_pass_field,$p,array('type'=>'hidden','id'=>sprintf('p_%s_%s',$sid,$t)));
|
||||
$output .= Form::close();
|
||||
$output .= Form::button('submit',_('Manage'),array('class'=>'form_button','value'=>sprintf('%s:%s',$sid,$t)));
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
protected function init() {
|
||||
echo __METHOD__;die();
|
||||
}
|
||||
|
||||
protected function server_command(XML $xml) {
|
||||
echo __METHOD__;die();
|
||||
}
|
||||
|
||||
public function loaded() {
|
||||
return $this->_loaded;
|
||||
}
|
||||
|
||||
private function render(XML $xml) {
|
||||
echo __METHOD__;die();
|
||||
}
|
||||
}
|
||||
?>
|
100
modules/host/classes/Host/Plugin/Cpanel/11.php
Normal file
100
modules/host/classes/Host/Plugin/Cpanel/11.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides CPANEL client support
|
||||
*
|
||||
* @package Host
|
||||
* @category Plugins
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Host_Plugin_Cpanel_11 extends Host_Plugin_Cpanel {
|
||||
# protected $protocol = '1.6.3.0';
|
||||
|
||||
// @todo Get these default "templates" values out of the DB
|
||||
private $_template = array(
|
||||
);
|
||||
|
||||
/**
|
||||
* Get a Client Configuration
|
||||
*/
|
||||
public function cmd_getclient(Model_Service $so) {
|
||||
throw new Kohana_Exception('Not Implemented');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a DNS Configuration
|
||||
*/
|
||||
public function cmd_getdns(Model_Service $so) {
|
||||
throw new Kohana_Exception('Not Implemented');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Mail Configuration
|
||||
*/
|
||||
public function cmd_getmail(Model_Service $so) {
|
||||
throw new Kohana_Exception('Not Implemented');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Domain Configuration
|
||||
*/
|
||||
public function cmd_getdomain(Model_Service $so) {
|
||||
throw new Kohana_Exception('Not Implemented');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Reseller
|
||||
*/
|
||||
public function cmd_getreseller(Model_Service $so) {
|
||||
throw new Kohana_Exception('Not Implemented');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
throw new Kohana_Exception('Not Implemented');
|
||||
}
|
||||
|
||||
/**
|
||||
* Provision a hosting service
|
||||
* @todo To implement
|
||||
*/
|
||||
public function provision(Model_Service $so) {
|
||||
throw new Kohana_Exception('Not Implemented');
|
||||
}
|
||||
|
||||
public function add_client(Model_Service $so) {
|
||||
throw new Kohana_Exception('Not Implemented');
|
||||
}
|
||||
|
||||
public function add_dnsdata(Model_Service $so,XML $dns) {
|
||||
throw new Kohana_Exception('Not Implemented');
|
||||
}
|
||||
|
||||
public function add_domain(Model_Service $so) {
|
||||
throw new Kohana_Exception('Not Implemented');
|
||||
}
|
||||
|
||||
public function newitem(Model_Service $so,$type) {
|
||||
throw new Kohana_Exception('Not Implemented');
|
||||
}
|
||||
|
||||
public function setexpire(Model_Service $so,$date=NULL) {
|
||||
throw new Kohana_Exception('Not Implemented');
|
||||
}
|
||||
|
||||
public function setpasswd(Model_Service $so,$pw) {
|
||||
throw new Kohana_Exception('Not Implemented');
|
||||
}
|
||||
}
|
||||
?>
|
117
modules/host/classes/Host/Plugin/Plesk.php
Normal file
117
modules/host/classes/Host/Plugin/Plesk.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides PLESK support
|
||||
*
|
||||
* @package Host
|
||||
* @category Plugins
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
abstract class Host_Plugin_Plesk extends Host_Plugin {
|
||||
// Service Object
|
||||
protected $protocol = '1.6.0.0';
|
||||
protected $path = 'enterprise/control/agent.php';
|
||||
protected $packet;
|
||||
protected $xml;
|
||||
protected $_loaded = FALSE;
|
||||
|
||||
// Manage UI Login Attributes
|
||||
protected $url = 'login_up.php3';
|
||||
protected $login_acnt_field = '';
|
||||
protected $login_user_field = 'login_name';
|
||||
protected $login_pass_field = 'passwd';
|
||||
|
||||
// Our required abstract classes
|
||||
public function serialize() {
|
||||
return (string)$this->_object;
|
||||
}
|
||||
public function unserialize($s) {
|
||||
$this->_object = XML::factory(NULL,NULL,$s);
|
||||
}
|
||||
|
||||
public function __get($index) {
|
||||
// We need to find out the command key, so we can get the status result.
|
||||
if (count($a=array_keys($this->xml->packet->as_array())) != 1)
|
||||
throw new Kohana_Exception('XML command malformed? :xml',array(':xml'=>(string)$this->xml));
|
||||
$key = array_shift($a);
|
||||
if (count($a=array_keys($this->xml->packet->$key->as_array())) != 1)
|
||||
throw new Kohana_Exception('XML command malformed? :xml',array(':xml'=>(string)$this->xml));
|
||||
$get = array_shift($a);
|
||||
|
||||
if ($index == '_object')
|
||||
return (! $this->_loaded OR $this->_object->$key->$get->result->status->value() != 'ok' ) ? $this->_object : $this->_object->$key->$get;
|
||||
elseif ($index == '_xml')
|
||||
return $this->xml;
|
||||
else
|
||||
return is_object($this->_object->$key->$get->result->$index) ? $this->_object->$key->$get->result->$index : NULL;
|
||||
}
|
||||
|
||||
public function admin_update() {
|
||||
return View::factory('host/admin/plugin/plesk')
|
||||
->set('o',$this);
|
||||
}
|
||||
|
||||
public function manage_button(Model_Service_Plugin_Host $spho,$t) {
|
||||
return $this->render_button($t,$spho->service_id,$spho->username_value(),substr(md5($spho->password_value()),0,8));
|
||||
}
|
||||
public function admin_manage_button(Model_Host_Server $hso,$t) {
|
||||
return $this->render_button($t,$hso->id,substr(md5($hso->manage_username),0,8),substr(md5($hso->manage_password),0,8));
|
||||
}
|
||||
|
||||
protected function render_button($t,$sid,$u,$p) {
|
||||
$debug = FALSE;
|
||||
$output = '';
|
||||
|
||||
$output .= Form::open(
|
||||
$debug ? 'debug/site' : sprintf('%s/%s',$this->hso->manage_url,$this->url),
|
||||
array('target'=>'w24','method'=>'post','id'=>sprintf('id_%s_%s',$sid,$t))
|
||||
);
|
||||
$output .= Form::input($this->login_user_field,$u,array('type'=>'hidden','id'=>sprintf('u_%s_%s',$sid,$t)));
|
||||
$output .= Form::input($this->login_pass_field,$p,array('type'=>'hidden','id'=>sprintf('p_%s_%s',$sid,$t)));
|
||||
$output .= Form::close();
|
||||
$output .= Form::button('submit',_('Manage'),array('class'=>'form_button','value'=>sprintf('%s:%s',$sid,$t)));
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
protected function init() {
|
||||
$this->_loaded = FALSE;
|
||||
$this->_object = XML::factory(NULL,'plesk');
|
||||
$this->xml = XML::factory(NULL,'plesk');
|
||||
$this->packet = $this->xml->add_node('packet','',array('version'=>$this->protocol));
|
||||
}
|
||||
|
||||
protected function server_command(XML $xml) {
|
||||
$request = Request::factory(sprintf('%s/%s',$this->hso->manage_url,$this->path))
|
||||
->method('POST');
|
||||
|
||||
$request->client()->options(Arr::merge($this->curlopts,array(
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'HTTP_AUTH_LOGIN: '.$this->hso->manage_username,
|
||||
'HTTP_AUTH_PASSWD: '.$this->hso->manage_password,
|
||||
'Content-Type: text/xml',
|
||||
),
|
||||
CURLOPT_POSTFIELDS => $this->render($xml),
|
||||
)));
|
||||
|
||||
$response = $request->execute();
|
||||
|
||||
$this->_object = XML::factory(NULL,'plesk',$response->body());
|
||||
|
||||
if ($this->_object->status->value() == 'ok')
|
||||
$this->_loaded = TRUE;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function loaded() {
|
||||
return $this->_loaded;
|
||||
}
|
||||
|
||||
private function render(XML $xml) {
|
||||
return preg_replace('/<\/?plesk>/','',(string)$xml->render(FALSE));
|
||||
}
|
||||
}
|
||||
?>
|
283
modules/host/classes/Host/Plugin/Plesk/10.php
Normal file
283
modules/host/classes/Host/Plugin/Plesk/10.php
Normal file
@@ -0,0 +1,283 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides PLESK client support
|
||||
*
|
||||
* @package Host
|
||||
* @category Plugins
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.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);
|
||||
}
|
||||
}
|
||||
?>
|
338
modules/host/classes/Host/Plugin/Plesk/9.php
Normal file
338
modules/host/classes/Host/Plugin/Plesk/9.php
Normal file
@@ -0,0 +1,338 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides PLESK client support
|
||||
*
|
||||
* @package Host
|
||||
* @category Plugins
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.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);
|
||||
}
|
||||
}
|
||||
?>
|
71
modules/host/classes/Model/Host/Server.php
Normal file
71
modules/host/classes/Model/Host/Server.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class supports OSB Web Hosting
|
||||
*
|
||||
* @package Host
|
||||
* @category Models
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Model_Host_Server extends ORM_OSB {
|
||||
// Host Server doesnt use the update column
|
||||
protected $_updated_column = FALSE;
|
||||
|
||||
protected $_serialize_column = array(
|
||||
'provision_plugin_data',
|
||||
);
|
||||
|
||||
/**
|
||||
* Return the object of the product plugin
|
||||
*/
|
||||
public function plugin($type='') {
|
||||
$c = Kohana::classname('Host_Plugin_'.$this->provision_plugin);
|
||||
|
||||
if (! $this->provision_plugin OR ! class_exists($c))
|
||||
return NULL;
|
||||
|
||||
$o = new $c($this);
|
||||
|
||||
return $type ? $o->$type : $o;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable the plugin to update
|
||||
*/
|
||||
public function admin_update() {
|
||||
if (is_null($plugin = $this->plugin()))
|
||||
return NULL;
|
||||
else
|
||||
return $plugin->admin_update();
|
||||
}
|
||||
|
||||
public function manage_button($t='') {
|
||||
static $k = '';
|
||||
|
||||
// If $k is already set, we've rendered this JS
|
||||
if (! $k) {
|
||||
$k = Random::char();
|
||||
Session::instance()->set('manage_button',$k);
|
||||
|
||||
Script::add(array('type'=>'stdin','data'=>'
|
||||
$(document).ready(function() {
|
||||
var x=0;
|
||||
$("button[name=submit]").click(function() {
|
||||
var t=$(this).val().split(":");
|
||||
if (x++) { alert("Session expired, please refresh the page!"); return false; }
|
||||
$.getJSON("'.URL::link('admin','host/ajaxmanage/'.$this->id,TRUE).'", { k: "'.$k.'",t: t[1] }, function(data) {
|
||||
$.each(data, function(key, val) { $("#"+key+"_"+t[0]+"_"+t[1]).val(val); });
|
||||
})
|
||||
.error(function() { alert("There was a problem with the request"); return false; })
|
||||
.success(function() { $("form[id=id_"+t[0]+"_"+t[1]+"]").submit(); });
|
||||
});
|
||||
});'
|
||||
));
|
||||
}
|
||||
|
||||
return is_null($this->plugin()) ? '' : $this->plugin()->admin_manage_button($this,$t);
|
||||
}
|
||||
}
|
||||
?>
|
14
modules/host/classes/Model/Host/Server/Affiliate.php
Normal file
14
modules/host/classes/Model/Host/Server/Affiliate.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class supports affiliates Host Server Configuration
|
||||
*
|
||||
* @package Host
|
||||
* @category Models
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Model_Host_Server_Affiliate extends ORM_OSB {
|
||||
}
|
||||
?>
|
25
modules/host/classes/Model/Product/Plugin/Host.php
Normal file
25
modules/host/classes/Model/Product/Plugin/Host.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class supports Host products
|
||||
*
|
||||
* @package Host
|
||||
* @category Models
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Model_Product_Plugin_Host extends Model_Product_Plugin {
|
||||
// @todo This model doesnt have a database table
|
||||
public function __construct() {
|
||||
}
|
||||
|
||||
// Our required abstract methods
|
||||
public function admin_update() {}
|
||||
public function feature_summary() {}
|
||||
|
||||
// @todo This is not used, but should be.
|
||||
public function order_features() {
|
||||
}
|
||||
}
|
||||
?>
|
79
modules/host/classes/Model/Service/Plugin/Host.php
Normal file
79
modules/host/classes/Model/Service/Plugin/Host.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class supports Services
|
||||
*
|
||||
* @package Host
|
||||
* @category Models
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Model_Service_Plugin_Host extends Model_Service_Plugin {
|
||||
protected $_table_name = 'service__hosting';
|
||||
protected $_created_column = FALSE;
|
||||
protected $_updated_column = FALSE;
|
||||
protected $_serialize_column = array(
|
||||
'server_data_date',
|
||||
);
|
||||
|
||||
// Relationships
|
||||
protected $_has_one = array(
|
||||
'domain_TLD'=>array('foreign_key'=>'id','far_key'=>'domain_tld_id'),
|
||||
'host_server'=>array('far_key'=>'host_server_id','foreign_key'=>'id'),
|
||||
);
|
||||
protected $_belongs_to = array(
|
||||
'service'=>array(),
|
||||
);
|
||||
|
||||
protected $_display_filters = array(
|
||||
'domain_name'=>array(
|
||||
array('strtoupper',array(':value')),
|
||||
),
|
||||
'host_expire'=>array(
|
||||
array('Config::date',array(':value')),
|
||||
),
|
||||
);
|
||||
|
||||
// Required abstract functions
|
||||
public function admin_update() {
|
||||
return '';
|
||||
}
|
||||
|
||||
public function expire() {
|
||||
return $this->host_expire;
|
||||
}
|
||||
|
||||
public function name() {
|
||||
return sprintf('%s.%s',$this->display('domain_name'),$this->domain_TLD->display('name'));
|
||||
}
|
||||
|
||||
public function service_view() {
|
||||
return View::factory('service/user/plugin/host/view')
|
||||
->set('so',$this);
|
||||
}
|
||||
|
||||
public function username_value() {
|
||||
return $this->host_username;
|
||||
}
|
||||
|
||||
public function password_value() {
|
||||
return $this->host_password;
|
||||
}
|
||||
|
||||
/**
|
||||
* This provides us with a manage button to jump to the hosting server
|
||||
* to manage the domain.
|
||||
*/
|
||||
public function manage_button($t='') {
|
||||
if (! parent::manage_button($t))
|
||||
return NULL;
|
||||
|
||||
// @todo Convert this to a Static_List display
|
||||
if ($this->service->queue == 'PROVISION')
|
||||
return _('To Be Provisioned');
|
||||
|
||||
return ($this->username_value() AND $this->password_value() AND $a=$this->host_server->plugin()) ? $a->manage_button($this,$t) : '';
|
||||
}
|
||||
}
|
||||
?>
|
6
modules/host/views/host/admin/plugin/plesk.php
Normal file
6
modules/host/views/host/admin/plugin/plesk.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<table class="box-left">
|
||||
<tr>
|
||||
<th>Shared IPs</th>
|
||||
<td><?php echo Form::input('provision_plugin_data[shared_ip]',$o->value('shared_ip')); ?></td>
|
||||
</tr>
|
||||
</table>
|
54
modules/host/views/host/admin/update.php
Normal file
54
modules/host/views/host/admin/update.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<!-- @todo NEEDS TO BE TRANSLATED -->
|
||||
<table width="100%">
|
||||
<?php if ($x=$hso->manage_button()) { ?>
|
||||
<tr>
|
||||
<td style="width: 40%;">Panel Login</td>
|
||||
<td style="width: 60%;" class="data"><?php echo $x; ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
<?php echo Form::open(); ?>
|
||||
<table class="box-left">
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<td><?php echo Form::input('name',$hso->name); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Active</th>
|
||||
<td><?php echo StaticList_YesNo::form('status',$hso->status); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Debug Mode</th>
|
||||
<td><?php echo StaticList_YesNo::form('debug',$hso->debug); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Notes</th>
|
||||
<td><?php echo Form::input('notes',$hso->notes); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Provision Plugin</th>
|
||||
<!-- @todo This should be a dynamic list -->
|
||||
<td><?php echo Form::input('provision_plugin',$hso->provision_plugin); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Max Accounts</th>
|
||||
<td><?php echo Form::input('max_accounts',$hso->max_accounts); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Manage URL</th>
|
||||
<td>
|
||||
<?php echo Form::input('manage_url',$hso->manage_url,array('size'=>($a=strlen($hso->manage_url)>50 ? $a : 50))); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Manage Admin</th>
|
||||
<td><?php echo Form::input('manage_username',$hso->manage_username); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Manage Password</th>
|
||||
<td><?php echo Form::input('manage_password',$hso->manage_password); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php if ($plugin_form) { echo '<br/>'.$plugin_form; } ?>
|
||||
<?php echo Form::submit('submit',_('Update'),array('class'=>'form_button')); ?>
|
||||
<?php echo Form::close(); ?>
|
33
modules/host/views/service/user/plugin/host/view.php
Normal file
33
modules/host/views/service/user/plugin/host/view.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<!-- //@todo To translate -->
|
||||
<table class="box-full">
|
||||
<tr>
|
||||
<td class="head" colspan="2">Service Details</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 50%">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td style="width: 40%;">Domain Name</td>
|
||||
<td style="width: 60%;" class="data"><?php echo $so->name(); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Hosting Expire</td>
|
||||
<td class="data"><?php echo $so->display('host_expire'); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td style="width: 50%">
|
||||
<table width="100%">
|
||||
<?php if ($x=$so->manage_button()) { ?>
|
||||
<tr>
|
||||
<td style="width: 40%;">Panel Login</td>
|
||||
<td style="width: 60%;" class="data"><?php echo $x; ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
Reference in New Issue
Block a user