<?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>PHP ROCKSTAR</title>
	<atom:link href="http://blog.moorberry.biz/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.moorberry.biz</link>
	<description>Public blog about PHP programming and how it interacts with the user-interface</description>
	<lastBuildDate>Thu, 15 Jul 2010 17:43:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>10 Productive PHP Functions that You Can Integrate into Your own Applications</title>
		<link>http://blog.moorberry.biz/2010/05/php-functions/</link>
		<comments>http://blog.moorberry.biz/2010/05/php-functions/#comments</comments>
		<pubDate>Fri, 14 May 2010 05:40:15 +0000</pubDate>
		<dc:creator>Michael Minter</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Review]]></category>
		<category><![CDATA[app]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[classes]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[constructive]]></category>
		<category><![CDATA[creative]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[downlaod]]></category>
		<category><![CDATA[format]]></category>
		<category><![CDATA[freelancers]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[helpful]]></category>
		<category><![CDATA[inspiration]]></category>
		<category><![CDATA[money]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[pre-built]]></category>
		<category><![CDATA[productive]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[tinyurl]]></category>
		<category><![CDATA[tinyurl.com]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://blog.moorberry.biz/?p=281</guid>
		<description><![CDATA[The following custom PHP functions have all been pulled from multiple resources, to generate a heartfelt appreciation for all the developers, whom share their program-expertise with the online public.]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-303" title="php-functions2" src="http://blog.moorberry.biz/wp-content/uploads/2010/05/php-functions2.jpg" alt="" width="560" height="200" /></p>
<p>The following custom PHP functions have all been pulled from multiple resources, to generate a heartfelt <strong>appreciation for</strong> all the developers, whom share their program-expertise with the online public.</p>
<p>A small degree of <strong>PHP knowledge is expected</strong>, to understand what every function is capable of, as I wont be going over them in great detail.</p>
<p><strong>Please submit</strong> any advice, code fixes, and|or personal favorites; <strong>in the comments section</strong> at the bottom of this post. Thank you</p>
<h3>1. Random Number</h3>
<pre>function unique_id($option) {
    $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    srand((double)microtime()*1000000);
    $i = 1;
    $rand = '' ;
    while ($i &lt;= $option) {
        $num = rand() % 33;
        $tmp = substr($chars, $num, 1);
        $rand = $rand . $tmp;
        $i++;
    }
    return $rand;
}
</pre>
<p>Although no random number generator can provide 100% accuracy, unless you assess all opposing variables, <strong>unique_id()</strong> stands very well on its own.</p>
<p><a href="http://blog.moorberry.biz" target="_blank">Michael Minter</a></p>
<h3>2. Update Your Twitter Status</h3>
<pre>function tweetThis($strUsername = '', $strPassword = '', $strMessage = '') {
    if (function_exists('curl_init')) {
        $twitterUsername = trim($strUsername);
        $twitterPassword = trim($strPassword);
        if(strlen($strMessage) &gt; 140) {
            $strMessage = substr($strMessage, 0, 140);
        }
        $twitterStatus = htmlentities(trim(strip_tags($strMessage)));
        if (!empty($twitterUsername) &amp;&amp; !empty($twitterPassword) &amp;&amp; !empty($twitterStatus)) {
            $strTweetUrl = 'http://www.twitter.com/statuses/update.xml';
            $objCurlHandle = curl_init();
            curl_setopt($objCurlHandle, CURLOPT_URL, "$strTweetUrl");
            curl_setopt($objCurlHandle, CURLOPT_CONNECTTIMEOUT, 2);
            curl_setopt($objCurlHandle, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($objCurlHandle, CURLOPT_POST, 1);
            curl_setopt($objCurlHandle, CURLOPT_POSTFIELDS, "status=$twitterStatus");
            curl_setopt($objCurlHandle, CURLOPT_USERPWD, "$twitterUsername:$twitterPassword");
            $result = curl_exec($objCurlHandle);
            $arrResult = curl_getinfo($objCurlHandle);
            if ($arrResult['http_code'] == 200) {
                echo 'Your Tweet has been posted';
            }  else {
                echo 'Could not post your Tweet to Twitter.';
            }
            curl_close($objCurlHandle);
        } else {
            echo('Missing required information to submit your Tweet.');
        }
    } else {
        echo('Curl Extension is not installed.');
    }
}
</pre>
<p><strong>tweetThis()</strong> adds direct glorification of being able to Tweet on a moment&#8217;s notice. Should be a privilege to use in existing functions to autonomously update followers of unique actions or as a manual social network plug-in.</p>
<p><a href="http://www.richardcastera.com" target="_blank">Richard Castera</a></p>
<h3>4. Shorten a URL with TinyURL</h3>
<pre>function ShortURL($toConvert) {
    $shortURL= file_get_contents('http://tinyurl.com/api-create.php?url=' . $toConvert);
    return $shortURL;
}
</pre>
<p><strong>shortURL()</strong> will go well (intentionally) with the tweetThis() function, listed above, if you know that you&#8217;ll be using long links.</p>
<p><a href="http://snipplr.com/popular/language/php" target="_blank">Snipplr.com</a></p>
<h3>3. Replace bad Words</h3>
<pre>function ReplaceBadWords($str, $bad_words, $replace_str){
    if (!is_array($bad_words)){ $bad_words = explode(',', $bad_words); }
    for ($x=0; $x &lt; count($bad_words); $x++){
        $fix = isset($bad_words[$x]) ? $bad_words[$x] : '';
        $_replace_str = $replace_str;
        if (strlen($replace_str)==1){
            $_replace_str = str_pad($_replace_str, strlen($fix), $replace_str);
        }
        $str = preg_replace('/'.$fix.'/i', $_replace_str, $str);
    }
    return $str;
}
$bad_words = array('fanny','socialism');
echo ReplaceBadWords($str, $bad_words, $replace_str);
</pre>
<p>I do not condone censorship in any medium. Although I&#8217;m still certain that you can find some excuse to modify and use <strong>ReplaceBadWords()</strong> in some of your work.</p>
<p><a href="http://www.jonasjohn.de/snippets/php/" target="_blank">Jonas John</a></p>
<h3>5. Capitalize the first Word of every Sentence</h3>
<pre>function uc_sentences($sString) {
    $sString = strtolower($sString);
    $words = split(" ", $sString); // each entry in array $words is a word from the string
    $firstword = false;
    $sNewString = "";
    foreach($words AS $wordkey=&gt;$word) {
        $word = trim($word); // just in case people double-space between sentences
        $lastchar = substr($word, -1); // $lastchar is used to determine if end-of-sentence is here
        if(($firstword) OR ($wordkey==0)) { // if it's the start of sentence then we capitalize the word
            $word = ucfirst($word);
            $firstword = false;
            $sNewString = $sNewString . " $word"; // add the word to the output string
        } elseif(($lastchar==".") OR($lastchar=="!") OR ($lastchar=="?")) { // you can add more chars if you need to
            $firstword = true; // now the next word will be first word of new sentence
            $sNewString = $sNewString . " $word"; // add the word to the output string
        } else {
            $sNewString = $sNewString . " $word"; // add the word to the output string
        }
    }
    $sNewString = trim($sNewString); // sometimes an extra space at beginning or end occurs, so this fixes it
    return $sNewString; // return the new string
}

$badstring = "I LIKE TO EAT POTATO CHIPS. GO EAT POTATO CHIPS! WHERE ARE THE CHIPS?"; // example string
print uc_sentences($badstring); // this will print "I like to eat potato chips. Go eat potato chips. Where are the potato chips?"
</pre>
<p><strong>uc_sentences() </strong>comes in real handy when dealing with dynamic paragraphs from any user submitted data. I use this consistently with customizable &#8220;About me&#8221; sections of a website.</p>
<p><a href="http://www.phpbuilder.com/snippet/" target="_blank">PHPBuilder.com</a></p>
<h3>6. Force file download</h3>
<pre>function force_download($file) {
    if ((isset($file))&amp;&amp;(file_exists($file))) {
        header("Content-length: ".filesize($file));
        header('Content-Type: application/octet-stream');
        header('Content-Disposition: attachment; filename="' . $file . '"');
        readfile("$file");
    } else {
        echo "No file selected";
    }
}
</pre>
<p>Do you want to provide a download for a file that needs to be rendered in another format, or requires a function to count the instances in which it&#8217;s called, than you&#8217;ll want to use <strong>force_download()</strong>. Easy to call, with a simple, <em>download.php?file=$file</em>.</p>
<p><a href="http://webdeveloperplus.com/php" target="_blank">WebDeveloperPlus.com</a></p>
<h3>7. Add notation to the end of numbers</h3>
<pre>function ordinal($num){
    $test_c = abs($num) % 10;
    $ext = ((abs($num) %100 &lt; 21 &amp;&amp; abs($num) %100 &gt; 4) ? 'th'
        : (($test_c &lt; 4) ? ($test_c &lt; 3) ? ($test_c &lt; 2) ? ($test_c &lt; 1)
        ? 'th' : 'st' : 'nd' : 'rd' : 'th'));
    return $num.$ext;
}
</pre>
<p>When I need to call a stamped number like this, I usually write out something out with <em>date()</em>. But <strong>ordinal()</strong>, I expect, would be a great resource for working with any kind of mathematical or scientific features.</p>
<p><a href="http://phpsnips.com" target="_blank">PHPSnippets</a></p>
<h3>8. Truncate a string</h3>
<pre>function truncate($text, $limit = 25, $ending = '...') {
    if (strlen($text) &gt; $limit) {
        $text = strip_tags($text);
        $text = substr($text, 0, $limit);
        $text = substr($text, 0, -(strlen(strrchr($text, ' '))));
        $text = $text . $ending;
    }
    return $text;
}
</pre>
<p><strong>truncate()</strong> takes a string and shortens it to a defined length. If the maximum character length falls in the middle of a word then the function moves the pointer to the previous space. Finishes by appending an ellipsis (or custom string) to the end.</p>
<p><a href="http://www.milesj.me/" target="_blank">Miles Johnson</a></p>
<h3>9. Simple hit-counter counter</h3>
<pre>function hits() {
    if (!file_exists('./hits.txt')) {
        $hits = 0;
        file_put_contents('./hits.txt', $hits);
    } else {
        $hits = file_get_contents('./hits.txt');
        $hits = hits + 1;
        file_put_contents('./hits.txt', $hits);
    }
    return $hits;
}
echo hits();
</pre>
<p><strong>hits()</strong> is about as easy as it gets. But as I do, as often as possible, I hope that you take most of the code you get from the Internet and make it more accessible to your tastes anyhow.</p>
<p><a href="http://www.phpsnaps.com/snaps" target="_blank">PHPSnaps.com</a></p>
<h3>10. Dollar format</h3>
<pre>function dollar_format($amount) {
    if (preg_match('/^([0-9]+\.[0-9])$/', $amount)) {
       $newAmount = money_format('%.2n', $amount);
    } else {
       $newAmount = $amount;
   }
   return $newAmount;
}
</pre>
<p>There is a few different methods available to print formatted numbers to show like money. But I recently needed something that only printed the change as change was required. The result is <strong>dollar_format()</strong>.</p>
<p><a href="http://blog.moorberry.biz" target="_blank">Michael Minter</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.moorberry.biz/2010/05/php-functions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Pre-Render Dynamically Resized Images with the PHP-GD Library</title>
		<link>http://blog.moorberry.biz/2010/04/php-gd-library/</link>
		<comments>http://blog.moorberry.biz/2010/04/php-gd-library/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 17:35:01 +0000</pubDate>
		<dc:creator>Michael Minter</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[article]]></category>
		<category><![CDATA[autonomous]]></category>
		<category><![CDATA[dynamic]]></category>
		<category><![CDATA[exacting]]></category>
		<category><![CDATA[gallery]]></category>
		<category><![CDATA[gd]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[photo]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[resize]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blog.godhacked.com/?p=71</guid>
		<description><![CDATA[If you&#8217;ve been frustrated with having to resize images for the sake of continuity or load time and don&#8217;t want to develop an entire caching system than this post will be of great value to you. Today I will discusses the theory and resolve of applying a system to autonomously resize images, with the GD library for [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve been frustrated with having to <strong>resize images</strong> for the sake of continuity or load time and don&#8217;t want to develop an entire caching system than this post will be of great value to you.</p>
<p>Today I will discusses the theory and resolve of applying a system to autonomously <strong>resize images</strong>, with the <strong>GD library</strong> for <strong>PHP</strong>, before they get requested by the browser.</p>
<p>This practice presents many benefits to its use.</p>
<ol>
<li>Save loads of hard drive space</li>
<li>Easy to resize div backgrounds</li>
<li>Faster to call than the use of <a href="http://blog.moorberry.biz/2010/03/php-vs-javascript/" target="_blank">JavaScript</a>.</li>
</ol>
<h3>Calling the Application With HTML</h3>
<pre lang="PHP">&lt;img src="image.php?i=image.jpg&amp;s=500" /&gt;</pre>
<p>Calling the php script is this easy. You can place this tag anywhere on any page and be able to display an image, with exact value constraints, and as many times as you need.</p>
<h3>Developing the image.php Application</h3>
<pre>header("Content-Type: image/jpeg");</pre>
<p><a href="http://us3.php.net/manual/en/function.header.php" target="_blank">header()</a> will make sure that the browser is aware how to handle the applicaton. Here it enables the page to be viewed as a jpeg source.</p>
<pre lang="PHP">if (!isset($_GET['s'])) {
    $size = 160;
} else {
    $size = $_GET['s'];
}
$image = $_GET['i'];

list($width, $height) = getimagesize($image);

$ratio = $width/$height;

if ($ratio &gt; 1) {
    $newWidth  = $size;
    $newHeight = $size/$ratio;
} else {
    $newHeight = $size;
    $newWidth  = $size*$ratio;
}
// creates a copy of the loaded image
$create = imagecreatefromjpeg($image);
// creates a blank template to work from
$template = imagecreatetruecolor($newWidth,$newHeight);
// copies the original onto the new template
imagecopyresized($template, $create, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
// displays the image
ImageJpeg($template);</pre>
<p>Usually I break this larger portion of my post up into smaller pieces so I can reference all the code being used and what it does. But the fundamentals are so well noted and easy to navigate, that I figured even if I left it as so, that you should have no problem implementing this into your own work.</p>
<h3>Error catching</h3>
<p>If source material is not working properly. Issue the following:</p>
<pre lang="PHP">if(!function_exists('imagecreatetruecolor')) {
    exit('Err, function : imagecreatetruecolor does not exist');
}</pre>
<p><a href="http://php.net/manual/en/function.function-exists.php" target="_blank">function_exists()</a> will check the currently active Apache function repository, both internal and user-defined, to see if the listed function matches anything available.</p>
<p>If you&#8217;re receiving the error message than the server you&#8217;re running this code on does not support the GD library and you must either <a href="http://www.php.net/manual/en/image.setup.php" target="_blank">set it up manually</a> or <a href="http://moorberry.biz" target="_blank">contact an administrator</a> to do so for you.</p>
<p>Also note that only Jpeg formats are acceptable by this set up. Extending is not a difficult task. I only wanted you to understand the basics and be able to evolve with PHP from my writings.</p>
<h3>Summary</h3>
<p>Hopefully I&#8217;ve left more than enough room for you to adapt this into your own projects. You can add on to this with many of the <a href="http://php.net/manual/en/book.image.php" target="_blank">GD library</a> features documented by the PHP network.</p>
<p>If you develop an extension or even a class, from these tips, please feel free to share by commenting back and letting me know what you&#8217;ve done.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.moorberry.biz/2010/04/php-gd-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bare-bones way of using Paypal&#8217;s Express Checkout NVP API with PHP</title>
		<link>http://blog.moorberry.biz/2010/04/paypal-nvp-api/</link>
		<comments>http://blog.moorberry.biz/2010/04/paypal-nvp-api/#comments</comments>
		<pubDate>Sat, 03 Apr 2010 22:01:26 +0000</pubDate>
		<dc:creator>Michael Minter</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[checkout]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[doexpresscheckoutpayment]]></category>
		<category><![CDATA[express]]></category>
		<category><![CDATA[getexpresscheckoutdetails]]></category>
		<category><![CDATA[getresponse]]></category>
		<category><![CDATA[key]]></category>
		<category><![CDATA[money]]></category>
		<category><![CDATA[name value pair]]></category>
		<category><![CDATA[nvp]]></category>
		<category><![CDATA[payment]]></category>
		<category><![CDATA[paypal]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[secure]]></category>
		<category><![CDATA[setexpresscheckout]]></category>
		<category><![CDATA[setnvp]]></category>
		<category><![CDATA[shopping cart]]></category>
		<category><![CDATA[transfer]]></category>

		<guid isPermaLink="false">http://blog.godhacked.com/?p=199</guid>
		<description><![CDATA[There's a few different ways that you could go about setting this kind of system up. So I'll let you handle the method on an individual basis, but explain how these functions work, and what happens when they're called.]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t know why <strong>Paypal</strong> has written its documentation on the subject of, using the <strong>Express Checkout name value pair </strong><strong>API with </strong><strong>PHP,</strong> with such an unreadable manner. The classes used with the Paypal API are extremely easy to use. All of this is likely contributing to the confusion about using Express Checkout. But I&#8217;m here now, to save your application, and possibly your sanity.</p>
<p>I&#8217;m going to explain why the API objects work and what happens when they&#8217;re called. There&#8217;s a few different ways that you could go about setting up the product and or service details. So I&#8217;ll keep this post relative to the main focus points and let you handle the before and after parts on an individual basis.</p>
<p><img class="alignnone size-full wp-image-220" title="checkout01" src="http://blog.moorberry.biz/wp-content/uploads/2010/03/checkout01.jpg" alt="" width="560" /></p>
<h3>Referring payment authentication</h3>
<pre>$paypal = new SetExpressCheckout($totalPrice);</pre>
<p>We start out by calling the <strong>SetExpressCheckOut()</strong> class. It contains the functions you&#8217;ll use to redirect the customer to Paypal along with data to differentiate each customer at the completion of the sale. A variable of the total price has to be set to complete the initiation of this class.</p>
<pre>$paypal-&gt;setNVP("RETURNURL", "http://yourURL.com/confirm.php");
$paypal-&gt;setNVP("HDRIMG", "http://yourURL.com/image.jpg");
$paypal-&gt;setNVP("EMAIL", "$userEmail"); // customer's email
$paypal-&gt;setNVP("AMT", $totalPrice);
$paypal-&gt;setNVP("SHIPPINGAMT", "32");
$paypal-&gt;setNVP("CUSTOM", "Anything you want to put");
$paypal-&gt;setNVP("INVNUM", $uniqueID); // personal invoice number</pre>
<p>Before you submit for a transfer to Paypal, know that there are optional values you can send with<strong> </strong>the <strong>setNVP()</strong> function, to customize the payment process. All values that can be found, by default, in the <em>etc/NVP/SetExpressCheckout.ini</em> file. I&#8217;ve included a list of common practice examples and how to use them in this template.</p>
<pre>$paypal-&gt;getResponse();</pre>
<p><strong>getResponse()</strong> sends the user&#8217;s browser to Paypal for authentication of credit information. Specifically to a URL that you&#8217;ll have to variably set between test mode (sandbox) and live, in the file named <em>etc/NVP/PayPalNVP.ini</em>.</p>
<p><img class="alignnone size-full wp-image-221" title="checkout02" src="http://blog.moorberry.biz/wp-content/uploads/2010/03/checkout02.jpg" alt="" width="560" /></p>
<h3>Completing the Sale</h3>
<pre>$paypal = new GetExpressCheckoutDetails;
$details = $paypal-&gt;getResponse();</pre>
<p><strong>GetExpressCheckoutDetails()</strong> is a class that is most responsible for presenting the custom specifications that you originally sent with SetExpressCheckOut() and SetNVP().</p>
<p><strong>getResponse()</strong> will gather all of the available options as an array, labelled <strong>$details</strong>.</p>
<pre>$payment = new DoExpressCheckoutPayment($totalPrice);
$response = $payment-&gt;getResponse();</pre>
<p><strong>DoExpressCheckoutPayment()</strong> will instinctively initiate a communication with Paypal to notify the service that you are ready for the payment to be transferred to your account. The only necessary requisite, of calling this class and it calling to action, is to include the total price in its variable containment field.</p>
<p><strong>getResponse() </strong>will gather the resulting responses by DoExpressCheckoutPayment() and include them in an array, labelled <strong>$response</strong>.</p>
<p>It could be said that you could apply another (final) verification for your customer to submit before the transaction is completed by DoExpressCheckoutPayment(). But not technically necessary.</p>
<pre>if ($response['PAYMENTSTATUS'] == 'Completed') {
    //process information
}</pre>
<p>One of the returned values in $response will be the <strong>PAYMENTSTATUS</strong> key. This is a string result that confirms whether or not the money has made been payed to your account. It will definitely be useful when you set up your system to print an invoice on <strong>complete</strong>, or some insightfully-formatted summary on <strong>failure</strong>.</p>
<h3>Displaying results from getRespnse</h3>
<pre>echo '&lt;pre&gt;';
print_r($details);
echo '&lt;pre&gt;';
print_r($payment_response);
</pre>
<p>The above code should print out something similar to the following:</p>
<pre>Array
(
    [TOKEN] =&gt; EC%2d8DS53628GJ4630109
    [TIMESTAMP] =&gt; 2010%2d03%2d31T08%3a25%3a40Z
    [CORRELATIONID] =&gt; ce3e460d38d2f
    [ACK] =&gt; Success
    [VERSION] =&gt; 51%2e0
    [BUILD] =&gt; 1247606
    [EMAIL] =&gt; test_acct_36654645742_per%40domain%2ecom
    [PAYERID] =&gt; W96GXTA5P9BRN
    [PAYERSTATUS] =&gt; verified
    [FIRSTNAME] =&gt; Test
    [LASTNAME] =&gt; User
    [COUNTRYCODE] =&gt; US
    [SHIPTONAME] =&gt; Test%20User
    [SHIPTOSTREET] =&gt; 1%20Main%20St
    [SHIPTOCITY] =&gt; San%20Jose
    [SHIPTOSTATE] =&gt; CA
    [SHIPTOZIP] =&gt; 95131
    [SHIPTOCOUNTRYCODE] =&gt; US
    [SHIPTOCOUNTRYNAME] =&gt; United%20States
    [ADDRESSSTATUS] =&gt; Confirmed
    [CUSTOM] =&gt; Anything you want to put
    [INVNUM] =&gt; IYUUFEOAS0ME3MTI
)
</pre>
<pre>Array
(
    [TOKEN] =&gt; EC%2d8DS53628GJ4630109
    [TIMESTAMP] =&gt; 2010%2d03%2d31T08%3a25%3a43Z
    [CORRELATIONID] =&gt; b1989df39a0ca
    [ACK] =&gt; Success
    [VERSION] =&gt; 51%2e0
    [BUILD] =&gt; 1247606
    [TRANSACTIONID] =&gt; 1PR0061154034542X
    [TRANSACTIONTYPE] =&gt; expresscheckout
    [PAYMENTTYPE] =&gt; instant
    [ORDERTIME] =&gt; 2010%2d03%2d31T08%3a25%3a42Z
    [AMT] =&gt; 152%2e00
    [FEEAMT] =&gt; 4%2e71
    [TAXAMT] =&gt; 0%2e00
    [CURRENCYCODE] =&gt; USD
    [PAYMENTSTATUS] =&gt; Completed
    [PENDINGREASON] =&gt; None
    [REASONCODE] =&gt; None
)</pre>
<h3>Testing</h3>
<p>If you don&#8217;t have a <a href="http://developer.paypal.com/" target="_blank">Paypal developer account</a>, than you should certainly sign up for one to use Paypal&#8217;s Sandbox, which makes a mock version of Paypal available for testing. Comes complete with personal and business accounts, each with their own credentials, and unlimited funds.</p>
<h3>Summary</h3>
<p>Follow the preceding order and you could easily narrow this code down to a a single file, with enough<a href="http://php.net/manual/en/control-structures.if.php" target="_blank"> if()</a> constructs, or span it out to many.</p>
<p>You might be left wondering why it seems less daunting than you have expected. That would be because you&#8217;re right. These few objects are all that&#8217;s needed to handle a shopping cart system on your website.</p>
<p>Maybe Paypal will use this post to refer new users trying to understand how this system works. But I doubt it.</p>
<p><a href="http://blog.godhacked.com/wp-content/uploads/2010/03/paypal_nvp_api.zip">Download now</a> (.zip)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.moorberry.biz/2010/04/paypal-nvp-api/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Analysis of Slow Response Times With Javascript Versus PHP</title>
		<link>http://blog.moorberry.biz/2010/03/php-vs-javascript/</link>
		<comments>http://blog.moorberry.biz/2010/03/php-vs-javascript/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 04:21:04 +0000</pubDate>
		<dc:creator>Michael Minter</dc:creator>
				<category><![CDATA[Analytics]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[alternating rows]]></category>
		<category><![CDATA[analysis]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[zebra]]></category>

		<guid isPermaLink="false">http://blog.godhacked.com/?p=77</guid>
		<description><![CDATA[I can only presume that it's because of the passionate advent of JQuery, that there has been an increasing rise of using Javascript, in precedence of PHP. This circumstance is arguably the sole cause to how and why designers are simply not learning a better way. I'm here to enlighten you.]]></description>
			<content:encoded><![CDATA[<p>I can only presume that it&#8217;s because of the passionate advent of JQuery, that there has been an increasing rise of using <strong>Javascript</strong>, in precedence of <strong>PHP</strong>. This circumstance is arguably the sole cause to how and why designers are simply not learning a better way. I&#8217;m here to enlighten you.</p>
<p>In opening, I&#8217;d like to express, that I hold no animosity for Javascript. Actually I quite often fancy a touch of its elegant lure and almost regularly indulge my viewers with its properties to control aesthetics at a dynamic fashion. But it has its place. If PHP can serve the same purpose, than its obvious strengths, should not be taken for granted.</p>
<p>One prominent example of this that I seem to notice more often in use than others, is the  application of color alternating rows with HTML tables, or also favorably known as the &#8220;zebra&#8221; effect. Which I&#8217;ll be using for my reference material.</p>
<h3>Zebra With PHP</h3>
<pre lang="PHP">for ($i = 1;$i &lt; 10;$i++) {
    if (($i % 2) == 0) {
        echo '&lt;tr class="zebra"&gt;';
    } else {
        echo '&lt;tr&gt;';
    }
}</pre>
<p>The <a href="http://php.net/manual/en/control-structures.for.php" target="_blank">for()</a> loop, does the accumulating work. It exponentially raises the default value ($i) by one, each iteration, so that the <a href="http://php.net/manual/en/language.operators.arithmetic.php" target="_blank">modulus operator</a> (%) can equate the remainder of <var><var>$i</var></var> divided by <var><var>two.</var></var> So every instance of an even number represented by $i would evaluate to zero.</p>
<h3>Zebra With JQuery</h3>
<pre lang="javascript">$(document).ready(function(){
    $("tr:even").css("background-color", "#EFEFEF");
    $("tr:odd").css("background-color", "#FFFFFF");
});</pre>
<p>The JQuery <strong>even</strong> and <strong>odd</strong> <a href="http://api.jquery.com/category/selectors/basic-filter-selectors/" target="_blank">filters</a> are used as index selectors. This method can be used on any page element with just a little bit of reverse engineering.</p>
<h3>Discovering the Front-End</h3>
<p>If you were to analyze the speed of using only Javascript, you would find that it is 16% slower, compared to PHP [1]. Though that number might seem relatively low in scale, because it is, consider all of the other factors when developing for the web.</p>
<p>80% of the average user&#8217;s response time is spent on the front-end [2]. This time, is composed of downloading all of the elements necessary to make up the page (Images, libraries, scripts, stylesheets and more). Reducing the number of elements, in turn, reduces the number of HTTP requests required to render the page.</p>
<p>With PHP everything is rendered before any HTTP requests are sent by the server.</p>
<p><img style="float: left; margin-top: 20px;" src="http://chart.apis.google.com/chart?cht=p&amp;chd=t:13,87&amp;chs=300x180&amp;chco=32cd32&amp;chdl=13.05%|86.95%&amp;chtt=GOOGLE&amp;chts=32cd32,12" alt="" /><img style="margin-top: 20px;" src="http://chart.apis.google.com/chart?cht=p&amp;chd=t:20,80&amp;chs=300x180&amp;chco=006699&amp;chdl=20.09%|79.91%&amp;chtt=PHP+ROCKSTAR&amp;chts=006699,12" alt="" /></p>
<p>Graphically interpreted above are the details associated with load times. This analysis completes the HTTP request cycle from initialization. The darker portion, of each representation, shows the percentage of work involved by the server. As consistency shows, a lot of web design and development, relies mostly on what&#8217;s being delivered to the browser.</p>
<h3>Summary</h3>
<p>It&#8217;s certain that a professional web server is going to best the average home network set-up, in performance, any day. It&#8217;s your responsibility to take advantage of that, by running some server-side code, to save your guests the frustration of dealing with an idle load time.</p>
<h3>References</h3>
<p>[1] <a href="http://www.timestretch.com/FractalBenchmark.html">http://www.timestretch.com/FractalBenchmark.html</a><br />
[2] <a href="http://developer.yahoo.net/blog/archives/2007/03/high_performanc.html" target="_blank">http://developer.yahoo.net/blog/archives/2007/03/high_performanc.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.moorberry.biz/2010/03/php-vs-javascript/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Most Simple Way to Implement A Flickr Gallery With PHP</title>
		<link>http://blog.moorberry.biz/2010/03/flickr-gallery/</link>
		<comments>http://blog.moorberry.biz/2010/03/flickr-gallery/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 02:49:18 +0000</pubDate>
		<dc:creator>Michael Minter</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[flickr]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.godhacked.com/?p=13</guid>
		<description><![CDATA[In my search for finding a simple solution to any problem, I usually cross many and many blogs and articles, discussing my queried topic. But with so much detail that the solution becomes a problem in itself. So I often times end up resolved to research on my own and in this case, I share how to build the most simple method of displaying a Flickr gallery, with PHP.]]></description>
			<content:encoded><![CDATA[<p>In my search for finding a simple solution to any problem, I usually cross many and many blogs and articles, discussing my queried topic. But with so much detail that the solution becomes a problem in itself. So I often times end up resolved to research on my own. In this case, I share how to build the most simple method of displaying a <strong>Flickr</strong> gallery, with <strong>PHP</strong>.</p>
<h3>Assembling Your Variables</h3>
<pre lang="PHP" escaped="true">$api = 'your-32-byte-api-key-courtesy-Flickr';
$user_id = '33822702%40N08';
$per_page = 10;</pre>
<p>The <strong>$api</strong> key allows your server and Flickr to &#8220;shake hands&#8221; sort of speak. You can get your Flickr API key <a href="http://www.flickr.com/services/api/keys/" target="_blank">here</a>.</p>
<p>Your <strong>$user_id</strong> is a static variable that Flickr uses to identify you. This value can be found in the URL of your &#8220;photostream&#8221;. I&#8217;ve left mine for <a href="http://www.flickr.com/photos/33822702@N08/" target="_blank">reference</a> (flickr.com).</p>
<p><strong>$per_page</strong> refers to how many photos will be retrieved from your photostream. Though this limiter is optional, the default count is, &#8220;all&#8221;. Which means if you have 1,000 plus photos, it could be a very bad thing, for you or your viewer&#8217;s load time.</p>
<pre lang="PHP" escaped="true">$xml = 'http://api.flickr.com/services/rest/?method=flickr.people.getPublicPhotos&amp;api_key='.$api.'&amp;user_id='.$user_id.'&amp;per_page='.$per_page;</pre>
<p><strong>$xml</strong> stores the link, that gets called on to retrieve a list of your photos, as XML. This will also be a part of the script you modify to extend the features of your application based on what&#8217;s available in the Flickr API.</p>
<pre lang="PHP" escaped="true">$flickr = simplexml_load_file($xml);</pre>
<pre lang="PHP" escaped="true">foreach($flickr-&gt;photos-&gt;photo as $p) {
    echo '&lt;a href="http://www.flickr.com/photos/'.$p['owner'].'/'.$p['id'].'"&gt;';
    echo '&lt;img src="http://farm'.$p['farm'].'.static.flickr.com/'.$p['server'].'/'.$p['id'].'_'.$p['secret'].'_s.jpg"&gt;';
    echo '&lt;/a&gt;';
}</pre>
<p><strong>$flickr</strong> uses a PHP function called, <a href="http://php.net/manual/en/function.simplexml-load-file.php" target="_blank">simplexml_load_file()</a>, which interprets an XML file into an object. In this case, $flickr, becomes an array, and we use <a href="http://us2.php.net/manual/en/control-structures.foreach.php" target="_blank">foreach()</a> to extract the values we need, to display the gallery.</p>
<h3>Summary</h3>
<p>This method is just what I needed. Something small, easily accessible, and scalable. As you experiment with this script, you&#8217;ll afford the opportunity to use many tools, which Flickr offers. You can view a <a href="http://www.flickr.com/services/api/" target="_blank">full list here</a> if or when you&#8217;re ready.</p>
<p><a href="http://blog.godhacked.com/wp-content/uploads/2010/03/flickr.php_.zip">Download Script</a> (.zip)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.moorberry.biz/2010/03/flickr-gallery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Invention That Could Revolutionize How People Act Online</title>
		<link>http://blog.moorberry.biz/2010/03/new-invention/</link>
		<comments>http://blog.moorberry.biz/2010/03/new-invention/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 02:35:21 +0000</pubDate>
		<dc:creator>Michael Minter</dc:creator>
				<category><![CDATA[Invention]]></category>
		<category><![CDATA[Theory]]></category>
		<category><![CDATA[desktop application]]></category>
		<category><![CDATA[embedded driver]]></category>
		<category><![CDATA[money]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[user interface]]></category>

		<guid isPermaLink="false">http://blog.godhacked.com/?p=8</guid>
		<description><![CDATA[Anybody can query the registry, using one of your usernames, to see if your box is set up. If so, they identify your handle, pay $3 for service and an encrypted message is sent through the online interface to your box...]]></description>
			<content:encoded><![CDATA[<p><span>It&#8217;s a box that you install on the underside of your desk and connect to your computer via a USB port&#8230;</span></p>
<p>There&#8217;s a software interface the user has to pre-install. Which through an embedded device manager, controls the connection of the box, to a secure protocol of an online storage system that maintains an array of all of your social network pseudonyms.</p>
<p>No login credentials are needed. <span>Anybody can query</span> query the registry, using one of your alias&#8217;, to verify an open connection with your terminal. If a response comes back valid,  a user confirms action, pays $3 for service and an encoded message is sent through the SSL-encrypted port to activate your box.</p>
<p><span>When the box receives a signal from the source server, with a valid key that identifies a monetary transfer was completed, it promptly flips open and PUNCHES you right in the dick&#8230;</span></p>
<h3><span><a href="http://blog.godhacked.com/wp-content/uploads/2010/03/punched.png"><img class="size-full wp-image-9 alignright" title="Punched" src="http://blog.godhacked.com/wp-content/uploads/2010/03/punched.png" alt="" width="256" height="256" /></a>Summary<br />
</span></h3>
<p><span>Of course, the person who gets punched in the dick, also receives a profit-sum of the initial $3 to keep them logging into the system&#8230;</span></p>
<p><span>The only problem bound to this device&#8217;s logic, is that there&#8217;d be a lot more swollen-nad ass-hats antagonizing me, now simply for money rather than just being an ass-hat.</span></p>
<p><span>Tell me how you think this could be improved?<br />
</span></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.moorberry.biz/2010/03/new-invention/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
