diff --git a/application/classes/lnapp/block.php b/application/classes/lnapp/block.php index 1d738473..810e1b21 100644 --- a/application/classes/lnapp/block.php +++ b/application/classes/lnapp/block.php @@ -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. diff --git a/application/classes/lnapp/script.php b/application/classes/lnapp/script.php index 103c2321..2620af1f 100644 --- a/application/classes/lnapp/script.php +++ b/application/classes/lnapp/script.php @@ -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); + } } ?> diff --git a/application/classes/ormosb.php b/application/classes/ormosb.php index e1a0b567..223ba7eb 100644 --- a/application/classes/ormosb.php +++ b/application/classes/ormosb.php @@ -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); diff --git a/modules/charge/classes/model/charge.php b/modules/charge/classes/model/charge.php index 5de1974f..8d51c382 100644 --- a/modules/charge/classes/model/charge.php +++ b/modules/charge/classes/model/charge.php @@ -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 */ diff --git a/modules/export/classes/model/export.php b/modules/export/classes/model/export.php index 2c008bff..f215121c 100644 --- a/modules/export/classes/model/export.php +++ b/modules/export/classes/model/export.php @@ -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(); diff --git a/modules/host/classes/controller/admin/host.php b/modules/host/classes/controller/admin/host.php new file mode 100644 index 00000000..7a9e9f39 --- /dev/null +++ b/modules/host/classes/controller/admin/host.php @@ -0,0 +1,79 @@ +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, + )); + } +} +?> diff --git a/modules/host/classes/controller/task/host.php b/modules/host/classes/controller/task/host.php index 8232f64c..752363ec 100644 --- a/modules/host/classes/controller/task/host.php +++ b/modules/host/classes/controller/task/host.php @@ -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); -*/ } } ?> diff --git a/modules/host/classes/host/plugin.php b/modules/host/classes/host/plugin.php new file mode 100644 index 00000000..138efe1a --- /dev/null +++ b/modules/host/classes/host/plugin.php @@ -0,0 +1,61 @@ + 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; + } + +} +?> diff --git a/modules/host/classes/host/plugin/plesk.php b/modules/host/classes/host/plugin/plesk.php new file mode 100644 index 00000000..f0e12e8f --- /dev/null +++ b/modules/host/classes/host/plugin/plesk.php @@ -0,0 +1,126 @@ +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)); + } +} +?> diff --git a/modules/host/classes/host/plugin/plesk/10.php b/modules/host/classes/host/plugin/plesk/10.php new file mode 100644 index 00000000..068faf65 --- /dev/null +++ b/modules/host/classes/host/plugin/plesk/10.php @@ -0,0 +1,246 @@ +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; + } +} +?> diff --git a/modules/host/classes/host/plugin/plesk/9.php b/modules/host/classes/host/plugin/plesk/9.php new file mode 100644 index 00000000..d1e08024 --- /dev/null +++ b/modules/host/classes/host/plugin/plesk/9.php @@ -0,0 +1,318 @@ +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); +*/ + } +} +?> diff --git a/modules/host/classes/model/host/server.php b/modules/host/classes/model/host/server.php index 45f6b753..ab357a04 100644 --- a/modules/host/classes/model/host/server.php +++ b/modules/host/classes/model/host/server.php @@ -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); } } ?> diff --git a/modules/host/classes/model/service/plugin/host.php b/modules/host/classes/model/service/plugin/host.php index 3a9d2a26..8e1c7330 100644 --- a/modules/host/classes/model/service/plugin/host.php +++ b/modules/host/classes/model/service/plugin/host.php @@ -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) : ''; } } ?> diff --git a/modules/host/classes/plesk.php b/modules/host/classes/plesk.php deleted file mode 100644 index b4ea47b2..00000000 --- a/modules/host/classes/plesk.php +++ /dev/null @@ -1,241 +0,0 @@ -_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)); - } -} -?> diff --git a/modules/host/classes/plesk/client.php b/modules/host/classes/plesk/client.php deleted file mode 100644 index 9ea580de..00000000 --- a/modules/host/classes/plesk/client.php +++ /dev/null @@ -1,105 +0,0 @@ -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; - } -} -?> diff --git a/modules/host/classes/plesk/domain.php b/modules/host/classes/plesk/domain.php deleted file mode 100644 index d8799d8a..00000000 --- a/modules/host/classes/plesk/domain.php +++ /dev/null @@ -1,56 +0,0 @@ -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; - } -} -?> diff --git a/modules/host/classes/service/host.php b/modules/host/classes/service/host.php deleted file mode 100644 index 0de19f16..00000000 --- a/modules/host/classes/service/host.php +++ /dev/null @@ -1,58 +0,0 @@ - 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; - } -} -?> diff --git a/modules/host/classes/service/host/plesk.php b/modules/host/classes/service/host/plesk.php deleted file mode 100644 index 74fa5a36..00000000 --- a/modules/host/classes/service/host/plesk.php +++ /dev/null @@ -1,35 +0,0 @@ -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; - } -} -?> diff --git a/modules/host/classes/service/host/tpp.php b/modules/host/classes/service/host/tpp.php deleted file mode 100644 index 9a8cc804..00000000 --- a/modules/host/classes/service/host/tpp.php +++ /dev/null @@ -1,34 +0,0 @@ -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; - } -} -?> diff --git a/modules/host/views/host/admin/plugin/plesk.php b/modules/host/views/host/admin/plugin/plesk.php new file mode 100644 index 00000000..b879567d --- /dev/null +++ b/modules/host/views/host/admin/plugin/plesk.php @@ -0,0 +1,6 @@ + + + + + +
Shared IPsvalue('shared_ip')); ?>
diff --git a/modules/host/views/host/admin/update.php b/modules/host/views/host/admin/update.php new file mode 100644 index 00000000..06d60aff --- /dev/null +++ b/modules/host/views/host/admin/update.php @@ -0,0 +1,54 @@ + + + manage_button()) { ?> + + + + + +
Panel Login
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Namename); ?>
Activestatus); ?>
Debug Modedebug); ?>
Notesnotes); ?>
Provision Pluginprovision_plugin); ?>
Max Accountsmax_accounts); ?>
Manage URL + manage_url,array('size'=>($a=strlen($hso->manage_url)>50 ? $a : 50))); ?> +
Manage Adminmanage_username); ?>
Manage Passwordmanage_password); ?>
+'.$plugin_form; } ?> +'form_button')); ?> + diff --git a/modules/product/classes/model/product.php b/modules/product/classes/model/product.php index 28241442..4e9a6e59 100644 --- a/modules/product/classes/model/product.php +++ b/modules/product/classes/model/product.php @@ -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 */ diff --git a/modules/service/classes/model/service/plugin.php b/modules/service/classes/model/service/plugin.php index 000ab6f9..b005c59b 100644 --- a/modules/service/classes/model/service/plugin.php +++ b/modules/service/classes/model/service/plugin.php @@ -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( diff --git a/modules/ssl/classes/model/service/plugin/ssl.php b/modules/ssl/classes/model/service/plugin/ssl.php index 0f4e25bd..46c45a14 100644 --- a/modules/ssl/classes/model/service/plugin/ssl.php +++ b/modules/ssl/classes/model/service/plugin/ssl.php @@ -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);