Index: trunk/lib/PayPal.inc.php
===================================================================
--- trunk/lib/PayPal.inc.php	(revision 20)
+++ trunk/lib/PayPal.inc.php	(revision 42)
@@ -1,5 +1,5 @@
 <?php
 /**
- * The PayPal:: class provides functions for creating PayPal buttons and for 
+ * The PayPal:: class provides functions for creating PayPal buttons and for
  * receiving PayPal's Instant Payment Notification (IPN) service.
  *
@@ -8,5 +8,5 @@
  */
 class PayPal {
-    
+
     // General object parameters.
     var $_params = array(
@@ -14,14 +14,14 @@
         'test_mode' => false,
     );
-    
-    // Options used for specific buttons and links. 
+
+    // Options used for specific buttons and links.
     var $_default_button_options = array();
-    
+
     // Array of buttons created by newButton().
     var $_buttons = array();
-    
+
     // Store the response from the last IPN.
     var $_ipn_response;
-    
+
     /**
      * Constructor.
@@ -38,5 +38,5 @@
             $url = 'www.paypal.com';
         }
-        
+
         $this->_default_button_options = array(
             '_global' => array(
@@ -59,12 +59,12 @@
         );
     }
-    
-    /**
-     * Updates the _default_button_options array with options used for 
+
+    /**
+     * Updates the _default_button_options array with options used for
      * specific buttons, or all buttons if $type is null.
      *
      * @access  public
      *
-     * @param   mixed   $type       The type of button to set defaults. If null, 
+     * @param   mixed   $type       The type of button to set defaults. If null,
      *                              sets the global button types.
      * @param   array   $options    Options to set for button.
@@ -78,5 +78,5 @@
             return false;
         }
-        
+
         if (is_null($type) || '_global' == $type) {
             $this->_default_button_options['_global'] = array_merge($this->_default_button_options['_global'], $options);
@@ -85,9 +85,9 @@
             return false;
         }
-        
+
         $this->_default_button_options[$type] = array_merge($this->_default_button_options[$type], $options);
         return true;
     }
-    
+
     /**
      * Creates a new element in the _buttons array. Uses _default_button_options
@@ -108,14 +108,14 @@
             return false;
         }
-        
+
         if (!is_array($options) || empty($options)) {
             App::logMsg(sprintf('Invalid options: %s', getDump($options)), LOG_WARNING, __FILE__, __LINE__);
             return false;
         }
-        
+
         if (isset($this->_buttons[$name])) {
             App::logMsg(sprintf('Overwriting existing button name: %s', getDump($this->_buttons[$name])), LOG_DEBUG, __FILE__, __LINE__);
         }
-        
+
         $this->_buttons[$name] = array(
             'type' => $type,
@@ -141,5 +141,5 @@
             return false;
         }
-        
+
         $query_string = '';
         $delim = '';
@@ -156,5 +156,5 @@
         $search = array('/%2F/');
         $replace = array('/');
-        
+
         return $this->_buttons[$name]['options']['link_url'] . preg_replace($search, $replace, $query_string);
     }
@@ -183,5 +183,5 @@
         ?>
         <form action="<?php echo $this->_buttons[$name]['options']['button_url']; ?>" method="post">
-        <?php 
+        <?php
         if (is_array($this->_buttons[$name]['options']) && !empty($this->_buttons[$name]['options'])) {
             foreach ($this->_buttons[$name]['options'] as $key=>$val) {
@@ -192,5 +192,5 @@
                 }
             }
-        } 
+        }
         ?>
         <input type="image" src="<?php echo $this->_buttons[$name]['options']['submit_img']; ?>" border="0" name="submit" alt="<?php echo $this->_buttons[$name]['options']['submit_text']; ?>" />
@@ -241,5 +241,5 @@
     function incomingIPNRequest()
     {
-        if ($_SERVER['REQUEST_METHOD'] == 'POST' 
+        if ($_SERVER['REQUEST_METHOD'] == 'POST'
         && $_SERVER['CONTENT_TYPE'] == 'application/x-www-form-urlencoded'
         && !empty($_POST)) {
@@ -258,5 +258,5 @@
      */
     function processIPN()
-    {        
+    {
         if (getPost('test_ipn') == '1' || $this->getParam('test_mode')) {
             App::logMsg(sprintf('Processing PayPal IPN in test mode: %s', getDump(getFormData())), LOG_DEBUG, __FILE__, __LINE__);
@@ -266,5 +266,5 @@
             $url = parse_url($this->getParam('paypal_url'));
         }
-        
+
         // Read POST request and add 'cmd'.
         $received_data = getPost();
@@ -273,7 +273,7 @@
             $return_data .= '&' . $post_key . '=' . urlencode($post_val);
         }
-        
+
         // Set the port number based on the scheme.
-        if ($url['scheme'] == "https") { 
+        if ($url['scheme'] == "https") {
             $url['port'] = 443;
             $ssl = 'ssl://';
@@ -282,7 +282,7 @@
             $ssl = '';
         }
-            
+
         // Open connection to PayPal server.
-        $fp = fsockopen($ssl . $url['host'], $url['port'], $errnum, $errstr, 30); 
+        $fp = fsockopen($ssl . $url['host'], $url['port'], $errnum, $errstr, 30);
 
         if (!$fp) {
@@ -290,11 +290,11 @@
             return false;
         } else {
-            fputs($fp, "POST {$url['path']} HTTP/1.1\r\n"); 
-            fputs($fp, "Host: {$url['host']}\r\n"); 
-            fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n"); 
-            fputs($fp, "Content-length: " . strlen($return_data) . "\r\n"); 
-            fputs($fp, "Connection: close\r\n\r\n"); 
-            fputs($fp, $return_data . "\r\n\r\n"); 
-                            
+            fputs($fp, "POST {$url['path']} HTTP/1.1\r\n");
+            fputs($fp, "Host: {$url['host']}\r\n");
+            fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
+            fputs($fp, "Content-length: " . strlen($return_data) . "\r\n");
+            fputs($fp, "Connection: close\r\n\r\n");
+            fputs($fp, $return_data . "\r\n\r\n");
+
             // Loop through the response lines from the server.
             $this->_ipn_response = '';
@@ -303,10 +303,10 @@
             }
             fclose($fp);
-            
+
             App::logMsg(sprintf('IPN response received: %s', $this->_ipn_response), LOG_NOTICE, __FILE__, __LINE__);
             return true;
         }
     }
-    
+
     /**
      * Checks the response received from PayPal's IPN upon calling processIPN().
@@ -322,10 +322,10 @@
             return false;
         }
-        
+
         if (empty($this->_ipn_response)) {
             App::logMsg(sprintf('Cannot verify IPN, response empty.', null), LOG_WARNING, __FILE__, __LINE__);
             return false;
         }
-        
+
         if (preg_match('/VERIFIED/', $this->_ipn_response)) {
             App::logMsg(sprintf('IPN verified!', null), LOG_DEBUG, __FILE__, __LINE__);
@@ -339,6 +339,6 @@
         }
     }
-    
-    
+
+
 } // End of class.
 
