去评论
dz插件网

请帮我写一个网站防采集代码,需要用到PHP网站上

镖师
2023/03/30 11:37:17
缃戠珯闃查噰闆嗘槸涓涓瘮杈冨鏉傜殑闂锛屽洜涓洪噰闆嗚呭彲浠ヤ娇鐢ㄥ悇绉嶆墜娈电粫杩囬槻鎶ゆ帾鏂姐備笉杩囷紝浠ヤ笅鏄竴浜涘父瑙佺殑闃查噰闆嗘妧宸э紝浣犲彲浠ュ弬鑰冧竴涓嬶細

[backcolor=rgba(0,0,0,var(--tw-bg-opacity))][color=rgba(217,217,227,var(--tw-text-opacity))][backcolor=rgba(52,53,65,var(--tw-bg-opacity))][size=0.75]phpCopy code
if (stripos($_SERVER['HTTP_USER_AGENT'], 'Mozilla') === false) {    exit('绂佹閲囬泦锛');}

[backcolor=rgba(0,0,0,var(--tw-bg-opacity))][color=rgba(217,217,227,var(--tw-text-opacity))][backcolor=rgba(52,53,65,var(--tw-bg-opacity))][size=0.75]phpCopy code
if (strpos($_SERVER['HTTP_REFERER'], 'http://www.yourwebsite.com') === false) {    exit('绂佹閲囬泦锛');}

[backcolor=rgba(0,0,0,var(--tw-bg-opacity))][color=rgba(217,217,227,var(--tw-text-opacity))][backcolor=rgba(52,53,65,var(--tw-bg-opacity))][size=0.75]phpCopy code
$seconds = 10; // 鏃堕棿闂撮殧锛屽崟浣嶄负绉$count = 0;$log_file = 'access.log'; // 璁板綍璁块棶鏃ュ織鐨勬枃浠跺悕// 璇诲彇璁块棶鏃ュ織if (file_exists($log_file)) {    $log = file_get_contents($log_file);    $log_array = explode("\n", $log);    $last_time = end($log_array);    $time_diff = time() - $last_time;    foreach ($log_arrayas$log_item) {        if (time() - $log_item <= $seconds) {            $count++;        }    }}// 鍐欏叆璁块棶鏃ュ織$fp = fopen($log_file, 'a');fwrite($fp, time() . "\n");fclose($fp);// 鍒ゆ柇璁块棶棰戠巼if ($count > 10) {    exit('绂佹閲囬泦锛');}

    鍥剧墖楠岃瘉鐮侊細鍦ㄥ叧閿〉闈㈡垨鑰呮搷浣滀笂娣诲姞鍥剧墖楠岃瘉鐮侊紝瑕佹眰鐢ㄦ埛杈撳叆楠岃瘉鐮佹墠鑳界户缁搷浣溿
[backcolor=rgba(0,0,0,var(--tw-bg-opacity))][color=rgba(217,217,227,var(--tw-text-opacity))][backcolor=rgba(52,53,65,var(--tw-bg-opacity))][size=0.75]phpCopy code
session_start();$code = ''; // 楠岃瘉鐮$width = 80; // 鍥剧墖瀹藉害$height = 30; // 鍥剧墖楂樺害$font_size = 16; // 瀛椾綋澶у皬$font_file = 'arial.ttf'; // 瀛椾綋鏂囦欢璺緞$code_length = 4; // 楠岃瘉鐮侀暱搴// 鐢熸垚闅忔満楠岃瘉鐮乫or ($i = 0; $i < $code_length; $i++) {    $code .= chr(rand(97, 122));}// 灏嗛獙璇佺爜淇濆瓨鍒 session 涓$_SESSION['code'] = $code;// 鍒涘缓鍥惧儚$image = imagecreatetruecolor($width, $height);// 璁剧疆鑳屾櫙棰滆壊$bg_color = imagecolorallocate($image, 255, 255, 255);imagefill($image, 0, 0, $bg_color);// 璁剧疆鏂囨湰棰滆壊$text_color = imagecolorallocate($image, 0, 0, 0);// 娣诲姞楠岃瘉鐮佹枃鏈琲magettftext($image, $font_size, 0, 10, $height / 2 + $font_size / 2, $text_color, $font_file, $
dz插件网 版权所有 @ 2020-2024