tijd berekenen in een sql query

Status
Niet open voor verdere reacties.

banaantje12

Gebruiker
Lid geworden
4 mrt 2007
Berichten
30
Ik probeer in een SQL query de tijd aan te geven.
Dat moet in dit voormaat: "2007-04-15 13:54:58"
Dus zo: "JAAR-MAAND-DAG UREN-MINUTEN-SECONDEN"
De tijd word waarschijnlijk zo berekend: mktime(date("Y"));

Onderin het bestand staat iets van mktime(date("G")
Daaronder word de SQL query uitgevoerd.
De query moet apart worden berekend dan de orginele omdat phpBB hem op een andere manier verstuurd.
De twee - en de twee : moeten erin.
Onder de SQL executie staat wat er orgineel hoort te staan. (waarvan ik de nieuwe query op heb gebasseerd)

PHP:
<?php
/***************************************************************************
 *				lwtopupresult.php
 *
 *	begin				: SEP/01/2004
 *	copyright			: Loewen Enterprise - Xiong Zou
 *	email				: zouxiong@loewen.com.sg
 *
 *	version				: 1.0.0.1 - OCT/16/2004
 *
 ***************************************************************************/
/***************************************************************************
## Terms of Use
##
## All of my MODifications are to use and edit/change for phpBB End Users
##
## Plese DO NOT remove any copyright/licence declaration when using the MODification
##
## I will remain as the sole developer for all my MODifications unless stated otherwise
##
##
## Distribution Terms
##
## All of my MODifications are prohibited to distribute to others without the permission from me.
##
## Plese DO NOT remove any copyright/licence declaration when using the MODification
##
## I will remain as the sole developer for all my MODifications unless stated otherwise
##
## Re-Distribution Terms
##
## If you are distributing WHOLE or PART of my MOD in your MOD Projects or Pre-modded Projects or any other means, you must:
##
## Get the formal authorization from me first.
##
## Plese DO NOT remove any copyright/licence declaration when using the MODification
##
## I will remain as the sole developer for all my MODification unless stated otherwise. Do NOT declare youself as my co-developer
##
## Re-Distribution Terms DOES NOT apply to MOD authors that developing Add-Ons to my MOD. You will be the Add-Ons' Developer/Author
##
***************************************************************************/

define('IN_PHPBB', true);
$phpbb_root_path = './';

include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//$unhtml_specialchars_match = array('#&gt;#', '#&lt;#', '#&quot;#', '#&amp;#');
//$unhtml_specialchars_replace = array('>', '<', '"', '&');

//
// Set page ID for session management
//
//$userdata = session_pagestart($user_ip, PAGE_INDEX);
//init_userprefs($userdata);
//
// End session management
//
if(phpversion() <= "4.0.6")  { $_POST = ($HTTP_POST_VARS);  }

// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';

foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}

// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('www.sandbox.paypal.com', 80, $errno, $errstr, 30);


// Below Instant Payment Notifiction Variables
                   $business = (isset($_POST['business']) ? $_POST['business'] : '');
                   $receiver_email = (isset($_POST['receiver_email']) ? $_POST['receiver_email'] : '');
                   $item_name = (isset($_POST['item_name']) ? $_POST['item_name'] : '');
                   $item_number = (isset($_POST['item_number']) ? $_POST['item_number'] : '');
                   $quantity = (isset($_POST['quantity']) ? $_POST['quantity'] : '');
//Advanced and Custom information
                   $invoice = (isset($_POST['invoice']) ? $_POST['invoice'] : '');
                   $custom = (isset($_POST['custom']) ? $_POST['custom'] : '');
                   $memo = (isset($_POST['memo']) ? $_POST['memo'] : '');
                   $tax = (isset($_POST['tax']) ? $_POST['tax'] : '');
                   $option_name1 = (isset($_POST['option_name1']) ? $_POST['option_name1'] : '');
                   $option_selection1 = (isset($_POST['option_selection1']) ? $_POST['option_selection1'] : '');
                   $option_name2 = (isset($_POST['option_name2']) ? $_POST['option_name2'] : '');
                   $option_selection2 = (isset($_POST['option_selection2']) ? $_POST['option_selection2'] : '');
// Shopping Cart Information
                   $num_cart_items = (isset($_POST['num_cart_items']) ? $_POST['num_cart_items'] : '');
// Transaction Information
                   $pending_reason = (isset($_POST['pending_reason']) ? $_POST['pending_reason'] : '');
                   $reason_code = (isset($_POST['reason_code']) ? $_POST['reason_code'] : '');
                   $payment_date = (isset($_POST['payment_date']) ? $_POST['payment_date'] : '');
                   $txn_id = (isset($_POST['txn_id']) ? $_POST['txn_id'] : '');
                   $txn_type = (isset($_POST['txn_type']) ? $_POST['txn_type'] : '');
                   
                   $payment_type = (isset($_POST['payment_type']) ? $_POST['payment_type'] : '');
                   $payment_status = (isset($_POST['payment_status']) ? $_POST['payment_status'] : '');
// Currency and Exchange Information                   
                   $mc_gross = (isset($_POST['mc_gross']) ? $_POST['mc_gross'] : '');
                   $mc_fee = (isset($_POST['mc_fee']) ? $_POST['mc_fee'] : '');
                   $mc_currency = (isset($_POST['mc_currency']) ? $_POST['mc_currency'] : '');
                   $settle_amount = (isset($_POST['settle_amount']) ? $_POST['settle_amount'] : '');
                   $settle_currency = (isset($_POST['settle_currency']) ? $_POST['settle_currency'] : '');
                   $exchange_rate = (isset($_POST['exchange_rate']) ? $_POST['exchange_rate'] : '');
                   $payment_gross = (isset($_POST['payment_gross']) ? $_POST['payment_gross'] : '');
                   $payment_fee = (isset($_POST['payment_fee']) ? $_POST['payment_fee'] : '');
// Auction Information 
                   $for_auction = (isset($_POST['for_auction']) ? $_POST['for_auction'] : '');
                   $auction_buyer_id = (isset($_POST['auction_buyer_id']) ? $_POST['auction_buyer_id'] : '');
                   $auction_closing_date = (isset($_POST['auction_closing_date']) ? $_POST['auction_closing_date'] : '');
                   $auction_multi_item = (isset($_POST['auction_multi_item']) ? $_POST['auction_multi_item'] : '');
 // Buyer Information
                   $first_name = (isset($_POST['first_name']) ? $_POST['first_name'] : '');
                   $last_name = (isset($_POST['last_name']) ? $_POST['last_name'] : '');
                   $address_name = (isset($_POST['address_name']) ? $_POST['address_name'] : '');
                   $address_street = (isset($_POST['address_street']) ? $_POST['address_street'] : '');
                   $address_city = (isset($_POST['address_city']) ? $_POST['address_city'] : '');
                   $address_state = (isset($_POST['address_state']) ? $_POST['address_state'] : '');
                   $address_zip = (isset($_POST['address_zip']) ? $_POST['address_zip'] : '');
                   $address_country = (isset($_POST['address_country']) ? $_POST['address_country'] : '');
                   $address_status = (isset($_POST['address_status']) ? $_POST['address_status'] : '');
                   $payer_email = (isset($_POST['payer_email']) ? $_POST['payer_email'] : '');
                   $payer_id = (isset($_POST['payer_id']) ? $_POST['payer_id'] : '');
                   $payer_status = (isset($_POST['payer_status']) ? $_POST['payer_status'] : '');

// Below are Subscription - Instant Payment Notifiction Variables
                   $notify_version = (isset($_POST['notify_version']) ? $_POST['notify_version'] : '');
                   $verify_sign = (isset($_POST['verify_sign']) ? $_POST['verify_sign'] : '');
                   $subscr_date = (isset($_POST['subscr_date']) ? $_POST['subscr_date'] : '');
                   $subscr_effective = (isset($_POST['subscr_effective']) ? $_POST['subscr_effective'] : '');
                   $period1 = (isset($_POST['period1']) ? $_POST['period1'] : '');
                   $period2 = (isset($_POST['period2']) ? $_POST['period2'] : '');
                   $period3 = (isset($_POST['period3']) ? $_POST['period3'] : '');
                   $amount1 = (isset($_POST['amount1']) ? $_POST['amount1'] : '');
                   $amount2 = (isset($_POST['amount2']) ? $_POST['amount2'] : '');
                   $amount3 = (isset($_POST['amount3']) ? $_POST['amount3'] : '');
                   $mc_amount1 = (isset($_POST['mc_amount1']) ? $_POST['mc_amount1'] : '');
                   $mc_amount2 = (isset($_POST['mc_amount2']) ? $_POST['mc_amount2'] : '');
                   $mc_amount3 = (isset($_POST['mc_amount3']) ? $_POST['mc_amount3'] : '');
                   $recurring = (isset($_POST['recurring']) ? $_POST['recurring'] : '');
                   $reattempt = (isset($_POST['reattempt']) ? $_POST['reattempt'] : '');
                   $retry_at = (isset($_POST['retry_at']) ? $_POST['retry_at'] : '');
                   $recur_times = (isset($_POST['recur_times']) ? $_POST['recur_times'] : '');
                   $username = (isset($_POST['username']) ? $_POST['username'] : '');
                   $password = (isset($_POST['password']) ? $_POST['password'] : '');
                   $subscr_id = (isset($_POST['subscr_id']) ? $_POST['subscr_id'] : '');

