Beispiel #1
0
function my_handler($number, $message, $file, $line)
{
    // jwg
    //	echo 'The following error occurred, allegedly on line ' . $line . ' of file ' . $file . ': ' . $message . ' <br/>';
    //	echo 'The existing variables are:' . print_r($GLOBALS, 1) . '';
    wrtlog("ERROR EXIT: line {$line} of {$file} - {$message}");
    echo '<div style="width:100%;textalign:center;"><table width="80%"><tr><td>There was an error processing your request. See log.</td></tr></table>';
    exit;
}
 /**
  * Service Call: CancelPreapproval
  * @param CancelPreapprovalRequest $cancelPreapprovalRequest
  * @param mixed $apiCredential - Optional API credential - can either be
  * 		a username configured in sdk_config.ini or a ICredential object
  *      created dynamically 		
  * @return CancelPreapprovalResponse
  * @throws APIException
  */
 public function CancelPreapproval($cancelPreapprovalRequest, $apiCredential = NULL)
 {
     $apiContext = new PPApiContext($this->config);
     wrtlog("DEBUG CancelPreapproval at 41. apiContext=" . print_r($apiContext, true));
     $handlers = array(new PPPlatformServiceHandler($apiCredential, self::$SDK_NAME, self::$SDK_VERSION));
     wrtlog("DEBUG CancelPreapproval at 45. handlers=" . print_r($handlers, true));
     $ret = new CancelPreapprovalResponse();
     $resp = $this->call('AdaptivePayments', 'CancelPreapproval', $cancelPreapprovalRequest, $apiContext, $handlers);
     wrtlog("DEBUG CancelPreapproval at 48. resp=" . print_r($resp, true));
     $ret->init(PPUtils::nvpToMap($resp));
     return $ret;
 }
 function processRequest()
 {
     // we can directly reference $_SESSION, $_REQUEST and defined vars set by config;
     global $con;
     // give access to open db connection object
     $this->sesstoken = fct_session_token();
     // from $_SESSION['token'] (may be gen'd new just now)
     $email = isset($_POST) && isset($_POST['email']) ? $_POST['email'] : '';
     $email = strtolower(urldecode($email));
     $existing_user = $con->recordselect("SELECT * FROM `prelaunch_signup` WHERE emailAddress='" . $email . "'");
     if (mysql_num_rows($existing_user) > 0) {
         return "That email address is already signed up.";
     } else {
         // new pre-launch signup
         $accessIp = get_ip_address1();
         if (isset($_SESSION['plc'])) {
             // new user has arrived on a referral link containing prelaunch_user created timestamp
             $con->insert("INSERT INTO `prelaunch_signup` \n\t\t\t\t\t\t\t(`emailAddress`, `created`, `ipaddress`, `referrerCreated`) \n\t\t\t\t\t\t\tVALUES ('{$email}', " . time() . ", '" . $accessIp . "', '" . $_SESSION['plc'] . "') ");
         } else {
             if (isset($_SESSION['ruid'])) {
                 // new user has arrived on a referral link containing a registered user's id
                 $referrer = $con->recordselect("SELECT * FROM `users` WHERE `userId` = '" . $_SESSION['ruid'] . "' ");
                 if (mysql_num_rows($referrer) >= 1) {
                     // Use registered user's "created" timestamp as referrerCreated
                     // ... to add a little confusion to understand which "create" we are talking about
                     $con->insert("INSERT INTO `prelaunch_signup` \n\t\t\t\t\t\t\t(`emailAddress`, `created`, `ipaddress`, `referrerCreated`) \n\t\t\t\t\t\t\tVALUES ('{$email}', " . time() . ", '" . $accessIp . "', '" . $referrer['created'] . "') ");
                 } else {
                     // strange ... cannot located registered user by id
                     wrtlog("DEBUG: could not locate registered user by userId=" . $_SESSION['ruid'] . " from session['ruid'] ");
                 }
             } else {
                 $con->insert("INSERT INTO `prelaunch_signup` (`emailAddress`, `created`, `ipaddress`) \n\t\t\t\t\t\t\tVALUES ('{$email}', " . time() . ", '" . $accessIp . "') ");
             }
         }
         return "Thank you! We will notify you as soon as we open for business.";
     }
 }
 if ($_POST['action'] == 'edit' && $error == '') {
     $con->update("UPDATE projectbasics SET projectTitle='{$project_title}', projectCategory='{$project_category}', shortBlurb='{$short_blurb}', projectLocation='{$project_location}' WHERE projectId='" . $_GET['id'] . "'");
     $con->update("UPDATE projects SET accepted='{$project_status}' WHERE projectId='" . $_GET['id'] . "'");
     //$con->update("UPDATE projectstory SET projectVideo='$project_video', projectDescription='$project_description' WHERE projectId='".$_GET['id']."'");
     // jwg -- alt approach for youtube video and its related image
     if (isset($project_video) && !empty($project_video)) {
         if (!preg_match('#youtube#i', $project_video)) {
             wrtlog("Video not youtube .. in project_accept.php: {$project_video} for {$project_title}");
             $error = 'We currently support only youtube videos';
         } else {
             $imageurl = '';
             if (preg_match('/https?:\\/\\/[a-z0-9]*\\.?youtube\\.[a-z]*\\/watch\\?v=((?:[a-zA-Z0-9._]|-)+)(?:\\&|$)/i', $videourl, $match) || preg_match('/https?:\\/\\/[a-z0-9]*\\.?youtube\\.[a-z]*\\/(?:user\\/)?(?:[a-z0-9\\_\\#\\/]|-)*\\/[a-z0-9]*\\/[a-z0-9]*\\/((?:[a-z0-9._]|-)+)(?:[\\&\\?\\w;=\\+_\\#\\%]|-)*/i', $videourl, $match) || preg_match('/https?:\\/\\/[a-z0-9]*\\.?youtube\\.[a-z]*\\/embed\\/((?:[a-z0-9._]|-)+)(?:\\?|$)/i', $videourl, $match)) {
                 $videoId = $match[1];
                 $imageurl = 'https://img.youtube.com/vi/' . $videoId . '/0.jpg';
             } else {
                 wrtlog("Could not determine YouTube video ID: {$project_video} for {$project_title}");
                 $error = 'Could not determine YouTube video Id for video image';
             }
             $con->update("UPDATE projectstory SET projectVideo='{$project_video}', projectVideoImage='{$imageurl}', projectDescription='{$project_description}' WHERE projectId='" . $_GET['id'] . "'");
         }
     }
     //$con->update("UPDATE categories SET username='******', password='******', role='$role' WHERE id='".$_GET['id']."'");
     // for paging
     /*$page1=$_GET['page'];
     		if($page1=='' || $page1==0)
     		{
     			$page1=1;
     		}*/
     header('location: project_accept.php');
     //?page='.$page1 redirect page after update all record
 }
             $inserReward = $con->insert("INSERT INTO projectrewards(`pledgeAmount`,`limitAvailable`,`description`,`estimateDeliveryMonth`, `estimateDeliveryYear`,`projectId`) \n\t\t\t\t\t\t\tVALUES(" . $pledgeAmount[$i] . "," . $limitAvailValue . ",'" . $rewardDescription[$i] . "', " . $rewardMonth[$i] . "," . $rewardYear[$i] . "," . $projectId . ")");
         }
     }
 } elseif ($_POST['current'] == '5') {
     // save story
     //echo $_POST['current'];
     $projectStory1 = sanitize_string($_POST['projectStory1']);
     //echo $projectStory1;
     if (!empty($projectStory1)) {
         $updateStory = $con->update("UPDATE projectstory SET `projectDescription` = '" . $projectStory1 . "' where projectId = " . $projectId . " LIMIT 1");
     }
     /* project video link -- jwg */
     if (isset($_POST['video_url']) && !empty($_POST['video_url'])) {
         $videourl = $_POST['video_url'];
         if (!preg_match('#youtube#i', $videourl)) {
             wrtlog("Not youtube: {$videourl}");
             $error = 'We currently support only youtube videos';
         } else {
             if (preg_match('/https?:\\/\\/[a-z0-9]*\\.?youtube\\.[a-z]*\\/watch\\?v=((?:[a-zA-Z0-9._]|-)+)(?:\\&|$)/i', $videourl, $match) || preg_match('/https?:\\/\\/[a-z0-9]*\\.?youtube\\.[a-z]*\\/(?:user\\/)?(?:[a-z0-9\\_\\#\\/]|-)*\\/[a-z0-9]*\\/[a-z0-9]*\\/((?:[a-z0-9._]|-)+)(?:[\\&\\?\\w;=\\+_\\#\\%]|-)*/i', $videourl, $match) || preg_match('/https?:\\/\\/[a-z0-9]*\\.?youtube\\.[a-z]*\\/embed\\/((?:[a-z0-9._]|-)+)(?:\\?|$)/i', $videourl, $match)) {
                 $videoId = $match[1];
                 $imageurl = 'https://img.youtube.com/vi/' . $videoId . '/0.jpg';
                 //$thumburl = 'https://img.youtube.com/vi/'.$videoId.'/2.jpg';
                 // don't override to embed format here .. do it where video will be used
                 //$videourl = 'https://www.youtube.com/embed/'.$videoId; // override to acceptable format
                 $prodId = $_SESSION['projectId'];
                 $now = time();
                 $userId = $_SESSION['userId'];
                 // SAVE VIDEO URL AND EXPECTED IMAGE URL OF REMOTELY SOURCED IMAGE
                 $update = "update projectstory set projectVideo='" . $_POST['video_url'] . "', projectVideoImage='" . $imageurl . "' where projectId=" . $prodId . " LIMIT 1";
                 $con->update($update);
             } else {
<?php

require_once "../../includes/config.php";
wrtlog("DEBUG user/user_activation: " . print_r($_REQUEST, true));
if ($_REQUEST['email'] != "" && $_REQUEST['actCode'] != "") {
    $email = (string) $_REQUEST['email'];
    $actCode = (string) $_REQUEST['actCode'];
    $qry1 = $con->recordselect("SELECT * FROM users WHERE emailAddress='" . $email . "' and randomNumber='" . $actCode . "' LIMIT 1");
    $tot_rec = mysql_num_rows($qry1);
    if ($tot_rec == 1) {
        $valid_user = mysql_fetch_array($qry1);
        //update status
        if ($valid_user['activated'] == 0) {
            $con->update("UPDATE users SET activated=1 WHERE emailAddress='" . $email . "' and randomNumber='" . $actCode . "'");
            $_SESSION['msgType'] = array('from' => 'user', 'type' => 'error', 'var' => "multiple", 'val' => 'Your account activated Successfully.');
            if ($valid_user['referrerId'] > 0) {
                $refid = $valid_user['referrerId'];
                $qry2 = $con->recordselect("SELECT * FROM referrals WHERE newuserId=" . $valid_user['userId'] . " AND referrerId=" . $refid . " LIMIT 1");
                $referral = mysql_fetch_array($qry2);
                $projid = $referral['projectId'];
                $targeturl = urlencode(SITE_URL . 'browseproject/' . $projid);
                $_SESSION['refid'] = $refid;
                $_SESSION['projid'] = $projid;
                if ($prelaunch) {
                    redirect(SITE_URL);
                }
                // jwg
                redirect(SITE_URL . 'browseproject/' . $projid);
                //redirect(SITE_URL."login?refid=$refid&projid=$projid&redirUrl=$targeturl");
            } else {
                if ($prelaunch) {
Beispiel #7
0
    if ($moduletemplate == 'staticPages-index') {
        if (isset($_SERVER['SCRIPT_URI']) && preg_match('#/terms/#i', $_SERVER['SCRIPT_URI'])) {
            $moduletemplate .= '-terms';
        }
    }
}
?>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv="Content-Language" content="en" />
    <meta http-equiv="X-UA-Compatible" content="IE=8" >
<?php 
if (!isset($meta) || !isset($meta['description'])) {
    if (!preg_match('#index\\.php$#', $_SERVER['SCRIPT_NAME'])) {
        // is something special .. not just index.php.. might want to consider adding meta
        wrtlog("meta not defined or not set.. called with " . $_SERVER['SCRIPT_NAME']);
        //fct_show_trace(debug_backtrace(),"backtrace");
    }
} else {
    ?>
    <meta name="description" content="<?php 
    echo $meta['description'];
    ?>
" />
    <meta name="keywords" content="<?php 
    echo $meta['keywords'];
    ?>
" />
<?php 
}
?>
Beispiel #8
0
<?php

require_once "../../includes/config.php";
//$left_panel=false;
//$cont_mid_cl='-75';
//echo 'hi';exit;
$title = 'My Inbox';
$meta = array("description" => "Message", "keywords" => "Message");
wrtlog("message debug: " . print_r($_GET, true));
$sel_project_detail = mysql_fetch_assoc($con->recordselect("SELECT * FROM `projectbasics` WHERE projectId='" . $_GET['projectId'] . "'"));
if (isset($_GET['id'])) {
    $sel_project_user = mysql_fetch_assoc($con->recordselect("SELECT * FROM `users` WHERE userId='" . $_GET['id'] . "'"));
    wrtlog("message found get['id']=" . $_GET['id']);
} else {
    $sel_project_user = array();
    wrtlog("message found no get['id']");
}
$sel_project_image = mysql_fetch_assoc($con->recordselect("SELECT * FROM `productimages` WHERE projectId='" . $_GET['projectId'] . "'"));
$sel_creator_name = mysql_fetch_assoc($con->recordselect("SELECT p.userId FROM `projects` as p WHERE p.projectId='" . $_GET['projectId'] . "'"));
$sel_creator_name1 = mysql_fetch_assoc($con->recordselect("SELECT name FROM users  WHERE userId='" . $sel_creator_name['userId'] . "'"));
if (!isset($_SESSION['userId']) || $_SESSION['userId'] == '') {
    //redirect(SITE_URL."index.php");
}
// reply message code start
if (isset($_POST['submitReplymessage'])) {
    extract($_POST);
    $message_time = time();
    $con->insert("INSERT INTO usermessages (`messageId` ,`message` ,`projectId` ,`receiverId` ,`senderId` ,`messageTime`)\n\t\tVALUES (NULL , '" . sanitize_string($replymessage) . "', '" . $_GET['projectId'] . "', '" . $_GET['id'] . "', '" . $_SESSION['userId'] . "', '" . $message_time . "')");
}
//reply message code end
// delete message code start
<?php

if (!isset($uid) || !isset($projectId) || !isset($projectStatus)) {
    wrtlog("createProject/project_del.php called w/o required set vars");
    $error = 'Unexpected error';
} else {
    if ($projectStatus['published'] != 0) {
        wrtlog("createProject/project_del.php called for published project");
        $error = 'You can only delete a project before it is published.';
    } else {
        $con->delete("DELETE FROM projects WHERE projectId='" . $projectId . "'");
        $con->delete("DELETE FROM projectstory WHERE projectId='" . $projectId . "'");
        $con->delete("DELETE FROM projectupdate WHERE projectId='" . $projectId . "'");
        $con->delete("DELETE FROM projectupdatecomment WHERE projectId='" . $projectId . "'");
        $con->delete("DELETE FROM staffpicks WHERE projectId='" . $projectId . "'");
        $con->delete("DELETE FROM usermessages WHERE projectId='" . $projectId . "'");
        $con->delete("DELETE FROM paypaltransaction WHERE projectId='" . $projectId . "'");
        $error = 'Project deleted';
        redirect($base_url);
    }
}
 function cancel_preapprovals_backer_dbupdate($array, $PayPalResult, $wasFunded = false)
 {
     // jwg - note: if $wasFunded=true it means that we tried to execute payment
     //       for a backing pledge, but the execute failed, so we are marking that pledge
     //       as cancelled.
     wrtlog("DEBUG in cancel_preapprovals_backer_dbupdate");
     /*paykey,$backer_id,$back_id,$backer_name,$projectId,
     		$project_name,$creator_id,$amount,$commision,$rewardId,$backer_email*/
     extract($array);
     extract($PayPalResult);
     $final_arr = array();
     foreach ($PayPalResult as $K => $P) {
         $final_arr[addslashes($K)] = addslashes(is_array($P) ? json_encode($P) : $P);
     }
     $final_arr['url'] = get_url();
     $this->con->insert("insert into preapproval_detail (detail) values ('" . mysql_real_escape_string(json_encode($final_arr)) . "')");
     $preapproval_detail_id = mysql_insert_id();
     $this->con->update("update projectbacking set payment_status='c',refund_detail_id='" . $preapproval_detail_id . "' where backingId='" . $back_id . "'");
     $pb_r = $this->con->recordselect("select paypalId from projectbacking where projectId='" . $projectId . "' and backingId='" . $back_id . "'");
     if (mysql_num_rows($pb_r) > 0) {
         $pb = mysql_fetch_assoc($pb_r);
         if (isset($pb['paypalId']) && !empty($pb['paypalId']) && $pb['paypalid'] != 0) {
             $this->con->update("update paypaltransaction set status='CANCELLED' where paypalId='" . $pb['paypalId'] . "'");
         }
     }
 }
 function cancel_preapprovals($sel_backing)
 {
     // $sel_backing is preapproved backing record to be cancelled
     $DataArray = array();
     $CancelPreapprovalFields = array('PreapprovalKey' => $sel_backing['preapproval_key']);
     $DataArray['CancelPreapprovalFields'] = $CancelPreapprovalFields;
     $PayPal = new PayPal_Adaptive($this->PayPalConfig);
     $PayPalResult = $PayPal->CancelPreapproval($DataArray);
     // $PayPalResult array(
     //	'Errors' => $Errors,
     //	'Ack' => $Ack,
     //	'Build' => $Build,
     //	'CorrelationID' => $CorrelationID,
     //	'Timestamp' => $Timestamp,
     //	'XMLRequest' => $XMLRequest,
     //	'XMLResponse' => $XMLResponse
     // }
     if (strtolower($PayPalResult['Ack']) == 'success') {
         $this->cancel_preapprovals_backer_dbupdate($array, $PayPalResult);
         $this->cancel_preapprovals_backer_mail($array, $PayPalResult);
     } else {
         wrtlog("WARNING: project #{$sel_backing['projectId']} backing #{$sel_backing['backingId']} could not be cancelled: " . print_r($PayPalResult, true));
         $this->cancel_preapprovals_backer_dbupdate($array, $PayPalResult);
         // still mark it cancelled
         // at this point - we are silent on outcome to the backer... tbd
     }
 }
        session_start();
    }
} else {
    if (session_status() == PHP_SESSION_NONE) {
        session_start();
    }
}
ini_set("html_errors", "0");
$extension = "ffmpeg";
$extension_soname = $extension . "." . PHP_SHLIB_SUFFIX;
$extension_fullname = PHP_EXTENSION_DIR . "/" . $extension_soname;
// load extension
if (!extension_loaded($extension)) {
    wrtlog("AT uploadVideo line 34 - loading {$extension_fullname}");
    @dl($extension_soname) or die("Can't load extension {$extension_fullname}\n");
    wrtlog("At uploadVideo line 36");
}
/***********************************************************/
/*****************Get the path to Extention ****************/
$array_path = explode("/", $_SERVER['SCRIPT_FILENAME']);
$dynamic_path = "";
for ($i = 0; $i < sizeof($array_path) - 1; $i++) {
    if ($array_path[$i] != "") {
        $dynamic_path = $dynamic_path . "/" . $array_path[$i];
    }
}
/**********************************************************/
/******************set folders*****************************/
$dynamic_path = substr($dynamic_path, 1);
$flvpath = DIR_IMG . "site/projectVideos/convertedVideo/";
$imagepath = DIR_IMG . "site/projectImages/photos/";
Beispiel #13
0
<?php

require_once "../../includes/config.php";
// jwg -- user cancelled preapproval
if (isset($_GET['projectId']) && is_numeric($_GET['projectId'])) {
    $projectId = $_GET['projectId'];
    if (!isset($_GET['trackingId'])) {
        wrtlog("WARNING!! No trackingId in call to precancel.php for project {$projectId}");
    } else {
        wrtlog("DEBUG projectBacker/precancel.php deleting project backing for project {$projectId} based on tracking_id.");
        $con->delete("DELETE projectbacking WHERE `projectId` = '{$projectId}' AND `tracking_id` = '{$_GET['trackingId']}' AND `payment_status` = '?' ");
    }
    $selectProject = mysql_fetch_assoc($con->recordselect("SELECT projectTitle from projectbasics where projectId = " . $projectId));
    $_SESSION['msgType'] = array('from' => 'user', 'type' => 'error', 'var' => "multiple", 'val' => "Preapproval cancelled.");
    wrtlog("Preapproval cancelled for " . Slug($selectProject['projectTitle']));
    redirect($base_url . "browseproject/" . $projectId . "/" . Slug($selectProject['projectTitle']) . '/');
}
wrtlog("WARNING precancel.php called without expected projectId");
redirect($base_url . 'index.php');
Beispiel #14
0
        if (isset($_POST) && isset($_POST['preapprove_backing'])) {
            // handle pre-approval request
            if ($_SERVER['SERVER_NAME'] != 'emptyrocket.com') {
                // only permit tests on emptyrocket
                ///// TEMP TURN OFF SUPPORT FOR BACKING UNTIL NEW PAYPAL SDK INTEGRATED ///////
                $_SESSION['msgType'] = array('from' => 'user', 'type' => 'error', 'var' => "multiple", 'val' => "Backing temporarily unavailable while new PayPal code is integrated.");
                $sel_pro_basicdata = mysql_fetch_assoc($con->recordselect("SELECT * FROM projectbasics WHERE projectId='" . $_POST['projectId'] . "'"));
                redirect(SITE_URL . "browseproject/" . $_POST['projectId'] . '/' . Slug($sel_pro_basicdata['projectTitle']) . '/');
                ///////////////////////////////////////////////////////////////////////////////
            }
            $backerId = sanitize_string($_POST['backerId']);
            if (!isset($_SESSION['userId']) || $_SESSION['userId'] != $backerId) {
                wrtlog("WARNING: preapprove_backing request userId ({$backerId}) does not match session (" . $_SESSION['userId'] . ") ");
                $_SESSION['msgType'] = array('from' => 'user', 'type' => 'error', 'var' => "multiple", 'val' => "Request does not match logged-in user.");
                redirect($base_url . 'index.php');
            } else {
                $Pay = new Payment();
                $response = $Pay->doPreapproval($_POST);
                wrtlog("WARNING: unexpected return from call to Pay->doPreapprovePayment in projectBacker/index.php");
                wrtlog("....... post vars: " . print_r($_POST, true));
                wrtlog("....... response: " . print_r($response, true));
                $_SESSION['msgType'] = array('from' => 'user', 'type' => 'error', 'var' => "multiple", 'val' => "Preapproval failed. See log.");
                $sel_pro_basicdata = mysql_fetch_assoc($con->recordselect("SELECT * FROM projectbasics WHERE projectId='" . $_POST['projectId'] . "'"));
                redirect(SITE_URL . "browseproject/" . $_POST['projectId'] . '/' . Slug($sel_pro_basicdata['projectTitle']) . '/');
            }
        } else {
            $_SESSION['msgType'] = array('from' => 'user', 'type' => 'error', 'var' => "multiple", 'val' => "No project found");
            redirect($base_url . 'index.php');
        }
    }
}
Beispiel #15
0
<?php

require "../config.php";
wrtlog("NOTIFY.PHP CALLED");
fct_show_trace(debug_backtrace(), "backtrace");
// THIS IS NO LONGER USED... TBD ...
// This is called by PayPal as a POST request at completion of a payment request.
// The actual url used by PayPal is specified by us in takePreApprovalFromBacker and contains a query string
// with relevant tracking information.
// Combine the two pieces of information (from query string and post variables) log in preapproval_detail and pass to _notify
$get_arry = array();
$post_arry = $_POST;
parse_str($_GET['q'], $get_arry);
//print_r($get_arry);
$PayPalConfig = array('Sandbox' => $sandbox, 'DeveloperAccountEmail' => $developer_account_email, 'ApplicationID' => $application_id, 'DeviceID' => $device_id, 'IPAddress' => $_SERVER['REMOTE_ADDR'], 'APIUsername' => $api_username, 'APIPassword' => $api_password, 'APISignature' => $api_signature, 'APISubject' => $api_subject);
$Pay = new Payment($PayPalConfig);
$result = array_merge($post_arry, $get_arry);
$final_arr = array();
foreach ($result as $K => $P) {
    $final_arr[addslashes($K)] = addslashes(is_array($P) ? json_encode($P) : $P);
}
$final_arr['url'] = get_url();
$con->insert("insert into preapproval_detail (detail) values ('" . json_encode($final_arr) . "')");
if (strtolower($_POST['status']) != 'error') {
    $Pay->takePreApprovalFromBacker_notify($result);
}
 /**
  * Submit Preapproval API request to PayPal.
  *
  * @access	public
  * @param	array	call config data
  * @return	array
  */
 function Preapproval($DataArray)
 {
     $PreapprovalFields = isset($DataArray['PreapprovalFields']) ? $DataArray['PreapprovalFields'] : array();
     $CancelURL = isset($PreapprovalFields['CancelURL']) ? $PreapprovalFields['CancelURL'] : '';
     $CurrencyCode = isset($PreapprovalFields['CurrencyCode']) ? $PreapprovalFields['CurrencyCode'] : '';
     $DateOfMonth = isset($PreapprovalFields['DateOfMonth']) ? $PreapprovalFields['DateOfMonth'] : '';
     $DayOfWeek = isset($PreapprovalFields['DayOfWeek']) ? $PreapprovalFields['DayOfWeek'] : '';
     $EndingDate = isset($PreapprovalFields['EndingDate']) ? $PreapprovalFields['EndingDate'] : '';
     $IPNNotificationURL = isset($PreapprovalFields['IPNNotificationURL']) ? $PreapprovalFields['IPNNotificationURL'] : '';
     $MaxAmountPerPayment = isset($PreapprovalFields['MaxAmountPerPayment']) ? $PreapprovalFields['MaxAmountPerPayment'] : '';
     $MaxNumberOfPayments = isset($PreapprovalFields['MaxNumberOfPayments']) ? $PreapprovalFields['MaxNumberOfPayments'] : '';
     $MaxNumberOfPaymentsPerPeriod = isset($PreapprovalFields['MaxNumberOfPaymentsPerPeriod']) ? $PreapprovalFields['MaxNumberOfPaymentsPerPeriod'] : '';
     $MaxTotalAmountOfAllPayments = isset($PreapprovalFields['MaxTotalAmountOfAllPayments']) ? $PreapprovalFields['MaxTotalAmountOfAllPayments'] : '';
     $Memo = isset($PreapprovalFields['Memo']) ? $PreapprovalFields['Memo'] : '';
     $PaymentPeriod = isset($PreapprovalFields['PaymentPeriod']) ? $PreapprovalFields['PaymentPeriod'] : '';
     $PinType = isset($PreapprovalFields['PinType']) ? $PreapprovalFields['PinType'] : '';
     $ReturnURL = isset($PreapprovalFields['ReturnURL']) ? $PreapprovalFields['ReturnURL'] : '';
     $SenderEmail = isset($PreapprovalFields['SenderEmail']) ? $PreapprovalFields['SenderEmail'] : '';
     $StartingDate = isset($PreapprovalFields['StartingDate']) ? $PreapprovalFields['StartingDate'] : '';
     $FeesPayer = isset($PreapprovalFields['FeesPayer']) ? $PreapprovalFields['FeesPayer'] : '';
     $DisplayMaxTotalAmount = isset($PreapprovalFields['DisplayMaxTotalAmount']) ? $PreapprovalFields['DisplayMaxTotalAmount'] : '';
     $ClientDetailsFields = isset($DataArray['ClientDetailsFields']) ? $DataArray['ClientDetailsFields'] : array();
     $CustomerID = isset($ClientDetailsFields['CustomerID']) ? $ClientDetailsFields['CustomerID'] : '';
     $CustomerType = isset($ClientDetailsFields['CustomerType']) ? $ClientDetailsFields['CustomerType'] : '';
     $GeoLocation = isset($ClientDetailsFields['GeoLocation']) ? $ClientDetailsFields['GeoLocation'] : '';
     $Model = isset($ClientDetailsFields['Model']) ? $ClientDetailsFields['Model'] : '';
     $PartnerName = isset($ClientDetailsFields['PartnerName']) ? $ClientDetailsFields['PartnerName'] : '';
     // Generate XML Request
     $XMLRequest = '<?xml version="1.0" encoding="utf-8"?>';
     $XMLRequest .= '<PreapprovalRequest xmlns="' . $this->XMLNamespace . '">';
     //$XMLRequest .= $this -> GetXMLRequestEnvelope(); // jwg - let envelope contain entire request
     $XMLRequest = '<requestEnvelope xmlns="">';
     $XMLRequest .= '<detailLevel>' . $this->DetailLevel . '</detailLevel>';
     $XMLRequest .= '<errorLanguage>' . $this->ErrorLanguage . '</errorLanguage>';
     $XMLRequest .= '<cancelUrl xmlns="">' . $CancelURL . '</cancelUrl>';
     $XMLRequest .= '<clientDetails xmlns="">';
     $XMLRequest .= $this->ApplicationID != '' ? '<applicationId xmlns="">' . $this->ApplicationID . '</applicationId>' : '';
     $XMLRequest .= $CustomerID != '' ? '<customerId xmlns="">' . $CustomerID . '</customerId>' : '';
     $XMLRequest .= $CustomerType != '' ? '<customerType xmlns="">' . $CustomerType . '</customerType>' : '';
     $XMLRequest .= $this->DeviceID != '' ? '<deviceId xmlns="">' . $this->DeviceID . '</deviceId>' : '';
     $XMLRequest .= $GeoLocation != '' ? '<geoLocation xmlns="">' . $GeoLocation . '</geoLocation>' : '';
     $XMLRequest .= $this->IPAddress != '' ? '<ipAddress xmlns="">' . $this->IPAddress . '</ipAddress>' : '';
     $XMLRequest .= $Model != '' ? '<model xmlns="">' . $Model . '</model>' : '';
     $XMLRequest .= $PartnerName != '' ? '<partnerName xmlns="">' . $PartnerName . '</partnerName>' : '';
     $XMLRequest .= '</clientDetails>';
     $XMLRequest .= '<currencyCode xmlns="">' . $CurrencyCode . '</currencyCode>';
     $XMLRequest .= $DateOfMonth != '' ? '<dateOfMonth xmlns="">' . $DateOfMonth . '</dateOfMonth>' : '';
     $XMLRequest .= $DayOfWeek != '' ? '<dayOfWeek xmlns="">' . $DayOfWeek . '</dayOfWeek>' : '';
     $XMLRequest .= $EndingDate != '' ? '<endingDate xmlns="">' . $EndingDate . '</endingDate>' : '';
     $XMLRequest .= $IPNNotificationURL != '' ? '<ipnNotificationUrl xmlns="">' . $IPNNotificationURL . '</ipnNotificationUrl>' : '';
     $XMLRequest .= $MaxAmountPerPayment != '' ? '<maxAmountPerPayment xmlns="">' . $MaxAmountPerPayment . '</maxAmountPerPayment>' : '';
     $XMLRequest .= $MaxNumberOfPayments != '' ? '<maxNumberOfPayments xmlns="">' . $MaxNumberOfPayments . '</maxNumberOfPayments>' : '';
     $XMLRequest .= $MaxNumberOfPaymentsPerPeriod != '' ? '<maxNumberOfPaymentsPerPeriod xmlns="">' . $MaxNumberOfPaymentsPerPeriod . '</maxNumberOfPaymentsPerPeriod>' : '';
     $XMLRequest .= $MaxTotalAmountOfAllPayments != '' ? '<maxTotalAmountOfAllPayments xmlns="">' . $MaxTotalAmountOfAllPayments . '</maxTotalAmountOfAllPayments>' : '';
     $XMLRequest .= $Memo != '' ? '<memo xmlns="">' . $Memo . '</memo>' : '';
     $XMLRequest .= $PaymentPeriod != '' ? '<paymentPeriod xmlns="">' . $PaymentPeriod . '</paymentPeriod>' : '';
     $XMLRequest .= $PinType != '' ? '<pinType xmlns="">' . $PinType . '</pinType>' : '';
     $XMLRequest .= $FeesPayer != '' ? '<feesPayer xmlns="">' . $FeesPayer . '</feesPayer>' : '';
     $XMLRequest .= $DisplayMaxTotalAmount != '' ? '<displayMaxTotalAmount xmlns="">' . $DisplayMaxTotalAmount . '</displayMaxTotalAmount>' : '';
     $XMLRequest .= $ReturnURL != '' ? '<returnUrl xmlns="">' . $ReturnURL . '</returnUrl>' : '';
     $XMLRequest .= $SenderEmail != '' ? '<senderEmail xmlns="">' . $SenderEmail . '</SenderEmail>' : '';
     $XMLRequest .= $StartingDate != '' ? '<startingDate xmlns="">' . $StartingDate . '</startingDate>' : '';
     $XMLRequest .= '</requestEnvelope>';
     // jwg
     $XMLRequest .= '</PreapprovalRequest>';
     // Call the API and load XML response into DOM
     wrtlog("In paypal.adaptive.class before Preapproval curl request. XMLRequest=" . print_r($XMLRequest, true));
     $XMLResponse = $this->CURLRequest($XMLRequest, 'AdaptivePayments', 'Preapproval');
     wrtlog("After Preapproval request. XMLResponse=" . print_r($XMLResponse, true));
     $DOM = new DOMDocument();
     $DOM->loadXML($XMLResponse);
     // Parse XML values
     $Fault = $DOM->getElementsByTagName('FaultMessage')->length > 0 ? true : false;
     $Errors = $this->GetErrors($XMLResponse);
     $Ack = $DOM->getElementsByTagName('ack')->length > 0 ? $DOM->getElementsByTagName('ack')->item(0)->nodeValue : '';
     $Build = $DOM->getElementsByTagName('build')->length > 0 ? $DOM->getElementsByTagName('build')->item(0)->nodeValue : '';
     $CorrelationID = $DOM->getElementsByTagName('correlationId')->length > 0 ? $DOM->getElementsByTagName('correlationId')->item(0)->nodeValue : '';
     $Timestamp = $DOM->getElementsByTagName('timestamp')->length > 0 ? $DOM->getElementsByTagName('timestamp')->item(0)->nodeValue : '';
     $PreapprovalKey = $DOM->getElementsByTagName('preapprovalKey')->length > 0 ? $DOM->getElementsByTagName('preapprovalKey')->item(0)->nodeValue : '';
     if ($this->Sandbox) {
         $RedirectURL = 'https://www.sandbox.paypal.com/webscr?cmd=_ap-preapproval&preapprovalkey=' . $PreapprovalKey;
     } elseif ($this->BetaSandbox) {
         $RedirectURL = 'https://www.beta-sandbox.paypal.com/webscr?cmd=_ap-preapproval&preapprovalkey=' . $PreapprovalKey;
     } else {
         $RedirectURL = 'https://www.paypal.com/webscr?cmd=_ap-preapproval&preapprovalkey=' . $PreapprovalKey;
     }
     $ResponseDataArray = array('Errors' => $Errors, 'Ack' => $Ack, 'Build' => $Build, 'CorrelationID' => $CorrelationID, 'Timestamp' => $Timestamp, 'PreapprovalKey' => $PreapprovalKey, 'RedirectURL' => $PreapprovalKey != '' ? $RedirectURL : '', 'XMLRequest' => $XMLRequest, 'XMLResponse' => $XMLResponse);
     return $ResponseDataArray;
 }