Thursday 30 October 2014

Wordpress spam users are clogging my site !

Share |

Wordpress spam users registering in huge numbers

You have your wordpress site launched, and all is going well. But browsing around one day, you realised that your user list has been growing exponentially. Moreover, the user names and email addresses look somewhat... not so right.

You may be a target of spam bots.

Such spam machines target public wordpress sites, registering themselves as fictitious users, some up to even 1000's of users a site per day. This creates a big headache and lots of tedious maintenance work for site administrators.

Why Spammers do this:

Spammers have more than a few reasons for doing this,
  • creating spam content on the web to deliver on their own motives
  • exploiting wordpress vulnerabilities
  • other malicious intent to demote, and otherwise negatively affect target sites

 

How you suffer:

Target sites of attack then suffer from a variety of consequences, some potentially very bad,
  • Unsolicited wordpress comments with possibly lots of unwanted hyperlinks
  • Negative effects on SEO
  • May even lead to blacklisting of your email server (because your site sends emails to these fictitious users who sign up, which then bounce)
  • slows down your database with useless data

 

What you can do: 

Basically its always easier to implement counter measures early at the start, before the spammers find your site. Otherwise you will be tasked with the tedious work of cleaning up fictitious users and their comments.

Non-Membership sites: 

For non-membership websites, the answer is simple. We can simply disable new user registrations via the wordpress admin.

uncheck anyone can register option
Uncheck "anyone can register" option!

Membership sites: 

For those with membership sites, it is a little more tricky. It is not the end though, as there are many tools out there to help. This is a constant evolving game between the spammers and site administrators though, because with every ingenious solution, comes new attack methods developed by spammers to counter your moves - and the cycle continues.

As a side note, I suggest never to give newly registered users a default role anything higher than "subscriber". 

An article by Cozmoslabs proposes several solutions.
  1. Install plugins to introduce CAPTCHA to your registration form:

  2. I personally do not really like this approach, as the solution only addresses the site administrators' issue. It does not add value to the user, and in fact makes his form harder to fill.

  3. Custom redirect to another registration form instead of Wordpress' default form:

  4. I think this is an interesting solution worth exploring. You can direct the user to your own customized form that is aligned with your site brand image. The different URL and form elements should make it more challenging for automated bots.

  5. Registration confirmation via Email:

  6. Meaning users will receive an email upon registering. They then need to activate their account to prove that they are a human and not a bot.

    I think this is quite a neat feature, as it is a common approach in many mainstream sites. Users know what to expect. They have an extra step of activating through their email though.
The final choice is yours, depending on your individual needs.

You can find their article here.


Friday 3 October 2014

My computer screen / display monitor text is blur and fuzzy !

Share |

How to ensure your computer display is as SHARP as possible

Note: My post is based on a LCD monitor and laptop setup, with VGA wire connection. This post is not meant to cater for every possible setup out there, but as a general guide on how to optimize the display clarity with what existing software and hardware that you have. We do not attempt to cover smartphones, TV, and other devices here.


Many times we want the best for our eyes, as they are indeed a very great asset. However in the modern cities, we are spending more and more hours in front of a screen, whether from smartphones, laptops, TV, and other devices. Below are some tips you can try to make the best of your situation.

Hardware Tips
  1. Ensure that you have a good quality wire connecting your computer/laptop to your monitor. This usually means wires that are thicker, and with bigger ferrite beads - sometimes also called ferrite chokes. This will minimize electronic interference.

    Ferrite beads or Ferrite chokes


  2. Your monitor usually comes with some buttons to configure its settings. Don't stick to manufacturer's default! Make the best of it.
Monitor display hardware settings

My recommended settings are:
- Set contrast to high (70~80%). This increases the difference between dark and bright things on the display, and hence makes things appear sharper, and thus less strain to the eyes.

- Set brightness to low (about 30%) . Many people confuse this by setting it to a very high setting, thinking that it should make the screen clearer. In fact, with today's LCD/LED monitors, they are able to display too much brightness for our eyes in my opinion, unless you work outdoors in the sun. For most of us office go-ers, its fine. This goes hand-in-hand with the contrast setting above.

- Angle the monitor so that reflected ambient light ie. the ceiling light, does not interfere with what you are trying to see.

- For users with the older VGA connectors, use the monitor's auto adjust feature to calibrate the details like frequency clock, phase etc as the auto detection usually works well.
VGA connector

- For our better off counterparts who use the newer DVI connectors, there won't be this auto adjust feature available.
DVI connector