/*// IPN was Confirmed as both Genuine and VERIFIED
            if (!strcmp ($reply, "VERIFIED"))
            {

/* Now that IPN was VERIFIED below are a few things which you may want to do at this point.
 1. Check that the "payment_status" variable is: "Completed"
 2. If it is Pending you may want to wait or inform your customer?
 3. You should Check your datebase to ensure this "txn_id" or "subscr_id" is not a duplicate. txn_id is not sent with subscriptions!
 4. Check "payment_gross" or "mc_gross" matches match your prices!
 5. You definately want to check the "receiver_email" or "business" is yours. 
*/

if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
// 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

		//$item_number will looks like 6-14  user_id-group_id
		$pos = strpos($item_number, '-', 0);
		$user_id = 0;
		$group_id = 0;
		if($pos !== false)
		{
			$user_id = intval(substr($item_number, 0, $pos));
			$group_id = intval(substr($item_number, $pos + 1));
		}
		if($user_id <= 0 || $group_id <= 0)
		{
			fclose ($fp);
			$message = sprintf($lang['LW_USER_ACCT_ERROR'], $user_id) . '<br /><br />' .  sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
			message_die(GENERAL_MESSAGE, $message);
		        exit;
		}
		$sql = "SELECT user_id, username, user_active, user_level, user_expire_date, user_regdate
			FROM " . USERS_TABLE . "
			WHERE user_id = $user_id";
		if ( !($result = $db->sql_query($sql)) )
		{
			fclose ($fp);
			message_die(GENERAL_ERROR, 'Error in obtaining userdata', '', __LINE__, __FILE__, $sql);
			exit;
		}
		if( $row = $db->sql_fetchrow($result) )
		{
			if( $row['user_level'] == ADMIN
				|| $row['user_level'] == MOD )
	//			|| time() <= ( $row['user_expire_date'] <= 0 ? ($row['user_regdate'] + intval($board_config['lw_trial_period']) * 24 * 60 * 60) : $row['user_expire_date']  ) )
			{
				fclose ($fp);
				$message = $lang['Account_activated_lw'] . '<br /><br />' .  sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
				message_die(GENERAL_MESSAGE, $message);
				exit;
			}
		}
		else
		{
				fclose ($fp);
				$message = $lang['Account_not_exist_lw'] . '<br /><br />' .  sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
				message_die(GENERAL_MESSAGE, $message);
				exit;
		}

		$flag = 0;
		if(strcasecmp($txn_type, 'web_accept') == 0)
		{
			$flag = 1; //check payment;
		}
		else if(strcasecmp($txn_type, 'subscr_payment') == 0)
		{
			$flag = 2; //check payment;
		}
		else if(strcasecmp($txn_type, 'subscr_signup') == 0)
		{
			$flag = 3;  //need to check whether first trial fee is 0, if yes, add to group, if no, wait for payment;
		}
		else if(strcasecmp($txn_type, 'subscr_cancel') == 0)
		{
			$flag = 5; //unsubcribe //cancel subscription, but wait till his time expire
		}
		else if(strcasecmp($txn_type, 'subscr_failed') == 0)
		{
			$flag = 4; //unsubscribe if any exits, report error in return_url what paypal will do if can not deduct money any more?
		}
		else if(strcasecmp($txn_type, 'subscr_eot') == 0)
		{
			$flag = 4; //unsubcribe
		}
		else if(strcasecmp($txn_type, 'subscr_modify') == 0)
		{
			$flag = 0; //else condition, or unknow condition;
		}
		else
		{
			$flag = 0; //else condition, or unknow condition;
		}
		
