Stop bad bots from crawling your website

Stop bad bots from crawling your website

If you are experiencing performance issues with your site one of the reasons could be your Bandwidth is getting unnecessarily utilised by some bad bots. This article explains what are bad bots, how to identify them and how to stop bad bots crawling your website so that your genuine visitors are not affected. What are bad bots upto? There are quite a number of bad bots operating and the number keeps increasing rapidly. Most of them are from hackers trying to find some vulnerability in your code. They may be trying to get credit card numbers from an online store or may be scraping the text off an article and posting it on some random blog. They may also want to steal username and passwords of peole on your database hoping people use same credentials elsewhere which surprisingly they do. Some may just want to post spam comments on your website. How to stop bad bots from crawling your website Bots are supposed to obey the rules within...
Read More
Server load monitoring tools for your wordpress site

Server load monitoring tools for your wordpress site

Here are some basic tools which will allow you to monitor server load to keep your wordpress site optimised. Uptime (shell command) [crayon-59e6eb28d90e2272801936/] Above command is an example of the uptime command. It says the server is up since 364 days, 2 users are logged in and the rest of the numbers are showing the server average load. The three numbers show the load averages for the last minute, 5 minutes and 15 minutes. If you have 4 CPUs and the load is 2 then your server is using half the CPU capacity. If you have 2 CPUs and the load is 2 then your server CPU is running at full capacity. A load above the number of CPUs means that the system is overloaded which reduces performance. top (shell command) [crayon-59e6eb28d90eb128183964/] top command shows information like tasks, memory, cpu and swap. Here is a sample output of the top command. PHP sys_getloadavg function [crayon-59e6eb28d90f0736849515/] sys_getloadavg function returns an array. In above code, $load[0] would be the server load value. Based on the above code we...
Read More

WordPress vulnerability – Bypass any password protected post

Wordpress has just released a new update version 4.5.3 which is mainly a security release fixing a major security issue present in all the previous wordpress versions. It is strongly recommends to update your sites immediately to the latest version. This vulnerability allows an attacker to gain access to password protected posts in wordpress. This vulnerability is high in case of wordpress installations with open registrations. Wordfence, a popular wordpress security plugin disclosed this vulnerability to wordpress on 3rd May...
Read More
How to prevent WordPress CSRF attack

How to prevent WordPress CSRF attack

Wordpress CSRF attack happens the same way as it happens on other sites. Wordpress provides some inbuilt tools to protect against CSRF. We will see how to make use of these tools while creating our own wordpress plugins. What is CSRF ? CSRF meansCross-Site Request Forgery (CSRF). It is a type of attack that occurs when a malicious web site, email, blog, instant message, or program causes a user's web browser to perform an unwanted action on a trusted site for which the user is currently authenticated. How does it happen ? For e.g. if you have a form on your website and you haven't protected it for CSRF attacks then a hacker can create a similar form elsewhere and trick one of your users to submit the form. This means the hacker can fill any values in the form. The damage depends on the functioning of the form. How to prevent CSRF In short, to prevent CSRF attack all we need to do is to check if...
Read More
Show custom field validation errors in WordPress Admin

Show custom field validation errors in WordPress Admin

If you are creating your own custom post type in wordpress and you use some custom fields to store data related to each post. For e.g. if you create a custom post for events then you would store data like event start date, end date, address, etc within custom fields. Unless all the all required custom fields are filled you do not want to publish the event and so you would want to warn the event editor about it. Wordpress admin_notices hook allows to achieve this very easily [crayon-59e6eb28d961f903940992/] admin_notices is the hook available to display the messages add_settings_error - Registers the setting error to be displayed to the user settings_errors - This function simply displays all the errors line by line...
Read More
Setup wordpress cron jobs and debug methods

Setup wordpress cron jobs and debug methods

Why would you need to setup Wordpress cron jobs ? Cron jobs in Wordpress can be set for following reasons You have a custom post type for events and you wish to archive all your old events at regular intervals Archive logs e.g. if you have some plugin which tracks user activity then you may want to archive the logs table at regular intervals If you have integrated wordpress with some external application e.g. a mailing server then you need to synchronise your mailing lists with the external server Clearing caches for certain pages How to setup wordpress cron jobs wp_schedule_event is the function used to set up wordpress cron jobs Here's a sample code to set up a cron job [crayon-59e6eb28d983d964579952/] The above code will execute the function wpi_some_cron_job on daily basis. Some of the other options are hourly, twicedaily Now the question is where do we add the above code. The answer to this depends whether you want to set this up as part of your own...
Read More
Selectively exclude pages from being cached in W3 Total Cache

Selectively exclude pages from being cached in W3 Total Cache

You may want to exclude some dynamic pages from being cached in W3 Total cache. To exclude a particular page from caching, W3 Total cache just needs below line of code on that page before the html  start tag [crayon-59e6eb28da09d458605465/] For this code to appear on such pages all you need to do is to create some custom field e.g. nocache Just add this custom field to the post/page you want to exclude from caching and set the value to 1 In your header.php add below lines above the html tag [crayon-59e6eb28da0a5838579160/] Other w3total cache options Disable database caching => DONOTCACHEDB Disable minify => DONOTMINIFY Disable CDN (Content Delivery Network) => DONOTCDN Disable Object Caching => DONOTCACHCEOBJECT ...
Read More
Sendgrid Contacts API  Examples

Sendgrid Contacts API Examples

If you are using Sendgrid to send your Marketing / Promotional emails then using the Sendgrid Contacts API can automate quite a few things for you. Here are some simple API examples to add/remove/edit recipients to the Sendgrid Contacts Database and synchronising the Sendgrid lists with the Wordpress mailing lists. There are 2 ways to synchronise your mailing lists in wordpress with the Sendgrid lists. One is using the daily/weekly cron job and the other is through real time i.e. an on demand system. Obviously we all would prefer the real time system. However it largely depends on how you handle your subscription process in Wordpress. If you have created your own subscription system then you are either storing the contacts in your own table or you are using the Wordpress usermeta table. API can be called by making the necessary changes in your system. Synchronisation of the mailing lists in that case can be done in real time. If you are using some plugin...
Read More
Offsite data storage for Disaster Recovery

Offsite data storage for Disaster Recovery

Offsite data storage for your website means copying your database, code, media and other files to a remote server so that in case of any disaster the server can be rebuilt using the data available on the remote server. Copying your database and code backups and other files like images, etc to a remote/offsite server can be done for various reasons. It is mostly done for 2 reasons. Preparing for Disaster Recover where the server can be rebuild using the data from offsite data storage Redundancy (when the live server stops due to some reason, the remote server can take over) Although below steps can work in both the cases, this particular article is written with a viewpoint of understanding how to setup an offsite data storage for Distaster Recovery. For preparing disaster recovery the remote server should ideally follow below criteria Backup server requirements The hosting provider should be different to your live/production server The hosting server should be in a different location to your live/production server Bandwidth may not be a crucial...
Read More
12