WHMCS Ahsay Plugin

<?php /* V1.0 Lite Version; Only Support suspend and unsuspend.  Installation and Setup -copy this file into <whmcsroot>/modules/servers/ahsayosb. You will have to create the folder ahsayosb in lower case.

-Add a new server and in Server Details select Ahsayosb as the type and put in your system administrator username and password. The Access Hash is not used and might be used for advanced settings in the future.
-If you select Secure the module will use ssl for connections (Highly Recommended)
-You can ignore all the Nameservers settings.

-Create a new product or modify an existing osb product and under module settings set the Modlue Name to Ahsayosb
-There are options for Language/Client Type/Bandwidth. These all can be ignored right now because this version only supports Suspend and Unsuspend.

-In the user account under the Products/Services make sure the correct username is listed the password can be ignored.

*/
$apiurl = "/obs/api/";

$auth = "AuthUser.do";
$adduser = "AddUser.do";
$moduser = "ModifyUser.do";
$removeuser = "RemoveUser.do";
$listuser = "ListUsers.do";
$getuser = "GetUser.do";

function ahsayosb_ConfigOptions() {
 # Should return an array of the module options for each product - maximum of 24
    $configarray = array(
  "Default Language" => array("Type" => "dropdown", "Options" => "English-en, Czech-cs, Danish-da, German-de, Spanish-es, French-fr,Finnish-fi,Icelandic-is,Italian-it,Japanese-ja,Lithuanian-lt,Dutch-nl,Norwegian-no,Portuguese-pt_PT, Slovenian-sl, Swedish-sv, Chinese(Simplified)-zh_CN, Chinese(Traditional)-zh_TW"),
  "Client Type" => array("Type" => "dropdown", "Options" => "OBM, ACB", "Description" => ""),
  "Bandwidth" => array("Type" => "text", "Size" => "5", "Description" => "MB, 0 = Unlimited"),
  "Fast Terminate" => array("Type" => "yesno", "Description" => "If enabled accounts will be instantly terminated"),
  "Add Group" => array("Type" => "text", "Size" => "7", "Description" => "Ad group name.(Only for ACB)"),
  //"Package Name" => array( "Type" => "text", "Size" => "25", ),
  //"Web Space Quota" => array( "Type" => "text", "Size" => "5", "Description" => "MB" ),
  //"FTP Access" => array( "Type" => "yesno", "Description" => "Tick to grant access" ),
     //"Subdomains" => array( "Type" => "dropdown", "Options" => "1,2,5,10,25,50,Unlimited"),
 );
 return $configarray;
}

function ahsayosb_CreateAccount($params) {

    # ** The variables listed below are passed into all module functions **

    $serviceid = $params["serviceid"]; # Unique ID of the product/service in the WHMCS Database
    $pid = $params["pid"]; # Product/Service ID
    $producttype = $params["producttype"]; # Product Type: hostingaccount, reselleraccount, server or other
    $domain = $params["domain"];
 $username = $params["username"];
 $password = $params["password"];
    $clientsdetails = $params["clientsdetails"]; # Array of clients details - firstname, lastname, email, country, etc...
    $customfields = $params["customfields"]; # Array of custom field values for the product
    $configoptions = $params["configoptions"]; # Array of configurable option values for the product

    # Product module option settings from ConfigOptions array above
    $configoption1 = $params["configoption1"];
    $configoption2 = $params["configoption2"];
    $configoption3 = $params["configoption3"];
    $configoption4 = $params["configoption4"];

    # Additional variables if the product/service is linked to a server
    $server = $params["server"]; # True if linked to a server
    $serverid = $params["serverid"];
    $serverip = $params["serverip"];
    $serverusername = $params["serverusername"];
    $serverpassword = $params["serverpassword"];
    $serveraccesshash = $params["serveraccesshash"];
    $serversecure = $params["serversecure"]; # If set, SSL Mode is enabled in the server config

 # Code to perform action goes here...

 if ($successful) {
  $result = "success";
 } else {
  $result = "Error Message Goes Here...";
 }
 #return $result;
 return "Not Implemented";
}

function ahsayosb_TerminateAccount($params) {

 # Code to perform action goes here...

    if ($successful) {
  $result = "success";
 } else {
  $result = "Error Message Goes Here...";
 }
 #return $result;
 return "Not Implemented";
}