//		if(($flag == 0 || $flag == 4 )
//			&& strcasecmp($payment_status, 'Refunded') != 0)
		if( $flag == 4 && strcasecmp($payment_status, 'Refunded') != 0 )
		{
			//remove member from all paid groups if any
			$sql = "SELECT * FROM " . GROUPS_TABLE . " WHERE group_type = " . GROUP_PAYMENT . " AND group_amount > 0";
			if ( !($result = $db->sql_query($sql)) )
			{
					message_die(GENERAL_ERROR, 'Error getting group information', '', __LINE__, __FILE__, $sql);
			}
			$group_infos = array();
			if( ($group_info = $db->sql_fetchrow($result)) )
			{
				do
				{
					$group_infos[] = $group_info;	
				}
				while( $group_info = $db->sql_fetchrow($result) );
			}
			$groupwhere = '';
			for($i = 0; $i < count($group_infos); $i++)
			{					
				$groupwhere .= "(group_id = " . $group_infos[$i]['group_id'] . " AND user_id = " . $row['user_id'] . ")";
				if($i < (count($group_infos) - 1))
				{
					$groupwhere .= " OR ";	
				}
			}
			if(strlen($groupwhere) > 0)
			{
				$sql = "DELETE FROM " . USER_GROUP_TABLE . " WHERE $groupwhere";
				if( !($result = $db->sql_query($sql)) )
				{
					//do nothing
				}
			}

			//end remove member from all paid groups if any
			$sql = "UPDATE " . USERS_TABLE . " SET user_actviate_date = " . time() . ", user_expire_date = " . time() . " WHERE user_id = " . $user_id;

			if ( !($result = $db->sql_query($sql)) )
			{
//				fclose ($fp);
//				$message = $lang['LW_UPDATE_USER_ACCT_ERROR'] . '<br /><br />' .  sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
//				message_die(GENERAL_MESSAGE, $message);
//			        exit;
				//do nothing
			}
		}
	
		//update the payee's user data with payment
		if((($flag == 1 || $flag == 2) && strcasecmp($payment_status, 'Completed') == 0)
			|| $flag == 3)
		{
			
			
	//update the user_group table:
	
			$sql = "SELECT g.* 
				FROM " . GROUPS_TABLE . " g
				WHERE g.group_id = $group_id";
			if ( !($resultr = $db->sql_query($sql)) )
			{
				fclose ($fp);
				$message = $lang['LW_UPDATE_USER_ACCT_ERROR'] . '<br /><br />' .  sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
				message_die(GENERAL_MESSAGE, $message);
			        exit;
			}
			if( !($rowr = $db->sql_fetchrow($resultr)) )
			{
				fclose ($fp);
				$message = $lang['LW_UPDATE_USER_ACCT_ERROR'] . '<br /><br />' .  sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
				message_die(GENERAL_MESSAGE, $message);
			        exit;
			}
			$group_id = $rowr['group_id'];
			$group_amount = $rowr['group_amount'];
			$group_period = $rowr['group_period'];
			$group_period_basis = $rowr['group_period_basis'];
			
			
			if(strcasecmp($board_config['paypal_p_acct'], $receiver_email) != 0 
				|| strcasecmp($board_config['paypal_currency_code'], $mc_currency) != 0)
			{
				fclose ($fp);
				$message = $lang['LW_UPDATE_USER_ACCT_ERROR'] . '<br /><br />' .  sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
				message_die(GENERAL_MESSAGE, $message);
			        exit;
			}
			
			//if repviously has a record with same txn_id and its status is completed. exit
			$sql = "SELECT * FROM " . ACCT_HIST_TABLE . " WHERE txn_id = '" . $txn_id . "' AND status = '" . $payment_status . "'";
			if ( !($resulta = $db->sql_query($sql)) )
			{
				//do nothing
			}
			if( !($rowa = $db->sql_fetchrow($resulta)) )
			{
				//do nothing
			}
			if($rowa['lw_money'] > 0)
			{
				fclose ($fp);
				$message = $lang['LW_UPDATE_USER_ACCT_ERROR'] . '<br /><br />' .  sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
				message_die(GENERAL_MESSAGE, $message);
			        exit;
			}
			//end if repviously has a record with same txn_id and its status is completed. exit
			
			
			//remove member from all paid groups if any
			$sql = "SELECT * FROM " . GROUPS_TABLE . " WHERE group_type = " . GROUP_PAYMENT . " AND group_amount > 0";
			if ( !($result = $db->sql_query($sql)) )
			{
					message_die(GENERAL_ERROR, 'Error getting group information', '', __LINE__, __FILE__, $sql);
			}
			$group_infos = array();
			if( ($group_info = $db->sql_fetchrow($result)) )
			{
				do
				{
					$group_infos[] = $group_info;	
				}
				while( $group_info = $db->sql_fetchrow($result) );
			}
			$groupwhere = '';
			for($i = 0; $i < count($group_infos); $i++)
			{					
				$groupwhere .= "(group_id = " . $group_infos[$i]['group_id'] . " AND user_id = " . $row['user_id'] . ")";
				if($i < (count($group_infos) - 1))
				{
					$groupwhere .= " OR ";	
				}
			}
			if(strlen($groupwhere) > 0)
			{
				$sql = "DELETE FROM " . USER_GROUP_TABLE . " WHERE $groupwhere";
				if( !($result = $db->sql_query($sql)) )
				{
					//do nothing
				}
			}
			//end remove member from all paid groups if any
			
			//add to the subscribed group
			$sql = "INSERT INTO " . USER_GROUP_TABLE . " (user_id, group_id, user_pending)
				VALUES ($user_id, $group_id, 0)";
	
			if( !($result = $db->sql_query($sql)) )
			{
				fclose ($fp);
				$message = $lang['LW_UPDATE_USER_ACCT_ERROR'] . '<br /><br />' .  sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
				message_die(GENERAL_MESSAGE, $message);
			        exit;
			}			
			//end add to the subscribed group
	//end update user group
	
			//expire date
			$expiretime = 0;
			$sql = '';
						
			$add_days = 0;
			$add_months = 0;
			$add_years = 0;	
						
			//cal the time to add, 
			if(($flag == 2 || $flag == 3) && $rowr['group_sub_recurring'] == 1)
			{
				if(($mc_gross + 0.00) >= $rowr['group_amount'])
				{
					$group_period_basis = $rowr['group_period_basis'];
					$group_period = $rowr['group_period'];
				}
				else if(($mc_gross + 0.00) >= $rowr['group_second_trial_fee'])
				{
					$group_period_basis = $rowr['group_second_trial_period_basis'];
					$group_period = $rowr['group_second_trial_period'];
				}
				else if(($mc_gross + 0.00) >= $rowr['group_first_trial_fee'])
				{
					$group_period_basis = $rowr['group_first_trial_period_basis'];
					$group_period = $rowr['group_first_trial_period'];
				}
				else
				{
					fclose ($fp);
					$message = $lang['LW_UPDATE_USER_ACCT_ERROR'] . '<br /><br />' .  sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
					message_die(GENERAL_MESSAGE, $message);
				        exit;
				}
				
			}
			if(strcasecmp($group_period_basis, 'D') == 0 )
			{
				$add_days = $group_period;
			}
			if(strcasecmp($group_period_basis, 'W') == 0 )
			{
				$add_days = $group_period * 7;
			}
			if(strcasecmp($group_period_basis, 'M') == 0 )
			{
				$add_months = $group_period;
			}
			if(strcasecmp($group_period_basis, 'Y') == 0 )
			{
				$add_years = $group_period;
			}
			//end cal the time to add, 
			
			if($row['user_expire_date'] <= time())
			{
				$expiretime = mktime(date("G")+1, 0, 0, date("m")+$add_months, date("d")+$add_days, date("Y")+$add_years);
				$mangos_expiretime = mktime(date("Y")+$add_years, '-', date("m")+$add_months, '-', date("d")+$add_days);
			}
			else
			{
				$expiretime = mktime(date("G", $row['user_expire_date'])+1, 0, 0, date("m", $row['user_expire_date'])+$add_months, date("d", $row['user_expire_date'])+$add_days,  date("Y", $row['user_expire_date'])+$add_years);
				$mangos_expiretime = mktime(date("Y", $row['user_expire_date'])+$add_years, '-', date("m", $row['user_expire_date'])+$add_months, '-', date("d", $row['user_expire_date'])+$add_days);
			}

			$sql = "UPDATE account SET banned = '0', locked = '0', user_actviate_date = HIER MOET OOK DE DATE WORDEN BEREKEND, user_expire_date = HIER MOET DE DATE WORDEN BEREKEND WHERE id = " . $user_id;
			if ( !($result = $db->sql_query($sql)) )
			{
//				fclose ($fp);
//				$message = $lang['LW_UPDATE_USER_ACCT_ERROR'] . '<br /><br />' .  sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
//				message_die(GENERAL_MESSAGE, $message);
//			        exit;
				//do nothing
			}

			$sql = "UPDATE " . USERS_TABLE . " SET user_active = 1, user_actkey='', user_actviate_date = " . time() . ", user_expire_date = " . $expiretime . " WHERE user_id = " . $user_id;
			if ( !($result = $db->sql_query($sql)) )
			{
//				fclose ($fp);
//				$message = $lang['LW_UPDATE_USER_ACCT_ERROR'] . '<br /><br />' .  sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
//				message_die(GENERAL_MESSAGE, $message);
//			        exit;
				//do nothing
			}
	
		}
	