Software Tips
  1. Sometimes in Advanced settings, you will be able to adjust the settings that come with your graphic cards and its particular drivers. The configuration here really depends on your setup which i will not elaborate on. The key is to try different settings, like graphics hardware acceleration etc to see what works for you.
  2. Clear-type settings: With Windows 7, they introduced ClearType technology. It was meant to make text sharper and easier to read. This was not the case however, as many users on the web complained about blur screens. 
    • I wrote about this in another blog post. I believe this has got to do with the quality of your display, and whether it is able to display the smooth font gradients as required. Otherwise, this technology can backfire on unsuspecting users who upgraded to Windows 7. I suggest to play around with the settings to see which way appears clearer for you.

    ClearType Technology. Makes things worse?

  3. Adjust the OS display settings to the native monitor resolution. Which means, make the OS display in settings that the monitor was manufactured for. This will give best results.   
  4. Chrome settings: Depending on which software you use the most in your everyday work, the specific software settings if mis-configured can really take its toil on the eyes. Recently, Chrome introduced ClearType as well in a recent version upgrade. This made many users upset. If you are experiencing blur text suddenly, do check out their bug report for a solution.

    For me, it worked by switching off "direct write" via a little known setting. Just enter chrome://flags/#disable-direct-write directly into your chrome URL bar. And toggle it off.
Turn DirectWrite OFF

Have other suggestions? Found a way? Tell us in the blog comments.


Sunday 14 September 2014

Retrieve back lost emails in Contact Form 7 Wordpress plugin

Share |

Make Contact Form send emails and recover those that were .... lost ....


Note: This write up is for users of wordpress plugin Contact Form 7, who are looking to retrieve back their lost emails that did not send out from their website. The aim is not to tackle how to make the plugin send emails to your desired account successfully which have already been tackled in many other blogs. 

Recently I had a client using the popular wordpress plugin Contact Form 7. His complaint was that he has not been receiving emails from the form for quite a while. And this has been happening for a couple of months. Since this form was a source of business revenue, it sure was not only an important problem so to speak, but an expensive one as well.

Investigating, I dived into the plugin settings. First i tested it with a neutral email recipient like gmail. That seemed to work. Setting it back to our domain's email address or my clients' preferred account however just did not receive anything. Something was fishy.

Contacting the hosting provider gave some clues on what was happening. Apparently some user on our shared hosting plan was sending out spam, causing the whole mail server to get on the spam blacklist. How come we get penalized for this i'm really not sure. I thought they were supposed to take care and prevent such problems...

As you know, waiting for them to react and rectify usually takes time. I had to fix it now.
Setting wordpress to use an external smtp server did the trick.

The lost business opportunities however kept bugging me. After-all this form was for potential business clients to express interest, so it meant money.

I searched for the email logs, they had to be somewhere.
Searching high and low, and I finally found them.

Go to Cpanel -> File Manager.
In the root folder, look for Mail folder -> New.
Hope you find something here, because i found several of the "lost" emails, together with mentions of error and rejection messages. Ouch...

Find Email Logs in Cpanel







Overview of my attempts:
1. Tried to set Contact Form 7 to send forms to my Gmail account. (works)

