Another JSON decode function for PHP

C-4 Systems

JSON or JavaScript Object Notation is a lightweight method of sending and receiving data over the web. Web services, ajax applications, cloud computing, and mobile platforms all use JSON-formatted data, so being able to read this kind of data is very important to reap full benefits from these services.

If you are a user of PHP 5.2+, the 'json_decode' is available to you as a standard PHP function. However, if you are running a old version of PHP or if want your PHP application to be backward compatible with PHP4 – PHP 5.1, you will need to add this function to your application.

Here is a little script that converts JSON data into a PHP object or associative array that you can use.

/**
 * Convert simple JSON data into a PHP object (default) or associative 
 *   array. Emulates 'json_decode' function from PHP 5.2+ 
 * @author: Helene D. 
 * @param string,boolean
 * @return (array or object)
 */
if (!function_exists('json_decode')) {
      function json_decode($json,$to_array=false) {
            $x=false;
            if (!empty($json) && strpos($json,'{"')!==false) {
                  $out = '$x='.str_replace(array('{','":','}'),array('array(','"=>',')'),$json);                  eval($out.';');
                  if (!$to_array) $x = (object) $x;
            }
            return $x;
      }
}

Texting from Email to Phone

How to Send a Text Message from Email

SMS test

There may come a time when you find that you need to send a text message, but your mobile phone is not available. Perhaps you left it at home, misplaced it, forgot to recharge the battery, or you exceeded their plan's allotted number of texts. Fortunately, if you have access to email and the internet, there is an easy way you can still send a text message

To send a text message from any email client, address the email to the phone number at the SMS gateway for the mobile phone carrier. An SMS gateway is a dedicated server that transforms and transmits message traffic from the internet to a mobile network and provides a way to send a text message with or without using a mobile phone. Emails sent through an SMS Gateway are received as text messages on a phone**. The format for recipient's email address is made up of the telephone number as username and the phone provider's mobile SMS gateway address as the domain, i.e. phoneNumber@SMSgateway.com.

***Note: a few phones may see the SMS text as email. Continue reading

Seamless WassUp Upgrades

Precautionary Steps for a Seamless WassUp Upgrade

WassUp Screenshot
In the newest WassUp WordPress plugin update (v.1.8.1), there is a precautionary notice about upgrading. This notice says that you should not upgrade if your site is busy. That is, you should check the number of current visitors online before upgrading and, if there are more than one regular visitors or multiple spiders online, don't upgrade!!

WassUp is different from most plugins because once it is enabled it starts working and never stops until it is disabled, deactivated or your site goes down. Every visitor click, every spider hit, every search, and every feed request triggers WassUp to write data into it's tables. The more popular your site is, the more data WassUp has to write in order to track visitors browsing your site.

An upgrade during a busy time for your site increases the odds that WassUp will be interrupted in the middle of a write operation. That kind of interruption can cause file corruption or can leave a permanent lock on WassUp tables. Continue reading

WassUp Works Well with WP Widget Cache

WassUp users looking for ways to speed up their site or blog should try WP Widget Cache plugin.

WP Widget Cache plays nicely with Wassup because it caches only the widgets on a page and does not affect other code in the document. It caches sidebar and footer widgets and allows you to customize cache settings for each widget individually. According to the author, you can achieve up 70% improvement in your site’s performance with this plugin. After installing it on my own blog and setting a cache timeout of 24 hours (86400 seconds) on all static widgets, I saw a impressive improvement in load speed, myself. Continue reading

CTRL+Z Undo: The Keyboard Shortcut You Can’t Do Without

There is one keyboard shortcut that everyone should know about: the universal UNDO keyboard sequence: CTRL+Z (Command+Z on the Mac).

Keyboard left keys

CTRL+Z ([CTRL]-key and Z-key pressed at the same time) undoes your previous edit. Multiple CTRL+Z's will undo multiple edits and can even restore a document to an older revision, if it was changed during the same session. It works in almost every application…text editors, graphics editors, and even in games.

I thought it was a no-brainer that everyone knew about CTRL+Z until I had a recent encounter with a young relative who was struggling to recreate a project that she had accidentally erased before saving. A few “command+Z”s (on MacBook) and the document was back and I was a hero. Continue reading