Unverified Commit 8c9c356f authored by Nathan Van Overloop's avatar Nathan Van Overloop
Browse files

centralnic/issues#3769: rework some core use cases and add example

parent c244d8c3
......@@ -2,14 +2,24 @@
class Net_EPP {
/**
* load a class by giving it's short name
* @return boolean
*/
static function autoload($class) {
$prefix = __CLASS__.'_';
if ($prefix == substr($class, 0, strlen($prefix))) {
debug_log($class);
$file = dirname(__FILE__).'/'.str_replace('_', '/', $class).'.php';
debug_log($file);
return (file_exists($file) && @include_once($file));
$basedir=dirname(dirname(__FILE__));
debug_log("class name is {$class} from dir {$basedir}");
$file = $basedir.'/'.str_replace('_', '/', $class).'.php';
if(!file_exists($file)){
debug_log("the file {$file} does not exist");
return false;
}
return include_once($file);
} else {
return false;
......
......@@ -24,9 +24,9 @@
* @revision $Id: Client.php,v 1.13 2010/10/21 11:55:07 gavin Exp $
*/
require_once('Net/EPP/Protocol.php');
require_once('Protocol.php');
$GLOBALS['Net_EPP_Client_Version'] = '0.0.4';
$GLOBALS['Net_EPP_Client_Version'] = '0.0.5';
/**
* A simple client class for the Extensible Provisioning Protocol (EPP)
......@@ -55,6 +55,7 @@
* @return a string containing the server <greeting>
*/
function connect($host, $port=700, $timeout=1, $ssl=true, $context=NULL) {
debug_log("start connecting");
$target = sprintf('%s://%s:%d', ($ssl === true ? 'tls' : 'tcp'), $host, $port);
if (is_resource($context)) {
$result = stream_socket_client($target, $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $context);
......@@ -78,7 +79,7 @@
if (!stream_set_blocking($this->socket,0)) {
throw new Exception("Failed to set blocking on socket: $errstr (code $errno)");
}
debug_log("returning the brand new socket");
return $this->getFrame();
}
......
......@@ -18,7 +18,7 @@ Net_EPP also provides a high-level EPP frame builder (Net_EPP_Frame)
which can be used to construct frames that comply with the EPP
specification and can be used to interact with a server.
The class is organised on similar lines to the Net::EPP::Client Perl
The class is organized on similar lines to the Net::EPP::Client Perl
module.
This program is free software; you can redistribute it and/or modify it
......@@ -26,3 +26,18 @@ under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
Example use case in code:
```
//load the autoloader class
require_once("php-epp/Net/EPP.php");
if(Net_EPP::autoload('Client')){
print "autoloading succeeded\n";
}
$epp=new Net_EPP_Client();
$greeting=$epp->connect('servername','port',20);
```
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment