<?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>Hayden Kibble &#187; PHP/MySQL/AJAX</title>
	<atom:link href="http://www.haydenkibble.com/category/php-mysql-ajax/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.haydenkibble.com</link>
	<description>PHP-SEO-IM-DESIGN</description>
	<lastBuildDate>Fri, 17 Dec 2010 23:06:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Copy Magento Category</title>
		<link>http://www.haydenkibble.com/2010/12/copy-magento-category/</link>
		<comments>http://www.haydenkibble.com/2010/12/copy-magento-category/#comments</comments>
		<pubDate>Fri, 17 Dec 2010 23:01:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP/MySQL/AJAX]]></category>
		<category><![CDATA[magento]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.haydenkibble.com/?p=68</guid>
		<description><![CDATA[Since first laying eyes on Magento, the open source eCommerce software, I been impressed by it&#8217;s power, flexibility and rigid code structure. But despite Magento&#8217;s almost endless list of strengths, it also has some significant weaknesses, that often leave me frustrated and confused. One such weakness is the apparent lack of any functionality in regards [...]]]></description>
			<content:encoded><![CDATA[<p>Since first laying eyes on Magento, the open source eCommerce software, I been impressed by it&#8217;s power, flexibility and rigid code structure. But despite Magento&#8217;s almost endless list of strengths, it also has some significant weaknesses, that often leave me frustrated and confused. One such weakness is the apparent lack of any functionality in regards to copying products and categories.</p>
<p>I had created a category, with about 10 child categories. Now I just wanted to duplicate that category 5 times, rather than creating another 4 from scratch, each with 10 children (4&#215;10=40 categories!). Rather than spend the next couple of hours adding categories, I knocked together this quick PHP script. Simply pass in the ID of the category you&#8217;d like to duplicate, and it will create a copy of the category, along with all of it&#8217;s child categories, as deep as they go!</p>
<p>Ideally, this would be a proper Magento module, but I&#8217;m just starting out with Magento. Give me 6 months, eh?!</p>
<p>To use the script, simply copy it into a file such as copycat.php in your Magento root directory and call it like so:</p>
<p>http://www.example.com/copycat.php?id=<em>[CATEGORY ID TO COPY]</em></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;
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_numeric</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Please specify a category ID'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$catId</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$xml</span> <span style="color: #339933;">=</span> <span style="color: #990000;">simplexml_load_file</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'app/etc/local.xml'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$host</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">global</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">resources</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">default_setup</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">connection</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">host</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$username</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">global</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">resources</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">default_setup</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">connection</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">username</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$password</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">global</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">resources</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">default_setup</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">connection</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">password</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dbname</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">global</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">resources</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">default_setup</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">connection</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dbname</span><span style="color: #339933;">;</span> 
<span style="color: #000088;">$res</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_pconnect</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$host</span><span style="color: #339933;">,</span> <span style="color: #000088;">$username</span><span style="color: #339933;">,</span> <span style="color: #000088;">$password</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
<span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dbname</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
<span style="color: #000088;">$catsDone</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
duplicate_entity<span style="color: #009900;">&#40;</span><span style="color: #000088;">$catId</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$catsDone</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' Categories duplicated.'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> duplicate_entity<span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #339933;">,</span> <span style="color: #000088;">$parent_id</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$catsDone</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
	<span style="color: #666666; font-style: italic;">// Grab category to copy</span>
	<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT * FROM catalog_category_entity WHERE entity_id = &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$id</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$query_entity</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$entity</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_object</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query_entity</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$parent_id</span><span style="color: #009900;">&#41;</span><span style="color: #000088;">$parent_id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$entity</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parent_id</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
	<span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;INSERT INTO catalog_category_entity (entity_type_id, attribute_set_id, parent_id, created_at, updated_at, path, position, level, children_count)
						VALUES (<span style="color: #006699; font-weight: bold;">{$entity-&gt;entity_type_id}</span>, <span style="color: #006699; font-weight: bold;">{$entity-&gt;attribute_set_id}</span>, <span style="color: #006699; font-weight: bold;">{$parent_id}</span>, NOW(), NOW(), '', <span style="color: #006699; font-weight: bold;">{$entity-&gt;position}</span>, <span style="color: #006699; font-weight: bold;">{$entity-&gt;level}</span>, <span style="color: #006699; font-weight: bold;">{$entity-&gt;children_count}</span>)&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$newEntityId</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_insert_id</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT path FROM catalog_category_entity WHERE entity_id = &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$parent_id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$parent</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_object</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$parent</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">path</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$newEntityId</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;UPDATE catalog_category_entity SET path='&quot;</span><span style="color: #339933;">.</span> <span style="color: #000088;">$path</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;' WHERE entity_id=&quot;</span><span style="color: #339933;">.</span> <span style="color: #000088;">$newEntityId</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'datetime'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'decimal'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'int'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'text'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'varchar'</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$dataType</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT * FROM catalog_category_entity_&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$dataType</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;
				WHERE entity_id=&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$entity</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">entity_id</span><span style="color: #339933;">;</span>
				<span style="color: #666666; font-style: italic;">//die($sql);</span>
		<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_object</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;INSERT INTO catalog_category_entity_&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$dataType</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; (entity_type_id, attribute_id, store_id, entity_id, value)
							VALUES (<span style="color: #006699; font-weight: bold;">{$value-&gt;entity_type_id}</span>, <span style="color: #006699; font-weight: bold;">{$value-&gt;attribute_id}</span>, <span style="color: #006699; font-weight: bold;">{$value-&gt;store_id}</span>, <span style="color: #006699; font-weight: bold;">{$newEntityId}</span>, '<span style="color: #006699; font-weight: bold;">{$value-&gt;value}</span>')&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT entity_id FROM catalog_category_entity WHERE parent_id = &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$id</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$entity</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_object</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		duplicate_entity<span style="color: #009900;">&#40;</span><span style="color: #000088;">$entity</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">entity_id</span><span style="color: #339933;">,</span> <span style="color: #000088;">$newEntityId</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000088;">$catsDone</span><span style="color: #339933;">++;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><a href="http://www.haydenkibble.com/?ibsa=share&amp;id=68" id="share-link-">Share</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.haydenkibble.com/2010/12/copy-magento-category/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Basic SQL Injection Tutorial</title>
		<link>http://www.haydenkibble.com/2010/05/basic-sql-injection-tutorial/</link>
		<comments>http://www.haydenkibble.com/2010/05/basic-sql-injection-tutorial/#comments</comments>
		<pubDate>Fri, 07 May 2010 18:54:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP/MySQL/AJAX]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.haydenkibble.com/?p=57</guid>
		<description><![CDATA[Since first laying eyes on Magento, the open source eCommerce software, I been impressed by it&#8217;s power, flexibility and rigid code structure. But despite Magento&#8217;s almost endless list of strengths, it also has some significant weaknesses, that often leave me frustrated and confused. One such weakness is the apparent lack of any functionality in regards [...]]]></description>
			<content:encoded><![CDATA[<p>Since first laying eyes on Magento, the open source eCommerce software, I been impressed by it&#8217;s power, flexibility and rigid code structure. But despite Magento&#8217;s almost endless list of strengths, it also has some significant weaknesses, that often leave me frustrated and confused. One such weakness is the apparent lack of any functionality in regards to copying products and categories.</p>
<p>I had created a category, with about 10 child categories. Now I just wanted to duplicate that category 5 times, rather than creating another 4 from scratch, each with 10 children (4&#215;10=40 categories!). Rather than spend the next couple of hours adding categories, I knocked together this quick PHP script. Simply pass in the ID of the category you&#8217;d like to duplicate, and it will create a copy of the category, along with all of it&#8217;s child categories, as deep as they go!</p>
<p>Ideally, this would be a proper Magento module, but I&#8217;m just starting out with Magento. Give me 6 months, eh?!</p>
<p>To use the script, simply copy it into a file such as copycat.php in your Magento root directory and call it like so:</p>
<p>http://www.example.com/copycat.php?id=<em>[CATEGORY ID TO COPY]</em></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;
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_numeric</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Please specify a category ID'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$catId</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$xml</span> <span style="color: #339933;">=</span> <span style="color: #990000;">simplexml_load_file</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'app/etc/local.xml'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$host</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">global</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">resources</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">default_setup</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">connection</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">host</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$username</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">global</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">resources</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">default_setup</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">connection</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">username</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$password</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">global</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">resources</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">default_setup</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">connection</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">password</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dbname</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">global</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">resources</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">default_setup</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">connection</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dbname</span><span style="color: #339933;">;</span> 
<span style="color: #000088;">$res</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_pconnect</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$host</span><span style="color: #339933;">,</span> <span style="color: #000088;">$username</span><span style="color: #339933;">,</span> <span style="color: #000088;">$password</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
<span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dbname</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
<span style="color: #000088;">$catsDone</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
duplicate_entity<span style="color: #009900;">&#40;</span><span style="color: #000088;">$catId</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$catsDone</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' Categories duplicated.'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> duplicate_entity<span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #339933;">,</span> <span style="color: #000088;">$parent_id</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$catsDone</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
	<span style="color: #666666; font-style: italic;">// Grab category to copy</span>
	<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT * FROM catalog_category_entity WHERE entity_id = &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$id</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$query_entity</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$entity</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_object</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query_entity</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$parent_id</span><span style="color: #009900;">&#41;</span><span style="color: #000088;">$parent_id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$entity</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parent_id</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
	<span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;INSERT INTO catalog_category_entity (entity_type_id, attribute_set_id, parent_id, created_at, updated_at, path, position, level, children_count)
						VALUES (<span style="color: #006699; font-weight: bold;">{$entity-&gt;entity_type_id}</span>, <span style="color: #006699; font-weight: bold;">{$entity-&gt;attribute_set_id}</span>, <span style="color: #006699; font-weight: bold;">{$parent_id}</span>, NOW(), NOW(), '', <span style="color: #006699; font-weight: bold;">{$entity-&gt;position}</span>, <span style="color: #006699; font-weight: bold;">{$entity-&gt;level}</span>, <span style="color: #006699; font-weight: bold;">{$entity-&gt;children_count}</span>)&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$newEntityId</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_insert_id</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT path FROM catalog_category_entity WHERE entity_id = &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$parent_id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$parent</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_object</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$parent</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">path</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$newEntityId</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;UPDATE catalog_category_entity SET path='&quot;</span><span style="color: #339933;">.</span> <span style="color: #000088;">$path</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;' WHERE entity_id=&quot;</span><span style="color: #339933;">.</span> <span style="color: #000088;">$newEntityId</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'datetime'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'decimal'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'int'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'text'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'varchar'</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$dataType</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT * FROM catalog_category_entity_&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$dataType</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;
				WHERE entity_id=&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$entity</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">entity_id</span><span style="color: #339933;">;</span>
				<span style="color: #666666; font-style: italic;">//die($sql);</span>
		<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_object</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;INSERT INTO catalog_category_entity_&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$dataType</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; (entity_type_id, attribute_id, store_id, entity_id, value)
							VALUES (<span style="color: #006699; font-weight: bold;">{$value-&gt;entity_type_id}</span>, <span style="color: #006699; font-weight: bold;">{$value-&gt;attribute_id}</span>, <span style="color: #006699; font-weight: bold;">{$value-&gt;store_id}</span>, <span style="color: #006699; font-weight: bold;">{$newEntityId}</span>, '<span style="color: #006699; font-weight: bold;">{$value-&gt;value}</span>')&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT entity_id FROM catalog_category_entity WHERE parent_id = &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$id</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$entity</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_object</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		duplicate_entity<span style="color: #009900;">&#40;</span><span style="color: #000088;">$entity</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">entity_id</span><span style="color: #339933;">,</span> <span style="color: #000088;">$newEntityId</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000088;">$catsDone</span><span style="color: #339933;">++;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><a href="http://www.haydenkibble.com/?ibsa=share&amp;id=57" id="share-link-">Share</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.haydenkibble.com/2010/05/basic-sql-injection-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Online MD5 Hasher/Cracker</title>
		<link>http://www.haydenkibble.com/2009/07/online-md5-hashercracker/</link>
		<comments>http://www.haydenkibble.com/2009/07/online-md5-hashercracker/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 09:36:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP/MySQL/AJAX]]></category>

		<guid isPermaLink="false">http://www.haydenkibble.com/?p=53</guid>
		<description><![CDATA[If you&#8217;ve ever worked with a PHP/MySQL application which handles user logins, then you will have worked with MD5 Hashes. An MD5 is a one-way encryption algorithm commonly used by web applications to store passwords.
When a new user creates an account, their password is &#8216;hashed&#8217; using MD5 and the hash is stored along with their [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.haydenkibble.com/wp-content/uploads/cracker-150x150.jpg" alt="Cloud Cracker" title="Cloud Cracker" width="150" height="150" class="alignright size-thumbnail wp-image-55" />If you&#8217;ve ever worked with a PHP/MySQL application which handles user logins, then you will have worked with MD5 Hashes. An MD5 is a one-way encryption algorithm commonly used by web applications to store passwords.<br />
When a new user creates an account, their password is &#8216;hashed&#8217; using MD5 and the hash is stored along with their username in the database. When they attempt to login in the future, their entered password is hashed and compared to the hash in the database. If they match, they are authenticated. This is great as the password does not have to be visible in the database.</p>
<p>If you forget your admin password when developing an app and haven&#8217;t coded a &#8216;reset your password&#8217; part yet (I always code these boring bits last!) you have 2 choices. You can create a new MD5 hash and replace the one in the database, or you can &#8216;crack&#8217; the hash to find out your password. But how?</p>
<p>Enter Cloud Cracker, the <a href="http://www.cloudcracker.net">free online MD5 hasher/cracker</a>. This nifty little tool will take any password and give you it&#8217;s MD5 hash. It will also attempt to &#8216;crack&#8217; an entered hash and show you the plaintext password.</p>
<p><a href="http://www.CloudCracker.net">Click Here to check out Cloud Cracker now.</a> and feel free to hit the &#8216;Digg&#8217; button if you like it.</p>
<p><a href="http://www.haydenkibble.com/?ibsa=share&amp;id=53" id="share-link-">Share</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.haydenkibble.com/2009/07/online-md5-hashercracker/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>What is AJAX?</title>
		<link>http://www.haydenkibble.com/2009/07/what-is-ajax/</link>
		<comments>http://www.haydenkibble.com/2009/07/what-is-ajax/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 13:13:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP/MySQL/AJAX]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[mootools]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://www.haydenkibble.com/?p=46</guid>
		<description><![CDATA[What is AJAX?
If you find yourself asking this question then you&#8217;re either new to PHP/Javascript or you have been hiding under a rock for the past three years.
Since around 2006, the term/buzzword &#8216;AJAX&#8217; has been thrown around like a frisbee in a playground. So what exactly is AJAX?
If you&#8217;ve had an auto-suggest bubble pop up [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.haydenkibble.com/wp-content/uploads/ajax_small-150x150.jpg" alt="Ajax" title="Ajax" width="150" height="150" class="alignright size-thumbnail wp-image-48" />What is AJAX?<br />
If you find yourself asking this question then you&#8217;re either new to PHP/Javascript or you have been hiding under a rock for the past three years.<br />
Since around 2006, the term/buzzword &#8216;AJAX&#8217; has been thrown around like a frisbee in a playground. So what exactly <em>is</em> AJAX?</p>
<p>If you&#8217;ve had an auto-suggest bubble pop up as you&#8217;re searching, or if you&#8217;ve seen form sub-sections magically appear as you choose options, then you have already used AJAX. Slow, static web pages have given way to speedy, animated interfaces with more nifty features.</p>
<p>Some examples of what you can achieve with AJAX include:</p>
<ul>
<li>Auto-suggest popups</li>
<li>Form elements appearing/hiding as you complete the form</li>
<li>Slider controls</li>
<li>Draggable/droppable content</li>
</ul>
<p>The term AJAX stands for &#8216;Asynchronous Javascript And XML&#8217;. Technically, AJAX is when javascript sends requests back to the server, receives a response in XML and acts upon it. These days though, AJAX is used more of a blanket term of for anything interactive which uses javascript.</p>
<p>If you have been developing PHP and looking to take your applications to the next level of interactivity, then check out some of the nifty AJAX Javascript frameworks out there that do all the hard work for you:</p>
<ul>
<li><a href="http://jquery.com/">jQuery</a></li>
<li><a href="http://mootools.net/">Mootools</a></li>
<li><a href="http://www.prototypejs.org/">Prototype</a></li>
</ul>
<p><a href="http://www.haydenkibble.com/?ibsa=share&amp;id=46" id="share-link-">Share</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.haydenkibble.com/2009/07/what-is-ajax/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Make Your Phone &#8216;Kerching&#8217; When You Make A Sale</title>
		<link>http://www.haydenkibble.com/2009/07/make-your-phone-kerching-when-you-make-a-sale/</link>
		<comments>http://www.haydenkibble.com/2009/07/make-your-phone-kerching-when-you-make-a-sale/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 19:23:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Internet Marketing]]></category>
		<category><![CDATA[PHP/MySQL/AJAX]]></category>
		<category><![CDATA[affiliate]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[kerching]]></category>
		<category><![CDATA[notification]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[sale]]></category>

		<guid isPermaLink="false">http://www.haydenkibble.com/?p=15</guid>
		<description><![CDATA[Being the egotistical git I am, I wanted my phone to make a &#8216;kerching&#8217; sound each time I made an affiliate sale. Nothing beats dozing off on a lazy Sunday evening and hearing your cash register ring out. Here&#8217;s how I made it happen&#8230;
First, you need to receive an email each time you make a [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.haydenkibble.com/wp-content/uploads/cash-register-150x150.jpg" alt="cash-register" title="cash-register" width="150" height="150" class="alignright size-thumbnail wp-image-33" />Being the egotistical git I am, I wanted my phone to make a &#8216;kerching&#8217; sound each time I made an affiliate sale. Nothing beats dozing off on a lazy Sunday evening and hearing your cash register ring out. Here&#8217;s how I made it happen&#8230;</p>
<p>First, you need to receive an email each time you make a sale. If your affiliate network will do this, then the first bit is already done. If not, copy the script below into a php file called something like  &#8216;xml-to-email.php&#8217; and upload it to your web server. Full instructions are in comments at the top of the file. You will most likely have to change the regex variable to work with your affiliate network&#8217;s own feed format.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* #########################################################
&nbsp;
Email When You Make a Sale
Developed by Hayden Kibble July 2009
Hayden@HaydenKibble.com
www.HaydenKibble.com
&nbsp;
Install instructions:
1. Put your affiliate network login and your email details into the variables below
2. You will probably have to edit '$regex_saletime' to match the sale time/date for your paticular aff networks xml feed
2. Upload this file to your web server.
3. Create a file called 'sales.txt' in the same directory as this script and make sure it has read/write permissions
4. Visit the page and it should show a blank page. An email will probably be sent as it picks up all your recent sales
5. Set a cron job up on your web server to run this script every 10 mins or so
6. If you have problems with any of the above, Google is your friend!
&nbsp;
######################################################### */</span>
&nbsp;
<span style="color: #000088;">$base_url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;https://www.affilliate-network.com/myfeed.xml&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$feed_user</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;USERNAME-HERE&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$feed_pass</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;PASSWORD-HERE&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$regex_saletime</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/&lt;date&gt;(.*)&lt;\/date&gt;/U&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$email_from</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;from@address.com&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$email_to</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;to@address.com&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$email_subject</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;You Made a Sale!&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// ##### Do Not Edit Below This Line! #####</span>
&nbsp;
<span style="color: #000088;">$ch</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #000088;">$base_url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Set your login and password for authentication</span>
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_USERPWD<span style="color: #339933;">,</span> <span style="color: #000088;">$feed_user</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">':'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$feed_pass</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_HTTPAUTH<span style="color: #339933;">,</span> CURLAUTH_ANY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_SSL_VERIFYPEER<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// get the data and close the session</span>
<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Error Getting Feed.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">curl_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$dates</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: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$regex_saletime</span><span style="color: #339933;">,</span><span style="color: #000088;">$data</span><span style="color: #339933;">,</span><span style="color: #000088;">$dates</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Read previous sales times from database</span>
<span style="color: #000088;">$fileData</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>
<span style="color: #000088;">$myFile</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;sales.txt&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$fh</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$myFile</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'r'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$fileData</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fread</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fh</span><span style="color: #339933;">,</span> <span style="color: #990000;">filesize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$myFile</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fh</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Split the file into lines</span>
<span style="color: #000088;">$fileLines</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$fileData</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$newsale</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$fh</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$myFile</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'a'</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;can't open file&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// See if this sale has already been logged. If not, log it and set 'new sale' variable</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dates</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$date</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$date</span><span style="color: #339933;">,</span><span style="color: #000088;">$fileLines</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$newsale</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$sale_time</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$date</span><span style="color: #339933;">;</span>
<span style="color: #990000;">fwrite</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fh</span><span style="color: #339933;">,</span> <span style="color: #000088;">$date</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fh</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;">$newsale</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #990000;">mail</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$email_to</span><span style="color: #339933;">,</span><span style="color: #000088;">$email_subject</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;You have made a sale.<span style="color: #000099; font-weight: bold;">\n</span>Sale Time: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$sale_time</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;From: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$email_from</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>To test, empty the  sales.txt file you created and run (access) the script. It will see your recent sales have not been logged and fire off the email. Make sure the email does not go to your junk folder.</p>
<p>If you want your computer to play a &#8216;kerching&#8217; upon making a sale, you can simply set up a rule in Microsoft Outlook to play the sound upon receiving an email with &#8216;Payment Received&#8217; in the subject. You get the idea.</p>
<p>For those of you who want the full-on portable cash register, continue on to create a gmail account with a difficult to guess name <em>just for these emails</em>. If you share this address <em>anywhere</em> it will get spammed. We do not want this as you will start hearing an awful lot of incorrect kerching&#8217;s!</p>
<p>You now need to set your phone up to use your gmail account. Make it check for new emails every 10 mins or so (depending on how often you set your cron job to run the script) and set <a href="http://www.haydenkibble.com/downloads/kerching.wav">this kerching wav</a> as your notification sound.</p>
<p>You are now set! When the php script runs intermittently on the cron job, it parses the feed for new sales. When it finds a new sale it sends an email to your phone, which plays a &#8216;kerching&#8217; sound on receipt!</p>
<p><a href="http://www.haydenkibble.com/?ibsa=share&amp;id=15" id="share-link-">Share</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.haydenkibble.com/2009/07/make-your-phone-kerching-when-you-make-a-sale/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
<enclosure url="http://www.haydenkibble.com/downloads/kerching.wav" length="12384" type="audio/x-wav" />
<enclosure url="http://www.haydenkibble.com/downloads/kerching.wav" length="12384" type="audio/x-wav" />
		</item>
		<item>
		<title>Dark Dreamweaver Theme</title>
		<link>http://www.haydenkibble.com/2009/06/dark-dreamweaver-theme/</link>
		<comments>http://www.haydenkibble.com/2009/06/dark-dreamweaver-theme/#comments</comments>
		<pubDate>Sat, 27 Jun 2009 18:24:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP/MySQL/AJAX]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[colour scheme]]></category>
		<category><![CDATA[dreamweaver]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.haydenkibble.com/?p=3</guid>
		<description><![CDATA[If, like me, you spend all day staring at a Dreamweaver code screen, you may have given thought to your eyesight and the steps you take to preserve it.
After over 10 years of software development, I have finally taken it upon myself to set my IDE background to black. I have tried this a couple [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.haydenkibble.com/wp-content/uploads/code-colouring-150x150.gif" alt="code-colouring" title="code-colouring" width="150" height="150" class="alignright size-thumbnail wp-image-34" />If, like me, you spend all day staring at a Dreamweaver code screen, you may have given thought to your eyesight and the steps you take to preserve it.</p>
<p>After over 10 years of software development, I have finally taken it upon myself to set my IDE background to black. I have tried this a couple of times over the years, but have immediately changed it back due to it looking &#8216;wierd&#8217;. I had just become too accustomed to the colour coding scheme PHP uses and found it extremely difficult to re-adjust.</p>
<p>After a scour on the internet for some sort of &#8216;theme&#8217;, I came across <a href="http://thatwebguyblog.com/show_article.php?id=2651" target="_blank">this excellent color scheme</a>.</p>
<p>I&#8217;ve now applied this colour scheme to the three PCs I develop on and two weeks down the line I&#8217;m really getting used to it. I think it will take another couple of weeks before the colours become second nature to my brain, but it&#8217;s worth it in the long run.</p>
<p><a href="http://www.haydenkibble.com/?ibsa=share&amp;id=3" id="share-link-">Share</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.haydenkibble.com/2009/06/dark-dreamweaver-theme/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