2. Tried to set Contact Form 7 to send forms to host domain email address, which is the domain where wordpress was installed. (dosen't work)

3. Contacted the hosting provider. (was told that because i was on a shared hosting plan, the mail ip was blacklisted due to some spammer)

4. I set wordpress to send email from my specified smtp server. (finally it works)

5. Put in place some anti spam measures.

6. And now that settles things for the time being. But the lost business kept haunting me.
Went to dig for Cpanel email logs.

7. Found them in Root - > Mail - > New

Useful links for those with email problems:
http://buzztone.com.au/contact-form-7-email-issues/#spam
http://contactform7.com/faq/

Disclaimer: Due to the multiple factors that can cause email problems, the solution presented here is meant to be an avenue of possible help, and cannot promise more than this. Feel free to post comments/questions though.

Sunday 7 September 2014

Find out who is using my Wordpress theme

Share |


Recently I needed to find out how other websites were also using my Wordpress theme of choice. I did not seem to find many tools out there to accomplish this. So i developed one here. This is still in prototype.


Friday 4 July 2014

Add check out time validation in WooCommerce - for delivery or otherwise

Share |

Adding a shipping delivery time check to WooCommerce Plugin - Server side validation


Suppose an online store wants to restrict delivery timings of its online goods. not just in terms of the days that delivery is available, but down to the timings. For example, if catering company ABC only delivers from 8am to 5pm on weekdays, and 4pm to 10pm on weekends.

The extension I happily bought seemed to have many good features. till I realized that it did not have a time slot option. It was disappointing at first, but I thought what the heck, I will hack it myself. So my journey begins.

The date picker extension uses a typical date time picker from jQuery in the front end. So I thought, since its a hack, lets modify this.

jQuery date picker, with Mondays disabled.

Looking in the javascript files, I found just the code that validates this date picker. I realized I would need to add logic to validate the time chosen according to the day of the week, followed by updates to the UI. After spending quite some time (longer than I expected) toying with the script, I managed to do something like this in pseudo code:


if (its a weekday & user selected delivery time between 8am-5pm)
    accept input, otherwise throw validation error and disable the Done button.
else if (its a weekend & user selected delivery time between 4pm to 10pm)
    accept input, otherwise also throw validation error
and disable the Done button.

Then I updated the UI to display the validation as a red error text, and disabled the "Done" button.

I then thought all was good, but well the UI came back to haunt me with issues. For example, the date picker does not work in certain browsers that don't support it for whatever reason, and the user can still enter the wrong time manually into the text field.

In the end, its back to server side validation that saves the day.

jQuery date picker, with validation message and disabled "Done" button

To do server side validation:

 

Create a WooCommerce child theme before editing. I would not elaborate here on how as its implementation is easily available online.
1.  Add a new method to the functions.php file in your WooCommerce template folder. This will validate the delivery time text field, and display the error messages nicely at the top when the user clicks Pay.

//add action hook
   add_action('woocommerce_checkout_process', 'my_custom_checkout_field_process');

//new method
   function my_custom_checkout_field_process() {
       global $woocommerce;
        
      $delvTime = $_POST['delivery_time'];   //store user input to variable
  
      $day = date('w', strtotime($delvTime));  //split and store into more variables
      $hour = date('H', strtotime($delvTime));
      $min = date('i', strtotime($delvTime));
     
      //logic for allowed delivery time starts here  

      //if weekday
      if($day>=1 && $day <=5) {
        if(timing is correct)
            return;      
        else
            $woocommerce->add_error( __("Sorry, our weekday delivery hours are between 8am to 5pm only.") );     
      }


      //if weekend    
      if($day==6 || $day==0) {
         if(timing is correct)
            return;
         else
            $woocommerce->add_error( __("Sorry, our weekend delivery hours are between 4pm to 10pm only. ") );
      }
   
}

2. Now we want to make the user experience even better by providing users with also a nice display image of a clock with highlighted delivery timings for easy reference (this i created in photoshop), in addition to the traditional plain text instructions. The image below is just an example.

Find the extension's template file to add the image to the code (delivery-time.php if you use my chosen extension).

Tip: you can try looking for the method that displays the timing text field.

Wall clock display with highlighted delivery timings

3. Now this would not be complete if the chosen delivery timings did not appear in the emails sent would it?

Therefore we edit the email template that is sent to the store admin, and also the one sent to the buyer, for everyone's easy reference. Look in the WooCommerce templates->email folder.

Edit admin-new-order.php and customer-processing-order.php to add our new delivery times. We have php tags here because there is a mixture of html.
//if there is user input, save it
<?php if ( $delivery_time = get_post_meta( $order->id, '_delivery_time', true ) ) : ?>
    <?php
    $option = get_option( 'wdt' );
    $label = isset( $option['label'] ) ? $option['label'] : __( 'Delivery Time', 'woocommerce' );
    ?>

//display the time chosen
    <p><strong><?php echo "Delivery Time"; ?></strong> <?php echo gmdate("F j, Y, g:i a", $delivery_time);?></p>
<?php endif; ?>
You can add the same code to both files, in the line according to where you would like the time to appear in the email.

4. If everything works without compilation errors, presto we are done in just a few steps. Of course, test it out to make sure.

What was used in this post:
  • WooCommerce Plugin
  • WooCommerce Delivery Time Picker for Shipping
  • Adobe Photoshop

Tuesday 21 January 2014

Display text blurry or fuzzy in Windows 7

Share |

Windows 7 display is not sharp, especially when reading text

One particular day when I upgraded to a new laptop installed with windows 7 and a new external monitor, I was surprised to find that the screen seemed blurry or basically not sharp,  unlike my trusted windows xp in the past (almost like a soft filter from photoshop was permanently applied). It was giving me an eye-strain at the end of every work day, pretty painful to me compared to my previous laptop.

I picked out 3 possibilities as the cause. Either the screen was at fault, the OS was at fault, or the graphics card was the cause.

Things I tried... Used a hdmi cable instead of vga. Nope.
Tried calibrating my external monitors and even trying another. Nope.
This left the OS and graphics card in question.

Switching the graphics card was a troublesome affair compared to the former, so I digged into the OS settings. In windows 7 Control panel-> Display properties, what I found was a little new feature that was previously unknown to me.

This new animal called "ClearType" claimed to make text sharper and clearer.
Using the tuner however did not really satisfy me.
In the end, I resorted to switching this "new" feature off totally.

Now my text is "sharp" like in windows xp, just the way I like it.
Maybe it is not as smooth, but I rather it stay comfortable for my eyes rather than keeping it pretty.





http://techdows.com/wp-content/uploads/2011/10/ClearType-Text-Tuner-in-Windows-7.png
The harmless looking ClearType feature