php,未找到 HTTP_REFERER

发布于 2024-08-21 14:20:45 字数 3339 浏览 2 评论 0原文

您好,我正在尝试连接以将我的表单集成到支付提供商,但我收到不允许的 URL,结果发现未找到 HTTP_REFERER..

#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>\n";
 }
 else {

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

    #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("\n",$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>

有人可以帮忙吗?

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>\n";
 }
 else {

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

    #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.="¤cycode=826";
$params.="&total=120";

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

#split the response into separate lines
$response_lines=explode("\n",$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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

空袭的梦i 2024-08-28 14:20:45

我认为其他一些帖子直接处理您所看到的问题,但是,我确实想建议您研究使用 CURL (http://php.net/manual/en/book.curl.php) 来了解您想要执行的操作,而不是手动打开套接字连接。您的支付提供商甚至可能有一些 PHP 代码示例。通常,这是处理网关通信的更好方法,并且具有更大的灵活性。

如果您与多个网关集成,这将特别方便,因为大多数网关都有 CURL 代码示例,并且您将来会发现它的其他用途。

编辑:

甚至比 PHP 手册更好 - 该网站更清楚地说明了如何使用它,包括身份验证例程、传递帖子变量等,并附有示例:

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

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

客…行舟 2024-08-28 14:20:45
fputs( $fp, "Referer: ".$somereferer."\n" );
fputs( $fp, "Referer: ".$somereferer."\n" );
檐上三寸雪 2024-08-28 14:20:45

我认为您忘记了 Host: 标头。

但是,有比打开套接字并实现您自己的 HTTP 客户端更好的方法来通过 HTTP 发布内容。尝试curl

I think you have forget the Host: header.

But, there are better ways how to POST something via HTTP than opening a socket and implementing your own HTTP client. Try curl.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文