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

@@ -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);
*/
}
}
?>