Working on HOST SERVER and improvements to ORMOSB

This commit is contained in:
Deon George 2012-06-27 00:28:18 +10:00
parent f50bea38a3
commit a0e1714358
24 changed files with 1007 additions and 645 deletions

View File

@ -24,6 +24,10 @@ class lnApp_Block extends HTMLRender {
* @param array Block attributes
*/
public static function add($block,$prepend=FALSE) {
// Any body objects should be converted to a string, so that any calls to Style/Script are processed
if (isset($block['body']))
$block['body'] = (string)$block['body'];
parent::add($block);
// Detect any style sheets.

View File

@ -15,6 +15,7 @@ class lnApp_Script extends HTMLRender {
protected static $_spacer = "\n";
protected static $_required_keys = array('type','data');
protected static $_unique_vals = array('file'=>'type');
protected static $_rendered = FALSE;
/**
* Return an instance of this class
@ -47,7 +48,15 @@ class lnApp_Script extends HTMLRender {
}
}
static::$_rendered = TRUE;
return $foutput.static::$_spacer.$soutput;
}
public static function add($item,$prepend=FALSE,$x='') {
if (static::$_rendered)
throw new Kohana_Exception('Already rendered?');
return parent::add($item,$prepend);
}
}
?>

View File

@ -96,18 +96,6 @@ abstract class ORMOSB extends ORM {
return TRUE;
}
// @todo Change this to be called by array_blob functions
public static function serialize_array(ORM $model,$field,$value) {
if (is_null($value))
return TRUE;
if (! is_array($value))
return FALSE;
$model->_changed[$field] = $field;
$model->$field = serialize($value);
}
public function __get($column) {
if (array_key_exists($column,$this->_table_columns)) {
@ -166,15 +154,20 @@ abstract class ORMOSB extends ORM {
}
public function save(Validation $validation = NULL) {
// Find any fields that have changed, and that are blobs, and encode them.
// Find any fields that have changed, and process them.
if ($this->_changed)
foreach ($this->_changed as $c)
// Any fields that are blobs, and encode them.
if ($this->_table_columns[$c]['data_type'] == 'blob') {
$this->_object[$c] = $this->blob($this->_object[$c],TRUE);
// We need to reset our auto_convert flag
if (isset($this->_table_columns[$c]['auto_convert']))
$this->_table_columns[$c]['auto_convert'] = FALSE;
// Any fields that should be seriailzed, we'll do that.
} elseif (is_array($this->_object[$c]) AND in_array($c,$this->_serialize_column)) {
$this->_object[$c] = serialize($this->_object[$c]);
}
return parent::save($validation);

View File

@ -13,6 +13,9 @@
class Model_Charge extends ORMOSB {
// Charge doesnt use the update column
protected $_updated_column = FALSE;
protected $_serialize_column = array(
'attributes',
);
protected $_belongs_to = array(
'account'=>array(),
@ -27,14 +30,6 @@ class Model_Charge extends ORMOSB {
),
);
public function rules() {
return array_merge(parent::rules(),array(
'attributes'=>array(
array('ORMOSB::serialize_array',array(':model',':field',':value')),
),
));
}
/**
* Render some details for specific calls, eg: invoice
*/

View File

@ -11,13 +11,9 @@
* @license http://dev.osbill.net/license.html
*/
class Model_Export extends ORMOSB {
public function rules() {
return array_merge(parent::rules(),array(
'map_data'=>array(
array('ORMOSB::serialize_array',array(':model',':field',':value')),
),
));
}
protected $_serialize_column = array(
'map_data',
);
public function list_itemsnoexport() {
$result = array();

View File

@ -0,0 +1,79 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides Host Server functions
*
* @package OSB
* @subpackage HostServer
* @category Controllers/Admin
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.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'=>'admin/host/update/'),
'name'=>array('label'=>'Details'),
),
array(
'page'=>TRUE,
'type'=>'select',
'form'=>'admin/host/update/',
)),
));
}
public function action_update() {
$hso = ORM::factory('host_server',$this->request->param('id'));
$output = '';
if (! $hso->loaded())
Request::current()->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,
));
}
}
?>

View File

