<?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>Zenovation's Blog &#187; Uncategorized</title>
	<atom:link href="http://zenovations.com/blog/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://zenovations.com/blog</link>
	<description>A blog about web design, programming, hosting, and virtualmin hacks</description>
	<lastBuildDate>Wed, 28 Jul 2010 23:33:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Teaching Cron to Run Every Ten Minutes</title>
		<link>http://zenovations.com/blog/2009/06/teaching-cron-to-run-every-ten-minutes/</link>
		<comments>http://zenovations.com/blog/2009/06/teaching-cron-to-run-every-ten-minutes/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 14:27:08 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://zenovations.com/blog/?p=82</guid>
		<description><![CDATA[I got tired of hacking cron and typing in ridiculous things like 0,5,10,15,20,25,30,35,40,45,50,55 to tell my cron jobs to run every five minutes. Knowing that if I was annoyed by it, someone else with more time had probably suffered too, I hit Google. The result was surprisingly easy&#8230; Cron jobs are run by using the [...]]]></description>
			<content:encoded><![CDATA[<p>I got tired of hacking cron and typing in ridiculous things like 0,5,10,15,20,25,30,35,40,45,50,55 to tell my cron jobs to run every five minutes.</p>
<p>Knowing that if I was annoyed by it, someone else with more time had probably suffered too, I hit Google. The result was surprisingly easy&#8230;<br />
<span id="more-82"></span></p>
<p>Cron jobs are run by using the syntax:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p82code6'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p826"><td class="code" id="p82code6"><pre class="bash" style="font-family:monospace;">crontab <span style="color: #660033;">-e</span></pre></td></tr></table></div>

<p>Or, to edit a user&#8217;s crontab as root:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p82code7'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p827"><td class="code" id="p82code7"><pre class="bash" style="font-family:monospace;">crontab <span style="color: #660033;">-u</span> username <span style="color: #660033;">-e</span></pre></td></tr></table></div>

<p>The format of the cron file is as follows:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p82code8'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p828"><td class="code" id="p82code8"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#Minute (0-59)  Hour (0-23)  Day of Month (1-31)  Month (1-12 or Jan-Dec)  Day of Week (0-6 or Sun-Sat)  Command</span></pre></td></tr></table></div>

<p>A * equals &#8220;all&#8221; and is equivalent to using something like 0-59 for minutes. You can also use commas to specify multiples. Examples:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p82code9'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p829"><td class="code" id="p82code9"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#Minute (0-59)  Hour (0-23)  Day of Month (1-31)  Month (1-12 or Jan-Dec)  Day of Week (0-6 or Sun-Sat)  Command</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#runs updatedb command on Sunday and Wednesday at 2:15 am</span>
<span style="color: #000000;">15</span> <span style="color: #000000;">2</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> Sun,Wed <span style="color: #c20cb9; font-weight: bold;">updatedb</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">#runs a php script every minute and discards the output (errors too)</span>
<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>jsmith<span style="color: #000000; font-weight: bold;">/</span>myscript.php <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#runs php script every 15 minutes and outputs results to /var/log/myscript</span>
<span style="color: #000000;">15</span>,<span style="color: #000000;">30</span>,<span style="color: #000000;">45</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>jsmith<span style="color: #000000; font-weight: bold;">/</span>myscript.php <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>myscript <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span></pre></td></tr></table></div>

<p>I didn&#8217;t want to run my script every minute, nor did I want to type in 0,10,20,30,40,50 to make it run. So I went googling and found this syntax:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p82code10'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p8210"><td class="code" id="p82code10"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#runs php script every 10 minutes</span>
<span style="color: #000000; font-weight: bold;">*/</span><span style="color: #000000;">10</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>jsmith<span style="color: #000000; font-weight: bold;">/</span>myscript.php</pre></td></tr></table></div>

<p>The */x notation is useful on any field. For instance, */2 in the hours field means every 2 hours, */4 in the months field means every quarter.</p>
<p>Yay!</p>
]]></content:encoded>
			<wfw:commentRss>http://zenovations.com/blog/2009/06/teaching-cron-to-run-every-ten-minutes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extending the Windows Clipboard</title>
		<link>http://zenovations.com/blog/2009/06/extending-the-windows-clipboard/</link>
		<comments>http://zenovations.com/blog/2009/06/extending-the-windows-clipboard/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 13:54:50 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[clipboard]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://zenovations.com/blog/?p=57</guid>
		<description><![CDATA[For programmers and writers, being able to keep a history of copy/paste and access it with a hotkey is a serious boon. Here are some of the ways I use a clipboard tool daily (sometimes fifty times a day): Take notes quickly&#8211;store a url, email address, or command for reference later Reorganize a document&#8211;clip here, [...]]]></description>
			<content:encoded><![CDATA[<p>For programmers and writers, being able to keep a history of copy/paste and access it with a hotkey is a serious boon. Here are some of the ways I use a clipboard tool daily (sometimes fifty times a day):</p>
<ul>
<li>Take notes quickly&#8211;store a url, email address, or command for reference later</li>
<li>Reorganize a document&#8211;clip here, copy there, then paste it all together</li>
<li>Store commonly used commands and html strings for quick access</li>
<li>Passwords that I type more than ten times an hour</li>
<li>Storing things I use daily: IP addresses, dates, sql queries, urls</li>
</ul>
<p> </p>
<p>I&#8217;ve tried a few different tools, like <a href="http://www.comfort-software.com/clipboard-manager.html">Comfort Clipboard</a> and <a href="http://www.xneat.com/clipboard-manager/index.htm">XNeat Clipboard</a>. But nothing beats <a href="http://m8software.com/clipboards/spartan/tour/tour.htm">Spartan</a> for simple, direct, fast, and capable.</p>
<p>It allows you to store most any sort of formatted text, has 36 quick copy/paste slots, and multiple columns where you can drop text for different topics to store permanently and access them with a click.</p>
<p>If that wasn&#8217;t enough, it offers 10 different views, each with full hotkeys and columns. I&#8217;ve set mine up with CTRL+\ as a hotkey, so I have quick access to anything on the clipboard at the speed of typing.</p>
<p>It has a trial period, and is well worth the 20 bills for the full version.</p>
<p>For those with a little less robust needs, they also have a free version, <a href="http://101clips.com/freeclip.htm">101clips</a>, that is quite capable. Though I couldn&#8217;t live without the advanced capabilities of the full version.</p>
]]></content:encoded>
			<wfw:commentRss>http://zenovations.com/blog/2009/06/extending-the-windows-clipboard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Cron to Run in Cygwin</title>
		<link>http://zenovations.com/blog/2009/05/getting-cron-to-run-in-cygwin/</link>
		<comments>http://zenovations.com/blog/2009/05/getting-cron-to-run-in-cygwin/#comments</comments>
		<pubDate>Fri, 08 May 2009 19:44:37 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[cygwin]]></category>

		<guid isPermaLink="false">http://zenovations.com/blog/?p=51</guid>
		<description><![CDATA[I had problems getting cron to run under cygwin. I could crontab -e and install scripts, but they never actually get run. The first step was to install cygrunsrv, which appears under the admin section of cywin&#8217;s setup.exe package list. A little searching revealed a utility that will check your set up and install crontab [...]]]></description>
			<content:encoded><![CDATA[<p>I had problems getting cron to run under cygwin. I could <code>crontab -e</code> and install scripts, but they never actually get run.</p>
<p>The first step was to install <code>cygrunsrv</code>, which appears under the admin section of cywin&#8217;s setup.exe package list.</p>
<p>A little searching revealed a utility that will check your set up and install crontab for you. Here&#8217;s the complete steps I found by runnning this utility repeatedly and researching the errors it reported:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p51code13'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p5113"><td class="code" id="p51code13"><pre class="bash" style="font-family:monospace;">kato<span style="color: #000000; font-weight: bold;">@</span>devbox  ~$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> a+r <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">passwd</span>
&nbsp;
kato<span style="color: #000000; font-weight: bold;">@</span>devbox  ~$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> a+r <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>group
&nbsp;
kato<span style="color: #000000; font-weight: bold;">@</span>devbox  ~$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> a+x <span style="color: #000000; font-weight: bold;">/</span>var
&nbsp;
kato<span style="color: #000000; font-weight: bold;">@</span>devbox  ~$ cron_diagnose.sh
Do you want to <span style="color: #c20cb9; font-weight: bold;">install</span> the cron daemon <span style="color: #c20cb9; font-weight: bold;">as</span> a service? <span style="color: #7a0874; font-weight: bold;">&#40;</span>yes<span style="color: #000000; font-weight: bold;">/</span>no<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #c20cb9; font-weight: bold;">yes</span>
&nbsp;
Enter the value of CYGWIN <span style="color: #000000; font-weight: bold;">for</span> the daemon: <span style="color: #7a0874; font-weight: bold;">&#91;</span>ntsec smbntsec<span style="color: #7a0874; font-weight: bold;">&#93;</span> ntsec
&nbsp;
The service can run either <span style="color: #c20cb9; font-weight: bold;">as</span> yourself or under a privileged account.
Running <span style="color: #c20cb9; font-weight: bold;">as</span> yourself allows better access to network drives,
but does not allow to run the crontab of other users.
Do you want to the cron daemon to run <span style="color: #c20cb9; font-weight: bold;">as</span> yourself? <span style="color: #7a0874; font-weight: bold;">&#40;</span>yes<span style="color: #000000; font-weight: bold;">/</span>no<span style="color: #7a0874; font-weight: bold;">&#41;</span> no
&nbsp;
Running cron_diagnose ...
... no problem found.
&nbsp;
Do you want to start the cron daemon <span style="color: #c20cb9; font-weight: bold;">as</span> a service now? <span style="color: #7a0874; font-weight: bold;">&#40;</span>yes<span style="color: #000000; font-weight: bold;">/</span>no<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #c20cb9; font-weight: bold;">yes</span>
OK. The cron daemon is now running.</pre></td></tr></table></div>

<p>In my particular case, I also had to run the following, though take care with these since they replace your /etc/passwd file:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p51code14'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p5114"><td class="code" id="p51code14"><pre class="bash" style="font-family:monospace;">kato<span style="color: #000000; font-weight: bold;">@</span>devbox ~$ mkpasswd <span style="color: #660033;">-l</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">passwd</span>
&nbsp;
kato<span style="color: #000000; font-weight: bold;">@</span>devbox ~$ mkgroup <span style="color: #660033;">-l</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>group
&nbsp;
kato<span style="color: #000000; font-weight: bold;">@</span>devbox  ~$ mkpasswd <span style="color: #660033;">-d</span> <span style="color: #660033;">-u</span> kato <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">passwd</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://zenovations.com/blog/2009/05/getting-cron-to-run-in-cygwin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Redirect domain to subfolder on different site</title>
		<link>http://zenovations.com/blog/2009/04/redirect-domain-to-subfolder-on-different-site/</link>
		<comments>http://zenovations.com/blog/2009/04/redirect-domain-to-subfolder-on-different-site/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 19:35:11 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://zenovations.com/blog/?p=41</guid>
		<description><![CDATA[Wanted to redirect our old standby, pastebin.zentrack.net to the new location, dev.zentrack.net/pastebin. Took a bit of mojo to find the answer to that problem. I decided on using apache and bypass virtualmin&#8217;s admin tools. The &#8220;Rewrite&#8221; Approach Here is an approach using a rewrite rule, that preserves files and query parms from the original entry. [...]]]></description>
			<content:encoded><![CDATA[<p>Wanted to redirect our old standby, pastebin.zentrack.net to the new location, dev.zentrack.net/pastebin. Took a bit of mojo to find the answer to that problem. I decided on using apache and bypass virtualmin&#8217;s admin tools.</p>
<h3>The &#8220;Rewrite&#8221; Approach</h3>
<p>Here is an approach using a rewrite rule, that preserves files and query parms from the original entry. This takes widgets.mysite.com/files/?id=20 and redirects it to www.mysite.com/widgets/files/?id=20:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p41code17'); return false;">View Code</a> LANGUAGE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p4117"><td class="code" id="p41code17"><pre class="language" style="font-family:monospace;">RewriteCond %{HTTP_HOST} ^(www\.)?subdomain\.mainsite\.com
RewriteRule (.*) http://www.mainsite.com/subdirectory$1 [L,R=permanent]</pre></td></tr></table></div>

<p><code>%{HTTP_HOST}</code> is an apache variable that refers to the current domain entered in browser.<br />
<br /><code>(www\.)</code> makes it possible to redirect widgets.mysite.com or www.widgets.mysite.com.<br />
<br /><code>/subdirectory </code>is where you specify which directory the redirect drops them in.<br />
<br /><code>(/.+)?</code> bit is what adds on any details after the url.<br />
<br /><code>[L, R=permanent]</code> is based on <a href="http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html#RewriteCond">Apache&#8217;s RewriteCond options</a>, and tells apache we actually want to change the url in the browser, instead of just showing the correct page at this url.</p>
<h3>The &#8220;Redirect&#8221; Approach</h3>
<p>A simpler approach is to create a hard redirect like the following. This takes widgets.mysite.com/files/?id=20 and redirects it to www.mysite.com/widgets/:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p41code18'); return false;">View Code</a> INI</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p4118"><td class="code" id="p41code18"><pre class="ini" style="font-family:monospace;">ServerAlias subdomain.mainsite.com
RewriteEngine on
RewriteCond %<span style="">&#123;</span>HTTP_HOST<span style="">&#125;</span> ^subdomain.mainsite.com$ <span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>OR<span style="">&#93;</span></span> 
RewriteCond %<span style="">&#123;</span>HTTP_HOST<span style="">&#125;</span> ^www.subdomain.mainsite.com$ 
RewriteRule ^<span style="">&#40;</span>.*<span style="">&#41;</span>$ http://www.mainsite.com/subdirectory <span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>R<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">301,L<span style="">&#93;</span></span></span></pre></td></tr></table></div>

<p>This goes into the apache config, inside mainsite.com&#8217;s VirtualHost directive.<br />
<br /><code>ServerAlias</code> directive allows the main site to also accept queries for the subdomain.<br />
You may also need to add a DNS entry, depending on your setup.<br />
<br /><code>RewriteCond </code>with www.subdomain.mainsite.com is optional and recommended&#8211;if you remove it, also remove the <code>[OR]</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://zenovations.com/blog/2009/04/redirect-domain-to-subfolder-on-different-site/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Evaluating CDBurnerXP</title>
		<link>http://zenovations.com/blog/2009/04/evaluating-cdburnerxp/</link>
		<comments>http://zenovations.com/blog/2009/04/evaluating-cdburnerxp/#comments</comments>
		<pubDate>Mon, 13 Apr 2009 21:26:36 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[desktop]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://zenovations.com/blog/?p=37</guid>
		<description><![CDATA[I installed a new DVD/CD drive on a box today and found that the WinXP version it was installed with had no CD burning software&#8211;yarr. A quick Google turned up about 20 paid products and 5 unpaid products that looked at least promising and moderately maintained. After reducing my list to the top three free&#8211;or [...]]]></description>
			<content:encoded><![CDATA[<p>I installed a new DVD/CD drive on a box today and found that the WinXP version it was installed with had no CD burning software&#8211;yarr.</p>
<p>A quick Google turned up about 20 paid products and 5 unpaid products that looked at least promising and moderately maintained. After reducing my list to <a href="http://cdburnerxp.se/help/">the </a><a href="http://www.cheetahburner.com/">top</a> <a href="http://www.deepburner.com/?r=products&amp;pr=provsfree">three</a> free&#8211;or nearly free&#8211;choices, I decided to give <a href="http://cdburnerxp.se/">CDBurnerXP</a> a go.</p>
<p>It didn&#8217;t find my DVD/CD combo drive, so I checked from explorer and found that it wasn&#8217;t being detected. A quick jumper fix and the drive was now on Cable Select and working for windows.</p>
<p>However, it still didn&#8217;t appear in CDBurnerXP. On a hunch, I un/re-installed CDBurnerXP. Low and behold, there it was. Hmmm. That means that should I change drives or add a new drive, I&#8217;d probably have to do the un/re-install again to get it to detect them.</p>
<p>However, the functionality/usability of the app is great, so I dropped a donation in their paypal acct and and decided to stick with it. I&#8217;ll post an update if I change my mind later.</p>
]]></content:encoded>
			<wfw:commentRss>http://zenovations.com/blog/2009/04/evaluating-cdburnerxp/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Converting Agora to Kunena &#8211; Joomla Migration Tools</title>
		<link>http://zenovations.com/blog/2009/04/converting-agora-to-kunena-joomla-migration-tools/</link>
		<comments>http://zenovations.com/blog/2009/04/converting-agora-to-kunena-joomla-migration-tools/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 19:55:33 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[joomla]]></category>
		<category><![CDATA[kunena]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://zenovations.com/blog/?p=13</guid>
		<description><![CDATA[I successfully converted our old Agora forum on zentrack.com to a shiny new Kunena forum. Since there weren&#8217;t any handy migration scripts, I broke out my trusty, quick and dirty db migrator, and whipped one up. Here&#8217;s what you&#8217;d need for these scripts to be useful for your install too: Existing Categories in your Kunena [...]]]></description>
			<content:encoded><![CDATA[<p>I successfully converted our old <a href="http://www.joomlame.com/" target="_blank">Agora</a> forum on <a href="http://www.zentrack.com">zentrack.com</a> to a shiny new <a href="http://www.kunena.com/" target="_blank">Kunena</a> forum.</p>
<p>Since there weren&#8217;t any handy migration scripts, I broke out my trusty, <a href="http://zenovations.com/blog/?p=16">quick and dirty db migrator</a>, and whipped one up.</p>
<p>Here&#8217;s what you&#8217;d need for these scripts to be useful for your install too:</p>
<ul>
<li>Existing Categories in your Kunena db that mirror the old Agora forums</li>
<li>Command Line Access to your server</li>
<li>Basic understanding of SQL and shell scripting</li>
</ul>
<p>Here&#8217;s what the scripts do:</p>
<ul>
<li>Works with or without <a href="http://www.joomlapolis.com/" target="_blank">CB</a></li>
<li>Import all posts from Agora to Kunena</li>
<li>Convert agora user ids to joomla ids (used by Kunena)</li>
<li>Updates post counts by category (Kunenas sync tool doesn&#8217;t do well)</li>
</ul>
<p>Here&#8217;s what to do:</p>
<ol>
<li>Make sure your categories are set up</li>
<li>Download the <a href="http://www.zenovations.com/misc/agora_to_kunena_converter.zip">zip file linked here</a></li>
<li>Open configure.php</li>
<li>Modify the connection info at the top</li>
<li>Set the forum ids to category ids</li>
<li>Set $fake_inserts = true</li>
<li>Run the script:  php ./converter.php (a test run)</li>
<li>Check out the printed results and make sure they look sensible</li>
<li>Set $fake_inserts = false</li>
<li>Have a go at the real data (you have a backup, right??)</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://zenovations.com/blog/2009/04/converting-agora-to-kunena-joomla-migration-tools/feed/</wfw:commentRss>
		<slash:comments>41</slash:comments>
		</item>
		<item>
		<title>Quick and Dirty Database Conversion Tool</title>
		<link>http://zenovations.com/blog/2009/04/quick-and-dirty-database-conversion-tool/</link>
		<comments>http://zenovations.com/blog/2009/04/quick-and-dirty-database-conversion-tool/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 19:11:29 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://zenovations.com/blog/?p=16</guid>
		<description><![CDATA[I created a quick tool for importing database data and modifying structure and data as it goes. It populates a single table at a time, offers decent flexibility, and allows you to specify your own callback functions to deal with data conversion. It can handle inserts and allows you to specify customized queries if desired. [...]]]></description>
			<content:encoded><![CDATA[<p>I created a quick tool for importing database data and modifying structure and data as it goes. It populates a single table at a time, offers decent flexibility, and allows you to specify your own callback functions to deal with data conversion.  It can handle inserts and allows you to specify customized queries if desired. It allows any complexity of joins on the source data. Alas, it only works in mysql because that&#8217;s all I needed it for.  Use an adapt for any non-evil purpose you like &#8211; Creative Commons.  Usage:</p>
<ol>
<li>Open configure.php</li>
<li>Set $fake_inserts = true (for testing)</li>
<li>Probably want to set $max_rows (for testing)</li>
<li>Set up your table conversions using the $tablemap arrays</li>
<li>Call the script to test results: php ./converter.php</li>
<li>When satisfied, set $fake_inserts = false (got a backup??)</li>
<li>Whammo!</li>
</ol>
<p>Here is the <b>config.php</b> file you&#8217;ll need to tweak:</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p16code21'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p1621"><td class="code" id="p16code21"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*************************************************************
   CONFIGURABLE PARAMETERS
**********************************************************/</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * These can also be configured per-query below, if more granularity is needed
 */</span>
<span style="color: #000088;">$from_db_connection</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'localhost'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'username'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'password'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'db-instance'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$to_db_connection</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'localhost'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'username'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'password'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'db-instance'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * We either output by printing insert statements to the screen for testing(true),
 * or by running the insert queries directly on the target db(false-default). Set this
 * to false when you're ready to import for real
 */</span>
<span style="color: #000088;">$fake_inserts</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Max rows allows you to only run a certain number of queries per table, for testing. Leave
 * this set to 0 for the real run
 */</span>
<span style="color: #000088;">$max_rows</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * If true, script will exist on any failed insert query.
 * If false, will continue to run even if queries fail and insert the other records.
 */</span>
<span style="color: #000088;">$stop_on_failed_query</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * $tablemap is an array containing one entry for each table to be converted.
 * Note that tables don't necessarily have to be 1:1 to make this work, since
 * the source query can use whatever sort of joins needed to set up the source
 * fields. There must, of course, be exactly one output table.
 *
 * &lt;p&gt;Here are the fields for each conversion element:
 * &lt;ul&gt;
 *   &lt;li&gt;connection info - an array containin the source database and target database. It contains two
 *       elements, each is an array containing array( host, username, password, db_instance )
 *   &lt;li&gt;source_query - the query to be run against source db, set it up however you like, the field names should correspond with the 'fields' array's keys
 *   &lt;li&gt;fields - see below
 *   &lt;li&gt;defaults - default values to apply to any fields in target table, overwritten by values in 'fields'
 * &lt;/ul&gt;
 *
 * &lt;p&gt;If you just want to create insert statements with the data, use dest_table. If you
 * need custom queries or updates to run, you can specify dest_query. Values for any output fields
 * can be substituted using {field_name} in the query.
 *
 * &lt;p&gt;The 'fields' element is an indexed array. The key is the source table's column name. The value is either a string indicating the name of hte column in the destination table, or an array containing exactly two elements: 1) a function to call, which will be passed the value from source table, 2) the destination column name
 *
 * &lt;p&gt;The function is passed a host of arguments, in order:
 * &lt;ol&gt;
 *  &lt;li&gt;value from originating column
 *  &lt;li&gt;entire data row
 *  &lt;li&gt;original column name
 *  &lt;li&gt;destination column name
 * &lt;/ol&gt;
 *
 * &lt;p&gt;To list the same field twice (since the keys would be identical) you can use an array index which will be stripped from the column name before querying, such as &quot;field_id[1]&quot;, &quot;field_id[2]&quot;, which both refer to a column named &quot;field_id&quot;
 */</span>
<span style="color: #000088;">$tablemap</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
* This example is a simple, straight copy from one table to another
*/</span>
<span style="color: #000088;">$tablemap</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
	 <span style="color: #0000ff;">&quot;connection_info&quot;</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
				    <span style="color: #0000ff;">&quot;source&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$from_db_connection</span><span style="color: #339933;">,</span>
				    <span style="color: #0000ff;">&quot;dest&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$to_db_connection</span>
	 <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	 <span style="color: #0000ff;">&quot;source_query&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'select * from source_table'</span><span style="color: #339933;">,</span>
	 <span style="color: #0000ff;">&quot;dest_table&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;destination_table&quot;</span><span style="color: #339933;">,</span>
	 <span style="color: #0000ff;">'fields'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">'source1'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'dest1'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'source2'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'dest2'</span><span style="color: #339933;">,</span>
			   <span style="color: #0000ff;">'posted'</span>  <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'toSqlDate'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'date'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// convert unix timestamp to sql date</span>
			   <span style="color: #0000ff;">'id[1]'</span>   <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'id'</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// here we set two dest fields from &quot;id&quot;, using array index</span>
			   <span style="color: #0000ff;">'id[2]'</span>   <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'getParentId'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'parent'</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// another custom function</span>
	 <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	 <span style="color: #0000ff;">'defaults'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
			   <span style="color: #0000ff;">'dest3'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'0'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'dest4'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</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;">/*
 * This example runs a customized query instead of a normal insert
 */</span>
&nbsp;
<span style="color: #000088;">$tablemap</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
	 <span style="color: #0000ff;">&quot;connection_info&quot;</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
          <span style="color: #0000ff;">&quot;source&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$from_db_connection</span><span style="color: #339933;">,</span>
          <span style="color: #0000ff;">&quot;dest&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$to_db_connection</span>
	 <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	 <span style="color: #0000ff;">&quot;source_query&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'
         select 
            count(*) as src_total, category
         from 
            source_table_1 s1, source_table_2 s2
         where
            s1.id = s2.id AND s2.id &gt; 100
         group by
            category'</span><span style="color: #339933;">,</span>
	 <span style="color: #0000ff;">&quot;dest_query&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'update dest_table set total = {dest_total} where catid = {cat}'</span><span style="color: #339933;">,</span>
	 <span style="color: #0000ff;">'fields'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
			   <span style="color: #0000ff;">'category'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'cat'</span><span style="color: #339933;">,</span>
			   <span style="color: #0000ff;">'src_total'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'dest_total'</span>
	 <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	 <span style="color: #0000ff;">'defaults'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// these are still applicable, just didn't need any</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">/*****************************************************************************
  USER FUNCTIONS (methods used by the 'fields' array to convert values)
***************************************************************************/</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Just an example function that creates a value by combining two cols from source table
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> getParentId<span style="color: #009900;">&#40;</span><span style="color: #000088;">$src_id</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data_row</span><span style="color: #339933;">,</span> <span style="color: #000088;">$src_col_name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dest_col_name</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: #000088;">$src_id</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #666666; font-style: italic;">// if it exists, use it</span>
      <span style="color: #b1b100;">return</span> <span style="color: #000088;">$src_id</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
   <span style="color: #666666; font-style: italic;">// otherwise, create one</span>
   <span style="color: #b1b100;">return</span> <span style="color: #000088;">$data_row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;number_1&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$data_row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;number_2&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Example function to create an incremental id for the result data
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> getIncrementalId<span style="color: #009900;">&#40;</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;">$currentIncId</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">return</span> <span style="color: #339933;">++</span><span style="color: #000088;">$currentIncId</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$currentIncId</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Converts a unix timestamp to a sql datetime
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> toSqlDate<span style="color: #009900;">&#40;</span><span style="color: #000088;">$utime</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">return</span> <a href="http://www.php.net/date"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Y-m-d H:i:s&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$utime</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>And here is the <b>convert.php</b> script you&#8217;ll be running:</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p16code22'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p1622"><td class="code" id="p16code22"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #666666; font-style: italic;">/*********************************
 GO TO THIS FILE TO CONFIGURE
 ********************************/</span>
  <span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;config.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*********************************
 YOU WON'T NEED TO CHANGE ANYTHING BELOW HERE
 ********************************/</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Prints out contents and adds html chars if this isn't cli
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> printIt<span style="color: #009900;">&#40;</span><span style="color: #000088;">$txt</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$e</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/php_sapi_name"><span style="color: #990000;">php_sapi_name</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;cli&quot;</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: #0000ff;">&quot;&lt;br&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">print</span> <span style="color: #000088;">$txt</span><span style="color: #339933;">.</span><span style="color: #000088;">$e</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Generates a list of insertable values, escaped for sql
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> make_vals<span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$s</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$k</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$v</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: #000088;">$s</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$s</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;, &quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
    <span style="color: #000088;">$s</span> <span style="color: #339933;">.=</span> fixMySquirrelVal<span style="color: #009900;">&#40;</span><span style="color: #000088;">$v</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$s</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Adds a data row to the dest table
 * @param resource $dbin the db connection
 * @param string $table dest table
 * @param array $row indexed array of (string)col =&gt; (mixed)value - do not escape these
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> addRow<span style="color: #009900;">&#40;</span><span style="color: #000088;">$dbin</span><span style="color: #339933;">,</span> <span style="color: #000088;">$table</span><span style="color: #339933;">,</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$vals</span> <span style="color: #339933;">=</span> make_vals<span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$cols</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'`'</span><span style="color: #339933;">.</span><a href="http://www.php.net/join"><span style="color: #990000;">join</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'`,`'</span><span style="color: #339933;">,</span><a href="http://www.php.net/array_keys"><span style="color: #990000;">array_keys</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'`'</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;INSERT INTO `<span style="color: #006699; font-weight: bold;">$table</span>` (<span style="color: #006699; font-weight: bold;">$cols</span>) VALUES(<span style="color: #006699; font-weight: bold;">$vals</span>)&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">return</span> runMySquirrelQuery<span style="color: #009900;">&#40;</span><span style="color: #000088;">$dbin</span><span style="color: #339933;">,</span> <span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Runs a custom query rather than a simple insert
 * @param resource $dbin the db connection
 * @param string $query the custom query, with {field_name} anywhere the field vals will be substituted
 * @param array $row indexed array of (string)col =&gt; (mixed)value - do not escape these
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> customQuery<span style="color: #009900;">&#40;</span><span style="color: #000088;">$dbin</span><span style="color: #339933;">,</span> <span style="color: #000088;">$query</span><span style="color: #339933;">,</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">// substitute our new vals</span>
  <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$k</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$v</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;{<span style="color: #006699; font-weight: bold;">{$k}</span>}&quot;</span><span style="color: #339933;">,</span> fixMySquirrelVal<span style="color: #009900;">&#40;</span><span style="color: #000088;">$v</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #666666; font-style: italic;">// run query with custom vals</span>
  <span style="color: #b1b100;">return</span> runMySquirrelQuery<span style="color: #009900;">&#40;</span><span style="color: #000088;">$dbin</span><span style="color: #339933;">,</span> <span style="color: #000088;">$query</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;">function</span> fixMySquirrelVal<span style="color: #009900;">&#40;</span><span style="color: #000088;">$v</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><a href="http://www.php.net/is_null"><span style="color: #990000;">is_null</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$v</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">&quot;NULL&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">return</span> <a href="http://www.php.net/sprintf"><span style="color: #990000;">sprintf</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; '<span style="color: #009933; font-weight: bold;">%s</span>' &quot;</span><span style="color: #339933;">,</span> <a href="http://www.php.net/mysql_real_escape_string"><span style="color: #990000;">mysql_real_escape_string</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$v</span><span style="color: #009900;">&#41;</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;">function</span> runMySquirrelQuery<span style="color: #009900;">&#40;</span><span style="color: #000088;">$dbin</span><span style="color: #339933;">,</span> <span style="color: #000088;">$query</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;">$fake_inserts</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$stop_on_failed_query</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$fake_inserts</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    printIt<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: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><a href="http://www.php.net/mysql_query"><span style="color: #990000;">mysql_query</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dbin</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    printIt<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;!!ERROR!! Unable to insert record (<span style="color: #006699; font-weight: bold;">$query</span>): &quot;</span><span style="color: #339933;">.</span><a href="http://www.php.net/mysql_error"><span style="color: #990000;">mysql_error</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$stop_on_failed_query</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <a href="http://www.php.net/exit"><span style="color: #990000;">exit</span></a><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Given a row from the source table, converts field names and values
 * to be compatible for dest table
 * @param array $row indexed array of (string)col =&gt; (mixed)value - do not escape these
 * @param array $fields indexed array of (string)source_field =&gt; (mixed)dest_field
 * @param array $defaults indexed array of (string)dest_field =&gt; (mixed)value -- can be null
 * @return array indexed by column names for dest table
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> convertRow<span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #339933;">,</span> <span style="color: #000088;">$fields</span><span style="color: #339933;">,</span> <span style="color: #000088;">$defaults</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">// start by applying default values, these can be overwritten if fields contains same value</span>
  <span style="color: #000088;">$newrow</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/is_array"><span style="color: #990000;">is_array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$defaults</span><span style="color: #009900;">&#41;</span>? <span style="color: #000088;">$defaults</span> <span style="color: #339933;">:</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fields</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$k</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$v</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// for multiple fields with same key, strips off the [n] from end</span>
    <span style="color: #000088;">$k</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;@\[[0-9]+\]$@&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$k</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <span style="color: #666666; font-style: italic;">// run user functions as needed to modify values</span>
    <span style="color: #000088;">$key</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/is_array"><span style="color: #990000;">is_array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$v</span><span style="color: #009900;">&#41;</span>? <span style="color: #000088;">$v</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$v</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$val</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/is_array"><span style="color: #990000;">is_array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$v</span><span style="color: #009900;">&#41;</span>? <a href="http://www.php.net/call_user_func"><span style="color: #990000;">call_user_func</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$v</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$k</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$row</span><span style="color: #339933;">,</span> <span style="color: #000088;">$k</span><span style="color: #339933;">,</span> <span style="color: #000088;">$key</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$k</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><a href="http://www.php.net/is_null"><span style="color: #990000;">is_null</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
      <span style="color: #666666; font-style: italic;">// create the new column in data row</span>
      <span style="color: #000088;">$newrow</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$val</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$newrow</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> connectToDb<span style="color: #009900;">&#40;</span><span style="color: #000088;">$connection_info</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <a href="http://www.php.net/list"><span style="color: #990000;">list</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$host</span><span style="color: #339933;">,</span> <span style="color: #000088;">$user</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pass</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dbname</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$connection_info</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$dbh</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_connect"><span style="color: #990000;">mysql_connect</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$host</span><span style="color: #339933;">,</span> <span style="color: #000088;">$user</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pass</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: #339933;">!</span><span style="color: #000088;">$dbh</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    printIt<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Unable to connect to DB: &quot;</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/mysql_error"><span style="color: #990000;">mysql_error</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <a href="http://www.php.net/exit"><span style="color: #990000;">exit</span></a><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/mysql_select_db"><span style="color: #990000;">mysql_select_db</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dbname</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dbh</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    printIt<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Unable to select <span style="color: #006699; font-weight: bold;">$dbname</span>: &quot;</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/mysql_error"><span style="color: #990000;">mysql_error</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <a href="http://www.php.net/exit"><span style="color: #990000;">exit</span></a><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$dbh</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> convertTable<span style="color: #009900;">&#40;</span><span style="color: #000088;">$map</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;">$max_rows</span><span style="color: #339933;">;</span>
&nbsp;
  printIt<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  printIt<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;-------------------------------------------------&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$map</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'dest_query'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    printIt<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Running custom query: <span style="color: #006699; font-weight: bold;">{$map['dest_query']}</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    printIt<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Migrating values to <span style="color: #006699; font-weight: bold;">{$map['dest_table']}</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  printIt<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;-------------------------------------------------&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  printIt<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// we call this each time because we can't just store a separate connection for the from instance</span>
  <span style="color: #666666; font-style: italic;">// and to instance... chances are they point to the same server, so php/mysql will re-use the connection</span>
  <span style="color: #666666; font-style: italic;">// and just switch the instance being operated on... this will cause our queries to go on the fritz</span>
  <span style="color: #666666; font-style: italic;">// the upside is that it doesn't have to reconnect since it's reused, so there's no big cost to this approach</span>
  <span style="color: #000088;">$dbout</span> <span style="color: #339933;">=</span> connectToDb<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$map</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'connection_info'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'source'</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;">// select the old data</span>
  <span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_query"><span style="color: #990000;">mysql_query</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$map</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'source_query'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dbout</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    printIt<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Unable to load source data (<span style="color: #006699; font-weight: bold;">{$map['source_query']}</span>): &quot;</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/mysql_error"><span style="color: #990000;">mysql_error</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <a href="http://www.php.net/exit"><span style="color: #990000;">exit</span></a><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/mysql_num_rows"><span style="color: #990000;">mysql_num_rows</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    printIt<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;No rows found, that's weird so I'm exiting&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <a href="http://www.php.net/exit"><span style="color: #990000;">exit</span></a><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// here again, we call this right before use, because we're going to switch instances, but</span>
  <span style="color: #666666; font-style: italic;">// it's probably to the same mysql server, so connection will get reused</span>
  <span style="color: #000088;">$dbin</span> <span style="color: #339933;">=</span> connectToDb<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$map</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'connection_info'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'dest'</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;">// While a row of data exists, put that row in $row as an associative array</span>
  <span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$j</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_fetch_assoc"><span style="color: #990000;">mysql_fetch_assoc</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$vals</span> <span style="color: #339933;">=</span> convertRow<span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #339933;">,</span> <span style="color: #000088;">$map</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'fields'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$map</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'defaults'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$map</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'dest_query'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      customQuery<span style="color: #009900;">&#40;</span><span style="color: #000088;">$dbin</span><span style="color: #339933;">,</span> <span style="color: #000088;">$map</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'dest_query'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$vals</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$j</span><span style="color: #339933;">++;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
      addRow<span style="color: #009900;">&#40;</span><span style="color: #000088;">$dbin</span><span style="color: #339933;">,</span> <span style="color: #000088;">$map</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'dest_table'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$vals</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$j</span><span style="color: #339933;">++;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000088;">$i</span><span style="color: #339933;">++;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$max_rows</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$max_rows</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// recover query memory</span>
  <a href="http://www.php.net/mysql_free_result"><span style="color: #990000;">mysql_free_result</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// show the user what we did</span>
  printIt<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Converted &quot;</span><span style="color: #339933;">.</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">-</span><span style="color: #000088;">$j</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; rows&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$j</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> printIt<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;!!!! <span style="color: #006699; font-weight: bold;">$j</span> errors !!!!!!&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;
<span style="color: #666666; font-style: italic;">// actually run the conversions</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tablemap</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$t</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  convertTable<span style="color: #009900;">&#40;</span><span style="color: #000088;">$t</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
printIt<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Finished without blowing up the planet&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://zenovations.com/blog/2009/04/quick-and-dirty-database-conversion-tool/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>phpize: command not found</title>
		<link>http://zenovations.com/blog/2009/04/phpize-command-not-found-2/</link>
		<comments>http://zenovations.com/blog/2009/04/phpize-command-not-found-2/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 18:25:37 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[centos 5]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[pecl]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://zenovations.com/blog/?p=15</guid>
		<description><![CDATA[Ran into this error (phpize: command not found) while trying to install json extension for PHP. Here is the solution on CentOS 5/RHEL: ?View Code BASHyum install php-devel On Debian/Ubuntu: ?View Code BASHapt-get install php5-dev Viola! Why do you have to install dev tools to use extensions? Dunno. Very irritating. But it solves it with [...]]]></description>
			<content:encoded><![CDATA[<p>Ran into this error (phpize: command not found) while trying to install json extension for PHP.</p>
<p>Here is the solution on CentOS 5/RHEL:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p15code25'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p1525"><td class="code" id="p15code25"><pre class="bash" style="font-family:monospace;">yum <span style="color: #c20cb9; font-weight: bold;">install</span> php-devel</pre></td></tr></table></div>

<p>On Debian/Ubuntu:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p15code26'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p1526"><td class="code" id="p15code26"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> php5-dev</pre></td></tr></table></div>

<p>Viola! Why do you have to install dev tools to use extensions? Dunno. Very irritating. But it solves it with no side effects.</p>
]]></content:encoded>
			<wfw:commentRss>http://zenovations.com/blog/2009/04/phpize-command-not-found-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Forward gmail to SMS (cell phone)</title>
		<link>http://zenovations.com/blog/2009/04/forward-gmail-to-sms-cell-phone/</link>
		<comments>http://zenovations.com/blog/2009/04/forward-gmail-to-sms-cell-phone/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 01:03:47 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[sms]]></category>

		<guid isPermaLink="false">http://zenovations.com/blog/?p=11</guid>
		<description><![CDATA[I stumbled across this handy article while trying to figure out how to get server related messages to send me a text. Apparently a gmail filter can forward right to my cell phone number. Yay!]]></description>
			<content:encoded><![CDATA[<p>I stumbled across <a href="http://www.googletutor.com/2005/03/25/gmail-to-your-phone/">this handy article</a> while trying to figure out how to get server related messages to send me a text.</p>
<p>Apparently a gmail filter can forward right to my cell phone number. Yay!</p>
]]></content:encoded>
			<wfw:commentRss>http://zenovations.com/blog/2009/04/forward-gmail-to-sms-cell-phone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changing SMTP Port to 587 (ISP Blocking and SASL)</title>
		<link>http://zenovations.com/blog/2009/03/changing-smtp-port-to-587-isp-blocking-and-sasl/</link>
		<comments>http://zenovations.com/blog/2009/03/changing-smtp-port-to-587-isp-blocking-and-sasl/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 07:27:59 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[smtp]]></category>
		<category><![CDATA[Virtualmin]]></category>

		<guid isPermaLink="false">http://zenovations.com/blog/?p=7</guid>
		<description><![CDATA[I got tired of ISPs blocking outgoing port 25, so I moved our SMTP for clients to port 587. Unfortunately, when migrating our new server, I couldn&#8217;t remember how to do this. After some Googling, I found the answer; add this line in /etc/postfix/master.cf, substituting your port number for 25000: ?View Code BASH25000 inet n - [...]]]></description>
			<content:encoded><![CDATA[<p>I got tired of ISPs blocking outgoing port 25, so I moved our SMTP for clients to port 587. Unfortunately, when migrating our new server, I couldn&#8217;t remember how to do this.</p>
<p>After some Googling, I found the answer; add this line in <em>/etc/postfix/master.cf</em>, substituting your port number for 25000:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p7code29'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p729"><td class="code" id="p7code29"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">25000</span> inet n - n - - smtpd <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_sasl_auth_enable</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span></pre></td></tr></table></div>

<p>I left port 25 on too, so users can try either from their ISP. If you want to turn off port 25, just comment out this line:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p7code30'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p730"><td class="code" id="p7code30"><pre class="bash" style="font-family:monospace;">smtp    inet    n       -       n       -       -       smtpd <span style="color: #660033;">-o</span> <span style="color: #007800;">smtpd_sasl_auth_enable</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span></pre></td></tr></table></div>

</p>
<p>Remember to open up the port in your server firewall as well!</p>
]]></content:encoded>
			<wfw:commentRss>http://zenovations.com/blog/2009/03/changing-smtp-port-to-587-isp-blocking-and-sasl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
