<?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"
	>

<channel>
	<title>GeekyBoy.com</title>
	<atom:link href="http://www.geekyboy.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.geekyboy.com</link>
	<description>Yep, another Geek weblog</description>
	<pubDate>Wed, 03 Sep 2008 13:36:30 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
	<language>en</language>
			<item>
		<title>Ubuntu Hardy Heron sound broken</title>
		<link>http://www.geekyboy.com/archives/118</link>
		<comments>http://www.geekyboy.com/archives/118#comments</comments>
		<pubDate>Wed, 03 Sep 2008 13:35:22 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
		
		<category><![CDATA[Hardware]]></category>

		<category><![CDATA[OS]]></category>

		<category><![CDATA[Quick Tips]]></category>

		<category><![CDATA[Ubuntu]]></category>

		<category><![CDATA[bluetooth]]></category>

		<category><![CDATA[dell]]></category>

		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.geekyboy.com/?p=118</guid>
		<description><![CDATA[Recently I was having a consistent problem with the sound on my Dell Inspiron 1720, which is running on Ubuntu Hardy Heron.  It would consistently stop working all together, and I had a terrible time finding the cause of the problem.  If I viewed a flash video on the web, the sound would [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I was having a consistent problem with the sound on my Dell Inspiron 1720, which is running on Ubuntu Hardy Heron.  It would consistently stop working all together, and I had a terrible time finding the cause of the problem.  If I viewed a flash video on the web, the sound would die afterwards.  If I listened to streaming Internet radio, the sound would die.  If I received an emial or IM the sound would die.</p>
<p>Finally it dawned on me, and I am not sure why or how.  But a few weeks prior I had been toying with a Bluetooth stereo headset and had turned on the Audio service in the Bluetooth manager on the services tab.</p>
<p><strong>Problem fixed:</strong> I simply turned off the Audio service in the Bluetooth manager, and all is working normally again.  However, if I ever need the Audio service I suppose it will break my sound.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekyboy.com/archives/118/feed</wfw:commentRss>
		</item>
		<item>
		<title>Hiding an email address using Javascript</title>
		<link>http://www.geekyboy.com/archives/48</link>
		<comments>http://www.geekyboy.com/archives/48#comments</comments>
		<pubDate>Fri, 29 Aug 2008 15:18:02 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
		
		<category><![CDATA[Quick Tips]]></category>

		<category><![CDATA[email]]></category>

		<category><![CDATA[html]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.geekyboy.com/?p=48</guid>
		<description><![CDATA[Have you ever wondered why you suddenly started getting tons of spam?
Do you have, or did you recently post your email address on a website?
Then the reason is probably because you did not properly protect the email address, and spammers get most email addresses from robot script that harvest email addresses from websites.  It [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever wondered why you suddenly started getting tons of spam?</p>
<p>Do you have, or did you recently post your email address on a website?</p>
<p>Then the reason is probably because you did not properly protect the email address, and spammers get most email addresses from robot script that harvest email addresses from websites.  It is pretty simple really.  The robot script hits the largest search engines for certain key words or phrases, to help the spammer hit the most relevent email addresses, and then systematically follows the links to websites.  Once the robot gets to the website it then searches all links on the page.  Each link it finds on the page that is a &#8220;mailto:&#8221; is an email address, and in a matter of minutes a robot script can harvest hundreds of emails.</p>
<p>So now you are asking, &#8220;What can be done to protect me from these vile robots?&#8221;.  Well that answer is also simple.  Most robot script are not smart enough, yet, to search Javascript code that scrambles an email address and form it back into a valid email address.  So here is how to do it:</p>
<p>First, you need to go into the HTML code and insert the Javascript as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> theuser <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;username&quot;</span>; <span style="color: #006600; font-style: italic;">// change this to be the username, or portion of the email to the left of the @</span>
<span style="color: #003366; font-weight: bold;">var</span> thehost <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;your-domain.com&quot;</span>; <span style="color: #006600; font-style: italic;">// change this to be your domain name</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> themessage <span style="color: #339933;">=</span> theuser <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;@&quot;</span> <span style="color: #339933;">+</span> thehost;
&nbsp;
<span style="color: #006600; font-style: italic;">// Now we tell Javascript to bring the pieces of the email address together visually on the screen as a link</span>
document.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&lt;a href=&quot;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;mail&quot;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;to:&quot;</span> <span style="color: #339933;">+</span> theuser <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;@&quot;</span> <span style="color: #339933;">+</span> thehost <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;&gt;&quot;</span> <span style="color: #339933;">+</span> themessage <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;&lt;/a&gt;&quot;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>Note: Be sure to substitute <code>username</code> and <code>your-domain.com</code> with your own information.</p>
<p>Now when you view your webpage in your favorite browser (<a href="http://www.getfirefox.com">Firefox</a>) you will see the email as a link like you wanted, and the robots will see a bunch of code that most of them cannot form into a valid email address.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekyboy.com/archives/48/feed</wfw:commentRss>
		</item>
		<item>
		<title>SSH port forwarding/tunneling for MySQL connection</title>
		<link>http://www.geekyboy.com/archives/47</link>
		<comments>http://www.geekyboy.com/archives/47#comments</comments>
		<pubDate>Wed, 02 Jan 2008 22:09:50 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
		
		<category><![CDATA[Databases]]></category>

		<category><![CDATA[MySQL]]></category>

		<category><![CDATA[OS]]></category>

		<category><![CDATA[Quick Tips]]></category>

		<category><![CDATA[linux]]></category>

		<category><![CDATA[networking]]></category>

		<category><![CDATA[php]]></category>

		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.geekyboy.com/archives/47</guid>
		<description><![CDATA[Create an account on the remote MySQL database server.

useradd -s /bin/false remote_user
mkdir /home/remote_user/.ssh
touch /home/remote_user/.ssh/authorized_keys
chown -R remote_user:remote_user /home/remote_user/.ssh
chmod 755 /home/remote_user/.ssh
chmod 600 /home/remote_user/.ssh/authorized_keys

Add MySQL permissions in the remote MySQL database to allow user connections from localhost.

USE mysql;
GRANT ALL ON db.* TO database_user@127.0.0.1 IDENTIFIED BY 'database_pass';
FLUSH PRIVILEGES;

Now, on the local server (as root) create an RSA key pair [...]]]></description>
			<content:encoded><![CDATA[<p>Create an account on the remote MySQL database server.</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;">useradd <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">false</span> remote_user
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>remote_user<span style="color: #000000; font-weight: bold;">/</span>.ssh
<span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>remote_user<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>authorized_keys
<span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #660033;">-R</span> remote_user:remote_user <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>remote_user<span style="color: #000000; font-weight: bold;">/</span>.ssh
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">755</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>remote_user<span style="color: #000000; font-weight: bold;">/</span>.ssh
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">600</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>remote_user<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>authorized_keys</pre></div></div>

<p>Add MySQL permissions in the remote MySQL database to allow user connections from localhost.</p>

<div class="wp_syntax"><div class="code"><pre class="sql sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">USE</span> mysql;
<span style="color: #993333; font-weight: bold;">GRANT</span> <span style="color: #993333; font-weight: bold;">ALL</span> <span style="color: #993333; font-weight: bold;">ON</span> db<span style="color: #66cc66;">.*</span> <span style="color: #993333; font-weight: bold;">TO</span> database_user@127<span style="color: #66cc66;">.</span>0<span style="color: #66cc66;">.</span>0<span style="color: #66cc66;">.</span>1 <span style="color: #993333; font-weight: bold;">IDENTIFIED</span> <span style="color: #993333; font-weight: bold;">BY</span> <span style="color: #ff0000;">'database_pass'</span>;
<span style="color: #993333; font-weight: bold;">FLUSH</span> PRIVILEGES;</pre></div></div>

<p>Now, on the local server (as root) create an RSA key pair to avoide the need for passwords for remote_user. (Simply hit enter for each question encountered.)</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ssh-keygen</span> <span style="color: #660033;">-t</span> rsa</pre></div></div>

<p>Now transfer the public key file to the remote server from your local server.</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">scp</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>id_rsa.pub root<span style="color: #000000; font-weight: bold;">@</span>remote_server.com:<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>local_server.local_rsa.pub
<span style="color: #c20cb9; font-weight: bold;">ssh</span> remote_server.com
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>local_server.local_rsa.pub <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>remote_user<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>authorized_keys</pre></div></div>

<p>On the local server, create an SSH tunnel to the remote MySQL database server using the following command.</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #660033;">-fNg</span> <span style="color: #660033;">-L</span> <span style="color: #000000;">3306</span>:127.0.0.1:<span style="color: #000000;">3306</span> remote_user<span style="color: #000000; font-weight: bold;">@</span>remote_server.com <span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">9999</span></pre></div></div>

<p>To use this from PHP you would simply do this:</p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #000088;">$remote_server_mysql</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;127.0.0.1&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;database_user&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;database_pass&quot;</span> <span style="color: #009900;">&#41;</span>;
<span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;database&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$remote_server_mysql</span> <span style="color: #009900;">&#41;</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.geekyboy.com/archives/47/feed</wfw:commentRss>
		</item>
		<item>
		<title>Using the UNIX tail -f command to watch log files</title>
		<link>http://www.geekyboy.com/archives/46</link>
		<comments>http://www.geekyboy.com/archives/46#comments</comments>
		<pubDate>Tue, 04 Dec 2007 20:26:12 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
		
		<category><![CDATA[OS]]></category>

		<category><![CDATA[Quick Tips]]></category>

		<category><![CDATA[apache]]></category>

		<category><![CDATA[linux]]></category>

		<category><![CDATA[programming]]></category>

		<category><![CDATA[servers]]></category>

		<guid isPermaLink="false">http://www.geekyboy.com/archives/46</guid>
		<description><![CDATA[When troubleshooting a problem in Apache it is a pain to open the log file, find an error, close the log file, and then open it again after you perform some action.  This is why &#8216;tail&#8217; is so handy.
Simply use the command below to view the last 100 lines of a log file, and [...]]]></description>
			<content:encoded><![CDATA[<p>When troubleshooting a problem in Apache it is a pain to open the log file, find an error, close the log file, and then open it again after you perform some action.  This is why &#8216;tail&#8217; is so handy.</p>
<p>Simply use the command below to view the last 100 lines of a log file, and as new entries are added to the file they are automatically displayed on the screen.</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>the<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">file</span><span style="color: #000000; font-weight: bold;">/</span>name <span style="color: #660033;">-n</span> <span style="color: #660033;">-100</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.geekyboy.com/archives/46/feed</wfw:commentRss>
		</item>
		<item>
		<title>Plesk backup problem</title>
		<link>http://www.geekyboy.com/archives/45</link>
		<comments>http://www.geekyboy.com/archives/45#comments</comments>
		<pubDate>Tue, 27 Nov 2007 15:23:18 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
		
		<category><![CDATA[Plesk]]></category>

		<guid isPermaLink="false">http://www.geekyboy.com/archives/45</guid>
		<description><![CDATA[I had a problem backing up domains on a server and received the following error message:
Error: Unable to create backup session: Specified file is not accessible
Finally i solved this problem!!!! it was all about wrong permission in some folders!
check that the folders &#8216;/var/lib/psa/dumps&#8217; and &#8216;/var/lib/psa/dumps/tmp&#8217; are chmod to 777
]]></description>
			<content:encoded><![CDATA[<p>I had a problem backing up domains on a server and received the following error message:</p>
<p>Error: Unable to create backup session: Specified file is not accessible</p>
<p>Finally i solved this problem!!!! it was all about wrong permission in some folders!</p>
<p>check that the folders &#8216;/var/lib/psa/dumps&#8217; and &#8216;/var/lib/psa/dumps/tmp&#8217; are chmod to 777</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekyboy.com/archives/45/feed</wfw:commentRss>
		</item>
		<item>
		<title>Change/update time on Linux</title>
		<link>http://www.geekyboy.com/archives/44</link>
		<comments>http://www.geekyboy.com/archives/44#comments</comments>
		<pubDate>Fri, 09 Nov 2007 16:59:15 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
		
		<category><![CDATA[OS]]></category>

		<category><![CDATA[Quick Tips]]></category>

		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.geekyboy.com/archives/44</guid>
		<description><![CDATA[Sets whether the hardware clock is stored as UTC or local time.

/etc/sysconfig/clock

Symlink /etc/localtime to /usr/share/zoneinfo/&#8230; to set your timezone.
To set the current system date/time.

date MMDDhhmm

To set the hardware clock.

/sbin/hwclock --systohc

]]></description>
			<content:encoded><![CDATA[<p>Sets whether the hardware clock is stored as UTC or local time.</p>
<pre>
/etc/sysconfig/clock
</pre>
<p>Symlink /etc/localtime to /usr/share/zoneinfo/&#8230; to set your timezone.</p>
<p>To set the current system date/time.</p>
<pre>
date MMDDhhmm
</pre>
<p>To set the hardware clock.</p>
<pre>
/sbin/hwclock --systohc
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.geekyboy.com/archives/44/feed</wfw:commentRss>
		</item>
		<item>
		<title>Javascript disable right click and image tool bar</title>
		<link>http://www.geekyboy.com/archives/43</link>
		<comments>http://www.geekyboy.com/archives/43#comments</comments>
		<pubDate>Thu, 27 Sep 2007 00:44:04 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
		
		<category><![CDATA[Quick Tips]]></category>

		<category><![CDATA[apache]]></category>

		<category><![CDATA[css]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.geekyboy.com/archives/43</guid>
		<description><![CDATA[A recent request from a client was to make life more difficult for his competitors to steal images from his site.  He was worried that they could save the images using the Image Toolbar in newer versions of Internet Explorer, and by using the right click menu on the page.  For those of [...]]]></description>
			<content:encoded><![CDATA[<p>A recent request from a client was to make life more difficult for his competitors to steal images from his site.  He was worried that they could save the images using the Image Toolbar in newer versions of Internet Explorer, and by using the right click menu on the page.  For those of you that wish to stop the right clickers from stealing your code, or from stealing images, here is a quick and easy way to make life more difficult for them.</p>
<p>To disable the Internet Explorer Image Toolbar for an entire page add this meta tag:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;meta http-equiv=&quot;imagetoolbar&quot; content=&quot;no&quot;&gt;</pre></div></div>

<p>To disable the Internet Explorer Image Toolbar for an individual Image do this:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;img src=&quot;image.gif&quot; width=&quot;250&quot; height=&quot;250&quot; galleryimg=&quot;no&gt;</pre></div></div>

<p>Now to handle those who love their &#8220;right-click&#8221;.  For the entire page:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;body oncontextmenu=&quot;return false&quot;&gt;</pre></div></div>

<p>And for individual images:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;img src=&quot;image.gif&quot; width=&quot;250&quot; height=&quot;250&quot; oncontextmenu=&quot;return false&quot;&gt;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.geekyboy.com/archives/43/feed</wfw:commentRss>
		</item>
		<item>
		<title>CSS style sheet switcher using Prototype</title>
		<link>http://www.geekyboy.com/archives/39</link>
		<comments>http://www.geekyboy.com/archives/39#comments</comments>
		<pubDate>Tue, 25 Sep 2007 20:09:31 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
		
		<category><![CDATA[Quick Tips]]></category>

		<category><![CDATA[css]]></category>

		<category><![CDATA[html]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[php]]></category>

		<category><![CDATA[programming]]></category>

		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://www.geekyboy.com/archives/39</guid>
		<description><![CDATA[A recent project had a requirementfor a style switcher allowing a visitor to control font size on the site as needed. (Many do not know how to change it through a browser, and most sites are not designed to allow for font size changes without completely trashing presentation.)
Because the project in question was a dynamic [...]]]></description>
			<content:encoded><![CDATA[<p>A recent project had a requirementfor a style switcher allowing a visitor to control font size on the site as needed. (Many do not know how to change it through a browser, and most sites are not designed to allow for font size changes without completely trashing presentation.)</p>
<p>Because the project in question was a dynamic site I wanted to make a style sheet switcher that didn&#8217;t force a page reload and it seemed like most examples on the net required a page to reload with a new stylesheet. (After PHP or some other scripting language decided which css sheet to render the page with.)  This meant additional calls to the server to repopulate data grids and other info, after re-running a query and parsing in PHP.  To me this was truly unacceptable load on a server to simply change font sizes on a page.</p>
<p><span id="more-39"></span><br />
I found one example that looked attractive to me, so my solution was driven from what I found at <a href="http://www.fastfwd.be/journal/28/Prototype_CSS_stylesheet_switcher" target="_blank">http://www.fastfwd.be/journal/28/Prototype_CSS_stylesheet_switcher</a>.  However this example switched between two styles, and I wanted a small - medium - large switch.</p>
<p>You can view my sample <a href="http://www.geekyboy.com/style_switcher/" target="_blank">HERE</a>.</p>
<p>So, here we go:<br />
<strong>First,</strong> I started by defining my style sheets:</p>

<div class="wp_syntax"><div class="code"><pre class="css css" style="font-family:monospace;">site.css
&nbsp;
body<span style="color: #00AA00;">,</span>html <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> 0;
    <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> Verdana<span style="color: #00AA00;">,</span> Arial<span style="color: #00AA00;">,</span> Helvetica<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span>;
    <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;"><span style="color: #cc66cc;">100</span>%</span>;
    <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#000</span>;
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.header</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;"><span style="color: #cc66cc;">120</span>%</span>;
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#head</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">600px</span>;
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">120px</span>;
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">15px</span>;
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* Page Structure */</span>
<span style="color: #cc00cc;">#styleSwitcher</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">right</span>;
	<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">absolute</span>;
	<span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">50px</span>;
	<span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">300px</span>;
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">33px</span>;
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">60px</span>;
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">images/style_switcher_small.gif</span><span style="color: #00AA00;">&#41;</span>; <span style="color: #808080; font-style: italic;">/* I also created a medium and large */</span>
	<span style="color: #000000; font-weight: bold;">background-repeat</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">no-repeat</span>;
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#styleSwitcher</span> a <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span>;
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span>;
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">16px</span>;
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">30px</span>;
	<span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span>;
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Now make two copies of this sheet, but change the font-size in the body,html portion of the sheet to be 90% and rename the background image for styleSwitcher to &#8216;medium&#8217; in one (site_minux_10.css) and 110% and rename the background image for styleSwitcher to &#8216;large&#8217; in the other (site_plus_10.css).  I put all three style sheets in a directory appropriately named &#8217;styles&#8217;.</p>
<p><strong>Second,</strong> I created an image that displayed the sizes in a meaningful way for the selector.  I actually made three of them, so the style sheets would change it depending on which style sheet was selected.</p>
<p><img src="http://www.geekyboy.com/wp-content/uploads/2007/09/style_switcher_small.gif" alt="CSS Selector Small" title="CSS Selector Small" /><br />
<img src="http://www.geekyboy.com/wp-content/uploads/2007/09/style_switcher_medium.gif" alt="CSS Selector Medium" title="CSS Selector Medium" /><br />
<img src="http://www.geekyboy.com/wp-content/uploads/2007/09/style_switcher_large.gif" alt="CSS Selector Large" title="CSS Selector Large" /></p>
<p>I put these images into a directory named &#8216;images&#8217;.</p>
<p><strong>Third,</strong> let&#8217;s get all of our magical Javascript ready for it&#8217;s task.  We will need the Prototype framework, and a small bit of our own magic that uses it.  You can download the newest version of Prototype <a href="http://www.prototypejs.org/download" target="_blank">HERE</a>. <em>(Please note that we are going to be using evalJSON(), so this means we need at least version 1.5.1 of the framework.)<br />
</em></p>
<p>Now we will put together own own script file:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;">main.<span style="color: #660066;">js</span>
&nbsp;
Event.<span style="color: #660066;">observe</span><span style="color: #009900;">&#40;</span>window<span style="color: #339933;">,</span> <span style="color: #3366CC;">'load'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> valueElement <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;rel&quot;</span>;
	<span style="color: #003366; font-weight: bold;">var</span> browserName <span style="color: #339933;">=</span> navigator.<span style="color: #660066;">appName</span>;
&nbsp;
	<span style="color: #006600; font-style: italic;">// define where the active style sheet needs to be changed</span>
	<span style="color: #003366; font-weight: bold;">var</span> styleObj <span style="color: #339933;">=</span> $$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'head link[type=text/css][rel=stylesheet]'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span>;
&nbsp;
	<span style="color: #006600; font-style: italic;">// create array of the links with class loadStyle</span>
	$$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a.loadStyle'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">// create observers for each link</span>
		Event.<span style="color: #660066;">observe</span><span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> <span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #006600; font-style: italic;">// when a click happens and the rel element has a value</span>
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>a.<span style="color: #660066;">hasAttribute</span><span style="color: #009900;">&#40;</span>valueElement<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #006600; font-style: italic;">// create a JSON string out of the rel value for use</span>
				<span style="color: #003366; font-weight: bold;">var</span> valueObj <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> String<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'{'</span><span style="color: #339933;">+</span> a.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span>valueElement<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span><span style="color: #3366CC;">'}'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/(\\[|\\])/g</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'&quot;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">evalJSON</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
&nbsp;
				<span style="color: #006600; font-style: italic;">// catch possible problem</span>
				<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> valueObj.<span style="color: #660066;">sheet</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'undefined'</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Sorry, no stylesheet defined'</span><span style="color: #009900;">&#41;</span>; <span style="color: #003366; font-weight: bold;">false</span>;
&nbsp;
				<span style="color: #006600; font-style: italic;">// if no problem, change the style sheet</span>
				<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> styleObj <span style="color: #339933;">!==</span> <span style="color: #3366CC;">&quot;undefined&quot;</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>browserName <span style="color: #339933;">==</span> <span style="color: #3366CC;">'Microsoft Internet Explorer'</span><span style="color: #009900;">&#41;</span>
					<span style="color: #009900;">&#123;</span>
						document.<span style="color: #660066;">styleSheets</span><span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">href</span> <span style="color: #339933;">=</span> valueObj.<span style="color: #660066;">sheet</span>;
					<span style="color: #009900;">&#125;</span>
					<span style="color: #000066; font-weight: bold;">else</span>
					<span style="color: #009900;">&#123;</span>			
						styleObj.<span style="color: #660066;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #339933;">,</span> valueObj.<span style="color: #660066;">sheet</span><span style="color: #009900;">&#41;</span>;
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'switchStyle: stylesheet definition not found on this page'</span><span style="color: #009900;">&#41;</span>; <span style="color: #003366; font-weight: bold;">false</span>;
			<span style="color: #009900;">&#125;</span>
			Event.<span style="color: #000066;">stop</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span>;
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>;
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

<p>I put both the Prototype and this file in a directory appropriately named &#8216;js&#8217;.</p>
<p><strong>Fourth,</strong> we now are ready for the HTML that you can get from the download file or from the sample <a href="http://www.geekyboy.com/style_switcher/" target="_blank">HERE</a>.</p>
<p>Please note that in the HTML we are not defining all three stylesheets.  I found that Internet Explorer did not like switching between the three stylesheets when they are all defined in the HTML, while Firefox happily accepted it.  This causes a slight blip on the screen when switching to a style initially, but due to cache you do not need to load the same sheet twice.</p>
<p>Of course this will go into the root of the public_html.</p>
<p><strong>Fifth,</strong> now that we have the switcher in place working fine wouldn&#8217;t it be nice if the site remembered what size the visitor selected?  Of course it would!  So here is how I implemented Cookies to remember:</p>
<p>In the main.js file I added a few small lines of code to our existing javascript, and added two functions borrowed from <a href="http://www.quirksmode.org/js/cookies.html" target="_blank">http://www.quirksmode.org/js/cookies.html</a> for the actual cookie handling:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;">main.<span style="color: #660066;">js</span> <span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> and improved <span style="color: #000066; font-weight: bold;">with</span> cookies<span style="color: #009900;">&#41;</span>
&nbsp;
Event.<span style="color: #660066;">observe</span><span style="color: #009900;">&#40;</span>window<span style="color: #339933;">,</span> <span style="color: #3366CC;">'load'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> valueElement <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;rel&quot;</span>;
	<span style="color: #003366; font-weight: bold;">var</span> cookieName <span style="color: #339933;">=</span> <span style="color: #3366CC;">'geekyStyles'</span>;
	<span style="color: #003366; font-weight: bold;">var</span> browserName <span style="color: #339933;">=</span> navigator.<span style="color: #660066;">appName</span>;
&nbsp;
	<span style="color: #006600; font-style: italic;">// define where the active style sheet needs to be changed</span>
	<span style="color: #003366; font-weight: bold;">var</span> styleObj <span style="color: #339933;">=</span> $$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'head link[type=text/css][rel=stylesheet]'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span>;
&nbsp;
	<span style="color: #006600; font-style: italic;">// create array of the links with class loadStyle</span>
	$$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a.loadStyle'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// base current style based on previous visit from cookie</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>readCookie<span style="color: #009900;">&#40;</span>cookieName<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> pastStyle <span style="color: #339933;">=</span> readCookie<span style="color: #009900;">&#40;</span>cookieName<span style="color: #009900;">&#41;</span>;
&nbsp;
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>browserName <span style="color: #339933;">==</span> <span style="color: #3366CC;">'Microsoft Internet Explorer'</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				document.<span style="color: #660066;">styleSheets</span><span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">href</span> <span style="color: #339933;">=</span> pastStyle;
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000066; font-weight: bold;">else</span>
			<span style="color: #009900;">&#123;</span>			
				styleObj.<span style="color: #660066;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #339933;">,</span> pastStyle<span style="color: #009900;">&#41;</span>;
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// create observers for each link</span>
		Event.<span style="color: #660066;">observe</span><span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> <span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #006600; font-style: italic;">// when a click happens and the rel element has a value</span>
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>a.<span style="color: #660066;">hasAttribute</span><span style="color: #009900;">&#40;</span>valueElement<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #006600; font-style: italic;">// create a JSON string out of the rel value for use</span>
				<span style="color: #003366; font-weight: bold;">var</span> valueObj <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> String<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'{'</span><span style="color: #339933;">+</span> a.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span>valueElement<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span><span style="color: #3366CC;">'}'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/(\\[|\\])/g</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'&quot;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">evalJSON</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
&nbsp;
				<span style="color: #006600; font-style: italic;">// catch possible problem</span>
				<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> valueObj.<span style="color: #660066;">sheet</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'undefined'</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Sorry, no stylesheet defined'</span><span style="color: #009900;">&#41;</span>; <span style="color: #003366; font-weight: bold;">false</span>;
&nbsp;
				<span style="color: #006600; font-style: italic;">// if no problem, change the style sheet</span>
				<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> styleObj <span style="color: #339933;">!==</span> <span style="color: #3366CC;">&quot;undefined&quot;</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>browserName <span style="color: #339933;">==</span> <span style="color: #3366CC;">'Microsoft Internet Explorer'</span><span style="color: #009900;">&#41;</span>
					<span style="color: #009900;">&#123;</span>
						document.<span style="color: #660066;">styleSheets</span><span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">href</span> <span style="color: #339933;">=</span> valueObj.<span style="color: #660066;">sheet</span>;
					<span style="color: #009900;">&#125;</span>
					<span style="color: #000066; font-weight: bold;">else</span>
					<span style="color: #009900;">&#123;</span>			
						styleObj.<span style="color: #660066;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #339933;">,</span> valueObj.<span style="color: #660066;">sheet</span><span style="color: #009900;">&#41;</span>;
					<span style="color: #009900;">&#125;</span>
&nbsp;
					<span style="color: #006600; font-style: italic;">// set a 30 day cookie to remember the latest selection</span>
					createCookie<span style="color: #009900;">&#40;</span>cookieName<span style="color: #339933;">,</span> valueObj.<span style="color: #660066;">sheet</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">30</span><span style="color: #009900;">&#41;</span>;
				<span style="color: #009900;">&#125;</span>
				<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'switchStyle: stylesheet definition not found on this page'</span><span style="color: #009900;">&#41;</span>; <span style="color: #003366; font-weight: bold;">false</span>;
			<span style="color: #009900;">&#125;</span>
			Event.<span style="color: #000066;">stop</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span>;
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>;
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #006600; font-style: italic;">// cookie functions by http://www.quirksmode.org/js/cookies.html</span>
<span style="color: #003366; font-weight: bold;">function</span> createCookie<span style="color: #009900;">&#40;</span><span style="color: #000066;">name</span><span style="color: #339933;">,</span>value<span style="color: #339933;">,</span>days<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>days<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> date <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
		date.<span style="color: #660066;">setTime</span><span style="color: #009900;">&#40;</span>date.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span>days<span style="color: #339933;">*</span><span style="color: #CC0000;">24</span><span style="color: #339933;">*</span><span style="color: #CC0000;">60</span><span style="color: #339933;">*</span><span style="color: #CC0000;">60</span><span style="color: #339933;">*</span><span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
		<span style="color: #003366; font-weight: bold;">var</span> expires <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;; expires=&quot;</span><span style="color: #339933;">+</span>date.<span style="color: #660066;">toGMTString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #003366; font-weight: bold;">var</span> expires <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span>;
	document.<span style="color: #660066;">cookie</span> <span style="color: #339933;">=</span> <span style="color: #000066;">name</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;=&quot;</span><span style="color: #339933;">+</span>value<span style="color: #339933;">+</span>expires<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;; path=/&quot;</span>;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> readCookie<span style="color: #009900;">&#40;</span><span style="color: #000066;">name</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> nameEQ <span style="color: #339933;">=</span> <span style="color: #000066;">name</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;=&quot;</span>;
	<span style="color: #003366; font-weight: bold;">var</span> ca <span style="color: #339933;">=</span> document.<span style="color: #660066;">cookie</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">';'</span><span style="color: #009900;">&#41;</span>;
	<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span>0;i <span style="color: #339933;">&lt;</span> ca.<span style="color: #660066;">length</span>;i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> c <span style="color: #339933;">=</span> ca<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>;
		<span style="color: #000066; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>c.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span>0<span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #3366CC;">' '</span><span style="color: #009900;">&#41;</span> c <span style="color: #339933;">=</span> c.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span>c.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span>;
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>c.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span>nameEQ<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> 0<span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> c.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span>nameEQ.<span style="color: #660066;">length</span><span style="color: #339933;">,</span>c.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span>;
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">null</span>;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Viola!  A completed Style Switcher using CSS, Prototype, HTML, and dabble of DOM.</p>
<p>To download all of the files for this, you can get them <a href="http://www.geekyboy.com/style_switcher/style_switcher.tar.gz" target="_blank">HERE</a>.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekyboy.com/archives/39/feed</wfw:commentRss>
		</item>
		<item>
		<title>PHP failing to upload images on a Plesk managed server</title>
		<link>http://www.geekyboy.com/archives/38</link>
		<comments>http://www.geekyboy.com/archives/38#comments</comments>
		<pubDate>Fri, 14 Sep 2007 18:42:35 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
		
		<category><![CDATA[OS]]></category>

		<category><![CDATA[Plesk]]></category>

		<category><![CDATA[Quick Tips]]></category>

		<category><![CDATA[apache]]></category>

		<category><![CDATA[linux]]></category>

		<category><![CDATA[php]]></category>

		<category><![CDATA[programming]]></category>

		<category><![CDATA[servers]]></category>

		<guid isPermaLink="false">http://www.geekyboy.com/archives/38</guid>
		<description><![CDATA[I recently upgraded a few of my Linux servers from Plesk 7.5 to 8.2.  Everything seemed to be fine, however calls started coming in about PHP forms not uploading images correctly.
My team and I were troubleshooting this problem for a few days trying to narrow down the problem.  We looked at folder permissions, [...]]]></description>
			<content:encoded><![CDATA[<p>I recently upgraded a few of my Linux servers from Plesk 7.5 to 8.2.  Everything seemed to be fine, however calls started coming in about PHP forms not uploading images correctly.</p>
<p>My team and I were troubleshooting this problem for a few days trying to narrow down the problem.  We looked at folder permissions, script permissions, database connectivity, and almost anything else we could think of.  Then we stumbled across the error message given by PHP (who would have thought to look at the error message?) that said function move_uploaded_file will not work in safe_mode.</p>
<p>Now looking at the PHP info the main php.ini was set with safe_mode off.  However, I found that the httpd.conf for the individual domains on a Plesk managed server carries a declaration for PHP safe_mode, and it was turned on.  Upon further investigation I found that in the Plesk interface for the domain there is a checkbox beside the PHP setting that allows safe_mode to be turned on and off.</p>
<p>Mission accomplished!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekyboy.com/archives/38/feed</wfw:commentRss>
		</item>
		<item>
		<title>Adding mssql capability to PHP5 on CentOS</title>
		<link>http://www.geekyboy.com/archives/37</link>
		<comments>http://www.geekyboy.com/archives/37#comments</comments>
		<pubDate>Thu, 06 Sep 2007 18:42:23 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
		
		<category><![CDATA[Databases]]></category>

		<category><![CDATA[MSSQL]]></category>

		<category><![CDATA[OS]]></category>

		<category><![CDATA[Quick Tips]]></category>

		<category><![CDATA[apache]]></category>

		<category><![CDATA[linux]]></category>

		<category><![CDATA[php]]></category>

		<category><![CDATA[programming]]></category>

		<category><![CDATA[servers]]></category>

		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://www.geekyboy.com/archives/37</guid>
		<description><![CDATA[I had a need to connect to MSSQL using PHP version 5 from a CentOS 5 server.  To do this I needed FreeTDS and the module mssql in PHP.  After a diligent search I found that there was no quick and easy way to install the mssql module, like &#8220;up2date install php-gd&#8221; to [...]]]></description>
			<content:encoded><![CDATA[<p>I had a need to connect to MSSQL using PHP version 5 from a CentOS 5 server.  To do this I needed FreeTDS and the module mssql in PHP.  After a diligent search I found that there was no quick and easy way to install the mssql module, like &#8220;up2date install php-gd&#8221; to get GD to work from PHP.</p>
<p>I found a few places that had ideas and hints to make this work, but finally used the directions I found at <a href="http://www.howtoforge.com/installing_php_mssql_centos5.0" target="_blank">http://www.howtoforge.com/installing_php_mssql_centos5.0</a> (slightly altered to fit my means) and will duplicate here so I can easily find it later.</p>
<p>At first I thought I needed to recompile PHP, but as it turned out I only needed to pre-compile it so that I could fetch the mssql.so, and then manually edit the php.ini to use it.</p>
<p><span id="more-37"></span><br />
NOTE-1: You should be running as SuperUser or using sudo to perform these tasks.<br />
NOTE-2: RPMForge was installed and running on my system, so I didn&#8217;t need to do the next couple of steps.</p>
<p>1. First you need to activate the RPMForge custom repository (formely known as Dag Wieers):<br />
<a href="http://dag.wieers.com/rpm/packages/rpmforge-release/" target="_blank">http://dag.wieers.com/rpm/packages/rpmforge-release/</a></p>
<p>2. Grab your specific RPM and install it:</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>dag.wieers.com<span style="color: #000000; font-weight: bold;">/</span>rpm<span style="color: #000000; font-weight: bold;">/</span>packages<span style="color: #000000; font-weight: bold;">/</span>rpmforge-release<span style="color: #000000; font-weight: bold;">/</span>rpmforge-release-<span style="color: #000000; font-weight: bold;">*</span>.rpm
rpm <span style="color: #660033;">--install</span> rpmforge-release-<span style="color: #000000; font-weight: bold;">*</span>.rpm</pre></div></div>

<p>3. Next step is to install freetds, freetds-devel, php-devel, and the Development tools.</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;">yum groupinstall ‘Development Tools’
&nbsp;
yum <span style="color: #c20cb9; font-weight: bold;">install</span> freetds freetds-devel --<span style="color: #007800;">enablerepo</span>=rpmforge
yum <span style="color: #c20cb9; font-weight: bold;">install</span> php-devel</pre></div></div>

<p>4. Next we alter the php.spec file, which contains the php configuration for compiling.</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>redhat<span style="color: #000000; font-weight: bold;">/</span>SPECS<span style="color: #000000; font-weight: bold;">/</span>php.spec</pre></div></div>

<p>5. If you don&#8217;t have the php.spec file, you can download the php src rpm.</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> centos.mirrors.skynet.be<span style="color: #000000; font-weight: bold;">/</span>pub<span style="color: #000000; font-weight: bold;">/</span>centos<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">/</span>os<span style="color: #000000; font-weight: bold;">/</span>SRPMS<span style="color: #000000; font-weight: bold;">/</span>php-5.1.6-5.el5.src.rpm
&nbsp;
rpm –<span style="color: #c20cb9; font-weight: bold;">install</span> php-5.1.6-5.el5.src.rpm</pre></div></div>

<p>6. And then do an updatedb and locate php.spec.</p>
<p>7. Edit the CFLAGS= line (~line 363) of the php.spec file - remove &#8220;-Wno-pointer-sign&#8221;.<br />
Then add the following piece of code to it:</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;">Group: Development<span style="color: #000000; font-weight: bold;">/</span>Languages
Requires: php = <span style="color: #000000; font-weight: bold;">%</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>version<span style="color: #7a0874; font-weight: bold;">&#125;</span>-<span style="color: #000000; font-weight: bold;">%</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>release<span style="color: #7a0874; font-weight: bold;">&#125;</span>, php-pdo
Summary: A module <span style="color: #000000; font-weight: bold;">for</span> PHP applications that use the MSSQL database.
provides: php_database
BuildRequires: freetds-devel
&nbsp;
<span style="color: #000000; font-weight: bold;">%</span>description mssql
The MSSQL package contains a dynamic shared object that will add
support <span style="color: #000000; font-weight: bold;">for</span> accessing MSSQL databases to php.</pre></div></div>

<p>8. Start building your php rpm:</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;">rpmbuild <span style="color: #660033;">-bb</span> .<span style="color: #000000; font-weight: bold;">/</span>php.spec</pre></div></div>

<p>NOTE: If you are asked for some dependencies, just yum install them.  I was asked for the following list of dependencies:<br />
bzip2-devel, curl-devel, db4-devel, expat-devel, gmp-devel, aspell-devel, httpd-devel, libjpeg-devel, libpng-devel, pam-devel, openssl-devel, sqlite-devel, zlib-devel, pcre-devel, krb5-devel, libc-client-devel, cyrus-sasl-devel, openldap-devel, mysql-devel, postgresql-devel, unixODBC-devel, libxml2-devel, net-snmp-devel, libxslt-devel, libxml2-devel, ncurses-devel, gd-devel, freetype-devel, freetds-devel</p>
<p>9. Now you need to go to the place where the build is kept.</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>redhat<span style="color: #000000; font-weight: bold;">/</span>BUILD<span style="color: #000000; font-weight: bold;">/</span>php-5.1.6<span style="color: #000000; font-weight: bold;">/</span>ext<span style="color: #000000; font-weight: bold;">/</span>mssql<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>10. Now we are going to make the mssql module without having to rewrite the php binary: (This takes a few minutes, relax.)</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;">phpize
.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--with-mssql</span>
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>11. Next look for the mssql.so file to make sure it is in the module directory &#8220;/usr/lib/php/modules/&#8221;, and specified in your php.ini. Or copy it to the specified location if needed.</p>
<p>12. Final Steps</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php.ini</pre></div></div>

<p>13. Add the following to the php.ini</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;"><span style="color: #007800;">extension</span>=mssql.so</pre></div></div>

<p>14. Save the php.ini using &#8220;:w!&#8221; or &#8220;Ctrl+ZZ&#8221; and restart Apache:</p>

<div class="wp_syntax"><div class="code"><pre class="bash bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>httpd restart</pre></div></div>

<p>All should work now.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.geekyboy.com/archives/37/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
