Noipfraud 新增 API 文件的方法
QQ 76762
欢迎加入我的自言自语群(QQ群:558575184)

通过增加 API 文件,可以实现多个服务器调用一个 Noipfraud Client,同时, Afilter Tracker 与 Noipfraud 的对接也是基于这个API 文件。

以下内容保存为 api.php,放到 Noipfraud Client 文件根目录
请一定注意,要修改第19行为你的 Client 安装目录(APPLOC)

<?php
/*
request format: clid=camp&reqip=ip&other_url_vars
then request with correct headers
especially things like 
HTTP_CLIENT_IP and 
HTTP_X_FORWARDED_FOR

Also pass
HTTP_ACCEPT
HTTP_ACCEPT_ENCODING
HTTP_ACCEPT_LANGUAGE
HTTP_ACCEPT_CHARSET
HTTP_REFERER
*/

//defines the location of noip client - you can get this line from the simple php deploy method
//** MAKE SURE YOU CHANGE THIS SO IT IS VALID FOR YOUR INSTALL
define('APPLOC','/var/www/app/api/');

$apiResponse=true;
$apiError="";
$apiResult=array();
$goto="";

//make sure request is valid
if (!isset($_GET['clid']) || !isset($_GET['reqip']) ) {
    $apiResponse=false;
    $apiError="Invalid api request url. Must contain clid and reqip variables";
}
if (!file_exists(APPLOC.'config.php')) {
    $apiResponse=false;
    $apiError="Client install not completed. Please check the install guide you were sent when you joined. Also make sure you updated APPLOC in your api.php file.";
}

if ( $apiResponse === TRUE ) {
    $_SERVER['REMOTE_ADDR']=$_GET['reqip'];
    include_once(APPLOC.'go.php');
    $apiResponse=$isItSafe;
    $apiError=$isItSafe ? "" : "Blocked";
}