//		$sql = "INSERT INTO " . ACCT_HIST_TABLE . "(user_id, lw_post_id, lw_money, lw_plus_minus, MNY_CURRENCY, lw_date, comment, lw_site, status, txn_id) VALUES(" . $user_id . ", 0, " . str_replace("\'", "''", $mc_gross) . ", -1, '" . str_replace("\'", "''", $mc_currency) . "', " . time() . ", 'pay from: " . str_replace("\'", "''", $payer_email) . " to: " . str_replace("\'", "''", $receiver_email) . "', '" . $table_prefix . "', '" . str_replace("\'", "''", $payment_status) . "', '" . str_replace("\'", "''", $txn_id) . "')";
		$sql = "INSERT INTO " . ACCT_HIST_TABLE . "(user_id, lw_post_id, lw_money, lw_plus_minus, MNY_CURRENCY, lw_date, comment, lw_site, status, txn_id) VALUES(" . $user_id . ", 0, " . ( (($mc_gross + 0.00) > 0) ? ($mc_gross + 0.00) : 0 ) . ", -1, '" . str_replace("\'", "''", $mc_currency) . "', " . time() . ", 'pay from: " . str_replace("\'", "''", $payer_email) . " to: " . str_replace("\'", "''", $receiver_email) . "', '" . $table_prefix . "', '" . str_replace("\'", "''", $payment_status) . "', '" . str_replace("\'", "''", $txn_id) . "')";
		if ( !($result = $db->sql_query($sql)) )
		{
			//do nothing
		}
}
else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
	$sql = "INSERT INTO " . ACCT_HIST_TABLE . "(user_id, lw_post_id, lw_money, lw_plus_minus, MNY_CURRENCY, lw_date, comment, lw_site, status, txn_id) VALUES(0, 0, " . str_replace("\'", "''", $mc_gross) . ", 1, '" . str_replace("\'", "''", $mc_currency) . "', " . time() . ", 'pay from: " . str_replace("\'", "''", $payer_email) . " to: " . str_replace("\'", "''", $receiver_email) . ", INVALID', '$table_prefix', '" . str_replace("\'", "''", $payment_status) . "', '" . str_replace("\'", "''", $txn_id) . "')";
	if ( !($result = $db->sql_query($sql)) )
	{
		//do nothing
	}

}
}
fclose ($fp);
}

