From db2c557438e393f9c378ed32cec7caba8d4b76f8 Mon Sep 17 00:00:00 2001
From: Nigel Kukard <nkukard@lbsd.net>
Date: Thu, 15 May 2014 17:10:43 +0000
Subject: [PATCH] Code cleanup

Change-Id: Icdbba876fa0ab6e08a189fd7a4cae7244b1a1c43
---
 modules/addons/awit_cozaepp/awit_cozaepp.php |  67 +++++----
 modules/registrars/cozaepp/cozaepp.php       | 145 +++++++++----------
 modules/registrars/cozaepp/cozaepppoll.php   |  26 ++--
 3 files changed, 121 insertions(+), 117 deletions(-)

diff --git a/modules/addons/awit_cozaepp/awit_cozaepp.php b/modules/addons/awit_cozaepp/awit_cozaepp.php
index 86e74a6..bf848e6 100644
--- a/modules/addons/awit_cozaepp/awit_cozaepp.php
+++ b/modules/addons/awit_cozaepp/awit_cozaepp.php
@@ -24,7 +24,7 @@ if (!defined("WHMCS"))
 
 // Our global supported field list
 $AWIT_COZAEPP_SUPPORTED_FIELDS = array(
-    "max_items"
+	"max_items"
 );
 
 // Addon configuration
@@ -118,7 +118,7 @@ function awit_cozaepp_deactivate()
 		DROP TABLE `mod_awit_cozaepp_messages`
 	");
 
-	if (!($result)) {
+	if (!$result) {
 		return array("status"=>"error","description"=>"There was an error deactivating the module.");
 	} else {
 		return array("status"=>"success","description"=>"Module has been deactivated.");
@@ -162,25 +162,27 @@ function awit_cozaepp_output($vars)
 	$link = $vars['modulelink'];
 
 	// Fancy date picker
-	echo '<script>
-		$(function() {
-			$( "#date_from" ).datepicker({
-				dateFormat: "yy-mm-dd",
-				constrainInput: true
-			});
-			$( "#date_to" ).datepicker({
-				dateFormat: "yy-mm-dd",
-				constrainInput: true
+	echo '
+		<script>
+			$(function() {
+				$( "#date_from" ).datepicker({
+					dateFormat: "yy-mm-dd",
+					constrainInput: true
+				});
+				$( "#date_to" ).datepicker({
+					dateFormat: "yy-mm-dd",
+					constrainInput: true
+				});
 			});
-		});
-	      </script>';
+		</script>
+	';
 
 	// Date search fields
 	echo "<p>Select a start and end date and hit search.</p>";
 	echo "<form action='$link' method='post'>";
 	echo "<input id='date_from' type='text' value='$dateFrom' name='date_from' />";
 	echo "<input id='date_to' type='text' value='$dateTo' name='date_to' />";
-	echo "<input type='submit' name='button'  value='Search' />";
+	echo "<input type='submit' name='button' value='Search' />";
 	echo "<input type='submit' name='button' value='Display All' />";
 	echo "<br /><br />";
 
@@ -221,14 +223,15 @@ function awit_cozaepp_output($vars)
 
 	// Query the database, getting the total amount of records
 	$result = mysql_query(sprintf("
-					SELECT
-						COUNT(*) AS cnt
-					FROM
-						mod_awit_cozaepp_messages
-					%s %s",
-					$whereClause,
-					$orderClause
-				));
+			SELECT
+				COUNT(*) AS cnt
+			FROM
+				mod_awit_cozaepp_messages
+			%s %s
+		",
+		$whereClause,
+		$orderClause
+	));
 
 	$row = mysql_fetch_array($result);
 	$totalRecords = $row['cnt'];
@@ -236,15 +239,16 @@ function awit_cozaepp_output($vars)
 
 	// Query the database
 	$result = mysql_query(sprintf("
-					SELECT
-						*
-					FROM
-						mod_awit_cozaepp_messages
-					%s %s %s",
-					$whereClause,
-					$orderClause,
-					$limitClause
-				));
+			SELECT
+				*
+			FROM
+				mod_awit_cozaepp_messages
+			%s %s %s
+		",
+		$whereClause,
+		$orderClause,
+		$limitClause
+	));
 
 	// Loop through results and genenrate form
 	$includeForm = 0;
