PHP check if search engine bot

How do you check if your website is being crawled by a bot or spider, or in case you want to expose a certain section or sections of your website to the search engines which otherwise would be hidden from them as they are protected resources.

First of all, you have to know the bots or spiders that exist in horizon

You can get the list of search engine bots/spiders and the user agents from the links below

http://www.robotstxt.org/db.html 

https://github.com/monperrus/crawler-user-agents/blob/master/crawler-user-agents.json

Now to the main part, how do we detect them

Most of the logic can be as simple as distinctly recognizing the User Agent

Here is a function that I use most of the time,

You can then simply call the above function as

This is the simplest way you can answer a question as to how to detect search engine/bots/spiders visits on my site

I hope this helps you to detect crawlers with PHP.

Best,

Ionic 2+ How to access parent navController

There could potentially be scenarios when you will have something like this [crayon-5a153a6917fbc394327773/] Each of ion-nav components have their own NavController, when you try to push or pop a view, depending on the inheritance level of your … [Continue reading]

PHP: Check if Start of each word in a sentence is uppercase or any part of a word is UPPERCASE

When working with strings, occasionally we would want to check if any part of a word is uppercase or start of a word is an uppercase letter. This post provide a generic function that can be extended to match your needs. For this post I will use … [Continue reading]

How to convert a string to equivalent integer value based on ASCII codes in Javascript

Hi Guys, Here is a quick tip if you would like to convert a string into a sum of ASCII codes for all characters Function you can use For ES5: [crayon-5a153a6918dc2207830763/] We can do equivalent in ES6 … [Continue reading]

Hunspell with PHP on Windows – Part 1

Ok so I hear you saying, how the hell can I use Hunspell and PHP with Windows, Now the way I am going to show you isn't the only way but is a much simpler way without compiling and using binaries. What is Hunspell? Well I can re-write what's … [Continue reading]

PHP Start of the day and End of the day for a timezone Util functions

This is a quick post where I am sharing a couple of functions to calculate start of a given day and end of the day for a given timezone Start of the day [crayon-5a153a6919be8184395164/] End of the … [Continue reading]

[Solved] bootbox.js show ajax html data inside the dialog

Hi Guys Just a quick one here if you are using a library called bootbox.js in your project. This library does not make ajax request automatically if you wish to load some data from your server to show within your dialog window. Instead, you can do … [Continue reading]

Project Data Sources: re-sync required – Upgrading to PhpStorm 10.0.2

Hey Guys, While I upgraded to PHPStorm 10.0.2 and restarted it, I got this message at the top right corner of this IDE Project Data Sources: re-sync required Unsupported format version 2.2 - (2.4 expected) While that got me puzzled for a … [Continue reading]

How to get Pinterest Numeric Board ID

Get Pinterest Numerci board ID

Hi Guys, It used to be easy to get Pinterest board ID before, but for some reason they have buried that sort of information within source, A while back I wrote something that wouldn't use the Pinterest official/unofficial API but parse the HTML … [Continue reading]

Free Clock Animation GIFs

Clock animation 15 minute interval

Hi Guys, While I was working on a project I need a couple of GIFs for Clock animations. I came up with these. You can use it in your commercial or free websites etc. Attribution or link to this page would be appreciated though :) Here are a … [Continue reading]