$message = $lang['LW_PAYMENT_DONE'] . '<br /><br />' .  sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
message_die(GENERAL_MESSAGE, $message);
exit;
		
      
      
      
      
/* =================================
         Below are functions
   ================================= */
   
// Email function
function send_mail($to, $subj, $body)
{
    global $from_name, $from_email, $mailpath;

// E-mail Configuration
	$announce_subject = "$subj";
	$announce_from_email = "$from_email";
	$announce_from_name = "$from_name";
	$announce_to_email = "$to";
	$MP = "$mailpath"; 
	$spec_envelope = 1;
	// End email config
// Access Sendmail
// Conditionally match envelope address
	if(isset($spec_envelope))
	{
	$MP .= " -f $announce_from_email";
	}
	$fd = popen($MP,"w"); 
	fputs($fd, "To: $announce_to_email\n"); 
	fputs($fd, "From: $announce_from_name <$announce_from_email>\n");
	fputs($fd, "Subject: $announce_subject\n"); 
	fputs($fd, "X-Mailer: MyPayPal_Mailer\n");
	fputs($fd, "Content-Type: text/html\n");
	fputs($fd, $body); // $body will be sent when the function is used
	pclose($fd);
}



?>

Weet iemand hoe dat moet?
 
Laatst bewerkt:
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan