From c3dc2f5dd1264cf33fe396a92bb4f0f85e5cb3a1 Mon Sep 17 00:00:00 2001
From: Nigel Kukard <nkukard@lbsd.net>
Date: Wed, 12 Sep 2012 21:35:37 +0000
Subject: [PATCH] Fixed bug with SSL setting & include path

---
 modules/registrars/cozaepp/cozaepp.php | 30 +++++++++++++++-----------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/modules/registrars/cozaepp/cozaepp.php b/modules/registrars/cozaepp/cozaepp.php
index 5d8d496..3b66aa9 100644
--- a/modules/registrars/cozaepp/cozaepp.php
+++ b/modules/registrars/cozaepp/cozaepp.php
@@ -36,8 +36,6 @@
 # http://allworldit.com
 
 
-## VERSION: 0.1.0 ##
-
 
 # Configuration array
 function cozaepp_getConfigArray() {
@@ -788,28 +786,34 @@ function cozaepp_DeleteNameserver($params) {
 function _cozaepp_Client() {
 	# Setup include dir
 	$include_path = ROOTDIR . '/modules/registrars/cozaepp';
-	set_include_path(get_include_path() . PATH_SEPARATOR . $include_path);
-	include_once 'Net/EPP/Client.php';
-	include_once 'Net/EPP/Protocol.php';
+	set_include_path($include_path . PATH_SEPARATOR . get_include_path());
+	require_once 'Net/EPP/Client.php';
+	require_once 'Net/EPP/Protocol.php';
 
 
 	# Grab module parameters
 	$params = getregistrarconfigoptions('cozaepp');
 
-	# Create EPP client
-	$client = new Net_EPP_Client();
-
-	# Set certificate if we have one
+	# Are we using ssl?
 	$use_ssl = false;
-	if (isset($params['SSL']) && $params['SSL'] == "on"  && isset($params['Certificate']) && file_exists($params['Certificate'])) {
+	if (isset($params['SSL']) && $params['SSL'] == 'on') {
+		$use_ssl = true;
+	}
+	# Set certificate if we have one
+ 	if ($use_ssl && isset($params['Certificate']) && file_exists($params['Certificate'])) {
 		# Create SSL context
 		$context = stream_context_create();
 		stream_context_set_option($context, 'ssl', 'local_cert', $params['Certificate']);
-		$use_ssl = true;
 	}
 
+	# Create EPP client
+	$client = new Net_EPP_Client();
 	# Connect
-	$client->connect($params['Server'], $params['Port'], 50, $use_ssl, $context);
+	$res = $client->connect($params['Server'], $params['Port'], 30, $use_ssl, $context);
+	# Check for error
+	if (PEAR::isError($res)) {
+		return $res;
+	}
 
 	# Perform login
 	$result = $client->request('
@@ -835,4 +839,6 @@ function _cozaepp_Client() {
 	return $client;
 }
 
+
+
 ?>
-- 
GitLab