Example #1
0
function _antareja_Client()
{
    # Setup include dir
    $include_path = ROOTDIR . '/modules/registrars/antareja';
    set_include_path($include_path . PATH_SEPARATOR . get_include_path());
    # Include EPP stuff we need
    require_once 'Net/EPP/Client.php';
    require_once 'Net/EPP/Protocol.php';
    require 'antarejaconfig.php';
    # Grab module parameters
    $params = getregistrarconfigoptions('antareja');
    # Check if module parameters are sane
    if (empty($params['Username']) || empty($params['Password'])) {
        throw new Exception('System configuration error(1), please contact your provider');
    }
    if ($params['Server'] != $server_addr) {
        throw new Exception('System configuration error(2), please contact your provider');
    }
    # Create SSL context
    $context = stream_context_create();
    # Are we using ssl?
    $use_ssl = false;
    if (!empty($params['SSL']) && $params['SSL'] == 'on') {
        $use_ssl = true;
    }
    # Set certificate if we have one
    if ($use_ssl && !empty($params['Certificate'])) {
        if (!file_exists($params['Certificate'])) {
            throw new Exception("System configuration error(3), please contact your provider");
        }
        # Set client side certificate
        stream_context_set_option($context, 'ssl', 'local_cert', $params['Certificate']);
    }
    # Create EPP client
    $client = new Net_EPP_Client();
    # Connect
    $res = $client->connect($params['Server'], $params['Port'], 15, $use_ssl, $context);
    # Perform login
    $request = $client->request($xml = '
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
	<command>
		<login>
			<clID>' . $params['Username'] . '</clID>
			<pw>' . $params['Password'] . '</pw>
			<options>
			<version>1.0</version>
			<lang>en</lang>
			</options>
			<svcs>
				<objURI>urn:ietf:params:xml:ns:domain-1.0</objURI>
				<objURI>urn:ietf:params:xml:ns:contact-1.0</objURI>
			</svcs>
		</login>
	</command>
</epp>
');
    logModuleCall('Antareja', 'Connect', $xml, $request);
    return $client;
}
Example #2
0
 function sendFrame($xml)
 {
     if ($xml instanceof DOMDocument) {
         $xml = $xml->saveXML();
     }
     foreach (explode("\n", str_replace('><', ">\n<", trim($xml))) as $line) {
         $this->debug("C: %s", $line);
     }
     return parent::sendFrame($xml);
 }