| <?php require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/app.class.php"); require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/nav.class.php"); require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/menu.class.php"); $App = new App(); $Nav = new Nav(); $Menu = new Menu(); include($App->getProjectCommon()); # All on the same line to unclutter the user's desktop' |
| /******************************************************************************* |
| * Copyright (c) 2012 Eclipse Foundation and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Denis Roy (Eclipse Foundation)- initial API and implementation |
| * Christopher Guindon (Eclipse Foundation) |
| *******************************************************************************/ |
| |
| $pageTitle = "Thank You"; |
| $pageKeywords = "friends of eclipse, donation, contribution"; |
| $pageAuthor = "Christopher Guindon"; |
| |
| //error_reporting(-1); |
| //ini_set('display_errors', TRUE); |
| //ini_set('display_startup_errors', TRUE); |
| |
| require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/classes/friends/friend.class.php"); |
| require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/classes/friends/contribution.class.php"); |
| |
| require_once("/home/data/httpd/eclipse-php-classes/system/authcode.php"); |
| require_once("includes/functions.inc.php"); |
| |
| ob_start(); |
| // read the post from PayPal system and add 'cmd' |
| $req = 'cmd=_notify-synch'; |
| |
| $tx_token = (isset($_POST['donation_information_form'])) ? $_POST['tx_token'] : $_GET['tx']; |
| |
| //remove when not using sandbox |
| //$auth_token = 'V8qE_sev7DTOjOHjTv9JdDUBy2wocTb6W96-h2CuQJO9kx_FKHz00gFq1ri'; |
| |
| $req .= "&tx=$tx_token&at=$auth_token"; |
| |
| |
| // post back to PayPal system to validate |
| $header = "POST /cgi-bin/webscr HTTP/1.0\r\n"; |
| $header .= "Host: www.paypal.com\r\n"; |
| $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; |
| $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; |
| $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30); |
| // If possible, securely post back to paypal using HTTPS |
| // Your PHP server will need to be SSL enabled |
| // $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30); |
| |
| if (!$fp) { |
| echo "FsockOpen seems to have failed. <br/>"; |
| |
| } |
| else { |
| //set a cookie for 279-days to block the donation page if the user made a donation |
| setcookie ("thankyou_page[donation]", TRUE, time() + (3600 * 24 * 279), '/', '.eclipse.org'); |
| |
| fputs ($fp, $header . $req); |
| // read the body data |
| $res = ''; |
| $headerdone = false; |
| while (!feof($fp)) { |
| $line = fgets ($fp, 1024); |
| if (strcmp($line, "\r\n") == 0) { |
| // read the header |
| $headerdone = true; |
| } |
| else if ($headerdone) |
| { |
| // header has been read. now read the contents |
| $res .= $line; |
| } |
| }//end while |
| // parse the data |
| $lines = explode("\n", $res); |
| $keyarray = array(); |
| if (strcmp ($lines[0], "SUCCESS") == 0) { |
| for ($i=1; $i<count($lines);$i++){ |
| list($key,$val) = explode("=", $lines[$i]); |
| $keyarray[urldecode($key)] = urldecode($val); |
| } |
| // check the payment_status is Completed |
| // check that txn_id has not been previously processed |
| // check that receiver_email is your Primary PayPal email |
| // check that payment_amount/payment_currency are correct |
| // process payment |
| |
| //default but overwritten if it's a normal donation from /donate. |
| $statusCheck = array('Completed', 'Pending'); |
| |
| $bugzillaEmail = $keyarray['item_number']; |
| |
| if(empty($keyarray['option_selection2'])){ |
| $showform = TRUE; |
| if(isset($_POST['donation_information_form'])){ |
| //the user submitted new information about his donation. |
| //this is only possible when $anonymous is unknown |
| $updateinformation = TRUE; |
| $bugzillaEmail = $_POST['item_number']; |
| $anonymous = $_POST['os1']; |
| //$comment = strip_tags($_POST['os0']); |
| } |
| }else{ |
| //Normal donation process. Normaly comming from eclipse.org/donate |
| $showform = FALSE; |
| $anonymous = $keyarray['option_selection2']; |
| $comment = strip_tags($keyarray['option_selection1']); |
| //for a regular donation we only want to add the info if the transaction was complete |
| //the IPN script will take care of adding the user once the transaction is completed |
| $statusCheck = array('Completed'); |
| } |
| |
| //default values: Information is from paypal |
| $itemname = $keyarray['item_name']; |
| $firstname = $keyarray['first_name']; |
| $lastname = $keyarray['last_name']; |
| $amount = $keyarray['payment_gross']; |
| $transactionID = $keyarray['txn_id']; |
| $paymentStatus = $keyarray['payment_status']; |
| |
| include('includes/donation_process.inc.php'); |
| include('content/en_thankyou_form.php'); |
| |
| } |
| else if (strcmp ($lines[0], "FAIL") == 0) { |
| ?><p>There was an error in processing your transaction. Please contact <a href="mailto:friends@eclipse.org">friends@eclipse.org</a> with the transaction information from PayPal.</p><? |
| } |
| } |
| |
| fclose ($fp); |
| ?> |
| |
| |
| <? $html = ob_get_clean(); |
| # Generate the web page |
| $App->AddExtraHtmlHeader('<script type="text/javascript" src="https://eclipse.org/donate/functions.js"></script><link rel="stylesheet" type="text/css" href="https://eclipse.org/donate/style.css" media="screen" />'); |
| $App->generatePage($theme, $Menu, $Nav, $pageAuthor, $pageKeywords, $pageTitle, $html); |
| ?> |
| |