opensrs-php-cvs Mailing List for PHP OpenSRS Client
Brought to you by:
cviebrock
You can subscribe to this list here.
| 2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(8) |
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2001 |
Jan
(2) |
Feb
|
Mar
(3) |
Apr
(3) |
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
(1) |
| 2002 |
Jan
(1) |
Feb
(3) |
Mar
|
Apr
|
May
(5) |
Jun
|
Jul
|
Aug
(1) |
Sep
(3) |
Oct
|
Nov
(1) |
Dec
(1) |
| 2003 |
Jan
(2) |
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
(9) |
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
| 2004 |
Jan
|
Feb
(7) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(5) |
| 2005 |
Jan
(2) |
Feb
(3) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Colin V. <cvi...@us...> - 2005-03-11 18:34:55
|
Update of /cvsroot/opensrs-php/opensrs-php In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6760 Modified Files: Tag: opensrs_php_2 CHANGELOG OPS.php Log Message: added OPS->_prettifyXML(), making logging compressed XML/HTML nicer Index: CHANGELOG =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/CHANGELOG,v retrieving revision 1.23.2.5 retrieving revision 1.23.2.6 diff -u -r1.23.2.5 -r1.23.2.6 --- CHANGELOG 25 Feb 2005 21:19:32 -0000 1.23.2.5 +++ CHANGELOG 11 Mar 2005 18:34:45 -0000 1.23.2.6 @@ -4,6 +4,7 @@ Version x.x.x xx-xxx-xxxx - hack to allow empty associative arrays, using: array( NULL => NULL ) + - added OPS->_prettifyXML(), making logging compressed XML/HTML nicer Version 2.8.0 Index: OPS.php =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/OPS.php,v retrieving revision 1.8.2.5 retrieving revision 1.8.2.6 diff -u -r1.8.2.5 -r1.8.2.6 --- OPS.php 25 Feb 2005 21:15:32 -0000 1.8.2.5 +++ OPS.php 11 Mar 2005 18:34:45 -0000 1.8.2.6 @@ -579,6 +579,45 @@ /** + * Formats (indents) XML + * + * @param string XML string to make pretty + * + * @return string prettified XML + * + */ + + function _prettifyXML($xml) + { + $xml = trim(preg_replace('/>([^<]*)</m', ">\n\\1\n<", $xml)); + $x = preg_split("/\n+/", $xml); + $r = ''; + $i = 0; + foreach($x as $line) { + + $line = trim($line); + if (empty($line)) { + continue; + } + + if ( substr($line,0,2)=='</') { + $r .= str_repeat($this->_SPACER, --$i) . $line . $this->_CRLF; + } else if ( substr($line,0,1)=='<' && substr($line,0,2)!='<!' && substr($line,0,2)!='<?' ) { + $r .= str_repeat($this->_SPACER, $i++) . $line . $this->_CRLF; + if (substr($line,-2)=='/>') { + $i--; + } + } else { + $r .= str_repeat($this->_SPACER, $i) . $line . $this->_CRLF; + } + + } + + return trim($r); + } + + + /** * Determines if an array is associative or not, since PHP * doesn't really distinguish between the two, but Perl/OPS does * @@ -624,6 +663,10 @@ ); if ($log=='xml' || $log=='http') { + if ($this->_OPT != 'compress' ) { + $msg = $this->_prettifyXML($msg); + } + $this->log[$log][] = sprintf("[% 6s:%06d] %s\n", strtoupper($types[$type]), ($type=='e' || $type=='i') ? 0 : strlen($msg), |
|
From: Colin V. <cvi...@us...> - 2005-02-25 21:19:41
|
Update of /cvsroot/opensrs-php/opensrs-php In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15076 Modified Files: Tag: opensrs_php_2 CHANGELOG Log Message: changelog Index: CHANGELOG =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/CHANGELOG,v retrieving revision 1.23.2.4 retrieving revision 1.23.2.5 diff -u -r1.23.2.4 -r1.23.2.5 --- CHANGELOG 28 Jan 2005 22:21:41 -0000 1.23.2.4 +++ CHANGELOG 25 Feb 2005 21:19:32 -0000 1.23.2.5 @@ -1,12 +1,18 @@ CHANGELOG --------- +Version x.x.x +xx-xxx-xxxx + - hack to allow empty associative arrays, using: array( NULL => NULL ) + + Version 2.8.0 15-Dec-2004 - added support for XML over HTTPS POST method for OpenSRS - (Jason Slaughter) - - new crypt_type "SSL," changed default to BLOWFISH from DES - (Jason Slaughter) + (Jason Slaughter) + - new crypt_type "SSL", changed default to BLOWFISH from DES + (Jason Slaughter) + - minor fix to ops.dtd (Jason Slaughter) Version 2.7.3 |
|
From: Colin V. <cvi...@us...> - 2005-02-25 21:17:09
|
Update of /cvsroot/opensrs-php/opensrs-php In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14214 Modified Files: CHANGELOG OPS.php README Log Message: hack for empty assoc arrays Index: CHANGELOG =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/CHANGELOG,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- CHANGELOG 11 Feb 2004 17:08:51 -0000 1.26 +++ CHANGELOG 25 Feb 2005 21:16:58 -0000 1.27 @@ -1,18 +1,24 @@ CHANGELOG --------- -Version 3.0.0 +Version x.x.x xx-xxx-xxxx - - PEAR-ify entire class + Version 2.8.0 -10-Feb-2004 (Jason Slaughter) +15-Dec-2004 - added support for XML over HTTPS POST method for OpenSRS + (Jason Slaughter) - new crypt_type "SSL," changed default to BLOWFISH from DES - - minor fix to ops.dtd + (Jason Slaughter) + - minor fix to ops.dtd (Jason Slaughter) + + +Version 2.7.3 +15-Aug-2003 - Updated README to reflect HRS functionality - exposed HRS_port in the config file, since that port number - is different for each HRS customer (Jason Slaughter) + is different for each HRS customer (Jason Slaughter) Version 2.7.2 Index: OPS.php =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/OPS.php,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- OPS.php 7 Dec 2004 20:22:20 -0000 1.13 +++ OPS.php 25 Feb 2005 21:16:58 -0000 1.14 @@ -486,13 +486,13 @@ $msg_type = $this->_MSGTYPE_STD; - if ($array['protocol']) { + if (!empty($array['protocol'])) { $array['protocol'] = strtoupper($array['protocol']); } - if ($array['action']) { + if (!empty($array['action'])) { $array['action'] = strtoupper($array['action']); } - if ($array['object']) { + if (!empty($array['object'])) { $array['object'] = strtoupper($array['object']); } @@ -573,6 +573,11 @@ continue; } + /* hack for an empty associative array */ + if (empty($k) && $v===NULL) { + continue; + } + $string .= $this->_OUTPUT_LF . $IND . '<item key="' . $k . '"'; if (gettype($v)=='object' && get_class($v)) { Index: README =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/README,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- README 7 Dec 2004 20:22:20 -0000 1.22 +++ README 25 Feb 2005 21:16:58 -0000 1.23 @@ -233,6 +233,7 @@ and general help - Victor Magdic at Tucows Inc. <vm...@tu...> who wrote the original Perl API +- Jason Slaughter at Tucows for the SSL-method code - the rest of the folks at OpenSRS (Ross, Dan, Charles, Erol, et al) - easyDNS <www.easydns.com>, my previous employer which "funded" most of the client development |
|
From: Colin V. <cvi...@us...> - 2005-02-25 21:15:41
|
Update of /cvsroot/opensrs-php/opensrs-php In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13623 Modified Files: Tag: opensrs_php_2 OPS.php Log Message: Fix to support empty associative arrays. Use this to define one: array( NULL => NULL ) Index: OPS.php =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/OPS.php,v retrieving revision 1.8.2.4 retrieving revision 1.8.2.5 diff -u -r1.8.2.4 -r1.8.2.5 --- OPS.php 28 Jan 2005 22:21:41 -0000 1.8.2.4 +++ OPS.php 25 Feb 2005 21:15:32 -0000 1.8.2.5 @@ -432,13 +432,13 @@ $msg_type = $this->_MSGTYPE_STD; - if ($array['protocol']) { + if (!empty($array['protocol'])) { $array['protocol'] = strtoupper($array['protocol']); } - if ($array['action']) { + if (!empty($array['action'])) { $array['action'] = strtoupper($array['action']); } - if ($array['object']) { + if (!empty($array['object'])) { $array['object'] = strtoupper($array['object']); } @@ -515,10 +515,16 @@ $indent++; /* don't encode some types of stuff */ - if ((gettype($v)=='resource') || (gettype($v)=='user function') || (gettype($v)=='unknown type')) { + if ( (gettype($v)=='resource') || (gettype($v)=='user function') || (gettype($v)=='unknown type') ) { continue; } + /* hack for an empty associative array */ + if (empty($k) && $v===NULL) { + continue; + } + + $string .= $this->_CRLF . $IND . '<item key="' . $k . '"'; if (gettype($v)=='object' && get_class($v)) { |
|
From: Colin V. <cvi...@us...> - 2005-01-28 22:21:56
|
Update of /cvsroot/opensrs-php/opensrs-php In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8752 Modified Files: Tag: opensrs_php_2 CHANGELOG OPS.php README Log Message: 2.8.0 changes that didn't get committed, for some reason Index: CHANGELOG =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/CHANGELOG,v retrieving revision 1.23.2.3 retrieving revision 1.23.2.4 diff -u -r1.23.2.3 -r1.23.2.4 --- CHANGELOG 11 Feb 2004 17:02:55 -0000 1.23.2.3 +++ CHANGELOG 28 Jan 2005 22:21:41 -0000 1.23.2.4 @@ -2,11 +2,15 @@ --------- Version 2.8.0 -10-Feb-2004 +15-Dec-2004 - added support for XML over HTTPS POST method for OpenSRS (Jason Slaughter) - new crypt_type "SSL," changed default to BLOWFISH from DES (Jason Slaughter) + + +Version 2.7.3 +15-Aug-2003 - minor fix to ops.dtd (Jason Slaughter) - Updated README to reflect HRS functionality - exposed HRS_port in the config file, since that port number Index: OPS.php =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/OPS.php,v retrieving revision 1.8.2.3 retrieving revision 1.8.2.4 diff -u -r1.8.2.3 -r1.8.2.4 --- OPS.php 7 Dec 2004 20:27:22 -0000 1.8.2.3 +++ OPS.php 28 Jan 2005 22:21:41 -0000 1.8.2.4 @@ -618,7 +618,7 @@ ); if ($log=='xml' || $log=='http') { - $this->log[$log][] = sprintf("[% 6s:%06d]\n%s\n", + $this->log[$log][] = sprintf("[% 6s:%06d] %s\n", strtoupper($types[$type]), ($type=='e' || $type=='i') ? 0 : strlen($msg), $msg Index: README =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/README,v retrieving revision 1.21.2.2 retrieving revision 1.21.2.3 diff -u -r1.21.2.2 -r1.21.2.3 --- README 7 Dec 2004 20:27:22 -0000 1.21.2.2 +++ README 28 Jan 2005 22:21:42 -0000 1.21.2.3 @@ -47,23 +47,34 @@ It requires that support be compiled in for: - PEAR extensions (use "--with-pear") - - the mcrypt library (use "--with-mcrypt"), as recent a stable - version as you can get (2.4.18 or higher should be safe) - expat XML functions (use "--with-xml" and "--with-expat-dir=DIR" if you don't want to use the bundled Expat library) - Perl regular expressions (compiled by default, but use "--with-pcre-regex=DIR" if you don't want the bundled PCRE library) + If you plan on using the old socket method to connect to OpenSRS, you + will also need to compile in support for: + - the mcrypt library (use "--with-mcrypt"), as recent a stable + version as you can get (2.4.18 or higher should be safe) + + If you plan on using the HTTPS POST method to connect to OpenSRS, you + will also need to compile in support for: + - the openssl library (use "--with-openssl"), as recent a stable + version as you can get + PEAR is part of current PHP releases, but will eventually be found separately at http://pear.php.net/. Once PEAR is installed, you will need - to install the Crypt_CBC package: http://pear.php.net/Crypt_CBC + to install the Crypt_CBC package: http://pear.php.net/Crypt_CBC (if you use + the socket method). - mcrypt libraries can be found at http://mcrypt.hellug.gr/lib/ or - Freshmeat. - PCRE libraries and James Clark's expat are bundled with PHP 4.x. If you don't want the bundled libraries, you can get them from Sourceforge at - http://pcre.sourceforge.net/ and http://expat.sourceforge.net/ + http://pcre.sourceforge.net/ and http://expat.sourceforge.net/. + + mcrypt libraries can be found at http://mcrypt.hellug.gr/lib/ or + Freshmeat. + + openssl libraries can be found at http://www.openssl.org/. @@ -115,7 +126,7 @@ var $TEST_PRIVATE_KEY = '1234567890abcdef'; # your private key on the test (horizon) server var $LIVE_PRIVATE_KEY = 'abcdef1234567890'; # your private key on the live server var $environment = 'TEST'; # 'TEST' or 'LIVE' - var $crypt_type = 'DES'; # 'DES' or 'BLOWFISH'; + var $crypt_type = 'BLOWFISH'; # 'DES' or 'BLOWFISH' or 'SSL'; var $ext_version = 'Foobar'; # anything you want } @@ -211,7 +222,7 @@ var $HRS_host = 'foobar.opensrs.net'; # your OpenHRS hostname var $environment = 'HRS'; # 'TEST' or 'LIVE' or 'HRS' - var $crypt_type = 'DES'; # 'DES' or 'BLOWFISH' + var $crypt_type = 'BLOWFISH'; # 'DES' or 'BLOWFISH' or 'SSL'; var $ext_version = 'Foobar'; # anything you want } |
|
From: Colin V. <cvi...@us...> - 2005-01-28 16:33:46
|
Update of /cvsroot/opensrs-php/opensrs-php In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20315 Modified Files: Tag: opensrs_php_2 openSRS_base.php Log Message: bug fixes from ros...@cy... Index: openSRS_base.php =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/openSRS_base.php,v retrieving revision 1.16.2.4 retrieving revision 1.16.2.5 diff -u -r1.16.2.4 -r1.16.2.5 --- openSRS_base.php 7 Dec 2004 20:27:22 -0000 1.16.2.4 +++ openSRS_base.php 28 Jan 2005 16:33:06 -0000 1.16.2.5 @@ -7,7 +7,7 @@ * Copyright (C) 2000-2004 Colin Viebrock * * Version 2.8.0 - * 10-Feb-2004 + * 15-Dec-2004 * ************************************************************************** * @@ -60,7 +60,7 @@ var $VERSION = 'XML:0.1'; - var $base_class_version = '2.7.3'; + var $base_class_version = '2.8.0'; var $environment = 'TEST'; /* 'TEST' or 'LIVE' or 'HRS' */ var $protocol = 'XCP'; /* 'XCP' or 'TPP' */ @@ -96,7 +96,7 @@ var $_CRYPT; var $_iv; - var $crypt_type = 'BLOWFISH'; /* 'DES' or 'BLOWFISH' or 'SSL' */ + var $crypt_type = 'BLOWFISH'; /* 'DES' or 'BLOWFISH' or 'SSL' */ var $crypt_mode = 'CBC'; /* only 'CBC' */ var $crypt_rand_source = MCRYPT_DEV_URANDOM; /* or MCRYPT_DEV_RANDOM or MCRYPT_RAND */ var $affiliate_id; @@ -431,25 +431,25 @@ $required_contact_fields = array ( 'first_name' => 'First Name', - 'last_name' => 'Last Name', - 'org_name' => 'Organization Name', - 'address1' => 'Address1', - 'city' => 'City', - 'country' => 'Country', - 'phone' => 'Phone', - 'email' => 'E-Mail' - ); + 'last_name' => 'Last Name', + 'org_name' => 'Organization Name', + 'address1' => 'Address1', + 'city' => 'City', + 'country' => 'Country', + 'phone' => 'Phone', + 'email' => 'E-Mail' + ); $contact_types = array ( 'owner' => '', 'billing' => 'Billing' - ); + ); $required_fields = array ( 'reg_username' => 'Username', 'reg_password' => 'Password', 'domain' => 'Domain', - ); + ); if (isset($params['custom_tech_contact'])) { $contact_types['tech'] = 'Tech'; @@ -948,7 +948,7 @@ if (strlen($domain) > $maxLengthForThisCase) { return "Domain name exceeds maximum length for registry ($maxLengthForThisCase)"; - } else if (!preg_match('/'.$OPENSRS_TLDS_REGEX.'$/', $domain)) { + } else if (!preg_match('/'.$this->OPENSRS_TLDS_REGEX.'$/', $domain)) { return "Top level domain in \"$domain\" is unavailable"; } else if (!preg_match('/^[a-zA-Z0-9][.a-zA-Z0-9\-]*[a-zA-Z0-9]'.$this->OPENSRS_TLDS_REGEX.'$/', $domain)) { return "Invalid domain format (try something similar to \"yourname.com\")"; @@ -1198,7 +1198,6 @@ if ('SSL' == $this->crypt_type) { $this->_OPS->_log('http', 'r', $header['full_header'].$line); - $this->close_socket(); } return $buf; } |
Update of /cvsroot/opensrs-php/opensrs-php In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30775 Modified Files: Tag: opensrs_php_2 OPS.php README country_codes.php openSRS.php.default openSRS_base.php test.php Log Message: update copyright notices, credits, contact info Index: OPS.php =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/OPS.php,v retrieving revision 1.8.2.2 retrieving revision 1.8.2.3 diff -u -r1.8.2.2 -r1.8.2.3 --- OPS.php 11 Feb 2004 17:02:55 -0000 1.8.2.2 +++ OPS.php 7 Dec 2004 20:27:22 -0000 1.8.2.3 @@ -4,8 +4,7 @@ * * OpenSRS-PHP * - * Copyright (C) 2000, 2001, 2002, 2003, 2004 Colin Viebrock - * and easyDNS Technologies Inc. + * Copyright (C) 2000-2004 Colin Viebrock * ************************************************************************** * Index: README =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/README,v retrieving revision 1.21.2.1 retrieving revision 1.21.2.2 diff -u -r1.21.2.1 -r1.21.2.2 --- README 11 Feb 2004 17:02:56 -0000 1.21.2.1 +++ README 7 Dec 2004 20:27:22 -0000 1.21.2.2 @@ -1,8 +1,7 @@ OpenSRS-PHP A PHP class to facilitate communicatation with OpenSRS' servers -Copyright 2000, 2001, 2002, 2003,2004 Colin Viebrock - and easyDNS Technologies Inc. +Copyright 2000-2004 Colin Viebrock @@ -235,6 +234,8 @@ - Victor Magdic at Tucows who wrote the original Perl API - Jason Slaughter at Tucows for the SSL-method code - the rest of the folks at OpenSRS (Ross, Dan, Charles, Erol, et al) +- easyDNS <www.easydns.com>, my previous employer which "funded" most of + the client development - all the users who've suggested changes or provided bug fixes - anyone else I forgot @@ -244,13 +245,8 @@ ------- Colin Viebrock -easyDNS Technologies Inc. -304A - 219 Dufferin Street -Toronto, ON, CANADA -M6G 3J4 - -email: co...@ea... -web: http://www.easydns.com/ +email: colin at viebrock dot ca +web: http://viebrock.ca Index: country_codes.php =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/country_codes.php,v retrieving revision 1.3.2.1 retrieving revision 1.3.2.2 diff -u -r1.3.2.1 -r1.3.2.2 --- country_codes.php 11 Feb 2004 17:02:56 -0000 1.3.2.1 +++ country_codes.php 7 Dec 2004 20:27:22 -0000 1.3.2.2 @@ -4,8 +4,7 @@ * * OpenSRS-PHP * - * Copyright (C) 2000, 2001, 2002, 2003, 2004 Colin Viebrock - * and easyDNS Technologies Inc. + * Copyright (C) 2000-2004 Colin Viebrock * ************************************************************************** * Index: openSRS.php.default =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/openSRS.php.default,v retrieving revision 1.7.2.2 retrieving revision 1.7.2.3 diff -u -r1.7.2.2 -r1.7.2.3 --- openSRS.php.default 11 Feb 2004 17:02:56 -0000 1.7.2.2 +++ openSRS.php.default 7 Dec 2004 20:27:22 -0000 1.7.2.3 @@ -4,8 +4,7 @@ * * OpenSRS-PHP * - * Copyright (C) 2000, 2001, 2002, 2003, 2004 Colin Viebrock - * and easyDNS Technologies Inc. + * Copyright (C) 2000-2004 Colin Viebrock * ************************************************************************** * Index: openSRS_base.php =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/openSRS_base.php,v retrieving revision 1.16.2.3 retrieving revision 1.16.2.4 diff -u -r1.16.2.3 -r1.16.2.4 --- openSRS_base.php 11 Feb 2004 17:02:56 -0000 1.16.2.3 +++ openSRS_base.php 7 Dec 2004 20:27:22 -0000 1.16.2.4 @@ -4,8 +4,7 @@ * * OpenSRS-PHP * - * Copyright (C) 2000, 2001, 2002, 2003, 2004 Colin Viebrock - * and easyDNS Technologies Inc. + * Copyright (C) 2000-2004 Colin Viebrock * * Version 2.8.0 * 10-Feb-2004 Index: test.php =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/test.php,v retrieving revision 1.17 retrieving revision 1.17.2.1 diff -u -r1.17 -r1.17.2.1 --- test.php 18 Jun 2003 19:53:22 -0000 1.17 +++ test.php 7 Dec 2004 20:27:22 -0000 1.17.2.1 @@ -4,8 +4,7 @@ * * OpenSRS-PHP * - * Copyright (C) 2000, 2001, 2002, 2003 Colin Viebrock - * and easyDNS Technologies Inc. + * Copyright (C) 2000-2004 Colin Viebrock * ************************************************************************** * |
|
From: Colin V. <cvi...@us...> - 2004-12-07 20:22:43
|
Update of /cvsroot/opensrs-php/opensrs-php In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29240 Modified Files: OPS.php README country_codes.php openSRS.php.default openSRS_base.php test.php Log Message: update copyrights and credits Index: OPS.php =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/OPS.php,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- OPS.php 11 Feb 2004 16:47:12 -0000 1.12 +++ OPS.php 7 Dec 2004 20:22:20 -0000 1.13 @@ -4,8 +4,7 @@ * * OpenSRS-PHP * - * Copyright (C) 2000, 2001, 2002, 2003 Colin Viebrock - * and easyDNS Technologies Inc. + * Copyright (C) 2000-2004 Colin Viebrock * ************************************************************************** * Index: README =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/README,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- README 19 Jun 2003 19:16:29 -0000 1.21 +++ README 7 Dec 2004 20:22:20 -0000 1.22 @@ -1,7 +1,7 @@ OpenSRS-PHP A PHP class to facilitate communicatation with OpenSRS' servers -Copyright 2000, 2001, 2002, 2003 Colin Viebrock and easyDNS Technologies Inc. +Copyright 2000-2004 Colin Viebrock @@ -234,6 +234,8 @@ - Victor Magdic at Tucows Inc. <vm...@tu...> who wrote the original Perl API - the rest of the folks at OpenSRS (Ross, Dan, Charles, Erol, et al) +- easyDNS <www.easydns.com>, my previous employer which "funded" most of + the client development - all the users who've suggested changes or provided bug fixes - anyone else I forgot @@ -243,13 +245,8 @@ ------- Colin Viebrock -easyDNS Technologies Inc. -304A - 219 Dufferin Street -Toronto, ON, CANADA -M6G 3J4 - -email: co...@ea... -web: http://www.easydns.com/ +email: colin at viebrock dot ca +web: http://viebrock.ca Index: country_codes.php =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/country_codes.php,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- country_codes.php 29 Apr 2003 16:45:24 -0000 1.3 +++ country_codes.php 7 Dec 2004 20:22:20 -0000 1.4 @@ -4,8 +4,7 @@ * * OpenSRS-PHP * - * Copyright (C) 2000, 2001, 2002, 2003 Colin Viebrock - * and easyDNS Technologies Inc. + * Copyright (C) 2000-2004 Colin Viebrock * ************************************************************************** * Index: openSRS.php.default =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/openSRS.php.default,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- openSRS.php.default 11 Feb 2004 17:08:27 -0000 1.9 +++ openSRS.php.default 7 Dec 2004 20:22:20 -0000 1.10 @@ -4,8 +4,7 @@ * * OpenSRS-PHP * - * Copyright (C) 2000, 2001, 2002, 2003, 2004 Colin Viebrock - * and easyDNS Technologies Inc. + * Copyright (C) 2000-2004 Colin Viebrock * ************************************************************************** * Index: openSRS_base.php =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/openSRS_base.php,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- openSRS_base.php 11 Feb 2004 17:08:27 -0000 1.20 +++ openSRS_base.php 7 Dec 2004 20:22:20 -0000 1.21 @@ -4,8 +4,7 @@ * * OpenSRS-PHP * - * Copyright (C) 2000, 2001, 2002, 2003, 2004 Colin Viebrock - * and easyDNS Technologies Inc. + * Copyright (C) 2000-2004 Colin Viebrock * * Version 3.0.0 * xx-xxx-xxxx Index: test.php =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/test.php,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- test.php 18 Jun 2003 19:53:22 -0000 1.17 +++ test.php 7 Dec 2004 20:22:21 -0000 1.18 @@ -4,8 +4,7 @@ * * OpenSRS-PHP * - * Copyright (C) 2000, 2001, 2002, 2003 Colin Viebrock - * and easyDNS Technologies Inc. + * Copyright (C) 2000-2004 Colin Viebrock * ************************************************************************** * |
|
From: Colin V. <co...@vi...> - 2004-12-07 20:07:23
|
Hi Trish, Actually, the OpenSRS-PHP client can do just about anything, including locking and unlocking domains. The client provides "low level" communication with OpenSRS, so you just need to format the command appropriately (using the API reference [1] as a resource). For a lock command, that might look like this: $command = array( 'action' => 'MODIFY', 'object' => 'DOMAIN', 'attributes' => array( 'data' => 'status', 'domain_name' => 'example.com', 'lock_state' => 1 ) ); $response = $O->send_cmd($command); ... Also, FYI, questions like this should probably go to the devel mailing list. The CVS list (which should be announce-only actually) is just for people to keep informed of any changes that happen to the OpenSRS-PHP code base. Thanks. - Colin [1] https://rrc.tucows.com/resources/docs/srsApiDoc.pdf On 7-Dec-04, at 10:31 AM, Trish Hartnett wrote: > Hello, > > sorry for the newbie question. Is there any plans to include in > opensrs-php functionality for the locking/unlocking of domains ? I > couldn't see any mention of it in the Readme file. > > Thanks, > > Trish. > > _________________________________________________________________ > Express yourself instantly with MSN Messenger! Download today it's > FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ > > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real > users. > Discover which products truly live up to the hype. Start reading now. > http://productguide.itmanagersjournal.com/ > _______________________________________________ > opensrs-php-cvs mailing list > ope...@li... > https://lists.sourceforge.net/lists/listinfo/opensrs-php-cvs > |
|
From: Trish H. <tri...@ho...> - 2004-12-07 15:32:15
|
Hello, sorry for the newbie question. Is there any plans to include in opensrs-php functionality for the locking/unlocking of domains ? I couldn't see any mention of it in the Readme file. Thanks, Trish. _________________________________________________________________ Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ |
|
From: Trish H. <tri...@ho...> - 2004-12-07 15:29:15
|
Hello, sorry for the newbie question. Is there any plans to build into opensrs-php functionality for the locking and unlocking of domains ? I couldn't see any mention of it in the Readme file. Thanks, Trish. _________________________________________________________________ Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ |
|
From: Colin V. <cvi...@us...> - 2004-02-11 17:13:09
|
Update of /cvsroot/opensrs-php/opensrs-php In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31411 Modified Files: CHANGELOG Log Message: comment Index: CHANGELOG =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/CHANGELOG,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- CHANGELOG 11 Feb 2004 17:08:27 -0000 1.25 +++ CHANGELOG 11 Feb 2004 17:08:51 -0000 1.26 @@ -3,7 +3,7 @@ Version 3.0.0 xx-xxx-xxxx - + - PEAR-ify entire class Version 2.8.0 10-Feb-2004 (Jason Slaughter) |
|
From: Colin V. <cvi...@us...> - 2004-02-11 17:12:44
|
Update of /cvsroot/opensrs-php/opensrs-php In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31195 Modified Files: CHANGELOG openSRS.php.default openSRS_base.php Log Message: fix 3.0 branch Index: CHANGELOG =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/CHANGELOG,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- CHANGELOG 10 Feb 2004 16:07:43 -0000 1.24 +++ CHANGELOG 11 Feb 2004 17:08:27 -0000 1.25 @@ -1,14 +1,15 @@ CHANGELOG --------- +Version 3.0.0 +xx-xxx-xxxx + + Version 2.8.0 10-Feb-2004 (Jason Slaughter) - added support for XML over HTTPS POST method for OpenSRS - new crypt_type "SSL," changed default to BLOWFISH from DES - minor fix to ops.dtd - -Version x.x.x -xx-xxx-xxxx - Updated README to reflect HRS functionality - exposed HRS_port in the config file, since that port number is different for each HRS customer (Jason Slaughter) Index: openSRS.php.default =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/openSRS.php.default,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- openSRS.php.default 10 Feb 2004 16:07:43 -0000 1.8 +++ openSRS.php.default 11 Feb 2004 17:08:27 -0000 1.9 @@ -4,7 +4,7 @@ * * OpenSRS-PHP * - * Copyright (C) 2000, 2001, 2002, 2003 Colin Viebrock + * Copyright (C) 2000, 2001, 2002, 2003, 2004 Colin Viebrock * and easyDNS Technologies Inc. * ************************************************************************** Index: openSRS_base.php =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/openSRS_base.php,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- openSRS_base.php 10 Feb 2004 22:51:17 -0000 1.19 +++ openSRS_base.php 11 Feb 2004 17:08:27 -0000 1.20 @@ -4,11 +4,11 @@ * * OpenSRS-PHP * - * Copyright (C) 2000, 2001, 2002, 2003 Colin Viebrock + * Copyright (C) 2000, 2001, 2002, 2003, 2004 Colin Viebrock * and easyDNS Technologies Inc. * - * Version 2.7.3 - * 15-Aug-2003 + * Version 3.0.0 + * xx-xxx-xxxx * ************************************************************************** * @@ -82,7 +82,7 @@ var $read_timeout = 20; /* seconds */ var $log = array(); - var $CRLF = "\r\n"; + var $CRLF = "\r\n"; var $_socket = false; var $_socket_error_num = false; @@ -97,7 +97,7 @@ var $_CRYPT; var $_iv; - var $crypt_type = 'DES'; /* 'DES' or 'BLOWFISH' */ + var $crypt_type = 'BLOWFISH'; /* 'DES' or 'BLOWFISH' or 'SSL' */ var $crypt_mode = 'CBC'; /* only 'CBC' */ var $crypt_rand_source = MCRYPT_DEV_URANDOM; /* or MCRYPT_DEV_RANDOM or MCRYPT_RAND */ var $affiliate_id; @@ -243,16 +243,17 @@ $this->crypt_type = strtoupper($this->crypt_type); - if ("SSL" == $this->crypt_type) { - if (!function_exists('version_compare') || version_compare("4.3",phpversion(),">=")) { - $error_message = "PHP version must be v4.3+ (current version is ".phpversion(). ") to use an OpenSRS \$crypt-type of \"SSL\""; + if ('SSL' == $this->crypt_type) { + if (!function_exists('version_compare') || version_compare('4.3', phpversion(), '>=')) { + $error_message = 'PHP version must be v4.3+ (current version is ' . + phpversion() . ') to use "SSL" encryption'; trigger_error ($error_message, E_USER_ERROR); - $this->_log('i',$error_message); + $this->_log('i', $error_message); return false; } elseif (!function_exists('openssl_open')) { - $error_message = "PHP must be compiled using --with-openssl to use an OpenSRS \$crypt-type of \"SSL\""; + $error_message = 'PHP must be compiled using --with-openssl to use "SSL" encryption'; trigger_error ($error_message, E_USER_ERROR); - $this->_log('i',$error_message); + $this->_log('i', $error_message); return false; } } @@ -597,7 +598,7 @@ } $this->REMOTE_HOST = $this->{$this->environment.'_host'}; - if ("SSL" == $this->crypt_type) { + if ('SSL' == $this->crypt_type) { $this->REMOTE_PORT = $this->{$this->environment.'_sslport'}; } else { $this->REMOTE_PORT = $this->{$this->environment.'_port'}; @@ -605,10 +606,10 @@ # create a socket - $connection_protocol = ""; - if ("SSL" == $this->crypt_type) { - # ssl:// requires PHP v4.3.0+ compiled with --with-openssl - $connection_protocol = "ssl://"; + $connection_protocol = ''; + if ('SSL' == $this->crypt_type) { + /* ssl:// requires PHP v4.3.0+ compiled with --with-openssl */ + $connection_protocol = 'ssl://'; } $this->_socket = fsockopen($connection_protocol.$this->REMOTE_HOST, $this->REMOTE_PORT, $this->_socket_err_num, $this->_socket_err_msg, $this->connect_timeout ); @@ -629,7 +630,7 @@ function authenticate($username=false,$private_key=false) { - if ($this->_authenticated || "SSL" == $this->crypt_type) { + if ($this->_authenticated || 'SSL' == $this->crypt_type) { return array('is_success' => true); } @@ -1036,65 +1037,64 @@ -/** -* Writes a message to a socket (buffered IO) -* -* @param int socket handle -* -* @param string message to write -* -*/ - -function writeData(&$fh,$msg) -{ - $header = ""; - $len = strlen($msg); - switch ($this->crypt_type) { - case 'SSL': - $signature = md5(md5($msg.$this->PRIVATE_KEY).$this->PRIVATE_KEY); - $header .= "POST / HTTP/1.0". $this->CRLF; - $header .= "Content-Type: text/xml" . $this->CRLF; - $header .= "X-Username: " . $this->USERNAME . $this->CRLF; - $header .= "X-Signature: " . $signature . $this->CRLF; - $header .= "Content-Length: " . $len . $this->CRLF . $this->CRLF; - break; - case 'BLOWFISH': - case 'DES': - default: - $header .= "Content-Length: " . $len . $this->CRLF . $this->CRLF; - break; - } + /** + * Writes a message to a socket (buffered IO) + * + * @param int socket handle + * + * @param string message to write + * + */ + + function writeData(&$fh,$msg) + { + $header = ""; + $len = strlen($msg); + switch ($this->crypt_type) { + case 'SSL': + $signature = md5(md5($msg.$this->PRIVATE_KEY).$this->PRIVATE_KEY); + $header .= "POST / HTTP/1.0". $this->CRLF; + $header .= "Content-Type: text/xml" . $this->CRLF; + $header .= "X-Username: " . $this->USERNAME . $this->CRLF; + $header .= "X-Signature: " . $signature . $this->CRLF; + $header .= "Content-Length: " . $len . $this->CRLF . $this->CRLF; + break; + case 'BLOWFISH': + case 'DES': + default: + $header .= "Content-Length: " . $len . $this->CRLF . $this->CRLF; + break; + } - fputs($fh, $header); + fputs($fh, $header); - fputs($fh, $msg, $len ); + fputs($fh, $msg, $len ); - if ("SSL" == $this->crypt_type) { - $this->_OPS->_log('http','w',$header.$msg); - } + if ('SSL' == $this->crypt_type) { + $this->_OPS->_log('http', 'w', $header.$msg); + } - $this->_OPS->_log('raw', 'w', $msg, $len); -} + $this->_OPS->_log('raw', 'w', $msg, $len); + } -/** -* Reads header data -* -* @param int socket handle -* -* @param int timeout for read -* -* @return hash hash containing header key/value pairs -* -*/ - -function readHeader($fh, $timeout=5) -{ - $header = array(); - switch ($this->crypt_type) { - case 'SSL': - # HTTP/SSL connection method - $http_log = ""; + /** + * Reads header data + * + * @param int socket handle + * + * @param int timeout for read + * + * @return hash hash containing header key/value pairs + * + */ + + function readHeader($fh, $timeout=5) { + $header = array(); + switch ($this->crypt_type) { + case 'SSL': + /* HTTP/SSL connection method */ + $http_log =''; $line = fgets($fh, 4000); $http_log .= $line; if (!preg_match('/^HTTP\/1.1 ([0-9]{0,3}) (.*)\r\n$/',$line, $matches)) { @@ -1102,8 +1102,8 @@ $this->_OPS->_log('raw', 'r', $line); return false; } - $header["http_response_code"] = $matches['1']; - $header["http_response_text"] = $matches['2']; + $header['http_response_code'] = $matches[1]; + $header['http_response_text'] = $matches[2]; while ($line != $this->CRLF) { $line = fgets($fh, 4000); $http_log .= $line; @@ -1117,13 +1117,12 @@ $header[trim(strtolower($matches[0]))] = $matches[1]; } } - $header{'full_header'} = $http_log; + $header['full_header'] = $http_log; break; - ## END SSL - case 'BLOWFISH': - case 'DES': - default: - # default (old-style) connection + case 'BLOWFISH': + case 'DES': + default: + /* socket (old-style) connection */ $line = fgets($fh, 4000); if ($this->_OPS->socketStatus($fh)) { return false; @@ -1150,60 +1149,59 @@ return false; } break; + } + return $header; } - return $header; -} -/** -* Reads data from a socket -* -* @param int socket handle -* -* @param int timeout for read -* -* @return mixed buffer with data, or an error for a short read -* -*/ - -function readData(&$fh, $timeout=5) -{ - $len = 0; + /** + * Reads data from a socket + * + * @param int socket handle + * + * @param int timeout for read + * + * @return mixed buffer with data, or an error for a short read + * + */ + + function readData(&$fh, $timeout=5) { + $len = 0; - /* PHP doesn't have timeout for fread ... we just set the timeout for the socket */ + /* PHP doesn't have timeout for fread ... we just set the timeout for the socket */ - socket_set_timeout($fh, $timeout); + socket_set_timeout($fh, $timeout); - $header = $this->readHeader($fh, $timeout); + $header = $this->readHeader($fh, $timeout); - if (!$header || !isset($header{'content-length'}) || (empty($header{'content-length'}))) { - $this->_OPS->_log('raw', 'e', 'UNEXPECTED ERROR: No Content-Length header provided!' ); - } + if (!$header || !isset($header{'content-length'}) || (empty($header{'content-length'}))) { + $this->_OPS->_log('raw', 'e', 'UNEXPECTED ERROR: No Content-Length header provided!' ); + } - $len = (int)$header{'content-length'}; + $len = (int)$header{'content-length'}; - $line = ''; - while (strlen($line) < $len) { - $line .= fread($fh, $len); - if ($this->_OPS->socketStatus($fh)) { - return false; + $line = ''; + while (strlen($line) < $len) { + $line .= fread($fh, $len); + if ($this->_OPS->socketStatus($fh)) { + return false; + } } - } - if ($line) { - $buf = $line; - $this->_OPS->_log('raw', 'r', $line); - } else { - $buf = false; - $this->_OPS->_log('raw', 'e', 'NEXT LINE SHORT READ (should be '.$len.')' ); - $this->_OPS->_log('raw', 'r', $line); - } + if ($line) { + $buf = $line; + $this->_OPS->_log('raw', 'r', $line); + } else { + $buf = false; + $this->_OPS->_log('raw', 'e', 'NEXT LINE SHORT READ (should be '.$len.')' ); + $this->_OPS->_log('raw', 'r', $line); + } - if ("SSL" == $this->crypt_type) { - $this->_OPS->_log('http','r',$header{'full_header'}.$line); - $this->close_socket(); + if ('SSL' == $this->crypt_type) { + $this->_OPS->_log('http', 'r', $header['full_header'].$line); + $this->close_socket(); + } + return $buf; } - return $buf; -} } |
Update of /cvsroot/opensrs-php/opensrs-php In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29777 Modified Files: Tag: opensrs_php_2 CHANGELOG OPS.php README TODO country_codes.php openSRS.php.default openSRS_base.php Log Message: update copyrights, change whitespacing, etc ... prepare for 2.8.0 release Index: CHANGELOG =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/CHANGELOG,v retrieving revision 1.23.2.2 retrieving revision 1.23.2.3 diff -u -r1.23.2.2 -r1.23.2.3 --- CHANGELOG 11 Feb 2004 16:37:15 -0000 1.23.2.2 +++ CHANGELOG 11 Feb 2004 17:02:55 -0000 1.23.2.3 @@ -2,10 +2,12 @@ --------- Version 2.8.0 -10-Feb-2004 (Jason Slaughter) +10-Feb-2004 - added support for XML over HTTPS POST method for OpenSRS + (Jason Slaughter) - new crypt_type "SSL," changed default to BLOWFISH from DES - - minor fix to ops.dtd + (Jason Slaughter) + - minor fix to ops.dtd (Jason Slaughter) - Updated README to reflect HRS functionality - exposed HRS_port in the config file, since that port number is different for each HRS customer (Jason Slaughter) Index: OPS.php =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/OPS.php,v retrieving revision 1.8.2.1 retrieving revision 1.8.2.2 diff -u -r1.8.2.1 -r1.8.2.2 --- OPS.php 11 Feb 2004 16:37:15 -0000 1.8.2.1 +++ OPS.php 11 Feb 2004 17:02:55 -0000 1.8.2.2 @@ -4,7 +4,7 @@ * * OpenSRS-PHP * - * Copyright (C) 2000, 2001, 2002, 2003 Colin Viebrock + * Copyright (C) 2000, 2001, 2002, 2003, 2004 Colin Viebrock * and easyDNS Technologies Inc. * ************************************************************************** Index: README =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/README,v retrieving revision 1.21 retrieving revision 1.21.2.1 diff -u -r1.21 -r1.21.2.1 --- README 19 Jun 2003 19:16:29 -0000 1.21 +++ README 11 Feb 2004 17:02:56 -0000 1.21.2.1 @@ -1,7 +1,8 @@ OpenSRS-PHP A PHP class to facilitate communicatation with OpenSRS' servers -Copyright 2000, 2001, 2002, 2003 Colin Viebrock and easyDNS Technologies Inc. +Copyright 2000, 2001, 2002, 2003,2004 Colin Viebrock + and easyDNS Technologies Inc. @@ -231,8 +232,8 @@ - Mike Glover <mp...@du...> for providing the CBC emulation functions and general help -- Victor Magdic at Tucows Inc. <vm...@tu...> who wrote the original - Perl API +- Victor Magdic at Tucows who wrote the original Perl API +- Jason Slaughter at Tucows for the SSL-method code - the rest of the folks at OpenSRS (Ross, Dan, Charles, Erol, et al) - all the users who've suggested changes or provided bug fixes - anyone else I forgot Index: TODO =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/TODO,v retrieving revision 1.11 retrieving revision 1.11.2.1 diff -u -r1.11 -r1.11.2.1 --- TODO 29 Apr 2003 16:45:23 -0000 1.11 +++ TODO 11 Feb 2004 17:02:56 -0000 1.11.2.1 @@ -2,7 +2,7 @@ - clean out cruft (domain validation, CA entity types, etc), and make this just a streamlined connection class -- ACE encoding (although I doubt this gets much use) +- PUNY encoding (although I doubt this gets much use) - complete PEAR-ification and PHPDoc documentation - test Index: country_codes.php =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/country_codes.php,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -r1.3 -r1.3.2.1 --- country_codes.php 29 Apr 2003 16:45:24 -0000 1.3 +++ country_codes.php 11 Feb 2004 17:02:56 -0000 1.3.2.1 @@ -4,7 +4,7 @@ * * OpenSRS-PHP * - * Copyright (C) 2000, 2001, 2002, 2003 Colin Viebrock + * Copyright (C) 2000, 2001, 2002, 2003, 2004 Colin Viebrock * and easyDNS Technologies Inc. * ************************************************************************** Index: openSRS.php.default =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/openSRS.php.default,v retrieving revision 1.7.2.1 retrieving revision 1.7.2.2 diff -u -r1.7.2.1 -r1.7.2.2 --- openSRS.php.default 11 Feb 2004 16:37:15 -0000 1.7.2.1 +++ openSRS.php.default 11 Feb 2004 17:02:56 -0000 1.7.2.2 @@ -4,7 +4,7 @@ * * OpenSRS-PHP * - * Copyright (C) 2000, 2001, 2002, 2003 Colin Viebrock + * Copyright (C) 2000, 2001, 2002, 2003, 2004 Colin Viebrock * and easyDNS Technologies Inc. * ************************************************************************** Index: openSRS_base.php =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/openSRS_base.php,v retrieving revision 1.16.2.2 retrieving revision 1.16.2.3 diff -u -r1.16.2.2 -r1.16.2.3 --- openSRS_base.php 11 Feb 2004 16:37:15 -0000 1.16.2.2 +++ openSRS_base.php 11 Feb 2004 17:02:56 -0000 1.16.2.3 @@ -4,11 +4,11 @@ * * OpenSRS-PHP * - * Copyright (C) 2000, 2001, 2002, 2003 Colin Viebrock + * Copyright (C) 2000, 2001, 2002, 2003, 2004 Colin Viebrock * and easyDNS Technologies Inc. * - * Version 2.7.3 - * 15-Aug-2003 + * Version 2.8.0 + * 10-Feb-2004 * ************************************************************************** * @@ -82,7 +82,7 @@ var $read_timeout = 20; /* seconds */ var $log = array(); - var $CRLF = "\r\n"; + var $CRLF = "\r\n"; var $_socket = false; var $_socket_error_num = false; @@ -97,7 +97,7 @@ var $_CRYPT; var $_iv; - var $crypt_type = 'DES'; /* 'DES' or 'BLOWFISH' */ + var $crypt_type = 'BLOWFISH'; /* 'DES' or 'BLOWFISH' or 'SSL' */ var $crypt_mode = 'CBC'; /* only 'CBC' */ var $crypt_rand_source = MCRYPT_DEV_URANDOM; /* or MCRYPT_DEV_RANDOM or MCRYPT_RAND */ var $affiliate_id; @@ -243,16 +243,17 @@ $this->crypt_type = strtoupper($this->crypt_type); - if ("SSL" == $this->crypt_type) { - if (!function_exists('version_compare') || version_compare("4.3",phpversion(),">=")) { - $error_message = "PHP version must be v4.3+ (current version is ".phpversion(). ") to use an OpenSRS \$crypt-type of \"SSL\""; + if ('SSL' == $this->crypt_type) { + if (!function_exists('version_compare') || version_compare('4.3', phpversion(), '>=')) { + $error_message = 'PHP version must be v4.3+ (current version is ' . + phpversion() . ') to use "SSL" encryption'; trigger_error ($error_message, E_USER_ERROR); - $this->_log('i',$error_message); + $this->_log('i', $error_message); return false; } elseif (!function_exists('openssl_open')) { - $error_message = "PHP must be compiled using --with-openssl to use an OpenSRS \$crypt-type of \"SSL\""; + $error_message = 'PHP must be compiled using --with-openssl to use "SSL" encryption'; trigger_error ($error_message, E_USER_ERROR); - $this->_log('i',$error_message); + $this->_log('i', $error_message); return false; } } @@ -597,7 +598,7 @@ } $this->REMOTE_HOST = $this->{$this->environment.'_host'}; - if ("SSL" == $this->crypt_type) { + if ('SSL' == $this->crypt_type) { $this->REMOTE_PORT = $this->{$this->environment.'_sslport'}; } else { $this->REMOTE_PORT = $this->{$this->environment.'_port'}; @@ -605,10 +606,10 @@ # create a socket - $connection_protocol = ""; - if ("SSL" == $this->crypt_type) { - # ssl:// requires PHP v4.3.0+ compiled with --with-openssl - $connection_protocol = "ssl://"; + $connection_protocol = ''; + if ('SSL' == $this->crypt_type) { + /* ssl:// requires PHP v4.3.0+ compiled with --with-openssl */ + $connection_protocol = 'ssl://'; } $this->_socket = fsockopen($connection_protocol.$this->REMOTE_HOST, $this->REMOTE_PORT, $this->_socket_err_num, $this->_socket_err_msg, $this->connect_timeout ); @@ -629,7 +630,7 @@ function authenticate($username=false,$private_key=false) { - if ($this->_authenticated || "SSL" == $this->crypt_type) { + if ($this->_authenticated || 'SSL' == $this->crypt_type) { return array('is_success' => true); } @@ -1036,65 +1037,64 @@ -/** -* Writes a message to a socket (buffered IO) -* -* @param int socket handle -* -* @param string message to write -* -*/ - -function writeData(&$fh,$msg) -{ - $header = ""; - $len = strlen($msg); - switch ($this->crypt_type) { - case 'SSL': - $signature = md5(md5($msg.$this->PRIVATE_KEY).$this->PRIVATE_KEY); - $header .= "POST / HTTP/1.0". $this->CRLF; - $header .= "Content-Type: text/xml" . $this->CRLF; - $header .= "X-Username: " . $this->USERNAME . $this->CRLF; - $header .= "X-Signature: " . $signature . $this->CRLF; - $header .= "Content-Length: " . $len . $this->CRLF . $this->CRLF; - break; - case 'BLOWFISH': - case 'DES': - default: - $header .= "Content-Length: " . $len . $this->CRLF . $this->CRLF; - break; - } + /** + * Writes a message to a socket (buffered IO) + * + * @param int socket handle + * + * @param string message to write + * + */ + + function writeData(&$fh,$msg) + { + $header = ""; + $len = strlen($msg); + switch ($this->crypt_type) { + case 'SSL': + $signature = md5(md5($msg.$this->PRIVATE_KEY).$this->PRIVATE_KEY); + $header .= "POST / HTTP/1.0". $this->CRLF; + $header .= "Content-Type: text/xml" . $this->CRLF; + $header .= "X-Username: " . $this->USERNAME . $this->CRLF; + $header .= "X-Signature: " . $signature . $this->CRLF; + $header .= "Content-Length: " . $len . $this->CRLF . $this->CRLF; + break; + case 'BLOWFISH': + case 'DES': + default: + $header .= "Content-Length: " . $len . $this->CRLF . $this->CRLF; + break; + } - fputs($fh, $header); + fputs($fh, $header); - fputs($fh, $msg, $len ); + fputs($fh, $msg, $len ); - if ("SSL" == $this->crypt_type) { - $this->_OPS->_log('http','w',$header.$msg); - } + if ('SSL' == $this->crypt_type) { + $this->_OPS->_log('http', 'w', $header.$msg); + } - $this->_OPS->_log('raw', 'w', $msg, $len); -} + $this->_OPS->_log('raw', 'w', $msg, $len); + } -/** -* Reads header data -* -* @param int socket handle -* -* @param int timeout for read -* -* @return hash hash containing header key/value pairs -* -*/ - -function readHeader($fh, $timeout=5) -{ - $header = array(); - switch ($this->crypt_type) { - case 'SSL': - # HTTP/SSL connection method - $http_log = ""; + /** + * Reads header data + * + * @param int socket handle + * + * @param int timeout for read + * + * @return hash hash containing header key/value pairs + * + */ + + function readHeader($fh, $timeout=5) { + $header = array(); + switch ($this->crypt_type) { + case 'SSL': + /* HTTP/SSL connection method */ + $http_log =''; $line = fgets($fh, 4000); $http_log .= $line; if (!preg_match('/^HTTP\/1.1 ([0-9]{0,3}) (.*)\r\n$/',$line, $matches)) { @@ -1102,8 +1102,8 @@ $this->_OPS->_log('raw', 'r', $line); return false; } - $header["http_response_code"] = $matches['1']; - $header["http_response_text"] = $matches['2']; + $header['http_response_code'] = $matches[1]; + $header['http_response_text'] = $matches[2]; while ($line != $this->CRLF) { $line = fgets($fh, 4000); $http_log .= $line; @@ -1117,13 +1117,12 @@ $header[trim(strtolower($matches[0]))] = $matches[1]; } } - $header{'full_header'} = $http_log; + $header['full_header'] = $http_log; break; - ## END SSL - case 'BLOWFISH': - case 'DES': - default: - # default (old-style) connection + case 'BLOWFISH': + case 'DES': + default: + /* socket (old-style) connection */ $line = fgets($fh, 4000); if ($this->_OPS->socketStatus($fh)) { return false; @@ -1150,60 +1149,59 @@ return false; } break; + } + return $header; } - return $header; -} -/** -* Reads data from a socket -* -* @param int socket handle -* -* @param int timeout for read -* -* @return mixed buffer with data, or an error for a short read -* -*/ - -function readData(&$fh, $timeout=5) -{ - $len = 0; + /** + * Reads data from a socket + * + * @param int socket handle + * + * @param int timeout for read + * + * @return mixed buffer with data, or an error for a short read + * + */ + + function readData(&$fh, $timeout=5) { + $len = 0; - /* PHP doesn't have timeout for fread ... we just set the timeout for the socket */ + /* PHP doesn't have timeout for fread ... we just set the timeout for the socket */ - socket_set_timeout($fh, $timeout); + socket_set_timeout($fh, $timeout); - $header = $this->readHeader($fh, $timeout); + $header = $this->readHeader($fh, $timeout); - if (!$header || !isset($header{'content-length'}) || (empty($header{'content-length'}))) { - $this->_OPS->_log('raw', 'e', 'UNEXPECTED ERROR: No Content-Length header provided!' ); - } + if (!$header || !isset($header{'content-length'}) || (empty($header{'content-length'}))) { + $this->_OPS->_log('raw', 'e', 'UNEXPECTED ERROR: No Content-Length header provided!' ); + } - $len = (int)$header{'content-length'}; + $len = (int)$header{'content-length'}; - $line = ''; - while (strlen($line) < $len) { - $line .= fread($fh, $len); - if ($this->_OPS->socketStatus($fh)) { - return false; + $line = ''; + while (strlen($line) < $len) { + $line .= fread($fh, $len); + if ($this->_OPS->socketStatus($fh)) { + return false; + } } - } - if ($line) { - $buf = $line; - $this->_OPS->_log('raw', 'r', $line); - } else { - $buf = false; - $this->_OPS->_log('raw', 'e', 'NEXT LINE SHORT READ (should be '.$len.')' ); - $this->_OPS->_log('raw', 'r', $line); - } + if ($line) { + $buf = $line; + $this->_OPS->_log('raw', 'r', $line); + } else { + $buf = false; + $this->_OPS->_log('raw', 'e', 'NEXT LINE SHORT READ (should be '.$len.')' ); + $this->_OPS->_log('raw', 'r', $line); + } - if ("SSL" == $this->crypt_type) { - $this->_OPS->_log('http','r',$header{'full_header'}.$line); - $this->close_socket(); + if ('SSL' == $this->crypt_type) { + $this->_OPS->_log('http', 'r', $header['full_header'].$line); + $this->close_socket(); + } + return $buf; } - return $buf; -} } |
|
From: Colin V. <cvi...@us...> - 2004-02-11 16:51:30
|
Update of /cvsroot/opensrs-php/opensrs-php In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26108 Modified Files: OPS.php Log Message: revert 3.0 changes Index: OPS.php =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/OPS.php,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- OPS.php 10 Feb 2004 16:07:43 -0000 1.11 +++ OPS.php 11 Feb 2004 16:47:12 -0000 1.12 @@ -34,13 +34,27 @@ require_once 'PEAR.php'; +define ('OPS_OK', 1 ); +define ('OPS_ERROR', -1 ); +define ('OPS_ERROR_TIMEOUT', -2 ); +define ('OPS_ERROR_EOF', -3 ); +define ('OPS_ERROR_NO_DATA', -4 ); +define ('OPS_ERROR_SHORT_READ', -5 ); +define ('OPS_ERROR_UNEXPECTED', -6 ); +define ('OPS_ERROR_CANT_DECODE', -7 ); +define ('OPS_ERROR_CANT_ENCODE', -8 ); +define ('OPS_ERROR_NO_SOCKET', -9 ); +define ('OPS_ERROR_CANT_WRITE', -10 ); + class OPS extends PEAR { - var $_OPS_VERSION = '0.9'; - var $_OPT = ''; - var $_SPACER = ' '; /* indent character */ - var $_CRLF = "\n"; - var $_MSGTYPE_STD = 'standard'; + var $_OPS_VERSION = '0.9'; + + var $_OUTPUT_COMPRESS = false; + var $_OUTPUT_INDENT = ' '; + var $_OUTPUT_LF = "\n"; + + var $_MSGTYPE_STD = 'standard'; var $_SESSID; var $_MSGCNT; @@ -69,10 +83,10 @@ $this->PEAR(); if (is_array($args)) { - if ($args['option']=='compress') { - $this->_OPT = 'compress'; - $this->_SPACER = ''; - $this->_CRLF = ''; + if ($args['compress']==true) { + $this->_OUTPUT_COMPRESS = true; + $this->_OUTPUT_INDENT = ''; + $this->_OUTPUT_LF = ''; } } @@ -88,6 +102,38 @@ } + function raiseError($code, $info=NULL) + { + return PEAR::raiseError( $this->errorMessage($code), $code, NULL, NULL, $info ); + } + + + function errorMessage($value) + { + static $errorMessages; + if (!isset($errorMessages)) { + $errorMessages = array( + OPS_OK => 'OK', + OPS_ERROR => 'unknown error', + OPS_ERROR_TIMEOUT => 'timeout reading', + OPS_ERROR_EOF => 'EOF reached', + OPS_ERROR_NO_DATA => 'no data read', + OPS_ERROR_SHORT_READ => 'short read', + OPS_ERROR_UNEXPECTED => 'unexpected data read', + OPS_ERROR_CANT_DECODE => 'can\'t decode data', + OPS_ERROR_CANT_ENCODE => 'can\'t encode data', + OPS_ERROR_NO_SOCKET => 'socket not active', + OPS_ERROR_CANT_WRITE => 'can\'t write to socket', + ); + } + + if (PEAR::isError($value)) { + $value = $value->getCode(); + } + + return isset($errorMessages[$value]) ? $errorMessages[$value] : $errorMessages[OPS_ERROR]; + + } /** @@ -102,10 +148,18 @@ function writeData(&$fh,$msg) { $len = strlen($msg); - fputs($fh, 'Content-Length: ' . $len . $this->CRLF . $this->CRLF); - fputs($fh, $msg, $len ); + + if (!fputs($fh, 'Content-Length: ' . $len . $this->CRLF . $this->CRLF) ) { + return $this->raiseError( OPS_ERROR_CANT_WRITE ); + } + if (!fputs($fh, $msg, $len ) ) { + return $this->raiseError( OPS_ERROR_CANT_WRITE ); + } $this->_log('raw', 'w', $msg, $len); + + return OPS_OK; + } @@ -116,12 +170,19 @@ * * @param string message to encode and write * + * @return mixed OK, or an error + * */ function writeMessage(&$fh, $hr ) { $msg = $this->encode( $hr ); - $this->writeData($fh, $msg ); + if (PEAR::isError($msg)) { + return $msg; + } + + return $this->writeData($fh, $msg ); + } @@ -132,7 +193,7 @@ * * @param int timeout for read * - * @return mixed buffer with data, or an error for a short read + * @return mixed buffer with data, or an error * */ @@ -145,9 +206,10 @@ socket_set_timeout($fh, $timeout); $line = fgets($fh, 4000); + $test = $this->socketStatus($fh); - if ($this->socketStatus($fh)) { - return false; + if (PEAR::isError($test)) { + return $test; } if (!$len && preg_match('/^\s*Content-Length:\s+(\d+)\s*\r\n/i', $line, $matches ) ) { @@ -155,40 +217,46 @@ } else { $this->_log('raw', 'e', 'UNEXPECTED READ: No Content-Length' ); $this->_log('raw', 'r', $line); - return false; + return $this->raiseError( OPS_ERROR_UNEXPECTED, 'No content-length' ); } /* read the empty line */ $line = fread($fh, 2); - if ($this->socketStatus($fh)) { - return false; + $test = $this->socketStatus($fh); + if (PEAR::isError($test)) { + return $test; } if ($line!=$this->CRLF) { $this->_log('raw', 'e', 'UNEXPECTED READ: No CRLF'); $this->_log('raw', 'r', $line); - return false; + return $this->raiseError( OPS_ERROR_UNEXPECTED, 'No CRLF' ); } $line = ''; while (strlen($line) < $len) { $line .= fread($fh, $len); - if ($this->socketStatus($fh)) { - return false; + $test = $this->socketStatus($fh); + if (PEAR::isError($test)) { + return $test; } } - if ($line) { - $buf = $line; - $this->_log('raw', 'r', $line); - } else { - $buf = false; - $this->_log('raw', 'e', 'NEXT LINE SHORT READ (should be '.$len.')' ); + if ($line=='') { + $this->_log('raw', 'e', 'NO DATA READ' ); + return $this->raiseError( OPS_ERROR_NO_DATA ); + } + + if (strlen($line) != $len ) { + $this->_log('raw', 'e', 'NEXT LINE SHORT READ (expecting '.$len.', read ' . strlen($line) . ')' ); $this->_log('raw', 'r', $line); + return $this->raiseError( OPS_ERROR_SHORT_READ ); } - return $buf; + $this->_log('raw', 'r', $line); + return $line; + } @@ -205,7 +273,10 @@ function readMessage(&$fh, $timeout=5) { $buf = $this->readData($fh, $timeout); - return ( $buf ? $this->decode($buf) : false ); + if (PEAR::isError($buf)) { + return $buf; + } + return $this->decode($buf); } @@ -215,52 +286,35 @@ * * @param int socket handle * - * @return boolean true if the socket has timed out or is EOF + * @return mixed true if the socket is ok, error otherwise * */ function socketStatus(&$fh) { - $return = false; - if (is_resource($fh)) { - $temp = socket_get_status($fh); - if ($temp['timed_out']) { - $this->_log('raw', 'e', 'SOCKET TIMED OUT'); - $return = true; - } - if ($temp['eof']) { - $this->_log('raw', 'e', 'SOCKET EOF'); - $return = true; - } - unset($temp); + if (!is_resource($fh)) { + return $this->raiseError( OPS_ERROR_NO_SOCKET ); } - return $return; - } + $temp = socket_get_status($fh); + if ($temp['timed_out']) { + $this->_log('raw', 'e', 'SOCKET TIMED OUT'); + return $this->raiseError( OPS_ERROR_TIMEOUT ); + } - /** - * Internal method to generate error codes hashes - * - * @param int error code - * - * @param string error message - * - * @return array error hash - * - */ + if ($temp['eof']) { + $this->_log('raw', 'e', 'SOCKET EOF'); + return $this->raiseError( OPS_ERROR_EOF ); + } + + return OPS_OK; - function _opsError($err_code,$err_text) - { - return array( - 'response_code' => $err_code, - 'response_text' => $err_text, - 'is_success' => 0 - ); } + # # DECODING METHODS # Converts XML OPS messages into PHP data @@ -285,10 +339,10 @@ /* determine if we were passed a string or file handle */ if (is_resource($in)) { - # read the file into a string, then process as usual - while (!feof($in)) { - $ops_msg .= fgets($in, 400); - } + /* read the file into a string, then process as usual */ + while (!feof($in)) { + $ops_msg .= fgets($in, 400); + } } else { $ops_msg = $in; } @@ -331,7 +385,7 @@ xml_get_current_line_number($xp) ); xml_parser_free($xp); - return $this->raiseError($error); + return $this->raiseError( OPS_ERROR_CANT_DECODE, $error ); } xml_parser_free($xp); @@ -445,17 +499,17 @@ $xml_data_block = $this->PHP2XML($array); - $ops_msg = '<?xml version="1.0" encoding="UTF-8" standalone="no" ?>' . $this->_CRLF . - '<!DOCTYPE OPS_envelope SYSTEM "ops.dtd">' . $this->_CRLF . - '<OPS_envelope>' . $this->_CRLF . - $this->_SPACER . '<header>' . $this->_CRLF . - $this->_SPACER . $this->_SPACER . '<version>' . $this->_OPS_VERSION . '</version>' . $this->_CRLF . - $this->_SPACER . $this->_SPACER . '<msg_id>' . $msg_id . '</msg_id>' . $this->_CRLF . - $this->_SPACER . $this->_SPACER . '<msg_type>' . $msg_type . '</msg_type>' . $this->_CRLF . - $this->_SPACER . '</header>' . $this->_CRLF . - $this->_SPACER . '<body>' . $this->_CRLF . - $xml_data_block . $this->_CRLF . - $this->_SPACER . '</body>' . $this->_CRLF . + $ops_msg = '<?xml version="1.0" encoding="UTF-8" standalone="no" ?>' . $this->_OUTPUT_LF . + '<!DOCTYPE OPS_envelope SYSTEM "ops.dtd">' . $this->_OUTPUT_LF . + '<OPS_envelope>' . $this->_OUTPUT_LF . + $this->_OUTPUT_INDENT . '<header>' . $this->_OUTPUT_LF . + $this->_OUTPUT_INDENT . $this->_OUTPUT_INDENT . '<version>' . $this->_OPS_VERSION . '</version>' . $this->_OUTPUT_LF . + $this->_OUTPUT_INDENT . $this->_OUTPUT_INDENT . '<msg_id>' . $msg_id . '</msg_id>' . $this->_OUTPUT_LF . + $this->_OUTPUT_INDENT . $this->_OUTPUT_INDENT . '<msg_type>' . $msg_type . '</msg_type>' . $this->_OUTPUT_LF . + $this->_OUTPUT_INDENT . '</header>' . $this->_OUTPUT_LF . + $this->_OUTPUT_INDENT . '<body>' . $this->_OUTPUT_LF . + $xml_data_block . $this->_OUTPUT_LF . + $this->_OUTPUT_INDENT . '</body>' . $this->_OUTPUT_LF . '</OPS_envelope>'; # log it @@ -479,9 +533,9 @@ function PHP2XML($data) { - return str_repeat($this->_SPACER,2) . '<data_block>' . + return str_repeat($this->_OUTPUT_INDENT,2) . '<data_block>' . $this->_convertData($data, 3) . - $this->_CRLF . str_repeat($this->_SPACER,2) . '</data_block>'; + $this->_OUTPUT_LF . str_repeat($this->_OUTPUT_INDENT,2) . '</data_block>'; } @@ -499,15 +553,15 @@ function _convertData(&$array, $indent=0) { $string = ''; - $IND = str_repeat($this->_SPACER,$indent); + $IND = str_repeat($this->_OUTPUT_INDENT,$indent); if (is_array($array)) { if ($this->_is_assoc($array)) { # HASH REFERENCE - $string .= $this->_CRLF . $IND . '<dt_assoc>'; + $string .= $this->_OUTPUT_LF . $IND . '<dt_assoc>'; $end = '</dt_assoc>'; } else { # ARRAY REFERENCE - $string .= $this->_CRLF . $IND . '<dt_array>'; + $string .= $this->_OUTPUT_LF . $IND . '<dt_array>'; $end = '</dt_array>'; } @@ -520,7 +574,7 @@ continue; } - $string .= $this->_CRLF . $IND . '<item key="' . $k . '"'; + $string .= $this->_OUTPUT_LF . $IND . '<item key="' . $k . '"'; if (gettype($v)=='object' && get_class($v)) { $string .= ' class="' . get_class($v) . '"'; @@ -530,7 +584,7 @@ if (is_array($v) || is_object($v)) { $string .= $this->_convertData($v, $indent+1); - $string .= $this->_CRLF . $IND . '</item>'; + $string .= $this->_OUTPUT_LF . $IND . '</item>'; } else { $string .= $this->_quoteXMLChars($v) . '</item>'; } @@ -538,11 +592,11 @@ $indent--; } - $string .= $this->_CRLF . $IND . $end; + $string .= $this->_OUTPUT_LF . $IND . $end; } else { # SCALAR - $string .= $this->_CRLF . $IND . '<dt_scalar>' . + $string .= $this->_OUTPUT_LF . $IND . '<dt_scalar>' . $this->_quoteXMLChars($array) . '</dt_scalar>'; } @@ -585,14 +639,14 @@ function _is_assoc(&$array) { - if (is_array($array)) { - foreach ($array as $k=>$v) { - if (!is_int($k)) { - return true; - } - } - } - return false; + if (is_array($array)) { + foreach ($array as $k=>$v) { + if (!is_int($k)) { + return true; + } + } + } + return false; } @@ -618,8 +672,8 @@ 'i' => 'info' ); - if ($log=='xml' || $log=='http') { - $this->log[$log][] = sprintf("[% 6s:%06d]\n%s\n", + if ($log=='xml') { + $this->log[$log][] = sprintf("[% 6s:%06d] %s\n", strtoupper($types[$type]), ($type=='e' || $type=='i') ? 0 : strlen($msg), $msg |
|
From: Colin V. <cvi...@us...> - 2004-02-11 16:41:32
|
Update of /cvsroot/opensrs-php/opensrs-php In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23701 Modified Files: Tag: opensrs_php_2 CHANGELOG OPS.php openSRS.php.default openSRS_base.php ops.dtd Log Message: should have been committed to the 2.x branch ... my fault for not telling jason Index: CHANGELOG =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/CHANGELOG,v retrieving revision 1.23.2.1 retrieving revision 1.23.2.2 diff -u -r1.23.2.1 -r1.23.2.2 --- CHANGELOG 15 Aug 2003 16:02:52 -0000 1.23.2.1 +++ CHANGELOG 11 Feb 2004 16:37:15 -0000 1.23.2.2 @@ -1,12 +1,11 @@ CHANGELOG --------- -Version x.x.x -xx-xxx-xxxx - - -Version 2.7.3 -15-Aug-2003 +Version 2.8.0 +10-Feb-2004 (Jason Slaughter) + - added support for XML over HTTPS POST method for OpenSRS + - new crypt_type "SSL," changed default to BLOWFISH from DES + - minor fix to ops.dtd - Updated README to reflect HRS functionality - exposed HRS_port in the config file, since that port number is different for each HRS customer (Jason Slaughter) Index: OPS.php =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/OPS.php,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -u -r1.8 -r1.8.2.1 --- OPS.php 18 Jun 2003 19:35:38 -0000 1.8 +++ OPS.php 11 Feb 2004 16:37:15 -0000 1.8.2.1 @@ -618,8 +618,8 @@ 'i' => 'info' ); - if ($log=='xml') { - $this->log[$log][] = sprintf("[% 6s:%06d] %s\n", + if ($log=='xml' || $log=='http') { + $this->log[$log][] = sprintf("[% 6s:%06d]\n%s\n", strtoupper($types[$type]), ($type=='e' || $type=='i') ? 0 : strlen($msg), $msg Index: openSRS.php.default =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/openSRS.php.default,v retrieving revision 1.7 retrieving revision 1.7.2.1 diff -u -r1.7 -r1.7.2.1 --- openSRS.php.default 24 Jun 2003 19:24:38 -0000 1.7 +++ openSRS.php.default 11 Feb 2004 16:37:15 -0000 1.7.2.1 @@ -57,9 +57,9 @@ var $HRS_USERNAME = 'yourOpenHRSname'; var $HRS_PRIVATE_KEY = 'abcdef1234567890'; - var $environment = 'TEST'; # 'TEST' or 'LIVE' or 'HRS' - var $crypt_type = 'DES'; # 'DES' or 'BLOWFISH'; - var $protocol = 'XCP'; # 'XCP' for domains, 'TPP' for email and certs + var $environment = 'TEST'; # 'TEST' or 'LIVE' or 'HRS' + var $crypt_type = 'BLOWFISH'; # 'DES' or 'BLOWFISH' or 'SSL'; + var $protocol = 'XCP'; # 'XCP' for domains, 'TPP' for email and certs var $connect_timeout = 20; # seconds Index: openSRS_base.php =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/openSRS_base.php,v retrieving revision 1.16.2.1 retrieving revision 1.16.2.2 diff -u -r1.16.2.1 -r1.16.2.2 --- openSRS_base.php 15 Aug 2003 16:02:52 -0000 1.16.2.1 +++ openSRS_base.php 11 Feb 2004 16:37:15 -0000 1.16.2.2 @@ -68,10 +68,13 @@ var $LIVE_host = 'rr-n1-tor.opensrs.net'; var $LIVE_port = 55000; + var $LIVE_sslport = 55443; var $TEST_host = 'horizon.opensrs.net'; var $TEST_port = 55000; + var $TEST_sslport = 55443; var $HRS_host; var $HRS_port; + var $HRS_sslport; var $REMOTE_HOST; var $REMOTE_PORT; @@ -79,11 +82,13 @@ var $read_timeout = 20; /* seconds */ var $log = array(); + var $CRLF = "\r\n"; var $_socket = false; var $_socket_error_num = false; var $_socket_error_msg = false; var $_session_key = false; + var $_authenticated = false; var $_OPS; var $_CBC; @@ -236,6 +241,22 @@ $this->PEAR(); + $this->crypt_type = strtoupper($this->crypt_type); + + if ("SSL" == $this->crypt_type) { + if (!function_exists('version_compare') || version_compare("4.3",phpversion(),">=")) { + $error_message = "PHP version must be v4.3+ (current version is ".phpversion(). ") to use an OpenSRS \$crypt-type of \"SSL\""; + trigger_error ($error_message, E_USER_ERROR); + $this->_log('i',$error_message); + return false; + } elseif (!function_exists('openssl_open')) { + $error_message = "PHP must be compiled using --with-openssl to use an OpenSRS \$crypt-type of \"SSL\""; + trigger_error ($error_message, E_USER_ERROR); + $this->_log('i',$error_message); + return false; + } + } + $this->_log('i', 'OpenSRS Log:'); $this->_log('i', 'Initialized: '.date('r') ); @@ -576,11 +597,20 @@ } $this->REMOTE_HOST = $this->{$this->environment.'_host'}; - $this->REMOTE_PORT = $this->{$this->environment.'_port'}; + if ("SSL" == $this->crypt_type) { + $this->REMOTE_PORT = $this->{$this->environment.'_sslport'}; + } else { + $this->REMOTE_PORT = $this->{$this->environment.'_port'}; + } # create a socket - $this->_socket = fsockopen($this->REMOTE_HOST, $this->REMOTE_PORT, + $connection_protocol = ""; + if ("SSL" == $this->crypt_type) { + # ssl:// requires PHP v4.3.0+ compiled with --with-openssl + $connection_protocol = "ssl://"; + } + $this->_socket = fsockopen($connection_protocol.$this->REMOTE_HOST, $this->REMOTE_PORT, $this->_socket_err_num, $this->_socket_err_msg, $this->connect_timeout ); if (!$this->_socket) { @@ -599,7 +629,7 @@ function authenticate($username=false,$private_key=false) { - if ($this->_authenticated) { + if ($this->_authenticated || "SSL" == $this->crypt_type) { return array('is_success' => true); } @@ -825,7 +855,7 @@ function read_data($args=array()) { - $buf = $this->_OPS->readData($this->_socket, $this->read_timeout); + $buf = $this->readData($this->_socket, $this->read_timeout); if (!$buf) { $data = array('error' => 'Read error'); @@ -879,7 +909,7 @@ $data_to_send = $this->_CBC->encrypt($data_to_send); } - return $this->_OPS->writeData( $this->_socket, $data_to_send ); + return $this->writeData( $this->_socket, $data_to_send ); } @@ -1006,4 +1036,174 @@ +/** +* Writes a message to a socket (buffered IO) +* +* @param int socket handle +* +* @param string message to write +* +*/ + +function writeData(&$fh,$msg) +{ + $header = ""; + $len = strlen($msg); + switch ($this->crypt_type) { + case 'SSL': + $signature = md5(md5($msg.$this->PRIVATE_KEY).$this->PRIVATE_KEY); + $header .= "POST / HTTP/1.0". $this->CRLF; + $header .= "Content-Type: text/xml" . $this->CRLF; + $header .= "X-Username: " . $this->USERNAME . $this->CRLF; + $header .= "X-Signature: " . $signature . $this->CRLF; + $header .= "Content-Length: " . $len . $this->CRLF . $this->CRLF; + break; + case 'BLOWFISH': + case 'DES': + default: + $header .= "Content-Length: " . $len . $this->CRLF . $this->CRLF; + break; + } + + fputs($fh, $header); + + fputs($fh, $msg, $len ); + + if ("SSL" == $this->crypt_type) { + $this->_OPS->_log('http','w',$header.$msg); + } + + $this->_OPS->_log('raw', 'w', $msg, $len); +} + + +/** +* Reads header data +* +* @param int socket handle +* +* @param int timeout for read +* +* @return hash hash containing header key/value pairs +* +*/ + +function readHeader($fh, $timeout=5) +{ + $header = array(); + switch ($this->crypt_type) { + case 'SSL': + # HTTP/SSL connection method + $http_log = ""; + $line = fgets($fh, 4000); + $http_log .= $line; + if (!preg_match('/^HTTP\/1.1 ([0-9]{0,3}) (.*)\r\n$/',$line, $matches)) { + $this->_OPS->_log('raw', 'e', 'UNEXPECTED READ: Unable to parse HTTP response code' ); + $this->_OPS->_log('raw', 'r', $line); + return false; + } + $header["http_response_code"] = $matches['1']; + $header["http_response_text"] = $matches['2']; + while ($line != $this->CRLF) { + $line = fgets($fh, 4000); + $http_log .= $line; + if (feof($fh)) { + $this->_OPS->_log('raw', 'e', 'UNEXPECTED READ: Error reading HTTP header' ); + $this->_OPS->_log('raw', 'r', $line); + return false; + } + $matches = explode(': ', $line, 2); + if (sizeof($matches) == 2) { + $header[trim(strtolower($matches[0]))] = $matches[1]; + } + } + $header{'full_header'} = $http_log; + break; + ## END SSL + case 'BLOWFISH': + case 'DES': + default: + # default (old-style) connection + $line = fgets($fh, 4000); + if ($this->_OPS->socketStatus($fh)) { + return false; + } + + if (preg_match('/^\s*Content-Length:\s+(\d+)\s*\r\n/i', $line, $matches ) ) { + $header{'content-length'} = (int)$matches[1]; + } else { + $this->_OPS->_log('raw', 'e', 'UNEXPECTED READ: No Content-Length' ); + $this->_OPS->_log('raw', 'r', $line); + return false; + } + + /* read the empty line */ + + $line = fread($fh, 2); + if ($this->_OPS->socketStatus($fh)) { + return false; + } + + if ($line!=$this->CRLF) { + $this->_OPS->_log('raw', 'e', 'UNEXPECTED READ: No CRLF'); + $this->_OPS->_log('raw', 'r', $line); + return false; + } + break; + } + return $header; +} + + +/** +* Reads data from a socket +* +* @param int socket handle +* +* @param int timeout for read +* +* @return mixed buffer with data, or an error for a short read +* +*/ + +function readData(&$fh, $timeout=5) +{ + $len = 0; + + /* PHP doesn't have timeout for fread ... we just set the timeout for the socket */ + + socket_set_timeout($fh, $timeout); + + $header = $this->readHeader($fh, $timeout); + + if (!$header || !isset($header{'content-length'}) || (empty($header{'content-length'}))) { + $this->_OPS->_log('raw', 'e', 'UNEXPECTED ERROR: No Content-Length header provided!' ); + } + + $len = (int)$header{'content-length'}; + + $line = ''; + while (strlen($line) < $len) { + $line .= fread($fh, $len); + if ($this->_OPS->socketStatus($fh)) { + return false; + } + } + + if ($line) { + $buf = $line; + $this->_OPS->_log('raw', 'r', $line); + } else { + $buf = false; + $this->_OPS->_log('raw', 'e', 'NEXT LINE SHORT READ (should be '.$len.')' ); + $this->_OPS->_log('raw', 'r', $line); + } + + if ("SSL" == $this->crypt_type) { + $this->_OPS->_log('http','r',$header{'full_header'}.$line); + $this->close_socket(); + } + return $buf; +} + } Index: ops.dtd =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/ops.dtd,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 --- ops.dtd 7 Sep 2000 23:53:20 -0000 1.1 +++ ops.dtd 11 Feb 2004 16:37:15 -0000 1.1.2.1 @@ -41,7 +41,7 @@ <!ATTLIST item key CDATA #REQUIRED - class CDATA > + class CDATA #IMPLIED > <!ELEMENT msg_id (#PCDATA)> |
|
From: Jason S. <jas...@us...> - 2004-02-10 22:54:58
|
Update of /cvsroot/opensrs-php/opensrs-php In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17244 Modified Files: openSRS_base.php Log Message: Removed ;charset="utf-8" due to a bug at OpenSRS. It will be added again later. Index: openSRS_base.php =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/openSRS_base.php,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- openSRS_base.php 10 Feb 2004 16:07:43 -0000 1.18 +++ openSRS_base.php 10 Feb 2004 22:51:17 -0000 1.19 @@ -1053,7 +1053,7 @@ case 'SSL': $signature = md5(md5($msg.$this->PRIVATE_KEY).$this->PRIVATE_KEY); $header .= "POST / HTTP/1.0". $this->CRLF; - $header .= "Content-Type: text/xml; charset=\"utf-8\"" . $this->CRLF; + $header .= "Content-Type: text/xml" . $this->CRLF; $header .= "X-Username: " . $this->USERNAME . $this->CRLF; $header .= "X-Signature: " . $signature . $this->CRLF; $header .= "Content-Length: " . $len . $this->CRLF . $this->CRLF; |
|
From: Jason S. <jas...@us...> - 2004-02-10 16:11:11
|
Update of /cvsroot/opensrs-php/opensrs-php In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17638 Modified Files: CHANGELOG OPS.php openSRS.php.default openSRS_base.php ops.dtd Log Message: Changed connection methods to support XML over HTTPS POST. writeData and readData functions moved to openSRS_base.php. Unmodified versions were left in OPS.php for legacy support, but they are no longer used in the main code. Index: CHANGELOG =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/CHANGELOG,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- CHANGELOG 24 Jun 2003 19:24:38 -0000 1.23 +++ CHANGELOG 10 Feb 2004 16:07:43 -0000 1.24 @@ -1,6 +1,12 @@ CHANGELOG --------- +Version 2.8.0 +10-Feb-2004 (Jason Slaughter) + - added support for XML over HTTPS POST method for OpenSRS + - new crypt_type "SSL," changed default to BLOWFISH from DES + - minor fix to ops.dtd + Version x.x.x xx-xxx-xxxx - Updated README to reflect HRS functionality Index: OPS.php =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/OPS.php,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- OPS.php 18 Aug 2003 22:36:24 -0000 1.10 +++ OPS.php 10 Feb 2004 16:07:43 -0000 1.11 @@ -34,27 +34,13 @@ require_once 'PEAR.php'; -define ('OPS_OK', 1 ); -define ('OPS_ERROR', -1 ); -define ('OPS_ERROR_TIMEOUT', -2 ); -define ('OPS_ERROR_EOF', -3 ); -define ('OPS_ERROR_NO_DATA', -4 ); -define ('OPS_ERROR_SHORT_READ', -5 ); -define ('OPS_ERROR_UNEXPECTED', -6 ); -define ('OPS_ERROR_CANT_DECODE', -7 ); -define ('OPS_ERROR_CANT_ENCODE', -8 ); -define ('OPS_ERROR_NO_SOCKET', -9 ); -define ('OPS_ERROR_CANT_WRITE', -10 ); - class OPS extends PEAR { - var $_OPS_VERSION = '0.9'; - - var $_OUTPUT_COMPRESS = false; - var $_OUTPUT_INDENT = ' '; - var $_OUTPUT_LF = "\n"; - - var $_MSGTYPE_STD = 'standard'; + var $_OPS_VERSION = '0.9'; + var $_OPT = ''; + var $_SPACER = ' '; /* indent character */ + var $_CRLF = "\n"; + var $_MSGTYPE_STD = 'standard'; var $_SESSID; var $_MSGCNT; @@ -83,10 +69,10 @@ $this->PEAR(); if (is_array($args)) { - if ($args['compress']==true) { - $this->_OUTPUT_COMPRESS = true; - $this->_OUTPUT_INDENT = ''; - $this->_OUTPUT_LF = ''; + if ($args['option']=='compress') { + $this->_OPT = 'compress'; + $this->_SPACER = ''; + $this->_CRLF = ''; } } @@ -102,38 +88,6 @@ } - function raiseError($code, $info=NULL) - { - return PEAR::raiseError( $this->errorMessage($code), $code, NULL, NULL, $info ); - } - - - function errorMessage($value) - { - static $errorMessages; - if (!isset($errorMessages)) { - $errorMessages = array( - OPS_OK => 'OK', - OPS_ERROR => 'unknown error', - OPS_ERROR_TIMEOUT => 'timeout reading', - OPS_ERROR_EOF => 'EOF reached', - OPS_ERROR_NO_DATA => 'no data read', - OPS_ERROR_SHORT_READ => 'short read', - OPS_ERROR_UNEXPECTED => 'unexpected data read', - OPS_ERROR_CANT_DECODE => 'can\'t decode data', - OPS_ERROR_CANT_ENCODE => 'can\'t encode data', - OPS_ERROR_NO_SOCKET => 'socket not active', - OPS_ERROR_CANT_WRITE => 'can\'t write to socket', - ); - } - - if (PEAR::isError($value)) { - $value = $value->getCode(); - } - - return isset($errorMessages[$value]) ? $errorMessages[$value] : $errorMessages[OPS_ERROR]; - - } /** @@ -148,18 +102,10 @@ function writeData(&$fh,$msg) { $len = strlen($msg); - - if (!fputs($fh, 'Content-Length: ' . $len . $this->CRLF . $this->CRLF) ) { - return $this->raiseError( OPS_ERROR_CANT_WRITE ); - } - if (!fputs($fh, $msg, $len ) ) { - return $this->raiseError( OPS_ERROR_CANT_WRITE ); - } + fputs($fh, 'Content-Length: ' . $len . $this->CRLF . $this->CRLF); + fputs($fh, $msg, $len ); $this->_log('raw', 'w', $msg, $len); - - return OPS_OK; - } @@ -170,19 +116,12 @@ * * @param string message to encode and write * - * @return mixed OK, or an error - * */ function writeMessage(&$fh, $hr ) { $msg = $this->encode( $hr ); - if (PEAR::isError($msg)) { - return $msg; - } - - return $this->writeData($fh, $msg ); - + $this->writeData($fh, $msg ); } @@ -193,7 +132,7 @@ * * @param int timeout for read * - * @return mixed buffer with data, or an error + * @return mixed buffer with data, or an error for a short read * */ @@ -206,10 +145,9 @@ socket_set_timeout($fh, $timeout); $line = fgets($fh, 4000); - $test = $this->socketStatus($fh); - if (PEAR::isError($test)) { - return $test; + if ($this->socketStatus($fh)) { + return false; } if (!$len && preg_match('/^\s*Content-Length:\s+(\d+)\s*\r\n/i', $line, $matches ) ) { @@ -217,46 +155,40 @@ } else { $this->_log('raw', 'e', 'UNEXPECTED READ: No Content-Length' ); $this->_log('raw', 'r', $line); - return $this->raiseError( OPS_ERROR_UNEXPECTED, 'No content-length' ); + return false; } /* read the empty line */ $line = fread($fh, 2); - $test = $this->socketStatus($fh); - if (PEAR::isError($test)) { - return $test; + if ($this->socketStatus($fh)) { + return false; } if ($line!=$this->CRLF) { $this->_log('raw', 'e', 'UNEXPECTED READ: No CRLF'); $this->_log('raw', 'r', $line); - return $this->raiseError( OPS_ERROR_UNEXPECTED, 'No CRLF' ); + return false; } $line = ''; while (strlen($line) < $len) { $line .= fread($fh, $len); - $test = $this->socketStatus($fh); - if (PEAR::isError($test)) { - return $test; + if ($this->socketStatus($fh)) { + return false; } } - if ($line=='') { - $this->_log('raw', 'e', 'NO DATA READ' ); - return $this->raiseError( OPS_ERROR_NO_DATA ); - } - - if (strlen($line) != $len ) { - $this->_log('raw', 'e', 'NEXT LINE SHORT READ (expecting '.$len.', read ' . strlen($line) . ')' ); + if ($line) { + $buf = $line; + $this->_log('raw', 'r', $line); + } else { + $buf = false; + $this->_log('raw', 'e', 'NEXT LINE SHORT READ (should be '.$len.')' ); $this->_log('raw', 'r', $line); - return $this->raiseError( OPS_ERROR_SHORT_READ ); } - $this->_log('raw', 'r', $line); - return $line; - + return $buf; } @@ -273,10 +205,7 @@ function readMessage(&$fh, $timeout=5) { $buf = $this->readData($fh, $timeout); - if (PEAR::isError($buf)) { - return $buf; - } - return $this->decode($buf); + return ( $buf ? $this->decode($buf) : false ); } @@ -286,35 +215,52 @@ * * @param int socket handle * - * @return mixed true if the socket is ok, error otherwise + * @return boolean true if the socket has timed out or is EOF * */ function socketStatus(&$fh) { - if (!is_resource($fh)) { - return $this->raiseError( OPS_ERROR_NO_SOCKET ); + $return = false; + if (is_resource($fh)) { + $temp = socket_get_status($fh); + if ($temp['timed_out']) { + $this->_log('raw', 'e', 'SOCKET TIMED OUT'); + $return = true; + } + if ($temp['eof']) { + $this->_log('raw', 'e', 'SOCKET EOF'); + $return = true; + } + unset($temp); } + return $return; + } - $temp = socket_get_status($fh); - if ($temp['timed_out']) { - $this->_log('raw', 'e', 'SOCKET TIMED OUT'); - return $this->raiseError( OPS_ERROR_TIMEOUT ); - } - if ($temp['eof']) { - $this->_log('raw', 'e', 'SOCKET EOF'); - return $this->raiseError( OPS_ERROR_EOF ); - } - - return OPS_OK; + /** + * Internal method to generate error codes hashes + * + * @param int error code + * + * @param string error message + * + * @return array error hash + * + */ + function _opsError($err_code,$err_text) + { + return array( + 'response_code' => $err_code, + 'response_text' => $err_text, + 'is_success' => 0 + ); } - # # DECODING METHODS # Converts XML OPS messages into PHP data @@ -339,10 +285,10 @@ /* determine if we were passed a string or file handle */ if (is_resource($in)) { - /* read the file into a string, then process as usual */ - while (!feof($in)) { - $ops_msg .= fgets($in, 400); - } + # read the file into a string, then process as usual + while (!feof($in)) { + $ops_msg .= fgets($in, 400); + } } else { $ops_msg = $in; } @@ -385,7 +331,7 @@ xml_get_current_line_number($xp) ); xml_parser_free($xp); - return $this->raiseError( OPS_ERROR_CANT_DECODE, $error ); + return $this->raiseError($error); } xml_parser_free($xp); @@ -499,17 +445,17 @@ $xml_data_block = $this->PHP2XML($array); - $ops_msg = '<?xml version="1.0" encoding="UTF-8" standalone="no" ?>' . $this->_OUTPUT_LF . - '<!DOCTYPE OPS_envelope SYSTEM "ops.dtd">' . $this->_OUTPUT_LF . - '<OPS_envelope>' . $this->_OUTPUT_LF . - $this->_OUTPUT_INDENT . '<header>' . $this->_OUTPUT_LF . - $this->_OUTPUT_INDENT . $this->_OUTPUT_INDENT . '<version>' . $this->_OPS_VERSION . '</version>' . $this->_OUTPUT_LF . - $this->_OUTPUT_INDENT . $this->_OUTPUT_INDENT . '<msg_id>' . $msg_id . '</msg_id>' . $this->_OUTPUT_LF . - $this->_OUTPUT_INDENT . $this->_OUTPUT_INDENT . '<msg_type>' . $msg_type . '</msg_type>' . $this->_OUTPUT_LF . - $this->_OUTPUT_INDENT . '</header>' . $this->_OUTPUT_LF . - $this->_OUTPUT_INDENT . '<body>' . $this->_OUTPUT_LF . - $xml_data_block . $this->_OUTPUT_LF . - $this->_OUTPUT_INDENT . '</body>' . $this->_OUTPUT_LF . + $ops_msg = '<?xml version="1.0" encoding="UTF-8" standalone="no" ?>' . $this->_CRLF . + '<!DOCTYPE OPS_envelope SYSTEM "ops.dtd">' . $this->_CRLF . + '<OPS_envelope>' . $this->_CRLF . + $this->_SPACER . '<header>' . $this->_CRLF . + $this->_SPACER . $this->_SPACER . '<version>' . $this->_OPS_VERSION . '</version>' . $this->_CRLF . + $this->_SPACER . $this->_SPACER . '<msg_id>' . $msg_id . '</msg_id>' . $this->_CRLF . + $this->_SPACER . $this->_SPACER . '<msg_type>' . $msg_type . '</msg_type>' . $this->_CRLF . + $this->_SPACER . '</header>' . $this->_CRLF . + $this->_SPACER . '<body>' . $this->_CRLF . + $xml_data_block . $this->_CRLF . + $this->_SPACER . '</body>' . $this->_CRLF . '</OPS_envelope>'; # log it @@ -533,9 +479,9 @@ function PHP2XML($data) { - return str_repeat($this->_OUTPUT_INDENT,2) . '<data_block>' . + return str_repeat($this->_SPACER,2) . '<data_block>' . $this->_convertData($data, 3) . - $this->_OUTPUT_LF . str_repeat($this->_OUTPUT_INDENT,2) . '</data_block>'; + $this->_CRLF . str_repeat($this->_SPACER,2) . '</data_block>'; } @@ -553,15 +499,15 @@ function _convertData(&$array, $indent=0) { $string = ''; - $IND = str_repeat($this->_OUTPUT_INDENT,$indent); + $IND = str_repeat($this->_SPACER,$indent); if (is_array($array)) { if ($this->_is_assoc($array)) { # HASH REFERENCE - $string .= $this->_OUTPUT_LF . $IND . '<dt_assoc>'; + $string .= $this->_CRLF . $IND . '<dt_assoc>'; $end = '</dt_assoc>'; } else { # ARRAY REFERENCE - $string .= $this->_OUTPUT_LF . $IND . '<dt_array>'; + $string .= $this->_CRLF . $IND . '<dt_array>'; $end = '</dt_array>'; } @@ -574,7 +520,7 @@ continue; } - $string .= $this->_OUTPUT_LF . $IND . '<item key="' . $k . '"'; + $string .= $this->_CRLF . $IND . '<item key="' . $k . '"'; if (gettype($v)=='object' && get_class($v)) { $string .= ' class="' . get_class($v) . '"'; @@ -584,7 +530,7 @@ if (is_array($v) || is_object($v)) { $string .= $this->_convertData($v, $indent+1); - $string .= $this->_OUTPUT_LF . $IND . '</item>'; + $string .= $this->_CRLF . $IND . '</item>'; } else { $string .= $this->_quoteXMLChars($v) . '</item>'; } @@ -592,11 +538,11 @@ $indent--; } - $string .= $this->_OUTPUT_LF . $IND . $end; + $string .= $this->_CRLF . $IND . $end; } else { # SCALAR - $string .= $this->_OUTPUT_LF . $IND . '<dt_scalar>' . + $string .= $this->_CRLF . $IND . '<dt_scalar>' . $this->_quoteXMLChars($array) . '</dt_scalar>'; } @@ -639,14 +585,14 @@ function _is_assoc(&$array) { - if (is_array($array)) { - foreach ($array as $k=>$v) { - if (!is_int($k)) { - return true; - } - } - } - return false; + if (is_array($array)) { + foreach ($array as $k=>$v) { + if (!is_int($k)) { + return true; + } + } + } + return false; } @@ -672,8 +618,8 @@ 'i' => 'info' ); - if ($log=='xml') { - $this->log[$log][] = sprintf("[% 6s:%06d] %s\n", + if ($log=='xml' || $log=='http') { + $this->log[$log][] = sprintf("[% 6s:%06d]\n%s\n", strtoupper($types[$type]), ($type=='e' || $type=='i') ? 0 : strlen($msg), $msg Index: openSRS.php.default =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/openSRS.php.default,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- openSRS.php.default 24 Jun 2003 19:24:38 -0000 1.7 +++ openSRS.php.default 10 Feb 2004 16:07:43 -0000 1.8 @@ -57,9 +57,9 @@ var $HRS_USERNAME = 'yourOpenHRSname'; var $HRS_PRIVATE_KEY = 'abcdef1234567890'; - var $environment = 'TEST'; # 'TEST' or 'LIVE' or 'HRS' - var $crypt_type = 'DES'; # 'DES' or 'BLOWFISH'; - var $protocol = 'XCP'; # 'XCP' for domains, 'TPP' for email and certs + var $environment = 'TEST'; # 'TEST' or 'LIVE' or 'HRS' + var $crypt_type = 'BLOWFISH'; # 'DES' or 'BLOWFISH' or 'SSL'; + var $protocol = 'XCP'; # 'XCP' for domains, 'TPP' for email and certs var $connect_timeout = 20; # seconds Index: openSRS_base.php =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/openSRS_base.php,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- openSRS_base.php 18 Aug 2003 22:36:24 -0000 1.17 +++ openSRS_base.php 10 Feb 2004 16:07:43 -0000 1.18 @@ -7,8 +7,8 @@ * Copyright (C) 2000, 2001, 2002, 2003 Colin Viebrock * and easyDNS Technologies Inc. * - * Version 3.0.0-beta - * 18-Aug-2003 + * Version 2.7.3 + * 15-Aug-2003 * ************************************************************************** * @@ -35,30 +35,22 @@ [...1121 lines suppressed...] + } + } + + if ($line) { + $buf = $line; + $this->_OPS->_log('raw', 'r', $line); + } else { + $buf = false; + $this->_OPS->_log('raw', 'e', 'NEXT LINE SHORT READ (should be '.$len.')' ); + $this->_OPS->_log('raw', 'r', $line); + } + + if ("SSL" == $this->crypt_type) { + $this->_OPS->_log('http','r',$header{'full_header'}.$line); + $this->close_socket(); + } + return $buf; +} + } Index: ops.dtd =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/ops.dtd,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ops.dtd 7 Sep 2000 23:53:20 -0000 1.1 +++ ops.dtd 10 Feb 2004 16:07:43 -0000 1.2 @@ -41,7 +41,7 @@ <!ATTLIST item key CDATA #REQUIRED - class CDATA > + class CDATA #IMPLIED > <!ELEMENT msg_id (#PCDATA)> |
|
From: Colin V. <cvi...@us...> - 2003-08-18 22:36:27
|
Update of /cvsroot/opensrs-php/opensrs-php
In directory sc8-pr-cvs1:/tmp/cvs-serv2880
Modified Files:
OPS.php openSRS_base.php
Log Message:
more changes for version 3
Index: OPS.php
===================================================================
RCS file: /cvsroot/opensrs-php/opensrs-php/OPS.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- OPS.php 15 Aug 2003 15:50:34 -0000 1.9
+++ OPS.php 18 Aug 2003 22:36:24 -0000 1.10
@@ -48,11 +48,13 @@
class OPS extends PEAR {
- var $_OPS_VERSION = '0.9';
- var $_OPT = '';
- var $_SPACER = ' '; /* indent character */
- var $_CRLF = "\n";
- var $_MSGTYPE_STD = 'standard';
+ var $_OPS_VERSION = '0.9';
+
+ var $_OUTPUT_COMPRESS = false;
+ var $_OUTPUT_INDENT = ' ';
+ var $_OUTPUT_LF = "\n";
+
+ var $_MSGTYPE_STD = 'standard';
var $_SESSID;
var $_MSGCNT;
@@ -81,10 +83,10 @@
$this->PEAR();
if (is_array($args)) {
- if ($args['option']=='compress') {
- $this->_OPT = 'compress';
- $this->_SPACER = '';
- $this->_CRLF = '';
+ if ($args['compress']==true) {
+ $this->_OUTPUT_COMPRESS = true;
+ $this->_OUTPUT_INDENT = '';
+ $this->_OUTPUT_LF = '';
}
}
@@ -497,17 +499,17 @@
$xml_data_block = $this->PHP2XML($array);
- $ops_msg = '<?xml version="1.0" encoding="UTF-8" standalone="no" ?>' . $this->_CRLF .
- '<!DOCTYPE OPS_envelope SYSTEM "ops.dtd">' . $this->_CRLF .
- '<OPS_envelope>' . $this->_CRLF .
- $this->_SPACER . '<header>' . $this->_CRLF .
- $this->_SPACER . $this->_SPACER . '<version>' . $this->_OPS_VERSION . '</version>' . $this->_CRLF .
- $this->_SPACER . $this->_SPACER . '<msg_id>' . $msg_id . '</msg_id>' . $this->_CRLF .
- $this->_SPACER . $this->_SPACER . '<msg_type>' . $msg_type . '</msg_type>' . $this->_CRLF .
- $this->_SPACER . '</header>' . $this->_CRLF .
- $this->_SPACER . '<body>' . $this->_CRLF .
- $xml_data_block . $this->_CRLF .
- $this->_SPACER . '</body>' . $this->_CRLF .
+ $ops_msg = '<?xml version="1.0" encoding="UTF-8" standalone="no" ?>' . $this->_OUTPUT_LF .
+ '<!DOCTYPE OPS_envelope SYSTEM "ops.dtd">' . $this->_OUTPUT_LF .
+ '<OPS_envelope>' . $this->_OUTPUT_LF .
+ $this->_OUTPUT_INDENT . '<header>' . $this->_OUTPUT_LF .
+ $this->_OUTPUT_INDENT . $this->_OUTPUT_INDENT . '<version>' . $this->_OPS_VERSION . '</version>' . $this->_OUTPUT_LF .
+ $this->_OUTPUT_INDENT . $this->_OUTPUT_INDENT . '<msg_id>' . $msg_id . '</msg_id>' . $this->_OUTPUT_LF .
+ $this->_OUTPUT_INDENT . $this->_OUTPUT_INDENT . '<msg_type>' . $msg_type . '</msg_type>' . $this->_OUTPUT_LF .
+ $this->_OUTPUT_INDENT . '</header>' . $this->_OUTPUT_LF .
+ $this->_OUTPUT_INDENT . '<body>' . $this->_OUTPUT_LF .
+ $xml_data_block . $this->_OUTPUT_LF .
+ $this->_OUTPUT_INDENT . '</body>' . $this->_OUTPUT_LF .
'</OPS_envelope>';
# log it
@@ -531,9 +533,9 @@
function PHP2XML($data)
{
- return str_repeat($this->_SPACER,2) . '<data_block>' .
+ return str_repeat($this->_OUTPUT_INDENT,2) . '<data_block>' .
$this->_convertData($data, 3) .
- $this->_CRLF . str_repeat($this->_SPACER,2) . '</data_block>';
+ $this->_OUTPUT_LF . str_repeat($this->_OUTPUT_INDENT,2) . '</data_block>';
}
@@ -551,15 +553,15 @@
function _convertData(&$array, $indent=0)
{
$string = '';
- $IND = str_repeat($this->_SPACER,$indent);
+ $IND = str_repeat($this->_OUTPUT_INDENT,$indent);
if (is_array($array)) {
if ($this->_is_assoc($array)) { # HASH REFERENCE
- $string .= $this->_CRLF . $IND . '<dt_assoc>';
+ $string .= $this->_OUTPUT_LF . $IND . '<dt_assoc>';
$end = '</dt_assoc>';
} else { # ARRAY REFERENCE
- $string .= $this->_CRLF . $IND . '<dt_array>';
+ $string .= $this->_OUTPUT_LF . $IND . '<dt_array>';
$end = '</dt_array>';
}
@@ -572,7 +574,7 @@
continue;
}
- $string .= $this->_CRLF . $IND . '<item key="' . $k . '"';
+ $string .= $this->_OUTPUT_LF . $IND . '<item key="' . $k . '"';
if (gettype($v)=='object' && get_class($v)) {
$string .= ' class="' . get_class($v) . '"';
@@ -582,7 +584,7 @@
if (is_array($v) || is_object($v)) {
$string .= $this->_convertData($v, $indent+1);
- $string .= $this->_CRLF . $IND . '</item>';
+ $string .= $this->_OUTPUT_LF . $IND . '</item>';
} else {
$string .= $this->_quoteXMLChars($v) . '</item>';
}
@@ -590,11 +592,11 @@
$indent--;
}
- $string .= $this->_CRLF . $IND . $end;
+ $string .= $this->_OUTPUT_LF . $IND . $end;
} else { # SCALAR
- $string .= $this->_CRLF . $IND . '<dt_scalar>' .
+ $string .= $this->_OUTPUT_LF . $IND . '<dt_scalar>' .
$this->_quoteXMLChars($array) . '</dt_scalar>';
}
Index: openSRS_base.php
===================================================================
RCS file: /cvsroot/opensrs-php/opensrs-php/openSRS_base.php,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- openSRS_base.php 24 Jun 2003 19:24:38 -0000 1.16
+++ openSRS_base.php 18 Aug 2003 22:36:24 -0000 1.17
@@ -7,8 +7,8 @@
* Copyright (C) 2000, 2001, 2002, 2003 Colin Viebrock
* and easyDNS Technologies Inc.
*
- * Version 2.7.2
- * 18-Jun-2003
+ * Version 3.0.0-beta
+ * 18-Aug-2003
*
**************************************************************************
*
@@ -35,21 +35,29 @@
*/
-# assuming that the PEAR directory is within your path, otherwise change the path here
+/* assuming that the PEAR directory is within your path, otherwise change the path here */
require_once 'PEAR.php';
require_once 'Crypt/CBC.php';
+require_once 'Log.php';
-# local requirements
+/* local requirements */
require_once 'OPS.php';
require_once 'country_codes.php';
+/* some error code definitions */
+
+define( 'OPENSRS_OK', 1 );
+define( 'OPENSRS_ERROR', -1 );
+define( 'OPENSRS_ERROR_INVALID_PROTOCOL', -2 );
+define( 'OPENSRS_ERROR_INVALID_ENVIRONMENT', -3 );
+define( 'OPENSRS_ERROR_INVALID_CIPHER', -4 );
-class openSRS_base extends PEAR {
+class openSRS_base extends PEAR {
var $USERNAME = '';
var $HRS_USERNAME = '';
@@ -59,19 +67,19 @@
var $LIVE_PRIVATE_KEY = '';
var $HRS_PRIVATE_KEY = '';
- var $VERSION = 'XML:0.1';
-
- var $base_class_version = '2.7.2';
+ var $_version = '3.0.0-beta';
var $environment = 'TEST'; /* 'TEST' or 'LIVE' or 'HRS' */
var $protocol = 'XCP'; /* 'XCP' or 'TPP' */
+ var $cipher = 'DES'; /* 'DES' or 'BLOWFISH' */
var $LIVE_host = 'rr-n1-tor.opensrs.net';
var $LIVE_port = 55000;
var $TEST_host = 'horizon.opensrs.net';
var $TEST_port = 55000;
- var $HRS_host;
- var $HRS_port;
+ var $HRS_host = '';
+ var $HRS_port = 0;
+
var $REMOTE_HOST;
var $REMOTE_PORT;
@@ -81,8 +89,6 @@
var $log = array();
var $_socket = false;
- var $_socket_error_num = false;
- var $_socket_error_msg = false;
var $_session_key = false;
var $_OPS;
@@ -92,128 +98,12 @@
var $_CRYPT;
var $_iv;
- var $crypt_type = 'DES'; /* 'DES' or 'BLOWFISH' */
var $crypt_mode = 'CBC'; /* only 'CBC' */
var $crypt_rand_source = MCRYPT_DEV_URANDOM; /* or MCRYPT_DEV_RANDOM or MCRYPT_RAND */
var $affiliate_id;
- var $PERMISSIONS = array (
- 'f_modify_owner' => 1,
- 'f_modify_admin' => 2,
- 'f_modify_billing' => 4,
- 'f_modify_tech' => 8,
- 'f_modify_nameservers' => 16
- );
-
- var $REG_PERIODS = array (
- 1 => '1 Year',
- 2 => '2 Years',
- 3 => '3 Years',
- 4 => '4 Years',
- 5 => '5 Years',
- 6 => '6 Years',
- 7 => '7 Years',
- 8 => '8 Years',
- 9 => '9 Years',
- 10 => '10 Years'
- );
-
- var $UK_REG_PERIODS = array (
- 2 => '2 Years'
- );
-
- var $TV_REG_PERIODS = array (
- 1 => '1 Year',
- 2 => '2 Years',
- 3 => '3 Years',
- 5 => '5 Years',
- 10 => '10 Years'
- );
-
- var $TRANSFER_PERIODS = array (
- 1 => '1 Year'
- );
-
var $OPENSRS_TLDS_REGEX = '(\.ca|\.(bc|ab|sk|mb|on|qc|nb|ns|pe|nf|nt|nv|yk)\.ca|\.com|\.net|\.org|\.co\.uk|\.org\.uk|\.tv|\.vc|\.cc|\.info|\.biz|\.name|\.us)';
- var $CA_LEGAL_TYPES = array (
- 'ABO' => 'Aboriginal',
- 'ASS' => 'Association',
- 'CCO' => 'Canadian Corporation',
- 'CCT' => 'Canadian Citizen',
- 'EDU' => 'Educational Institute',
- 'GOV' => 'Government',
- 'HOP' => 'Hospital',
- 'INB' => 'Indian Band',
- 'LAM' => 'Library, Archive or Museum',
- 'LGR' => 'Legal Respresentative',
- 'MAJ' => 'Her Majesty the Queen',
- 'OMK' => 'Protected by Trade-marks Act',
- 'PLT' => 'Political Party',
- 'PRT' => 'Partnership',
- 'RES' => 'Permanent Resident',
- 'TDM' => 'Trade-mark Owner',
- 'TRD' => 'Trade Union',
- 'TRS' => 'Trust'
- );
-
- var $CA_LANGUAGE_TYPES = array (
- 'EN' => 'English',
- 'FR' => 'French'
- );
-
- var $CA_NATIONALITIES = array (
- 'CND' => 'Canadian citizen',
- 'OTH' => 'Foreign citizenship',
- 'RES' => 'Canadian permanent resident'
- );
-
-
- var $OPENSRS_ACTIONS = array (
- 'get_domain' => true,
- 'get_userinfo' => true,
-
- 'modify_domain' => true,
- 'renew_domain' => true,
- 'register_domain' => true,
-
- 'get_nameserver' => true,
- 'create_nameserver' => true,
- 'modify_nameserver' => true,
- 'delete_nameserver' => true,
-
- 'get_subuser' => true,
- 'add_subuser' => true,
- 'modify_subuser' => true,
- 'delete_subuser' => true,
-
- 'change_password' => true,
- 'change_ownership' => true,
-
- 'set_cookie' => true,
- 'delete_cookie' => true,
- 'update_cookie' => true,
-
- 'sw_register_domain' => true,
- 'bulk_transfer_domain' => true,
- 'register_domain' => true,
-
- 'lookup_domain' => true,
- 'get_price_domain' => true,
-
- 'check_transfer_domain' => true,
- 'quit_session' => true,
-
- 'buy_webcert' => true,
- 'refund_webcert' => true,
- 'query_webcert' => true,
- 'cprefget_webcert' => true,
- 'cprefset_webcert' => true,
- 'cancel_pending_webcert' => true,
- 'update_webcert' => true,
-
- );
-
#
@@ -231,37 +121,78 @@
*
*/
- function openSRS_base( $environment=NULL, $protocol=NULL )
+ function openSRS_base( $env=NULL, $proto=NULL, $cipher=NULL )
{
$this->PEAR();
+ $this->setErrorHandling( PEAR_ERROR_TRIGGER, E_USER_ERROR );
$this->_log('i', 'OpenSRS Log:');
$this->_log('i', 'Initialized: '.date('r') );
$this->_OPS = new OPS;
+ $this->_CBC = false;
- if ($environment) {
- $this->environment = strtoupper($environment);
+ if (!is_null($env)) {
+ $temp = $this->setEnvironment( $env );
+ if (PEAR::isError($temp)) {
+ return $temp;
+ }
}
- if ($protocol) {
- $this->protocol = strtoupper($protocol);
+
+ if (!is_null($proto)) {
+ $temp = $this->setProtocol( $proto );
+ if (PEAR::isError($temp)) {
+ return $temp;
+ }
}
- $this->_log('i', 'Environment: '.$this->environment );
- $this->_log('i', 'Protocol: '.$this->protocol );
+ if (!is_null($cipher)) {
+ $temp = $this->setCipher( $cipher );
+ if (PEAR::isError($temp)) {
+ return $temp;
+ }
+ }
+
+ }
- $this->PRIVATE_KEY = $this->{$this->environment.'_PRIVATE_KEY'};
- $this->_CBC = false;
+ function raiseError($code, $info=NULL, $mode=NULL)
+ {
+ return PEAR::raiseError( $this->errorMessage($code), $code, $mode, 'OpenSRS Error: %s', $info );
}
-#
-# setProtocol()
-# Switch between XCP and TPP
-#
+ function errorMessage($value)
+ {
+ static $errorMessages;
+ if (!isset($errorMessages)) {
+ $errorMessages = array(
+ OPENSRS_OK => 'OK',
+ OPENSRS_ERROR => 'unknown error',
+ OPENSRS_ERROR_INVALID_PROTOCOL => 'invalid protocol',
+ OPENSRS_ERROR_INVALID_ENVIRONMENT => 'invalid environment',
+ OPENSRS_ERROR_INVALID_CIPHER => 'invalid cipher',
+ );
+ }
+
+ if (PEAR::isError($value)) {
+ $value = $value->getCode();
+ }
+
+ return isset($errorMessages[$value]) ? $errorMessages[$value] : $errorMessages[OPENSRS_ERROR];
+
+ }
+
+
+
+
+ function getProtocol( )
+ {
+ return $this->protocol;
+ }
+
function setProtocol( $proto )
@@ -280,277 +211,162 @@
break;
default:
- return array(
- 'is_success' => false,
- 'error' => 'Invalid protocol: ' . $proto
- );
+ return $this->raiseError( OPENSRS_ERROR_INVALID_PROTOCOL, NULL, PEAR_ERROR_DIE );
break;
}
}
-#
-# logout()
-# Send a 'quit' command to the server
-#
-
- function logout() {
- if ($this->_socket) {
- $this->send_cmd( array(
- 'action' => 'quit',
- 'object' => 'session' )
- );
- $this->close_socket();
- }
+ function getCipher( )
+ {
+ return $this->cipher;
}
-#
-# send_cmd()
-# Send a command to the server
-#
-
- function send_cmd($request) {
- global $HTTP_SERVER_VARS;
-
- if (!is_array($request)) {
- $data = array(
- 'is_success' => false,
- 'response_code' => 400,
- 'response_text' => 'Invalid command (not an array): '.$request
- );
- $this->_log('i',$data);
- return $data;
- }
- $action = $request['action'];
- $object = $request['object'];
-
- # prune any private data before sending down to the server
- # (eg. credit card numbers and information
-
- $this->prune_private_keys($request);
+ function setCipher( $cipher )
+ {
-#
-# Disable action checking. This means you don't need to update the code
-# each time OpenSRS adds a new command, but means you should be more
-# careful with your coding ...
-#
-# if (!isset($this->OPENSRS_ACTIONS[$action.'_'.$object])) {
-# $data = array(
-# 'is_success' => false,
-# 'response_code' => 400,
-# 'response_text' => 'Invalid command: '.$action.' '.$object
-# );
-# $this->_log('i',$data);
-# return $data;
-# }
+ $cipher = trim(strtoupper($cipher));
+ switch ($cipher) {
+ case 'DES':
+ case 'BLOWFISH':
+ $this->cipher = $cipher;
- # make or get the socket filehandle
+ $this->_log('i', 'Set cipher: '.$this->cipher );
- if (!$this->init_socket() ) {
- $data = array(
- 'is_success' => false,
- 'response_code' => 400,
- 'response_text' => 'Unable to establish socket: (' .
- $this->_socket_err_num . ') ' . $this->_socket_err_msg
- );
- $this->_log('i',$data);
- return $data;
- }
-
- if ($this->environment == 'HRS') {
- $auth = $this->authenticate($this->HRS_USERNAME,$this->PRIVATE_KEY);
- } else {
- $auth = $this->authenticate($this->USERNAME,$this->PRIVATE_KEY);
- }
+ return true;
+ break;
- if (!$auth['is_success']) {
- if ($this->_socket) {
- $this->close_socket();
- }
- $data = array(
- 'is_success' => false,
- 'response_code' => 400,
- 'response_text' => 'Authentication Error: ' . $auth['error']
- );
- $this->_log('i',$data);
- return $data;
+ default:
+ return $this->raiseError( OPENSRS_ERROR_INVALID_CIPHER, NULL, PEAR_ERROR_DIE );
+ break;
}
- $request['registrant_ip'] = $HTTP_SERVER_VARS['REMOTE_ADDR'];
-
- if ( strstr($request['action'], 'lookup') ) {
- # lookups are treated specially
- $data = $this->lookup_domain( $request );
- } else {
- # send request to server
- $this->send_data( $request );
- $data = $this->read_data( );
- }
+ }
- return $data;
+ function getEnvironment( )
+ {
+ return $this->environment;
}
-#
-# validate()
-# Check data for validity
-#
- function validate($data,$params=array()) {
+ function setEnvironment( $env )
+ {
- # Country codes are needed for checking ... more reliable than /^[A-Z]{2}$/
- include 'country_codes.php';
+ $env = trim(strtoupper($env));
- $missing_fields = $problem_fields = array();
-
- $required_contact_fields = array (
- 'first_name' => 'First Name',
- 'last_name' => 'Last Name',
- 'org_name' => 'Organization Name',
- 'address1' => 'Address1',
- 'city' => 'City',
- 'country' => 'Country',
- 'phone' => 'Phone',
- 'email' => 'E-Mail'
- );
+ switch ($env) {
+ case 'TEST':
+ case 'LIVE':
+ case 'HRS':
+ $this->environment = $env;
- $contact_types = array (
- 'owner' => '',
- 'billing' => 'Billing'
- );
+ $this->_log('i', 'Set environment: '.$this->environment );
- $required_fields = array (
- 'reg_username' => 'Username',
- 'reg_password' => 'Password',
- 'domain' => 'Domain',
- );
+ return true;
+ break;
- if (isset($params['custom_tech_contact'])) {
- $contact_types['tech'] = 'Tech';
+ default:
+ return $this->raiseError( OPENSRS_ERROR_INVALID_ENVIRONMENT, NULL, PEAR_ERROR_DIE );
+ break;
}
- # The primary and secondary nameservers are required.
+ }
- if ( isset($params['custom_nameservers']) && $data['reg_type']=='new' ) {
- if (!$data['fqdn1']) {
- $missing_fields[] = 'Primary DNS Hostname';
- }
- if (!$data['fqdn2']) {
- $missing_fields[] = 'Secondary DNS Hostname';
- }
- }
- # check the required fields
+#
+# logout()
+# Send a 'quit' command to the server
+#
- foreach ($contact_types as $type=>$contact_type) {
+ function logout() {
+ if ($this->_socket) {
+ $this->sendCommand( array(
+ 'action' => 'quit',
+ 'object' => 'session' )
+ );
+ $this->_close_socket();
+ }
+ }
- foreach ($required_contact_fields as $field=>$required_field) {
- $data[$type.'_'.$field] = trim($data[$type.'_'.$field]);
- if ($data[$type.'_'.$field] == '') {
- $missing_fields[] = $contact_type.' '.$required_field;
- }
- }
- $data[$type.'_country'] = strtolower($data[$type.'_country']);
- if ($data[$type.'_country']=='us' || $data[$type.'_country']=='ca') {
- if ($data[$type.'_postal_code']=='') {
- $missing_fields[] = $contact_type.' Zip/Postal Code';
- }
- if ($data[$type.'_state']=='') {
- $missing_fields[] = $contact_type.' State/Province';
- }
- }
+#
+# send_cmd()
+# Send a command to the server
+#
- if (!isset($COUNTRY_CODES[$data[$type.'_country']])) {
- $problem_fields[$contact_type.' Country'] = $data[$type.'_country'];
- }
+ function send_cmd( $request )
+ {
+ return $this->sendCommand( $request );
+ }
- if (!$this->check_email_syntax($data[$type.'_email'])) {
- $problem_fields[$contact_type.' Email'] = $data[$type.'_email'];
- }
- if (!preg_match('/^\+?[\d\s\-\.\(\)]+$/', $data[$type.'_phone'] )) {
- $problem_fields[$contact_type.' Phone'] = $data[$type.'_phone'];
- }
- }
+ function sendCommand($request)
+ {
- foreach ($required_fields as $field=>$required_field) {
- if ($data[$field] == '') {
- $missing_fields[] = $required_field;
- }
+ if (!is_array($request)) {
+ return $this->raiseError( OPENSRS_ERROR_INVALID_COMMAND, 'not an aray' );
}
- # these fields must have at least an alpha in them
+ $action = $request['action'];
+ $object = $request['object'];
- foreach ($data as $field=>$value) {
- if ($value=='') {
- continue; # skip blanks
- }
+ # prune any private data before sending down to the server
+ # (eg. credit card numbers and information
- if ($field=='first_name' || $field=='last_name' || $field=='org_name' || $field=='city' || $field=='state') {
- if (!preg_match('/[a-zA-Z]/', $value)) {
- $error_msg .= "Field $field must contain at least 1 alpha character.<br>\n";
- }
- }
- }
+ $this->_prune_private_keys($request);
- # take $missing_fields and add them to $error_msg
+ # make or get the socket filehandle
- foreach ($missing_fields as $field) {
- $error_msg .= "Missing field: $field.<br>\n";
+ $temp = $this->_init_socket();
+ if (PEAR::isError($temp)) {
+ return $temp;
}
+ $this->PRIVATE_KEY = $this->{$this->environment.'_PRIVATE_KEY'};
- # check syntax on several fields
- # check domain, country, billing_country, email, billing_email, phone,
- # and billing_phone
-
- $domains = explode("\0", $data['domain'] );
- foreach ($domains as $domain) {
- $syntaxError = $this->check_domain_syntax($domain);
- if ($syntaxError) {
- $problem_fields['Domain'] = $domain . " - " . $syntaxError;
- }
+ if ($this->environment == 'HRS') {
+ $auth = $this->_authenticate($this->HRS_USERNAME,$this->PRIVATE_KEY);
+ } else {
+ $auth = $this->_authenticate($this->USERNAME,$this->PRIVATE_KEY);
}
-
- # print error if $problem_fields
-
- if (count(array_keys($problem_fields))) {
- foreach ($problem_fields as $field=>$problem) {
- # only show problem fields if it had a value. Otherwise, it
- # would have been caught above.
- if ($problem != '') {
- $error_msg .= "The field \"$field\" contained invalid characters: <i>$problem</i><br>\n";
- }
+ if (!$auth['is_success']) {
+ if ($this->_socket) {
+ $this->_close_socket();
}
+ return $this->raiseError( OPENSRS_ERROR_AUTH_FAILED, $auth['error'] );
}
+ $request['registrant_ip'] = $_SERVER['REMOTE_ADDR'];
- # insert other error checking here...
-
- if ($error_msg) {
- return ( array('error_msg' => $error_msg) );
+ if ( strstr($request['action'], 'lookup') ) {
+ # lookups are treated specially
+ $data = $this->_lookup_domain( $request );
} else {
- return ( array('is_success' => true) );
+ # send request to server
+ $this->_send_data( $request );
+ $data = $this->_read_data( );
}
- }
+ return $data;
+
+ }
#
# version()
# return base class version
#
- function version() {
- return 'OpenSRS-PHP Class version '.$this->base_class_version;
+ function getVersion() {
+ return 'OpenSRS-PHP Class version '.$this->_version;
}
@@ -561,18 +377,19 @@
#
#
-# init_socket()
+# _init_socket()
# Initialize a socket connection to the OpenSRS server
#
- function init_socket() {
+ function _init_socket()
+ {
if ($this->_socket) {
return true;
}
if (!$this->environment) {
- return false;
+ return $this->raiseError( OPENSRS_ERROR_INVALID_ENVIRONMENT, NULL, PEAR_ERROR_DIE );
}
$this->REMOTE_HOST = $this->{$this->environment.'_host'};
@@ -581,10 +398,10 @@
# create a socket
$this->_socket = fsockopen($this->REMOTE_HOST, $this->REMOTE_PORT,
- $this->_socket_err_num, $this->_socket_err_msg, $this->connect_timeout );
+ $err_num, $err_msg, $this->connect_timeout );
if (!$this->_socket) {
- return false;
+ return $this->raiseError( OPENSRS_ERROR_SOCKET_ERROR, $err_msg . ' (' . $err_num . ')' );
} else {
$this->_log('i','Socket initialized: ' . $this->REMOTE_HOST . ':' . $this->REMOTE_PORT );
return true;
@@ -593,42 +410,32 @@
#
-# authenticate()
+# _authenticate()
# Authenticate the connection with the username/private key
#
- function authenticate($username=false,$private_key=false) {
+ function _authenticate( $username=null, $private_key=null ) {
if ($this->_authenticated) {
- return array('is_success' => true);
+ return true;
}
- if (!$username) {
- return array(
- 'is_success' => false,
- 'error' => 'Missing reseller username'
- );
- } else if (!$private_key) {
- return array(
- 'is_success' => false,
- 'error' => 'Missing private key'
- );
+ if (is_null($username)) {
+ return $this->raiseError( OPENSRS_ERROR_MISSING_USERNAME );
}
- $prompt = $this->read_data();
+ if (is_null($private_key)) {
+ return $this->raiseError( OPENSRS_ERROR_MISSING_PRIVATE_KEY );
+ }
+
+ $prompt = $this->_read_data();
if ( $prompt['response_code'] == 555 ) {
- # the ip address from which we are connecting is not accepted
- return array(
- 'is_success' => false,
- 'error' => $prompt['response_text']
- );
- } else if ( !preg_match('/OpenSRS\sSERVER/', $prompt['attributes']['sender']) ||
- substr($prompt['attributes']['version'],0,3) != 'XML' ) {
- return array(
- 'is_success' => false,
- 'error' => 'Unrecognized Peer'
- );
+ return $this->raiseError( OPENSRS_ERROR_CONNECTION_ERROR, $prompt['response_text'] );
+ }
+
+ if ( !preg_match('/OpenSRS\sSERVER/', $prompt['attributes']['sender']) || substr($prompt['attributes']['version'],0,3) != 'XML' ) {
+ return $this->raiseError( OPENSRS_ERROR_UNRECOGNIZED_PEER );
}
# first response is server version
@@ -638,57 +445,54 @@
'object' => 'version',
'attributes' => array(
'sender' => 'OpenSRS CLIENT',
- 'version' => $this->VERSION,
+ 'version' => 'XML:0.1',
'state' => 'ready'
)
);
- $this->send_data( $cmd );
+ $this->_send_data( $cmd );
$cmd = array(
'action' => 'authenticate',
'object' => 'user',
'attributes' => array(
- 'crypt_type' => strtolower($this->crypt_type),
+ 'crypt_type' => strtolower($this->cipher),
'username' => $username,
'password' => $username
)
);
- $this->send_data( $cmd );
+ $this->_send_data( $cmd );
- $challenge = $this->read_data( array('no_xml'=>true,'binary'=>true) );
+ $challenge = $this->_read_data( array( 'no_xml' => true, 'binary' => true ) );
# Respond to the challenge with the MD5 checksum of the challenge.
- # note the use of the no_xml => 1 set, because challenges are
+ # note the use of no_xml => true, because challenges are
# are sent without XML
# ... and PHP's md5() doesn't return binary data, so
# we need to pack that too
- $this->_CBC = new Crypt_CBC(pack('H*', $private_key), $this->crypt_type );
+ $this->_CBC = new Crypt_CBC( pack( 'H*', $private_key), $this->cipher );
- $response = pack('H*',md5($challenge));
+ $response = pack( 'H*', md5($challenge) );
- $this->send_data( $response, array('no_xml'=>true,'binary'=>true) );
+ $this->_send_data( $response, array( 'no_xml' => true, 'binary' => true ) );
# Read the server's response to our login attempt (XML)
- $answer = $this->read_data();
+ $answer = $this->_read_data();
if (substr($answer['response_code'],0,1)== '2') {
$this->_authenticated = true;
return array('is_success' => true);
} else {
- return array(
- 'is_success' => false,
- 'error' => 'Authentication failed'
- );
+ return $this->raiseError( OPENSRS_ERROR_AUTHENTICATION_FAILED );
}
}
#
-# lookup_domain()
+# _lookup_domain()
# Special case for domain lookups
#
#
@@ -709,7 +513,7 @@
#
- function lookup_domain($lookupData) {
+ function _lookup_domain($lookupData) {
$domain = strtolower($lookupData['attributes']['domain']);
$affiliate_id = $lookupData['attributes']['affiliate_id'];
@@ -771,8 +575,8 @@
# send request to server
- $this->send_data( $lookupData );
- $answer = $this->read_data( );
+ $this->_send_data( $lookupData );
+ $answer = $this->_read_data( );
if ( $answer['attributes']['status'] &&
stristr($answer['attributes']['status'],'available') &&
@@ -802,11 +606,11 @@
#
-# close_socket()
+# _close_socket()
# Close the socket connection
#
- function close_socket() {
+ function _close_socket() {
fclose($this->_socket);
if ($this->_CBC) {
$this->_CBC->_Crypt_CBC(); /* destructor */
@@ -814,16 +618,16 @@
$this->_CBC = false;
$this->_authenticated = false;
$this->_socket = false;
- $this->_log('i','Socket closed');
+ $this->_log('i', 'Socket closed');
}
#
-# read_data()
+# _read_data()
# Reads a response from the server
#
- function read_data($args=array()) {
+ function _read_data($args=array()) {
$buf = $this->_OPS->readData($this->_socket, $this->read_timeout);
@@ -852,7 +656,7 @@
# Sends request to the server
#
- function send_data($message, $args=array()) {
+ function _send_data($message, $args=array()) {
if (!$args['no_xml']) {
$message['protocol'] = $this->protocol;
@@ -883,20 +687,6 @@
}
-#
-# check_email_syntax()
-# Regex check for valid email
-#
-
- function check_email_syntax($email) {
- if ( preg_match('/(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/', $email) ||
- !preg_match('/^\S+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/', $email) ) {
- return false;
- } else {
- return true;
- }
- }
-
#
# check_domain_syntax()
@@ -928,11 +718,11 @@
#
-# prune_private_keys()
+# _prune_private_keys()
# Recursively remove keys that start with 'p_' from an array
#
- function prune_private_keys(&$data) {
+ function _prune_private_keys(&$data) {
if (is_array($data) || is_object($data)) {
foreach($data as $key=>$value) {
if (substr($key,0,2)=='p_') {
@@ -979,7 +769,7 @@
$temp = sprintf("[ %s%s ]\n",
strtoupper($types[$type]),
- (($type!='i' && $this->_CBC) ? ' - '.$this->crypt_type.' ENCRYPTED' : '')
+ (($type!='i' && $this->_CBC) ? ' - '.$this->cipher.' ENCRYPTED' : '')
);
ob_start();
|
|
From: Colin V. <cvi...@us...> - 2003-08-16 01:19:08
|
Update of /cvsroot/opensrs-php/opensrs-php
In directory sc8-pr-cvs1:/tmp/cvs-serv13432
Modified Files:
Tag: opensrs_php_2
CHANGELOG openSRS_base.php
Log Message:
version 2.7.3
Index: CHANGELOG
===================================================================
RCS file: /cvsroot/opensrs-php/opensrs-php/CHANGELOG,v
retrieving revision 1.23
retrieving revision 1.23.2.1
diff -u -r1.23 -r1.23.2.1
--- CHANGELOG 24 Jun 2003 19:24:38 -0000 1.23
+++ CHANGELOG 15 Aug 2003 16:02:52 -0000 1.23.2.1
@@ -3,6 +3,10 @@
Version x.x.x
xx-xxx-xxxx
+
+
+Version 2.7.3
+15-Aug-2003
- Updated README to reflect HRS functionality
- exposed HRS_port in the config file, since that port number
is different for each HRS customer (Jason Slaughter)
Index: openSRS_base.php
===================================================================
RCS file: /cvsroot/opensrs-php/opensrs-php/openSRS_base.php,v
retrieving revision 1.16
retrieving revision 1.16.2.1
diff -u -r1.16 -r1.16.2.1
--- openSRS_base.php 24 Jun 2003 19:24:38 -0000 1.16
+++ openSRS_base.php 15 Aug 2003 16:02:52 -0000 1.16.2.1
@@ -7,8 +7,8 @@
* Copyright (C) 2000, 2001, 2002, 2003 Colin Viebrock
* and easyDNS Technologies Inc.
*
- * Version 2.7.2
- * 18-Jun-2003
+ * Version 2.7.3
+ * 15-Aug-2003
*
**************************************************************************
*
@@ -61,7 +61,7 @@
var $VERSION = 'XML:0.1';
- var $base_class_version = '2.7.2';
+ var $base_class_version = '2.7.3';
var $environment = 'TEST'; /* 'TEST' or 'LIVE' or 'HRS' */
var $protocol = 'XCP'; /* 'XCP' or 'TPP' */
|
|
From: Colin V. <cvi...@us...> - 2003-08-16 00:21:04
|
Update of /cvsroot/opensrs-php/opensrs-php
In directory sc8-pr-cvs1:/tmp/cvs-serv10507
Modified Files:
OPS.php
Log Message:
starting rewrite of class
Index: OPS.php
===================================================================
RCS file: /cvsroot/opensrs-php/opensrs-php/OPS.php,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- OPS.php 18 Jun 2003 19:35:38 -0000 1.8
+++ OPS.php 15 Aug 2003 15:50:34 -0000 1.9
@@ -34,6 +34,18 @@
require_once 'PEAR.php';
+define ('OPS_OK', 1 );
+define ('OPS_ERROR', -1 );
+define ('OPS_ERROR_TIMEOUT', -2 );
+define ('OPS_ERROR_EOF', -3 );
+define ('OPS_ERROR_NO_DATA', -4 );
+define ('OPS_ERROR_SHORT_READ', -5 );
+define ('OPS_ERROR_UNEXPECTED', -6 );
+define ('OPS_ERROR_CANT_DECODE', -7 );
+define ('OPS_ERROR_CANT_ENCODE', -8 );
+define ('OPS_ERROR_NO_SOCKET', -9 );
+define ('OPS_ERROR_CANT_WRITE', -10 );
+
class OPS extends PEAR {
var $_OPS_VERSION = '0.9';
@@ -88,6 +100,38 @@
}
+ function raiseError($code, $info=NULL)
+ {
+ return PEAR::raiseError( $this->errorMessage($code), $code, NULL, NULL, $info );
+ }
+
+
+ function errorMessage($value)
+ {
+ static $errorMessages;
+ if (!isset($errorMessages)) {
+ $errorMessages = array(
+ OPS_OK => 'OK',
+ OPS_ERROR => 'unknown error',
+ OPS_ERROR_TIMEOUT => 'timeout reading',
+ OPS_ERROR_EOF => 'EOF reached',
+ OPS_ERROR_NO_DATA => 'no data read',
+ OPS_ERROR_SHORT_READ => 'short read',
+ OPS_ERROR_UNEXPECTED => 'unexpected data read',
+ OPS_ERROR_CANT_DECODE => 'can\'t decode data',
+ OPS_ERROR_CANT_ENCODE => 'can\'t encode data',
+ OPS_ERROR_NO_SOCKET => 'socket not active',
+ OPS_ERROR_CANT_WRITE => 'can\'t write to socket',
+ );
+ }
+
+ if (PEAR::isError($value)) {
+ $value = $value->getCode();
+ }
+
+ return isset($errorMessages[$value]) ? $errorMessages[$value] : $errorMessages[OPS_ERROR];
+
+ }
/**
@@ -102,10 +146,18 @@
function writeData(&$fh,$msg)
{
$len = strlen($msg);
- fputs($fh, 'Content-Length: ' . $len . $this->CRLF . $this->CRLF);
- fputs($fh, $msg, $len );
+
+ if (!fputs($fh, 'Content-Length: ' . $len . $this->CRLF . $this->CRLF) ) {
+ return $this->raiseError( OPS_ERROR_CANT_WRITE );
+ }
+ if (!fputs($fh, $msg, $len ) ) {
+ return $this->raiseError( OPS_ERROR_CANT_WRITE );
+ }
$this->_log('raw', 'w', $msg, $len);
+
+ return OPS_OK;
+
}
@@ -116,12 +168,19 @@
*
* @param string message to encode and write
*
+ * @return mixed OK, or an error
+ *
*/
function writeMessage(&$fh, $hr )
{
$msg = $this->encode( $hr );
- $this->writeData($fh, $msg );
+ if (PEAR::isError($msg)) {
+ return $msg;
+ }
+
+ return $this->writeData($fh, $msg );
+
}
@@ -132,7 +191,7 @@
*
* @param int timeout for read
*
- * @return mixed buffer with data, or an error for a short read
+ * @return mixed buffer with data, or an error
*
*/
@@ -145,9 +204,10 @@
socket_set_timeout($fh, $timeout);
$line = fgets($fh, 4000);
+ $test = $this->socketStatus($fh);
- if ($this->socketStatus($fh)) {
- return false;
+ if (PEAR::isError($test)) {
+ return $test;
}
if (!$len && preg_match('/^\s*Content-Length:\s+(\d+)\s*\r\n/i', $line, $matches ) ) {
@@ -155,40 +215,46 @@
} else {
$this->_log('raw', 'e', 'UNEXPECTED READ: No Content-Length' );
$this->_log('raw', 'r', $line);
- return false;
+ return $this->raiseError( OPS_ERROR_UNEXPECTED, 'No content-length' );
}
/* read the empty line */
$line = fread($fh, 2);
- if ($this->socketStatus($fh)) {
- return false;
+ $test = $this->socketStatus($fh);
+ if (PEAR::isError($test)) {
+ return $test;
}
if ($line!=$this->CRLF) {
$this->_log('raw', 'e', 'UNEXPECTED READ: No CRLF');
$this->_log('raw', 'r', $line);
- return false;
+ return $this->raiseError( OPS_ERROR_UNEXPECTED, 'No CRLF' );
}
$line = '';
while (strlen($line) < $len) {
$line .= fread($fh, $len);
- if ($this->socketStatus($fh)) {
- return false;
+ $test = $this->socketStatus($fh);
+ if (PEAR::isError($test)) {
+ return $test;
}
}
- if ($line) {
- $buf = $line;
- $this->_log('raw', 'r', $line);
- } else {
- $buf = false;
- $this->_log('raw', 'e', 'NEXT LINE SHORT READ (should be '.$len.')' );
+ if ($line=='') {
+ $this->_log('raw', 'e', 'NO DATA READ' );
+ return $this->raiseError( OPS_ERROR_NO_DATA );
+ }
+
+ if (strlen($line) != $len ) {
+ $this->_log('raw', 'e', 'NEXT LINE SHORT READ (expecting '.$len.', read ' . strlen($line) . ')' );
$this->_log('raw', 'r', $line);
+ return $this->raiseError( OPS_ERROR_SHORT_READ );
}
- return $buf;
+ $this->_log('raw', 'r', $line);
+ return $line;
+
}
@@ -205,7 +271,10 @@
function readMessage(&$fh, $timeout=5)
{
$buf = $this->readData($fh, $timeout);
- return ( $buf ? $this->decode($buf) : false );
+ if (PEAR::isError($buf)) {
+ return $buf;
+ }
+ return $this->decode($buf);
}
@@ -215,52 +284,35 @@
*
* @param int socket handle
*
- * @return boolean true if the socket has timed out or is EOF
+ * @return mixed true if the socket is ok, error otherwise
*
*/
function socketStatus(&$fh)
{
- $return = false;
- if (is_resource($fh)) {
- $temp = socket_get_status($fh);
- if ($temp['timed_out']) {
- $this->_log('raw', 'e', 'SOCKET TIMED OUT');
- $return = true;
- }
- if ($temp['eof']) {
- $this->_log('raw', 'e', 'SOCKET EOF');
- $return = true;
- }
- unset($temp);
+ if (!is_resource($fh)) {
+ return $this->raiseError( OPS_ERROR_NO_SOCKET );
}
- return $return;
- }
+ $temp = socket_get_status($fh);
+ if ($temp['timed_out']) {
+ $this->_log('raw', 'e', 'SOCKET TIMED OUT');
+ return $this->raiseError( OPS_ERROR_TIMEOUT );
+ }
- /**
- * Internal method to generate error codes hashes
- *
- * @param int error code
- *
- * @param string error message
- *
- * @return array error hash
- *
- */
+ if ($temp['eof']) {
+ $this->_log('raw', 'e', 'SOCKET EOF');
+ return $this->raiseError( OPS_ERROR_EOF );
+ }
+
+ return OPS_OK;
- function _opsError($err_code,$err_text)
- {
- return array(
- 'response_code' => $err_code,
- 'response_text' => $err_text,
- 'is_success' => 0
- );
}
+
#
# DECODING METHODS
# Converts XML OPS messages into PHP data
@@ -285,10 +337,10 @@
/* determine if we were passed a string or file handle */
if (is_resource($in)) {
- # read the file into a string, then process as usual
- while (!feof($in)) {
- $ops_msg .= fgets($in, 400);
- }
+ /* read the file into a string, then process as usual */
+ while (!feof($in)) {
+ $ops_msg .= fgets($in, 400);
+ }
} else {
$ops_msg = $in;
}
@@ -331,7 +383,7 @@
xml_get_current_line_number($xp)
);
xml_parser_free($xp);
- return $this->raiseError($error);
+ return $this->raiseError( OPS_ERROR_CANT_DECODE, $error );
}
xml_parser_free($xp);
@@ -585,14 +637,14 @@
function _is_assoc(&$array)
{
- if (is_array($array)) {
- foreach ($array as $k=>$v) {
- if (!is_int($k)) {
- return true;
- }
- }
- }
- return false;
+ if (is_array($array)) {
+ foreach ($array as $k=>$v) {
+ if (!is_int($k)) {
+ return true;
+ }
+ }
+ }
+ return false;
}
|
|
From: Colin V. <cvi...@us...> - 2003-06-25 20:31:28
|
Update of /cvsroot/opensrs-php/frontend In directory sc8-pr-cvs1:/tmp/cvs-serv12557 Log Message: module for frontend development Status: Vendor Tag: easydns Release Tags: init N frontend/README No conflicts created by this import ***** Bogus filespec: - ***** Bogus filespec: Imported ***** Bogus filespec: sources |
|
From: Colin V. <cvi...@us...> - 2003-06-25 20:30:04
|
Update of /cvsroot/opensrs-php/frontend In directory sc8-pr-cvs1:/tmp/cvs-serv12256 Log Message: module for frontend development Status: Vendor Tag: easydns Release Tags: init No conflicts created by this import ***** Bogus filespec: - ***** Bogus filespec: Imported ***** Bogus filespec: sources |
|
From: Colin V. <cvi...@us...> - 2003-06-24 19:24:41
|
Update of /cvsroot/opensrs-php/opensrs-php In directory sc8-pr-cvs1:/tmp/cvs-serv23933 Modified Files: CHANGELOG openSRS.php.default openSRS_base.php Log Message: exposed HRS_port in the config file, since that port number is different for each HRS customer (Jason Slaughter) Index: CHANGELOG =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/CHANGELOG,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- CHANGELOG 19 Jun 2003 19:17:28 -0000 1.22 +++ CHANGELOG 24 Jun 2003 19:24:38 -0000 1.23 @@ -4,22 +4,23 @@ Version x.x.x xx-xxx-xxxx - Updated README to reflect HRS functionality - - ??? + - exposed HRS_port in the config file, since that port number + is different for each HRS customer (Jason Slaughter) Version 2.7.2 18-Jun-2003 - add new environment 'HRS' and related class properties for - people using the OpenHRS system. - - added ability to define protocol in class constructor. + people using the OpenHRS system + - added ability to define protocol in class constructor - added more info to logging to show chosen environment, chosen - protocol, and server/port connected to. + protocol, and server/port connected to Version 2.7.1 16-Jun-2003 - bug fix in OPS->readData(), where it sometimes did not read - all of the available data. Thanks to Pat Ekman for this. + all of the available data (Pat Ekman) Version 2.7 @@ -35,8 +36,8 @@ Version 2.6.1 03-Jan-2003 - - patch from Jim Cottrell to set private key when environment - is explicitly set + - patch to set private key when environment is explicitly + set (Jim Cottrell) - fix bug that was causing read errors in PHP 4.3.0, due to change in behaviour of fgets() Index: openSRS.php.default =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/openSRS.php.default,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- openSRS.php.default 18 Jun 2003 19:35:38 -0000 1.6 +++ openSRS.php.default 24 Jun 2003 19:24:38 -0000 1.7 @@ -53,6 +53,7 @@ var $LIVE_PRIVATE_KEY = 'abcdef1234567890'; var $HRS_host = 'yourOpenHRSname.opensrs.net'; + var $HRS_port = 54321; var $HRS_USERNAME = 'yourOpenHRSname'; var $HRS_PRIVATE_KEY = 'abcdef1234567890'; Index: openSRS_base.php =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/openSRS_base.php,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- openSRS_base.php 18 Jun 2003 19:47:32 -0000 1.15 +++ openSRS_base.php 24 Jun 2003 19:24:38 -0000 1.16 @@ -70,8 +70,8 @@ var $LIVE_port = 55000; var $TEST_host = 'horizon.opensrs.net'; var $TEST_port = 55000; - var $HRS_host = 'horizon.opensrs.net'; - var $HRS_port = 53000; + var $HRS_host; + var $HRS_port; var $REMOTE_HOST; var $REMOTE_PORT; |
|
From: Colin V. <cvi...@us...> - 2003-06-19 19:17:31
|
Update of /cvsroot/opensrs-php/opensrs-php In directory sc8-pr-cvs1:/tmp/cvs-serv2521 Modified Files: CHANGELOG Log Message: update instructions for HRS functions Index: CHANGELOG =================================================================== RCS file: /cvsroot/opensrs-php/opensrs-php/CHANGELOG,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- CHANGELOG 18 Jun 2003 19:53:22 -0000 1.21 +++ CHANGELOG 19 Jun 2003 19:17:28 -0000 1.22 @@ -3,6 +3,7 @@ Version x.x.x xx-xxx-xxxx + - Updated README to reflect HRS functionality - ??? |