Netgear DG834N dead WiFi

The problem began when both the green WiFi light on the DG834N (v1) ADSL/router stopped functioning and the ability to see the SSID being broadcast ceased. It seemed nothing had changed and during transport from one location to another it had simply died.

To begin with I flashed the latest firmware to the device. It is really important to do this via a wired connection to these devices; often if you perform the operation via wireless the upload of the firmware partially fails and the device ends up becoming a brick. You have been warned!

With new firmware I rebooted the device and at this point the WiFi light turned green. I congratulated myself and expected to find the SSID being broadcast as per normal. It was not to be however, and many hours were about to be spent solving the problem.

I tried many resets – including a hard reset. To perform a hard reset hold the reset button in for 20 seconds with power, continuing to hold the reset button but remove the power for 20 seconds, and finally connect the power while still holding in the reset button. So: 60 seconds holding in the reset button, 20 powered, 20 unpowered, 20 powered. If this reset works properly the power LED will flash between red and green.

After a phenomenal amount of searching the internet I found a few clues to the issue and eventually solved it.

The WiFi component on this model is a plug in module that can sometimes become loose. Open the case, pull the module out, and re-insert firmly. The module is instantly recognisable by the two antenna wires that attach to it.
Note: There are two torx screws that need to be removed underneath at the base and also two underneath the large sticker label at the rear of the unit.

The future:
Apparently the chipset on this model is notorious for heat generation eventually leading to failure. A future mod for this device could be using a dremel to carve out a hole in the chasis and subsequently add a fan to improve airflow.
With the simple plug in antenna arrangement these could also be replaced; however I have had no issues with WiFi performance.
The power supply that comes with these devices are also reputed to be quite underpowered. Mine seemed quite heavy duty so I dont think I will need to replace it unless the addition of a fan increases the current draw too much.

Netgear DG834N dead WiFi Read More »

PHP Arrays

Recently I had to refactor a few quite old CRON jobs which made extensive use of arrays within loops.

As usual with old code I had to brush up a little as a reminder so thought I would summarise a few quick notes:

sort() and rsort() are for sorting indexed arrays
asort() and arsort() are for sorting associative arrays
ksort() and krsort() are for sorting associative arrays by key
array_multisort() is for sorting multiple related arrays and multidimensional arrays

The PHP sort() function sorts values contained within an indexed array in ascending order.
This means that A-Z, and 0-9. Uppercase letters come before lowercase letters, and all letters come before numbers.

$testArray = array( 1, 2, 3, 'a', 'b', 'c', 'A', 'B', 'C' );
sort( $testArray );

// Displays "A B C a b c 1 2 3"
foreach ( $testArray as $value ) echo "$value ";

rsort() works exactly the same as sort(), except that it sorts in descending order.

$testArray = array( 1, 2, 3, 'a', 'b', 'c', 'A', 'B', 'C' );
rsort( $testArray );

// Displays "3 2 1 c b a C B A"
foreach ( $testArray as $value ) echo "$value ";

Sorting associative arrays using asort() and arsort()

sort() and rsort() are great for indexed arrays where you usually do not care about the relationship between keys and values; however with an associative array they can cause problems:

$book = array( "title" => "Lord Of The Rings", "author" => "J.R.R. Tolkien", "year" => 1954 );
sort( $book );

// Displays "Array ( [0] => J.R.R. Tolkien [1] => Lord Of The Rings [3] => 1954 )"
print_r( $book );

As you can see, the sort() function has reindexed the array with numeric indices and in the process destroyed the original string indices of “title”, “author”, and “year”.

To sort values in an associative array whilst preserving keys, use asort() and arsort() instead as these functions preserve not only the keys, but also the relationship between keys and their values.

$book = array( "title" => "Lord Of The Rings", "author" => "J.R.R. Tolkien", "year" => 1954 );
asort( $book );

// Displays "Array ( [author] => J.R.R. Tolkien [title] => Lord Of The Rings [year] => 1954 )"
print_r( $book );

Sorting associative arrays by key using ksort() and krsort()

As well as sorting an associative array by value it can also be sorted by key. ksort() sorts the elements in ascending key order, while krsort() sorts in descending key order.

Just like asort() and arsort() these functions will preserve the relationship between key and value.

$book = array( "title" => "Lord Of The Rings", "author" => "J.R.R. Tolkien", "year" => 1954 );
ksort( $book );

// Displays "Array ( [author] => J.R.R. Tolkien [title] => Lord Of The Rings [year] => 1954 )"
print_r( $book );

krsort( $book );
// Displays "Array ( [year] => 1954 [title] => Lord Of The Rings [author] => J.R.R. Tolkien )"
print_r( $book );

So far, so good, – so lets move onto multidimensional arrays.

Sorting multiple arrays and multidimensional arrays with array_multisort()

The PHP array_multisort() function sorts multiple related arrays in one run whilst preserving the relationships between the arrays, and it can also sort multidimensional arrays.

