Skip to content

Commit

Permalink
Update black.php
Browse files Browse the repository at this point in the history
  • Loading branch information
5ime authored Jan 13, 2022
1 parent ab75f05 commit 60f5a51
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions api/black.php
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<?php
$file = '../black.data';
$data = fopen($file, 'r');
$data = fread($data, filesize($file));
$data = json_decode($data,true);

if(in_array(get_ip(),$data)){
$Json = array(
'code' => 201,
'msg' => '您已被拉黑',
);
$Json = json_encode($Json,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);
echo stripslashes($Json);
die;
}
if(!empty(get_referer())){
if(in_array(get_referer(),$data)){
if(filesize($file) > 0){
$data = fread($data, filesize($file));
$data = json_decode($data,true);
if(in_array(get_ip(),$data)){
$Json = array(
'code' => 201,
'msg' => '您已被拉黑',
);
);
$Json = json_encode($Json,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);
echo stripslashes($Json);
die;
}
if(!empty(get_referer())){
if(in_array(get_referer(),$data)){
$Json = array(
'code' => 201,
'msg' => '您已被拉黑',
);
$Json = json_encode($Json,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);
echo stripslashes($Json);
die;
}
}
}

function get_referer()
{
$referer = @$_SERVER['HTTP_REFERER'];
Expand All @@ -51,4 +51,4 @@ function get_ip()
$cip = isset($cips[0]) ? $cips[0] : 'unknown';
unset($cips);
return $cip;
}
}

0 comments on commit 60f5a51

Please sign in to comment.