Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 允许通过IPN访问特定站点_Php - Fatal编程技术网

Php 允许通过IPN访问特定站点

Php 允许通过IPN访问特定站点,php,Php,IPN如何授予对特定站点的访问权限?我正在使用一个名为paygol的网站,人们可以通过短信进行捐赠或销售。当你为捐赠创建按钮时,他们会给你一个IPN代码,你可以修改 <?php // check that the request comes from PayGol server /* if(!in_array($_SERVER['REMOTE_ADDR'], array('109.70.3.48', '109.70.3.146', '109.

IPN如何授予对特定站点的访问权限?我正在使用一个名为paygol的网站,人们可以通过短信进行捐赠或销售。当你为捐赠创建按钮时,他们会给你一个IPN代码,你可以修改

    <?php 

    // check that the request comes from PayGol server
    /*
    if(!in_array($_SERVER['REMOTE_ADDR'],
      array('109.70.3.48', '109.70.3.146', '109.70.3.210'))) {
      header("HTTP/1.0 403 Forbidden");
      die("Error: Unknown IP");
    }
    */ 
// CONFIG 
$your_service_id = 49001;  // this is my service ID from Paygol     

    // get the variables from PayGol system
    $message_id = $_GET['message_id'];
    $service_id = $_GET['service_id'];
    $shortcode  = $_GET['shortcode'];
    $keyword    = $_GET['keyword'];
    $message    = $_GET['message'];
    $sender = $_GET['sender'];
    $operator   = $_GET['operator'];
    $country    = $_GET['country'];
    $custom = $_GET['custom'];
    $points = $_GET['points'];
    $price  = $_GET['price'];
    $currency   = $_GET['currency'];

    // Here you can do whatever you want with the variables, for instance inserting or updating data into your Database 

    ?>

捐赠完成后,我如何允许访问某个特定页面?

将加密或哈希数据设置为cookie,并在过期1年或2年后告知他已进行捐赠:

$token = md5($_SERVER['REMOTE_ADDR'].time());
mysql_query("INSERT INTO access_tokens (token) VALUE ('".mysql_real_escape_string($token)."')");
setcookie("access_token", $token, time() + 365*24*60*60);
并在页面中检查其令牌是否存在于access_tokens表中:

$token = $_COOKIE['access_token'];
$accept = false;
if(strlen($token) == 32) {
  $r = mysql_query("SELECT 1 FROM access_token WHERE token = '".mysql_real_escape_string($token)."' LIMIT 1");
  if(mysql_num_rows($r) == 1) {
    $accept = true;
  }
}

if(!$accept) {
  header('Location: /');
  exit(0);
}
有很多方法可以做到这一点。 他们中的一个在捐款后向用户的电子邮件发送特定的优惠券代码,并在允许访问资源之前询问每一次。
这一切都取决于你的想象力:

将加密数据设置为cookie,在cookie过期1年或2年后,表明他进行了捐赠