Initial Commit of AgileBill Open Source
This commit is contained in:
259
plugins/provision/_rrad/RRAD.php
Normal file
259
plugins/provision/_rrad/RRAD.php
Normal file
@@ -0,0 +1,259 @@
|
||||
<?
|
||||
// Author: Dirk Bhagat, August 15, 2000.
|
||||
// Client API for Rrad: in php. Version: 0.4
|
||||
|
||||
// $Id: librrad.php,v 1.1 2000/10/05 16:02:21 dirk Exp $
|
||||
|
||||
define ("RRAD_DEFAULT_SERVER_NAME", "rrad.hostopia.com");
|
||||
define ("RRAD_DEFAULT_SERVER_PORT", 669);
|
||||
define ("RRAD_DEFAULT_USERNAME", "testola10000.com");
|
||||
define ("RRAD_DEFAULT_PASSWORD", "test123");
|
||||
define ("RRAD_FAMILY", "Rasmus");
|
||||
define ("RRAD_F_VERSION", "1.2");
|
||||
|
||||
/**
|
||||
* RRADServer used to authenticate client, and provide access to other services.
|
||||
*
|
||||
* @access Public
|
||||
*/
|
||||
|
||||
class RRADServer
|
||||
{
|
||||
/**
|
||||
* Username to authenticate with.
|
||||
* @var string $username
|
||||
*/
|
||||
var $username;
|
||||
|
||||
/**
|
||||
* Password to authenticate with.
|
||||
* @var string $password
|
||||
*/
|
||||
var $password;
|
||||
|
||||
var $salesrep;
|
||||
var $hostname = "rrad.hostopia.com";
|
||||
var $port = 669;
|
||||
var $sock; //socket to communicate on.
|
||||
|
||||
/**
|
||||
* Instantiate an RRADServer object. This must be the first step taken.
|
||||
* @param string
|
||||
* @param string
|
||||
* @param string
|
||||
* @access public
|
||||
*/
|
||||
function RRADServer($user, $pass, $srep="")
|
||||
{
|
||||
$this->username = $user;
|
||||
$this->password = $pass;
|
||||
$this->salesrep = $srep;
|
||||
}
|
||||
|
||||
/**
|
||||
* Auth using credentials supplied. Precedes requests for services etc.
|
||||
* @access public
|
||||
*/
|
||||
function authenticate()
|
||||
{
|
||||
$this->sock = fsockopen ($this->hostname, $this->port,
|
||||
&$errno, &$errstr, 10);
|
||||
if (!$this->sock)
|
||||
{
|
||||
$this->message = "$errstr ($errno)\n";
|
||||
die("Can't connect ".$this->hostname." ".$this->port);
|
||||
return false;
|
||||
}
|
||||
|
||||
$cmd = new hAuthCommand($this->username,$this->password,$this->salesrep);
|
||||
$ret = $this->write($cmd);
|
||||
if ( (!$ret) || (strlen($this->message)<1) )
|
||||
$this->message = "ERR: Invalid username or password.";
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the connection to the server.
|
||||
* @access public
|
||||
*/
|
||||
|
||||
function close()
|
||||
{
|
||||
$cmd = new hCloseCommand();
|
||||
$ret = $this->write($cmd);
|
||||
if ( (!$ret) || (strlen($this->message)<1) )
|
||||
$this->message = "ERR: Could not close connection.";
|
||||
|
||||
/* Try closing the sock anyway */
|
||||
fclose($this->sock);
|
||||
$this->sock = false;
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a command to the server.
|
||||
* @param object
|
||||
* @access private
|
||||
*/
|
||||
function simple_write($cmd)
|
||||
{
|
||||
// print "<br>client says: '".$cmd->assemble()."'<br>";
|
||||
fputs($this->sock, $cmd->assemble()."\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the host that Authenticate() will connect to. Defaults are provided.
|
||||
* @param string
|
||||
* @access public
|
||||
*/
|
||||
function setHost($host)
|
||||
{
|
||||
$this->hostname = $host;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Port that Authenticate() will connect to.
|
||||
* @param int
|
||||
* @access public
|
||||
*/
|
||||
function setPort($port)
|
||||
{
|
||||
$this->port = $port;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a context object that is used to configure each service. A domain name is currentl the only accepted value.
|
||||
* @param string
|
||||
* @access public
|
||||
*/
|
||||
function getContext($dom)
|
||||
{
|
||||
$c = new hDomain($dom);
|
||||
return $c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latest message from the server.
|
||||
* @access public
|
||||
*/
|
||||
|
||||
function getMessage ()
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next 'row' of data returned from the server.
|
||||
* @access private
|
||||
*/
|
||||
function getNextRow()
|
||||
{
|
||||
if (!feof($this->sock))
|
||||
{
|
||||
$this->message = fgets ($this->sock,4096);
|
||||
if (substr($this->message,0,1) == chr(3))
|
||||
return false;
|
||||
else if (substr($this->message,0,4) == "ERR:")
|
||||
return false;
|
||||
|
||||
// Strip newline
|
||||
$this->message = chop($this->message);
|
||||
$vals = explode(chr(31),$this->message);
|
||||
return $vals;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a command to the server and retrieve the server's response.
|
||||
* @param object
|
||||
* @access private
|
||||
*/
|
||||
function write ($cmd)
|
||||
{
|
||||
if (! $this->sock )
|
||||
{
|
||||
$this->message = "ERR: Commands out of sync";
|
||||
return -1;
|
||||
}
|
||||
|
||||
// print "<br>client says: '".$cmd->assemble()."'<br>";
|
||||
fputs ($this->sock, $cmd->assemble()."\r\n");
|
||||
if (!feof($this->sock))
|
||||
{
|
||||
$this->message = fgets ($this->sock,128);
|
||||
if (substr($this->message,0,2) == "OK")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->message = "ERR: No response from server.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve an hWebService object. Use this for Web methods.
|
||||
* @access public
|
||||
*/
|
||||
function getWebService()
|
||||
{
|
||||
$w = new hWebService();
|
||||
$w->RRADServer = &$this;
|
||||
return $w;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve an hInfoService object. Use this to retrieve Info objects.
|
||||
* @access public
|
||||
*/
|
||||
function getInfoService()
|
||||
{
|
||||
$i = new hInfoService();
|
||||
$i->RRADServer = &$this;
|
||||
return $i;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve an hConvenienceService object. Commonly used methods.
|
||||
* @access public
|
||||
*/
|
||||
|
||||
function getConvenienceService()
|
||||
{
|
||||
$convenience = new hConvenienceService();
|
||||
$convenience->RRADServer = &$this;
|
||||
return $convenience;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve an hAdminService object.
|
||||
* @access public
|
||||
*/
|
||||
|
||||
function getAdminService()
|
||||
{
|
||||
$admin = new hAdminService();
|
||||
$admin->RRADServer = &$this;
|
||||
return $admin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve an hMailService object. Used to execute mail management commands.
|
||||
* @access public
|
||||
*/
|
||||
|
||||
function getMailService()
|
||||
{
|
||||
$mail = new hMailService();
|
||||
$mail->RRADServer =&$this;
|
||||
return $mail;
|
||||
}
|
||||
}
|
||||
?>
|
16
plugins/provision/_rrad/RRADCommonIncludes.php
Normal file
16
plugins/provision/_rrad/RRADCommonIncludes.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?
|
||||
ini_set("include_path", dirname(__FILE__) . "/");
|
||||
|
||||
include_once("hInfoService.php"); // Info Services: usage, contact, etc
|
||||
include_once("hWebService.php"); // Web Services: add domain, delete, etc
|
||||
include_once("hConvenienceService.php"); // Convenience Services: add domain, change pass, etc
|
||||
include_once("hAdminService.php"); // Admin Service: enable, disable
|
||||
|
||||
// Different Info objects
|
||||
include_once("hServiceInfo.php");
|
||||
include_once("hContactInfo.php");
|
||||
include_once("hUsageInfo.php");
|
||||
include_once("hAdminInfo.php");
|
||||
|
||||
ini_restore("include_path");
|
||||
?>
|
14
plugins/provision/_rrad/RRADCoreIncludes.php
Normal file
14
plugins/provision/_rrad/RRADCoreIncludes.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?
|
||||
|
||||
ini_set("include_path", dirname(__FILE__) . "/");
|
||||
|
||||
include_once("RRAD.php"); // Always require the RRADServer Object.
|
||||
include_once("hCommand.php"); // Can't send commands without this
|
||||
include_once("hAuthCommand.php"); // authentication commands
|
||||
include_once("hCloseCommand.php"); // authentication commands
|
||||
include_once("hService.php"); // Base class for all services
|
||||
include_once("hInfo.php"); // Base class for Info objects
|
||||
include_once("hDomain.php"); // Context required for most services.
|
||||
|
||||
ini_restore("include_path");
|
||||
?>
|
28
plugins/provision/_rrad/hAdminInfo.php
Normal file
28
plugins/provision/_rrad/hAdminInfo.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?
|
||||
class hAdminInfo extends hInfo
|
||||
{
|
||||
var $fields;
|
||||
|
||||
function hAdminInfo(&$domaincon)
|
||||
{
|
||||
$this->fields = array ("SalesRep", "ExternalID");
|
||||
|
||||
$this->RRADRetrieveCommand = &new hCommand("I RA","",$domaincon);
|
||||
$this->RRADUpdateCommand = &new hCommand("I UA","",$domaincon);
|
||||
|
||||
}
|
||||
|
||||
function getRRADUpdateCommand()
|
||||
{
|
||||
for ($i=0; $i<sizeof($this->fields); $i++)
|
||||
{
|
||||
$fn = $this->fields[$i];
|
||||
if ($i > 0)
|
||||
$suffix .= " ";
|
||||
$suffix .= str_replace(" ", chr(31), $this->properties[$fn]);
|
||||
}
|
||||
$this->RRADUpdateCommand->suffix = $suffix;
|
||||
return $this->RRADUpdateCommand;
|
||||
}
|
||||
}
|
||||
?>
|
34
plugins/provision/_rrad/hAdminService.php
Normal file
34
plugins/provision/_rrad/hAdminService.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?
|
||||
|
||||
class hAdminService extends hService
|
||||
{
|
||||
function enable()
|
||||
{
|
||||
$cmd = new hCommand("A AE", "", $this->context);
|
||||
$r_code = $this->RRADServer->write($cmd);
|
||||
return($r_code);
|
||||
}
|
||||
|
||||
function disable()
|
||||
{
|
||||
$cmd = new hCommand("A AD", "", $this->context);
|
||||
$r_code = $this->RRADServer->write($cmd);
|
||||
return($r_code);
|
||||
}
|
||||
|
||||
function suspend()
|
||||
{
|
||||
$cmd = new hCommand("A AS", "", $this->context);
|
||||
$r_code = $this->RRADServer->write($cmd);
|
||||
return($r_code);
|
||||
}
|
||||
|
||||
function unsuspend()
|
||||
{
|
||||
$cmd = new hCommand("A AU", "", $this->context);
|
||||
$r_code = $this->RRADServer->write($cmd);
|
||||
return($r_code);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
27
plugins/provision/_rrad/hAuthCommand.php
Normal file
27
plugins/provision/_rrad/hAuthCommand.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?
|
||||
class hAuthCommand extends hCommand
|
||||
{
|
||||
var $username;
|
||||
var $password;
|
||||
var $salesperson;
|
||||
|
||||
function hAuthCommand($u,$p,$s)
|
||||
{
|
||||
$this->username = $u;
|
||||
$this->password = $p;
|
||||
$this->salesperson = $s;
|
||||
$this->prefix = "L I";
|
||||
}
|
||||
|
||||
function assemble()
|
||||
{
|
||||
$str = $this->prefix.$this->delim.$this->username
|
||||
. $this->delim.$this->password.$this->delim.RRAD_FAMILY."-"
|
||||
. RRAD_F_VERSION;
|
||||
|
||||
if (strlen($this->salesperson))
|
||||
$str .= $this->delim.$this->salesperson;
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
?>
|
11
plugins/provision/_rrad/hCloseCommand.php
Normal file
11
plugins/provision/_rrad/hCloseCommand.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?
|
||||
class hCloseCommand extends hCommand
|
||||
{
|
||||
// Might be expanded in the future ..
|
||||
|
||||
function assemble()
|
||||
{
|
||||
return "L O";
|
||||
}
|
||||
}
|
||||
?>
|
25
plugins/provision/_rrad/hCommand.php
Normal file
25
plugins/provision/_rrad/hCommand.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?
|
||||
class hCommand
|
||||
{
|
||||
var $prefix;
|
||||
var $suffix;
|
||||
var $domain;
|
||||
var $delim = " ";
|
||||
|
||||
function assemble()
|
||||
{
|
||||
$cmd = $this->prefix.$this->delim.$this->domain;
|
||||
if (strlen($this->suffix)>0)
|
||||
$cmd .= $this->delim.$this->suffix;
|
||||
return $cmd;
|
||||
}
|
||||
|
||||
function hCommand($prefix="",$suffix="", $domaincon=false)
|
||||
{
|
||||
$this->prefix = $prefix;
|
||||
$this->suffix = $suffix;
|
||||
if (is_object($domaincon))
|
||||
$this->domain = $domaincon->getName();
|
||||
}
|
||||
}
|
||||
?>
|
31
plugins/provision/_rrad/hContactInfo.php
Normal file
31
plugins/provision/_rrad/hContactInfo.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?
|
||||
class hContactInfo extends hInfo
|
||||
{
|
||||
var $fields;
|
||||
|
||||
function hContactInfo(&$domaincon)
|
||||
{
|
||||
$this->fields = array (
|
||||
"FirstName", "LastName", "Company", "Address1",
|
||||
"Address2", "City", "State", "PostalCode", "Country",
|
||||
"Email", "Phone", "Fax");
|
||||
|
||||
$this->RRADRetrieveCommand = &new hCommand("I RC","",$domaincon);
|
||||
$this->RRADUpdateCommand = &new hCommand("I UC","",$domaincon);
|
||||
|
||||
}
|
||||
|
||||
function getRRADUpdateCommand()
|
||||
{
|
||||
for ($i=0; $i<sizeof($this->fields); $i++)
|
||||
{
|
||||
$fn = $this->fields[$i];
|
||||
if ($i > 0)
|
||||
$suffix .= " ";
|
||||
$suffix .= str_replace(" ", chr(31), $this->properties[$fn]);
|
||||
}
|
||||
$this->RRADUpdateCommand->suffix = $suffix;
|
||||
return $this->RRADUpdateCommand;
|
||||
}
|
||||
}
|
||||
?>
|
85
plugins/provision/_rrad/hConvenienceService.php
Normal file
85
plugins/provision/_rrad/hConvenienceService.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?
|
||||
class hConvenienceService extends hService
|
||||
{
|
||||
function newDomain ($domain, $password, $package,
|
||||
$contactInfo, $linkdomain="")
|
||||
|
||||
{
|
||||
$web_svc = $this->RRADServer->getWebService();
|
||||
$info_svc = $this->RRADServer->getInfoService();
|
||||
|
||||
$newdom = $web_svc->newDomain( $domain,$password,
|
||||
$package, $contactInfo["Email"],$linkdomain);
|
||||
if (!$newdom)
|
||||
return false;
|
||||
|
||||
$info_svc->setContext($newdom);
|
||||
$contact_details = $info_svc->getContactInfo();
|
||||
if (!$contact_details)
|
||||
return false; // Domain created, but couldn't set info ...?
|
||||
|
||||
foreach($contactInfo as $k => $v)
|
||||
$contact_details->set($k,$v);
|
||||
return $info_svc->setInfo($contact_details);
|
||||
}
|
||||
|
||||
function delDomain ($domain)
|
||||
{
|
||||
$web_svc = $this->RRADServer->getWebService();
|
||||
$dom = $this->RRADServer->getContext($domain);
|
||||
if (!$dom)
|
||||
return false;
|
||||
$web_svc->setContext($dom);
|
||||
|
||||
return $web_svc->delDomain();
|
||||
}
|
||||
|
||||
function setPackage($domain, $package, $referencedomain="")
|
||||
{
|
||||
$web_svc = $this->RRADServer->getWebService();
|
||||
$dom = $this->RRADServer->getContext($domain);
|
||||
|
||||
if (!$dom)
|
||||
return false;
|
||||
|
||||
$web_svc->setContext($dom);
|
||||
return $web_svc->setPackage($package,$referencedomain);
|
||||
}
|
||||
|
||||
function setPassword($domain, $password)
|
||||
{
|
||||
$web_svc = $this->RRADServer->getWebService();
|
||||
$dom = $this->RRADServer->getContext($domain);
|
||||
|
||||
if (!$dom)
|
||||
return false;
|
||||
$web_svc->setContext($dom);
|
||||
return $web_svc->setPassword($password);
|
||||
}
|
||||
|
||||
function addService ($domain, $product_code, $quantity = 1,
|
||||
$discount = 0, $comment = "")
|
||||
{
|
||||
$web_svc = $this->RRADServer->getWebService();
|
||||
$dom = $this->RRADServer->getContext($domain);
|
||||
|
||||
if (!$dom)
|
||||
return false;
|
||||
$web_svc->setContext($dom);
|
||||
|
||||
return $web_svc->addService($product_code,$quantity,
|
||||
$discount,$comment);
|
||||
}
|
||||
|
||||
function dropService($domain, $service, $id="")
|
||||
{
|
||||
$web_svc = $this->RRADServer->getWebService();
|
||||
$dom = $this->RRADServer->getContext($domain);
|
||||
|
||||
if (!$dom)
|
||||
return false;
|
||||
$web_svc->setContext($dom);
|
||||
return $web_svc->dropService($service,$id);
|
||||
}
|
||||
}
|
||||
?>
|
17
plugins/provision/_rrad/hDomain.php
Normal file
17
plugins/provision/_rrad/hDomain.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?
|
||||
class hDomain
|
||||
{
|
||||
var $domainname;
|
||||
var $RRADServer;
|
||||
|
||||
function getName()
|
||||
{
|
||||
return $this->domainname;
|
||||
}
|
||||
|
||||
function hDomain ($domain)
|
||||
{
|
||||
$this->domainname = $domain;
|
||||
}
|
||||
}
|
||||
?>
|
66
plugins/provision/_rrad/hInfo.php
Normal file
66
plugins/provision/_rrad/hInfo.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?
|
||||
class hInfo
|
||||
{
|
||||
var $RRADRetrieveCommand;
|
||||
var $RRADUpdateCommand;
|
||||
var $current_index = 0;
|
||||
var $RawElements;
|
||||
var $fields;
|
||||
var $numEls = 0;
|
||||
|
||||
function getNumEls()
|
||||
{
|
||||
return $this->numEls;
|
||||
}
|
||||
|
||||
function set($prop_name, $prop_val)
|
||||
{
|
||||
if (($this->numEls == 1) && ($this->current_index == 0))
|
||||
$this->next();
|
||||
$this->properties[$prop_name] = $prop_val;
|
||||
return true;
|
||||
}
|
||||
|
||||
function get($prop_name)
|
||||
{
|
||||
if (($this->numEls == 1) && ($this->current_index == 0))
|
||||
$this->next();
|
||||
return $this->properties[$prop_name];
|
||||
}
|
||||
|
||||
function propertyExists($prop_name)
|
||||
{
|
||||
return isset($this->properties[$prop_name]);
|
||||
}
|
||||
|
||||
function getRRADRetrieveCommand()
|
||||
{
|
||||
return $this->RRADRetrieveCommand;
|
||||
}
|
||||
|
||||
function addElement($row)
|
||||
{
|
||||
$this->RawElements[] = $row;
|
||||
$this->numEls++;
|
||||
}
|
||||
|
||||
function next()
|
||||
{
|
||||
// Use fields and replace properties
|
||||
// table with new values.
|
||||
if ( ($this->current_index < $this->numEls)
|
||||
&& ($this->current_index >= 0) )
|
||||
{
|
||||
$currow = $this->RawElements[$this->current_index];
|
||||
for ($i=0; $i<sizeof($this->fields); $i++)
|
||||
{
|
||||
$fn = $this->fields[$i];
|
||||
$this->properties[$fn] = $currow[$i] ;
|
||||
}
|
||||
$this->current_index++;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
73
plugins/provision/_rrad/hInfoService.php
Normal file
73
plugins/provision/_rrad/hInfoService.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?
|
||||
class hInfoService extends hService
|
||||
{
|
||||
function getContactInfo()
|
||||
{
|
||||
$info = new hContactInfo($this->context);
|
||||
if ($this->getInfo($info))
|
||||
return $info;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
function getAdminInfo()
|
||||
{
|
||||
$info = new hAdminInfo($this->context);
|
||||
if ($this->getInfo($info))
|
||||
return $info;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
function getServiceInfo()
|
||||
{
|
||||
$info = new hServiceInfo($this->context);
|
||||
if ($this->getInfo($info))
|
||||
return $info;
|
||||
else
|
||||
return $false;
|
||||
}
|
||||
|
||||
function getUsageInfo($startMonth="", $endMonth="")
|
||||
{
|
||||
if (strlen($startMonth)> 1)
|
||||
{
|
||||
if ($startMonth < 0 || $startMonth > 12)
|
||||
return false;
|
||||
}
|
||||
if (strlen($endMonth)> 1)
|
||||
{
|
||||
if ($endMonth < 0 || $endMonth > 12)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Allow range to be inverted .. i.e. startMonth > endmonth ...
|
||||
|
||||
$info = new hUsageInfo($startMonth,$endMonth,$this->context);
|
||||
if ($this->getInfo($info))
|
||||
return $info;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
function setInfo($info)
|
||||
{
|
||||
$cmd = &$info->getRRADUpdateCommand();
|
||||
return $this->RRADServer->write($cmd);
|
||||
}
|
||||
|
||||
function getInfo(&$info)
|
||||
{
|
||||
$cmd = &$info->getRRADRetrieveCommand();
|
||||
$this->RRADServer->simple_write($cmd);
|
||||
|
||||
if (!is_array($this->RRADServer->getNextRow()))
|
||||
return false;
|
||||
|
||||
while (($row = $this->RRADServer->getNextRow()))
|
||||
$info->addElement($row);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
10
plugins/provision/_rrad/hMailService.php
Normal file
10
plugins/provision/_rrad/hMailService.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?
|
||||
class hMailService extends hService
|
||||
{
|
||||
function setNumAccounts($numaccts)
|
||||
{
|
||||
return $this->RRADServer->write(new hCommand("A E", $numaccts, $this->context));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
11
plugins/provision/_rrad/hService.php
Normal file
11
plugins/provision/_rrad/hService.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?
|
||||
class hService
|
||||
{
|
||||
var $context;
|
||||
|
||||
function setContext(&$con)
|
||||
{
|
||||
$this->context = $con;
|
||||
}
|
||||
}
|
||||
?>
|
10
plugins/provision/_rrad/hServiceInfo.php
Normal file
10
plugins/provision/_rrad/hServiceInfo.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?
|
||||
class hServiceInfo extends hInfo
|
||||
{
|
||||
function hServiceInfo($domaincon)
|
||||
{
|
||||
$this->fields = array ("ServiceName", "Status", "ServiceID");
|
||||
$this->RRADRetrieveCommand = &new hCommand("I RS","",$domaincon);
|
||||
}
|
||||
}
|
||||
?>
|
29
plugins/provision/_rrad/hUsageInfo.php
Normal file
29
plugins/provision/_rrad/hUsageInfo.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?
|
||||
|
||||
class hUsageInfo extends hInfo
|
||||
{
|
||||
var $startMonth;
|
||||
var $endMonth;
|
||||
|
||||
function hUsageInfo($startMonth, $endMonth, $domaincon)
|
||||
{
|
||||
|
||||
$this->startMonth = $startMonth;
|
||||
$this->endMonth = $endMonth;
|
||||
$this->fields = array ("Month", "Bandwidth", "Diskusage",
|
||||
"MailboxesUsed", "Mailboxes");
|
||||
$this->RRADRetrieveCommand = &new hCommand("I RU","",$domaincon);
|
||||
}
|
||||
|
||||
function getRRADRetrieveCommand()
|
||||
{
|
||||
if (strlen($this->startMonth)>0 )
|
||||
$this->RRADRetrieveCommand->suffix .= $this->startMonth;
|
||||
|
||||
if (strlen($this->endMonth)>0 )
|
||||
$this->RRADRetrieveCommand->suffix .= " ".$this->endMonth;
|
||||
return $this->RRADRetrieveCommand;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
82
plugins/provision/_rrad/hWebService.php
Normal file
82
plugins/provision/_rrad/hWebService.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?
|
||||
class hWebService extends hService
|
||||
{
|
||||
function newDomain ($domain, $password, $package,
|
||||
$email, $linktodomain = "")
|
||||
{
|
||||
if (strlen($linktodomain)>0)
|
||||
$email .= " $linktodomain";
|
||||
$cmd = new hCommand("W A", "$password $package $email");
|
||||
$cmd->domain = $domain;
|
||||
if ($this->RRADServer->write($cmd))
|
||||
{
|
||||
// Return a domain context if create succeeded ...
|
||||
$d = &new hDomain($domain);
|
||||
return $d;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function delDomain ()
|
||||
{
|
||||
return $this->RRADServer->write(
|
||||
new hCommand("W D", "", $this->context));
|
||||
}
|
||||
|
||||
function setPassword($password)
|
||||
{
|
||||
|
||||
echo "\n\n<!-- Password: $password -->\n\n";
|
||||
return $this->RRADServer->write(
|
||||
new hCommand("W C",$password,$this->context));
|
||||
}
|
||||
|
||||
function setPackage($newpackage, $referencedomain="")
|
||||
{
|
||||
if (strlen($referencedomain)>1)
|
||||
$newpackage .= " $referencedomain";
|
||||
return $this->RRADServer->write(
|
||||
new hCommand("A C",$newpackage,$this->context));
|
||||
}
|
||||
|
||||
function setStorage ($megabytes)
|
||||
{
|
||||
return $this->RRADServer->write(
|
||||
new hCommand("A S",$megabytes,$this->context));
|
||||
}
|
||||
|
||||
function setBandwidth ($megabytes)
|
||||
{
|
||||
return $this->RRADServer->write(
|
||||
new hCommand("A B",$megabytes,$this->context));
|
||||
}
|
||||
|
||||
|
||||
// Positive return code on success (it's the service-id.)
|
||||
// false on failure
|
||||
|
||||
function addService ($product_code, $quantity = 1,
|
||||
$discount = 0, $comment = "")
|
||||
{
|
||||
if (strlen($comment)>0)
|
||||
$discount .= " $comment";
|
||||
$cmd = new hCommand("S A","$product_code $quantity $discount",$this->context);
|
||||
$r_code = $this->RRADServer->write($cmd);
|
||||
if ($r_code)
|
||||
{
|
||||
$pieces = explode ("#", $this->RRADServer->getMessage());
|
||||
$r_code = preg_replace("/[^0-9]/", "", $pieces[1] );
|
||||
}
|
||||
return $r_code;
|
||||
}
|
||||
|
||||
function dropService ($service_name, $id="")
|
||||
{
|
||||
if (strlen($id)>0)
|
||||
$service_name .= " $id";
|
||||
$cmd = new hCommand("S D",$service_name,$this->context);
|
||||
return $this->RRADServer->write($cmd);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user