<?php 
require_once("../../conn/conn.php");
require_once("../../conn/function.php");
$info=getbody("https://www.paypal.com/cgi-bin/webscr",$_POST."&cmd=_notify-validate");
$D_domain=splitx($_SERVER["HTTP_HOST"].$_SERVER["PHP_SELF"],"/pay",0);

$remark=$_POST["option_selection1"];
$no=$_POST["txn_id"];
$money=$_POST["payment_gross"];

if($info=="VERIFIED") {
	$sql="select * from sl_list where L_mid=".$remark." and L_no='".$no."'";
	$result = mysqli_query($conn, $sql);
	$row = mysqli_fetch_assoc($result);
	if(mysqli_num_rows($result) > 0) {

	}else{
		mysqli_query($conn,"update sl_member set M_money=M_money+".$money." where M_id=".$remark);
		mysqli_query($conn,"insert into sl_list(L_mid,L_no,L_title,L_time,L_money,L_genkey) values(".$remark.",'$no','帐号充值','".date('Y-m-d H:i:s')."',".$money.",'')");
	}
	echo "success";
}else{
	echo "fail";
}
?>