@ -10,9 +10,8 @@
* @license http://dev.leenooks.net/license.html
*/
class Controller_Task_Host extends Controller_Task {
// Host Server Object
private $hs;
private $so;
private $so; // Service Object
private $hpo; //Host Server Object
public function __construct(Request $request, Response $response) {
parent::__construct($request,$response);
@ -21,6 +20,7 @@ class Controller_Task_Host extends Controller_Task {
switch (Request::current()->action()) {
case 'getclient':
case 'getdomain':
case 'getreseller':
case 'gettraffic':
case 'provision':
$this->so = ORM::factory('service',$this->request->param('id'));
@ -28,8 +28,7 @@ class Controller_Task_Host extends Controller_Task {
if (! $this->so->loaded())
throw new Kohana_Exception('Unknown service :sid',array(':sid'=>$this->request->param('id')));
$hso = $this->so->plugin()->host_server;
$this->hs = new $hso->provision_plugin($hso);
$this->hpo = $this->so->plugin()->host_server->plugin();
break;
}
@ -50,57 +49,63 @@ class Controller_Task_Host extends Controller_Task {
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->hs->cmd_getclient($this->so);
$p = $this->so->plugin();
$result = $this->hpo->cmd_getclient($this->so);
if ($result->loaded()) {
if (! isset($p->server_data[$p->host_server_id]['c']) OR (md5($p->server_data[$p->host_server_id]['c']) != md5(serialize($result)))) {
echo "WARNING: data changed on server";
$this->save('c',$result);
} else
echo "NOTE: data same on server";
if ($result->loaded())
$this->verify('c',$result);
} else
print_r($result);
print_r($result);
}
/**
* Get Client Details from Host Server
*/
public function action_getdomain() {
$result = $this->hs->cmd_getdomain($this->so);
$p = $this->so->plugin();
$result = $this->hpo->cmd_getdomain($this->so);
if ($result->loaded()) {
if (! isset($p->server_data[$p->host_server_id]['d']) OR (md5($p->server_data[$p->host_server_id]['d']) != md5(serialize($result)))) {
echo "WARNING: data changed on server";
$this->save('d',$result);
} else
echo "NOTE: data same on server";
if ($result->loaded())
$this->verify('d',$result);
} else
print_r($result);
print_r($result);
}
/**
* Get Reseller
*/
public function action_getreseller() {
$result = $this->hpo->cmd_getreseller($this->so);
print_r($result);
}
/**
* Get Domain Traffic
*/
public function action_gettraffic() {
$sid = $this->request->param('id');
$result = $this->hpo->cmd_gettraffic($this->so);
$result = $this->hs->cmd_gettraffic(ORM::factory('service',$sid));
if ($result->gen_info)
print_r($result->gen_info->as_array());
else
print_r((string)$result);
print_r($result);
}
/**
* List services that need to be provisioned
* @todo This needs to be reviewed for functionality
*/
public function action_provisionlist() {
$mode = $this->request->param('id');
@ -117,7 +122,7 @@ class Controller_Task_Host extends Controller_Task {
if (! $so->product->avail_category OR ! preg_match('/^a:/',$so->product->avail_category))
continue;
$pc = unserialize($so->product->avail_category);
$pc = unserialize($so->product->avail_category);
if (! array_intersect($pc,array_keys($cats)))
continue;
@ -137,37 +142,11 @@ class Controller_Task_Host extends Controller_Task {
}
/**
* Add a domain for the client
*
* @param int $id Hosting ID (in OSB)
* @return unknown_type
* Provision a Hosting Service
*/
public function action_provision() {
$sid = $this->request->param('id');
$so = ORM::factory('service',$sid);
// Provision Account
// @todo Need a test to see if an account alerady exists.
/*
$result = $this->hs->add_client($so);
$result = $this->hpo->provision($this->so);
print_r((string)$result);
// 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);
*/
}
}
?>

View File

@ -0,0 +1,61 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides HOST Plugin Support
*
* @package OSB
* @subpackage Host Plugins
* @category Plugins
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.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,
);
public function serialize() {
return serialize($this->_object);
}
public function unserialize($s) {
$this->_object = unserialize($s);
}
public function __get($key) {
return isset($this->_object[$key]) ? $this->_object[$key] : NULL;
}
// Required abstract classes
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;
}
}
?>

View File

@ -0,0 +1,126 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides PLESK support
*
* @package OSB
* @subpackage Plugins/Plesk
* @category Plugins
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.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;
private $_loaded;
// 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 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->xml = XML::factory(null,'plesk');
$this->packet = $this->xml->add_node('packet','',array('version'=>$this->protocol));
}
protected function server_command(XML $xml) {
// We need to find out the command key, so we can get the status result.
if (count($a=array_keys($xml->packet->as_array())) != 1)
throw new Kohana_Exception('XML command malformed? :xml',array(':xml'=>(string)$xml));
$key = array_shift($a);
if (count($a=array_keys($xml->packet->$key->as_array())) != 1)
throw new Kohana_Exception('XML command malformed? :xml',array(':xml'=>(string)$xml));
$get = array_shift($a);
$request = Request::factory(sprintf('%s/%s',$this->hso->manage_url,$this->path))
->method('POST');
$request->get_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();
$result = XML::factory(null,'plesk',$response->body());
if ($result->status->value() == 'ok')
$this->_loaded = TRUE;
return $result;
}
protected function collapse(XML $xml) {
$result = array();
foreach ($xml->as_array() as $j=>$k) {
$v = $xml->$j->value();
if (count($k) > 1) {
foreach ($xml->get($j,1) as $k)
if (isset($k['name'][0]))
$result[$j][$k['name'][0]] = (isset($k['value'][0]) ? $k['value'][0] : '');
else
$result[$j][] = $k;
} elseif (! is_null($v))
$result[$j] = $v;
else
$result[$j] = $this->collapse($xml->$j);
}
if (array_key_exists('name',$result) AND array_key_exists('value',$result))
$result = array($result['name']=>$result['value']);
return $result;
}
public function loaded() {
return $this->_loaded;
}
private function render(XML $xml) {
return preg_replace('/<\/?plesk>/','',(string)$xml->render(FALSE));
}
}
?>

View File

@ -0,0 +1,246 @@
<?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';
private $_loaded = FALSE;
// @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_account);
$dataset = $get->add_node('dataset');
foreach ($items as $k)
$dataset->add_node($k);
$result = $this->server_command($this->xml);
if (! $this->loaded())
throw new Kohana_Exception('Unable to get PLESK Client data - Error :error',array(':error'=>(string)$result));
$this->_object['id'] = $result->id->value();
foreach ($items as $k)
foreach ($result->get($k) as $a=>$b)
$this->_object[$k] = $this->collapse($b);
return $this;
}
/**
* 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);
$result = $this->server_command($this->xml);
if (! $this->loaded())
throw new Kohana_Exception('Unable to get PLESK Domain data - Error :error',array(':error'=>(string)$result));
$this->_object['id'] = $result->id->value();
foreach ($items as $k)
foreach ($result->get($k) as $a=>$b)
$this->_object[$k] = $this->collapse($b);
return $this;
}
/**
* 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);
$result = $this->server_command($this->xml);
if (! $this->loaded())
throw new Kohana_Exception('Unable to get PLESK Reseller data - Error :error',array(':error'=>(string)$result));
$this->_object['id'] = $result->id->value();
foreach ($items as $k)
foreach ($result->get($k) as $a=>$b)
$this->_object[$k] = $this->collapse($b);
return $this;
}
/**
* Get Domain Traffic
*/
public function cmd_gettraffic(Model_Service $so) {
throw new Kohana_Exception('Not Implemented');
}
/**
* Provision a hosting service
* @todo To implement
*/
public function provision(Model_Service $so) {
/*
$ro = $this->cmd_getreseller($so);
// Make sure our reseller exists
if ($ro AND ! $ro->id)
throw new Kohana_Exception('Add Reseller - Not Implemented');
$result = $this->add_client($so);
if (! $result->loaded())
throw new Kohana_Exception('Failed to Add Client?');
*/
// Provision Domain
$result = $this->add_domain($so);
if (! $this->loaded())
throw new Kohana_Exception('Failed to Add Domain?');
print_r(array('r'=>(string)$result,'t'=>$this));
// Create Client Account
throw new Kohana_Exception('Not Implemented');
/*
// 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);
// 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);
*/
}
public function add_client(Model_Service $so) {
$ro = $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_account);
$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);
$result = $this->server_command($this->xml);
if (! $this->loaded())
throw new Kohana_Exception('Unable to add PLESK Client - Error :error',array(':error'=>(string)$result));
return $result;
}
public function add_domain(Model_Service $so) {
$plan = 'Default Domain';
$co = $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?');
$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);
$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);
$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);
$result = $this->server_command($this->xml);
if (! $this->loaded())
throw new Kohana_Exception('Unable to add PLESK Domain - Error :error',array(':error'=>(string)$result));
return $result;
}
}
?>

