<?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>Shawngo.com</title>
	<atom:link href="http://www.shawngo.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.shawngo.com</link>
	<description>Just another WorthLess weblog</description>
	<pubDate>Thu, 25 Sep 2008 01:56:24 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
	<language>en</language>
			<item>
		<title>Hotspots.php Google Map Script</title>
		<link>http://www.shawngo.com/2008/09/hotspotsphp-google-map-script/</link>
		<comments>http://www.shawngo.com/2008/09/hotspotsphp-google-map-script/#comments</comments>
		<pubDate>Thu, 25 Sep 2008 01:56:24 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

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

		<category><![CDATA[google maps]]></category>

		<guid isPermaLink="false">http://www.shawngo.com/?p=49</guid>
		<description><![CDATA[A visitor to the site had requested the Fishing Hotspots Script that I wrote several years ago. I figured it can&#8217;t hurt to give it away since the code is pretty bad and all.
I decided to throw this script on the site as a download for all to enjoy. It was one of my first [...]]]></description>
			<content:encoded><![CDATA[<p>A visitor to the site had requested the <a href="hotspots.php">Fishing Hotspots Script</a> that I wrote several years ago. I figured it can&#8217;t hurt to give it away since the code is pretty bad and all.</p>
<p>I decided to throw this script on the site as a download for all to enjoy. It was one of my first attempts at some sort of Web 2.0 fishing map using Google Maps. I was big into mashups back then which lead me to create <a href="gmaps/states.php">this beast!</a></p>
<p>The script hasn&#8217;t been tested after I stripped out all my database info and Google Maps key and anything else that would give away my deepest darkest secrets. So, you get what will appear like a work in progress or a PHP 101 final project. There are a few scripts included that I didn&#8217;t write, so thanks to them for those.</p>
<p>If you care to comment, or have any questions, feel free to post such comments/questions and I will try to respond in a reasonable fashion (time-wise, not fashion-wise).</p>
<p>So here it is in all of it&#8217;s &#8220;Web 1.0 in a Web 2.0 World&#8221; glory:</p>
<h1><a href="hotspots.rar">Download PHP Hotspots Script &raquo;</a></h1>
<h4>Enjoy!</h4>
<p style="font-size:8px;">heh&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shawngo.com/2008/09/hotspotsphp-google-map-script/feed/</wfw:commentRss>
		</item>
		<item>
		<title>JavaScript BlackBelt ISO JavaScript Ninja!</title>
		<link>http://www.shawngo.com/2008/09/javascript-blackbelt-iso-javascript-ninja/</link>
		<comments>http://www.shawngo.com/2008/09/javascript-blackbelt-iso-javascript-ninja/#comments</comments>
		<pubDate>Sat, 13 Sep 2008 14:56:57 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

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

		<guid isPermaLink="false">http://www.shawngo.com/?p=47</guid>
		<description><![CDATA[Let it be known, I can&#8217;t wait for Secrets of the JavaScript Ninja to be released. Written by JavaScript Sage John Resig author of my all time favorite JavaScript Library jQuery, this book is sure to be phenomenal!
The new jQuery site looks great!
]]></description>
			<content:encoded><![CDATA[<p>Let it be known, I can&#8217;t wait for <a href="http://jsninja.com/">Secrets of the JavaScript Ninja</a> to be released. Written by <a href="http://ejohn.org/">JavaScript Sage John Resig</a> author of my all time favorite <a href="http://jquery.com">JavaScript Library jQuery</a>, this book is sure to be phenomenal!</p>
<p>The new jQuery site looks great!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shawngo.com/2008/09/javascript-blackbelt-iso-javascript-ninja/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Animated Progress Meter using jQuery</title>
		<link>http://www.shawngo.com/2008/04/animated-progress-meter-using-jquery/</link>
		<comments>http://www.shawngo.com/2008/04/animated-progress-meter-using-jquery/#comments</comments>
		<pubDate>Sun, 13 Apr 2008 18:30:48 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

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

		<guid isPermaLink="false">http://www.shawngo.com/?p=43</guid>
		<description><![CDATA[Need an animated progress meter for an application? This particular example is set up to accept a percentage of completion and a couple other numbers you can set. It&#8217;s super easy to use and implement, the best part, ONE line of javascript (including the 30KB that is jQuery(packed)).
View the animated jQuery progress bar in action.
]]></description>
			<content:encoded><![CDATA[<p>Need an animated progress meter for an application? This particular example is set up to accept a percentage of completion and a couple other numbers you can set. It&#8217;s super easy to use and implement, the best part, ONE line of javascript (including the 30KB that is <a href="http://jquery.com">jQuery</a>(packed)).</p>
<p>View the animated <a href="http://shawngo.com/slider.php">jQuery progress bar in action</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shawngo.com/2008/04/animated-progress-meter-using-jquery/feed/</wfw:commentRss>
		</item>
		<item>
		<title>KML Generator for Google Earth - written in PHP</title>
		<link>http://www.shawngo.com/2008/04/kml-generator-for-google-earth-written-in-php/</link>
		<comments>http://www.shawngo.com/2008/04/kml-generator-for-google-earth-written-in-php/#comments</comments>
		<pubDate>Sun, 13 Apr 2008 18:30:08 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[google maps]]></category>

		<guid isPermaLink="false">http://www.shawngo.com/?p=42</guid>
		<description><![CDATA[A What Generator?

This script is a homemade botch that I wrote because I didn&#8217;t like any of the other KML generating scripts out there.
The one that I did find is for PHP5. Hmph..
Basically this script grabs info from my Fishing Spots MySQL database and fires it out as xml, which is
in turn, read by Google [...]]]></description>
			<content:encoded><![CDATA[<h2>A What Generator?</h2>
<p>
This script is a homemade botch that I wrote because I didn&#8217;t like any of the other KML generating scripts out there.</p>
<p>The <i>one</i> that I did find is for PHP5. Hmph..</p>
<p>Basically this script grabs info from my <a href="hotspots.php" title="Fishing HotSpots!">Fishing Spots</a> MySQL database and fires it out as xml, which is<br />
in turn, read by Google Earth as a .kml file.
</p>
<h2>On with the script</h2>
<p>Ok, enough said. Here is the source:</p>
<p><a href="http://www.shawngo.com/xgenerator.php" title="Source code for KML Generator Script - written in pHp">www.shawngo.com/xgenerator.php</a></p>
<p>And here is the actual KML File Output:<br />
<a href="http://www.shawngo.com/generator.php" title="Output of KML Data - for Fishing Hotspots page">www.shawngo.com/generator.php</a></p>
<p>And last but not least, the Google Maps + Fishing Spots page:<br />
<a href="http://www.shawngo.com/hotspots.php" title="Google Maps and Fishing Locations">www.shawngo.com/hotspots.php</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.shawngo.com/2008/04/kml-generator-for-google-earth-written-in-php/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Google Maps API; A Tutorial</title>
		<link>http://www.shawngo.com/2008/04/google-maps-api-a-tutorial/</link>
		<comments>http://www.shawngo.com/2008/04/google-maps-api-a-tutorial/#comments</comments>
		<pubDate>Sun, 13 Apr 2008 18:09:29 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[google maps]]></category>

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

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

		<guid isPermaLink="false">http://shawngo.com/wordpress/?p=40</guid>
		<description><![CDATA[Step 1: Google Maps API Key
Note: this didn&#8217;t come out as expected during the Wordpress migration  
In order to get a map on your site you must first sign up for a Google Maps API Key. There is no charge for this. Just make sure you follow the Google Maps Terms and Conditions.
The official [...]]]></description>
			<content:encoded><![CDATA[<h2>Step 1: Google Maps API Key</h2>
<p><strong>Note:</strong> this didn&#8217;t come out as expected during the Wordpress migration <img src='http://www.shawngo.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>In order to get a map on your site you must first sign up for a <a href="http://www.google.com/apis/maps/signup.html">Google Maps API Key</a>. There is no charge for this. Just make sure you follow the <a href="http://www.google.com/apis/maps/terms.html">Google Maps Terms and Conditions</a>.</p>
<p>The official <a href="http://www.google.com/apis/maps/documentation/">Google Maps Documentation</a> contains specifc API commands for more advanced users.</p>
<p>The &#8220;Hello World&#8221; of Google Maps<br />
For the most part, basic Google Maps are fairly trivial. It&#8217;s when you&#8217;re handling 2 million data points is when it gets a bit tricky.</p>
<p><a href="googlemaps-basic-example.php">See Example</a><br />
*note: I like to stick with the latest web standards, hence the strict DOCTYPE*</p>
<p>&lt;!DOCTYPE html PUBLIC  &#8220;-//W3C//DTD XHTML 1.1//EN&#8221;<br />
&#8220;http://www.w3.org/TR/2001/REC-xhtml11-20010531/DTD/xhtml11-flat.dtd&#8221;&gt;<br />
&lt;html xmlns=&#8221;http://www.w3.org/1999/xhtml&#8221; xml:lang=&#8221;en&#8221;&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv=&#8221;Content-Type&#8221; content=&#8221;text/javascript;<br />
  charset=iso-8859-1&#8243; /&gt;<br />
&lt;meta name=&#8221;description&#8221; content=&#8221;Google Maps Basic Example&#8221; /&gt;<br />
&lt;meta name=&#8221;keywords&#8221; content=&#8221;" /&gt;<br />
&lt;title&gt;My First Google Map&lt;/title&gt;<br />
&lt;script<br />
  src=&#8221;http://maps.google.com/maps?file=api&#038;v=2.44&#038;key=your_map_key&#8221;<br />
type=&#8221;text/javascript&#8221;&gt;&lt;/script&gt;<br />
&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
//&lt;![CDATA[</p>
<p>// this is the javascript that is responsible for generating the map<br />
function load_map() {<br />
  if (GBrowserIsCompatible()) {</p>
<p>	// assign an id to the location in the html,<br />
	// in this case it is a div element<br />
	var map = new GMap2(document.getElementById("map"));</p>
<p>	// latitude and longitude of center of map, on load<br />
	// the 18 is for the zoom level<br />
	map.setCenter(new GLatLng(41.902277, -87.62832), 18);<br />
  }<br />
}</p>
<p>//]]&gt;</p>
<p>&lt;/script&gt;<br />
&lt;/head&gt;</p>
<p>&lt;body onload=&#8221;load_map()&#8221; onunload=&#8221;GUnload()&#8221;&gt;</p>
<p>&lt;div id=&#8221;map&#8221; style=&#8221;width: 500px; height: 300px&#8221;&gt;&lt;/div&gt;<br />
&lt;br/&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p>
<h2>Google Map Controls</h2>
<p>In order to zoom or pan or view different versions of the map (Satellite or Hybrid) you need to add some more <a href="http://www.javascript.com">JavaScript</a>.</p>
<p>This adds basic zoom and pan controls to your map (<a href="googlemaps-basicexample1.php">See Example</a>)</p>
<p>function load_map() {<br />
  if (GBrowserIsCompatible()) {</p>
<p>	// assign an id to the location in the html,<br />
	// in this case it is a div element<br />
	var map = new GMap2(document.getElementById(&#8221;map&#8221;));</p>
<p>	map.addControl(new GSmallMapControl());<br />
	map.addControl(new GMapTypeControl());</p>
<p>	// latitude and longitude of center of map, on load<br />
	// the 18 is for the zoom level<br />
	map.setCenter(new GLatLng(41.902277, -87.62832), 8);<br />
  }<br />
}</p>
<h2>Add a Marker and Info Window</h2>
<p>Generally speaking, data points can be sent in XML format and loaded onto the map. This is just the basic way to include a data point (marker) and it&#8217;s corresponding Info Window.</p>
<p>// Adds a marker at the given point with an info window<br />
function createMarker(point, data) {<br />
  var marker = new GMarker(point);<br />
  GEvent.addListener(marker, &#8220;click&#8221;, function() {<br />
    marker.openInfoWindowHtml(data);<br />
  });<br />
  return marker;<br />
}</p>
<p>function load_map() {<br />
  if (GBrowserIsCompatible()) {</p>
<p>	// assign an id to the location in the html,<br />
	// in this case it is a div element<br />
	var map = new GMap2(document.getElementById(&#8221;map&#8221;));</p>
<p>	// this will add a larger zoom control to the map<br />
	map.addControl(new GLargeMapControl());<br />
	map.addControl(new GMapTypeControl());</p>
<p>	// latitude and longitude of center of map, on load<br />
	// the 8 is for the zoom level<br />
	map.setCenter(new GLatLng(41.902277, -87.62832), 8);</p>
<p>	// Add a marker with an Info Window<br />
	var point = new GLatLng(41.91862,-87.86590);</p>
<p>	// you can also style the info window<br />
	var html = &#8216;&lt;div style=&#8221;color:#005;width:200px;&#8221;&gt;&#8217;;<br />
	html    += &#8216;Check out our other maps at &#8216;;<br />
	html    += &#8216;&lt;a href=&#8221;http://www.fishing-locations.com&#8221;&#8216;;<br />
	html	+= &#8216;title=&#8221;Fishing Locations and Google Maps&#8221;&gt;&#8217;;<br />
	html	+= &#8216;fishing-locations.com&lt;/a&gt;&lt;/div&gt;&#8217;;<br />
	var marker = createMarker(point,html);</p>
<p>	// add the marker to the map<br />
	map.addOverlay(marker);<br />
  }<br />
}</p>
<p>This adds a marker and corresponding info window. (<a href="googlemaps-basicexample2.php">See Example</a>)</p>
<h2>AJAX Your Google Map</h2>
<p>One of the cool features of Google Maps API is that it allows you to grab the data using <a href="http://en.wikipedia.org/wiki/AJAX">Asynchronous Javascript and XML</a>, better known as <a href="http://www.adaptivepath.com/publications/essays/archives/000385.php">AJAX</a>.</p>
<p>This allows you to update the map without refreshing the page. This example gives a basic outline of the request and response activity when the user loads the page.</p>
<p>This adds a marker and corresponding info window. (<a href="googlemaps-basicexample3.php">See Example</a>)</p>
<p>function load_map() {<br />
	var map = new GMap2(document.getElementById(&#8221;map&#8221;));<br />
	// this will add a larger zoom control to the map<br />
	map.addControl(new GLargeMapControl());<br />
	map.addControl(new GMapTypeControl());</p>
<p>	// latitude and longitude of center of map, on load<br />
	// the 8 is for the zoom level<br />
	map.setCenter(new GLatLng(41.902277, -87.62832), 4);</p>
<p> // Read the data from example.xml<br />
      var request = GXmlHttp.create();<br />
      request.open(&#8221;GET&#8221;, &#8220;data.xml&#8221;, true);</p>
<p>      // this is how the ajax is performed<br />
      // this part of the script sends a request to the server<br />
      // and receives the data.xml file<br />
      request.onreadystatechange = function() {<br />
        if (request.readyState == 4) { // when all is clear<br />
          var xmlDoc = request.responseXML;</p>
<p>          // get the marker array and parse the data<br />
          var markers = xmlDoc.documentElement.getElementsByTagName(&#8221;marker&#8221;);</p>
<p>		  // for each marker, get the attributes and the infowindow data<br />
          for (var i = 0; i &lt; markers.length; i++) {<br />
            // parse the marker attributes<br />
            var lat = parseFloat(markers[i].getAttribute(&#8221;lat&#8221;)); // lat<br />
            var lng = parseFloat(markers[i].getAttribute(&#8221;lng&#8221;)); // long<br />
            var point = new GLatLng(lat,lng); // create the point<br />
            // get the infowindow data<br />
            var html = GXml.value(markers[i].getElementsByTagName(&#8221;infowindow&#8221;)[0]);<br />
            // create the marker<br />
            var marker = createMarker(point,html);<br />
            // add the marker to the map<br />
            map.addOverlay(marker);<br />
          }<br />
        }<br />
      }<br />
      // this sends the ajax request<br />
      request.send(null);</p>
<p>} // end load_map()</p>
<p>				 Here are some of my favorite resources for building Google Maps.</p>
<ul>
<li><a href="http://www.google.com/apis/maps/documentation/" title="Google Maps API Documentation">Google Maps API Documentation</a></li>
<li><a href="http://groups.google.com/group/Google-Maps-API" title="Google groups - Maps API">Google Groups: Google Maps API</a></li>
<li><a href="http://www.google.com/apis/maps/documentation/reference.html#Events_GMap" title="API 2 Reference">Google Maps API 2 Reference</a></li>
<li><a href="http://www.google.com/apis/maps/documentation/upgrade.html" title="Upgrade from google maps 1 to version 2">Google Maps API Upgrade Guide</a></li>
<li><a href="http://www.pixeldevelopment.com/pdmarker.asp" title="PdMarker">PdMarker</a></li>
<li><a href="http://www.econym.demon.co.uk/googlemaps/" title="Great Maps Resource, lots of tutorials">Google Maps Resource</a></li>
<li><a href="http://www.econym.demon.co.uk/googlemaps/reference.htm" title="More on the API">Unofficial Google Maps API</a></li>
<li><a href="http://outofhanwell.com/ieleak/index.php?title=Main_Page" title="Drip IE Leak Protector">IE Memory Leaks</a></li>
<li><a href="http://www.mozilla.org/projects/venkman/" title="Javascript Debugger">Venkman Javascript Debugger Project</a></li>
<li><a href="http://jibbering.com/faq/faq_notes/closures.html" title="Javascript Closures Tutorial">Javascript Closures</a></li>
</ul>
<p>				 Check out a few of the Google Maps Extended APIs</p>
<ul>
<li><a href="http://gmaps.tommangan.us/" title="Google Maps Extended API">Tom Mangan&#8217;s Fun With Google Maps</a> Tom has a few extended API&#8217;s that allow you to overlay images or add special labels to your markers.</li>
<li><a href="http://mapki.com/wiki/Main_Page" title="Google Maps API Wiki">Google Mapki</a> - A Wiki for Google Maps API. Share information, different implementations and help out!</li>
<li><a href="http://www.lifehack.org/articles/lifehack/essential-resources-for-google-maps.html" title="Google Maps Extended API and General Info">LifeHack.org</a> - Listing of Google Maps mash-ups and some more resources. Hey, add your link! PageRank of 5, not bad <img src='http://www.shawngo.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
<li><a href="http://xmaps.busmonster.com/" title="Google Maps Extended API - XMaps Library">XMaps Library</a> - Google Maps API Extension allowing you to do some nifty effects with Polylines and Trails</li>
<li><a href="http://brainoff.com/gmaps/mgeorss.html" title="Google Maps Extended API for GeoRSS">MGeoRss</a> - &#8220;This extension integrates basic GeoRSS support directly into Google Maps. This work is public domain.&#8221;</li>
<li><a href="http://extensions.joomla.org/component/option,com_mtree/task,viewlink/link_id,377/Itemid,35/" title="Google Maps Extended API">Joomla Extension Directory</a> - an API Extension for Joomla</li>
<li><a href="http://www.directionsmag.com/article.php?article_id=2120&#038;trv=1" title="Google Maps Noob Instructions">Google Maps Instructions</a> - Instruction guide for Google Maps Noobs I guess.</li>
<li><a href="http://www.directionsmag.com/article.php?article_id=2120&#038;trv=1" title="Google Maps : Chicago Tranist Authority">Chicago Transit Authority map on Google Maps</a> - This guy takes trains to the extreme!</li>
<li><a href="http://www.googlemappers.com/libraries/gxmagnifier/docs/default.htm" title="Google Maps Extended API - GxMagnify">GxMagnify</a> - GxMagnifier is a free add-in control for Google Maps that creates a moveable, magnified window on top of your map.</li>
<li><a href="http://forums.mysql.com/read.php?23,40909,40909" title="MySQL Forum on Google Maps">Using MySQL Spatial Extensions to make a Google Maps interface.</a></li>
<li><a href="http://www.mgmaps.com/" title="A Mobile Google Maps Extended API">Mobile GMaps</a> - is &#8220;a FREE application that displays Google Maps, Yahoo! Maps, Windows Live Local (MSN Virtual Earth) and Ask.com Maps and satellite imagery on Java J2ME-enabled mobile phones, PDAs and other devices.&#8221; <b>Sweet!</b></li>
<li><a href="http://conversationswithmyself.com/maps/tracker/gmapTracker.html" title="Real Time GMaps Tracker">DIY Real Time GPS Tracker</a> - create a real-time GPS tracker using Google Maps API</li>
<li><a href="http://blog.tooleshed.com/?p=16" title="GeoCoding with TIGER">The Toolshed</a> - Geocoding with TIGER/Line, MySQL and PHP</li>
<li><a href="" title="Google Maps Extended API"></a></li>
<li><a href="" title="Google Maps Extended API"></a></li>
<li><a href="" title="Google Maps Extended API"></a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.shawngo.com/2008/04/google-maps-api-a-tutorial/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP MySQL Connection Class</title>
		<link>http://www.shawngo.com/2008/04/php-mysql-connection-class/</link>
		<comments>http://www.shawngo.com/2008/04/php-mysql-connection-class/#comments</comments>
		<pubDate>Sun, 13 Apr 2008 17:43:22 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://shawngo.com/wordpress/?p=38</guid>
		<description><![CDATA[This PHP helper class allows you to easily connect to your MySQL database.
There are a couple other functions that may prove useful such as:
mysql_result_all() - Displays results in a table
getUserIP() - returns the User&#8217;s IP address
validate_email() - returns boolean if email validates. 
You must change the database information to your particular database. 


&#60;?php
/**
* DB_Connect.php
* @author Shawn McFarlane
* @version $Id$
* @copyright 2005
**/

class DB_Connect{
// change these values
var $host = &#8220;&#8221;;
var 
$user = &#8220;&#8221;;
var 

$pass = &#8220;&#8221;;
var 
$db = &#8220;&#8221;;
function 

query_db($query)
{
    

$conn = mysql_connect($this-&#62;host, $this-&#62;user, $this-&#62;pass);
    if (!
$conn) {
        die(

&#8216;Could not connectooo: &#8217; . mysql_error());
    }
    
mysql_select_db($db);
    
$results = mysql_query($query, $conn);
    

mysql_close($conn);
    return 
$results;
}
function 

mysql_insert($query)
{
    
$results = $this-&#62;query_db($query);
    return 

$results;
}

/*
 * Displays results in table format
 *
*/

function mysql_result_all($resultz, $rownumber)
{
    echo 

&#8216;&#60;table align=&#8221;center&#8221; class=&#8221;atablelayout1&#8243; cellspacing=&#8221;2&#8243;&#62;&#8217;;
    for(
$i = 0; $i &#60; mysql_num_fields($resultz); $i++) {
        echo 

&#8216;&#60;th class=&#8221;aheader&#8221;&#62;&#8217;;
        echo 
mysql_field_name($resultz, $i);
        echo 
&#8216;&#60;/th&#62;&#8217;;
    }
    

$rowCounter = 1;
    while (

$row = mysql_fetch_array($resultz)) {
        echo 
&#8216;&#60;tr&#62;&#8217;;
        for(

$i = 0; $i &#60; $rownumber; $i++) {
            echo 
&#8216;&#60;td class=&#8221;arow&#8217; . $rowCounter . &#8216;&#8221;&#62;&#8217; . $row[$i] . &#8216;&#60;/td&#62;&#8217;;
        }
        echo 

&#8216;&#60;/tr&#62;&#8217;;
        if (
$rowCounter === 1) {
            
$rowCounter = 2;
        } else {
            

$rowCounter = 1;
        }
    }
    echo 
&#8216;&#60;/table&#62;&#8217;;
    include(
&#8216;./includes/bottom.inc&#8217;);
}

/*
 * returns the User IP Address
 *
 *
*/

function getUserIP()
{
   
$ip = &#8220;&#8221;;
   if (isset(

$_SERVER)){
       if (isset(
$_SERVER["HTTP_X_FORWARDED_FOR"])){
           
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
       } elseif (isset(

$_SERVER["HTTP_CLIENT_IP"])) {
           
$ip = $_SERVER["HTTP_CLIENT_IP"];
       } else {
           

$ip = $_SERVER["REMOTE_ADDR"];
       }
   } else {
       if ( 
getenv( &#8216;HTTP_X_FORWARDED_FOR&#8217; ) ) {
           

$ip = getenv( &#8216;HTTP_X_FORWARDED_FOR&#8217; );
       } elseif ( 
getenv( &#8216;HTTP_CLIENT_IP&#8217; ) ) {
           
$ip = getenv( &#8216;HTTP_CLIENT_IP&#8217; );
       } else {
           

$ip = getenv( &#8216;REMOTE_ADDR&#8217; );
       }
   }
   return 
$ip;
}

/*
 *
 *
 *
*/

function authenticate($field)
{
    
// To foil any possible attempts at SQL injection,
    // do the following function
    // $variable=str_replace(&#8221;what to look for&#8221;,
    //           &#8221;what to replace it with&#8221;,$what_variable_to_use);
    // Now use the replace function on our variables
    

if(trim($field) == &#8220;&#8221; &#124;&#124; $field == null) return false;
    

$field = str_replace(&#8220; &#8221;, &#8220;&#8221;, $field); //remove spaces from password
    
$field = str_replace(&#8220;%20&#8243;, &#8220;&#8221;, $field); //remove escaped spaces from password
    // And finally, add slashes to escape things like quotes and apostrophes
    // because they can be used to hijack SQL statements!
    // use the function, addslashes(), pretty self explanatory
    //$field = addslashes($field); //remove spaces from password
    

return $field;
} 

// end authenticate()
function validate_email($email)
{
   

// Create the syntactical validation regular expression
   

$regexp =
    
&#8220;^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$&#8221;;
   

// Presume that the email is invalid
   
$valid = 0;
   

// Validate the syntax
   
if (eregi($regexp, $email))
   {
      list(
$username,$domaintld) = split(&#8220;@&#8221;,$email);
      

$valid = 1;
   } else {
      
$valid = 0;
   }
   return 

$valid;
}
}

?&#62;

]]></description>
			<content:encoded><![CDATA[<p>This PHP helper class allows you to easily connect to your MySQL database.</p>
<p>There are a couple other functions that may prove useful such as:<br />
<i>mysql_result_all()</i> - Displays results in a table</p>
<p><i>getUserIP()</i> - returns the User&#8217;s IP address<br />
<i>validate_email()</i> - returns boolean if email validates. </p>
<p>You must change the database information to your particular database. </p>
<div style="background-color: rgb(255, 255, 255);">
<code><font color="#000000"></p>
<p></font><font color="#0000bb">&lt;?php</p>
<p></font><font color="#ff8000">/**</p>
<p>* DB_Connect.php</p>
<p>* @author Shawn McFarlane</p>
<p>* @version $Id$</p>
<p>* @copyright 2005</p>
<p>**/</p>
</p>
<p></font><font color="#007700">class </font><font color="#0000bb">DB_Connect</font><font color="#007700">{</p>
<p></font><font color="#ff8000">// change these values</p>
<p></font><font color="#007700">var </font><font color="#0000bb">$host </font><font color="#007700">= </font><font color="#dd0000">&#8220;&#8221;</font><font color="#007700">;</p>
<p>var </p>
<p></font><font color="#0000bb">$user </font><font color="#007700">= </font><font color="#dd0000">&#8220;&#8221;</font><font color="#007700">;</p>
<p>var </p>
</p>
<p></font><font color="#0000bb">$pass </font><font color="#007700">= </font><font color="#dd0000">&#8220;&#8221;</font><font color="#007700">;</p>
<p>var </p>
<p></font><font color="#0000bb">$db </font><font color="#007700">= </font><font color="#dd0000">&#8220;&#8221;</font><font color="#007700">;</p>
<p>function </p>
</p>
<p></font><font color="#0000bb">query_db</font><font color="#007700">(</font><font color="#0000bb">$query</font><font color="#007700">)</p>
<p>{</p>
<p>    </p>
</p>
<p></font><font color="#0000bb">$conn </font><font color="#007700">= </font><font color="#0000bb">mysql_connect</font><font color="#007700">(</font><font color="#0000bb">$this</font><font color="#007700">-&gt;</font><font color="#0000bb">host</font><font color="#007700">, </font><font color="#0000bb">$this</font><font color="#007700">-&gt;</font><font color="#0000bb">user</font><font color="#007700">, </font><font color="#0000bb">$this</font><font color="#007700">-&gt;</font><font color="#0000bb">pass</font><font color="#007700">);</p>
<p>    if (!</p>
<p></font><font color="#0000bb">$conn</font><font color="#007700">) {</p>
<p>        die(</p>
</p>
<p></font><font color="#dd0000">&#8216;Could not connectooo: &#8217; </font><font color="#007700">. </font><font color="#0000bb">mysql_error</font><font color="#007700">());</p>
<p>    }</p>
<p>    </p>
<p></font><font color="#0000bb">mysql_select_db</font><font color="#007700">(</font><font color="#0000bb">$db</font><font color="#007700">);</p>
<p>    </p>
<p></font><font color="#0000bb">$results </font><font color="#007700">= </font><font color="#0000bb">mysql_query</font><font color="#007700">(</font><font color="#0000bb">$query</font><font color="#007700">, </font><font color="#0000bb">$conn</font><font color="#007700">);</p>
<p>    </p>
</p>
<p></font><font color="#0000bb">mysql_close</font><font color="#007700">(</font><font color="#0000bb">$conn</font><font color="#007700">);</p>
<p>    return </p>
<p></font><font color="#0000bb">$results</font><font color="#007700">;</p>
<p>}</p>
<p>function </p>
</p>
<p></font><font color="#0000bb">mysql_insert</font><font color="#007700">(</font><font color="#0000bb">$query</font><font color="#007700">)</p>
<p>{</p>
<p>    </p>
<p></font><font color="#0000bb">$results </font><font color="#007700">= </font><font color="#0000bb">$this</font><font color="#007700">-&gt;</font><font color="#0000bb">query_db</font><font color="#007700">(</font><font color="#0000bb">$query</font><font color="#007700">);</p>
<p>    return </p>
</p>
<p></font><font color="#0000bb">$results</font><font color="#007700">;</p>
<p>}</p>
</p>
<p></font><font color="#ff8000">/*</p>
<p> * Displays results in table format</p>
<p> *</p>
<p>*/</p>
</p>
<p></font><font color="#007700">function </font><font color="#0000bb">mysql_result_all</font><font color="#007700">(</font><font color="#0000bb">$resultz</font><font color="#007700">, </font><font color="#0000bb">$rownumber</font><font color="#007700">)</p>
<p>{</p>
<p>    echo </p>
</p>
<p></font><font color="#dd0000">&#8216;&lt;table align=&#8221;center&#8221; class=&#8221;atablelayout1&#8243; cellspacing=&#8221;2&#8243;&gt;&#8217;</font><font color="#007700">;</p>
<p>    for(</p>
<p></font><font color="#0000bb">$i </font><font color="#007700">= </font><font color="#0000bb">0</font><font color="#007700">; </font><font color="#0000bb">$i </font><font color="#007700">&lt; </font><font color="#0000bb">mysql_num_fields</font><font color="#007700">(</font><font color="#0000bb">$resultz</font><font color="#007700">); </font><font color="#0000bb">$i</font><font color="#007700">++) {</p>
<p>        echo </p>
</p>
<p></font><font color="#dd0000">&#8216;&lt;th class=&#8221;aheader&#8221;&gt;&#8217;</font><font color="#007700">;</p>
<p>        echo </p>
<p></font><font color="#0000bb">mysql_field_name</font><font color="#007700">(</font><font color="#0000bb">$resultz</font><font color="#007700">, </font><font color="#0000bb">$i</font><font color="#007700">);</p>
<p>        echo </p>
<p></font><font color="#dd0000">&#8216;&lt;/th&gt;&#8217;</font><font color="#007700">;</p>
<p>    }</p>
<p>    </p>
</p>
<p></font><font color="#0000bb">$rowCounter </font><font color="#007700">= </font><font color="#0000bb">1</font><font color="#007700">;</p>
<p>    while (</p>
</p>
<p></font><font color="#0000bb">$row </font><font color="#007700">= </font><font color="#0000bb">mysql_fetch_array</font><font color="#007700">(</font><font color="#0000bb">$resultz</font><font color="#007700">)) {</p>
<p>        echo </p>
<p></font><font color="#dd0000">&#8216;&lt;tr&gt;&#8217;</font><font color="#007700">;</p>
<p>        for(</p>
</p>
<p></font><font color="#0000bb">$i </font><font color="#007700">= </font><font color="#0000bb">0</font><font color="#007700">; </font><font color="#0000bb">$i </font><font color="#007700">&lt; </font><font color="#0000bb">$rownumber</font><font color="#007700">; </font><font color="#0000bb">$i</font><font color="#007700">++) {</p>
<p>            echo </p>
<p></font><font color="#dd0000">&#8216;&lt;td class=&#8221;arow&#8217; </font><font color="#007700">. </font><font color="#0000bb">$rowCounter </font><font color="#007700">. </font><font color="#dd0000">&#8216;&#8221;&gt;&#8217; </font><font color="#007700">. </font><font color="#0000bb">$row</font><font color="#007700">[</font><font color="#0000bb">$i</font><font color="#007700">] . </font><font color="#dd0000">&#8216;&lt;/td&gt;&#8217;</font><font color="#007700">;</p>
<p>        }</p>
<p>        echo </p>
</p>
<p></font><font color="#dd0000">&#8216;&lt;/tr&gt;&#8217;</font><font color="#007700">;</p>
<p>        if (</p>
<p></font><font color="#0000bb">$rowCounter </font><font color="#007700">=== </font><font color="#0000bb">1</font><font color="#007700">) {</p>
<p>            </p>
<p></font><font color="#0000bb">$rowCounter </font><font color="#007700">= </font><font color="#0000bb">2</font><font color="#007700">;</p>
<p>        } else {</p>
<p>            </p>
</p>
<p></font><font color="#0000bb">$rowCounter </font><font color="#007700">= </font><font color="#0000bb">1</font><font color="#007700">;</p>
<p>        }</p>
<p>    }</p>
<p>    echo </p>
<p></font><font color="#dd0000">&#8216;&lt;/table&gt;&#8217;</font><font color="#007700">;</p>
<p>    include(</p>
<p></font><font color="#dd0000">&#8216;./includes/bottom.inc&#8217;</font><font color="#007700">);</p>
<p>}</p>
</p>
<p></font><font color="#ff8000">/*</p>
<p> * returns the User IP Address</p>
<p> *</p>
<p> *</p>
<p>*/</p>
</p>
<p></font><font color="#007700">function </font><font color="#0000bb">getUserIP</font><font color="#007700">()</p>
<p>{</p>
<p>   </p>
<p></font><font color="#0000bb">$ip </font><font color="#007700">= </font><font color="#dd0000">&#8220;&#8221;</font><font color="#007700">;</p>
<p>   if (isset(</p>
</p>
<p></font><font color="#0000bb">$_SERVER</font><font color="#007700">)){</p>
<p>       if (isset(</p>
<p></font><font color="#0000bb">$_SERVER</font><font color="#007700">[</font><font color="#dd0000">"HTTP_X_FORWARDED_FOR"</font><font color="#007700">])){</p>
<p>           </p>
<p></font><font color="#0000bb">$ip </font><font color="#007700">= </font><font color="#0000bb">$_SERVER</font><font color="#007700">[</font><font color="#dd0000">"HTTP_X_FORWARDED_FOR"</font><font color="#007700">];</p>
<p>       } elseif (isset(</p>
</p>
<p></font><font color="#0000bb">$_SERVER</font><font color="#007700">[</font><font color="#dd0000">"HTTP_CLIENT_IP"</font><font color="#007700">])) {</p>
<p>           </p>
<p></font><font color="#0000bb">$ip </font><font color="#007700">= </font><font color="#0000bb">$_SERVER</font><font color="#007700">[</font><font color="#dd0000">"HTTP_CLIENT_IP"</font><font color="#007700">];</p>
<p>       } else {</p>
<p>           </p>
</p>
<p></font><font color="#0000bb">$ip </font><font color="#007700">= </font><font color="#0000bb">$_SERVER</font><font color="#007700">[</font><font color="#dd0000">"REMOTE_ADDR"</font><font color="#007700">];</p>
<p>       }</p>
<p>   } else {</p>
<p>       if ( </p>
<p></font><font color="#0000bb">getenv</font><font color="#007700">( </font><font color="#dd0000">&#8216;HTTP_X_FORWARDED_FOR&#8217; </font><font color="#007700">) ) {</p>
<p>           </p>
</p>
<p></font><font color="#0000bb">$ip </font><font color="#007700">= </font><font color="#0000bb">getenv</font><font color="#007700">( </font><font color="#dd0000">&#8216;HTTP_X_FORWARDED_FOR&#8217; </font><font color="#007700">);</p>
<p>       } elseif ( </p>
<p></font><font color="#0000bb">getenv</font><font color="#007700">( </font><font color="#dd0000">&#8216;HTTP_CLIENT_IP&#8217; </font><font color="#007700">) ) {</p>
<p>           </p>
<p></font><font color="#0000bb">$ip </font><font color="#007700">= </font><font color="#0000bb">getenv</font><font color="#007700">( </font><font color="#dd0000">&#8216;HTTP_CLIENT_IP&#8217; </font><font color="#007700">);</p>
<p>       } else {</p>
<p>           </p>
</p>
<p></font><font color="#0000bb">$ip </font><font color="#007700">= </font><font color="#0000bb">getenv</font><font color="#007700">( </font><font color="#dd0000">&#8216;REMOTE_ADDR&#8217; </font><font color="#007700">);</p>
<p>       }</p>
<p>   }</p>
<p>   return </p>
<p></font><font color="#0000bb">$ip</font><font color="#007700">;</p>
<p>}</p>
</p>
<p></font><font color="#ff8000">/*</p>
<p> *</p>
<p> *</p>
<p> *</p>
<p>*/</p>
</p>
<p></font><font color="#007700">function </font><font color="#0000bb">authenticate</font><font color="#007700">(</font><font color="#0000bb">$field</font><font color="#007700">)</p>
<p>{</p>
<p>    </p>
<p></font><font color="#ff8000">// To foil any possible attempts at SQL injection,</p>
<p>    // do the following function</p>
<p>    // $variable=str_replace(&#8221;what to look for&#8221;,</p>
<p>    //           &#8221;what to replace it with&#8221;,$what_variable_to_use);</p>
<p>    // Now use the replace function on our variables</p>
<p>    </p>
</p>
<p></font><font color="#007700">if(</font><font color="#0000bb">trim</font><font color="#007700">(</font><font color="#0000bb">$field</font><font color="#007700">) == </font><font color="#dd0000">&#8220;&#8221; </font><font color="#007700">|| </font><font color="#0000bb">$field </font><font color="#007700">== </font><font color="#0000bb">null</font><font color="#007700">) return </font><font color="#0000bb">false</font><font color="#007700">;</p>
<p>    </p>
</p>
<p></font><font color="#0000bb">$field </font><font color="#007700">= </font><font color="#0000bb">str_replace</font><font color="#007700">(</font><font color="#dd0000">&#8220; &#8221;</font><font color="#007700">, </font><font color="#dd0000">&#8220;&#8221;</font><font color="#007700">, </font><font color="#0000bb">$field</font><font color="#007700">); </font><font color="#ff8000">//remove spaces from password</p>
<p>    </p>
<p></font><font color="#0000bb">$field </font><font color="#007700">= </font><font color="#0000bb">str_replace</font><font color="#007700">(</font><font color="#dd0000">&#8220;%20&#8243;</font><font color="#007700">, </font><font color="#dd0000">&#8220;&#8221;</font><font color="#007700">, </font><font color="#0000bb">$field</font><font color="#007700">); </font><font color="#ff8000">//remove escaped spaces from password</p>
<p>    // And finally, add slashes to escape things like quotes and apostrophes</p>
<p>    // because they can be used to hijack SQL statements!</p>
<p>    // use the function, addslashes(), pretty self explanatory</p>
<p>    //$field = addslashes($field); //remove spaces from password</p>
<p>    </p>
</p>
<p></font><font color="#007700">return </font><font color="#0000bb">$field</font><font color="#007700">;</p>
<p>} </p>
</p>
<p></font><font color="#ff8000">// end authenticate()</p>
<p></font><font color="#007700">function </font><font color="#0000bb">validate_email</font><font color="#007700">(</font><font color="#0000bb">$email</font><font color="#007700">)</p>
<p>{</p>
<p>   </p>
</p>
<p></font><font color="#ff8000">// Create the syntactical validation regular expression</p>
<p>   </p>
</p>
<p></font><font color="#0000bb">$regexp </font><font color="#007700">=</p>
<p>    </p>
<p></font><font color="#dd0000">&#8220;^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$&#8221;</font><font color="#007700">;</p>
<p>   </p>
</p>
<p></font><font color="#ff8000">// Presume that the email is invalid</p>
<p>   </p>
<p></font><font color="#0000bb">$valid </font><font color="#007700">= </font><font color="#0000bb">0</font><font color="#007700">;</p>
<p>   </p>
</p>
<p></font><font color="#ff8000">// Validate the syntax</p>
<p>   </p>
<p></font><font color="#007700">if (</font><font color="#0000bb">eregi</font><font color="#007700">(</font><font color="#0000bb">$regexp</font><font color="#007700">, </font><font color="#0000bb">$email</font><font color="#007700">))</p>
<p>   {</p>
<p>      list(</p>
<p></font><font color="#0000bb">$username</font><font color="#007700">,</font><font color="#0000bb">$domaintld</font><font color="#007700">) = </font><font color="#0000bb">split</font><font color="#007700">(</font><font color="#dd0000">&#8220;@&#8221;</font><font color="#007700">,</font><font color="#0000bb">$email</font><font color="#007700">);</p>
<p>      </p>
</p>
<p></font><font color="#0000bb">$valid </font><font color="#007700">= </font><font color="#0000bb">1</font><font color="#007700">;</p>
<p>   } else {</p>
<p>      </p>
<p></font><font color="#0000bb">$valid </font><font color="#007700">= </font><font color="#0000bb">0</font><font color="#007700">;</p>
<p>   }</p>
<p>   return </p>
</p>
<p></font><font color="#0000bb">$valid</font><font color="#007700">;</p>
<p>}</p>
<p>}</p>
</p>
<p></font><font color="#0000bb">?&gt;</font><br />
</code></div>
]]></content:encoded>
			<wfw:commentRss>http://www.shawngo.com/2008/04/php-mysql-connection-class/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Simple PHP Log-in script</title>
		<link>http://www.shawngo.com/2008/04/simple-php-log-in-script/</link>
		<comments>http://www.shawngo.com/2008/04/simple-php-log-in-script/#comments</comments>
		<pubDate>Sun, 13 Apr 2008 17:40:50 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://shawngo.com/wordpress/?p=37</guid>
		<description><![CDATA[This page submits to itself, queries a database, and either allows or denies the user access.
You must change the database information to your particular database. 


&#60;?php
// simple login script
// filename: login.php
   $form = &#8216;
    Simple Login Form&#60;br&#62;
       &#60;form action=&#8221;login.php&#8221; method=&#8221;post&#8221;&#62;
       &#60;input type=&#8221;text&#8221; name=&#8221;username&#8221;&#62;
       &#60;input type=&#8221;password&#8221; name=&#8221;password&#8221;&#62;
       &#60;input type=&#8221;submit&#8221; name=&#8221;submit&#8221; value=&#8221;submit this&#8221;&#62;
       &#60;/form&#62;
       &#8217;;
if(isset($_POST['submit'])){
    $hm = authenticate($_POST['username'], $_POST['password']);
    $hm2 = mysql_num_rows($hm);
    if($hm2 &#62; 0){
      echo &#8220;You are logged in&#8221;;
    }else{
      echo &#8220;username / password not valid&#60;br&#62;&#8221;;
      echo $form;
    }
}else{
    echo $form;
}
function authenticate($user, $pass){
    $user = str_replace(&#8220; &#8221;, &#8220;&#8221;, $user); //remove spaces
    $pass = str_replace(&#8220; &#8221;, &#8220;&#8221;, $pass); //remove spaces
    $user = str_replace(&#8220;%20&#8243;, &#8220;&#8221;, $user); //remove escaped spaces
    $pass = str_replace(&#8220;%20&#8243;, &#8220;&#8221;, $pass); //remove escaped spaces
    // add slashes to escape things like quotes and apostrophes
    // because they can be used to hijack SQL statements!
    $user = addslashes($user); //remove spaces from username
    $pass = addslashes($pass); //remove spaces from password
    // the function md5 creates a unique 32 character string,
    $pass = md5($pass);
    $request = &#8220;SELECT * FROM user WHERE password=&#8217;$pass&#8217; AND userName=&#8217;$user&#8217;&#8221;;
    // Pass the request to the mysql connection,
    $results = query_db($request);
    // if mysql returns any number of rows great than 0 there is a match
    return $results;
}
function query_db($query){
    $conn = mysql_connect(&#8220;localhost&#8221;, &#8220;your_username&#8221;, &#8220;your_password&#8221;);
    if (!$conn) {
        die(&#8216;Could not connecteeer: &#8217; . mysql_error());
    }
    mysql_select_db(&#8220;your_database&#8221;);
    $results = mysql_query($query, $conn);
    mysql_close($conn);
    return $results;
}
 ?&#62;


]]></description>
			<content:encoded><![CDATA[<p>This page submits to itself, queries a database, and either allows or denies the user access.</p>
<p>You must change the database information to your particular database. </p>
<div>
<p><code><font color="#000000"><br />
</font><font color="#0000bb">&lt;?php</font></code></p>
<p><font color="#ff8000">// simple login script</font></p>
<p>// filename: login.php</p>
<p>   <font color="#0000bb">$form </font><font color="#007700">= </font><font color="#dd0000">&#8216;</font></p>
<p>    Simple Login Form&lt;br&gt;</p>
<p>       &lt;form action=&#8221;login.php&#8221; method=&#8221;post&#8221;&gt;</p>
<p>       &lt;input type=&#8221;text&#8221; name=&#8221;username&#8221;&gt;</p>
<p>       &lt;input type=&#8221;password&#8221; name=&#8221;password&#8221;&gt;</p>
<p>       &lt;input type=&#8221;submit&#8221; name=&#8221;submit&#8221; value=&#8221;submit this&#8221;&gt;</p>
<p>       &lt;/form&gt;</p>
<p>       &#8217;<font color="#007700">;</font></p>
<p>if(isset(<font color="#0000bb">$_POST</font><font color="#007700">[</font><font color="#dd0000">'submit'</font><font color="#007700">])){</font></p>
<p>    <font color="#0000bb">$hm </font><font color="#007700">= </font><font color="#0000bb">authenticate</font><font color="#007700">(</font><font color="#0000bb">$_POST</font><font color="#007700">[</font><font color="#dd0000">'username'</font><font color="#007700">], </font><font color="#0000bb">$_POST</font><font color="#007700">[</font><font color="#dd0000">'password'</font><font color="#007700">]);</font></p>
<p>    <font color="#0000bb">$hm2 </font><font color="#007700">= </font><font color="#0000bb">mysql_num_rows</font><font color="#007700">(</font><font color="#0000bb">$hm</font><font color="#007700">);</font></p>
<p>    if(<font color="#0000bb">$hm2 </font><font color="#007700">&gt; </font><font color="#0000bb">0</font><font color="#007700">){</font></p>
<p>      echo <font color="#dd0000">&#8220;You are logged in&#8221;</font><font color="#007700">;</font></p>
<p>    }else{</p>
<p>      echo <font color="#dd0000">&#8220;username / password not valid&lt;br&gt;&#8221;</font><font color="#007700">;</font></p>
<p>      echo <font color="#0000bb">$form</font><font color="#007700">;</font></p>
<p>    }</p>
<p>}else{</p>
<p>    echo <font color="#0000bb">$form</font><font color="#007700">;</font></p>
<p>}</p>
<p>function <font color="#0000bb">authenticate</font><font color="#007700">(</font><font color="#0000bb">$user</font><font color="#007700">, </font><font color="#0000bb">$pass</font><font color="#007700">){</font></p>
<p>    <font color="#0000bb">$user </font><font color="#007700">= </font><font color="#0000bb">str_replace</font><font color="#007700">(</font><font color="#dd0000">&#8220; &#8221;</font><font color="#007700">, </font><font color="#dd0000">&#8220;&#8221;</font><font color="#007700">, </font><font color="#0000bb">$user</font><font color="#007700">); </font><font color="#ff8000">//remove spaces</font></p>
<p>    <font color="#0000bb">$pass </font><font color="#007700">= </font><font color="#0000bb">str_replace</font><font color="#007700">(</font><font color="#dd0000">&#8220; &#8221;</font><font color="#007700">, </font><font color="#dd0000">&#8220;&#8221;</font><font color="#007700">, </font><font color="#0000bb">$pass</font><font color="#007700">); </font><font color="#ff8000">//remove spaces</font></p>
<p>    <font color="#0000bb">$user </font><font color="#007700">= </font><font color="#0000bb">str_replace</font><font color="#007700">(</font><font color="#dd0000">&#8220;%20&#8243;</font><font color="#007700">, </font><font color="#dd0000">&#8220;&#8221;</font><font color="#007700">, </font><font color="#0000bb">$user</font><font color="#007700">); </font><font color="#ff8000">//remove escaped spaces</font></p>
<p>    <font color="#0000bb">$pass </font><font color="#007700">= </font><font color="#0000bb">str_replace</font><font color="#007700">(</font><font color="#dd0000">&#8220;%20&#8243;</font><font color="#007700">, </font><font color="#dd0000">&#8220;&#8221;</font><font color="#007700">, </font><font color="#0000bb">$pass</font><font color="#007700">); </font><font color="#ff8000">//remove escaped spaces</font></p>
<p>    // add slashes to escape things like quotes and apostrophes</p>
<p>    // because they can be used to hijack SQL statements!</p>
<p>    <font color="#0000bb">$user </font><font color="#007700">= </font><font color="#0000bb">addslashes</font><font color="#007700">(</font><font color="#0000bb">$user</font><font color="#007700">); </font><font color="#ff8000">//remove spaces from username</font></p>
<p>    <font color="#0000bb">$pass </font><font color="#007700">= </font><font color="#0000bb">addslashes</font><font color="#007700">(</font><font color="#0000bb">$pass</font><font color="#007700">); </font><font color="#ff8000">//remove spaces from password</font></p>
<p>    // the function md5 creates a unique 32 character string,</p>
<p>    <font color="#0000bb">$pass </font><font color="#007700">= </font><font color="#0000bb">md5</font><font color="#007700">(</font><font color="#0000bb">$pass</font><font color="#007700">);</font></p>
<p>    <font color="#0000bb">$request </font><font color="#007700">= </font><font color="#dd0000">&#8220;SELECT * FROM user WHERE password=&#8217;$pass&#8217; AND userName=&#8217;$user&#8217;&#8221;</font><font color="#007700">;</font></p>
<p>    <font color="#ff8000">// Pass the request to the mysql connection,</font></p>
<p>    <font color="#0000bb">$results </font><font color="#007700">= </font><font color="#0000bb">query_db</font><font color="#007700">(</font><font color="#0000bb">$request</font><font color="#007700">);</font></p>
<p>    <font color="#ff8000">// if mysql returns any number of rows great than 0 there is a match</font></p>
<p>    <font color="#007700">return </font><font color="#0000bb">$results</font><font color="#007700">;</font></p>
<p>}</p>
<p>function <font color="#0000bb">query_db</font><font color="#007700">(</font><font color="#0000bb">$query</font><font color="#007700">){</font></p>
<p>    <font color="#0000bb">$conn </font><font color="#007700">= </font><font color="#0000bb">mysql_connect</font><font color="#007700">(</font><font color="#dd0000">&#8220;localhost&#8221;</font><font color="#007700">, </font><font color="#dd0000">&#8220;your_username&#8221;</font><font color="#007700">, </font><font color="#dd0000">&#8220;your_password&#8221;</font><font color="#007700">);</font></p>
<p>    if (!<font color="#0000bb">$conn</font><font color="#007700">) {</font></p>
<p>        die(<font color="#dd0000">&#8216;Could not connecteeer: &#8217; </font><font color="#007700">. </font><font color="#0000bb">mysql_error</font><font color="#007700">());</font></p>
<p>    }</p>
<p>    <font color="#0000bb">mysql_select_db</font><font color="#007700">(</font><font color="#dd0000">&#8220;your_database&#8221;</font><font color="#007700">);</font></p>
<p>    <font color="#0000bb">$results </font><font color="#007700">= </font><font color="#0000bb">mysql_query</font><font color="#007700">(</font><font color="#0000bb">$query</font><font color="#007700">, </font><font color="#0000bb">$conn</font><font color="#007700">);</font></p>
<p>    <font color="#0000bb">mysql_close</font><font color="#007700">(</font><font color="#0000bb">$conn</font><font color="#007700">);</font></p>
<p>    return <font color="#0000bb">$results</font><font color="#007700">;</font></p>
<p>}</p>
<p> <font color="#0000bb">?&gt;</font>
</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.shawngo.com/2008/04/simple-php-log-in-script/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Old Ajax 4-Star Rating Script</title>
		<link>http://www.shawngo.com/2008/04/old-ajax-rating-script/</link>
		<comments>http://www.shawngo.com/2008/04/old-ajax-rating-script/#comments</comments>
		<pubDate>Sun, 13 Apr 2008 17:34:39 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

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

		<guid isPermaLink="false">http://shawngo.com/wordpress/?p=35</guid>
		<description><![CDATA[Ok. This needs updating!! This is how I did it back in 2005 or so.

What I&#8217;d rather this be&#8230;
First off, this script is poorly written! Get rid of the javascript inside the xhtml tags!! Say hello to behaviour.js!
Second of all, who uses document.getElementById() anymore??? Say hello to my little friend prototype.js
Third point, I already hate [...]]]></description>
			<content:encoded><![CDATA[<h2>Ok. This needs updating!! This is how I did it back in 2005 or so.</h2>
<div class="verbage">
<h2>What I&#8217;d rather this be&#8230;</h2>
<p>First off, this script is poorly written! Get rid of the javascript inside the xhtml tags!! Say hello to <a href="http://bennolan.com/behaviour/" title="Using CSS selectors to apply JavaScript Behaviours">behaviour.js</a>!</p>
<p>Second of all, who uses <code>document.getElementById()</code> anymore??? Say hello to my little friend <a href="http://prototype.conio.net/" title="Javascript Framework .. I call it a toolkit">prototype.js</a></p>
<p>Third point, I already hate the new style of the site <img src='http://www.shawngo.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So ya. I ought to update this script. But if you haven&#8217;t heard of the two scripts mentioned above, they&#8217;re well worth checking out! Makes writing this script a lot less painful!</p>
<p>I&#8217;d like feedback on this site but am too lazy to implement a site-wide, cool-a$$ Ajax comment widget. Unless someone is willing to provide on to me so they can tell me how bad some of these toot&#8217;s are :)) </p>
</div>
<p><!-- end msg --></p>
<div class="portfolio2"><b class="artop"></b><b style=" " class="re1"></b><b style=" " class="re2"></b><b style=" " class="re3"></b><b style=" " class="re4"></b></p>
<div class="headera"><b>Ajax Rating Script using Stars Tutorial</b> - 07-05-2006</div>
<div class="verbage">
<h2>Ajax / PHP Rating Script</h2>
<p>This is a neato little script I wrote for <a href="http://www.mealsanddeals.com/basha" title="Meals and Deals">Meals and Deals</a> to rate restaurants without refreshing the page.</p>
<p>I figured someone out there might get a kick out of it. Feel free to use it or even learn from it <img src='http://www.shawngo.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> A backlink would be nice but not necessary <img src='http://www.shawngo.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Ok - this was old and I decided to ditch it. I might resurrect it someday.</p>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.shawngo.com/2008/04/old-ajax-rating-script/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Ajax Rating Script using Thumbs Tutorial</title>
		<link>http://www.shawngo.com/2008/04/ajax-rating-script-using-thumbs-tutorial/</link>
		<comments>http://www.shawngo.com/2008/04/ajax-rating-script-using-thumbs-tutorial/#comments</comments>
		<pubDate>Sun, 13 Apr 2008 17:31:18 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

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

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

		<guid isPermaLink="false">http://shawngo.com/wordpress/?p=34</guid>
		<description><![CDATA[Thumber - Ajax / PHP Rating Script II
I made this script because I realized how awful my other Ajax Rating Script code looks!
This is a fairly light-weight, non-degradable  Ajax script for rating a specific item using the &#8220;Thumbs Up, Thumbs Down&#8221; approach.
The script uses the Prototype Javascript Framework to ligthen the load!
The script is [...]]]></description>
			<content:encoded><![CDATA[<h2>Thumber - Ajax / PHP Rating Script II</h2>
<p>I made this script because I realized how awful my other <a href="rating-script.php" title="Ajax Rating Script">Ajax Rating Script</a> code looks!</p>
<p>This is a fairly light-weight, non-degradable <img src='http://www.shawngo.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> Ajax script for rating a specific item using the &#8220;Thumbs Up, Thumbs Down&#8221; approach.</p>
<p>The script uses the <a href="http://prototype.conio.net/" title="Prototype Javascript Framework">Prototype Javascript Framework</a> to ligthen the load!</p>
<p>The script is also in object notation (<a href="http://www.dustindiaz.com/json-for-the-masses/" title="JSON for the masses">JSON</a>) style / function closure, using a Cookies object and Voter object explained below.</p>
<p>Here&#8217;s the <a href="http://www.shawngo.com/thumber/" title="Ajax Thumb Rating Script Example">Ajaxian thumb rate script example</a>.</p>
<p>I use <a href="http://bennolan.com/behaviour/" title="Using CSS to apply Javscript Behaviors">Behaviour.js</a> to set the onclick events outside of the markup. This sort of separation leads to unobtrusive, degradable javscript, which is pretty damn cool!</p>
<p><!-- end msg --></p>
<div class="headera">On to the script!</div>
<div class="verbage">
<p>Here is the XHTML for the page. The two images are controlled by the CSS. The anchor tags have an onclick event (handled by <code>myrules</code>)that fires <code>Voter</code>&#8217;s <code>vote()</code> function.</p>
<p>The input button is for demo only. When pressed, it erases the Cookie that is stored on the client, so you can vote one more time. This is simply for demonstrative purposes.</p>
<pre style="overflow: scroll;  color: rgb(0, 0, 85); width: 450px;">

&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/2001/REC-xhtml11-20010531/DTD/xhtml11-flat.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"&gt;
&lt;head&gt;
&lt;title&gt;Rating Script - Thumbs Up Thumbs Down | Shawngo.com&lt;/title&gt;
&lt;meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8"/&gt;

&lt;link type="text/css" href="thumber.css" rel="stylesheet" media="screen,projection"  title="Default Theme" /&gt;

&lt;script src="prototype.js" type="text/javascript"&gt;&lt;/script&gt;

&lt;script src="behaviour.js" type="text/javascript"&gt;&lt;/script&gt;

&lt;script type="text/javascript" src="voter.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="cookies.js"&gt;&lt;/script&gt;

&lt;script type="text/javascript"&gt;

// two event handlers .. thumberdown could actually call thumberup..etc
var myrules = {
  '.thumberup' : function(element){
	element.onclick = function(){
	  Voter.vote(this.id);
	  return false;
	}
  },
  '.thumberdown' : function(element){
	element.onclick = function(){
	  Voter.vote(this.id);
	  return false;
	}
  }
};

Behaviour.register(myrules);
&lt;/script&gt;

&lt;/head&gt;
&lt;body&gt;
&lt;div class="thumbs"&gt;
  &lt;span id="blog1.msg"&gt;Rate Me&lt;/span&gt;
  &lt;ul&gt;
	&lt;li class="up"&gt;&lt;a id="blog1.up" title="Thumbs Up" class="thumberup" href="fart.html"&gt;10&lt;/a&gt;&lt;/li&gt;

	&lt;li class="down"&gt;&lt;a id="blog1.down" title="Thumbs Down" class="thumberdown" href="fart.html"&gt;11&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;

&lt;div class="thumbs"&gt;
  &lt;span id="blog2.msg"&gt;Rate Me&lt;/span&gt;

  &lt;ul&gt;
	&lt;li&gt;&lt;a id="blog2.up" title="Thumbs Up" class="thumberup" href="fart.html"&gt;10&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a id="blog2.down" title="Thumbs Down" class="thumberdown" href="fart.html"&gt;11&lt;/a&gt;&lt;/li&gt;

  &lt;/ul&gt;
&lt;/div&gt;

&lt;div id="result"&gt;&lt;/div&gt;
&lt;p&gt;&lt;input type="button" onclick="Cookies.erase('blog1');" value="Erase cookie"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;input type="button" onclick="Cookies.erase('blog2');" value="Erase cookie"/&gt;&lt;/p&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
</div>
<p><!-- end msg --></p>
<div style="padding-top: 0pt; padding-bottom: 0pt;" class="portfolio2"><b class="artop"></p>
<div class="headera">The CSS!</div>
<div class="verbage">
<p>Nothing fancy here. Just padding out the anchor tag to fit the image and setting font attributes.</p>
<pre style="overflow: scroll;  color: rgb(0, 0, 85); width: 450px;">.thumbs{
font-family: "Trebuchet MS";
font-size:15px;
font-weight:bold;
border: 3px solid #eee;
padding:0 5px 10px 5px;
width:150px;
text-align:center;
}
.thumbs ul{
padding:0;
margin:0;
}
.thumbs ul li{
display:inline;
}
.thumbs a{
text-decoration:none;
padding:0 5px;
border: 3px solid #feb;
}
a.thumberup{
background:url(up.jpg) top right no-repeat;
padding-right:20px;
}
a.thumberdown{
background:url(down.jpg) top left no-repeat;
padding-left:20px;
}
.thumbs a:hover{
border: 3px solid #feb300;
}
</pre>
</div>
<p><!-- end msg --></p>
<div class="headera">The javascript!</div>
<div class="verbage">
<p>The <code>Voter</code> Class in <a href="thumber/voter.js" title="Thumber Script file">voter.js</a>.</p>
<p>Clicking on the link, which fires <code>onclick = "Voter.vote('blog1.up');"</code>, determines if there is a cookie set for this <i>widget</i>.</p>
<p>If not, the request parameters, <code>pars</code>, are sent to Prototype&#8217;s <code>Ajax.Request</code> function.</p>
<p>Otherwise, a message is sent to the client that they have voted.</p>
<p>When the function is complete, it calls <code>Voter.showResponse</code> function which could either substitue for <code>$(what_in).innerHTML = parseInt($(what_in).innerHTML)+1;</code> this line. We could return all sorts of information to relay to the user, but that is beyond the scope of this tutorial. Don&#8217;t you hate that?</p>
<pre style="overflow: scroll;  color: rgb(0, 0, 85); width: 450px;">Voter = {
vote : function(what_in){
    var what = what_in.substring(0,what_in.indexOf("."));
    var up_down = what_in.substring(what_in.indexOf(".")+1,what_in.length);

    var voted = Cookies.read(what);
    if(voted == null){
	$(what_in).innerHTML = parseInt($(what_in).innerHTML)+1;
	this.voted=true;
	pars="vote="+up_down+"&#038;what="+what;
	Cookies.create(what,"voted",1);
	var myAjax = new Ajax.Request( 'vote.php', { method: 'get', parameters: pars, onComplete: this.showResponse })
    }else{
	$(what+'.msg').innerHTML="You already voted";
    }
  },
  showResponse : function(originalRequest){
	$('result').innerHTML = originalRequest.responseText;
  }
}
</pre>
<p>The message sent to the client can also be split into an array. This could be useful for updating several different parts of the page.</p>
<p>To do this in the PHP script, simply separate the response with a bar |, example <code> echo $response1."|".$response2;</code>.</p>
<div style=" color: rgb(0, 0, 85);">
  showResponse : function(originalRequest){</p>
<p>	$(&#8217;result&#8217;).innerHTML = originalRequest.responseText.split(&#8221;|&#8221;)[0];<br />
	$(&#8217;some_other_element&#8217;).innerHTML = originalRequest.responseText.split(&#8221;|&#8221;)[1];<br />
  }
</p>
</div>
</div>
<p><!-- end msg --></p>
<div class="headera">The javascript!</div>
<div class="verbage">
<p>The <code>Cookies</code> Class in <a href="thumber/cookies.js" title="Cookies Script file">cookies.js</a>.</p>
<p>This is a basic javascript cookie utility class. I found it online and just rewrote it using Object Notation.</p>
<pre style="overflow: scroll;  color: rgb(0, 0, 85); width: 450px;">Cookies = {
  create : function (name,value,days){
    if (days){
      var date = new Date();
      date.setTime(date.getTime()+(days*24*60*60*1000));
      var expires = "; expires="+date.toGMTString();
    }else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
  },

  read : function read(name){
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i &lt; ca.length;i++){
      var c = ca[i];
      while (c.charAt(0)==' ') c = c.substring(1,c.length);
	if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
      }
      return null;
  },

  erase : function (name){
    this.create(name,"",-1);
  }
}
</pre>
</div>
<p><!-- end msg --></p>
<div class="headera">The PHP!</div>
<div class="verbage">
<p>I didn&#8217;t do very much on the PHP-side. This just returns the <code>$_GET</code> variables for demonstrative purposes.</p>
<p>This script was intented to be used wherever you want. Just assign the name of the item in the 2nd parameter when calling Voter.vote().</p>
<p>You&#8217;ll also need to use PHP (or whichever server-side language you choose) to set the initial value for &#8216;number of votes&#8217;. For this tutorial I have the example set to 10 for both.</p>
<p>Ideally you&#8217;d write a simple database query function with a bit of error checking for fun.</p>
<pre style="overflow: scroll;  color: rgb(0, 0, 85); width: 450px;">&lt;?

// do database stuff here

// i threw this in here for fun
print_r($_GET);

// you could also send multiple responses separated by, oh, say, a
// then split the response in the javascript.. demonstrated

?&gt;
</pre>
</div>
<p></b></div>
]]></content:encoded>
			<wfw:commentRss>http://www.shawngo.com/2008/04/ajax-rating-script-using-thumbs-tutorial/feed/</wfw:commentRss>
		</item>
		<item>
		<title>HTACCESS Wrappers Tutorial</title>
		<link>http://www.shawngo.com/2008/04/htaccess-wrappers-tutorial/</link>
		<comments>http://www.shawngo.com/2008/04/htaccess-wrappers-tutorial/#comments</comments>
		<pubDate>Sun, 13 Apr 2008 07:37:17 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://shawngo.com/wordpress/?p=29</guid>
		<description><![CDATA[Instead of naming your PHP .php, you have the option of keeping the file extension as .html or .htm.
This only takes a few lines of code in the .htacces file, and a few more lines of code in the PHP script that runs the show.
Here is the code for the .htaccess file:
AddHandler pagex.htmAddHandler pagex.htmlAction pagex/page.php
The [...]]]></description>
			<content:encoded><![CDATA[<p>Instead of naming your <a href="http://www.php.net" title="PHP Manual">PHP</a> .php, you have the option of keeping the file extension as .html or .htm.</p>
<p>This only takes a few lines of code in the .htacces file, and a few more lines of code in the PHP script that runs the show.</p>
<p>Here is the code for the .htaccess file:</p>
<p><code>AddHandler pagex.htm<br />AddHandler pagex.html<br />Action pagex/page.php</code></p>
<p>The first two lines tell <a href="http://www.apache.org" title="Apache Web Server">Apache</a> to designate files of type .htm or .html to a type called &#8216;pagex&#8217;.</p>
<p>The last line instructs the web server to execute the page.php script when either of the files listed above are requested.</p>
<p>The path is relative, so if the script was in directory http://www.example.com/scripts/page.php, the line would read <code>Action pagex /scripts/page.php</code></p>
<h3>Now the magic&#8230;</h3>
<p>In this tutorial we will identify the name of the file being requested, and serve the relevant content (wrapped in <b>valid XHTML</b> of course!).</p>
<p>The following is the code for <code>page.php</code>:</p>
<div style="background-color: rgb(255, 255, 255);">
<code><font color="#000000"></p>
<p><font color="#0000bb">&lt;?php</p>
<p>$file </font><font color="#007700">= </font><font color="#0000bb">$_SERVER</font><font color="#007700">[</font><font color="#dd0000">"PATH_INFO"</font><font color="#007700">];</p>
<p>switch(</font><font color="#0000bb">$file</font><font color="#007700">){</p>
<p>  case </font><font color="#dd0000">&#8220;/index.html&#8221;</font><font color="#007700">:</p>
<p>    include(</font><font color="#dd0000">&#8216;index.php&#8217;</font><font color="#007700">);</p>
<p>    break;</p>
<p>  case </font><font color="#dd0000">&#8220;/shawngo.html&#8221;</font><font color="#007700">:</p>
<p>      include(</font><font color="#dd0000">&#8217;shawngo.php&#8217;</font><font color="#007700">);</p>
<p>    break;</p>
<p>}</p>
<p></font><font color="#0000bb">?&gt;</font><br />
</font><br />
</code></div>
<p><code>$file = $_SERVER["PATH_INFO"];</code> returns the file name of the requested file in the form &#8220;/filename.html&#8221;. We could do some fancy string work, but that is out of scope.</p>
<p>The <code>switch statement</code> <i>switches</i> on <code>$file</code> and the corresponding .php file is included using the <code>include</code> statements.</p>
<p>Here is an example of the index.php file:</p>
<div style="background-color: rgb(255, 255, 255);">
<code><font color="#000000"><br />
<font color="#0000bb">&lt;?php</p>
<p></font><font color="#ff8000">// define a few variables</p>
<p></font><font color="#0000bb">$title</font><font color="#007700">=</font><font color="#dd0000">&#8220;Web Development is Fun!&#8221;</font><font color="#007700">;</p>
<p></font><font color="#0000bb">$description </font><font color="#007700">= </font><font color="#dd0000">&#8220;PHP Scripts, Google Maps API Tutorials And More!&#8221;</font><font color="#007700">;</p>
<p></font><font color="#0000bb">$keywords </font><font color="#007700">= </font><font color="#dd0000">&#8220;KML, Google Maps API, Tutorials&#8221;</font><font color="#007700">;</p>
<p></font><font color="#0000bb">?&gt;</p>
<p></font></p>
<p>&lt;!DOCTYPE html PUBLIC &#8220;-//W3C//DTD XHTML 1.1//EN&#8221;</p>
<p>&#8220;http://www.w3.org/TR/2001/REC-xhtml11-20010531/DTD/xhtml11-flat.dtd&#8221;&gt;</p>
<p>&lt;html xmlns=&#8221;http://www.w3.org/1999/xhtml&#8221; xml:lang=&#8221;en&#8221;&gt;</p>
<p>&lt;head&gt;</p>
<p>&lt;title&gt;<font color="#0000bb">&lt;?=$title?&gt;</font>&lt;/title&gt;</p>
<p>&lt;meta http-equiv=&#8221;Content-Type&#8221; content=&#8221;text/xml; charset=iso-8859-1&#8243; /&gt;</p>
<p>&lt;meta name=&#8221;description&#8221; content=&#8221;<font color="#0000bb">&lt;?=$description?&gt;</font>&#8221; /&gt;</p>
<p>&lt;meta name=&#8221;keywords&#8221; content=&#8221;<font color="#0000bb">&lt;?=$keywords?&gt;</font>&#8221; /&gt;</p>
<p>&lt;meta name=&#8221;title&#8221; content=&#8221;<font color="#0000bb">&lt;?=$title?&gt;</font>&#8221; /&gt;</p>
<p>&lt;/head&gt;</p>
<p>&lt;body&gt;</p>
<p>&lt;div id=&#8221;wrapper&#8221;&gt;</p>
<p>  &lt;h1&gt;Hello World&lt;/h1&gt;</p>
<p>&lt;/div&gt;</p>
<p>&lt;/body&gt;</p>
<p>&lt;/html&gt;</font><br />
</code>				</div>
<h3>Wasn&#8217;t That Fun?</h3>
<p>There are many different applications for this type of modifications. This offers the ability to <b>insert ads into the header or footer</b> of any or all pages of your webste. This is how some of the free hosts add advertising to the free websites they host.</p>
<p>My most recent application of this obfuscation is <a href="http://www.iseeyoumarketing.com" title="Chicago Advertising">I See You Marketing</a> where all the html pages are served up this way.</p>
<h2>Have fun and share your code! <img src='http://www.shawngo.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </h2>
]]></content:encoded>
			<wfw:commentRss>http://www.shawngo.com/2008/04/htaccess-wrappers-tutorial/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
