Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 181 lines (161 sloc) 5.763 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
<?php
$xml=simplexml_load_file('/var/www/lighttpd/whmcs/modules/servers/virtuozzo/config.xml');

$value=(int)$_GET['userid'];
$productid=(int)$_GET['id'];
$hostingid=(int)$_GET['hostingid'];
$path=$xml->path;
$scriptpath=$path."lib/";

$host=$xml->host;
$user=$xml->user;
$pass=$xml->pass;
$db=$xml->db;
$conn=mysql_connect($host,$user,$pass) or die('Error connecting to mysql');
mysql_select_db($db);

if ($productid==0 && $hostingid==0 ){
$status=mysql_fetch_row(mysql_query("select domainstatus from tblhosting where userid=$value ORDER BY id DESC"));
}
else{
$status=mysql_fetch_row(mysql_query("select domainstatus from tblhosting where userid=$value and (id='$hostingid' or id='$productid')"));
}

function virtuozzo_ConfigOptions() {
# Should return an array of the module options for each product - maximum of 24
    $configarray = array(
# "Creation Node" => array( "Type" => "text", "Size" => "25", ),
);
return $configarray;
}
#function virtuozzo_AdminCustomButtonArray() {
# This function can define additional functions your module supports, the example here is a reboot button and then the reboot function is defined below
# $buttonarray=array("License Control Panel"=>"clicense");
# return $buttonarray;
#}


if ($status[0]=="Pending" || $status[0]=="Terminated"){
function virtuozzo_CreateAccount($params) {

global $scriptpath;
         #if (isEmpty($params)) {
                #return 'Check Hostname and Password fields';
         #}
chdir($scriptpath);
writeJson($params);
$output=shell_exec("ruby ".$scriptpath."virtuozzo.rb create .= 2>&1");
$successful=rtrim($output,"\0");
outputwind($successful);
if ($successful=="success") {
return "success";
} else {
mail('justin@eboundhost.com','virtuozzo error',$output);
return $output;
}
}
}
if ($status[0]=="Active"){
global $scriptpath;
function virtuozzo_AdminCustomButtonArray() {
        # This function can define additional functions your module supports, the example here is a reboot button and then the reboot function is defined below
        $buttonarray=array("License Control Panel"=>"clicense");
        return $buttonarray;

}

function virtuozzo_TerminateAccount($params) {
global $scriptpath;

chdir($scriptpath);
writeJson($params);
$output=shell_exec("ruby ".$scriptpath."virtuozzo.rb destroy .= 2>&1");
# Code to perform action goes here...
outputwind($output);
if ($output=='success') {
return "success";
} else {
mail('justin@eboundhost.com','virtuozzo error',$output);
return $output;

}
}


function virtuozzo_SuspendAccount($params) {
global $scriptpath;

chdir($scriptpath);
writeJson($params);
$output=shell_exec("ruby ".$scriptpath."virtuozzo.rb suspend .= 2>&1");
outputwind($output);
if ($output=='success') {
return "success";
} else {
mail('justin@eboundhost.com','virtuozzo error',$output);
return $output;
}
}
function virtuozzo_clicense($params) {
global $scriptpath;
chdir($scriptpath);
writeJson($params);
$output=shell_exec("ruby ".$scriptpath."virtuozzo.rb license .= 2>&1");
outputwind($output);
if ($output=='success') {
         return "success";
         }
else {
                mail('justin@eboundhost.com','virtuozzo error',$output);
                return $output;
         }
}
}

if ($status[0]=="Suspended"){
global $scriptpath;
        chdir($scriptpath);
function virtuozzo_UnsuspendAccount($params) {
chdir($scriptpath);
writeJson($params);
$output=shell_exec("ruby ".$scriptpath."virtuozzo.rb unsuspend .= 2>&1");
outputwind($output);
if ($output=='success') {
                return "success";
         } else {
mail('justin@eboundhost.com','virtuozzo error',$output);
                return $output;
         }
}

function virtuozzo_TerminateAccount($params) {

         chdir($scriptpath);
writeJson($params);
         $output=shell_exec("ruby ".$scriptpath."virtuozzo.rb destroy .= 2>&1");
         # Code to perform action goes here...
         outputwind($output);
         if ($output=='success') {
                return "success";
         } else {
                 mail('justin@eboundhost.com','virtuozzo error',$output);
                return $output;

         }
}
}

#--------------------------------------------------------------------------------------------------------------------
#Custom Functions
function isEmpty($params){
if ( empty($params["domain"]) || empty($params["password"]) || empty($params["serverip"]) ) {
return true;
}
}
function writeJson($params){
$jparam=json_encode($params);
$fp = fopen($scriptpath."data.json", 'w');
        fwrite($fp,$jparam);
        fclose($fp);
}
function outputwind($status){
$value=$_GET['userid'];
$productid=$_GET['id'];
if ($status=='success') {
echo "<BODY onLoad=\"javascript: alert('Zug Zug'); location='clientshosting.php?userid=$value&id=$productid';\">";
} else {
                 echo "<BODY onLoad=\"javascript: alert('Error: There was an error with the module, bother Justin'); location='clientshosting.php?userid=$value&id=$productid';\">";
}
}
?>
<script>
$(document).ready(function(){
//HIDE UNECCESSARY TABLES
$("tr:contains(Subscription ID),tr:contains(Username),tr:contains(Nameserver),tr:contains(Promotion),tr:contains(Overide),tr:contains(Auto-Terminate)").hide();
//HIDE LICENSE BUTTON IF FIELDS ARE FULL
if ( $("input[type=text][name=customfield[11]]").val() != "" || $("input[type=text][name=customfield[12]]").val() != "" ) {
$(":input[type=button][value=License Control Panel]").hide()
}
});
</script>
Something went wrong with that request. Please try again.