├── .gitmodules ├── .gitignore ├── Net ├── EPP │ ├── Frame │ │ ├── Hello.php │ │ ├── Command │ │ │ ├── Logout.php │ │ │ ├── Info │ │ │ │ ├── Host.php │ │ │ │ ├── Domain.php │ │ │ │ └── Contact.php │ │ │ ├── Check │ │ │ │ ├── Host.php │ │ │ │ ├── Contact.php │ │ │ │ └── Domain.php │ │ │ ├── Create │ │ │ │ ├── Host.php │ │ │ │ ├── Domain.php │ │ │ │ └── Contact.php │ │ │ ├── Delete │ │ │ │ ├── Host.php │ │ │ │ ├── Domain.php │ │ │ │ └── Contact.php │ │ │ ├── Update │ │ │ │ ├── Host.php │ │ │ │ ├── Domain.php │ │ │ │ └── Contact.php │ │ │ ├── Renew │ │ │ │ └── Domain.php │ │ │ ├── Transfer │ │ │ │ ├── Contact.php │ │ │ │ └── Domain.php │ │ │ ├── Poll │ │ │ │ ├── Req.php │ │ │ │ └── Ack.php │ │ │ ├── Create.php │ │ │ ├── Delete.php │ │ │ ├── Update.php │ │ │ ├── Poll.php │ │ │ ├── Check.php │ │ │ ├── Renew.php │ │ │ ├── Info.php │ │ │ ├── Transfer.php │ │ │ └── Login.php │ │ ├── Response.php │ │ ├── Greeting.php │ │ └── Command.php │ ├── Exception.php │ ├── Frame.php │ ├── ObjectSpec.php │ ├── Protocol.php │ ├── Simple.php │ └── Client.php └── EPP.php ├── .php_cs.dist ├── .gitlab-ci.yml ├── README.md └── COPYING /.gitmodules: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **/.php_cs.cache 2 | -------------------------------------------------------------------------------- /Net/EPP/Frame/Hello.php: -------------------------------------------------------------------------------- 1 | setOp('req'); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Net/EPP/Frame/Command/Create.php: -------------------------------------------------------------------------------- 1 | type = $type; 11 | parent::__construct('create', $type); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Net/EPP/Frame/Command/Delete.php: -------------------------------------------------------------------------------- 1 | type = $type; 11 | parent::__construct('delete', $type); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Net/EPP/Frame/Command/Update.php: -------------------------------------------------------------------------------- 1 | type = $type; 11 | parent::__construct('update', $type); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Net/EPP/Frame/Command/Poll.php: -------------------------------------------------------------------------------- 1 | command->setAttribute('op', $op); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Net/EPP/Frame/Command/Poll/Ack.php: -------------------------------------------------------------------------------- 1 | setOp('ack'); 12 | } 13 | 14 | public function setMsgID($id) 15 | { 16 | $this->command->setAttribute('msgID', $id); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Net/EPP/Frame/Response.php: -------------------------------------------------------------------------------- 1 | getElementsByTagName('result')->item(0)->getAttribute('code'); 16 | } 17 | 18 | public function message() 19 | { 20 | return $this->getElementsByTagName('msg')->item(0)->firstChild->textContent; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Net/EPP/Frame/Command/Transfer/Domain.php: -------------------------------------------------------------------------------- 1 | createObjectPropertyElement('period'); 16 | $el->setAttribute('unit', $units); 17 | $el->appendChild($this->createTextNode($period)); 18 | $this->payload->appendChild($el); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Net/EPP/Frame/Command/Check.php: -------------------------------------------------------------------------------- 1 | payload->appendChild($this->createElementNS( 17 | Net_EPP_ObjectSpec::xmlns($type), 18 | $type.':'.Net_EPP_ObjectSpec::id($type), 19 | $object 20 | )); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Net/EPP/Frame/Command/Renew.php: -------------------------------------------------------------------------------- 1 | payload->appendChild($this->createElementNS( 17 | Net_EPP_ObjectSpec::xmlns($type), 18 | $type.':'.Net_EPP_ObjectSpec::id($type), 19 | $object 20 | )); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Net/EPP/Frame/Greeting.php: -------------------------------------------------------------------------------- 1 | svID = $this->createElement('svID'); 13 | $this->body->appendChild($this->svID); 14 | 15 | $this->svDate = $this->createElement('svDate'); 16 | $this->body->appendChild($this->svDate); 17 | 18 | $this->svcMenu = $this->createElement('svcMenu'); 19 | $this->body->appendChild($this->svcMenu); 20 | 21 | $this->dcp = $this->createElement('dcp'); 22 | $this->body->appendChild($this->dcp); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Net/EPP/Exception.php: -------------------------------------------------------------------------------- 1 | exclude('tests') 5 | ->in(__DIR__) 6 | ; 7 | 8 | return PhpCsFixer\Config::create() 9 | ->setRules([ 10 | '@PSR2' => true, 11 | 'declare_equal_normalize' => ['space' => 'single'], 12 | 'array_syntax' => ['syntax' => 'long'], 13 | 'object_operator_without_whitespace' => true, 14 | 'binary_operator_spaces' => true, 15 | 'no_alternative_syntax' => true, 16 | 'braces' => true, 17 | 'php_unit_method_casing' => ['case' => 'camel_case'], 18 | 'class_attributes_separation' => ['elements' => ['method']], 19 | 'no_blank_lines_after_phpdoc' => true, 20 | 'no_trailing_whitespace' => true, 21 | 'constant_case' => ['case' => 'lower'], 22 | 'phpdoc_indent' => true, 23 | 'phpdoc_align' => ['align' => 'vertical'], 24 | 25 | ]) 26 | ->setFinder($finder) 27 | ; -------------------------------------------------------------------------------- /Net/EPP/Frame.php: -------------------------------------------------------------------------------- 1 | '; 11 | 12 | public function __construct($type) 13 | { 14 | parent::__construct('1.0', 'UTF-8'); 15 | 16 | $this->loadXML(self::TEMPLATE); 17 | 18 | $type = strtolower($type); 19 | if (!in_array($type, array('hello', 'greeting', 'command', 'response'))) { 20 | trigger_error("Invalid argument value '$type' for \$type", E_USER_ERROR); 21 | } 22 | 23 | $this->epp = $this->firstChild; 24 | $this->body = $this->createElement($type); 25 | $this->epp->appendChild($this->body); 26 | } 27 | 28 | public function friendly() 29 | { 30 | return str_replace('><', ">\n<", $this->saveXML()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Net/EPP/Frame/Command/Info.php: -------------------------------------------------------------------------------- 1 | payload->childNodes as $child) { 17 | $this->payload->removeChild($child); 18 | } 19 | $this->payload->appendChild($this->createElementNS( 20 | Net_EPP_ObjectSpec::xmlns($type), 21 | $type.':'.Net_EPP_ObjectSpec::id($type), 22 | $object 23 | )); 24 | } 25 | 26 | public function setAuthInfo($authInfo) 27 | { 28 | $el = $this->createObjectPropertyElement('authInfo'); 29 | $el->appendChild($this->createObjectPropertyElement('pw')); 30 | $el->firstChild->appendChild($this->createTextNode($authInfo)); 31 | $this->payload->appendChild($el); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Net/EPP/Frame/Command/Transfer.php: -------------------------------------------------------------------------------- 1 | payload->childNodes as $child) { 17 | $this->payload->removeChild($child); 18 | } 19 | $this->payload->appendChild($this->createElementNS( 20 | Net_EPP_ObjectSpec::xmlns($type), 21 | $type.':'.Net_EPP_ObjectSpec::id($type), 22 | $object 23 | )); 24 | } 25 | 26 | public function setOp($op) 27 | { 28 | $this->command->setAttribute('op', $op); 29 | } 30 | 31 | public function setAuthInfo($authInfo) 32 | { 33 | $el = $this->createObjectPropertyElement('authInfo'); 34 | $el->appendChild($this->createObjectPropertyElement('pw')); 35 | $el->firstChild->appendChild($this->createTextNode($authInfo)); 36 | $this->payload->appendChild($el); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Net/EPP/Frame/Command/Login.php: -------------------------------------------------------------------------------- 1 | clID = $this->createElement('clID'); 13 | $this->command->appendChild($this->clID); 14 | 15 | $this->pw = $this->createElement('pw'); 16 | $this->command->appendChild($this->pw); 17 | 18 | $this->options = $this->createElement('options'); 19 | $this->command->appendChild($this->options); 20 | 21 | $this->eppVersion = $this->createElement('version'); 22 | $this->options->appendChild($this->eppVersion); 23 | 24 | $this->eppLang = $this->createElement('lang'); 25 | $this->options->appendChild($this->eppLang); 26 | 27 | $this->svcs = $this->createElement('svcs'); 28 | $this->command->appendChild($this->svcs); 29 | } 30 | 31 | public function addExtension($exts) 32 | { 33 | $extensions = $this->createElement('svcExtension'); 34 | foreach ($exts as $ext) { 35 | $ext_el = $this->createObjectPropertyElement('extURI'); 36 | $ext_el->appendChild($this->createTextNode(Net_EPP_ObjectSpec::xmlns($ext))); 37 | $extensions->appendChild($ext_el); 38 | } 39 | $this->svcs->appendChild($extensions); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | #this is the latest template to assist in copying 2 | 3 | image: git.centralnic.com:5050/centralnic/syntaxchecker:master 4 | 5 | stages: 6 | - syntax-check 7 | - git-robot 8 | 9 | default: 10 | before_script: 11 | - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@git.centralnic.com/centralnic/tests.git 12 | - tests/prep-alpine-env.sh 13 | 14 | step-syntax-check: 15 | stage: syntax-check 16 | script: 17 | - export DYNAMIC_ENV_VAR=DEVELOP 18 | - echo running tests in $DYNAMIC_ENV_VAR 19 | - tests/testlints.sh 20 | 21 | merge-master-to-ote: 22 | stage: git-robot 23 | only: 24 | - master 25 | script: 26 | - eval $(ssh-agent -s) 27 | - bash -c "ssh-add <(echo '$GIT_SSH_PRIV_KEY')" 28 | - ssh-add -L 29 | - export TMP_DIR=$(mktemp -d -t ./ci-XXXXXXXXXX) 30 | - cd $TMP_DIR 31 | - pwd 32 | - bash -c "set -x; git clone git@git.centralnic.com:${CI_PROJECT_PATH}.git" 33 | - cd ${CI_PROJECT_NAME} 34 | - git checkout master 35 | - git checkout --track origin/ote 36 | - git merge master 37 | - git push origin ote 38 | 39 | merge-ote-to-dev: 40 | stage: git-robot 41 | only: 42 | - ote 43 | script: 44 | - eval $(ssh-agent -s) 45 | - bash -c "ssh-add <(echo '$GIT_SSH_PRIV_KEY')" 46 | - ssh-add -L 47 | - export TMP_DIR=$(mktemp -d -t ./ci-XXXXXXXXXX) 48 | - cd $TMP_DIR 49 | - pwd 50 | - bash -c "set -x; git clone git@git.centralnic.com:${CI_PROJECT_PATH}.git" 51 | - cd ${CI_PROJECT_NAME} 52 | - git checkout --track origin/ote 53 | - git checkout --track origin/dev 54 | - git merge ote 55 | - git push origin dev -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | EPP is the Extensible Provisioning Protocol. EPP (defined in RFC 5730 4 | and subsequent documents) is an application layer client-server protocol 5 | for the provisioning and management of objects stored in a shared 6 | central repository. Specified in XML, the protocol defines generic 7 | object management operations and an extensible framework that maps 8 | protocol operations to objects. As of writing, its only well-developed 9 | application is the provisioning of Internet domain names, hosts, and 10 | related contact details. 11 | 12 | RFC 3734 defines a TCP based transport model for EPP, and the 13 | Net_EPP_Client class included in this distribution implements a client 14 | for that model. You can establish and manage EPP connections and send 15 | and receive responses over these connections. 16 | 17 | Net_EPP also provides a high-level EPP frame builder (Net_EPP_Frame) 18 | which can be used to construct frames that comply with the EPP 19 | specification and can be used to interact with a server. 20 | 21 | The class is organized on similar lines to the Net::EPP::Client Perl 22 | module. 23 | 24 | This program is free software; you can redistribute it and/or modify it 25 | under the terms of the GNU General Public License as published by the 26 | Free Software Foundation; either version 2 of the License, or (at your 27 | option) any later version. 28 | 29 | Example use case in code: 30 | 31 | ``` 32 | //load the autoloader class 33 | require_once("php-epp/Net/EPP.php"); 34 | 35 | if(Net_EPP::autoload('Client')){ 36 | print "autoloading succeeded\n"; 37 | } 38 | 39 | $epp=new Net_EPP_Client(); 40 | 41 | $greeting=$epp->connect('servername','port',20); 42 | 43 | ``` -------------------------------------------------------------------------------- /Net/EPP/Frame/Command.php: -------------------------------------------------------------------------------- 1 | type = $type; 11 | $command = strtolower($command); 12 | if (!in_array($command, array('check', 'info', 'create', 'update', 'delete', 'renew', 'transfer', 'poll', 'login', 'logout'))) { 13 | trigger_error("Invalid argument value '$command' for \$command", E_USER_ERROR); 14 | } 15 | parent::__construct('command'); 16 | 17 | $this->command = $this->createElement($command); 18 | $this->body->appendChild($this->command); 19 | 20 | if (!empty($this->type)) { 21 | $this->payload = $this->createElementNS( 22 | Net_EPP_ObjectSpec::xmlns($this->type), 23 | $this->type.':'.$command 24 | ); 25 | 26 | $this->command->appendChild($this->payload); 27 | } 28 | } 29 | 30 | public function addclTRID($id) 31 | { 32 | $this->clTRID = $this->createElement('clTRID'); 33 | $this->clTRID->appendChild($this->createTextNode($id)); 34 | $this->body->appendChild($this->clTRID); 35 | } 36 | 37 | public function addObjectProperty($name, $value = null) 38 | { 39 | $element = $this->createObjectPropertyElement($name); 40 | $this->payload->appendChild($element); 41 | 42 | if ($value instanceof DomNode) { 43 | $element->appendChild($value); 44 | } elseif (isset($value)) { 45 | $element->appendChild($this->createTextNode($value)); 46 | } 47 | return $element; 48 | } 49 | 50 | public function createObjectPropertyElement($name, $type = null) 51 | { 52 | $ns_type = isset($type) ? $type : $this->type; 53 | $ns = !empty($ns_type) ? $ns_type.':'.$name : $name; 54 | return $this->createElementNS( 55 | Net_EPP_ObjectSpec::xmlns($ns_type), 56 | $ns 57 | ); 58 | } 59 | 60 | public function createExtension() 61 | { 62 | $this->extension = $this->createElement('extension'); 63 | $this->body->appendChild($this->extension); 64 | } 65 | 66 | /** 67 | * Creates an extension element with the option of specifying a custom namespace 68 | * @param $ext 69 | * @param $command 70 | * @param null $version * 71 | */ 72 | public function createExtensionElement($ext, $command, $version = null) 73 | { 74 | $this->extension->payload = $this->createElementNS( 75 | Net_EPP_ObjectSpec::xmlns($version !== null ? $version : $ext), 76 | $ext.':'.$command 77 | ); 78 | $this->extension->appendChild($this->extension->payload); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /Net/EPP/ObjectSpec.php: -------------------------------------------------------------------------------- 1 | array( 10 | 'xmlns' => 'urn:ietf:params:xml:ns:domain-1.0', 11 | 'id' => 'name', 12 | 'schema' => 'urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd', 13 | ), 14 | 'host' => array( 15 | 'xmlns' => 'urn:ietf:params:xml:ns:host-1.0', 16 | 'id' => 'name', 17 | 'schema' => 'urn:ietf:params:xml:ns:host-1.0 host-1.0.xsd', 18 | ), 19 | 'contact' => array( 20 | 'xmlns' => 'urn:ietf:params:xml:ns:contact-1.0', 21 | 'id' => 'id', 22 | 'schema' => 'urn:ietf:params:xml:ns:contact-1.0 contact-1.0.xsd', 23 | ), 24 | 'rgp' => array( 25 | 'xmlns' => 'urn:ietf:params:xml:ns:rgp-1.0', 26 | 'id' => 'id', 27 | 'schema' => 'urn:ietf:params:xml:ns:rgp-1.0 rgp-1.0.xsd', 28 | ), 29 | 'launch' => array( 30 | 'xmlns' => 'urn:ietf:params:xml:ns:launch-1.0', 31 | 'id' => 'id', 32 | 'schema' => 'urn:ar:params:xml:ns:launch-1.0 launch-1.0.xsd', 33 | ), 34 | 'idn' => array( 35 | 'xmlns' => 'urn:ietf:params:xml:ns:idn-1.0', 36 | 'id' => 'id', 37 | 'schema' => 'urn:ar:params:xml:ns:idn-1.0 idn-1.0.xsd', 38 | ), 39 | 'tmch' => array( 40 | 'xmlns' => 'urn:ar:params:xml:ns:tmch-1.0', 41 | 'id' => 'id', 42 | 'schema' => 'urn:ar:params:xml:ns:tmch-1.0 tmch-1.0.xsd', 43 | ), 44 | 'application' => array( 45 | 'xmlns' => 'urn:ar:params:xml:ns:application-1.0', 46 | 'id' => 'id', 47 | 'schema' => 'urn:ar:params:xml:ns:application-1.0 application-1.0.xsd', 48 | ), 49 | 'price' => array( 50 | 'xmlns' => 'urn:ar:params:xml:ns:price-1.0', 51 | 'id' => 'id', 52 | 'schema' => 'urn:ar:params:xml:ns:price-1.0 price-1.0.xsd', 53 | ), 54 | 'asia' => array( 55 | 'xmlns' => 'urn:ar:params:xml:ns:asia-1.0', 56 | 'id' => 'id', 57 | 'schema' => 'urn:ar:params:xml:ns:asia-1.0 asia-1.0.xsd', 58 | ), 59 | 'signedMark' => array( 60 | 'xmlns' => 'urn:ietf:params:xml:ns:signedMark-1.0', 61 | 'id' => 'domain', 62 | 'schema' => 'urn:ietf:params:xml:ns:signedMark-1.0 signedMark-1.0.xsd', 63 | ), 64 | 'fee' => array( 65 | 'xmlns' => 'urn:ietf:params:xml:ns:fee-0.5', 66 | 'id' => 'domain', 67 | 'schema' => 'urn:ietf:params:xml:ns:fee-0.5 fee-0.5.xsd', 68 | ), 69 | 'fee_23' => array( 70 | 'xmlns' => 'urn:ietf:params:xml:ns:fee-0.23', 71 | 'id' => 'domain', 72 | 'schema' => 'urn:ietf:params:xml:ns:fee-0.23 fee-0.23.xsd', 73 | ), 74 | 'allocationToken' => array( 75 | 'xmlns' => 'urn:ietf:params:xml:ns:allocationToken-1.0', 76 | 'id' => 'domain', 77 | 'schema' => 'urn:ietf:params:xml:ns:allocationToken-1.0 allocationToken-1.0.xsd', 78 | ), 79 | 'auxcontact' => array( 80 | 'xmlns' => 'urn:ietf:params:xml:ns:auxcontact-0.1', 81 | 'id' => 'domain', 82 | 'schema' => 'urn:ietf:params:xml:ns:auxcontact-0.1 auxcontact-1.0.xsd', 83 | ), 84 | ); 85 | 86 | public static function id($object) 87 | { 88 | return self::$_spec[$object]['id']; 89 | } 90 | 91 | public static function xmlns($object) 92 | { 93 | return self::$_spec[$object]['xmlns']; 94 | } 95 | 96 | public static function schema($object) 97 | { 98 | return self::$_spec[$object]['schema']; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /Net/EPP/Protocol.php: -------------------------------------------------------------------------------- 1 | 24 | * @revision $Id: Protocol.php,v 1.4 2011/06/28 09:48:02 gavin Exp $ 25 | */ 26 | 27 | /** 28 | * Low-level functions useful for both EPP clients and servers 29 | * @package Net_EPP 30 | */ 31 | class Net_EPP_Protocol 32 | { 33 | public static function _fread_nb($socket, $length) 34 | { 35 | $result = ''; 36 | 37 | // Loop reading and checking info to see if we hit timeout 38 | $info = stream_get_meta_data($socket); 39 | $time_start = $time_end = microtime(true); 40 | $timeout_time = $time_start + $GLOBALS['timeout']; 41 | 42 | while (!$info['timed_out'] && !feof($socket)) { 43 | //make sure we don't wait to long 44 | if (($time_end - $time_start) > 10000000) { 45 | $time_diff = microtime(true) - $time_start; 46 | throw new exception("Timeout reading from EPP server after $time_diff seconds"); 47 | } 48 | // Try read remaining data from socket 49 | $buffer = fread($socket, $length - strlen($result)); 50 | // If the buffer actually contains something then add it to the result 51 | if ($buffer !== false) { 52 | $result .= $buffer; 53 | // If we hit the length we looking for, break 54 | if (strlen($result) == $length) { 55 | break; 56 | } 57 | } else { 58 | // Sleep 0.25s 59 | usleep(250000); 60 | } 61 | // Update metadata 62 | $info = stream_get_meta_data($socket); 63 | $time_end = microtime(true); 64 | } 65 | 66 | // Check for timeout 67 | if ($info['timed_out']) { 68 | throw new Exception('Timeout while reading data from socket'); 69 | } 70 | if ($GLOBALS['debug']) { 71 | $time_diff = (microtime(true) - $time_start) * 1000; 72 | syslog(LOG_INFO, "returning after {$time_diff} ms"); 73 | } 74 | 75 | return $result; 76 | } 77 | 78 | public static function _fwrite_nb($socket, $buffer, $length) 79 | { 80 | // Loop writing and checking info to see if we hit timeout 81 | $info = stream_get_meta_data($socket); 82 | $time_start = microtime(true); 83 | 84 | $pos = 0; 85 | while (!$info['timed_out'] && !feof($socket)) { 86 | // Some servers don't like alot of data, so keep it small per chunk 87 | $wlen = $length - $pos; 88 | if ($wlen > 1024) { 89 | $wlen = 1024; 90 | } 91 | // Try write remaining data from socket 92 | $written = @fwrite($socket, substr($buffer, $pos), $wlen); 93 | // If we read something, bump up the position 94 | if ($written && $written !== false) { 95 | $pos += $written; 96 | // If we hit the length we looking for, break 97 | if ($pos == $length) { 98 | break; 99 | } 100 | } else { 101 | // Sleep 0.25s 102 | usleep(250000); 103 | } 104 | // Update metadata 105 | $info = stream_get_meta_data($socket); 106 | $time_end = microtime(true); 107 | $timeDiff = round(($time_end - $time_start) * 1000); 108 | if ($GLOBALS['debug']) { 109 | syslog(LOG_DEBUG, "time to write to socket ${timeDiff}ms"); 110 | } 111 | if (($time_end - $time_start) > 10000000) { 112 | throw new exception('Timeout while writing to EPP Server'); 113 | } 114 | } 115 | // Check for timeout 116 | if ($info['timed_out']) { 117 | throw new Exception('Timeout while writing data to socket'); 118 | } 119 | 120 | 121 | return $pos; 122 | } 123 | 124 | /** 125 | * get an EPP frame from the remote peer 126 | * @param resource $socket a socket connected to the remote peer 127 | * @throws Exception on frame errors. 128 | * @return string the frame 129 | */ 130 | public static function getFrame($socket) 131 | { 132 | if ($GLOBALS['debug']) { 133 | syslog(LOG_INFO, "start reading first 4 bytes"); 134 | } 135 | // Read header 136 | $hdr = Net_EPP_Protocol::_fread_nb($socket, 4); 137 | 138 | // Unpack first 4 bytes which is our length 139 | $unpacked = unpack('N', $hdr); 140 | $length = $unpacked[1]; 141 | if ($length < 5) { 142 | throw new Exception(sprintf('Got a bad frame header length of %d bytes from peer', $length)); 143 | } else { 144 | $length -= 4; // discard the length of the header itself 145 | // Read frame 146 | return Net_EPP_Protocol::_fread_nb($socket, $length); 147 | } 148 | } 149 | 150 | /** 151 | * send an EPP frame to the remote peer 152 | * @param resource $socket a socket connected to the remote peer 153 | * @param string $xml the XML to send 154 | * @throws Exception when it doesn't complete the write to the socket 155 | * @return the amount of bytes written to the frame 156 | */ 157 | public static function sendFrame($socket, $xml) 158 | { 159 | $length = strlen($xml) + 4; 160 | if ($GLOBALS['debug']) { 161 | syslog(LOG_INFO, "length of the header is ${length} about to write ${xml}"); 162 | } 163 | // Grab XML length & add on 4 bytes for the counter 164 | $res = Net_EPP_Protocol::_fwrite_nb($socket, pack('N', $length) . $xml, $length); 165 | // Check our write matches 166 | if ($length != $res) { 167 | throw new Exception("Short write when sending XML"); 168 | } 169 | 170 | return $res; 171 | } 172 | } 173 | -------------------------------------------------------------------------------- /Net/EPP/Simple.php: -------------------------------------------------------------------------------- 1 | 26 | */ 27 | class Net_EPP_Simple extends Net_EPP_Client { 28 | 29 | private $connected; 30 | private $logged_in; 31 | private $user; 32 | 33 | var $debug; 34 | 35 | /** 36 | * @var DOMDocument 37 | */ 38 | var $greeting; 39 | 40 | /** 41 | * @param string $host 42 | * @param string $user 43 | * @param string $pass 44 | * @param boolean $debug 45 | * @param integer $port 46 | * @param integer timeout 47 | * @param boolean $ssl 48 | * @param resource $context 49 | * @throws Net_EPP_Exception 50 | */ 51 | function __construct($host=NULL, $user=NULL, $pass=NULL, $debug=false, $port=700, $timeout=1, $ssl=true, $context=NULL) { 52 | $this->connected = false; 53 | $this->logged_in = false; 54 | $this->debug = $debug; 55 | $this->user = $user; 56 | 57 | if ($host) $this->connect($host, $port, $timeout, $ssl, $context); 58 | if ($user && $pass) $this->login($user, $pass); 59 | } 60 | 61 | /** 62 | * @param string $user 63 | * @param string $pass 64 | * @throws Net_EPP_Exception 65 | */ 66 | function login($user, $pass) { 67 | if (!$this->connected) throw new Net_EPP_Exception("Not connected"); 68 | $frame = new Net_EPP_Frame_Command_Login; 69 | $frame->clID->appendChild($frame->createTextNode($user)); 70 | $frame->pw->appendChild($frame->createTextNode($pass)); 71 | 72 | $frame->eppVersion->appendChild($frame->createTextNode($this->greeting->getElementsByTagNameNS(Net_EPP_Frame::EPP_URN, 'version')->item(0)->textContent)); 73 | $frame->eppLang->appendChild($frame->createTextNode($this->greeting->getElementsByTagNameNS(Net_EPP_Frame::EPP_URN, 'lang')->item(0)->textContent)); 74 | 75 | $els = $this->greeting->getElementsByTagNameNS(Net_EPP_Frame::EPP_URN, 'objURI'); 76 | for ($i = 0 ; $i < $els->length ; $i++) $frame->svcs->appendChild($frame->importNode($els->item($i), true)); 77 | 78 | $els = $this->greeting->getElementsByTagNameNS(Net_EPP_Frame::EPP_URN, 'svcExtension'); 79 | if (1 == $els->length) $frame->svcs->appendChild($frame->importNode($els->item(0), true)); 80 | 81 | $this->request($frame); 82 | } 83 | 84 | function checkDomain($domain) { 85 | } 86 | 87 | function checkDomains($domains) { 88 | } 89 | 90 | function checkHost($host) { 91 | } 92 | 93 | function checkHosts($host) { 94 | } 95 | 96 | function checkContact($contact) { 97 | } 98 | 99 | function checkContacts($contacts) { 100 | } 101 | 102 | function domainInfo($domain, $authInfo=NULL) { 103 | } 104 | 105 | function hostInfo($host, $authInfo=NULL) { 106 | } 107 | 108 | function contactInfo($contact, $authInfo=NULL) { 109 | } 110 | 111 | function domainTransferQuery($domain) { 112 | } 113 | 114 | function domainTransferCancel($domain) { 115 | } 116 | 117 | function domainTransferRequest($domain, $authInfo, $period, $unit='y') { 118 | } 119 | 120 | function domainTransferApprove($domain) { 121 | } 122 | 123 | function domainTransferReject($domain) { 124 | } 125 | 126 | function contactTransferQuery($contact) { 127 | } 128 | 129 | function contactTransferCancel($contact) { 130 | } 131 | 132 | function contactTransferRequest($contact, $authInfo) { 133 | } 134 | 135 | function contactTransferApprove($contact) { 136 | } 137 | 138 | function contactTransferReject($contact) { 139 | } 140 | 141 | function createDomain($domain) { 142 | } 143 | 144 | function createHost($host) { 145 | } 146 | 147 | function createContact($contact) { 148 | } 149 | 150 | function updateDomain($domain, $add, $rem, $chg) { 151 | } 152 | 153 | function updateContact($contact, $add, $rem, $chg) { 154 | } 155 | 156 | function updateHost($host, $add, $rem, $chg) { 157 | } 158 | 159 | function deleteDomain($domain) { 160 | } 161 | 162 | function deleteHost($host) { 163 | } 164 | 165 | function deleteContact($contact) { 166 | } 167 | 168 | function renewDomain($domain, $period, $unit='y') { 169 | } 170 | 171 | function ping() { 172 | } 173 | 174 | private function _check($type, $objects) { 175 | $class = 'Net_EPP_Frame_Command_Check_'.ucfirst($type); 176 | $frame = new $class; 177 | 178 | foreach ($objects as $object) $frame->addObject($object); 179 | $frame->clTRID->appendChild($frame->createTextNode($this->clTRID())); 180 | 181 | $result = $this->request($frame); 182 | } 183 | 184 | /* 185 | * send a frame to the server and get the response 186 | * @param DOMDocument|string $frame 187 | * @return DOMDocument 188 | * @throws Net_EPP_Exception 189 | */ 190 | function request($frame) { 191 | $this->sendFrame($frame); 192 | $response = $this->getFrame(); 193 | return $response; 194 | } 195 | 196 | /* 197 | * send a to the server 198 | * @throws Net_EPP_Exception 199 | */ 200 | function logout() { 201 | $this->debug("logging out"); 202 | $frame = new Net_EPP_Frame_Command_Logout; 203 | $frame->clTRID->appendChild($frame->createTextNode($this->clTRID())); 204 | $this->request($frame); 205 | } 206 | 207 | /* 208 | * connect to the server 209 | * @param string $host 210 | * @param integer $port 211 | * @param integer timeout 212 | * @param boolean $ssl 213 | * @param resource $context 214 | * @throws Net_EPP_Exception 215 | * @return DOMDocument the frame recived from the server 216 | */ 217 | function connect($host, $port, $timeout, $ssl, $context) { 218 | $this->debug("attempting to connect to %s:%d", $host, $port); 219 | $dom = parent::connect($host, $port, $timeout, $ssl, $context); 220 | $this->debug("connected OK"); 221 | $this->connected = true; 222 | $this->greeting = new Net_EPP_Frame_Greeting; 223 | $this->greeting->loadXML($dom->saveXML()); 224 | return $this->greeting; 225 | } 226 | 227 | /* 228 | * get a frame from the server 229 | * @return DOMDocument 230 | * @throws Net_EPP_Exception 231 | */ 232 | function getFrame() { 233 | $xml = parent::getFrame(); 234 | foreach (explode("\n", str_replace('><', ">\n<", trim($xml))) as $line) $this->debug("S: %s", $line); 235 | return DOMDocument::loadXML($xml); 236 | } 237 | 238 | /* 239 | * send a frame to the server 240 | * @param DOMDocument|string $xml 241 | * @return integer number of btyes sent 242 | * @throws Net_EPP_Exception 243 | */ 244 | function sendFrame($xml) { 245 | if ($xml instanceof DOMDocument) $xml = $xml->saveXML(); 246 | foreach (explode("\n", str_replace('><', ">\n<", trim($xml))) as $line) $this->debug("C: %s", $line); 247 | return parent::sendFrame($xml); 248 | } 249 | 250 | /* 251 | * write a debug messge to the error log - is silent unless 252 | * debugging is enabled 253 | * @param string $format 254 | * @param one or more variables 255 | * @return boolean 256 | */ 257 | protected function debug() { 258 | if (!$this->debug) return true; 259 | $args = func_get_args(); 260 | error_log(vsprintf(array_shift($args), $args)); 261 | } 262 | 263 | /* 264 | * destructor - cleanly disconnect from the server 265 | * @throws Net_EPP_Exception 266 | */ 267 | function __destruct() { 268 | if ($this->logged_in) $this->logout(); 269 | $this->debug("disconnecting from server"); 270 | $this->disconnect(); 271 | } 272 | 273 | /* 274 | * generate a client transaction ID 275 | * @return string 276 | */ 277 | function clTRID() { 278 | $clTRID = base_convert( 279 | hash('sha256', ($this->user ? $this->user.'-' : '').uniqid()), 280 | 16, 281 | 36 282 | ); 283 | } 284 | } -------------------------------------------------------------------------------- /Net/EPP/Client.php: -------------------------------------------------------------------------------- 1 | 24 | * @revision $Id: Client.php,v 1.13 2010/10/21 11:55:07 gavin Exp $ 25 | */ 26 | require_once('Protocol.php'); 27 | 28 | $GLOBALS['Net_EPP_Client_Version'] = '0.0.6'; 29 | 30 | /** 31 | * A simple client class for the Extensible Provisioning Protocol (EPP) 32 | * @package Net_EPP 33 | */ 34 | class Net_EPP_Client 35 | { 36 | 37 | /** 38 | * @var resource the socket resource, once connected 39 | */ 40 | public $socket; 41 | /** 42 | * @var bool do output more debug messages 43 | */ 44 | public $debug; 45 | 46 | /** 47 | * @var integer timeout to wait on commands 48 | */ 49 | public $timeout; 50 | 51 | /** 52 | * constructor set initialize various objects 53 | * @param boolean set debugging on 54 | */ 55 | public function __construct($debug = false) 56 | { 57 | $this->debug = $debug; 58 | $GLOBALS['debug'] = $debug; 59 | $this->socket = null; 60 | } 61 | 62 | /** 63 | * Establishes a connect to the server 64 | * This method establishes the connection to the server. If the connection was 65 | * established, then this method will call getFrame() and return the EPP 66 | * frame which is sent by the server upon connection. If connection fails, then 67 | * an exception with a message explaining the error will be thrown and handled 68 | * in the calling code. 69 | * @param string $host the hostname 70 | * @param integer $port the TCP port 71 | * @param integer $timeout the timeout in seconds 72 | * @param boolean $ssl whether to connect using SSL 73 | * @param resource $context a stream resource to use when setting up the socket connection 74 | *@param string $protocol whether to use TLS or SSL 75 | * @throws Exception on connection errors 76 | * @return a string containing the server 77 | */ 78 | public function connect($host, $port = 700, $timeout = 1, $ssl = true, $context = null, $protocol = 'tls') 79 | { 80 | if ($this->debug) { 81 | syslog(LOG_INFO, "in connect"); 82 | } 83 | 84 | $target = sprintf('%s://%s:%d', ($ssl === true ? $protocol : 'tcp'), $host, $port); 85 | if ($this->debug) { 86 | syslog(LOG_INFO, "connecting to {$target}"); 87 | } 88 | 89 | if (is_resource($context)) { 90 | if ($this->debug) { 91 | syslog(LOG_INFO, "using your provided context resource"); 92 | } 93 | $result = stream_socket_client($target, $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $context); 94 | } else { 95 | $result = stream_socket_client($target, $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT); 96 | } 97 | if (is_resource($result)) { 98 | if ($errno == 0) { 99 | if ($this->debug) { 100 | $socketmeta = stream_get_meta_data($result); 101 | if (isset($socketmeta['crypto'])) { 102 | syslog(LOG_NOTICE, "socket opened with protocol ".$socketmeta['crypto']['protocol'].", cipher ".$socketmeta['crypto']['cipher_name'].", ".$socketmeta['crypto']['cipher_bits']." bits ".$socketmeta['crypto']['cipher_version']); 103 | } else { 104 | syslog(LOG_INFO, "socket opened without crypt"); 105 | } 106 | } 107 | // Set our socket 108 | $this->socket = $result; 109 | } else { 110 | throw new Exception("non errono 0 retrieved from socket connection: {$errno}"); 111 | } 112 | } else { 113 | if ($result === false && $errno == 0) { 114 | throw new Exception("Connection could not be opened due to socket problem. Reasons can be unmatched peer name, tls not supported..."); 115 | } else { 116 | throw new Exception("Connection could not be opened: $errno $errstr"); 117 | } 118 | } 119 | 120 | // Set stream timeout 121 | if (!stream_set_timeout($this->socket, $timeout)) { 122 | throw new Exception("Failed to set timeout on socket: $errstr (code $errno)"); 123 | } 124 | $this->timeout = $timeout; 125 | $GLOBALS['timeout'] = $timeout; 126 | 127 | // Set blocking 128 | if (!stream_set_blocking($this->socket, 0)) { 129 | throw new Exception("Failed to set blocking on socket: $errstr (code $errno)"); 130 | } 131 | if ($this->debug) { 132 | syslog(LOG_INFO, "trying to get frame from server"); 133 | } 134 | return $this->getFrame(); 135 | } 136 | 137 | /** 138 | * Get an EPP frame from the server. 139 | * This retrieves a frame from the server. Since the connection is blocking, this 140 | * method will wait until one becomes available. If the connection has been broken, 141 | * this method will return a string containing the XML from the server 142 | * @throws Exception on frame errors 143 | * @return a string containing the frame 144 | */ 145 | public function getFrame() 146 | { 147 | return Net_EPP_Protocol::getFrame($this->socket); 148 | } 149 | 150 | /** 151 | * Send an XML frame to the server. 152 | * This method sends an EPP frame to the server. 153 | * @param string the XML data to send 154 | * @throws Exception when it doesn't complete the write to the socket 155 | * @return boolean the result of the fwrite() operation 156 | */ 157 | public function sendFrame($xml) 158 | { 159 | return Net_EPP_Protocol::sendFrame($this->socket, $xml); 160 | } 161 | 162 | /** 163 | * a wrapper around sendFrame() and getFrame() 164 | * @param string $xml the frame to send to the server 165 | * @throws Exception when it doesn't complete the write to the socket 166 | * @return string the frame returned by the server, or an error object 167 | */ 168 | public function request($xml) 169 | { 170 | $res = $this->sendFrame($xml); 171 | return $this->getFrame(); 172 | } 173 | 174 | /** 175 | * Close the connection. 176 | * This method closes the connection to the server. Note that the 177 | * EPP specification indicates that clients should send a 178 | * command before ending the session. 179 | * @return boolean the result of the fclose() operation 180 | */ 181 | public function disconnect() 182 | { 183 | return @fclose($this->socket); 184 | } 185 | 186 | /** 187 | * ping the connection to check that it's up 188 | * @return boolean 189 | */ 190 | public function ping() 191 | { 192 | return (!is_resource($this->socket) || feof($this->socket) ? false : true); 193 | } 194 | } 195 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. 5 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Library General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License 307 | along with this program; if not, write to the Free Software 308 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 309 | 310 | 311 | Also add information on how to contact you by electronic and paper mail. 312 | 313 | If the program is interactive, make it output a short notice like this 314 | when it starts in an interactive mode: 315 | 316 | Gnomovision version 69, Copyright (C) year name of author 317 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 318 | This is free software, and you are welcome to redistribute it 319 | under certain conditions; type `show c' for details. 320 | 321 | The hypothetical commands `show w' and `show c' should show the appropriate 322 | parts of the General Public License. Of course, the commands you use may 323 | be called something other than `show w' and `show c'; they could even be 324 | mouse-clicks or menu items--whatever suits your program. 325 | 326 | You should also get your employer (if you work as a programmer) or your 327 | school, if any, to sign a "copyright disclaimer" for the program, if 328 | necessary. Here is a sample; alter the names: 329 | 330 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 331 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 332 | 333 | , 1 April 1989 334 | Ty Coon, President of Vice 335 | 336 | This General Public License does not permit incorporating your program into 337 | proprietary programs. If your program is a subroutine library, you may 338 | consider it more useful to permit linking proprietary applications with the 339 | library. If this is what you want to do, use the GNU Library General 340 | Public License instead of this License. 341 | --------------------------------------------------------------------------------