PHP: Crawl Detect

Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)

The code used for index.php is below:


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="../styles.css">
    <title>PHP: Crawl Detect</title>
</head>
<body>

<h1 class="lesson-h1">PHP: Crawl Detect</h1>

<?php
$useragent = $_SERVER['HTTP_USER_AGENT'];

echo $useragent;

if(stripos($useragent, "Chrome")){
    //if found create file to store info
    $file = fopen("crawled.txt", "a");
    fwrite($file, "You've Been Crawled\n");
}

include('../show_code.php');
show_code('index.php');
show_code('crawled.txt');
?>    
</body>
</html>

The code used for crawled.txt is below:


You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled
You've Been Crawled