View File

@ -0,0 +1,318 @@
<?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';
private $_loaded = FALSE;
// @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_account);
$dataset = $get->add_node('dataset');
foreach ($items as $k)
$dataset->add_node($k);
$result = $this->server_command($this->xml);
if (! $this->loaded())
throw new Kohana_Exception('Unable to get PLESK Client data - Error :error',array(':error'=>(string)$result));
foreach ($items as $k)
foreach ($result->get($k) as $a=>$b)
$this->_object[$k] = $this->collapse($b);
return $this;
}
/**
* 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);
$result = $this->server_command($this->xml);
if (! $this->loaded())
throw new Kohana_Exception('Unable to get PLESK Domain data - Error :error',array(':error'=>(string)$result));
foreach ($items as $k)
foreach ($result->get($k) as $a=>$b)
$this->_object[$k] = $this->collapse($b);
return $this;
}
/**
* 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');
$result = $this->server_command($this->xml);
if (! $this->loaded())
throw new Kohana_Exception('Unable to get PLESK Traffic data - Error :error',array(':error'=>(string)$result));
$this->_object = $this->collapse($result);
return $this;
}
/**
* 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);
*/
}
}
?>

View File

@ -14,21 +14,59 @@ class Model_Host_Server extends ORMOSB {
// Host Server doesnt use the update column
protected $_updated_column = FALSE;
public function manage_button(Model_Service_Plugin_Host $spho,$t) {
$c = sprintf('Service_Host_%s',$this->provision_plugin);
if (! class_exists($c))
return '';
protected $_serialize_column = array(
'provision_plugin_data',
);
$po = new $c($this->id);
/**
* Return the object of the product plugin
*/
public function plugin($type='') {
$c = sprintf('Host_Plugin_%s',$this->provision_plugin);
return $po->manage_button($spho,$t);
if (! $this->provision_plugin OR ! class_exists($c))
return NULL;
$o = new $c($this);
return $type ? $o->$type : $o;
}
public function prov_plugin_data() {
if (! $this->provision_plugin_data)
throw new Kohana_Exception('No plugin configuration data');
/**
* Enable the plugin to update
*/
public function admin_update() {
if (is_null($plugin = $this->plugin()))
return NULL;
else
return $plugin->admin_update();
}
return unserialize($this->provision_plugin_data);
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::site('admin/host/ajaxmanage/'.$this->id).'", { 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);
}
}
?>

View File

@ -36,14 +36,6 @@ class Model_Service_Plugin_Host extends Model_Service_Plugin {
),
);
public function rules() {
return array_merge(parent::rules(),array(
'server_data_date'=>array(
array('ORMOSB::serialize_array',array(':model',':field',':value')),
),
));
}
// Required abstract functions
public function admin_update() {
return '';
@ -77,7 +69,7 @@ class Model_Service_Plugin_Host extends Model_Service_Plugin {
if ($this->service->queue == 'PROVISION')
return _('To Be Provisioned');
return ($this->username_value() AND $this->password_value()) ? $this->host_server->manage_button($this,$t) : '';
return ($this->username_value() AND $this->password_value()) ? $this->host_server->plugin()->manage_button($this,$t) : '';
}
}
?>

View File

@ -1,241 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides PLESK support
*
* @package OSB
* @subpackage Plugins/Plesk
* @category Plugins
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Plesk implements Serializable {
private $protocol = '1.6.0.1';
private $path = 'enterprise/control/agent.php';
// Service Object
protected $hso;
protected $packet;
protected $xml;
protected $_object;
public function serialize() {
return serialize($this->_object);
}
public function unserialize($s) {
$this->_object = unserialize($s);
}
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,
);
public function __construct(Model_Host_Server $hso) {
$this->hso = $hso;
$this->xml = XML::factory(null,'plesk');
$this->packet = $this->xml->add_node('packet','',array('version'=>$this->protocol));
}
protected function server_command(XML $xml) {
if (count($a=array_keys($xml->packet->as_array())) != 1)
throw kohana_exception('XML command malformed?');
// We need to find out the command key, so we can get the status result.
$key = array_shift($a);
$hs = $this->hso->prov_plugin_data();
$request = Request::factory(sprintf('%s/%s',$this->hso->manage_url,$this->path))
->method('POST');
$request->get_client()->options(Arr::merge($this->curlopts,array(
CURLOPT_HTTPHEADER => array(
'HTTP_AUTH_LOGIN: '.$hs['user'],
'HTTP_AUTH_PASSWD: '.$hs['pass'],
'Content-Type: text/xml',
),
CURLOPT_POSTFIELDS => $this->render($xml),
)));
$response = $request->execute();
$result = XML::factory(null,'plesk',$response->body());
return $result;
return ($result->$key->get->result->status->value() == 'ok') ? $result->data : $result;
}
protected function collapse(XML $xml) {
$result = array();
foreach ($xml->as_array() as $j=>$k) {
$v = $xml->$j->value();
if (count($k) > 1) {
foreach ($xml->get($j,1) as $k)
if (isset($k['name'][0]))
$result[$j][$k['name'][0]] = (isset($k['value'][0]) ? $k['value'][0] : '');
else
$result[$j][] = $k;
} elseif (! is_null($v))
$result[$j] = $v;
else
$result[$j] = $this->collapse($xml->$j);
}
if (array_key_exists('name',$result) AND array_key_exists('value',$result))
$result = array($result['name']=>$result['value']);
return $result;
}
/**
* Get a Client Configuration
*/
public function cmd_getclient(Model_Service $so) {
$pco = new Plesk_Client($this->hso);
return $pco->cmd_getclient($so);
}
/**
* Get a Server Configuration
*/
public function cmd_getdomain(Model_Service $so) {
$pdo = new Plesk_Domain($this->hso);
return $pdo->cmd_getdomain($so);
}
/**
* Get Domain Traffic
*/
public function cmd_gettraffic(Model_Service $so) {
$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()));
# $filter->add_node('id',1);
# $get->add_node('since_date','2012-04-01');
# $get->add_node('end_date','2012-04-02');
return $this->server_command($this->xml);
}
/**
* Add a new client to the host server
*/
public function add_client(Model_Service $so) {
$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);
}
public function add_service(Model_Service $so) {
// @todo This should come from the DB.
$host_ip = '111.67.13.20';
$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
public function setlimits(Model_Service $so) {
$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);
}
public function setip($id) {
$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);
}
public function disablemail($id) {
$client = $this->packet->add_node('mail');
$disable = $client->add_node('disable');
$disable->add_node('domain_id',$id);
return $this->server_command($this->xml);
}
private function render(XML $xml) {
return preg_replace('/<\/?plesk>/','',(string)$xml->render(FALSE));
}
}
?>

View File

@ -1,105 +0,0 @@
<?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 Plesk_Client extends Plesk {
private $_loaded = FALSE;
// @todo Get these default "templates" values out of the DB
private $_template = 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(
'111.67.13.20'=>'shared',
),
);
/**
* Get a Client Configuration
*/
public function cmd_getclient(Model_Service $so) {
$items = array_keys($this->_template);
$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);
$result = $this->server_command($this->xml);
if ($result->client->get->result->status->value() != 'ok')
throw new Kohana_Exception('Unable to get PLESK Client data');
foreach ($items as $k)
foreach ($result->get($k) as $a=>$b)
$this->_object[$k] = $this->collapse($b);
$this->_loaded = TRUE;
return $this;
}
public function loaded() {
return $this->_loaded;
}
}
?>

View File

@ -1,56 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides PLESK domain support
*
* @package OSB
* @subpackage Plugins/Plesk
* @category Plugins
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Plesk_Domain extends Plesk {
private $_loaded = FALSE;
// @todo Get these default "templates" values out of the DB
private $_template = array(
'gen_info'=>array(),
'hosting'=>array(),
'limits'=>array(),
'user'=>array(),
);
/**
* Get a Client Configuration
*/
public function cmd_getdomain(Model_Service $so) {
$items = array_keys($this->_template);
$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);
$result = $this->server_command($this->xml);
if ($result->domain->get->result->status->value() != 'ok')
throw new Kohana_Exception('Unable to get PLESK Domain data');
foreach ($items as $k)
foreach ($result->get($k) as $a=>$b)
$this->_object[$k] = $this->collapse($b);
$this->_loaded = TRUE;
return $this;
}
public function loaded() {
return $this->_loaded;
}
}
?>

