<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Robert Mullaney&#039;s Blog</title>
	<atom:link href="http://www.robertmullaney.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.robertmullaney.com</link>
	<description>Linux, Apache, MySQL, PHP, HTML, CSS, jQuery, CodeIgniter and More!</description>
	<lastBuildDate>Thu, 09 May 2013 17:24:06 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Automatically expand textarea to fit content using jQuery without autogrow or autosize plugins</title>
		<link>http://www.robertmullaney.com/2013/05/09/automatically-expand-textarea-jquery-without-autogrow-autosize-plugins/</link>
		<comments>http://www.robertmullaney.com/2013/05/09/automatically-expand-textarea-jquery-without-autogrow-autosize-plugins/#comments</comments>
		<pubDate>Thu, 09 May 2013 17:21:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[manipulation]]></category>

		<guid isPermaLink="false">http://www.robertmullaney.com/?p=864</guid>
		<description><![CDATA[I&#8217;m sure there is a more efficient way to do this, but it suited my needs. &#60;script&#62; $(function() {     $('textarea').keyup(function(){         $(this).each(function(index, element) {             $(element).height(element.scrollHeight);         });     }).keyup(); //trigger event to initialize pre-filled textareas }); &#60;/script&#62; Enjoy]]></description>
				<content:encoded><![CDATA[<p>I&#8217;m sure there is a more efficient way to do this, but it suited my needs.</p>
<pre>&lt;script&gt;
$(function() {
    $('textarea').keyup(function(){
        $(this).each(function(index, element) {
            $(element).height(element.scrollHeight);
        });
    }).keyup(); //trigger event to initialize pre-filled textareas
});
&lt;/script&gt;</pre>
<p>Enjoy <img src='http://www.robertmullaney.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.robertmullaney.com/2013/05/09/automatically-expand-textarea-jquery-without-autogrow-autosize-plugins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CodeIgniter: Load View from Database (more or less)</title>
		<link>http://www.robertmullaney.com/2013/05/08/codeigniter-load-view-from-database/</link>
		<comments>http://www.robertmullaney.com/2013/05/08/codeigniter-load-view-from-database/#comments</comments>
		<pubDate>Wed, 08 May 2013 17:40:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[parser]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[views]]></category>

		<guid isPermaLink="false">http://www.robertmullaney.com/?p=856</guid>
		<description><![CDATA[I have seen a few people asking how to load a view from a database (or something other than a physical file in the &#8220;views&#8221; folder). In my particular case, a client wants the ability to edit HTML and TEXT email templates. Without giving them direct access to editing the physical files, I decided to [...]]]></description>
				<content:encoded><![CDATA[<p>I have seen a few people asking how to load a view from a database (or something other than a physical file in the &#8220;views&#8221; folder).</p>
<p>In my particular case, a client wants the ability to edit HTML and TEXT email templates. Without giving them direct access to editing the physical files, I decided to move the views being used for email to the database instead.<span id="more-856"></span></p>
<p>Instead of something like this&#8230;</p>
<pre>$data = $this-&gt;db-&gt;get_where('users', array('user_id' =&gt; $user_id), 1)-&gt;row();
$this-&gt;load-&gt;library('email', array('mailtype' =&gt; 'html'));
$this-&gt;email-&gt;from('admin@domain.com');
$this-&gt;email-&gt;to($data-&gt;user_email);
$this-&gt;email-&gt;subject('My Subject');
$this-&gt;email-&gt;message($this-&gt;load-&gt;view('emails/welcome_html', $data, TRUE));
$this-&gt;email-&gt;set_alt_message($this-&gt;load-&gt;view('emails/welcome_text', $data, TRUE));
$this-&gt;email-&gt;send();</pre>
<p>Try something like this&#8230;</p>
<pre>$template = $this-&gt;db-&gt;get_where('email_templates', array('template_key' =&gt; 'user_welcome'), 1)-&gt;row();
$this-&gt;load-&gt;library(array('parser', 'email'));
$this-&gt;email-&gt;initialize(array('mailtype' =&gt; 'html'));
$this-&gt;email-&gt;from('admin@domain.com');
$this-&gt;email-&gt;to($data-&gt;user_email);
$this-&gt;email-&gt;subject($this-&gt;parser-&gt;parse_string($template-&gt;template_subject, $data, TRUE));
$this-&gt;email-&gt;message($this-&gt;parser-&gt;parse_string($template-&gt;template_html, $data, TRUE));
$this-&gt;email-&gt;set_alt_message($this-&gt;parser-&gt;parse_string($template-&gt;template_text, $data, TRUE));
$this-&gt;email-&gt;send();</pre>
<p>Then you can use {curly_braced} items in the resulting email. For instance, if $template-&gt;template_subject was &#8220;Welcome to my site {user_first_name}&#8221; it would arrive to my inbox as &#8220;Welcome to my site Robert!&#8221;. That of course applies to the HTML and TEXT message as well.</p>
<p>Note: You could add some conditions to initialize the email class differently based on whether or not an HTML email message format is available. Thereby negating alt message and HTML format configuration.</p>
<p>Warning: This is not intended for use with batch mode. I am only offering a solution for one-off personalized emails or messages being sent within a loop. While message content can be customized using this method, personalization is not possible when using &#8220;bcc_batch_mode&#8221;</p>
<p>Here is the basic table structure used for this example&#8230;</p>
<pre>CREATE TABLE IF NOT EXISTS `email_templates` (
  `template_key` varchar(32) NOT NULL,
  `template_subject` varchar(255) NOT NULL,
  `template_text` text NOT NULL,
  `template_html` mediumtext NOT NULL,
  PRIMARY KEY (`template_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;</pre>
<p>Feel free to comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.robertmullaney.com/2013/05/08/codeigniter-load-view-from-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Email Delivery Codes: Errors</title>
		<link>http://www.robertmullaney.com/2013/04/24/email-delivery-codes-errors/</link>
		<comments>http://www.robertmullaney.com/2013/04/24/email-delivery-codes-errors/#comments</comments>
		<pubDate>Thu, 25 Apr 2013 01:55:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[errors]]></category>
		<category><![CDATA[stmp]]></category>

		<guid isPermaLink="false">http://www.robertmullaney.com/?p=850</guid>
		<description><![CDATA[Every time when your email cannot be delivered, the SMTP server sends you a notification, which includes a standard error message, associated with the real problem. Each code is composed of three digits (X.X.X). The first digit gives the status of the email message: 2 means the email was successfully sent; 4 means there was [...]]]></description>
				<content:encoded><![CDATA[<p>Every time when your email cannot be delivered, the SMTP server sends you a notification, which includes a standard error message, associated with the real problem. Each code is composed of three digits (X.X.X). The first digit gives the status of the email message:<span id="more-850"></span></p>
<ul>
<li><b>2</b> means the email was <b>successfully sent</b>;</li>
<li><b>4</b> means there was a <b>temporary problem</b> while sending the email (your email server may try to send it again or you have to resend it, depending on your server settings). Such error messages are using codes like 4.X.X, where X.X are used in order to give more precise information about the error;</li>
<li><b>5</b> means there is a <b>permanent/fatal error</b> related to the email (the email address of the receiver does not exist, it doesn&#8217;t accept emails from you, etc). Such error messages are using codes like 5.X.X, where X.X are used in order to give more precise information about the error.</li>
</ul>
<p>Here is a complete list of <b>email delivery error codes</b>, based on the Extended SMTP (ESMTP) standards, where X can be 4 or 5, depending on the error type (Persistent Transient or Permanent):</p>
<ul>
<li>X.1.0 Other address status</li>
<li>X.1.1 Bad destination mailbox address</li>
<li>X.2.0 Bad destination system address</li>
<li>X.1.3 Bad destination mailbox address syntax</li>
<li>X.1.4 Destination mailbox address ambiguous</li>
<li>X.1.5 Destination mailbox address valid</li>
<li>X.1.6 Mailbox has moved</li>
<li>X.1.7 Bad sender&#8217;s mailbox address syntax</li>
<li>X.1.8 Bad sender&#8217;s system address</li>
</ul>
<ul>
<li>X.2.0 Other or undefined mailbox status</li>
<li>X.2.1 Mailbox disabled, not accepting messages</li>
<li>X.2.2 Mailbox full</li>
<li>X.2.3 Message length exceeds administrative limit.</li>
<li>X.2.4 Mailing list expansion problem</li>
</ul>
<ul>
<li>X.3.0 Other or undefined mail system status</li>
<li>X.3.1 Mail system full</li>
<li>X.3.2 System not accepting network messages</li>
<li>X.3.3 System not capable of selected features</li>
<li>X.3.4 Message too big for system</li>
</ul>
<ul>
<li>X.4.0 Other or undefined network or routing status</li>
<li>X.4.1 No answer from host</li>
<li>X.4.2 Bad connection</li>
<li>X.4.3 Routing server failure</li>
<li>X.4.4 Unable to route</li>
<li>X.4.5 Network congestion</li>
<li>X.4.6 Routing loop detected</li>
<li>X.4.7 Delivery time expired</li>
</ul>
<ul>
<li>X.5.0 Other or undefined protocol status</li>
<li>X.5.1 Invalid command</li>
<li>X.5.2 Syntax error</li>
<li>X.5.3 Too many recipients</li>
<li>X.5.4 Invalid command arguments</li>
<li>X.5.5 Wrong protocol version</li>
</ul>
<ul>
<li>X.6.0 Other or undefined media error</li>
<li>X.6.1 Media not supported</li>
<li>X.6.2 Conversion required and prohibited</li>
<li>X.6.3 Conversion required but not supported</li>
<li>X.6.4 Conversion with loss performed</li>
<li>X.6.5 Conversion failed</li>
</ul>
<ul>
<li>X.7.0 Other or undefined security status</li>
<li>X.7.1 Delivery not authorized, message refused</li>
<li>X.7.2 Mailing list expansion prohibited</li>
<li>X.7.3 Security conversion required but not possible</li>
<li>X.7.4 Security features not supported</li>
<li>X.7.5 Cryptographic failure</li>
<li>X.7.6 Cryptographic algorithm not supported</li>
<li>X.7.7 Message integrity failure</li>
</ul>
<p>Credits: http://www.emailaddressmanager.com/tips/codes.html</p>
]]></content:encoded>
			<wfw:commentRss>http://www.robertmullaney.com/2013/04/24/email-delivery-codes-errors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Updated ISO-3316 Country List as PHP Array</title>
		<link>http://www.robertmullaney.com/2013/04/03/updated-iso-3316-country-list-php-array/</link>
		<comments>http://www.robertmullaney.com/2013/04/03/updated-iso-3316-country-list-php-array/#comments</comments>
		<pubDate>Wed, 03 Apr 2013 14:17:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.robertmullaney.com/?p=842</guid>
		<description><![CDATA[Here is an updated version of ISO-3316 Country List as PHP Array&#8230; $countries = array(     'AF' =&#62; 'Afghanistan',     'AX' =&#62; 'Åland Islands',     'AL' =&#62; 'Albania',     'DZ' =&#62; 'Algeria',     'AS' =&#62; 'American Samoa',     'AD' =&#62; 'Andorra',     'AO' =&#62; 'Angola',     'AI' =&#62; 'Anguilla',     'AQ' =&#62; 'Antarctica',     'AG' [...]]]></description>
				<content:encoded><![CDATA[<p>Here is an updated version of <a title="ISO-3316 Country List as PHP Array" href="http://www.robertmullaney.com/2012/08/24/iso-3316-country-list-as-php-array/">ISO-3316 Country List as PHP Array</a>&#8230;</p>
<pre>$countries = array(
    'AF' =&gt; 'Afghanistan',
    'AX' =&gt; 'Åland Islands',
    'AL' =&gt; 'Albania',
    'DZ' =&gt; 'Algeria',
    'AS' =&gt; 'American Samoa',
    'AD' =&gt; 'Andorra',
    'AO' =&gt; 'Angola',
    'AI' =&gt; 'Anguilla',
    'AQ' =&gt; 'Antarctica',
    'AG' =&gt; 'Antigua and Barbuda',
    'AR' =&gt; 'Argentina',
    'AM' =&gt; 'Armenia',
    'AW' =&gt; 'Aruba',
    'AU' =&gt; 'Australia',
    'AT' =&gt; 'Austria',
    'AZ' =&gt; 'Azerbaijan',
    'BS' =&gt; 'Bahamas',
    'BH' =&gt; 'Bahrain',
    'BD' =&gt; 'Bangladesh',
    'BB' =&gt; 'Barbados',
    'BY' =&gt; 'Belarus',
    'BE' =&gt; 'Belgium',
    'BZ' =&gt; 'Belize',
    'BJ' =&gt; 'Benin',
    'BM' =&gt; 'Bermuda',
    'BT' =&gt; 'Bhutan',
    'BO' =&gt; 'Bolivia, Plurinational State of',
    'BQ' =&gt; 'Bonaire, Sint Eustatius and Saba',
    'BA' =&gt; 'Bosnia and Herzegovina',
    'BW' =&gt; 'Botswana',
    'BV' =&gt; 'Bouvet Island',
    'BR' =&gt; 'Brazil',
    'IO' =&gt; 'British Indian Ocean Territory',
    'BN' =&gt; 'Brunei Darussalam',
    'BG' =&gt; 'Bulgaria',
    'BF' =&gt; 'Burkina Faso',
    'BI' =&gt; 'Burundi',
    'KH' =&gt; 'Cambodia',
    'CM' =&gt; 'Cameroon',
    'CA' =&gt; 'Canada',
    'CV' =&gt; 'Cape Verde',
    'KY' =&gt; 'Cayman Islands',
    'CF' =&gt; 'Central African Republic',
    'TD' =&gt; 'Chad',
    'CL' =&gt; 'Chile',
    'CN' =&gt; 'China',
    'CX' =&gt; 'Christmas Island',
    'CC' =&gt; 'Cocos (Keeling) Islands',
    'CO' =&gt; 'Colombia',
    'KM' =&gt; 'Comoros',
    'CG' =&gt; 'Congo',
    'CD' =&gt; 'Congo, the Democratic Republic of the',
    'CK' =&gt; 'Cook Islands',
    'CR' =&gt; 'Costa Rica',
    'CI' =&gt; 'Côte d\'Ivoire',
    'HR' =&gt; 'Croatia',
    'CU' =&gt; 'Cuba',
    'CW' =&gt; 'Curaçao',
    'CY' =&gt; 'Cyprus',
    'CZ' =&gt; 'Czech Republic',
    'DK' =&gt; 'Denmark',
    'DJ' =&gt; 'Djibouti',
    'DM' =&gt; 'Dominica',
    'DO' =&gt; 'Dominican Republic',
    'EC' =&gt; 'Ecuador',
    'EG' =&gt; 'Egypt',
    'SV' =&gt; 'El Salvador',
    'GQ' =&gt; 'Equatorial Guinea',
    'ER' =&gt; 'Eritrea',
    'EE' =&gt; 'Estonia',
    'ET' =&gt; 'Ethiopia',
    'FK' =&gt; 'Falkland Islands (Malvinas)',
    'FO' =&gt; 'Faroe Islands',
    'FJ' =&gt; 'Fiji',
    'FI' =&gt; 'Finland',
    'FR' =&gt; 'France',
    'GF' =&gt; 'French Guiana',
    'PF' =&gt; 'French Polynesia',
    'TF' =&gt; 'French Southern Territories',
    'GA' =&gt; 'Gabon',
    'GM' =&gt; 'Gambia',
    'GE' =&gt; 'Georgia',
    'DE' =&gt; 'Germany',
    'GH' =&gt; 'Ghana',
    'GI' =&gt; 'Gibraltar',
    'GR' =&gt; 'Greece',
    'GL' =&gt; 'Greenland',
    'GD' =&gt; 'Grenada',
    'GP' =&gt; 'Guadeloupe',
    'GU' =&gt; 'Guam',
    'GT' =&gt; 'Guatemala',
    'GG' =&gt; 'Guernsey',
    'GN' =&gt; 'Guinea',
    'GW' =&gt; 'Guinea-Bissau',
    'GY' =&gt; 'Guyana',
    'HT' =&gt; 'Haiti',
    'HM' =&gt; 'Heard Island and McDonald Islands',
    'VA' =&gt; 'Holy See (Vatican City State)',
    'HN' =&gt; 'Honduras',
    'HK' =&gt; 'Hong Kong',
    'HU' =&gt; 'Hungary',
    'IS' =&gt; 'Iceland',
    'IN' =&gt; 'India',
    'ID' =&gt; 'Indonesia',
    'IR' =&gt; 'Iran, Islamic Republic of',
    'IQ' =&gt; 'Iraq',
    'IE' =&gt; 'Ireland',
    'IM' =&gt; 'Isle of Man',
    'IL' =&gt; 'Israel',
    'IT' =&gt; 'Italy',
    'JM' =&gt; 'Jamaica',
    'JP' =&gt; 'Japan',
    'JE' =&gt; 'Jersey',
    'JO' =&gt; 'Jordan',
    'KZ' =&gt; 'Kazakhstan',
    'KE' =&gt; 'Kenya',
    'KI' =&gt; 'Kiribati',
    'KP' =&gt; 'Korea, Democratic People\'s Republic of',
    'KR' =&gt; 'Korea, Republic of',
    'KW' =&gt; 'Kuwait',
    'KG' =&gt; 'Kyrgyzstan',
    'LA' =&gt; 'Lao People\'s Democratic Republic',
    'LV' =&gt; 'Latvia',
    'LB' =&gt; 'Lebanon',
    'LS' =&gt; 'Lesotho',
    'LR' =&gt; 'Liberia',
    'LY' =&gt; 'Libya',
    'LI' =&gt; 'Liechtenstein',
    'LT' =&gt; 'Lithuania',
    'LU' =&gt; 'Luxembourg',
    'MO' =&gt; 'Macao',
    'MK' =&gt; 'Macedonia, The Former Yugoslav Republic of',
    'MG' =&gt; 'Madagascar',
    'MW' =&gt; 'Malawi',
    'MY' =&gt; 'Malaysia',
    'MV' =&gt; 'Maldives',
    'ML' =&gt; 'Mali',
    'MT' =&gt; 'Malta',
    'MH' =&gt; 'Marshall Islands',
    'MQ' =&gt; 'Martinique',
    'MR' =&gt; 'Mauritania',
    'MU' =&gt; 'Mauritius',
    'YT' =&gt; 'Mayotte',
    'MX' =&gt; 'Mexico',
    'FM' =&gt; 'Micronesia, Federated States of',
    'MD' =&gt; 'Moldova, Republic of',
    'MC' =&gt; 'Monaco',
    'MN' =&gt; 'Mongolia',
    'ME' =&gt; 'Montenegro',
    'MS' =&gt; 'Montserrat',
    'MA' =&gt; 'Morocco',
    'MZ' =&gt; 'Mozambique',
    'MM' =&gt; 'Myanmar',
    'NA' =&gt; 'Namibia',
    'NR' =&gt; 'Nauru',
    'NP' =&gt; 'Nepal',
    'NL' =&gt; 'Netherlands',
    'NC' =&gt; 'New Caledonia',
    'NZ' =&gt; 'New Zealand',
    'NI' =&gt; 'Nicaragua',
    'NE' =&gt; 'Niger',
    'NG' =&gt; 'Nigeria',
    'NU' =&gt; 'Niue',
    'NF' =&gt; 'Norfolk Island',
    'MP' =&gt; 'Northern Mariana Islands',
    'NO' =&gt; 'Norway',
    'OM' =&gt; 'Oman',
    'PK' =&gt; 'Pakistan',
    'PW' =&gt; 'Palau',
    'PS' =&gt; 'Palestine, State of',
    'PA' =&gt; 'Panama',
    'PG' =&gt; 'Papua New Guinea',
    'PY' =&gt; 'Paraguay',
    'PE' =&gt; 'Peru',
    'PH' =&gt; 'Philippines',
    'PN' =&gt; 'Pitcairn',
    'PL' =&gt; 'Poland',
    'PT' =&gt; 'Portugal',
    'PR' =&gt; 'Puerto Rico',
    'QA' =&gt; 'Qatar',
    'RE' =&gt; 'Réunion',
    'RO' =&gt; 'Romania',
    'RU' =&gt; 'Russian Federation',
    'RW' =&gt; 'Rwanda',
    'BL' =&gt; 'Saint Barthélemy',
    'SH' =&gt; 'Saint Helena, Ascension and Tristan da Cunha',
    'KN' =&gt; 'Saint Kitts and Nevis',
    'LC' =&gt; 'Saint Lucia',
    'MF' =&gt; 'Saint Martin (French part)',
    'PM' =&gt; 'Saint Pierre and Miquelon',
    'VC' =&gt; 'Saint Vincent and the Grenadines',
    'WS' =&gt; 'Samoa',
    'SM' =&gt; 'San Marino',
    'ST' =&gt; 'Sao Tome and Principe',
    'SA' =&gt; 'Saudi Arabia',
    'SN' =&gt; 'Senegal',
    'RS' =&gt; 'Serbia',
    'SC' =&gt; 'Seychelles',
    'SL' =&gt; 'Sierra Leone',
    'SG' =&gt; 'Singapore',
    'SX' =&gt; 'Sint Maarten (Dutch part)',
    'SK' =&gt; 'Slovakia',
    'SI' =&gt; 'Slovenia',
    'SB' =&gt; 'Solomon Islands',
    'SO' =&gt; 'Somalia',
    'ZA' =&gt; 'South Africa',
    'GS' =&gt; 'South Georgia and the South Sandwich Islands',
    'SS' =&gt; 'South Sudan',
    'ES' =&gt; 'Spain',
    'LK' =&gt; 'Sri Lanka',
    'SD' =&gt; 'Sudan',
    'SR' =&gt; 'Suriname',
    'SJ' =&gt; 'Svalbard and Jan Mayen',
    'SZ' =&gt; 'Swaziland',
    'SE' =&gt; 'Sweden',
    'CH' =&gt; 'Switzerland',
    'SY' =&gt; 'Syrian Arab Republic',
    'TW' =&gt; 'Taiwan, Province of China',
    'TJ' =&gt; 'Tajikistan',
    'TZ' =&gt; 'Tanzania, United Republic of',
    'TH' =&gt; 'Thailand',
    'TL' =&gt; 'Timor-Leste',
    'TG' =&gt; 'Togo',
    'TK' =&gt; 'Tokelau',
    'TO' =&gt; 'Tonga',
    'TT' =&gt; 'Trinidad and Tobago',
    'TN' =&gt; 'Tunisia',
    'TR' =&gt; 'Turkey',
    'TM' =&gt; 'Turkmenistan',
    'TC' =&gt; 'Turks and Caicos Islands',
    'TV' =&gt; 'Tuvalu',
    'UG' =&gt; 'Uganda',
    'UA' =&gt; 'Ukraine',
    'AE' =&gt; 'United Arab Emirates',
    'GB' =&gt; 'United Kingdom',
    'US' =&gt; 'United States',
    'UM' =&gt; 'United States Minor Outlying Islands',
    'UY' =&gt; 'Uruguay',
    'UZ' =&gt; 'Uzbekistan',
    'VU' =&gt; 'Vanuatu',
    'VE' =&gt; 'Venezuela, Bolivarian Republic of',
    'VN' =&gt; 'Viet Nam',
    'VG' =&gt; 'Virgin Islands, British',
    'VI' =&gt; 'Virgin Islands, U.S.',
    'WF' =&gt; 'Wallis and Futuna',
    'EH' =&gt; 'Western Sahara',
    'YE' =&gt; 'Yemen',
    'ZM' =&gt; 'Zambia',
    'ZW' =&gt; 'Zimbabwe'
);</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.robertmullaney.com/2013/04/03/updated-iso-3316-country-list-php-array/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Recursively set permissions (CHMOD) for a specific file extension</title>
		<link>http://www.robertmullaney.com/2013/03/28/recursive-file-permissions-chmod-file-extension/</link>
		<comments>http://www.robertmullaney.com/2013/03/28/recursive-file-permissions-chmod-file-extension/#comments</comments>
		<pubDate>Thu, 28 Mar 2013 14:52:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.robertmullaney.com/?p=834</guid>
		<description><![CDATA[Just a quick snippet&#8230; find /start/from/here -type f -name "*.php" -print &#124; xargs chmod 644 Enjoy]]></description>
				<content:encoded><![CDATA[<p>Just a quick snippet&#8230;</p>
<pre dir="ltr">find /start/from/here -type f -name "*.php" -print | xargs chmod 644</pre>
<p>Enjoy <img src='http://www.robertmullaney.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.robertmullaney.com/2013/03/28/recursive-file-permissions-chmod-file-extension/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dive Gear Photos</title>
		<link>http://www.robertmullaney.com/2013/02/16/dive-gear-photos/</link>
		<comments>http://www.robertmullaney.com/2013/02/16/dive-gear-photos/#comments</comments>
		<pubDate>Sat, 16 Feb 2013 15:10:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.robertmullaney.com/?p=817</guid>
		<description><![CDATA[http://lakeland.craigslist.org/spo/3732833434.html http://lakeland.craigslist.org/spo/3732833434.html]]></description>
				<content:encoded><![CDATA[<p><a href="http://lakeland.craigslist.org/spo/3732833434.html">http://lakeland.craigslist.org/spo/3732833434.html<span id="more-817"></span></a></p>
<p><a href="http://www.robertmullaney.com/2013/02/16/dive-gear-photos/imag0119/" rel="attachment wp-att-823"><img class="alignnone size-full wp-image-823" alt="IMAG0119" src="http://www.robertmullaney.com/wp-content/uploads/2013/02/IMAG0119.jpg" width="1952" height="3264" /></a> <a href="http://www.robertmullaney.com/2013/02/16/dive-gear-photos/imag0120/" rel="attachment wp-att-824"><img class="alignnone size-full wp-image-824" alt="IMAG0120" src="http://www.robertmullaney.com/wp-content/uploads/2013/02/IMAG0120.jpg" width="1952" height="3264" /></a> <a href="http://www.robertmullaney.com/2013/02/16/dive-gear-photos/imag0121/" rel="attachment wp-att-825"><img class="alignnone size-full wp-image-825" alt="IMAG0121" src="http://www.robertmullaney.com/wp-content/uploads/2013/02/IMAG0121.jpg" width="1952" height="3264" /></a> <a href="http://www.robertmullaney.com/2013/02/16/dive-gear-photos/imag0122/" rel="attachment wp-att-826"><img class="alignnone size-full wp-image-826" alt="IMAG0122" src="http://www.robertmullaney.com/wp-content/uploads/2013/02/IMAG0122.jpg" width="1952" height="3264" /></a> <a href="http://www.robertmullaney.com/2013/02/16/dive-gear-photos/imag0123/" rel="attachment wp-att-827"><img class="alignnone size-full wp-image-827" alt="IMAG0123" src="http://www.robertmullaney.com/wp-content/uploads/2013/02/IMAG0123.jpg" width="1952" height="3264" /></a> <a href="http://www.robertmullaney.com/2013/02/16/dive-gear-photos/imag0124/" rel="attachment wp-att-828"><img class="alignnone size-full wp-image-828" alt="IMAG0124" src="http://www.robertmullaney.com/wp-content/uploads/2013/02/IMAG0124.jpg" width="1952" height="3264" /></a> <a href="http://www.robertmullaney.com/2013/02/16/dive-gear-photos/imag0125/" rel="attachment wp-att-829"><img class="alignnone size-full wp-image-829" alt="IMAG0125" src="http://www.robertmullaney.com/wp-content/uploads/2013/02/IMAG0125.jpg" width="1952" height="3264" /></a></p>
<p><a href="http://lakeland.craigslist.org/spo/3732833434.html">http://lakeland.craigslist.org/spo/3732833434.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.robertmullaney.com/2013/02/16/dive-gear-photos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easily convert MySQL database collations and alter character sets</title>
		<link>http://www.robertmullaney.com/2013/02/06/convert-alter-mysql-databases-collations-character-sets/</link>
		<comments>http://www.robertmullaney.com/2013/02/06/convert-alter-mysql-databases-collations-character-sets/#comments</comments>
		<pubDate>Thu, 07 Feb 2013 01:43:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.robertmullaney.com/?p=793</guid>
		<description><![CDATA[I can&#8217;t remember what all I looked at for references, but this completed tool will generate the SQL  commands necessary to convert your database, tables and fields from any collation and character set into another. It goes without saying to make a backup of your database before running such commands. If you don&#8217;t make a [...]]]></description>
				<content:encoded><![CDATA[<p>I can&#8217;t remember what all I looked at for references, but this completed tool will generate the SQL  commands necessary to convert your database, tables and fields from any collation and character set into another.</p>
<p>It goes without saying to make a backup of your database before running such commands. If you don&#8217;t make a backup first, shame on you <img src='http://www.robertmullaney.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> <span id="more-793"></span></p>
<pre>&lt;?php

function show_error($string) {
    header('Content-Type: text/plain');
    echo $string;
    exit(1);
}

function db_connect() {
    if ( ! mysql_connect($_POST['host'], $_POST['user'], $_POST['pass']) || ! mysql_select_db($_POST['name'])) {
        show_error(mysql_error());
    }
}

if (empty($_POST['host']) || empty($_POST['user']) || empty($_POST['pass']) || empty($_POST['name'])) {

?&gt;
&lt;form method="post"&gt;
    &lt;fieldset&gt;
        &lt;legend&gt;Database&lt;/legend&gt;
        &lt;label&gt;Host&lt;/label&gt;
        &lt;input type="text" name="host" value="&lt;?php echo (empty($_POST['host'])) ? 'localhost' : htmlentities($_POST['host']); ?&gt;"&gt;
        &lt;label&gt;User&lt;/label&gt;
        &lt;input type="text" name="user" value="&lt;?php echo htmlentities($_POST['user']); ?&gt;"&gt;
        &lt;label&gt;Pass&lt;/label&gt;
        &lt;input type="text" name="pass" value="&lt;?php echo htmlentities($_POST['pass']); ?&gt;"&gt;
        &lt;label&gt;Name&lt;/label&gt;
        &lt;input type="text" name="name" value="&lt;?php echo htmlentities($_POST['name']); ?&gt;"&gt;
        &lt;input type="submit" value="Go"&gt;
    &lt;/fieldset&gt;
&lt;/form&gt;
&lt;?php

} elseif (empty($_POST['collate']) || empty($_POST['charset']) || !isset($_POST['alter_database']) || !isset($_POST['alter_tables']) || !isset($_POST['alter_fields'])) {

    db_connect();

    $collations = array();
    $sql = 'SHOW COLLATION WHERE `Compiled` = \'Yes\'';
    $rs = mysql_query($sql);
    while ($row = mysql_fetch_assoc($rs)) {
        $collations[] = $row['Collation'];
    }
    if (count($collations)) {
        sort($collations);
    } else {
        show_error('NO RESULTS FOR: ' . $sql);
    }

    $charsets = array();
    $sql = 'SHOW CHARACTER SET';
    $rs = mysql_query($sql);
    while ($row = mysql_fetch_assoc($rs)) {
        $charsets[] = $row['Charset'];
    }
    if (count($charsets)) {
        sort($charsets);
    } else {
        show_error('NO RESULTS FOR: ' . $sql);
    }

?&gt;
&lt;form method="post"&gt;
    &lt;fieldset&gt;
        &lt;legend&gt;Configuration&lt;/legend&gt;
        &lt;label&gt;Collation&lt;/label&gt;
        &lt;select name="collate"&gt;
            &lt;option&gt;&lt;?php echo implode('&lt;/option&gt;&lt;option&gt;', $collations); ?&gt;&lt;/option&gt;
        &lt;/select&gt;
        &lt;label&gt;Character Set&lt;/label&gt;
        &lt;select name="charset"&gt;
            &lt;option&gt;&lt;?php echo implode('&lt;/option&gt;&lt;option&gt;', $charsets); ?&gt;&lt;/option&gt;
        &lt;/select&gt;
        &lt;label&gt;Show Database Alterations&lt;/label&gt;
        &lt;select name="alter_database"&gt;
            &lt;option value="1"&gt;Yes&lt;/option&gt;
            &lt;option value="0"&lt;?php echo (isset($_POST['tables']) &amp;&amp; $_POST['tables'] == '0') ? ' selected="selected"' : ''; ?&gt;&gt;No&lt;/option&gt;
        &lt;/select&gt;
        &lt;label&gt;Show Table Alterations&lt;/label&gt;
        &lt;select name="alter_tables"&gt;
            &lt;option value="1"&gt;Yes&lt;/option&gt;
            &lt;option value="0"&lt;?php echo (isset($_POST['tables']) &amp;&amp; $_POST['tables'] == '0') ? ' selected="selected"' : ''; ?&gt;&gt;No&lt;/option&gt;
        &lt;/select&gt;
        &lt;label&gt;Show Field Alterations&lt;/label&gt;
        &lt;select name="alter_fields"&gt;
            &lt;option value="1"&gt;Yes&lt;/option&gt;
            &lt;option value="0"&lt;?php echo (isset($_POST['fields']) &amp;&amp; $_POST['fields'] == '0') ? ' selected="selected"' : ''; ?&gt;&gt;No&lt;/option&gt;
        &lt;/select&gt;
        &lt;input type="submit" value="Go"&gt;
    &lt;/fieldset&gt;
    &lt;input type="hidden" name="host" value="&lt;?php echo htmlentities($_POST['host']); ?&gt;"&gt;
    &lt;input type="hidden" name="user" value="&lt;?php echo htmlentities($_POST['user']); ?&gt;"&gt;
    &lt;input type="hidden" name="pass" value="&lt;?php echo htmlentities($_POST['pass']); ?&gt;"&gt;
    &lt;input type="hidden" name="name" value="&lt;?php echo htmlentities($_POST['name']); ?&gt;"&gt;
&lt;/form&gt;
&lt;?php

} else {

    db_connect();
    set_time_limit(0);
    $convert_to = $_POST['collate'];
    $character_set = $_POST['charset'];
    $show_alter_database = (bool) $_POST['alter_database'];
    $show_alter_table = (bool) $_POST['alter_tables'];
    $show_alter_field = (bool) $_POST['alter_fields'];
    $database = mysql_real_escape_string($_POST['name']);

    header('Content-Type: text/plain');
    echo "/* DATABASE: $_POST[name] */\n";
    echo "/* COLLATE: $convert_to */\n";
    echo "/* CHARSET: $character_set */\n";
    echo "/* ---------------------------------------- */\n";

    if ($show_alter_database) {
        $rs = mysql_query("SHOW CREATE DATABASE `$database`") or show_error(mysql_error());
        $row = mysql_fetch_assoc($rs);
        if (strpos($row['Create Database'], "CHARACTER SET $character_set") === FALSE) {
            echo "ALTER DATABASE `$database` DEFAULT CHARACTER SET $character_set COLLATE $convert_to;\n";
        }
    }
    $rs_tables = mysql_query('SHOW TABLES') or show_error(mysql_error());
    while ($row_tables = mysql_fetch_row($rs_tables)) {
        $table = mysql_real_escape_string($row_tables[0]);
        if ($show_alter_table) {
            $rs = mysql_query("SHOW CREATE TABLE `$table`") or show_error(mysql_error());
            $row = mysql_fetch_assoc($rs);
            if (strpos($row['Create Table'], "DEFAULT CHARSET=$character_set") === FALSE) {
                echo "ALTER TABLE `$table` DEFAULT CHARACTER SET $character_set;\n";
            }
        }
        if ($show_alter_field) {
            $rs = mysql_query("SHOW FULL FIELDS FROM `$table`") or show_error(mysql_error());
            while ($row = mysql_fetch_assoc($rs)) {
                if ($row['Collation'] == '' || $row['Collation'] == $convert_to) {
                    continue;
                }
                $nullable = ($row['Null'] == 'YES') ? 'NULL' : 'NOT NULL';
                if ($row['Default'] === NULL &amp;&amp; $row['Null'] == 'YES') {
                    $default = ($nullable == 'NOT NULL') ? '' : ' DEFAULT NULL';
                } elseif ($row['Default'] != '') {
                    $default = ' DEFAULT \'' . mysql_real_escape_string($row['Default']) . '\'';
                } else {
                    $default = '';
                }
                $field = mysql_real_escape_string($row['Field']);
                echo "ALTER TABLE `$table` CHANGE `$field` `$field` LONGBLOB;\n";
                echo "ALTER TABLE `$table` CHANGE `$field` `$field` $row[Type] CHARACTER SET $character_set COLLATE $convert_to $nullable$default;\n";
            }
        }
    }
    echo "/* ---------------------------------------- */\n";
}</pre>
<ol>
<li>You have to provide your MySQL connection information (duh)</li>
<li>Select the desired collation, and character set</li>
<li>Select whether to show database, table and/or field alterations</li>
<li>The SQL code is output to the screen for review</li>
</ol>
<p>Note: Collations and character sets are automatically retrieved from the MySQL server <img src='http://www.robertmullaney.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>I used to go through phpMyAdmin and do this manually on each table and field&#8230; seriously. This tool could easily save you an hour or two having to do that with a robust database schema <img src='http://www.robertmullaney.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.robertmullaney.com/2013/02/06/convert-alter-mysql-databases-collations-character-sets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using chown recursively with a reference file</title>
		<link>http://www.robertmullaney.com/2013/01/31/using-chown-recursively-with-a-reference-file/</link>
		<comments>http://www.robertmullaney.com/2013/01/31/using-chown-recursively-with-a-reference-file/#comments</comments>
		<pubDate>Thu, 31 Jan 2013 22:51:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.robertmullaney.com/?p=788</guid>
		<description><![CDATA[Nothing too complicated -R &#62; recursive (includes all folders/files) &#8211;reference=. &#62; get owner:group from the current folder (eg: single dot) . &#62; start in current directory chown -R --reference=. . This comes in pretty handy when migrating sites using gzipped archives]]></description>
				<content:encoded><![CDATA[<p>Nothing too complicated <img src='http://www.robertmullaney.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><span style="color: #ff0000;"><strong>-R</strong></span> &gt; recursive (includes all folders/files)<br />
<span style="color: #ff0000;"><strong>&#8211;reference=.</strong></span> &gt; get owner:group from the current folder (eg: single dot)<br />
<span style="color: #ff0000;"><strong>.</strong></span> &gt; start in current directory</p>
<pre>chown -R --reference=. .</pre>
<p>This comes in pretty handy when migrating sites using <a title="Create/restore a recursive gzipped archive of the current folder" href="http://www.robertmullaney.com/2013/01/31/tar-gzip-recursive-directory-folder/">gzipped archives</a> <img src='http://www.robertmullaney.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.robertmullaney.com/2013/01/31/using-chown-recursively-with-a-reference-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create/restore a recursive gzipped archive of the current folder</title>
		<link>http://www.robertmullaney.com/2013/01/31/tar-gzip-recursive-directory-folder/</link>
		<comments>http://www.robertmullaney.com/2013/01/31/tar-gzip-recursive-directory-folder/#comments</comments>
		<pubDate>Thu, 31 Jan 2013 22:09:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.robertmullaney.com/?p=784</guid>
		<description><![CDATA[Compress: tar -zcvf myarchive.tar.gz ./ Extract: tar -zxvf myarchive.tar.gz That&#8217;s all folks Goes well with recursive chown when moving files between servers!]]></description>
				<content:encoded><![CDATA[<p>Compress:</p>
<pre>tar -zcvf myarchive.tar.gz ./</pre>
<p>Extract:</p>
<pre>tar -zxvf myarchive.tar.gz</pre>
<p>That&#8217;s all folks <img src='http://www.robertmullaney.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Goes well with <a title="Using chown recursively with a reference file" href="http://www.robertmullaney.com/2013/01/31/using-chown-recursively-with-a-reference-file/">recursive chown</a> when moving files between servers!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.robertmullaney.com/2013/01/31/tar-gzip-recursive-directory-folder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple PHP function to convert hexadecimal colors to RGB (red, green, blue) decimal values</title>
		<link>http://www.robertmullaney.com/2013/01/23/php-convert-hex-colors-rgb-decimal-hex2rgb/</link>
		<comments>http://www.robertmullaney.com/2013/01/23/php-convert-hex-colors-rgb-decimal-hex2rgb/#comments</comments>
		<pubDate>Wed, 23 Jan 2013 19:05:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.robertmullaney.com/?p=770</guid>
		<description><![CDATA[This function will convert hexadecimal colors with a length of 6, 3, 2, or 1 into their RGB decimal equivalents. If a value cannot be converted, it defaults to black&#8230; function hex2rgb($hex = NULL) { preg_match('/^#{0,1}([0-9a-f]{1,6})$/i', $hex, $matches); if ($hex[0] == '#') $hex = substr($hex, 1); $length = @strlen($matches[1]); switch ($length) { case 6: $rgb [...]]]></description>
				<content:encoded><![CDATA[<p>This function will convert hexadecimal colors with a length of 6, 3, 2, or 1 into their RGB decimal equivalents. If a value cannot be converted, it defaults to black&#8230;</p>
<pre>function hex2rgb($hex = NULL) {
	preg_match('/^#{0,1}([0-9a-f]{1,6})$/i', $hex, $matches);
	if ($hex[0] == '#') $hex = substr($hex, 1);
	$length = @strlen($matches[1]);
	switch ($length) {
		case 6:
			$rgb = array($hex[0] . $hex[1], $hex[2] . $hex[3], $hex[4] . $hex[5]);
			break;
		case 3:
			$rgb = array($hex[0] . $hex[0], $hex[1] . $hex[1], $hex[2] . $hex[2]);
			break;
		case 2:
			$rgb = array($hex[0] . $hex[1], $hex[0] . $hex[1], $hex[0] . $hex[1]);
			break;
		default:
			$hex = ($length == 1) ? $hex . $hex : 0;
			$rgb = array($hex, $hex, $hex);
			break;
	}
	return array(
		'r' =&gt; hexdec($rgb[0]),
		'g' =&gt; hexdec($rgb[1]),
		'b' =&gt; hexdec($rgb[2])
	);
}</pre>
<p>Short, simple and sweet <img src='http://www.robertmullaney.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.robertmullaney.com/2013/01/23/php-convert-hex-colors-rgb-decimal-hex2rgb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Merry Christmas to all the coders out there ;)</title>
		<link>http://www.robertmullaney.com/2012/12/25/merry-christmas-coders/</link>
		<comments>http://www.robertmullaney.com/2012/12/25/merry-christmas-coders/#comments</comments>
		<pubDate>Tue, 25 Dec 2012 14:05:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.robertmullaney.com/?p=765</guid>
		<description><![CDATA[Just wanted to take a moment and wish everyone a Merry Christmas (or Happy Holidays, you pick). Hope you are enjoying time with family and loved ones. By the way&#8230; where are my gifts? Click a banner and make my holiday a little brighter.]]></description>
				<content:encoded><![CDATA[<p>Just wanted to take a moment and wish everyone a Merry Christmas (or Happy Holidays, you pick). Hope you are enjoying time with family and loved ones.</p>
<p>By the way&#8230; where are my gifts? <img src='http://www.robertmullaney.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  Click a banner and make my holiday a little brighter.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.robertmullaney.com/2012/12/25/merry-christmas-coders/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How-To: Reload verification image using Codeigniter 2 CAPTCHA helper</title>
		<link>http://www.robertmullaney.com/2012/12/05/how-to-reload-verification-image-using-codeigniter-2-captcha-helper/</link>
		<comments>http://www.robertmullaney.com/2012/12/05/how-to-reload-verification-image-using-codeigniter-2-captcha-helper/#comments</comments>
		<pubDate>Wed, 05 Dec 2012 12:41:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[captcha]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery ui]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://www.robertmullaney.com/?p=750</guid>
		<description><![CDATA[Out of the box, CodeIgniter has a good CAPTCHA helper to use in your web applications. Here is a simple example of how to get a new CAPTCHA image without having to reload the page Basic Controller class Welcome extends CI_Controller {     private $captcha_path = 'assets/img/captcha/';     public function __construct()     {        [...]]]></description>
				<content:encoded><![CDATA[<p>Out of the box, CodeIgniter has a good CAPTCHA helper to use in your web applications. Here is a simple example of how to get a new CAPTCHA image without having to reload the page <img src='http://www.robertmullaney.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Basic Controller</p>
<pre>class Welcome extends CI_Controller {

    private $captcha_path = 'assets/img/captcha/';

    public function __construct()
    {
        parent::__construct();
    }

    public function index()
    {
        $this-&gt;load-&gt;helper(array('captcha'));
        $captcha = create_captcha(array(
            'word'        =&gt; strtoupper(substr(md5(time()), 0, 6)),
            'img_path'    =&gt; $this-&gt;captcha_path,
            'img_url'    =&gt; $this-&gt;captcha_path
        ));
        $data = array(
            'captcha'        =&gt; $captcha
        );
        $this-&gt;session-&gt;set_userdata('captcha', $captcha['word']);
        $this-&gt;load-&gt;view('welcome', $data);
    }

}</pre>
<p>The View (jQuery used for UI buttons and altering CAPTCHA image &#8216;src&#8217; attribute)</p>
<pre>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"&gt;&lt;/script&gt;
&lt;script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"&gt;&lt;/script&gt;
&lt;link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/blitzer/jquery-ui.css"&gt;
&lt;script&gt;
$(function(){
    $('#new_captcha').button({
        text: false,
        icons: {
            primary: 'ui-icon-refresh'
        }
    }).click(function(event){
        event.preventDefault();
        $(this).prev().attr('src', '<span style="color: #ff0000;">welcome/new_captcha</span>?'+Math.random());
    });
});
&lt;/script&gt;
&lt;?php echo $captcha['image']; ?&gt;
&lt;a href="#" id="new_captcha"&gt;Reload CAPTCHA&lt;/a&gt;</pre>
<p>Modified Controller<span id="more-750"></span></p>
<pre>class Welcome extends CI_Controller {

    private $captcha_path = 'assets/img/captcha/';

    public function __construct()
    {
        parent::__construct();
    }

    public function index()
    {
        $this-&gt;load-&gt;helper(array('captcha'));
        $captcha = create_captcha(array(
            'word'        =&gt; strtoupper(substr(md5(time()), 0, 6)),
            'img_path'    =&gt; $this-&gt;captcha_path,
            'img_url'    =&gt; $this-&gt;captcha_path
        ));
        $data = array(
            'captcha'        =&gt; $captcha
        );
        $this-&gt;session-&gt;set_userdata('captcha', $captcha['word']);
        $this-&gt;load-&gt;view('welcome', $data);
    }

<span style="color: #ff0000;">    public function new_captcha()</span>
<span style="color: #ff0000;">    {</span>
<span style="color: #ff0000;">        $this-&gt;load-&gt;helper(array('captcha', 'file'));</span>
<span style="color: #ff0000;">        $captcha = create_captcha(array(</span>
<span style="color: #ff0000;">            'word'        =&gt; strtoupper(substr(md5(time()), 0, 6)),</span>
<span style="color: #ff0000;">            'img_path'    =&gt; $this-&gt;captcha_path,</span>
<span style="color: #ff0000;">            'img_url'    =&gt; $this-&gt;captcha_path</span>
<span style="color: #ff0000;">        ));</span>
<span style="color: #ff0000;">        $this-&gt;session-&gt;set_userdata('captcha', $captcha['word']);</span>
<span style="color: #ff0000;">        $filename = $this-&gt;captcha_path . $captcha['time'] . '.jpg';</span>
<span style="color: #ff0000;">        $this-&gt;output-&gt;set_header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');</span>
<span style="color: #ff0000;">        $this-&gt;output-&gt;set_header('Cache-Control: no-cache, no-store, must-revalidate, max-age=0');</span>
<span style="color: #ff0000;">        $this-&gt;output-&gt;set_header('Cache-Control: post-check=0, pre-check=0', FALSE);</span>
<span style="color: #ff0000;">        $this-&gt;output-&gt;set_header('Pragma: no-cache');</span>
<span style="color: #ff0000;">        $this-&gt;output-&gt;set_header('Content-Type: image/jpeg');</span>
<span style="color: #ff0000;">        $this-&gt;output-&gt;set_header('Content-Length: ' . filesize($filename));</span>
<span style="color: #ff0000;">        echo read_file($filename);</span>
<span style="color: #ff0000;">    }</span>

}</pre>
<p>Result&#8230;</p>
<p><a href="http://www.robertmullaney.com/wp-content/uploads/2012/12/ci-captcha-reload.png"><img class="alignnone size-full wp-image-753" title="CodeIngiter CAPTCHA with Reload Button" src="http://www.robertmullaney.com/wp-content/uploads/2012/12/ci-captcha-reload.png" alt="" width="190" height="36" /></a></p>
<p>Enjoy <img src='http://www.robertmullaney.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.robertmullaney.com/2012/12/05/how-to-reload-verification-image-using-codeigniter-2-captcha-helper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extending the CodeIgniter URI class to simplify pagination base_url option</title>
		<link>http://www.robertmullaney.com/2012/11/13/extending-codeigniter-uri-class-simplify-pagination-base_url-option/</link>
		<comments>http://www.robertmullaney.com/2012/11/13/extending-codeigniter-uri-class-simplify-pagination-base_url-option/#comments</comments>
		<pubDate>Tue, 13 Nov 2012 16:22:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[extend]]></category>

		<guid isPermaLink="false">http://www.robertmullaney.com/?p=743</guid>
		<description><![CDATA[In a lot of my controllers, I use pagination along with the HTML &#60;base&#62; tag&#8217;s href attribute for relative link URLs. Example URL: http://www.domain.com/admin/users/index/pagination_offset HTML Base tag: &#60;base href=&#8221;http://www.domain.com/admin/&#8221;&#62; What this means, is I usually have to build pagination&#8217;s base_url option based on where I am and what information is being passed in the URI. [...]]]></description>
				<content:encoded><![CDATA[<p>In a lot of my controllers, I use pagination along with the HTML &lt;base&gt; tag&#8217;s href attribute for relative link URLs.</p>
<p><strong>Example URL:</strong> http://www.domain.com/admin/users/index/pagination_offset</p>
<p><strong>HTML Base tag:</strong> &lt;base href=&#8221;http://www.domain.com/admin/&#8221;&gt;</p>
<p>What this means, is I usually have to build pagination&#8217;s base_url option based on where I am and what information is being passed in the URI. A lot of times it ends up looking something like&#8230;</p>
<pre>$this-&gt;load-&gt;library('pagination', array(
    'base_url'       =&gt; <span style="color: #ff0000;">$this-&gt;uri-&gt;segment(2) . '/' . $this-&gt;uri-&gt;segment(3) . '/' . $this-&gt;uri-&gt;segment(4),</span>
    'total_rows'     =&gt; $total_rows,
    'per_page'       =&gt; 20,
    'uri_segment'    =&gt; 4
));</pre>
<p>What I decided to do what extend the core CodeIgniter URI class to provide a basic slice method to grab a chunk of the URI by applying PHP&#8217;s array_slice function to the segments property of the URI class.<span id="more-743"></span></p>
<pre>&lt;?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_URI extends CI_URI {

    public function __construct()
    {
        parent::__construct();
    }

    public function segments_slice($offset = 0, $length = NULL)
    {
        if ($offset == 0 &amp;&amp; $length === NULL) return $this-&gt;uri_string;
        return implode('/', array_slice($this-&gt;segments, (int) $offset, $length));
    }

}

/* End of file MY_URI.php */
/* Location: ./application/core/MY_URI.php */</pre>
<p>Now instead of the first example, I call the following method.</p>
<pre>$this-&gt;load-&gt;library('pagination', array(
    'base_url'       =&gt; <span style="color: #ff0000;">$this-&gt;uri-&gt;segments_slice(1, 3),</span>
    'total_rows'     =&gt; $total_rows,
    'per_page'       =&gt; 20,
    'uri_segment'    =&gt; 5
));</pre>
<p>Considering the low number of calls made to the URI library, I doubt it has any noticeable performance improvements, but I think it provides nicer code and is pretty easy to elicit what is happening just by seeing the name of the method <img src='http://www.robertmullaney.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.robertmullaney.com/2012/11/13/extending-codeigniter-uri-class-simplify-pagination-base_url-option/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use JavaScript (using jQuery) to add support for HTML5 placeholder attribute in form fields</title>
		<link>http://www.robertmullaney.com/2012/10/18/javascript-jquery-add-support-html5-placeholder-attribute-form-fields/</link>
		<comments>http://www.robertmullaney.com/2012/10/18/javascript-jquery-add-support-html5-placeholder-attribute-form-fields/#comments</comments>
		<pubDate>Thu, 18 Oct 2012 21:17:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Snippets]]></category>

		<guid isPermaLink="false">http://www.robertmullaney.com/?p=728</guid>
		<description><![CDATA[Some browsers do not support the placeholder attribute added in HTML5. This attribute is useful for field hinting such as input formats for dates, phone numbers, and the like. If you see text in the field below, your browser supports placeholder, if not, add the code below to mimic the behavior Example field: JavaScript (jQuery) [...]]]></description>
				<content:encoded><![CDATA[<p>Some browsers do not support the <em>placeholder</em> attribute added in HTML5. This attribute is useful for field hinting such as input formats for dates, phone numbers, and the like. If you see text in the field below, your browser supports placeholder, if not, add the code below to mimic the behavior <img src='http://www.robertmullaney.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Example field:<br />
<input type="text" value="" placeholder="It works!" /></p>
<p>JavaScript (jQuery) workaround:<span id="more-728"></span></p>
<pre>$(function() {
	if (!('placeholder' in document.createElement('input'))) {
		$('form [placeholder]').focus(function(){
			if ($(this).val() == $(this).attr('placeholder')) {
				$(this).val('');
			}
		}).blur(function(){
			if ($(this).val() == '') {
				$(this).val($(this).attr('placeholder'));
			}
		}).blur();
	}
});</pre>
<p>Happy coding <img src='http://www.robertmullaney.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.robertmullaney.com/2012/10/18/javascript-jquery-add-support-html5-placeholder-attribute-form-fields/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Database helper for CodeIgniter to retrieve enumerated field values</title>
		<link>http://www.robertmullaney.com/2012/09/27/database-helper-codeigniter-enumerated-field-values/</link>
		<comments>http://www.robertmullaney.com/2012/09/27/database-helper-codeigniter-enumerated-field-values/#comments</comments>
		<pubDate>Thu, 27 Sep 2012 14:36:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.robertmullaney.com/?p=723</guid>
		<description><![CDATA[Load the helper: $this-&#62;load-&#62;helper(&#8216;database&#8217;); Call the function: $enums = field_enums(&#8216;table_name&#8217;, &#8216;field_name&#8217;); &#60;?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed'); if ( ! function_exists('field_enums')) {     function field_enums($table = '', $field = '')     {         $enums = array();         if ($table == '' &#124;&#124; $field == '') return $enums;        [...]]]></description>
				<content:encoded><![CDATA[<p>Load the helper:</p>
<p style="padding-left: 30px;">$this-&gt;load-&gt;helper(&#8216;database&#8217;);</p>
<p>Call the function:</p>
<p style="padding-left: 30px;">$enums = field_enums(&#8216;table_name&#8217;, &#8216;field_name&#8217;);</p>
<p><span id="more-723"></span></p>
<pre>&lt;?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

if ( ! function_exists('field_enums'))
{
    function field_enums($table = '', $field = '')
    {
        $enums = array();
        if ($table == '' || $field == '') return $enums;
        $CI =&amp; get_instance();
        preg_match_all("/'(.*?)'/", $CI-&gt;db-&gt;query("SHOW COLUMNS FROM {$table} LIKE '{$field}'")-&gt;row()-&gt;Type, $matches);
        foreach ($matches[1] as $key =&gt; $value) {
            $enums[$value] = $value; 
        }
        return $enums;
    }  
}

/* End of file database_helper.php */
/* Location: ./application/helpers/database_helper.php */</pre>
<p>Happy coding <img src='http://www.robertmullaney.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.robertmullaney.com/2012/09/27/database-helper-codeigniter-enumerated-field-values/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ISO-3316 Country List as PHP Array</title>
		<link>http://www.robertmullaney.com/2012/08/24/iso-3316-country-list-as-php-array/</link>
		<comments>http://www.robertmullaney.com/2012/08/24/iso-3316-country-list-as-php-array/#comments</comments>
		<pubDate>Sat, 25 Aug 2012 00:40:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Snippets]]></category>

		<guid isPermaLink="false">http://www.robertmullaney.com/?p=714</guid>
		<description><![CDATA[Compliments my US State List A new updated list can be found at Updated ISO-3316 Country List as PHP Array Thanks to sowiq for pointing out the outdated information $countries = array( 'AD' =&#62; 'Andorra', 'AE' =&#62; 'United Arab Emirates', 'AF' =&#62; 'Afghanistan', 'AG' =&#62; 'Antigua &#38;amp; Barbuda', 'AI' =&#62; 'Anguilla', 'AL' =&#62; 'Albania', 'AM' [...]]]></description>
				<content:encoded><![CDATA[<p>Compliments my <a title="US State List as PHP Array" href="http://www.robertmullaney.com/2012/08/24/us-state-list-as-php-array/">US State List</a> <img src='http://www.robertmullaney.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> <span id="more-714"></span></p>
<p>A new updated list can be found at <a title="Updated ISO-3316 Country List as PHP Array" href="http://www.robertmullaney.com/2013/04/03/updated-iso-3316-country-list-php-array/">Updated ISO-3316 Country List as PHP Array</a> <img src='http://www.robertmullaney.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Thanks to <cite>sowiq</cite> for pointing out the outdated information <img src='http://www.robertmullaney.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<pre>$countries = array(
	'AD' =&gt; 'Andorra',
	'AE' =&gt; 'United Arab Emirates',
	'AF' =&gt; 'Afghanistan',
	'AG' =&gt; 'Antigua &amp;amp; Barbuda',
	'AI' =&gt; 'Anguilla',
	'AL' =&gt; 'Albania',
	'AM' =&gt; 'Armenia',
	'AN' =&gt; 'Netherlands Antilles',
	'AO' =&gt; 'Angola',
	'AQ' =&gt; 'Antarctica',
	'AR' =&gt; 'Argentina',
	'AS' =&gt; 'American Samoa',
	'AT' =&gt; 'Austria',
	'AU' =&gt; 'Australia',
	'AW' =&gt; 'Aruba',
	'AZ' =&gt; 'Azerbaijan',
	'BA' =&gt; 'Bosnia and Herzegovina',
	'BB' =&gt; 'Barbados',
	'BD' =&gt; 'Bangladesh',
	'BE' =&gt; 'Belgium',
	'BF' =&gt; 'Burkina Faso',
	'BG' =&gt; 'Bulgaria',
	'BH' =&gt; 'Bahrain',
	'BI' =&gt; 'Burundi',
	'BJ' =&gt; 'Benin',
	'BM' =&gt; 'Bermuda',
	'BN' =&gt; 'Brunei Darussalam',
	'BO' =&gt; 'Bolivia',
	'BR' =&gt; 'Brazil',
	'BS' =&gt; 'Bahama',
	'BT' =&gt; 'Bhutan',
	'BU' =&gt; 'Burma (no longer exists)',
	'BV' =&gt; 'Bouvet Island',
	'BW' =&gt; 'Botswana',
	'BY' =&gt; 'Belarus',
	'BZ' =&gt; 'Belize',
	'CA' =&gt; 'Canada',
	'CC' =&gt; 'Cocos (Keeling) Islands',
	'CF' =&gt; 'Central African Republic',
	'CG' =&gt; 'Congo',
	'CH' =&gt; 'Switzerland',
	'CI' =&gt; 'Côte D\'ivoire (Ivory Coast)',
	'CK' =&gt; 'Cook Iislands',
	'CL' =&gt; 'Chile',
	'CM' =&gt; 'Cameroon',
	'CN' =&gt; 'China',
	'CO' =&gt; 'Colombia',
	'CR' =&gt; 'Costa Rica',
	'CS' =&gt; 'Czechoslovakia (no longer exists)',
	'CU' =&gt; 'Cuba',
	'CV' =&gt; 'Cape Verde',
	'CX' =&gt; 'Christmas Island',
	'CY' =&gt; 'Cyprus',
	'CZ' =&gt; 'Czech Republic',
	'DD' =&gt; 'German Democratic Republic (no longer exists)',
	'DE' =&gt; 'Germany',
	'DJ' =&gt; 'Djibouti',
	'DK' =&gt; 'Denmark',
	'DM' =&gt; 'Dominica',
	'DO' =&gt; 'Dominican Republic',
	'DZ' =&gt; 'Algeria',
	'EC' =&gt; 'Ecuador',
	'EE' =&gt; 'Estonia',
	'EG' =&gt; 'Egypt',
	'EH' =&gt; 'Western Sahara',
	'ER' =&gt; 'Eritrea',
	'ES' =&gt; 'Spain',
	'ET' =&gt; 'Ethiopia',
	'FI' =&gt; 'Finland',
	'FJ' =&gt; 'Fiji',
	'FK' =&gt; 'Falkland Islands (Malvinas)',
	'FM' =&gt; 'Micronesia',
	'FO' =&gt; 'Faroe Islands',
	'FR' =&gt; 'France',
	'FX' =&gt; 'France, Metropolitan',
	'GA' =&gt; 'Gabon',
	'GB' =&gt; 'United Kingdom (Great Britain)',
	'GD' =&gt; 'Grenada',
	'GE' =&gt; 'Georgia',
	'GF' =&gt; 'French Guiana',
	'GH' =&gt; 'Ghana',
	'GI' =&gt; 'Gibraltar',
	'GL' =&gt; 'Greenland',
	'GM' =&gt; 'Gambia',
	'GN' =&gt; 'Guinea',
	'GP' =&gt; 'Guadeloupe',
	'GQ' =&gt; 'Equatorial Guinea',
	'GR' =&gt; 'Greece',
	'GS' =&gt; 'South Georgia and the South Sandwich Islands',
	'GT' =&gt; 'Guatemala',
	'GU' =&gt; 'Guam',
	'GW' =&gt; 'Guinea-Bissau',
	'GY' =&gt; 'Guyana',
	'HK' =&gt; 'Hong Kong',
	'HM' =&gt; 'Heard &amp;amp; McDonald Islands',
	'HN' =&gt; 'Honduras',
	'HR' =&gt; 'Croatia',
	'HT' =&gt; 'Haiti',
	'HU' =&gt; 'Hungary',
	'ID' =&gt; 'Indonesia',
	'IE' =&gt; 'Ireland',
	'IL' =&gt; 'Israel',
	'IN' =&gt; 'India',
	'IO' =&gt; 'British Indian Ocean Territory',
	'IQ' =&gt; 'Iraq',
	'IR' =&gt; 'Islamic Republic of Iran',
	'IS' =&gt; 'Iceland',
	'IT' =&gt; 'Italy',
	'JM' =&gt; 'Jamaica',
	'JO' =&gt; 'Jordan',
	'JP' =&gt; 'Japan',
	'KE' =&gt; 'Kenya',
	'KG' =&gt; 'Kyrgyzstan',
	'KH' =&gt; 'Cambodia',
	'KI' =&gt; 'Kiribati',
	'KM' =&gt; 'Comoros',
	'KN' =&gt; 'St. Kitts and Nevis',
	'KP' =&gt; 'Korea, Democratic People\'s Republic of',
	'KR' =&gt; 'Korea, Republic of',
	'KW' =&gt; 'Kuwait',
	'KY' =&gt; 'Cayman Islands',
	'KZ' =&gt; 'Kazakhstan',
	'LA' =&gt; 'Lao People\'s Democratic Republic',
	'LB' =&gt; 'Lebanon',
	'LC' =&gt; 'Saint Lucia',
	'LI' =&gt; 'Liechtenstein',
	'LK' =&gt; 'Sri Lanka',
	'LR' =&gt; 'Liberia',
	'LS' =&gt; 'Lesotho',
	'LT' =&gt; 'Lithuania',
	'LU' =&gt; 'Luxembourg',
	'LV' =&gt; 'Latvia',
	'LY' =&gt; 'Libyan Arab Jamahiriya',
	'MA' =&gt; 'Morocco',
	'MC' =&gt; 'Monaco',
	'MD' =&gt; 'Moldova, Republic of',
	'MG' =&gt; 'Madagascar',
	'MH' =&gt; 'Marshall Islands',
	'ML' =&gt; 'Mali',
	'MN' =&gt; 'Mongolia',
	'MM' =&gt; 'Myanmar',
	'MO' =&gt; 'Macau',
	'MP' =&gt; 'Northern Mariana Islands',
	'MQ' =&gt; 'Martinique',
	'MR' =&gt; 'Mauritania',
	'MS' =&gt; 'Monserrat',
	'MT' =&gt; 'Malta',
	'MU' =&gt; 'Mauritius',
	'MV' =&gt; 'Maldives',
	'MW' =&gt; 'Malawi',
	'MX' =&gt; 'Mexico',
	'MY' =&gt; 'Malaysia',
	'MZ' =&gt; 'Mozambique',
	'NA' =&gt; 'Namibia',
	'NC' =&gt; 'New Caledonia',
	'NE' =&gt; 'Niger',
	'NF' =&gt; 'Norfolk Island',
	'NG' =&gt; 'Nigeria',
	'NI' =&gt; 'Nicaragua',
	'NL' =&gt; 'Netherlands',
	'NO' =&gt; 'Norway',
	'NP' =&gt; 'Nepal',
	'NR' =&gt; 'Nauru',
	'NT' =&gt; 'Neutral Zone (no longer exists)',
	'NU' =&gt; 'Niue',
	'NZ' =&gt; 'New Zealand',
	'OM' =&gt; 'Oman',
	'PA' =&gt; 'Panama',
	'PE' =&gt; 'Peru',
	'PF' =&gt; 'French Polynesia',
	'PG' =&gt; 'Papua New Guinea',
	'PH' =&gt; 'Philippines',
	'PK' =&gt; 'Pakistan',
	'PL' =&gt; 'Poland',
	'PM' =&gt; 'St. Pierre &amp;amp; Miquelon',
	'PN' =&gt; 'Pitcairn',
	'PR' =&gt; 'Puerto Rico',
	'PT' =&gt; 'Portugal',
	'PW' =&gt; 'Palau',
	'PY' =&gt; 'Paraguay',
	'QA' =&gt; 'Qatar',
	'RE' =&gt; 'Réunion',
	'RO' =&gt; 'Romania',
	'RU' =&gt; 'Russian Federation',
	'RW' =&gt; 'Rwanda',
	'SA' =&gt; 'Saudi Arabia',
	'SB' =&gt; 'Solomon Islands',
	'SC' =&gt; 'Seychelles',
	'SD' =&gt; 'Sudan',
	'SE' =&gt; 'Sweden',
	'SG' =&gt; 'Singapore',
	'SH' =&gt; 'St. Helena',
	'SI' =&gt; 'Slovenia',
	'SJ' =&gt; 'Svalbard &amp;amp; Jan Mayen Islands',
	'SK' =&gt; 'Slovakia',
	'SL' =&gt; 'Sierra Leone',
	'SM' =&gt; 'San Marino',
	'SN' =&gt; 'Senegal',
	'SO' =&gt; 'Somalia',
	'SR' =&gt; 'Suriname',
	'ST' =&gt; 'Sao Tome &amp;amp; Principe',
	'SU' =&gt; 'Union of Soviet Socialist Republics (no longer exists)',
	'SV' =&gt; 'El Salvador',
	'SY' =&gt; 'Syrian Arab Republic',
	'SZ' =&gt; 'Swaziland',
	'TC' =&gt; 'Turks &amp;amp; Caicos Islands',
	'TD' =&gt; 'Chad',
	'TF' =&gt; 'French Southern Territories',
	'TG' =&gt; 'Togo',
	'TH' =&gt; 'Thailand',
	'TJ' =&gt; 'Tajikistan',
	'TK' =&gt; 'Tokelau',
	'TM' =&gt; 'Turkmenistan',
	'TN' =&gt; 'Tunisia',
	'TO' =&gt; 'Tonga',
	'TP' =&gt; 'East Timor',
	'TR' =&gt; 'Turkey',
	'TT' =&gt; 'Trinidad &amp;amp; Tobago',
	'TV' =&gt; 'Tuvalu',
	'TW' =&gt; 'Taiwan, Province of China',
	'TZ' =&gt; 'Tanzania, United Republic of',
	'UA' =&gt; 'Ukraine',
	'UG' =&gt; 'Uganda',
	'UM' =&gt; 'United States Minor Outlying Islands',
	'US' =&gt; 'United States of America',
	'UY' =&gt; 'Uruguay',
	'UZ' =&gt; 'Uzbekistan',
	'VA' =&gt; 'Vatican City State (Holy See)',
	'VC' =&gt; 'St. Vincent &amp;amp; the Grenadines',
	'VE' =&gt; 'Venezuela',
	'VG' =&gt; 'British Virgin Islands',
	'VI' =&gt; 'United States Virgin Islands',
	'VN' =&gt; 'Viet Nam',
	'VU' =&gt; 'Vanuatu',
	'WF' =&gt; 'Wallis &amp;amp; Futuna Islands',
	'WS' =&gt; 'Samoa',
	'YD' =&gt; 'Democratic Yemen (no longer exists)',
	'YE' =&gt; 'Yemen',
	'YT' =&gt; 'Mayotte',
	'YU' =&gt; 'Yugoslavia',
	'ZA' =&gt; 'South Africa',
	'ZM' =&gt; 'Zambia',
	'ZR' =&gt; 'Zaire',
	'ZW' =&gt; 'Zimbabwe'
);</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.robertmullaney.com/2012/08/24/iso-3316-country-list-as-php-array/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>US State List as PHP Array</title>
		<link>http://www.robertmullaney.com/2012/08/24/us-state-list-as-php-array/</link>
		<comments>http://www.robertmullaney.com/2012/08/24/us-state-list-as-php-array/#comments</comments>
		<pubDate>Sat, 25 Aug 2012 00:28:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Snippets]]></category>

		<guid isPermaLink="false">http://www.robertmullaney.com/?p=711</guid>
		<description><![CDATA[Sometimes you just don&#8217;t need this information stored in a database table Compliments my ISO-3316 Country List $states = array(     'AL' =&#62; 'Alabama',       'AK' =&#62; 'Alaska',       'AZ' =&#62; 'Arizona',       'AR' =&#62; 'Arkansas',       'CA' =&#62; 'California',       'CO' =&#62; 'Colorado',       'CT' =&#62; 'Connecticut',   [...]]]></description>
				<content:encoded><![CDATA[<p>Sometimes you just don&#8217;t need this information stored in a database table <img src='http://www.robertmullaney.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Compliments my <a title="ISO-3316 Country List as PHP Array" href="http://www.robertmullaney.com/2012/08/24/iso-3316-country-list-as-php-array/">ISO-3316 Country List</a> <img src='http://www.robertmullaney.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> <span id="more-711"></span></p>
<pre>$states = array(
    'AL' =&gt; 'Alabama',  
    'AK' =&gt; 'Alaska',  
    'AZ' =&gt; 'Arizona',  
    'AR' =&gt; 'Arkansas',  
    'CA' =&gt; 'California',  
    'CO' =&gt; 'Colorado',  
    'CT' =&gt; 'Connecticut',  
    'DE' =&gt; 'Delaware',  
    'DC' =&gt; 'District Of Columbia',  
    'FL' =&gt; 'Florida',  
    'GA' =&gt; 'Georgia',  
    'HI' =&gt; 'Hawaii',  
    'ID' =&gt; 'Idaho',  
    'IL' =&gt; 'Illinois',  
    'IN' =&gt; 'Indiana',  
    'IA' =&gt; 'Iowa',  
    'KS' =&gt; 'Kansas',  
    'KY' =&gt; 'Kentucky',  
    'LA' =&gt; 'Louisiana',  
    'ME' =&gt; 'Maine',  
    'MD' =&gt; 'Maryland',  
    'MA' =&gt; 'Massachusetts',  
    'MI' =&gt; 'Michigan',  
    'MN' =&gt; 'Minnesota',  
    'MS' =&gt; 'Mississippi',  
    'MO' =&gt; 'Missouri',  
    'MT' =&gt; 'Montana',
    'NE' =&gt; 'Nebraska',
    'NV' =&gt; 'Nevada',
    'NH' =&gt; 'New Hampshire',
    'NJ' =&gt; 'New Jersey',
    'NM' =&gt; 'New Mexico',
    'NY' =&gt; 'New York',
    'NC' =&gt; 'North Carolina',
    'ND' =&gt; 'North Dakota',
    'OH' =&gt; 'Ohio',  
    'OK' =&gt; 'Oklahoma',  
    'OR' =&gt; 'Oregon',  
    'PA' =&gt; 'Pennsylvania',  
    'RI' =&gt; 'Rhode Island',  
    'SC' =&gt; 'South Carolina',  
    'SD' =&gt; 'South Dakota',
    'TN' =&gt; 'Tennessee',  
    'TX' =&gt; 'Texas',  
    'UT' =&gt; 'Utah',  
    'VT' =&gt; 'Vermont',  
    'VA' =&gt; 'Virginia',  
    'WA' =&gt; 'Washington',  
    'WV' =&gt; 'West Virginia',  
    'WI' =&gt; 'Wisconsin',  
    'WY' =&gt; 'Wyoming'
);</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.robertmullaney.com/2012/08/24/us-state-list-as-php-array/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Auto-claim Zynga Rewards (Everybody &amp; Friends)</title>
		<link>http://www.robertmullaney.com/2012/08/24/auto-claim-zynga-rewards-everybody-friends/</link>
		<comments>http://www.robertmullaney.com/2012/08/24/auto-claim-zynga-rewards-everybody-friends/#comments</comments>
		<pubDate>Fri, 24 Aug 2012 23:26:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[Gaming]]></category>
		<category><![CDATA[bookmark]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.robertmullaney.com/?p=707</guid>
		<description><![CDATA[Here&#8217;s a little bookmarklet I wrote that you can add use automatically collect Zynga rewards while you&#8217;re playing games over at Zynga.com. It seems to work for all rewards regardless of which game you&#8217;re playing (though I primarily use it for CastleVille). javascript:var classesPublic='zui_list_itemsContainer zui_zdc_gameboard_rts_rtsList_itemsContainer zui_zdc_gameboard_rts_rtsPublicList_itemsContainer';var classesNeighbors='zui_list_itemsContainer zui_zdc_gameboard_rts_rtsList_itemsContainer zui_zdc_gameboard_rts_rtsNeighborList_itemsContainer';var classesButtons='zui zui_button zui_enabled zui_button_enabled zui_zdc zui_button_zdc [...]]]></description>
				<content:encoded><![CDATA[<p>Here&#8217;s a little <em>bookmarklet</em> I wrote that you can add use automatically collect Zynga rewards while you&#8217;re playing games over at Zynga.com. It seems to work for all rewards regardless of which game you&#8217;re playing (though I primarily use it for CastleVille).</p>
<pre>javascript:var classesPublic='zui_list_itemsContainer zui_zdc_gameboard_rts_rtsList_itemsContainer zui_zdc_gameboard_rts_rtsPublicList_itemsContainer';var classesNeighbors='zui_list_itemsContainer zui_zdc_gameboard_rts_rtsList_itemsContainer zui_zdc_gameboard_rts_rtsNeighborList_itemsContainer';var classesButtons='zui zui_button zui_enabled zui_button_enabled zui_zdc zui_button_zdc zui_zdc_enabled zui_button_zdc_enabled zui_button_tiny zui_button_white';var unclaimedRewardsNeighbors,unclaimedRewardsPublic;var unclaimedNeighborsInit=unclaimedPublicInit=true;function collectRewardsNeighbors(){for(unclaimedIndex=0;unclaimedIndex=1){if(unclaimedNeighborsInit){unclaimedNeighborsInit=false;collectRewardsNeighbors();}else{setTimeout('collectRewardsNeighbors()',1000);}}},false);var parentUnclaimedPublic=document.getElementsByClassName(classesPublic)[0];parentUnclaimedPublic.addEventListener('DOMSubtreeModified',function(){unclaimedRewardsPublic=parentUnclaimedPublic.getElementsByClassName(classesButtons);if(unclaimedRewardsPublic.length&gt;=1){if(unclaimedPublicInit){unclaimedPublicInit=false;collectRewardsPublic();}else{setTimeout('collectRewardsPublic()',1000);}}},false);</pre>
<p>What you need to do, is copy the code above and paste it into a new bookmark within your browser. Couldn&#8217;t be easier <img src='http://www.robertmullaney.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Note: This script requires a browser that supports the DOMSubtreeModified &#8211; <a href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-eventgroupings-mutationevents" target="_blank">DOM Level 2 Mutation Event</a> (eg: IE9, FF, Safari and Chrome)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.robertmullaney.com/2012/08/24/auto-claim-zynga-rewards-everybody-friends/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery UI replacement for javascript:confirm() links</title>
		<link>http://www.robertmullaney.com/2012/07/20/jquery-ui-replacement-javascript-confirm-links/</link>
		<comments>http://www.robertmullaney.com/2012/07/20/jquery-ui-replacement-javascript-confirm-links/#comments</comments>
		<pubDate>Fri, 20 Jul 2012 18:34:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[dialog]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery ui]]></category>

		<guid isPermaLink="false">http://www.robertmullaney.com/?p=701</guid>
		<description><![CDATA[Here is a nice confirmation handler to replace javascript:confim() links using jQuery UI&#8230; $(function() {     $('.ui-icon-trash').click(function(event){         event.preventDefault();         var targetUrl = $(this).attr('href');         $('&#60;div title="Confirmation Required"&#62;&#60;p&#62;Delete this record?&#60;/p&#62;&#60;/div&#62;').dialog({             autoOpen: true,             modal: true,             resizable: false,             buttons: {        [...]]]></description>
				<content:encoded><![CDATA[<p>Here is a nice confirmation handler to replace javascript:confim() links using jQuery UI&#8230;</p>
<pre>$(function() {
    $('.ui-icon-trash').click(function(event){
        event.preventDefault();
        var targetUrl = $(this).attr('href');
        $('&lt;div title="Confirmation Required"&gt;&lt;p&gt;Delete this record?&lt;/p&gt;&lt;/div&gt;').dialog({
            autoOpen: true,
            modal: true,
            resizable: false,
            buttons: {
                Yes: function() {
                    window.location.href = targetUrl;
                },
                No: function() {
                    $(this).remove();
                }
            }
        });
    });
});</pre>
<p>I use it for &#8220;delete&#8221; links (should be obvious) but it can be easily adjusted for any other type of confirmation.</p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.robertmullaney.com/2012/07/20/jquery-ui-replacement-javascript-confirm-links/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generic Database Table Model for CodeIgniter 2.x</title>
		<link>http://www.robertmullaney.com/2012/07/12/generic-database-table-model-codeigniter-2/</link>
		<comments>http://www.robertmullaney.com/2012/07/12/generic-database-table-model-codeigniter-2/#comments</comments>
		<pubDate>Thu, 12 Jul 2012 18:32:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.robertmullaney.com/?p=691</guid>
		<description><![CDATA[For a while I had been wanting to author a generic database table model for CodeIgniter. Here are the results of those efforts&#8230; The model: &#60;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); /**  * Generic Database Table Model for CodeIgniter 2.x  *  * @author        Robert Mullaney  * @link        http://www.robertmullaney.com/2012/07/12/generic-database-table-model-codeigniter-2  */ [...]]]></description>
				<content:encoded><![CDATA[<p>For a while I had been wanting to author a generic database table model for CodeIgniter. Here are the results of those efforts&#8230;<span id="more-691"></span></p>
<p>The model:</p>
<pre>&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * Generic Database Table Model for CodeIgniter 2.x
 *
 * @author        Robert Mullaney
 * @link        http://www.robertmullaney.com/2012/07/12/generic-database-table-model-codeigniter-2
 */
class Generic_model extends CI_Model {

    var $table_name = '';  //required
    var $field_prefix = '';
    var $primary_key = ''; //required
    var $select_fields = '*';
    var $num_rows = 0;
    var $insert_id = 0;
    var $affected_rows = 0;
    var $last_query = '';
    var $error_msg = array();

    public function initialize($params = array())
    {
        if (count($params) &gt; 0) {
            foreach ($params as $key =&gt; $val) {
                if (isset($this-&gt;$key)) {
                    $this-&gt;$key = $val;
                }
            }
        }
        if ($this-&gt;table_name == '') {
            $this-&gt;_set_error('table_name_required');
        }
        if ($this-&gt;primary_key == '') {
            $this-&gt;_set_error('primary_key_required');
        }
        if (count($this-&gt;error_msg) &gt; 0) {
            return FALSE;
        }
    }
    
    public function get($limit = NULL, $offset = NULL, $sort = NULL, $search = NULL)
    {
        if ($limit !== NULL) $limit = (int) $limit;
        if ($offset !== NULL) $offset = (int) $offset;
        if (is_array($sort)) {
            foreach ($sort as $field =&gt; $order) {
                $this-&gt;db-&gt;order_by($this-&gt;field_prefix . $field, $order);
            }
        }
        if (is_array($search)) {
            foreach ($search as $field =&gt; $match) {
                $this-&gt;db-&gt;like($this-&gt;field_prefix . $field, $match);
            }
        }
        $this-&gt;db-&gt;select($this-&gt;select_fields);
        $query = $this-&gt;db-&gt;get($this-&gt;table_name, $limit, $offset);
        $this-&gt;last_query = $this-&gt;db-&gt;last_query();
        $this-&gt;num_rows = $this-&gt;_num_rows($search);
        return ($limit == 1) ? $query-&gt;row() : $query-&gt;result();
    }

    public function insert($data = array())
    {
        if (is_array($data)) {
            $this-&gt;db-&gt;insert($this-&gt;table_name, $data);
            $this-&gt;insert_id = $this-&gt;db-&gt;insert_id();
            $this-&gt;_optimize();
        }
    }
    
    public function update($id = 0, $data = array())
    {
        $id = (int) $id;
        if ($id &amp;&amp; is_array($data)) {
            $this-&gt;db-&gt;where($this-&gt;primary_key, $id);
            $this-&gt;db-&gt;update($this-&gt;table_name, $data); 
            $this-&gt;_optimize();
        }
    }
    
    public function delete($id = 0)
    {
        $id = (int) $id;
        if ($id) {
            $this-&gt;db-&gt;where($this-&gt;primary_key, $id);
            $this-&gt;db-&gt;delete($this-&gt;table_name); 
            $this-&gt;_optimize();
        }
    }
    
    private function _num_rows($search = NULL)
    {
        if ($search !== NULL) {
            foreach ($search as $field =&gt; $match) {
                $this-&gt;db-&gt;like($this-&gt;field_prefix . $field, $match);
            }
            return $this-&gt;db-&gt;count_all_results($this-&gt;table_name);
        }
        return $this-&gt;db-&gt;count_all($this-&gt;table_name);
    }

    private function _optimize()
    {
        $this-&gt;last_query = $this-&gt;db-&gt;last_query();
        $this-&gt;affected_rows = $this-&gt;db-&gt;affected_rows();
        $this-&gt;load-&gt;dbutil();
        $this-&gt;dbutil-&gt;optimize_table($this-&gt;table_name);
    }

    private function _set_error($msg)
    {
        if (is_array($msg)) {
            foreach ($msg as $val) {
                $this-&gt;error_msg[] = $val;
                log_message('error', $val);
            }
        } else {
            $this-&gt;error_msg[] = $msg;
            log_message('error', $msg);
        }
    }

    public function display_errors($open = '&lt;p&gt;', $close = '&lt;/p&gt;')    {
        $str = '';
        foreach ($this-&gt;error_msg as $val) {
            $str .= $open . $val . $close;
        }
        return $str;
    }

}

/* End of file generic_model.php */
/* Location: ./application/models/generic_model.php */</pre>
<p>Basic select usage:</p>
<pre>$this-&gt;load-&gt;model('generic_model');
$this-&gt;generic_model-&gt;initialize(array(
    'table_name'    =&gt; 'users',
    'field_prefix'    =&gt; 'user_',
    'primary_key'    =&gt; 'user_id',
    'select_fields'    =&gt; 'user_id, user_email, user_password'
));
$user = $this-&gt;generic_model-&gt;get(1, NULL, NULL, array(
    'username'    =&gt; $this-&gt;input-&gt;post('user')),
    'password'    =&gt; $this-&gt;input-&gt;post('pass'))
);</pre>
<p>The other functions within the model should be easily understandable. Feel free to comment if something doesn&#8217;t make sense to you. <img src='http://www.robertmullaney.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.robertmullaney.com/2012/07/12/generic-database-table-model-codeigniter-2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
