[英]Hide url header redirect parameters using session
我有以下php代碼
<?php
$token_cipherText=$_POST['tokenex_cipherText'];
$token=generateToken($tokenex_cipherText);
$merchantid="example";
$Password="example1";
$remoteIP='11.22.95.5';
$customerReferenceNo = $_POST['customerReferenceNo'];
$amount=$_POST['amount'];
$currencyCode='356';
$expiryMonth=$_POST['expiry_month'];
$expiryYear=$_POST['expiry_year'];
$securityCode=$_POST['cvv'];
$cardHolderName=$_POST['name_on_card'];
$cardType=$_POST['selectedRadioValue'];
if($cardType=='radio1')
{
$cardType='CC';
}
if($cardType=='radio2')
{
$cardType='DB';
}
$cardProvider=$_POST['ccType'];
if($cardProvider=='visa_electron')
{
$cardProvider='visa';
}
if($cardProvider=='mastercard')
{
$cardProvider='mc';
}
if($cardProvider=='maestro')
{
$cardProvider='maest';
}
if($cardProvider=='sbi_maestro')
{
$cardProvider='sbime';
}
$cardProvider=strtoupper($cardProvider);
$name=$cardHolderName;
$mobileNo=$_POST['mobileNo'];
$Email=$_POST['email'];
$merchant_id=$_POST['merchant_id'];
$sql=mysql_query("select * from card_token where token='$token'");
$numrows=mysql_num_rows($sql);
if($numrows==0)
{
$sql=mysql_query("insert into card_token value('','$token','$merchant_id',now())");
}
$sql=mysql_query("update payment_tools_transactions set token_id='$token', cardHolderName='$cardHolderName', cust_Email='$Email', mobileNo='$mobileNo', trans_type='$cardType', cardProvider='$cardProvider', trans_amount='$amount' where trans_refNo='$customerReferenceNo'");
$checksum = $merchantid."|".$_POST['amount']."|".$customerReferenceNo;
$checksum = hash('sha256', $checksum);
$data='tokenNo='.$token.'&securityCode='.$securityCode.'&cardExpiryMonth='.$expiryMonth.'&cardExpiryYear='.$expiryYear.'&cardHolderName='.$cardHolderName.'&transactionAmount='.$amount.'&paymentMode='.$cardType.'¤cyCode='.$currencyCode.'&customerReferenceNo='.$customerReferenceNo.'&cardProvider='.$cardProvider.'&name='.$name.'&mobileNo='.$mobileNo.'&email='.$Email.'&password='.$Password.'&amount='.$_POST['amount'].'&remoteIP='.$remoteIP.'&checkSum='.$checksum;
$encryption_key = "CE5D964";
$desEncryptedData = encryptText_3des($data, $encryption_key);
$desEncryptedData = urlencode($desEncryptedData);
$url='https://payment.paykml.com/PGCCDCToken/TokenPayment.jsp?merchantId='.$merchantid.'&data='.$desEncryptedData; //URL for CC authentication
header("location:$url");
一個html表單將一些值發布到此php中,並使用標header("location:$url");
執行上述代碼header("location:$url");
這些參數將重定向到$url='https://payment.paykml.com/PGCCDCToken/TokenPayment.jsp?merchantId='.$merchantid.'&data='.$desEncryptedData;
但是我面臨的問題是,重定向URL像https://payment.paykml.com/PGCCDCToken/TokenPayment.jsp?merchantId=example&data=**********
任何人都可以操縱或輕松獲取此值。是否可以使用會話隱藏此參數?或者是否有其他方法可以隱藏此網址重定向參數?
有人可以幫忙嗎?我一直在到處尋找解決方案,但是vien :(
解決方案:由於我們正在重定向到第三方網站,因此無法在此處使用會話,因此我使用curl將參數發布到該網站
//Copy paste all the code till here...
$encryption_key = "CE5D964";
$desEncryptedData = encryptText_3des($data, $encryption_key);
$desEncryptedData = urlencode($desEncryptedData);
$url='https://payment.paykml.com/PGCCDCToken/TokenPayment.jsp?merchantId='.$merchantid.'&data='.$desEncryptedData;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
//curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
$auth = curl_exec($curl);
if($auth)
{
header("Location:success.php"); //Redirect to a success page after payment.
exit;
}
如果paykml.com是您自己網站的一部分,則可以使用$_SESSION
vars。 如果您要發布到第三方付款處理公司,則安全性取決於他們如何設置此安全性,並且您不能使用$_SESSION
vars。 我擔心將值傳遞到上面的表格的數據輸入表格。 如果您是將信用卡信息發布到上述表格中的人,則應使用SSL。 $_SESSION
不會幫助您。 在此處查看有關在您的網站上接受信用卡信息的信息。
使用stream_context_create和fopen()。 此代碼從此處改編。 我尚未對此進行測試,因此不知道它是否可以工作,但是您可以從這里開始。
<?php
$options = array(
'http'=>array(
'method'=>"GET",
'header'=>
"Accept-language: en\r\n".
"Content-type: application/x-www-form-urlencoded\r\n",
'content'=>http_build_query(array("merchantId"=>$merchantid,'data'=>$data))
));
$context = stream_context_create($options);
$result = file_get_contents('http://paykml.com/PGCCDCToken/TokenPayment.jsp',false,$context);
?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.