View File

@ -1,58 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class will take care of Domain Registrars.
*
* @package OSB
* @subpackage Service
* @category Helpers
* @author Deon George
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
abstract class Service_Host {
protected $so;
protected $fetchresult = NULL;
// @todo These options should be centrally defined
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,
);
/**
* Setup this class. We need to get our supplier details out of the database.
*/
public function __construct($sid) {
$this->so = ORM::factory('host_server',$sid);
}
/**
* Our HTML button that will enable us to manage this domain.
*
* @param so Our Service Object
*/
abstract public function manage_button(Model_Service_Plugin_Host $spho,$t);
/**
* Return an instance of this class
*
* @return HeadImage
*/
public static function instance($supplier) {
$sc = sprintf('%s_%s',get_called_class(),$supplier);
if (! class_exists($sc))
throw new Kohana_Exception('Class doesnt exist for :supplier',array(':supplier'=>$supplier));
else
return new $sc;
}
}
?>

View File

@ -1,35 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class is able to interact with PLESK
*
* @package OSB
* @subpackage Service
* @category Helpers
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Service_Host_Plesk extends Service_Host {
private $login_acnt_field = '';
private $login_user_field = 'login_name';
private $login_pass_field = 'passwd';
// Our required abstract classes
public function manage_button(Model_Service_Plugin_Host $spho,$t) {
$debug = FALSE;
$output = '';
$output .= Form::open(
$debug ? 'debug/site' : sprintf('%s/%s',$this->so->manage_url,'login_up.php3'),
array('target'=>'w24','method'=>'post','id'=>sprintf('id_%s_%s',$spho->service_id,$t))
);
$output .= Form::input($this->login_user_field,$spho->username_value(),array('type'=>'hidden','id'=>sprintf('u_%s_%s',$spho->service_id,$t)));
$output .= Form::input($this->login_pass_field,substr(md5($spho->password_value()),0,8),array('type'=>'hidden','id'=>sprintf('p_%s_%s',$spho->service_id,$t)));
$output .= Form::close();
$output .= Form::button('submit',_('Manage'),array('class'=>'form_button','value'=>sprintf('%s:%s',$spho->service_id,$t)));
return $output;
}
}
?>

View File

@ -1,34 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class is able to interact with TPP
*
* @package OSB
* @subpackage Service
* @category Helpers
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Service_Host_TPP extends Service_Host {
private $login_acnt_field = '';
private $login_user_field = 'login';
private $login_pass_field = 'password';
// Our required abstract classes
public function manage_button($u,$p,$d) {
$output = '';
$output .= Form::open(
sprintf('%s/%s',$this->so->whitelabel_url,'execute/logon'),
array('target'=>'tpp','method'=>'post')
);
$output .= Form::input($this->login_user_field,$u,array('type'=>'hidden'));
$output .= Form::input($this->login_pass_field,$p,array('type'=>'hidden'));
$output .= Form::button('submit',_('Manage'),array('class'=>'form_button'));
$output .= Form::close();
return $output;
}
}
?>

View 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>

View 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(); ?>

View File

@ -46,14 +46,6 @@ class Model_Product extends ORMOSB {
'price_group',
);
public function rules() {
return array_merge(parent::rules(),array(
'price_group'=>array(
array('ORMOSB::serialize_array',array(':model',':field',':value')),
),
));
}
/**
* Return the object of the product plugin
*/

View File

@ -57,7 +57,7 @@ abstract class Model_Service_Plugin extends ORMOSB {
var x=0;
$("button[name=submit]").click(function() {
var t=$(this).val().split(":");
if (x++) { alert("Please refresh the page"); return false; }
if (x++) { alert("Session expired, please refresh the page!"); return false; }
$.getJSON("'.URL::site('user/service/ajaxmanage/'.$this->service_id).'", { 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(

View File

@ -32,6 +32,9 @@ class Model_Service_Plugin_SSL extends Model_Service_Plugin {
);
// Required abstract functions
public function username_value() {} // Not used
public function password_value() {} // Not used
public function service_view() {
return View::factory('service/user/plugin/ssl/view')
->set('so',$this);