@@ -268,7 +272,6 @@ function awit_cozaepp_output($vars)
 		echo "<td>".$row['message']."</td>";
 		echo "</tr>";
 	}
-	unset($result);
 
 	// Close form
 	if ($includeForm) {
diff --git a/modules/registrars/cozaepp/cozaepp.php b/modules/registrars/cozaepp/cozaepp.php
index 56cdbf2..867d160 100644
--- a/modules/registrars/cozaepp/cozaepp.php
+++ b/modules/registrars/cozaepp/cozaepp.php
@@ -51,13 +51,13 @@ function cozaepp_getConfigArray() {
 }
 
 function cozaepp_AdminCustomButtonArray() {
-  $buttonarray = array(
-      "Approve Transfer" => "ApproveTransfer",
-      "Cancel Transfer Request" => "CancelTransferRequest",
-      "Reject Transfer" => "RejectTransfer",
-      "Recreate Contact" => "RecreateContact",
-      );
-  return $buttonarray;
+	$buttonarray = array(
+		"Approve Transfer" => "ApproveTransfer",
+		"Cancel Transfer Request" => "CancelTransferRequest",
+		"Reject Transfer" => "RejectTransfer",
+		"Recreate Contact" => "RecreateContact",
+	);
+	return $buttonarray;
 }
 
 # Function to return current nameservers
@@ -866,7 +866,7 @@ function cozaepp_SaveContactDetails($params) {
 	# Registrant details
 	$registrant_name = $params["contactdetails"]["Registrant"]["Contact Name"];
 	$registrant_org = $params["contactdetails"]["Registrant"]["Organisation"];
-	$registrant_address1 =  $params["contactdetails"]["Registrant"]["Address line 1"];
+	$registrant_address1 = $params["contactdetails"]["Registrant"]["Address line 1"];
 	$registrant_address2 = $params["contactdetails"]["Registrant"]["Address line 2"];
 	$registrant_town = $params["contactdetails"]["Registrant"]["TownCity"];
 	$registrant_state = $params["contactdetails"]["Registrant"]["State"];
@@ -1065,21 +1065,21 @@ function cozaepp_ModifyNameserver($params) {
 		# Modify nameserver
 		$request = $client->request($xml = '
 <epp:epp xmlns:epp="urn:ietf:params:xml:ns:epp-1.0" xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
-  <epp:command>
-    <epp:update>
-      <domain:update>
-		<domain:name>'.$sld.'.'.$tld.'</domain:name>
-        <domain:add>
-          <domain:ns>
-            <domain:hostAttr>
-              <domain:hostName>'.$nameserver.'</domain:hostName>
-              <domain:hostAddr ip="v4">'.$newipaddress.'</domain:hostAddr>
-            </domain:hostAttr>
-          </domain:ns>
-        </domain:add>
-      </domain:update>
-    </epp:update>
-  </epp:command>
+	<epp:command>
+		<epp:update>
+			<domain:update>
+				<domain:name>'.$sld.'.'.$tld.'</domain:name>
+				<domain:add>
+					<domain:ns>
+						<domain:hostAttr>
+							<domain:hostName>'.$nameserver.'</domain:hostName>
+							<domain:hostAddr ip="v4">'.$newipaddress.'</domain:hostAddr>
+						</domain:hostAttr>
+					</domain:ns>
+				</domain:add>
+			</domain:update>
+		</epp:update>
+	</epp:command>
 </epp:epp>
 ');
 		# Parse XML result
@@ -1122,26 +1122,26 @@ function cozaepp_DeleteNameserver($params) {
 	try {
 		$client = _cozaepp_Client();
 
-		# If we were given   hostname.  blow away all of the stuff behind it and allow us to remove hostname
+		# If we were given hostname. blow away all of the stuff behind it and allow us to remove hostname
 		$nameserver = preg_replace('/\.\.\S+/','',$nameserver);
 
 		# Delete nameserver
 		$request = $client->request($xml = '
 <epp:epp xmlns:epp="urn:ietf:params:xml:ns:epp-1.0" xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
-  <epp:command>
-    <epp:update>
-      <domain:update>
-		<domain:name>'.$sld.'.'.$tld.'</domain:name>
-        <domain:rem>
-          <domain:ns>
-            <domain:hostAttr>
-              <domain:hostName>'.$nameserver.'</domain:hostName>
-            </domain:hostAttr>
-          </domain:ns>
-        </domain:rem>
-      </domain:update>
-    </epp:update>
-  </epp:command>
+	<epp:command>
+		<epp:update>
+			<domain:update>
+				<domain:name>'.$sld.'.'.$tld.'</domain:name>
+				<domain:rem>
+					<domain:ns>
+						<domain:hostAttr>
+							<domain:hostName>'.$nameserver.'</domain:hostName>
+						</domain:hostAttr>
+					</domain:ns>
+				</domain:rem>
+			</domain:update>
+		</epp:update>
+	</epp:command>
 </epp:epp>
 ');
 		# Parse XML result
@@ -1366,31 +1366,31 @@ function cozaepp_RecreateContact($params) {
 		$request = $client->request($xml = '
 <epp:epp xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:epp="urn:ietf:params:xml:ns:epp-1.0"
 		xmlns:contact="urn:ietf:params:xml:ns:contact-1.0" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
-  <epp:command>
-    <epp:create>
-      <contact:create xsi:schemaLocation="urn:ietf:params:xml:ns:contact-1.0 contact-1.0.xsd">
-		<contact:id>'.$registrant.'</contact:id>
-		<contact:postalInfo type="loc">
-		<contact:name>'.$contact["Registrant"]["Contact Name"].'</contact:name>
-		<contact:org>'.$contact["Registrant"]["Organisation"].'</contact:org>
-		<contact:addr>
-			<contact:street>'.$contact["Registrant"]["Address line 1"].'</contact:street>
-			<contact:street>'.$contact["Registrant"]["Address line 2"].'</contact:street>
-			<contact:city>'.$contact["Registrant"]["TownCity"].'</contact:city>
-			<contact:sp>'.$contact["Registrant"]["State"].'</contact:sp>
-			<contact:pc>'.$contact["Registrant"]["Zip code"].'</contact:pc>
-			<contact:cc>'.$contact["Registrant"]["Country Code"].'</contact:cc>
-		</contact:addr>
-		</contact:postalInfo>
-		<contact:voice>'.$contact["Registrant"]["Phone"].'</contact:voice>
-		<contact:fax></contact:fax>
-		<contact:email>'.$contact["Registrant"]["Email"].'</contact:email>
-		<contact:authInfo>
-			<contact:pw>AxA8AjXbAH'.rand().rand().'</contact:pw>
-		</contact:authInfo>
-      </contact:create>
-    </epp:create>
-  </epp:command>
+	<epp:command>
+		<epp:create>
+			<contact:create xsi:schemaLocation="urn:ietf:params:xml:ns:contact-1.0 contact-1.0.xsd">
+				<contact:id>'.$registrant.'</contact:id>
+				<contact:postalInfo type="loc">
+				<contact:name>'.$contact["Registrant"]["Contact Name"].'</contact:name>
+				<contact:org>'.$contact["Registrant"]["Organisation"].'</contact:org>
+				<contact:addr>
+					<contact:street>'.$contact["Registrant"]["Address line 1"].'</contact:street>
+					<contact:street>'.$contact["Registrant"]["Address line 2"].'</contact:street>
+					<contact:city>'.$contact["Registrant"]["TownCity"].'</contact:city>
+					<contact:sp>'.$contact["Registrant"]["State"].'</contact:sp>
+					<contact:pc>'.$contact["Registrant"]["Zip code"].'</contact:pc>
+					<contact:cc>'.$contact["Registrant"]["Country Code"].'</contact:cc>
+				</contact:addr>
+				</contact:postalInfo>
+				<contact:voice>'.$contact["Registrant"]["Phone"].'</contact:voice>
+				<contact:fax></contact:fax>
+				<contact:email>'.$contact["Registrant"]["Email"].'</contact:email>
+				<contact:authInfo>
+					<contact:pw>AxA8AjXbAH'.rand().rand().'</contact:pw>
+				</contact:authInfo>
+			</contact:create>
+		</epp:create>
+	</epp:command>
 </epp:epp>
 ');
 
@@ -1494,8 +1494,8 @@ function cozaepp_Sync($params) {
 		} else if ($coderes == '1000') {
 			# Code 1000, success
 			if (
-				$doc->getElementsByTagName('infData') && 
-				$doc->getElementsByTagName('infData')->item(0)->getElementsByTagName('ns')->item(0) && 
+				$doc->getElementsByTagName('infData') &&
+				$doc->getElementsByTagName('infData')->item(0)->getElementsByTagName('ns')->item(0) &&
 				$doc->getElementsByTagName('infData')->item(0)->getElementsByTagName('clID')
 			) {
 				$owningRegistrar = $doc->getElementsByTagName('infData')->item(0)->getElementsByTagName('clID')->item(0)->nodeValue;
@@ -1602,13 +1602,13 @@ function cozaepp_ApproveTransfer($params) {
 		# Grab domain info
 		$request = $client->request($xml = '
 <epp:epp xmlns:epp="urn:ietf:params:xml:ns:epp-1.0" xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
-  <epp:command>
-    <epp:transfer op="approve">
-      <domain:transfer>
-        <domain:name>'.$sld.'.'.$tld.'</domain:name>
-      </domain:transfer>
-    </epp:transfer>
-  </epp:command>
+	<epp:command>
+		<epp:transfer op="approve">
+			<domain:transfer>
+				<domain:name>'.$sld.'.'.$tld.'</domain:name>
+			</domain:transfer>
+		</epp:transfer>
+	</epp:command>
 </epp:epp>
 ');
 
@@ -1728,4 +1728,3 @@ function cozaepp_RejectTransfer($params) {
 	return $values;
 }
 
-?>
diff --git a/modules/registrars/cozaepp/cozaepppoll.php b/modules/registrars/cozaepp/cozaepppoll.php
index 3663a22..498b5ae 100644
--- a/modules/registrars/cozaepp/cozaepppoll.php
+++ b/modules/registrars/cozaepp/cozaepppoll.php
@@ -95,17 +95,19 @@ try {
 					if (!in_array(trim($msgs->item($m)->textContent), $ignored)) {
 						$message = mysql_real_escape_string(trim($msgs->item($m)->textContent));
 						$result = mysql_query("
-									INSERT INTO mod_awit_cozaepp_messages (
-												created,
-												code,
-												message
-											)
-											VALUES (
-												Now(),
-												'$coderes',
-												'$message'
-											);
-								");
+							INSERT INTO mod_awit_cozaepp_messages
+								(
+									created,
+									code,
+									message
+								)
+							VALUES
+								(
+									now(),
+									'$coderes',
+									'$message'
+								)
+						");
 						if (mysql_error($result)) {
 							echo "ERROR: couldn't log epp message: " . mysql_error($result);
 						}
@@ -144,4 +146,4 @@ try {
 	echo("ERROR: ".$e->getMessage(). "\n");
 	exit;
 }
-?>
+
-- 
GitLab