Skip to content

Commit

Permalink
Fixing ispconfig file
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed Sep 7, 2010
1 parent d3cdc43 commit c1023e1
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 32 deletions.
25 changes: 15 additions & 10 deletions admin/pages/servers.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public function __construct() {
$this->navlist[] = array("View All Servers", "server_go.png", "view");
$this->navlist[] = array("Add Server", "server_add.png", "add");

//@todo this foreach for something lighter
//@todo change this and user a simple array
/*
$files = $main->folderFiles(LINK."servers/");
require_once LINK.'servers/panel.php';
if(is_array($files) && count($files) > 0) {
Expand All @@ -29,7 +30,9 @@ public function __construct() {
}
}
}
$this->array_type = $values;
$values = array('whm'=>'cPanel/WHM');
*/
$this->array_type = array('whm'=>'cPanel/WHM','da'=>'Direct Admin', 'ispconfig'=>'ISPConfig3', 'test'=>'Test');
}

public function description() {
Expand Down Expand Up @@ -58,7 +61,8 @@ public function content() { # Displays the page
}
}
//$array['TYPE'] = $this->array_type;
$array['TYPE'] = $main->dropDown("type", $this->array_type, 0, 0);
//$array['TYPE'] = $main->dropDown("type", $this->array_type, 0, 0);
$array['TYPE'] = $main->createSelect("type", $this->array_type, '' ,array('onchange'=>'serverchange(this.value)'));

echo $style->replaceVar("tpl/servers/addserver.tpl", $array);
break;
Expand Down Expand Up @@ -93,15 +97,16 @@ public function content() { # Displays the page
$array['HASH'] = $data['accesshash'];
$array['ID'] = $data['id'];

$array['TYPE'] = $main->dropDown("type", $this->array_type, $data['type'], 0);
//$array['TYPE'] = $main->dropDown("type", $this->array_type, $data['type'], 0);
$array['TYPE'] = $main->createSelect("type", $this->array_type, $data['type'], array('onchange'=>'serverchange(this.value)'));

global $server;
$server_php = $server->loadServer($data['id']);
$server_status = $server_php->getServerStatus();

global $server;
$serverphp = $server->loadServer($data['id']);
$server_status = $serverphp->getServerStatus();
//Testing connection
$array['SERVER_STATUS'] = $server_php->testConnection();
echo $style->replaceVar("tpl/servers/viewserver.tpl", $array);
$array['SERVER_STATUS'] = $serverphp->testConnection();
echo $style->replaceVar("tpl/servers/viewserver.tpl", $array);
}
} else {
//@todo replace this queries
Expand Down
4 changes: 2 additions & 2 deletions includes/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ public function serverhash() {
require_once LINK.'servers/panel.php';
if (in_array($type, $server->getAvailablePanels())) {
require_once LINK ."servers/". $type .".php";
$server = new $type;
$server = new $type(-1);
if($server->hash) {
echo 0;
} else {
Expand All @@ -670,7 +670,7 @@ public function editserverhash() {
require_once LINK.'servers/panel.php';
if (in_array($type, $server->getAvailablePanels())) {
require_once LINK."servers/". $type .".php";
$serverphp = new $type();
$serverphp = new $type(-1);
if($serverphp->hash) {
echo 0;
} else {
Expand Down
40 changes: 25 additions & 15 deletions includes/servers/ispconfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,21 @@ class ispconfig extends Panel {

public function __construct($server_id = null) {
global $main;
parent::__construct($server_id);
$this->status = false;
if (!empty($server_id)) {
if ($this->_testConnection()) {
$this->status = true;
$main->addlog('ispconfig::construct testing connection ok');
//@todo fix me this is an ugly fix to avoid the useless calls in the ajax::editserverhash and ajax::serverhash
if ($server_id != '-1') {
parent::__construct($server_id);
$this->status = false;
if (!empty($server_id)) {
if ($this->_testConnection()) {
$this->status = true;
$main->addlog('ispconfig::construct Testing connection ok');
} else {
$main->addlog('ispconfig::construct Testing connection failed');
}
} else {
$main->addlog('ispconfig::construct testing connection failed');
$main->addlog('ispconfig::server id not provided');
}
}
$main->addlog('ispconfig::server id not provided');
}

public function getSessionId() {
Expand Down Expand Up @@ -66,13 +70,12 @@ public function load() {
global $main;
$my_session_id = $this->getSessionId();
//Try to check if there is already a soap client available
if (isset($this->_soap_client) && !empty($this->_soap_client) && !empty($my_session_id)) {
$main->addLog("ispconfig::load returning existent SOAP client");
/*if (isset($this->_soap_client) && !empty($this->_soap_client) && !empty($my_session_id)) {
$main->addLog("ispconfig::load Returning SOAP client already set");
return $this->_soap_client;
} else {
//$main->addlog($this->getServerId());
} else {*/
$data = $this->serverDetails($this->getServerId());
if (!empty($data) && is_array($data)) {
if (!empty($data) && is_array($data)) {
// $host_parts = parse_url($data['host']);
//$data['host'] = $host_parts['scheme'].$host_parts['host'].$host_parts['path'];

Expand All @@ -88,6 +91,7 @@ public function load() {
if ($this->debug) {echo 'Logged into remote server successfully. The SessionID is '.$session_id.'<br />';}
$main->addLog("ispconfig::load Session id $session_id");
$this->session_id = $session_id;
$this->_soap_client = $client;
return $client;
}
} catch (SoapFault $e) {
Expand All @@ -99,7 +103,7 @@ public function load() {
}
$main->addLog("ispconfig::load error seems that the server id is wrong");
return false;
}

}

/**
Expand Down Expand Up @@ -271,7 +275,7 @@ private function remote($action, $params = array()) {
break;
}
if ($this->debug) { echo 'Result: '; var_dump($soap_result); echo '------------------>><br />';}
$main->addLog("Result of ispconfig:: $action - ".print_r($soap_result,1));
$main->addLog("Result of ispconfig:: $action : ".print_r($soap_result,1));
return $soap_result;
} catch (SoapFault $e) {
$main->addLog("ispconfig::remote Soap error: ".$e->getMessage());
Expand Down Expand Up @@ -915,7 +919,11 @@ public function getSiteStatus($order_id) {
}

public function getServerStatus() {
global $main;
$main->addlog("ispconfig::getServerStatus");
if ($this->status) {

$main->addlog("ispconfig::getServerStatus status = true");
//we should use only the load function
$server_params['server_id'] = $this->getServerId();
$server_params['section'] = 'web';
Expand All @@ -928,6 +936,8 @@ public function getServerStatus() {
$result = false;
}
return $result;
} else {
$main->addlog("ispconfig::getServerStatus status = false");
}
return false;
}
Expand Down
4 changes: 3 additions & 1 deletion includes/servers/panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ public function GenPassword() {
public function serverDetails($server) {
global $db, $main;
if (!empty($server)) {
$sql = "SELECT * FROM `<PRE>servers` WHERE `id` = '{$db->strip($server)}'";
$server = $db->strip($server);
$sql = "SELECT * FROM <PRE>servers WHERE id = $server";
$query = $db->query($sql);
if($db->num_rows($query) > 0) {
return $db->fetch_array($query, 'ASSOC');
}
} else {
$main->addlog('panel::serverDetails server id is not set');
return false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions includes/tpl/orderform/orderform.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,9 @@ function nextstep() {
//Check if an invoice is generated
$.get("<AJAX>function=ispaid", function(invoice_id) {
if(invoice_id != "") {
//window.location = "../client/?page=invoices&iid="+invoice_id;
window.location = "../client/?page=invoices&iid="+invoice_id;
} else {
//window.location = "../client/?page=invoices";
window.location = "../client/?page=invoices";
}
});
Expand Down
5 changes: 4 additions & 1 deletion includes/tpl/servers/addserver.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ $(window).load(function () {

<tr>
<td valign="top">Type:</td>
<td><select name="type" id="type" onchange="serverchange(this.value)">%TYPE%</select> <a title="The Server Type. This is the Control Panel that your server is running.<br /><i>eg: cPanel/WHM</i>" class="tooltip"><img src="<URL>themes/icons/information.png" /></a></td>
<td>
%TYPE%

<a title="The Server Type. This is the Control Panel that your server is running.<br /><i>eg: cPanel/WHM</i>" class="tooltip"><img src="<URL>themes/icons/information.png" /></a></td>
</tr>

<tr>
Expand Down
2 changes: 1 addition & 1 deletion includes/tpl/servers/viewserver.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ $(window).load(function () {
<tr>
<td valign="top">Type:</td>
<td>
<select name="type" id="type" onchange="serverchange(this.value)">%TYPE%</select>
%TYPE%
<a title="The control panel that this server is running." class="tooltip">
<img src="<URL>themes/icons/information.png" /></a>
</td>
Expand Down

0 comments on commit c1023e1

Please sign in to comment.