action()) { case 'getclient': case 'getdomain': case 'getreseller': case 'gettraffic': case 'provision': $this->so = ORM::factory('service',$this->request->param('id')); if (! $this->so->loaded()) throw new Kohana_Exception('Unknown service :sid',array(':sid'=>$this->request->param('id'))); $this->hpo = $this->so->plugin()->host_server->plugin(); break; } } public function save($index,$result) { $p = $this->so->plugin(); // We need to use a new var to avoid Indirect modification of overloaded property errors. $x = is_null($p->server_data) ? array() : $p->server_data; $x[$p->host_server_id][$index] = serialize($result); $p->server_data = $x; $x = is_null($p->server_data_date) ? array() : $p->server_data_date; $x[$p->host_server_id][$index] = time(); $p->server_data_date = $x; return $p->save(); } private function verify($index,$result,$save=TRUE) { $p = $this->so->plugin(); if (! isset($p->server_data[$p->host_server_id][$index]) OR (md5($p->server_data[$p->host_server_id][$index]) != md5(serialize($result)))) { if ($save) $this->save('c',$result); return FALSE; } else return TRUE; } /** * Get Client Details from Host Server */ public function action_getclient() { $result = $this->hpo->cmd_getclient($this->so); if ($result->loaded()) $this->verify('c',$result); print_r($result); } /** * Get Client Details from Host Server */ public function action_getdomain() { $result = $this->hpo->cmd_getdomain($this->so); if ($result->loaded()) $this->verify('d',$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() { $result = $this->hpo->cmd_gettraffic($this->so); 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'); $cats = array(); if ($mode) $cats = ORM::factory('product_category')->list_bylistgroup($mode); foreach (ORM::Factory('service')->list_provision()->find_all() as $so) { $pc = array(); // Limit to show only those by the requested category. if ($cats) { if (! $so->product->avail_category OR ! preg_match('/^a:/',$so->product->avail_category)) continue; $pc = unserialize($so->product->avail_category); if (! array_intersect($pc,array_keys($cats))) continue; } echo $so->id(); switch ($mode) { case 'host': printf(' %s %s %s',$so->plugin(),$so->plugin()->host_server->name,$so->service_name()); break; default: } echo "\n"; } } /** * Provision a Hosting Service */ public function action_provision() { $result = $this->hpo->provision($this->so); print_r((string)$result); } } ?>