# This patch file was generated by NetBeans IDE
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
Index: contributions/modules/backup_migrate/includes/destinations.inc
--- contributions/modules/backup_migrate/includes/destinations.inc Base (1.1.2.1.2.18)
+++ contributions/modules/backup_migrate/includes/destinations.inc Locally Modified (Based On 1.1.2.1.2.18)
@@ -71,6 +71,13 @@
       'type_name' => t('FTP Directory'),
       'can_create' => TRUE,
     ),
+    'nirvanix' => array(
+      'description' => t('Save the backup files to Nirvanix storage delivery network.'),
+      'file' => drupal_get_path('module', 'backup_migrate') . '/includes/destinations.nirvanix.inc',
+      'class' => 'backup_migrate_destination_nirvanix',
+      'type_name' => t('Nirvanix storage delivery network'),
+      'can_create' => TRUE,
+    ),
     's3' => array(
       'description' => t('Save the backup files to a bucket on your !link.', array('!link' => l(t('Amazon S3 account'), 'http://aws.amazon.com/s3/'))),
       'file' => drupal_get_path('module', 'backup_migrate') .'/includes/destinations.s3.inc',
Index: contributions/modules/backup_migrate/includes/destinations.nirvanix.inc
--- contributions/modules/backup_migrate/includes/destinations.nirvanix.inc No Base Revision
+++ contributions/modules/backup_migrate/includes/destinations.nirvanix.inc Locally New
@@ -0,0 +1,180 @@
+<?php
+// $Id$
+
+/**
+ * A destination for sending database backups to an nirvanix server.
+ *
+ * @ingroup backup_migrate_destinations
+ */
+class backup_migrate_destination_nirvanix extends backup_migrate_destination_remote {
+  var $supported_ops = array('scheduled backup', 'manual backup', 'restore', 'list files', 'configure', 'delete');
+  var $imfs = NULL;
+  var $auth = NULL;
+  var $token;
+  var $username;
+  var $password;
+  var $appKey;
+
+  function  __destruct() {
+    $this->logout();
+  }
+
+  /**
+   * Save file to nirvanix server
+   */
+  function save_file($file, $settings) {
+    $this->token();
+    $this->imfs_object();
+
+    // Retrieve the upload node with the upload access token.
+    // this is passed on to the client so they can authenticate with an IP Address
+    // that is different from the servers that was used to login.
+    $uploadNode = $this->imfs->GetUploadNode($this->token);
+    // retrieve the accessToken
+    $accessToken = $uploadNode->GetUploadNode->AccessToken;
+    // get server to upload to
+    $upload_address  = $uploadNode->GetUploadNode->IPAddress;
+    $upload_address .= '/Upload.ashx';
+    
+    $ch = curl_init($upload_address);
+    curl_setopt($ch, CURLOPT_POSTFIELDS, array(
+      'uploadToken'    => $accessToken,
+      'destFolderPath' => $this->dest_url['path'],
+      'uploadFile1'    => "@{$file->path}",
+      'filename'       => $file->file_info['filename']
+    ));
+    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+    $postResult = curl_exec($ch);
+    curl_close($ch);
+
+    // update file name
+    $file->file_info['filename'] .= '.' . implode('.', $file->ext);
+
+    // update file path
+    $file->path = $this->dest_url;
+
+    return $file;
+  }
+
+  /**
+   * Load file from nirvanix destination
+   */
+  function load_file($file_id) {
+    $this->token();
+    $this->imfs_object();
+    
+    backup_migrate_include('files');
+    $file = new backup_file(array('filename' => $file_id));
+    $file->path = $this->dest_url['path'] . '/' . $file->file_info['filename'];
+    $file->path = $this->imfs->GetDownloadLinks($this->token, array($file->path), 1);
+
+    if ($file->path) {
+      drupal_goto((string)$file->path->Download->DownloadURL);
+    }
+
+    return FALSE;
+  }
+
+  function delete_file($file_id) {
+    $this->token();
+    $this->imfs_object();
+
+    backup_migrate_include('files');
+    $file = new backup_file(array('filename' => $file_id));
+    $file->path = $this->dest_url['path'] . '/' . $file->file_info['filename'];
+    $file->path = $this->imfs->GetDownloadLinks($this->token, array($file->path), 1);
+
+    if ($file->path) {
+      $file->path = (string)$file->path->Download->DownloadURL;
+      $this->imfs->DeleteFiles($this->token, array($file->path));
+    }
+
+    return FALSE;
+  }
+
+  /**
+   * List all files from nirvanix destination
+   */
+  function list_files() {
+    $files = array();
+    $this->token();
+    $this->imfs_object();
+    $path  = $this->dest_url['path'];
+    $limit = 500;
+    $page  = 1;
+    $xml   = $this->imfs->ListFolder($this->token, $path, $page, $limit, '', '');
+    if ($xml) {
+      backup_migrate_include('files');
+      $folder = &$xml->ListFolder;
+      $xml_files  = &$folder->File;
+      foreach ($xml_files as $file) {
+        $filetime = (string)$file->CreatedDate;
+        $filetime = strtotime($filetime);
+        $info = array(
+          'filename' => (string)$file->Name,
+          'filesize' => (string)$file->SizeBytes,
+          'filetime' => $filetime,
+        );
+
+        $files[$id] = new backup_file($info);
+      }
+    }
+
+    return $files;
+  }
+
+  /**
+   * Get the form for the settings for this filter.
+   */
+  function edit_form() {
+    $form = parent::edit_form();
+
+    $form['name']['#weight'] = -10;
+    
+    $form['scheme']['#type']  = 'textfield';
+    $form['scheme']['#title'] = t('Application key');
+    $form['scheme']['#default_value'] = $this->dest_url['scheme'];
+    unset($form['scheme']['#options']);
+
+    $form['host']['#type']  = 'value';
+    $form['host']['#value'] = 'services.nirvanix.com';
+    
+    $form['path']['#title'] = t('Remote directory');
+
+    return $form;
+  }
+
+  /**
+   * Helper to set IMFS object to $this->imfs property
+   */
+  function imfs_object() {
+    if (!$this->imfs) {
+      module_load_include('php', 'backup_migrate', 'includes/NirvanixAPI/IMFS');
+      $this->imfs = new IMFS();
+    }
+  }
+
+  /**
+   * Helper to set token to $this->token property
+   */
+  function token() {
+    if (!$this->token) {
+      global $AUTHHOST;
+      global $IMFSHOST;
+      $AUTHHOST = $IMFSHOST = 'http://services.nirvanix.com';
+      
+      module_load_include('php', 'backup_migrate', 'includes/NirvanixAPI/Authentication');
+      $this->auth  = new Authentication();
+      $this->token = $this->auth->Login($this->dest_url['user'], $this->dest_url['pass'], $this->dest_url['scheme']);
+    }
+  }
+
+  /**
+   * Clean up session
+   */
+  function logout() {
+    if ($this->token) {
+      $this->auth->Logout($this->token);
+    }
+  }
+}
Index: contributions/modules/backup_migrate/includes/NirvanixAPI/Authentication.php
--- contributions/modules/backup_migrate/includes/NirvanixAPI/Authentication.php No Base Revision
+++ contributions/modules/backup_migrate/includes/NirvanixAPI/Authentication.php Locally New
@@ -0,0 +1,66 @@
+<?php
+/****
+Author:  Nirvanix
+Date:    8-21-2007
+Website: http://developer.nirvanix.com/
+License: See http://developer.nirvanix.com/content/license.aspx
+        Limited Permissive License
+        This license governs use of the accompanying software. If you use the software, 
+        you accept this license. If you do not accept the license, do not use or distribute 
+        the software.
+****/
+
+require_once "RestUtils.php";
+
+// Simple Class for calling Nirvanix Authentication API Rest methods.
+class Authentication
+{
+    // Login - lets a parent or child user login to the system and returns a sessionToken 
+    // that can be used for account/imfs functions.
+    public function Login($username, $password, $appKey)
+    {
+        global $DEBUG;
+        global $AUTHHOST;
+
+        // set the parameters
+        $params = 'username=' . $username . '&';
+        $params = $params . 'password=' . $password . '&';
+        $params = $params . 'appKey=' . $appKey;
+        
+        // retrieve from the REST interface the response xml.
+        $xmlstring = curlGet($AUTHHOST . '/ws/Authentication/Login.ashx?' . $params);
+        
+        // turn into an object for easier handling.
+        $xml = new SimpleXMLElement($xmlstring);
+
+        // return string sessiontoken, you must cast it or it stores the node.
+        return (string)$xml->SessionToken; 
+    }
+    
+    // Logout invalidates a sessiontoken this should always be called when you are done with a 
+    // sessionToken for increased security.
+    public function Logout($sessionToken)
+    {
+        global $DEBUG;
+        global $AUTHHOST;
+        
+        // set the parameters
+        $params = 'sessionToken=' . $sessionToken;
+        
+        // retrieve from the REST interface the response xml.
+        $xmlstring = curlGet($AUTHHOST . '/ws/Authentication/Logout.ashx?' . $params);
+        
+        if ($DEBUG)
+        {
+            print '<!--Logout: ';
+            print_r($xmlstring);
+            print '-->';
+        }
+        
+        // turn into an object for easier handling
+        $xml = new SimpleXMLElement($xmlstring);
+        
+        return $xml; 
+    }
+}
+?>
\ No newline at end of file
Index: contributions/modules/backup_migrate/includes/NirvanixAPI/Config.php
--- contributions/modules/backup_migrate/includes/NirvanixAPI/Config.php No Base Revision
+++ contributions/modules/backup_migrate/includes/NirvanixAPI/Config.php Locally New
@@ -0,0 +1,8 @@
+<?php
+// If the Debug flag is set to true each call will output the xml results in an html 
+// comment.  You can view the source to take a look at the output.
+$DEBUG = true;
+// Namespace host names
+$AUTHHOST = 'https://services.nirvanix.com';
+$IMFSHOST = 'http://services.nirvanix.com';
+?>
\ No newline at end of file
Index: contributions/modules/backup_migrate/includes/NirvanixAPI/IMFS.php
--- contributions/modules/backup_migrate/includes/NirvanixAPI/IMFS.php No Base Revision
+++ contributions/modules/backup_migrate/includes/NirvanixAPI/IMFS.php Locally New
@@ -0,0 +1,381 @@
+<?php
+/****
+Author:  Nirvanix
+Date:    8-21-2007
+Website: http://developer.nirvanix.com/
+License: See http://developer.nirvanix.com/content/license.aspx
+        Limited Permissive License
+        This license governs use of the accompanying software. If you use the software, 
+        you accept this license. If you do not accept the license, do not use or distribute 
+        the software.
+****/
+
+require_once "RestUtils.php";
+require_once "Config.php";
+
+class IMFS
+{
+    //Copies one or more folders to a destination folder
+    public function CopyFiles($sessionToken, $srcFilePaths, $destFilePath)
+    {
+        global $DEBUG;
+        global $IMFSHOST;
+        
+        // Set the parameters
+        $filePathParams = 'sessionToken=' . $sessionToken . '&';
+        $filePathParams = $filePathParams. 'destFolderPath=' . $destFilePath . '&';
+        
+        // loop through each source file path building the arrray.
+        foreach ($srcFilePaths as $filePath)
+        {
+            $filePathParams = $filePathParams . 'srcFilePath=' . $filePath . '&';
+        }
+        
+        // retrieve from the REST interface the response xml.
+        $xmlstring = curlGet($IMFSHOST . '/ws/IMFS/copyfiles.ashx?' . $filePathParams);
+        
+        if ($DEBUG)
+        {
+            print '<!--CopyFiles: ';
+            print_r($xmlstring);
+            print '-->';
+        }
+        
+        // turn into an object for easier handling.
+        $xml = new SimpleXMLElement($xmlstring);
+        
+        return $xml; 
+    }
+    
+    //Copies one or more folders to a destination folder
+    public function CopyFolders($sessionToken, $srcFolderPaths, $destFolderPath)
+    {
+        global $DEBUG;
+        global $IMFSHOST;
+        
+        // set the parameters.
+        $folderPathParams = 'sessionToken=' . $sessionToken . '&';
+        $folderPathParams = $folderPathParams . 'destFolderPath=' . $destFolderPath . '&';
+
+        // loop through each source file path building the arrray.
+        foreach ($srcFolderPaths as $folderPath)
+        {
+            $folderPathParams = $folderPathParams . 'srcFolderPath=' . $folderPath . '&';
+        }
+        
+        // retrieve from the REST interface the response xml.
+        $xmlstring = curlGet($IMFSHOST . '/ws/IMFS/copyfolders.ashx?' . $folderPathParams);
+        
+        if ($DEBUG)
+        {
+            print '<!--CopyFolders: ';
+            print_r($xmlstring);
+            print '-->';
+        }
+        
+        // turn into an object for easier handling.
+        $xml = new SimpleXMLElement($xmlstring);
+        
+        return $xml; 
+    }
+
+    // Creates one or more folders
+    public function CreateFolders($sessionToken, $folderPaths)
+    {
+        global $DEBUG;
+        global $IMFSHOST;
+        
+        // Set the parameters
+        $folderPathParams = 'sessionToken=' . $sessionToken . '&';
+
+        // loop through each source file path building the arrray.
+        foreach ($folderPaths as $folderPath)
+        {
+            $folderPathParams = $folderPathParams . 'folderPath=' . $folderPath . '&';
+        }
+        
+        // retrieve from the REST interface the response xml.
+        $xmlstring = curlGet($IMFSHOST . '/ws/IMFS/createfolders.ashx?' . $folderPathParams);
+        
+        if ($DEBUG)
+        {
+            print '<!--CreateFolders: ';
+            print_r($xmlstring);
+            print '-->';
+        }
+        
+        // turn into an object for easier handling.
+        $xml = new SimpleXMLElement($xmlstring);
+        
+        return $xml;  
+    }
+
+    //Deletes one or more files
+    public function DeleteFiles($sessionToken, $filePaths)
+    {
+        global $DEBUG;
+        global $IMFSHOST;
+        
+
+        // Set the parameters
+        $params = 'sessionToken=' . $sessionToken . '&';
+
+        // loop through each source file path building the arrray.
+        foreach ($filePaths as $filePath)
+        {
+            $params = $params . 'filePath=' . $filePath . '&';
+        }
+        
+        // retrieve from the REST interface the response xml.
+        $xmlstring = curlGet($IMFSHOST . '/ws/IMFS/deletefiles.ashx?' . $params);
+        
+        if ($DEBUG)
+        {
+            print '<!--DeleteFiles: ';
+            print_r($xmlstring);
+            print '-->';
+        }
+        
+        // turn into an object for easier handling.
+        $xml = new SimpleXMLElement($xmlstring);
+        
+        return $xml;        
+    }
+
+    //Deletes one or more folders
+    public function DeleteFolders($sessionToken, $folderPaths)
+    {
+        global $DEBUG;
+        global $IMFSHOST;
+        
+        // Set the parameters
+        $folderPathParams = 'sessionToken=' . $sessionToken . '&';
+
+        // loop through each source file path building the arrray.
+        foreach ($folderPaths as $folderPath)
+        {
+            $folderPathParams = $folderPathParams . 'folderPath=' . $folderPath . '&';
+        }
+        
+        // retrieve from the REST interface the response xml.
+        $xmlstring = curlGet($IMFSHOST . '/ws/IMFS/deletefolders.ashx?' . $folderPathParams);
+        
+        if ($DEBUG)
+        {
+            print '<!--DeleteFolders: ';
+            print_r($xmlstring);
+            print '-->';
+        }
+        
+        // turn into an object for easier handling.
+        $xml = new SimpleXMLElement($xmlstring);
+        
+        return $xml;        
+    }
+
+    // Gets the links for an array of files.
+    public function GetDownloadLinks($sessionToken, $filePaths, $expiration, $restrictedIP = null)
+    {
+        global $DEBUG;
+        global $IMFSHOST;
+        
+        // Set the parameters
+        $filePathParams = 'sessionToken=' . $sessionToken . '&';
+        $filePathParams = $filePathParams . 'expiration=' . $expiration . '&';
+        $filePathParams = $filePathParams . 'restrictedIP=' . $restrictedIP . '&';
+
+        // loop through each source file path building the arrray.
+        foreach ($filePaths as $filePath)
+        {
+            $filePathParams = $filePathParams . 'filePath=' . $filePath . '&';            
+        }
+        
+        // retrieve from the REST interface the response xml.
+        $xmlstring = curlGet($IMFSHOST . '/ws/IMFS/GetDownloadLinks.ashx?' . $filePathParams);
+        
+        if ($DEBUG)
+        {
+            print '<!--GetDownloadLinks: ';
+            print_r($xmlstring);
+            print '-->';
+        }
+        
+        // turn into an object for easier handling.
+        $xml = new SimpleXMLElement($xmlstring);
+        
+        return $xml;
+    }
+
+    // Get the node to upload this file to.
+    // Since this is over the web we have to estimate the sizeBytes since we cannot control
+    // the client.
+    public function GetUploadNode($sessionToken)
+    {
+        global $DEBUG;
+        global $IMFSHOST;
+        
+        // Set the parameters
+        $params = 'sessionToken=' . $sessionToken . '&';
+        $params = $params . 'sizeBytes=10000';
+
+        // retrieve from the REST interface the response xml.
+        $xmlstring = curlGet($IMFSHOST . '/ws/IMFS/GetUploadNode.ashx?' . $params);
+
+        if ($DEBUG)
+        {
+            print '<!--GetUploadNode: ';
+            print_r($xmlstring);
+            print '-->';            
+        }
+        
+        // turn into an object for easier handling.
+        $xml = new SimpleXMLElement($xmlstring);
+        
+        return $xml;
+    }
+
+    // Lists the specified folder.
+    public function ListFolder($sessionToken, $folderPath, $pageNumber, $pageSize, $sortCode, $sortDescending)
+    {
+        global $DEBUG;
+        global $IMFSHOST;
+        
+
+        // Set the parameters
+        $params = 'sessionToken=' . $sessionToken . '&';
+        $params = $params . 'folderPath=' . $folderPath . '&';
+        $params = $params . 'pageNumber=' . $pageNumber . '&';
+        $params = $params . 'pageSize=' . $pageSize . '&';
+        $params = $params . 'sortCode=' . $sortCode . '&';
+        $params = $params . 'sortDescending=' . $sortDescending;
+
+        // retrieve from the REST interface the response xml.
+        $xmlstring = curlGet($IMFSHOST . '/ws/IMFS/listfolder.ashx?' . $params);
+        
+        // turn into an object for easier handling.
+        $xml = new SimpleXMLElement($xmlstring);
+        
+        return $xml; 
+    }
+
+    //Moves one or more files to a destination folder
+    public function MoveFiles($sessionToken, $srcFilePaths, $destFolderPath)
+    {
+        global $DEBUG;
+        global $IMFSHOST;
+        
+        // Set the parameters
+        $params = 'sessionToken=' . $sessionToken . '&';
+        $params = $params . 'destFolderPath=' . $destFolderPath . '&';
+
+        // loop through each source file path building the arrray.
+        foreach ($srcFilePaths as $filePath)
+        {
+            $params = $params . 'srcFilePath=' . $filePath . '&';
+        }
+        
+        // retrieve from the REST interface the response xml.
+        $xmlstring = curlGet($IMFSHOST . '/ws/IMFS/movefiles.ashx?' . $params);
+        
+        if ($DEBUG)
+        {
+            print '<!--MoveFiles: ';
+            print_r($xmlstring);
+            print '-->';
+        }
+        
+        // turn into an object for easier handling.
+        $xml = new SimpleXMLElement($xmlstring);
+        
+        return $xml; 
+    }
+    
+    // Moves one or more folders to a destination folder
+    public function MoveFolders($sessionToken, $srcFolderPaths, $destFolderPath)
+    {
+        global $DEBUG;
+        global $IMFSHOST;
+        
+
+        // Set the parameters
+        $folderPathParams = 'sessionToken=' . $sessionToken . '&';
+        $folderPathParams = $folderPathParams . 'destFolderPath=' . $destFolderPath . '&';
+
+        // loop through each source file path building the arrray.
+        foreach ($srcFolderPaths as $folderPath)
+        {
+            $folderPathParams = $folderPathParams . 'srcFolderPath=' . $folderPath . '&';
+        }
+        
+        // retrieve from the REST interface the response xml.
+        $xmlstring = curlGet($IMFSHOST . '/ws/IMFS/movefolders.ashx?' . $folderPathParams);
+        
+        if ($DEBUG)
+        {
+            print '<!--MoveFolders: ';
+            print_r($xmlstring);
+            print '-->';
+        }
+        
+        // turn into an object for easier handling.
+        $xml = new SimpleXMLElement($xmlstring);
+        
+        return $xml; 
+    }
+
+    // Renames a single file
+    public function RenameFile($sessionToken, $filePath, $newFileName)
+    {
+        global $DEBUG;
+        global $IMFSHOST;
+        
+
+        // Set the parameters
+        $params = 'sessionToken=' . $sessionToken . '&';
+        $params = $params . 'filePath=' . $filePath . '&';
+        $params = $params . 'newFileName=' . $newFileName;
+
+        // retrieve from the REST interface the response xml.
+        $xmlstring = curlGet($IMFSHOST . '/ws/IMFS/renamefile.ashx?' . $params);
+        
+        if ($DEBUG)
+        {
+            print '<!--RenameFile: ';
+            print_r($xmlstring);
+            print '-->';
+        }
+        
+        // turn into an object for easier handling.
+        $xml = new SimpleXMLElement($xmlstring);
+        
+        return $xml; 
+    }
+
+    // Renames a single folder
+    public function RenameFolder($sessionToken, $folderPath, $newFolderName)
+    {
+        global $DEBUG;
+        global $IMFSHOST;
+
+        // Set the parameters
+        $folderPathParams = 'sessionToken=' . $sessionToken . '&';
+        $folderPathParams = $folderPathParams . 'folderPath=' . $folderPath . '&';
+        $folderPathParams = $folderPathParams . 'newFolderName=' . $newFolderName;
+
+        // retrieve from the REST interface the response xml.
+        $xmlstring = curlGet($IMFSHOST . '/ws/IMFS/renamefolder.ashx?' . $folderPathParams);
+        
+        if ($DEBUG)
+        {
+            print '<!--RenameFolder: ';
+            print_r($xmlstring);
+            print '-->';
+        }
+        
+        // turn into an object for easier handling.
+        $xml = new SimpleXMLElement($xmlstring);
+        
+        return $xml; 
+    }
+}
+?>
\ No newline at end of file
Index: contributions/modules/backup_migrate/includes/NirvanixAPI/RestUtils.php
--- contributions/modules/backup_migrate/includes/NirvanixAPI/RestUtils.php No Base Revision
+++ contributions/modules/backup_migrate/includes/NirvanixAPI/RestUtils.php Locally New
@@ -0,0 +1,62 @@
+<?php
+/****
+Author:  Nirvanix
+Date:    8-21-2007
+Website: http://developer.nirvanix.com/
+License: See http://developer.nirvanix.com/content/license.aspx
+        Limited Permissive License
+        This license governs use of the accompanying software. If you use the software, 
+        you accept this license. If you do not accept the license, do not use or distribute 
+        the software.
+****/
+
+// doRequest wrapper for doing posts.
+function curlPost($url, $vars) {
+    return doRequest('POST', $url, $vars);
+}
+
+// doRequest wrapper for doing get calls.
+function curlGet($url) {
+    return doRequest('GET', $url, 'NULL');
+}
+
+// Uses Curl Library to retrieve via GET/POST the remote web services REST interfaces.
+function doRequest($method, $url, $vars) 
+{
+    // Init the CURL library
+    $ch = curl_init();
+    // Set the URL to request
+    curl_setopt($ch, CURLOPT_URL, $url);
+    
+    // set the user agent based on the server settings.
+    curl_setopt($ch, CURLOPT_USERAGENT, "PHP File System Manager");
+    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
+    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+    
+    // This is to simplify release / distribution but should be changed
+    // when you have a production PHP system to be enabled using good
+    // certificates.
+    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
+    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
+    
+    // set the post values.
+    if ($method == 'POST') 
+    {
+        curl_setopt($ch, CURLOPT_POST, 1);
+        curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
+    }
+    // execute the curl request and return the xml response.
+    $data = curl_exec($ch);
+    if ($data) 
+    {
+        return $data;
+    } 
+    else 
+    {
+        return curl_error($ch);
+    }
+    // clean up when finished with the curl library.
+    curl_close($ch);
+}
+   
+?>
\ No newline at end of file
