<?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>SayNoToFlash &#187; Scripts</title>
	<atom:link href="http://www.saynotoflash.com/archives/category/scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.saynotoflash.com</link>
	<description>PHP, Symfony, Web Development</description>
	<lastBuildDate>Tue, 17 Jan 2012 13:27:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Network Merchants API Script</title>
		<link>http://www.saynotoflash.com/archives/network-merchants-api-script/</link>
		<comments>http://www.saynotoflash.com/archives/network-merchants-api-script/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 19:08:32 +0000</pubDate>
		<dc:creator>jestep</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://www.saynotoflash.com/?p=447</guid>
		<description><![CDATA[Have just completed a Network Merchants API class. This class utilizes the Network Merchants credit card and electronic check processing API. It also includes the customer vault API which allows merchants to securely store their customer&#8217;s credit card and bank account information in Network Merchant&#8217;s secure customer vault. Go to the Network Merchants API PHP [...]]]></description>
			<content:encoded><![CDATA[<p>Have just completed a Network Merchants API class. This class utilizes the Network Merchants credit card and electronic check processing API. It also includes the customer vault API which allows merchants to securely store their customer&#8217;s credit card and bank account information in Network Merchant&#8217;s secure customer vault.</p>
<p><a href="http://www.saynotoflash.com/scripts/network-merchants-api-php-class-script/">Go to the Network Merchants API PHP Class &raquo;</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.saynotoflash.com/archives/network-merchants-api-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Magic __get, __set Methods, and Retaining Private and Protected Properties</title>
		<link>http://www.saynotoflash.com/archives/php-magic-__get-__set-methods-and-retaining-private-and-protected-properties/</link>
		<comments>http://www.saynotoflash.com/archives/php-magic-__get-__set-methods-and-retaining-private-and-protected-properties/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 08:00:03 +0000</pubDate>
		<dc:creator>jestep</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.saynotoflash.com/?p=272</guid>
		<description><![CDATA[I have been making an integration with a complex API with hundreds of potential user provided variables, necessitating me use of PHP&#8217;s Magic __get and __set methods. Unfortunately, by using these methods, PHP&#8217;s restriction on private and protected properties is bypassed, making all properties public. This is completely unacceptable from my coding perspective. This class [...]]]></description>
			<content:encoded><![CDATA[<p>I have been making an integration with a complex API with hundreds of potential user provided variables, necessitating me use of PHP&#8217;s <a href="http://www.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.members">Magic __get and __set methods</a>. </p>
<p>Unfortunately, by using these methods, PHP&#8217;s restriction on private and protected properties is bypassed, making all properties public. This is completely unacceptable from my coding perspective. </p>
<p>This class model overrides the magic __get and __set&#8217;s ability to alter and access private and protected properties. Public properties are unaffected. This script also allows the class to set and access private and protected properties.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> setter_getter_respect 
<span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$current_page</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$private_properties</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #000088;">$class</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ReflectionClass<span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__CLASS__</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">current_page</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$class</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getFileName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$class_properties</span> <span style="color: #339933;">=</span> <span style="color: #990000;">get_class_vars</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__CLASS__</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$class_properties</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$class_property_name</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$property_value</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$prop</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ReflectionProperty<span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__CLASS__</span><span style="color: #339933;">,</span> <span style="color: #000088;">$class_property_name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$prop</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isPrivate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$prop</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isProtected</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">private_properties</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$prop</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$prop</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isPrivate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">'private'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">'protected'</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __set<span style="color: #009900;">&#40;</span><span style="color: #000088;">$var</span><span style="color: #339933;">,</span> <span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$requesting_page</span> <span style="color: #339933;">=</span> <span style="color: #990000;">debug_backtrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$requesting_page</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'file'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">current_page</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">array_key_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$var</span><span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">private_properties</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
&nbsp;
        	<span style="color: #990000;">trigger_error</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Cannot access &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">private_properties</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; property &quot;</span><span style="color: #339933;">.</span><span style="color: #009900; font-weight: bold;">__CLASS__</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;::&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$var</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; in &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$requesting_page</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'file'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;on line &quot;</span><span style="color: #339933;">.</span> <span style="color: #000088;">$requesting_page</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'line'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">E_USER_ERROR</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #000088;">$var</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$val</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __get<span style="color: #009900;">&#40;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #000088;">$requesting_page</span> <span style="color: #339933;">=</span> <span style="color: #990000;">debug_backtrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
            <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$requesting_page</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'file'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">current_page</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">array_key_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$var</span><span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">private_properties</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
&nbsp;
				<span style="color: #990000;">trigger_error</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Cannot access &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">private_properties</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; property &quot;</span><span style="color: #339933;">.</span><span style="color: #009900; font-weight: bold;">__CLASS__</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;::&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$var</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; in &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$requesting_page</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'file'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;on line &quot;</span><span style="color: #339933;">.</span> <span style="color: #000088;">$requesting_page</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'line'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">E_USER_ERROR</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #000088;">$var</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
&nbsp;
            <span style="color: #b1b100;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> Exception<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Required property [&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$var</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;] has not been set!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Extended classes will not have access to __get or __set protected properties. I will alter this snippet when I find a suitable method of handling extended classes.</p>
<p>I&#8217;m hoping that php alters the way it handles private and protected properties through the magic methods but until then, this is a way to semi-preserve private and protected properties.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.saynotoflash.com/archives/php-magic-__get-__set-methods-and-retaining-private-and-protected-properties/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Multi process / thread PHP execution</title>
		<link>http://www.saynotoflash.com/archives/multi-process-php-execution/</link>
		<comments>http://www.saynotoflash.com/archives/multi-process-php-execution/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 16:32:33 +0000</pubDate>
		<dc:creator>jestep</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://www.saynotoflash.com/?p=15</guid>
		<description><![CDATA[UPDATE&#8211; I&#8217;ve created the official PHP Multi-process script page. Further updates, the usage manual, and other information about PHP Multi-process will be found here. I&#8217;ve run into the problem of needing to use multiple processes with a php script on multiple occasions. Most notably, I have some very complex data processing scripts that take several [...]]]></description>
			<content:encoded><![CDATA[<p><em>UPDATE&#8211; I&#8217;ve created <a href="http://www.saynotoflash.com/scripts/php-multi-process/">the official PHP Multi-process script </a> page. Further updates, the usage manual, and other information about PHP Multi-process will be found here.</em></p>
<p>I&#8217;ve run into the problem of needing to use multiple processes with a php script on multiple occasions. Most notably, I have some very complex data processing scripts that take several minutes to complete. If I can break these up into several parts and run them all at the same time, the execution time can be greatly reduced. </p>
<p><img src="http://www.ecommerce-blog.org/wp-content/uploads/2009/05/php-multi.gif" alt="php-multi" title="php-multi" width="355" height="308" class="aligncenter size-full wp-image-353" /></p>
<p>There are several methods of running additional processes with php. <a href="http://www.tuxradar.com/practicalphp/16/1/3">pcntl_fork</a> is a great way to do it, but it requires php to be running as a cgi module rather than through apache as most web hosts do.</p>
<p>This is a script of how to fork multiple processes on a server running PHP through apache. These process will all run concurrently, and the parent will wait to exit until all of the child processes have completed.</p>
<p><span id="more-15"></span>An easy way to fork a process through php is to run a quiet <a href="http://www.php.net/function.exec">exec</a> command with no output. This will create a process that runs in the background. However, there are times that we need to know a script successfully processed, or even get some data that the script produces.</p>
<p>This solution requires tying together several moderately advanced ideas, but in the end will produce a usable and stable multiple processing php system. Despite it&#8217;s simplicity, this script took a lot of testing to complete. It&#8217;s definitely in an Alpha+ stage so if you find any bugs or problems, please let me know.</p>
<p><strong>Server requirements:</strong></p>
<ul>
<li>PHP 5</li>
<li>Sqlite (<a href="http://www.php.net/memcache">Memcached</a> is an alternative)</li>
<li>Ability to use exec and run php from the command line</li>
</ul>
<p><strong>How does this work?</strong><br />
Using the exec function, a script <em>(the parent)</em> executes multiple additional php scripts <em>(children)</em> silently in the background. The parent script neither waits for, nor cares about the execution of, the children scripts, so the children all process concurrently. Each child script, upon completion updates a temporary database table used as a caching mechanism. The parent queries the cache table until each child is complete, or until itself times out, and then exits. This allows multiple scripts to be spawned from a single script.</p>
<p><strong>How to use it:</strong><br />
<a href="http://www.saynotoflash.com/downloads/multiproc.zip">Download multiproc.zip</a>. Extract and upload the files to your server. The sqlite folder will need to be made writable. </p>
<p>To use the script you will need to specify the child scripts you want to process. Add these into the $processes_to_execute array. You may need to use the full path of the files depending on your server setup.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$processes_to_execute</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">'other_process.php'</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'other_process.php'</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>For the children, you can copy other_process.php and add any of your own php code between the BEGIN and END comments. Passed data does not inheretly come across in $_GET variables. Do not alter the variable setting code at the top of the script unless you understand how not to break it.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #666666; font-style: italic;">/*-----------------BEGIN YOUR OWN CODE HERE------------------------*/</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*
&nbsp;
This is a normal PHP script so you can do whatever you want.
But, don't output anything because this is running in the background.
You can return output to the primary script via the setOutput method.
&nbsp;
$ouput = 'WHATEVER YOU WANT';
&nbsp;
$script-&gt;setOutput($envelope,$pid,$output);
&nbsp;
*/</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*-----------------END YOUR OWN CODE HERE---------------------------*/</span></pre></div></div>

<p>Lastly, point your browser to multi_proc.php, and let it go. It may take some altering to get the to work on your specific server setup, but I&#8217;ve got it working on several servers with very little/no additional configuration.</p>
<h3>Personal Notes:</h3>
<p><strong>Windows</strong><br />
This is written for Linux running PHP from Apache, but should be able to be modified to work on Windows Apache.</p>
<p><strong>Benchmarking:</strong><br />
I&#8217;ve benchmarked this script and it does deliver the performance I was expecting. Each child provides a linear reduction in execution time. Since the time spent executing the children and reading / writing to the database is negligible. If a script takes 30 seconds to process, and you can split it into 2 children or 1 parent 1 child, the final result will be ~15 seconds.</p>
<p>Additionally, you could execute just about anything in each child as long as the child doesn&#8217;t timeout. The parent will wait for each to finish, or until it&#8217;s execution time limit is reached before exiting.</p>
<p><strong>Personally, I am using this on a script which originally took 12 minutes to process, now down to about 90 seconds.</strong></p>
<p><strong>Caching</strong><br />
This script uses sqlite as an interim caching system. <a href="http://www.php.net/apc/">APC</a> was my original plan for a cache, but due to some technical impossibilities, discovered in 6 hours of troubleshooting, APC can not be used for this <em>(trust me on this one&#8230;)</em>. <a href="http://www.php.net/memcache">Memcache</a> however, is a method that would work very well for this.</p>
<p><strong>Script Failures</strong><br />
One of the current issues that needs to be addressed is reporting failed children. This could easily be accomplished by creating another method to return child processes that haven&#8217;t completed. This will be added into my next revision of this script along with some other error control and any bug fixes that are needed.</p>
<p><em>As long as exit() is used at the bottom of each child process, there shouldn&#8217;t be any potential for &#8220;permanent&#8221; memory leaks. If the parent process is killed prematurely, the children will continue to run until they timeout, or are killed via exit(). For this reason it is imperative to set a timeout, and to manually kill the script once it reaches the end.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.saynotoflash.com/archives/multi-process-php-execution/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>**UPDATED** Adding Google Business search to your ecommerce website</title>
		<link>http://www.saynotoflash.com/archives/updated-adding-google-business-search-to-your-ecommerce-website/</link>
		<comments>http://www.saynotoflash.com/archives/updated-adding-google-business-search-to-your-ecommerce-website/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 16:25:09 +0000</pubDate>
		<dc:creator>jestep</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://www.saynotoflash.com/?p=8</guid>
		<description><![CDATA[**UPDATED** This is an updated version of the script. It now resides on only a single page and should be less confusing to put into a website. Please feel free to use this script as a base and customize as you like. Sign up for a business site search account here: http://www.google.com/sitesearch/index.html The internet is [...]]]></description>
			<content:encoded><![CDATA[<p>**UPDATED**<br />
This is an updated version of the script. It now resides on only a single page and should be less confusing to put into a website. Please feel free to use this script as a base and customize as you like.</p>
<p>Sign up for a business site search account here: <a href="http://www.google.com/sitesearch/index.html">http://www.google.com/sitesearch/index.html</a></p>
<p>The internet is abuzz with news of <a href="http://googlecustomsearch.blogspot.com/2007/07/now-cse-for-businesses.html">Google&#8217;s new business custom search engine</a>. Google is allowing business sites to have their own custom search engine for $100 per year (<5,000 pages) or $500 per year (up to 50,000) pages. This includes some cool reporting and an XML API so that you can customize to your heart's content.</p>
<p><img src="http://www.ecommerce-blog.org/images/google-custom.gif" alt="Google Custom Search"></p>
<p>After messing around with Google&#8217;s javascript code I decided to write my own little script to better integrate it into my website. The javascript code was giving me some major problems with the width of my pages, so I canned it and went to their XML version of the search function.</p>
<p>The following is a <strong>very simple</strong> php &#038; html script that you can use for your own Google business search engine. It was made for a php5 server as it uses the built-in simpleXML class. Upload this to your website, enter your account id, and make a form to post to it. That&#8217;s it!</p>
<p><span id="more-8"></span>It currently uses two tables, but you can easily change this to a division based layout. I used tables only so I didn&#8217;t have to use external css, or mess with division styling that might not work universally. Also, you can post to this page from a form anywhere on your site as long as the text field name is &#8220;query&#8221; and you are using the GET method to submit the form. Lastly, I would set error_reporting to E_ERROR, as E_WARNING may generate some few warnings.</p>
<p><strong>Here we go:</strong></p>
<p>The zip file has a version with correct tabs and the GPL license and is located below this code. Also, I rarely distribute code that I write, so I apologize in advance for any poor commenting.</p>
<p>Save this file as site-search.php or something similar. Edit the $accountId variable with your specific google search information.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">/*
&nbsp;
AUTHOR: Jamie Estep
WEBSITE: http://www.ecommerce-blog.org
&nbsp;
LICENSE:
&nbsp;
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
&nbsp;
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
&nbsp;
For a copy of the GNU General Public License see 
&lt;http://www.gnu.org/licenses/&gt;
&nbsp;
*/</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> cleanSearch<span style="color: #009900;">&#40;</span><span style="color: #000088;">$input</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">//this will clean the query so that it is safe to use for whatever</span>
	<span style="color: #666666; font-style: italic;">//this is broken into steps, but can be done on a single line if prefered</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//trim whitespace</span>
	<span style="color: #000088;">$input</span> <span style="color: #339933;">=</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$input</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//if you would like your users to be able to search for code, you can comment this out</span>
	<span style="color: #666666; font-style: italic;">//Make sure you know what you're doing before you comment this out!</span>
	<span style="color: #000088;">$input</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strip_tags</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$input</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Convert html characters to a safe format, IE: &amp; - &amp;amp; etc.</span>
	<span style="color: #000088;">$input</span> <span style="color: #339933;">=</span> <span style="color: #990000;">htmlspecialchars</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$input</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//convert to a url safe code since we use the GET function to request from google</span>
	<span style="color: #000088;">$input</span> <span style="color: #339933;">=</span> <span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$input</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$input</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> replaceChars<span style="color: #009900;">&#40;</span><span style="color: #000088;">$input</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">//using this function to replace some html from the data returned by google</span>
<span style="color: #666666; font-style: italic;">//Make sure there is a corresponding value in the find and replace arrays or you will have problems</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//these are what you want to replace</span>
	<span style="color: #000088;">$find</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
	<span style="color: #0000ff;">'»'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'&lt;br&gt;'</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//these are what you need to replace them with</span>
	<span style="color: #000088;">$replace</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
	<span style="color: #0000ff;">'&amp;raquo;'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">''</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$find</span><span style="color: #339933;">,</span><span style="color: #000088;">$replace</span><span style="color: #339933;">,</span><span style="color: #000088;">$input</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//constants</span>
<span style="color: #000088;">$accountId</span> 		<span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span> 				<span style="color: #666666; font-style: italic;">//put google search ID Here - Should be a long string of numbers letters and symbols</span>
<span style="color: #000088;">$collation</span>  	<span style="color: #339933;">=</span> <span style="color: #0000ff;">'ISO-8859-1'</span><span style="color: #339933;">;</span> 	<span style="color: #666666; font-style: italic;">//change this if you want something other than ISO-8859-1, IE: ut8-f</span>
<span style="color: #000088;">$numberPerPage</span> 	<span style="color: #339933;">=</span> <span style="color: #0000ff;">'10'</span><span style="color: #339933;">;</span> 			<span style="color: #666666; font-style: italic;">//this is how many results you want per page</span>
<span style="color: #000088;">$noResults</span> 		<span style="color: #339933;">=</span> <span style="color: #0000ff;">'There were no results found for your search. Please try again.'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Message if no results are found</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&nbsp;
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot; /&gt;
&lt;title&gt;My Custom Search&lt;/title&gt;
&lt;/head&gt;
&nbsp;
&lt;body&gt;
&nbsp;
&lt;!-- Start Search Box --&gt;
&lt;table width=&quot;100%&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;10&quot;&gt;
  &lt;tr&gt;
    &lt;td align=&quot;center&quot; valign=&quot;middle&quot;&gt;
&nbsp;
	&lt;form action=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'PHP_SELF'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;
		&lt;input name=&quot;query&quot; type=&quot;text&quot; size=&quot;40&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'query'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #b1b100;">echo</span> <span style="color: #990000;">urldecode</span><span style="color: #009900;">&#40;</span>cleanSearch<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'query'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;
		&lt;input type=&quot;submit&quot; name=&quot;sa&quot; value=&quot;Search&quot; /&gt;
		&lt;img src=&quot;http://google.com/coop/images/google_custom_search_smnar.gif&quot; alt=&quot;Google Custom Search&quot; /&gt;
   &lt;/form&gt;
&nbsp;
	&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;
&lt;!-- End Search Box --&gt;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//check if the form was submitted</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'query'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//clean the input so that it is safe</span>
	<span style="color: #000088;">$searchTerm</span> <span style="color: #339933;">=</span> cleanSearch<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'query'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//cast $_GET['start'] to an integer just in case</span>
	<span style="color: #000088;">$start</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'start'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//build the google query here</span>
	<span style="color: #000088;">$buildQuery</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://www.google.com/search?cx='</span><span style="color: #339933;">.</span><span style="color: #000088;">$accountId</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;client=google-csbe&amp;start='</span><span style="color: #339933;">.</span><span style="color: #000088;">$start</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;num='</span><span style="color: #339933;">.</span><span style="color: #000088;">$numberPerPage</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;output=xml_no_dtd&amp;q='</span><span style="color: #339933;">.</span><span style="color: #000088;">$searchTerm</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;ie='</span><span style="color: #339933;">.</span><span style="color: #000088;">$collation</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;oe='</span><span style="color: #339933;">.</span><span style="color: #000088;">$collation</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//get the result for the query from google</span>
	<span style="color: #000088;">$thisSearch</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$buildQuery</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//instantiate a simple xml class and process the google result</span>
	<span style="color: #000088;">$xml</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SimpleXMLElement<span style="color: #009900;">&#40;</span><span style="color: #000088;">$thisSearch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//find the number of results for pagination later on</span>
	<span style="color: #000088;">$total</span> <span style="color: #339933;">=</span> <span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Display Nothing found message if there are no results.</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$total</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
		&lt;p&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$noResults</span> <span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/p&gt;
&nbsp;
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> 
	<span style="color: #b1b100;">else</span><span style="color: #339933;">:</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//loop through the results </span>
		<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">RES</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">R</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">//the replaceChars removes anything you need it to, I found google returning some unusable characters, and you can fix it with this function</span>
			<span style="color: #666666; font-style: italic;">//Edit the actual find / replace at the bottom</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">//format the output for each result</span>
&nbsp;
			<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
			&lt;p&gt;&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$key</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">U</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> replaceChars<span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">T</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;&lt;br /&gt;
			<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> replaceChars<span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">S</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;br /&gt;
			&lt;span style=&quot;color:#060;&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$key</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">U</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/span&gt;&lt;/p&gt;
&nbsp;
		<span style="color: #000000; font-weight: bold;">&lt;?php</span> 
		<span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//simple pagination ?&gt;</span>
		<span style="color: #339933;">&lt;</span>table width<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;100%&quot;</span> border<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;0&quot;</span> cellspacing<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;0&quot;</span> cellpadding<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;5&quot;</span><span style="color: #339933;">&gt;</span>
			<span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">&lt;?php</span>
			<span style="color: #666666; font-style: italic;">//make sure we dont display previous page on the first page</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$start</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
				&lt;td align=&quot;left&quot;&gt;&lt;a href=&quot;?query=<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$searchTerm</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>.'&amp;start=<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$start</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$numberPerPage</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;&amp;laquo; Previous 10&lt;/a&gt;&lt;/td&gt;
&nbsp;
			<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> 
&nbsp;
			<span style="color: #666666; font-style: italic;">//make sure we dont display next page on the last page</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$total</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$numberPerPage</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
				&lt;td align=&quot;right&quot;&gt;&lt;a href=&quot;?query=<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$searchTerm</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&amp;start=<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$start</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$numberPerPage</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;Next 10 &amp;raquo;&lt;/a&gt;&lt;/td&gt;
&nbsp;
			<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
			&lt;/tr&gt;
		&lt;/table&gt;
		<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #666666; font-style: italic;">/* 
		I ALWAYS APPRECIATE CREDIT FOR WORK THAT I HAVE DONE, 
		BUT FEEL FREE TO REMOVE THIS LINK. 
		REMOVAL OF THIS LINK DOES NOT VALIDE LICENSE AGREEMENT! 
		THANKS */</span> 
		<span style="color: #000000; font-weight: bold;">?&gt;</span>
		&lt;p align=&quot;center&quot;&gt;Google search script provided by &lt;a href=&quot;http://www.ecommerce-blog.org/&quot; target=&quot;_blank&quot;&gt;an Ecommerce Blog&lt;/a&gt;.&lt;/p&gt;
	<span style="color: #000000; font-weight: bold;">&lt;?php</span> 
	<span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;/body&gt;
&lt;/html&gt;</pre></div></div>

<p><strong>Example of how to implement it:</strong></p>
<p><a href="http://www.saynotoflash.com/downloads/googleSearch.zip">Download this file along with it&#8217;s license.</a></p>
<p>Enter your site&#8217;s google custom search account id, and upload the file to your server. You can also post a search directly to the site-search.php page using a GET request.</p>
<p><strong>Related information:</strong><br />
<a href="http://googlecustomsearch.blogspot.com">Official Google Custom Search Blog</a><br />
<a href="http://www.seobook.com/archives/002357.shtml">The Benefits of Using Google&#8217;s Custom Search Engine</a> &#8211; seobook.com<br />
<a href="http://www.online-tech-tips.com/google-softwaretips/google-custom-search-engine-for-businesses-custom-search-for-your-website-without-any-ads-for-100-a-year/">Google Custom Search Engine for Businesses</a> &#8211; online-tech-tips.com</p>
<p>**If you notice any errors or security issues with any of the code, or bugs in general let me know and I will update this script.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.saynotoflash.com/archives/updated-adding-google-business-search-to-your-ecommerce-website/feed/</wfw:commentRss>
		<slash:comments>43</slash:comments>
		</item>
	</channel>
</rss>

