dongsang6899 2010-02-11 19:45
浏览 332

php,找不到HTTP_REFERER

Hi im trying to connect to integrate my form to a payment provider but im getting URL not allowed and it turns out that the HTTP_REFERER is not found..

#the following function performs a HTTP Post and returns the whole response
function pullpage( $host, $usepath, $postdata = "" ) {

# open socket to filehandle(epdq encryption cgi)
 $fp = fsockopen( $host, 80, &$errno, &$errstr, 60 );

#check that the socket has been opened successfully
 if( !$fp ) {
    print "$errstr ($errno)<br>
";
 }
 else {

    #write the data to the encryption cgi
    fputs( $fp, "POST $usepath HTTP/1.0
");
    $strlength = strlen( $postdata );
    fputs( $fp, "Content-type: application/x-www-form-urlencoded
" );
    fputs( $fp, "Content-length: ".$strlength."

" );
    fputs( $fp, $postdata."

" );

    #clear the response data
   $output = "";


    #read the response from the remote cgi 
    #while content exists, keep retrieving document in 1K chunks
    while( !feof( $fp ) ) {
        $output .= fgets( $fp, 1024);
    }

    #close the socket connection
    fclose( $fp);
 }

#return the response
 return $output;
}

#define the remote cgi in readiness to call pullpage function 
$server="secure2.epdq.co.uk";
$url="/cgi-bin/CcxBarclaysEpdqEncTool.e";

#the following parameters have been obtained earlier in the merchant's webstore
#clientid, passphrase, oid, currencycode, total
$params="clientid=xxx";
$params.="&password=xxxx";
$params.="&oid=xxxx";
$params.="&chargetype=Auth";
$params.="&currencycode=826";
$params.="&total=120";

#perform the HTTP Post
$response = pullpage( $server,$url,$params );

#split the response into separate lines
$response_lines=explode("
",$response);

#for each line in the response check for the presence of the string 'epdqdata'
#this line contains the encrypted string
$response_line_count=count($response_lines);
for ($i=0;$i<$response_line_count;$i++){
    if (preg_match('/epdqdata/',$response_lines[$i])){
        $strEPDQ=$response_lines[$i];
    }
}


<FORM action="https://secure2.epdq.co.uk/cgi-bin/CcxBarclaysEpdq.e" method="POST">
<?php print "$strEPDQ"; ?>
<INPUT type="hidden" name="returnurl" value="http://www.xxxxxx.co.uk/test/confirm.php">
<INPUT type="hidden" name="merchantdisplayname" value="xx xxx">
<INPUT type=hidden name=baddr1 value="address line 1">
<INPUT type=hidden name=baddr2 value="address line 2">
<INPUT type=hidden name=baddr3 value="address line 3">
<INPUT type=hidden name=bcity value="City">
<INPUT type=hidden name=bcountyprovince value="County">
<INPUT type=hidden name=bpostalcode value="Postcode">
<INPUT type=hidden name=bcountry value="GB">
<INPUT type=hidden name=btelephonenumber value="01111 012345">
<INPUT type=hidden name=email value="xxxxx">
<INPUT type=hidden name=saddr1 value="Address line 1">
<INPUT type=hidden name=saddr2 value="Address line 2">
<INPUT type=hidden name=saddr3 value="Address line 3">
<INPUT type=hidden name=scity value="City">
<INPUT type=hidden name=scountyprovince value="County">
<INPUT type=hidden name=spostalcode value="Postcode">
<INPUT type=hidden name=scountry value="GB">
<INPUT type=hidden name=stelephonenumber value="01111 012345">
<INPUT TYPE="submit" VALUE="purchase">
</FORM>

can anyone help?

  • 写回答

3条回答 默认 最新

  • dongzeao5047 2010-02-11 19:50
    关注

    I think some of the other posts deal directly with the issue you are seeing, however, I do want to suggest that you look into using CURL (http://php.net/manual/en/book.curl.php) for what you are trying to do instead of opening a socket connection manually. Your payment provider might even have some code examples for that in PHP. Typically this is a much better way of handling communication with gateways and has a lot more flexibility.

    This will be especially handy if you integrate with multiple gateways since most have CURL code examples, and you will find other uses for it in the future.

    EDIT:

    Even better than the PHP manual--this site makes it much more clear how to use it including auth routines, passing post vars, etc with examples:

    http://devzone.zend.com/article/1081

    评论

报告相同问题?

悬赏问题

  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件