function ahsayosb_SuspendAccount($params) {
 if ($params["serversecure"] == 'on')
 {
  $conn = "https://";
 }
 else
 {
  $conn = "http://";
 }

 $adminAuth = "?SysUser=" . $params["serverusername"]."&SysPwd=".$params["serverpassword"]. "&";
 #getRemoteData($conn, $server, $cmd, $getcmd = NULL)

 $response = getRemoteData($conn, $params["serverhostname"], $GLOBALS["moduser"], $adminAuth . "LoginName=" . $params["username"] . "&Status=SUSPENDED");

 #$moduser, $adminAuth . "LoginName=$user&Status=ENABLE");

 if ($response == "<ok/>") {
  $result = "success";
 } else {
  $result = "Error: The return was " . $response;
 }
 return $result;
}

function ahsayosb_UnsuspendAccount($params) {
 if ($params["serversecure"] == 'on')
 {
  $conn = "https://";
 }
 else
 {
  $conn = "http://";
 }

 $adminAuth = "?SysUser=" . $params["serverusername"]."&SysPwd=".$params["serverpassword"]. "&";
 #getRemoteData($conn, $server, $cmd, $getcmd = NULL)

 $response = getRemoteData($conn, $params["serverhostname"], $GLOBALS["moduser"], $adminAuth . "LoginName=" . $params["username"] . "&Status=ENABLE");

 #$moduser, $adminAuth . "LoginName=$user&Status=ENABLE");

 if ($response == "<ok/>") {
  $result = "success";
 } else {
  $result = "Error: The return was " . $response;
 }
 return $result;
}

function ahsayosb_ChangePassword($params) {

 # Code to perform action goes here...

    if ($successful) {
  $result = "success";
 } else {
  $result = "Error Message Goes Here...";
 }
 #return $result;
 return "Not Implemented";
}

function ahsayosb_ChangePackage($params) {

 # Code to perform action goes here...

    if ($successful) {
  $result = "success";
 } else {
  $result = "Error Message Goes Here...";
 }
 #return $result;
 return "Not Implemented";
}

function ahsayosb_ClientArea($params) {
 $code = '<form action="http://'.$serverip.'/controlpanel" method="post" target="_blank">
<input type="hidden" name="user" value="'.$params[">
<input type="hidden" name="pass" value="'.$params[">
<input type="submit" value="Login to Control Panel">
<input type="button" value="Login to Webmail" onclick="window.open(\'http://'.$serverip.'/webmail\')">
</form>';
 return $code;
}

function ahsayosb_AdminLink($params) {
 if ($params["serversecure"] == 'on')
 {
  $conn = "https://";
 }
 else
 {
  $conn = "http://";
 }

 $code = '<form action="'. $conn .$params[" method="post" target="_blank">
<input type="hidden" name="systemLoginName" value="'.$params[">
<input type="hidden" name="systemPassword" value="'.$params[">
<input type="submit" value="OSB Admin">
</form>';
 return $code;
}

function ahsayosb_LoginLink($params) {
 if ($params["serversecure"] == 'on')
 {
  $conn = "https://";
 }
 else
 {
  $conn = "http://";
 }
 echo "<a href="\" loginname=".$params[" target="\" style="\">login to control panel</a>";

}

function ahsayosb_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(
  #"Reboot Server" => "reboot",
 );
 return $buttonarray;
}

function ahsayosb_reboot($params) {

 # Code to perform action goes here...

    if ($successful) {
  $result = "success";
 } else {
  $result = "Error Message Goes Here...";
 }
 return $result;
}

#Inernal Functions ONLY
function getRemoteData($conn, $server, $cmd, $getcmd = NULL)
{
 $response = '';
 if (ini_get('allow_url_fopen') == '1')
 {
  $response = file_get_contents($conn . $server . $GLOBALS['apiurl'] . $cmd . $getcmd);

  //use filegetcontects
 }
 else
 {
  print "Have to use curl";
 }
 return $response;
}

?>

Here is a a module/plugin for whmcs that controls an Ahsay off-site backup server.

http://www.whmcs.com
http://www.ahsay.com

It will automatically suspend and un-suspend off-site backup accounts.