$directors = array( "James Cameron", "Ethan Cohen", "Christopher Nolan" );
$titles = array( "Aliens", "The Big Lebowski", "Inception" );
$years = array( 1986, 1998, 1973 );

array_multisort( $directors, $titles, $years );

print_r( $directors );
echo "<br />";
print_r( $titles );
echo "<br />";
print_r( $years );
echo "<br />";

Outputs:

Array ( [0] => Christopher Nolan [1] => Ethan Cohen [2] => James Cameron )
Array ( [0] => Inception [1] => The Big Lebowski [2] => Aliens )
Array ( [0] => 2010 [1] => 1998 [2] => 1986 )

Notice how the array_multisort() function has sorted the values in $directors in ascending order and then sorted the other 2 arrays so that the element order matches the order of the sorted $directors array.

Sorting multidimensional arrays

If you pass a multidimensional array to array_multisort() then it sorts by looking at the first element of each nested array.

If 2 elements have the same value then it sorts by the second element, and so on. For example:

$movies = array(
array(
"director" => "Ethan Cohen",
"title" => "The Big Lebowski",
"year" => 1998
),
array(
"director" => "James Cameron",
"title" => "Aliens",
"year" => 1986
),
array(
"director" => "Christopher Nolan",
"title" => "Inception",
"year" => 1973
),
array(
"director" => "James Cameron",
"title" => "Titanic",
"year" => 1997
)
);

array_multisort( $movies );
echo "<pre>";
print_r( $movies );
echo "</pre>";

Outputs:

Array
(

[0] => Array
(
[director] => Christopher Nolan
[title] => Inception
[year] => 1973
)
[1] => Array
(
[director] => Ethan Cohen
[title] => The Big Lebowski
[year] => 1998
)

[2] => Array
(
[director] => James Cameron
[title] => Aliens
[year] => 1986
)

[3] => Array
(
[director] => James Cameron
[title] => Titanic
[year] => 1997
)
)

So as you can see the array sorting functions in PHP are quite powerful and flexible. This brief post only covers a few options, there are more functions if you require them. Here is a great place to start.

PHP Arrays Read More »

Mail, Google Apps, Cpanel, and SPF

Sender Policy Framework (or SPF) is an email validation system designed to addressing source address spoofing. It allows administrators to specify which hosts are allowed to send email from a given domain by creating a specific DNS SPF record in the public DNS. Mail exchangers can then check that mail from a given domain is being sent by a host sanctioned by that domains administrators.

So, after setting up mail from Google apps you’re getting this error:
(IP addresses and domains have been changed to protect the innocent)

SMTP error from remote mail server after RCPT TO:<email@domain.com>:
host something.email.com [127.0.0.1]: 550 <email@domain.com>:
Recipient address rejected: undeliverable address:
host domain.com[127.0.0.1] said: 550-something.email.com [127.0.0.2] is currently not permitted to relay 550-through this server. Perhaps you have not logged into the pop/imap server 550-in the last 30 minutes or do not have SMTP Authentication turned on in your 550 email client. (in reply to RCPT TO command)

You check your DNS records and everything seems to be in order…
You’ve changed your cname for mail to point to Google: ghs.google.com
You’ve changed your MX records for your domain to point to Googles: aspmx.l.google.com etc
You’ve configured your server in Cpanel to act as a Remote Mail Exchanger

For Google to accept your mail server as a relay, you need to enter a line in your DNS zone:
yourdomain.com TXT v=spf1 include:_spf.google.com ~all
(Do not use the built in SPF in Cpanel, and you may need your host to enter this line for you)

A little info is here for Google Support
Background reading in SPF in Wikipedia is here

Mail, Google Apps, Cpanel, and SPF Read More »

Website Analytics Introduction

With the powerful and free solutions available you would have to be crazy not to use website analytics. However for most people analysing the data means little more than viewing the visitor count and informing potential advertisers of the figure.

Used correctly analytics can be much more useful as an error checker, a marketing tool, a usability tool, and an ecommerce tracker. Lets examine some basic ways of getting more out of your analytics.

There are a lot of analytics packages, – personally I find the offering from Google to provide everything necessary. Google Analytics

Bounce Rate
Bounce rate is the number of people who after arriving at your site dont look at another page and leave straight away. This statistic is generally represented as a percentage of your total visitor count.

Make no mistake, bounce rate is very important. A high bounce rate can be an indicator of serious problems with your site. It could be the that your calls to action that are ineffective at engaging your visitors, or worse that your content is lacking.

Common causes of high bounce rates can be:

  • Site errors and broken links
  • Non-engaging content
  • Poorly placed calls to action
  • Poorly targeted advertisments

Conversely a low bounce rate can often illustrate a site that has engaging content that people want to read more of as well as effective ways to draw people in further. For example related content lists or invitations to try a product.

