<?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>super-cooper &#187; php</title>
	<atom:link href="http://www.super-cooper.com/archive/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.super-cooper.com</link>
	<description>Python, GIS, and a sprinkling of mindless drivel from Chad Cooper</description>
	<lastBuildDate>Wed, 08 Dec 2010 02:12:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>WordPress plugin: Conversation Viewer</title>
		<link>http://www.super-cooper.com/archive/2005/05/26/wordpress-plugin-conversation-viewer/</link>
		<comments>http://www.super-cooper.com/archive/2005/05/26/wordpress-plugin-conversation-viewer/#comments</comments>
		<pubDate>Thu, 26 May 2005 12:14:34 +0000</pubDate>
		<dc:creator>Chad</dc:creator>
				<category><![CDATA[site]]></category>
		<category><![CDATA[conversation]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://super-cooper.com/?p=93</guid>
		<description><![CDATA[First off, I have to say that I can really only take credit for about 10% of the code in this plugin, if that. I really can&#8217;t even take credit for the idea. And let me also come out and say that I am in no way any sort of PHP genius. I&#8217;m sure there [...]]]></description>
			<content:encoded><![CDATA[<p>First off, I have to say that I can really only take credit for about 10% of the code in this plugin, if that. I really can&#8217;t even take credit for the idea. And let me also come out and say that I am in no way any sort of PHP genius. I&#8217;m sure there are things that could be done better in this plugin, but this works for me. So, with all that out of the way, the idea for this came from <a href="http://www.1976design.com/blog/archive/2004/07/29/redesign-tag-transform/" title="Dunstan's idea for inserting conversations using XML">Dunstan</a>, and the majority of the code came from <a href="http://elasticdog.com/" title="Elastic Dog">Aaron Schaefer&#8217;s</a> <a href="http://elasticdog.com/2004/09/code-viewer/" title="Code Viewer plugin">Code Viewer</a> plugin.<br />
<span id="more-41"></span></p>
<h2>What is it, and why?</h2>
<p>Conversation Viewer is a WordPress <del>1.2</del> 2.5 plugin that pulls a external text file into a post and formats it into a defined list, keeping you from having to manually code the conversation into a defined list, ordered list, or Heaven forbid, a ghastly table. I wanted to be able to easily and quickly include conversations into posts, while still keeping the code nice and clean. <a href="http://www.super-cooper.com/archive/2004/10/12/retro-dude-thats-tom-sizemore/">I tried this manually once with a table</a>, and while the result looked good, the code was rather sloppy and <em>very</em> cumbersome to compose.</p>
<h2>How it works</h2>
<p>Basically, you tell the plugin the path to your conversation text files, and to insert a conversation, you simply call the text file(s) containing the conversation(s), and it (they) will appear in the post. You can call as many different conversations in one post as you want, just name them uniquely. The nitty gritty of how the plugin works is commented in the plugin code.</p>
<h2>Usage</h2>
<p>You need three things to get this up and running: the plugin, a text file of a conversation (with proper syntax), and some CSS for styling. <a href="http://www.super-cooper.com/snippets/conv-viewer/conv-viewer.txt">Get the plugin here.</a> Change <code>$default_conv_path</code> to the absolute path of the directory you plan on storing your text files of conversations (mine is something like <code>http://www.super-cooper.com/conversations/</code>), then slap it into your plugins folder and activate it. Next, construct your conversation file, which should look something like this:</p>
<link rel="stylesheet" href="http://www.super-cooper.com/wp-content/plugins/codeviewer.css" type="text/css" media="all" />
<ol class="codelist">
<li value="1" class="tab0 odd"><code>Me,Why did the chicken cross the road?</code></li>
<li value="2" class="tab0 even"><code>The Wife,Why?.</code></li>
<li value="3" class="tab0 odd"><code>Me,To get to the other side.</code></li>
<li value="4" class="tab0 even"><code>The Wife,You're crazy.</code></li>
<li class="sourcelink"><strong>Download this code:</strong> <a href="http://www.super-cooper.com/snippets/conv-viewer/conversation-viewer-example-1.txt">conversation-viewer-example-1.txt</a></li>
</ol>
<p>Now let&#8217;s break this down. This is a conversation between the Wife and I where I am showing off my joke-telling prowess, and she is obviously <em>very</em> impressed. There a basically two parts to the conversation: who&#8217;s talking and what they are saying, which are separated by a comma. The plugin looks for the occurence of the first comma, assumes everything to the left of it is the person, and everything to the right of it is what that person is saying. Call the text file in your post like so:</p>
<p><code>&lt;conversation src="http://www.super-cooper.com/snippets/conversation-viewer-example-1.txt" /&gt;</code></p>
<p>I like to arrange mine in subdirectories by date, and if you have more than one to include in a post, just add the numbers on the end and call them accordingly. Note that this path is relative, you set the root of this path in <code>$default_conv_path</code> in the plugin earlier. The above text conversation, parsed through the browser,  would look like so with the plugin and my CSS:</p>
<dl class="conversation">
<dt>Me:</dt>
<dd>Why did the chicken cross the road?</dd>
<dt>The Wife:</dt>
<dd>Why?.</dd>
<dt>Me:</dt>
<dd>To get to the other side.</dd>
<dt>The Wife:</dt>
<dd>You&#8217;re crazy.</dd>
</dl>
<p>And the code that produced it would look like so:</p>
<link rel="stylesheet" href="http://www.super-cooper.com/wp-content/plugins/codeviewer.css" type="text/css" media="all" />
<ol class="codelist">
<li value="1" class="tab0 odd"><code>&lt;dl class=&quot;conversation&quot;&gt;</code></li>
<li value="2" class="tab0 even"><code>&lt;dt&gt;Me:&lt;/dt&gt;</code></li>
<li value="3" class="tab0 odd"><code>&lt;dd&gt;Why did the chicken cross the road?&lt;/dd&gt;</code></li>
<li value="4" class="tab0 even"><code>&lt;dt&gt;The Wife:&lt;/dt&gt;</code></li>
<li value="5" class="tab0 odd"><code>&lt;dd&gt;Why?.&lt;/dd&gt;</code></li>
<li value="6" class="tab0 even"><code>&lt;dt&gt;Me:&lt;/dt&gt;</code></li>
<li value="7" class="tab0 odd"><code>&lt;dd&gt;To get to the other side.&lt;/dd&gt;</code></li>
<li value="8" class="tab0 even"><code>&lt;dt&gt;The Wife:&lt;/dt&gt;</code></li>
<li value="9" class="tab0 odd"><code>&lt;dd&gt;You&amp;#8217;re crazy.&lt;/dd&gt;</code></li>
<li value="10" class="tab0 even"><code>&lt;/dl&gt;</code></li>
</ol>
<p>The definition term is the person&#8217;s name, and what they said is the definition.</p>
<h2>Mixing it up</h2>
<p>Let&#8217;s say you want to emphasize what someone is saying. I like to do this with italics. Well, to style what the person is saying in italics, simply add a pound sign (&#35;) <em>before</em> the person&#8217;s name, like so:</p>
<link rel="stylesheet" href="http://www.super-cooper.com/wp-content/plugins/codeviewer.css" type="text/css" media="all" />
<ol class="codelist">
<li value="1" class="tab0 odd"><code>The Son,I'm having a horndog for dinner.</code></li>
<li value="2" class="tab0 even"><code>#Me,Really?</code></li>
<li value="3" class="tab0 odd"><code>The Son,U-huh.</code></li>
<li value="4" class="tab0 even"><code>Me,Don't you mean a corndog?</code></li>
<li value="5" class="tab0 odd"><code>The Son,That's what I said, a corndog.</code></li>
</ol>
<p>Which, when called through the plugin and parsed, would look like this:</p>
<dl class="conversation">
<dt>The Son:</dt>
<dd>I&#8217;m having a horndog for dinner.</dd>
<dt>Me:</dt>
<dd class="emphasis">Really?</dd>
<dt>The Son:</dt>
<dd>U-huh.</dd>
<dt>Me:</dt>
<dd>Don&#8217;t you mean a corndog?</dd>
<dt>The Son:</dt>
<dd>That&#8217;s what I said, a corndog.</dd>
</dl>
<p>And the code that produced it would look like this:</p>
<link rel="stylesheet" href="http://www.super-cooper.com/wp-content/plugins/codeviewer.css" type="text/css" media="all" />
<ol class="codelist">
<li value="1" class="tab0 odd"><code>&lt;dl class=&quot;conversation&quot;&gt;</code></li>
<li value="2" class="tab0 even"><code>&lt;dt&gt;The Son:&lt;/dt&gt;</code></li>
<li value="3" class="tab0 odd"><code>&lt;dd&gt;I&amp;#8217;m having a horndog for dinner.&lt;/dd&gt;</code></li>
<li value="4" class="tab0 even"><code>&lt;dt&gt;Me:&lt;/dt&gt;</code></li>
<li value="5" class="tab0 odd"><code>&lt;dd class=&quot;emphasis&quot;&gt;Really?&lt;/dd&gt;</code></li>
<li value="6" class="tab0 even"><code>&lt;dt&gt;The Son:&lt;/dt&gt;</code></li>
<li value="7" class="tab0 odd"><code>&lt;dd&gt;U-huh.&lt;/dd&gt;</code></li>
<li value="8" class="tab0 even"><code>&lt;dt&gt;Me:&lt;/dt&gt;</code></li>
<li value="9" class="tab0 odd"><code>&lt;dd&gt;Don&amp;#8217;t you mean a corndog?&lt;/dd&gt;</code></li>
<li value="10" class="tab0 even"><code>&lt;dt&gt;The Son:&lt;/dt&gt;</code></li>
<li value="11" class="tab0 odd"><code>&lt;dd&gt;That&amp;#8217;s what I said, a corndog.&lt;/dd&gt;</code></li>
<li value="12" class="tab0 even"><code>&lt;/dl&gt;</code></li>
</ol>
<p>Finally, here&#8217;s my CSS that I use for styling my conversations:</p>
<link rel="stylesheet" href="http://www.super-cooper.com/wp-content/plugins/codeviewer.css" type="text/css" media="all" />
<ol class="codelist">
<li value="1" class="tab0 odd"><code>dl<span style="color: #6666ff;">.conversation</span> dt <span style="color: #66cc66;">&#123;</span></code></li>
<li value="2" class="tab1 even"><code>clear<span style="color: #3333ff;">:left</span><span style="color: #66cc66;">;</span></code></li>
<li value="3" class="tab1 odd"><code>float<span style="color: #3333ff;">:left</span><span style="color: #66cc66;">;</span></code></li>
<li value="4" class="tab1 even"><code>text-align<span style="color: #3333ff;">:right</span><span style="color: #66cc66;">;</span></code></li>
<li value="5" class="tab1 odd"><code>width<span style="color: #3333ff;">:<span style="color: #933;">9em</span></span><span style="color: #66cc66;">;</span></code></li>
<li value="6" class="tab1 even"><code>line-height<span style="color: #3333ff;">:<span style="color: #933;">1</span></span><span style="color: #6666ff;"><span style="color: #933;">.8em</span></span><span style="color: #66cc66;">;</span></code></li>
<li value="7" class="tab1 odd"><code>font-weight<span style="color: #3333ff;">:bold</span><span style="color: #66cc66;">;</span></code></li>
<li value="8" class="tab1 even"><code><span style="color: #66cc66;">&#125;</span></code></li>
<li value="9" class="tab0 odd"><code>dl<span style="color: #6666ff;">.conversation</span> dd <span style="color: #66cc66;">&#123;</span></code></li>
<li value="10" class="tab1 even"><code>margin<span style="color: #3333ff;">:<span style="color: #933;">0</span></span> <span style="color: #933;">7px</span> <span style="color: #933;">0</span> <span style="color: #933;">10em</span><span style="color: #66cc66;">;</span></code></li>
<li value="11" class="tab1 odd"><code>padding<span style="color: #3333ff;">:<span style="color: #933;">0</span></span><span style="color: #66cc66;">;</span></code></li>
<li value="12" class="tab1 even"><code>vertical-align<span style="color: #3333ff;">:top</span><span style="color: #66cc66;">;</span></code></li>
<li value="13" class="tab1 odd"><code>line-height<span style="color: #3333ff;">:<span style="color: #933;">1</span></span><span style="color: #6666ff;"><span style="color: #933;">.8em</span></span><span style="color: #66cc66;">;</span></code></li>
<li value="14" class="tab1 even"><code><span style="color: #66cc66;">&#125;</span></code></li>
<li value="15" class="tab0 odd"><code>dl dd<span style="color: #6666ff;">.emphasis</span> <span style="color: #66cc66;">&#123;</span></code></li>
<li value="16" class="tab1 even"><code>font-style<span style="color: #3333ff;">:italic</span><span style="color: #66cc66;">;</span></code></li>
<li value="17" class="tab1 odd"><code><span style="color: #66cc66;">&#125;</span></code></li>
<li class="sourcelink"><strong>Download this code:</strong> <a href="http://www.super-cooper.com/snippets/conv-viewer/conversation-viewer-example-css.txt">conversation-viewer-example-css.txt</a></li>
</ol>
<p>Some other examples of this plugin in use can be found <a href="http://super-cooper.com/2005/05/02/how-ya-doin/">here</a> and <a href="http://super-cooper.com/2005/03/13/retro-jack-theres-no-speed-limit-in-montana/"> here</a>.</p>
<h2>Other stuff</h2>
<p>This plugin was designed for WP 1.2 (yeah, I know I should migrate to 1.5, but I don&#8217;t have the time or desire to do so anytime soon), so I have no idea if it will work in 1.5. If it does or doesn&#8217;t, please let me know. <strong>EDIT: This works in 2.5 as of 2008-04-22. Also works on 2.7 as of 2009-01-02</strong> Any feedback is appreciated, but remember, most of the code I just hacked up from <a href="http://elasticdog.com/2004/09/code-viewer/" title="Code Viewer plugin">Code Viewer</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.super-cooper.com/archive/2005/05/26/wordpress-plugin-conversation-viewer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Converting latitude/longitude with PHP</title>
		<link>http://www.super-cooper.com/archive/2004/11/16/convert-lat-long-php/</link>
		<comments>http://www.super-cooper.com/archive/2004/11/16/convert-lat-long-php/#comments</comments>
		<pubDate>Tue, 16 Nov 2004 23:20:36 +0000</pubDate>
		<dc:creator>Chad</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://super-cooper.com/?p=61</guid>
		<description><![CDATA[Ok, so what I&#8217;m about to show you is hardly rocket science. It is however, the first chunk of math I&#8217;ve done with PHP that is more than 2 lines long. So I figured why not, I&#8217;ll post it. I was coding up a USGS gaging station finder and realized that I had latitude/longitude values [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, so what I&#8217;m about to show you is hardly rocket science. It is however, the first chunk of math I&#8217;ve done with PHP that is more than 2 lines long. So I figured why not, I&#8217;ll post it. I was coding up a USGS gaging station finder and realized that I had latitude/longitude values for the stations in decimal degrees (such as 32.872352&#176; latitude, -91.867904&#176; longitude), but couldn&#8217;t I convert these to degrees/minutes/seconds (such as 32&#176;   52&#8217; 20.47&#8221; latitude, 91&#176; 52&#8217; 4.45&#8221; longitude)? Surely I could figure this out.<br />
<span id="more-29"></span><br />
Surely. So this is how I did it. Now I do realize that much of the math could be combined to save on the quantity of calculations, but then it would just be even more confusing for me.</p>
<link rel="stylesheet" href="http://www.super-cooper.com/wp-content/plugins/codeviewer.css" type="text/css" media="all" />
<ol class="codelist">
<li value="1" class="tab0 odd"><code><span style="color: #000000; font-weight: bold;">&lt;?php</span></code></li>
<li value="2" class="tab0 even"><code><span style="color: #808080; font-style: italic;">// convert decimal degrees to degrees/minutes/seconds \\</span></code></li>
<li value="3" class="tab0 odd"><code><span style="color: #808080; font-style: italic;">// &nbsp;&nbsp; &nbsp; some definitions:</span></code></li>
<li value="4" class="tab0 even"><code><span style="color: #808080; font-style: italic;">// &nbsp;&nbsp; &nbsp; DD=decimal degrees</span></code></li>
<li value="5" class="tab0 odd"><code><span style="color: #808080; font-style: italic;">// &nbsp;&nbsp; &nbsp; DMS=degrees/minutes/seconds</span></code></li>
<li value="6" class="tab0 even"><code><span style="color: #808080; font-style: italic;">//</span></code></li>
<li value="7" class="tab0 odd"><code><span style="color: #808080; font-style: italic;">// How this works:</span></code></li>
<li value="8" class="tab0 even"><code><span style="color: #808080; font-style: italic;">// Say you have 32.872352 lat and -91.632563 long</span></code></li>
<li value="9" class="tab0 odd"><code><span style="color: #808080; font-style: italic;">// The whole units of the decimal will remain the same, so</span></code></li>
<li value="10" class="tab0 even"><code><span style="color: #808080; font-style: italic;">// 1) multiply the decimal by 60 (0.872352 * 60 = 52.34112), the whole number becomes the minutes (52)</span></code></li>
<li value="11" class="tab0 odd"><code><span style="color: #808080; font-style: italic;">// 2) take the remaining decimal (0.34112) and multiply by 60, this is now the seconds, round this to two decimal places (0.34221 * 60 = 20.53)</span></code></li>
<li value="12" class="tab0 even"><code><span style="color: #808080; font-style: italic;">// 3) string them all together 32 52 20.53</span></code></li>
<li value="13" class="tab0 odd"><code><span style="color: #808080; font-style: italic;">//</span></code></li>
<li value="14" class="tab1 even"><code><span style="color: #808080; font-style: italic;">// ** LATITUDE ** \\</span></code></li>
<li value="15" class="tab2 odd"><code><span style="color: #808080; font-style: italic;">// DEGREES \\</span></code></li>
<li value="16" class="tab3 even"><code><span style="color: #808080; font-style: italic;">// get integer value of latitude from db -&gt; where $lat_dd is a floating point number like 32.872352</span></code></li>
<li value="17" class="tab3 odd"><code><span style="color: #ff0000">$lat_dd_int</span> <span style="color: #66cc66;">=</span> <a href="http://www.php.net/intval"><span style="color: #000066;">intval</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;$lat_dd&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span></code></li>
<li value="18" class="tab2 even"><code><span style="color: #808080; font-style: italic;">// &nbsp;MINUTES \\</span></code></li>
<li value="19" class="tab3 odd"><code><span style="color: #808080; font-style: italic;">// &nbsp;get DD minutes (whats after the decimal point)-&gt; Lat DD floating point - lat DD integer</span></code></li>
<li value="20" class="tab3 even"><code><span style="color: #ff0000">$lat_dd_m</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000">$lat_dd</span> <span style="color: #66cc66;">-</span> <span style="color: #ff0000">$lat_dd_int</span><span style="color: #66cc66;">;</span></code></li>
<li value="21" class="tab3 odd"><code><span style="color: #808080; font-style: italic;">// get DMS minutes as floating point -&gt; 60 * DD minutes floating</span></code></li>
<li value="22" class="tab3 even"><code><span style="color: #ff0000">$lat_dms_m_float</span> <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">60</span> <span style="color: #66cc66;">*</span> <span style="color: #ff0000">$lat_dd_m</span><span style="color: #66cc66;">;</span></code></li>
<li value="23" class="tab3 odd"><code><span style="color: #808080; font-style: italic;">// get int value of lat DMS floating point</span></code></li>
<li value="24" class="tab3 even"><code><span style="color: #ff0000">$lat_dms_m_int</span> <span style="color: #66cc66;">=</span> <a href="http://www.php.net/intval"><span style="color: #000066;">intval</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;$lat_dms_m_float&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span></code></li>
<li value="25" class="tab2 odd"><code><span style="color: #808080; font-style: italic;">// SECONDS \\</span></code></li>
<li value="26" class="tab3 even"><code><span style="color: #808080; font-style: italic;">// get DD seconds -&gt; DMS minutes floating - DMS minutes integer</span></code></li>
<li value="27" class="tab3 odd"><code><span style="color: #ff0000">$lat_dd_s</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000">$lat_dms_m_float</span> <span style="color: #66cc66;">-</span> <span style="color: #ff0000">$lat_dms_m_int</span><span style="color: #66cc66;">;</span></code></li>
<li value="28" class="tab3 even"><code><span style="color: #808080; font-style: italic;">// convert DD secs to DMS secs -&gt; 60 * DD seconds</span></code></li>
<li value="29" class="tab3 odd"><code><span style="color: #ff0000">$lat_dms_s</span> <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">60</span> <span style="color: #66cc66;">*</span> <span style="color: #ff0000">$lat_dd_s</span><span style="color: #66cc66;">;</span></code></li>
<li value="30" class="tab1 even"><code><span style="color: #808080; font-style: italic;">// ** LONGITUDE ** \\</span></code></li>
<li value="31" class="tab2 odd"><code><span style="color: #808080; font-style: italic;">// DEGREES \\</span></code></li>
<li value="32" class="tab3 even"><code><span style="color: #808080; font-style: italic;">// get integer value of longitude from db -&gt; where $long_dd is a floating point number like -91.632563</span></code></li>
<li value="33" class="tab3 odd"><code><span style="color: #808080; font-style: italic;">// this number remains negative</span></code></li>
<li value="34" class="tab3 even"><code><span style="color: #ff0000">$long_dd_int</span> <span style="color: #66cc66;">=</span> <a href="http://www.php.net/intval"><span style="color: #000066;">intval</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;$long_dd&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span></code></li>
<li value="35" class="tab2 odd"><code><span style="color: #808080; font-style: italic;">// &nbsp;MINUTES \\</span></code></li>
<li value="36" class="tab3 even"><code><span style="color: #808080; font-style: italic;">// &nbsp;get DD minutes (whats after the decimal point)-&gt; Long DD floating point - long DD integer</span></code></li>
<li value="37" class="tab3 odd"><code><span style="color: #808080; font-style: italic;">// &nbsp;use abs to get rid of the negative sign</span></code></li>
<li value="38" class="tab3 even"><code><span style="color: #ff0000">$long_dd_m</span> <span style="color: #66cc66;">=</span> <a href="http://www.php.net/abs"><span style="color: #000066;">abs</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$long_dd</span> <span style="color: #66cc66;">-</span> <span style="color: #ff0000">$long_dd_int</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span></code></li>
<li value="39" class="tab3 odd"><code><span style="color: #808080; font-style: italic;">// get DMS minutes as floating point -&gt; 60 * DD minutes floating</span></code></li>
<li value="40" class="tab3 even"><code><span style="color: #ff0000">$long_dms_m_float</span> <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">60</span> <span style="color: #66cc66;">*</span> <span style="color: #ff0000">$long_dd_m</span><span style="color: #66cc66;">;</span></code></li>
<li value="41" class="tab3 odd"><code><span style="color: #808080; font-style: italic;">// get int value of long DMS floating</span></code></li>
<li value="42" class="tab3 even"><code><span style="color: #ff0000">$long_dms_m_int</span> <span style="color: #66cc66;">=</span> <a href="http://www.php.net/intval"><span style="color: #000066;">intval</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;$long_dms_m_float&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span></code></li>
<li value="43" class="tab2 odd"><code><span style="color: #808080; font-style: italic;">// SECONDS \\</span></code></li>
<li value="44" class="tab3 even"><code><span style="color: #808080; font-style: italic;">// get DD seconds -&gt; DMS minutes floating - DMS minutes integer</span></code></li>
<li value="45" class="tab3 odd"><code><span style="color: #ff0000">$long_dd_s</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000">$long_dms_m_float</span> <span style="color: #66cc66;">-</span> <span style="color: #ff0000">$long_dms_m_int</span><span style="color: #66cc66;">;</span></code></li>
<li value="46" class="tab3 even"><code><span style="color: #808080; font-style: italic;">// convert DD secs to DMS secs -&gt; 60 * DD seconds</span></code></li>
<li value="47" class="tab3 odd"><code><span style="color: #ff0000">$long_dms_s</span> <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">60</span> <span style="color: #66cc66;">*</span> <span style="color: #ff0000">$long_dd_s</span><span style="color: #66cc66;">;</span></code></li>
<li value="48" class="tab0 even"><code><span style="color: #808080; font-style: italic;">// end conversion of lat/long \\</span></code></li>
<li value="49" class="tab0 odd"><code><span style="color: #808080; font-style: italic;">// next just echo the output with the degree/minute/second symbols in place</span></code></li>
<li value="50" class="tab0 even"><code><span style="color: #000000; font-weight: bold;">?&gt;</span></code></li>
<li value="51" class="tab0 odd"><code>Latitude<span style="color: #66cc66;">:</span> <span style="color: #000000; font-weight: bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000">$lat_dd_int</span><span style="color: #66cc66;">;</span> ?<span style="color: #66cc66;">&gt;&amp;</span><span style="color: #808080; font-style: italic;">#176; &lt;?php echo $lat_dms_m_int; ?&gt;&amp;#8217; &lt;?php echo round($lat_dms_s, 2); ?&gt;&amp;#8221;</span></code></li>
<li value="52" class="tab0 even"><code>Longitude<span style="color: #66cc66;">:</span> <span style="color: #000000; font-weight: bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000">$long_dd_int</span><span style="color: #66cc66;">;</span> ?<span style="color: #66cc66;">&gt;&amp;</span><span style="color: #808080; font-style: italic;">#176; &lt;?php echo $long_dms_m_int; ?&gt;&amp;#8217; &lt;?php echo round($long_dms_s, 2); ?&gt;&amp;#8221;</span></code></li>
<li class="sourcelink"><strong>Download this code:</strong> <a href="http://www.super-cooper.com/snippets/2004/dd-dms-1.txt">dd-dms-1.txt</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.super-cooper.com/archive/2004/11/16/convert-lat-long-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP/CSS versus ASP/tables</title>
		<link>http://www.super-cooper.com/archive/2004/08/27/php-versus-asp/</link>
		<comments>http://www.super-cooper.com/archive/2004/08/27/php-versus-asp/#comments</comments>
		<pubDate>Sat, 28 Aug 2004 03:42:18 +0000</pubDate>
		<dc:creator>Chad</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[site]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://super-cooper.com/?p=47</guid>
		<description><![CDATA[For the past few days, I have been tinkering around with PHP while rebuilding our site at work. I initially did everything in tables and ASP back last year sometime. Just some small stuff, nothing major. Well, then our Windoze IIS server crashed, and the powers that be decided to move all the web-related stuff [...]]]></description>
			<content:encoded><![CDATA[<p>For the past few days, I have been tinkering around with PHP while rebuilding our site at work. I initially did everything in tables and ASP back last year sometime. Just some small stuff, nothing major.<br />
<span id="more-21"></span><br />
Well, then our Windoze IIS server crashed, and the powers that be decided to move all the web-related stuff over to a Linux/Apache server (a good thing). So there goes my site along with my ability to run ASP, since they aren&#8217;t about to try to do any customization for just one loser using ASP. Basically, this was the push I needed to migrate to PHP (another good thing). I&#8217;ve been messing around a little bit with PHP, mostly with this site and the WordPress templates. The work site, however,  is my first big dive into PHP. I am amazed at the amount (or lack thereof) of PHP code it is taking to redo the site to do basically (or in some cases, more) of the same things it was before. Also, since I&#8217;m trying not to use tables (styled ordered lists instead), the size of my templates are just amazing when compared to the tabled ASP templates of the old version. For instance, I have an ASP tabled template that is 46KB in size; the same template done with PHP and CSS-styled order lists: about 4KB (plus about 3KB of included files). Damn! That&#8217;s a huge reduction in file size, not to mention the code is gorgeous now without all the tables and that mess in there to clutter it up.</p>
<p>Another thing is adding the last modified date to the pages. In the old version, I used some JavaScript I found somewhere to accomplish this. I looks like so:</p>
<link rel="stylesheet" href="http://www.super-cooper.com/wp-content/plugins/codeviewer.css" type="text/css" media="all" />
<ol class="codelist">
<li value="1" class="tab0 odd"><code><span style="color: #66cc66;">&lt;</span>script language=<span style="color: #3366CC;">&quot;JavaScript&quot;</span><span style="color: #66cc66;">&gt;</span></code></li>
<li value="2" class="tab0 even"><code><span style="color: #66cc66;">&lt;!</span>--</code></li>
<li value="3" class="tab0 odd"><code><span style="color: #003366; font-weight: bold;">function</span> getLongDateString<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></code></li>
<li value="4" class="tab0 even"><code><span style="color: #66cc66;">&#123;</span>&nbsp; &nbsp;<span style="color: #009900; font-style: italic;">//method defined on class Date.</span></code></li>
<li value="5" class="tab1 odd"><code><span style="color: #009900; font-style: italic;">//Returns a date string of the form: Day DD Month,YYYY</span></code></li>
<li value="6" class="tab1 even"><code><span style="color: #009900; font-style: italic;">//(e.g. Sunday 27 September, 1998)</span></code></li>
<li value="7" class="tab1 odd"><code>monthNames = <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;January&quot;</span>,<span style="color: #3366CC;">&quot;February&quot;</span>,<span style="color: #3366CC;">&quot;March&quot;</span>,<span style="color: #3366CC;">&quot;April&quot;</span>, <span style="color: #3366CC;">&quot;May&quot;</span>,<span style="color: #3366CC;">&quot;June&quot;</span>,<span style="color: #3366CC;">&quot;July&quot;</span>,<span style="color: #3366CC;">&quot;August&quot;</span>,<span style="color: #3366CC;">&quot;September&quot;</span>, <span style="color: #3366CC;">&quot;October&quot;</span>,<span style="color: #3366CC;">&quot;November&quot;</span>,<span style="color: #3366CC;">&quot;December&quot;</span><span style="color: #66cc66;">&#41;</span>;</code></li>
<li value="8" class="tab0 even"><code>dayNames = <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;Sunday&quot;</span>,<span style="color: #3366CC;">&quot;Monday&quot;</span>,<span style="color: #3366CC;">&quot;Tuesday&quot;</span>,<span style="color: #3366CC;">&quot;Wednesday&quot;</span>, <span style="color: #3366CC;">&quot;Thursday&quot;</span>,<span style="color: #3366CC;">&quot;Friday&quot;</span>,<span style="color: #3366CC;">&quot;Saturday&quot;</span><span style="color: #66cc66;">&#41;</span>;</code></li>
<li value="9" class="tab1 odd"><code>dayOfWeek = <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">getDay</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</code></li>
<li value="10" class="tab1 even"><code>day = dayNames<span style="color: #66cc66;">&#91;</span>dayOfWeek<span style="color: #66cc66;">&#93;</span>;</code></li>
<li value="11" class="tab1 odd"><code>dateOfMonth = <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">getDate</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</code></li>
<li value="12" class="tab1 even"><code>monthNo = <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">getMonth</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</code></li>
<li value="13" class="tab1 odd"><code>month = monthNames<span style="color: #66cc66;">&#91;</span>monthNo<span style="color: #66cc66;">&#93;</span>;</code></li>
<li value="14" class="tab0 even"><code>year = <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">getYear</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</code></li>
<li value="15" class="tab1 odd"><code><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>year <span style="color: #66cc66;">&lt;</span> <span style="color: #CC0000;">2000</span><span style="color: #66cc66;">&#41;</span></code></li>
<li value="16" class="tab0 even"><code>year = year + <span style="color: #CC0000;">1900</span>;</code></li>
<li value="17" class="tab0 odd"><code>dateStr = day+<span style="color: #3366CC;">&quot;, &quot;</span>+month+<span style="color: #3366CC;">&quot; &quot;</span>+dateOfMonth+<span style="color: #3366CC;">&quot;, &quot;</span>+year;</code></li>
<li value="18" class="tab1 even"><code><span style="color: #000066; font-weight: bold;">return</span> dateStr;</code></li>
<li value="19" class="tab0 odd"><code><span style="color: #66cc66;">&#125;</span></code></li>
<li value="20" class="tab0 even"><code><span style="color: #009900; font-style: italic;">//register the &nbsp;method in the class Date</span></code></li>
<li value="21" class="tab0 odd"><code>Date.<span style="color: #006600;">prototype</span>.<span style="color: #006600;">getLongDateString</span>=getLongDateString;</code></li>
<li value="22" class="tab0 even"><code><span style="color: #003366; font-weight: bold;">function</span> DocDate<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></code></li>
<li value="23" class="tab0 odd"><code><span style="color: #66cc66;">&#123;</span> <span style="color: #009900; font-style: italic;">//return the document modification date (excl.time)</span></code></li>
<li value="24" class="tab0 even"><code><span style="color: #009900; font-style: italic;">//as a string</span></code></li>
<li value="25" class="tab1 odd"><code>DateTimeStr = document.<span style="color: #006600;">lastModified</span>;</code></li>
<li value="26" class="tab1 even"><code>secOffset = Date.<span style="color: #006600;">parse</span><span style="color: #66cc66;">&#40;</span>DateTimeStr<span style="color: #66cc66;">&#41;</span>;</code></li>
<li value="27" class="tab1 odd"><code><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>secOffset == <span style="color: #CC0000;">0</span> <span style="color: #66cc66;">||</span> secOffset == <span style="color: #003366; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> <span style="color: #009900; font-style: italic;">//Opera3.2</span></code></li>
<li value="28" class="tab2 even"><code>dateStr = <span style="color: #3366CC;">&quot;Unknown&quot;</span>;</code></li>
<li value="29" class="tab1 odd"><code><span style="color: #000066; font-weight: bold;">else</span></code></li>
<li value="30" class="tab1 even"><code><span style="color: #66cc66;">&#123;</span></code></li>
<li value="31" class="tab2 odd"><code>aDate = <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</code></li>
<li value="32" class="tab2 even"><code>aDate.<span style="color: #006600;">setTime</span><span style="color: #66cc66;">&#40;</span>secOffset<span style="color: #66cc66;">&#41;</span>;</code></li>
<li value="33" class="tab2 odd"><code><span style="color: #009900; font-style: italic;">//use method defined above</span></code></li>
<li value="34" class="tab2 even"><code>datestr = aDate.<span style="color: #006600;">getLongDateString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</code></li>
<li value="35" class="tab1 odd"><code><span style="color: #66cc66;">&#125;</span></code></li>
<li value="36" class="tab2 even"><code><span style="color: #000066; font-weight: bold;">return</span> dateStr;</code></li>
<li value="37" class="tab1 odd"><code><span style="color: #66cc66;">&#125;</span></code></li>
<li value="38" class="tab1 even"><code>document.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;&lt;center&gt; Last Updated: &quot;</span><span style="color: #66cc66;">&#41;</span>;</code></li>
<li value="39" class="tab1 odd"><code>document.<span style="color: #006600;">writeln</span><span style="color: #66cc66;">&#40;</span>DocDate<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>,<span style="color: #3366CC;">&quot;&lt;/center&gt;&quot;</span><span style="color: #66cc66;">&#41;</span>;</code></li>
<li value="40" class="tab1 even"><code><span style="color: #009900; font-style: italic;">//</span></code></li>
<li value="41" class="tab0 odd"><code>--<span style="color: #66cc66;">&gt;</span></code></li>
<li value="42" class="tab0 even"><code><span style="color: #66cc66;">&lt;/</span>script<span style="color: #66cc66;">&gt;</span></code></li>
</ol>
<p>Kinda ridiculously long, eh? Then today I ran across this <a href="http://www.theprojects.org/dev/lastmodified.html">sweet little piece o&#8217; PHP code</a> that I actually inserted into my footer include file that all of my pages will call. This inserts the last modified date of the template neatly onto my pages, and the date format is, of course, customizable:</p>
<link rel="stylesheet" href="http://www.super-cooper.com/wp-content/plugins/codeviewer.css" type="text/css" media="all" />
<ol class="codelist">
<li value="1" class="tab0 odd"><code><span style="color: #000000; font-weight: bold;">&lt;?php</span></code></li>
<li value="2" class="tab2 even"><code><a href="http://www.php.net/putenv"><span style="color: #000066;">putenv</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;TZ=America/Chicago&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span></code></li>
<li value="3" class="tab2 odd"><code><a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">&quot;Page last modified on &quot;</span> <span style="color: #66cc66;">.</span> <a href="http://www.php.net/date"><span style="color: #000066;">date</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;F d, Y&quot;</span><span style="color: #66cc66;">,</span> <a href="http://www.php.net/getlastmod"><span style="color: #000066;">getlastmod</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span></code></li>
<li value="4" class="tab0 even"><code><span style="color: #000000; font-weight: bold;">?&gt;</span></code></li>
<li class="sourcelink"><strong>Download this code:</strong> <a href="http://www.super-cooper.com/snippets/2004/php-vs-asp-2.txt">php-vs-asp-2.txt</a></li>
</ol>
<p>So what does all of this mean, and why am I seemingly on a soapbox? Well, I&#8217;m very pleased so far with PHP (any surprises there?), what it can do, and the ease of getting it do those tasks. Oh yeah,  and what is even better is that I am <i>getting paid</i> to do this. Ain&#8217;t life grand?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.super-cooper.com/archive/2004/08/27/php-versus-asp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache/PHP local install</title>
		<link>http://www.super-cooper.com/archive/2004/08/18/apachephp-local-install/</link>
		<comments>http://www.super-cooper.com/archive/2004/08/18/apachephp-local-install/#comments</comments>
		<pubDate>Wed, 18 Aug 2004 22:26:34 +0000</pubDate>
		<dc:creator>Chad</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://super-cooper.com/?p=46</guid>
		<description><![CDATA[Today on my Windoze XP machine at work, I installed Apache 2.0.5 and PHP 5.0.1 locally for development. Previously, I had a mapped drive to our server, and I would copy/paste files from my machine to the server, then reload the page in the browser. Repeat 5,895 times. Okay, so maybe not that many times, [...]]]></description>
			<content:encoded><![CDATA[<p>Today on my Windoze XP machine at work, I installed Apache 2.0.5 and PHP 5.0.1 locally for development. Previously, I had a mapped drive to our server, and I would copy/paste files from my machine to the server, then reload the page in the browser. Repeat 5,895 times. Okay, so maybe not that many times, but it was a pain. Actually, the current version of our lab site (our server is currently &#8220;in repair&#8221; so I can&#8217;t give you a link to it) I did in *cough* ASP *cough*, because I didn&#8217;t know PHP at the time and needed to get some Access databases on the web quickly. Now, however, in the coming months I plan on migrating all of the Access data to MySQL and powering it all with PHP (as I learn it). Soooo, I decided to install Apache and PHP today. I&#8217;ve heard horror stories of installing server packages and getting it all configured. I found this <a href="http://www.digitalamit.com/article/apache_php_mysql.phtml">tutorial</a> that helped alot. I did the Apache binary installer and PHP zip package installation, tinkered with the Apache httpd.conf file settings and some Windoze system file settings, and by 9:30 this morning, I was parsing PHP locally. It was alot easier than I thought it would be, especially since this was my first attempt at installing/running a server. All I can say now is why the hell didn&#8217;t I do this earlier?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.super-cooper.com/archive/2004/08/18/apachephp-local-install/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