A 30% bounce rate is a good figure to use as a rough guide, whereas over 50% shows room for improvement.

It is important to realise that acceptable bounce rates differ for some types of websites. Blogs often have high bounce rates because people often click through from RSS feeds and tweets to read only that single web page. 60% could be considered a good figure for a site like this, and anywhere from 70% – 80% is ok. Over 80% could be cause for concern.

eCommerce sites are an example of sites that benefit from low bounce rates. They can draw people into investigating other products, reading more content on the site, and potentially making more purchases. Amazon is very good with their suggested items at doing this.

Conversion Rate
The conversion rate is the number of people who fulfill your goal. For an eCommerce site this is generally a completed checkout, for websites that require you to register (Twitter for example) it is completing the sign up form and for a business site it could be a completed enquiry form.

Conversion rate is another percentage, – the amount of people visiting your site that are carrying out the actions you want of them.

If you have a clear path to your goal (e.g. a certain process of clicks), set up a funnel to see where people are falling off. Where are they dropping shopping baskets, and where are they encountering errors on web forms? Overly complex forms are often a barrier to goal completion.

If you do not have a single set path, comparing where people come from to get to your goal pages can be valuable. If people arrive from one page but not another then compare both pages and contrast their differences.

Conversion rates are often surprisingly low; 3% is good conversion rate for completing a transaction on an eCommerce site.

Once you have established why people are or arent completing your goals and have fixed your issues and calls to action, then is time to look at where people are going after converting. Are they staying on your site or exiting? If they are exiting, then perhaps you are missing opportunity to upsell.

Percentage of visitors viewing target pages
Tracking target pages is similar to tracking conversions however these stats offer different values.

For example consider a conversion page being a completed checkout page.

Target pages could be an information page for a business site, or an individual post for a blog.

In most cases pages such as these are the first steps towards goal completion. Viewing a product is generally required prior to completing a checkout and viewing a business service is the first step to getting in touch to ask about that service.

It starts to become clear where a strongly defined funnel can really help to benefit your analytics. If people are getting to these information pages and not completeing a conversion, consider where they are getting lost.

Examine searches and post search actions
Tracking site search is something very few people tend to do, overlooking a valuable resource for finding out what your visitors actually want.

To illustrate if the search results revealed people searching for an item that was not stocked it would make sense to start stocking that item or offer substitutes.

Post search actions can have two results

The search reveals the item

The user goes to the relevant page and remains on your site.
or
The user doesnt go to the relevant page, revealing a problem with the search results. It may not be returning the results it should be, or perhaps the search results are not displayed in a way the visitor can understand.

The search does not reveal the item
Do not let these visitors leave if possible
The “Did you mean” search suggestions on sites like Amazon and Google are great examples of turning a negative into a positive with search results by offering alternatives to keep your users from leaving.

Site search reveals what your visitors want, – without it even being necessary to ask!

Website Analytics Introduction Read More »

Embedding Google Maps in WordPress

Wordpress Logo

According to the support on the WordPress site here embedding GoogleMaps in WordPress is simply a matter of cutting and pasting the Iframe to your post. Simple! Effective? Not so much!

The problem is that if you use the Visual instead of the HTML Post or Page editors the code can get very messed up which is frustrating to say the least. So, a simple and elegant solution:

In your functions.php or custom_functions.php file (for your relevant theme of course) place the following code

//GoogleMaps Shortcode
function googleMaps($attribs, $content = null) {
extract(shortcode_atts(array(
"width" => '640',
"height" => '480',
"src" => ''
), $attribs));
return '<iframe width="''.$width.''" height="'.$height.'" scrolling="no" frameborder="0" marginwidth="0" marginheight="0" src="'.$src.'&output=embed"></iframe>';
}
add_shortcode("googlemap", "googleMaps");

Usage within a Page or Post
[googlemap width="200" height="200" src="YOUR_URL_HERE"]

So there are three parameters for our custom shortcode: width and height are optional – if you do not specify the size will default to that specified in the functions.php file. The URL is simply the GoogleMaps share URL.

Update 25/09/2012 – Clarified a few typos where WordPress has messed with the character encoding.

Embedding Google Maps in WordPress Read More »

SEO Keywords and Tags

We had a client today with a triple figure for keywords. Guess what? Less can be more!

A few tips on selecting relevant keywords:

  • neither too general, nor too specific
  • in common usage
  • relevant to the site in question

General keywords will be competing against millions of other search results, while becoming too specific will attract better searches, – there will be less of them. Finding the balance is our goal here.

People tend to search in two to four word phrases, (single word searches are very uncommon) so make your keywords realistic.

Keyword placement

Dont limit yourself to the document body text, remember:

  • headline text (H1, H2, etc)
  • header tags: title, meta
  • HTML comments
  • URLs and links
  • image ALT tags

This barely scratches the surface of this subject, – what else can you add to it?

SEO Keywords and Tags Read More »