<?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>Feet Have Been &#187; Concepts</title>
	<atom:link href="http://wheremy.feethavebeen.com/category/tutorials/concepts/feed/" rel="self" type="application/rss+xml" />
	<link>http://wheremy.feethavebeen.com</link>
	<description>Sometimes, you just go where your feet take you</description>
	<lastBuildDate>Tue, 24 Jan 2012 17:39:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>Custom Select Element</title>
		<link>http://wheremy.feethavebeen.com/2010/08/custom-select-element/</link>
		<comments>http://wheremy.feethavebeen.com/2010/08/custom-select-element/#comments</comments>
		<pubDate>Mon, 16 Aug 2010 22:04:59 +0000</pubDate>
		<dc:creator>xangelo</dc:creator>
				<category><![CDATA[Concepts]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[dropdown]]></category>
		<category><![CDATA[element]]></category>
		<category><![CDATA[form]]></category>

		<guid isPermaLink="false">http://wheremy.feethavebeen.com/?p=475</guid>
		<description><![CDATA[Since the post on styling the input box I thought I&#8217;d post a another method to create custom drop-down lists. Again, most browsers won&#8217;t let you do very much in the way of styling. IE lets you mess with scrollbars and gecko and webkit let you adjust line-heights and padding, but really, you are STILL [...]]]></description>
			<content:encoded><![CDATA[<p>Since the post on styling the input box I thought I&#8217;d post a another method to create custom drop-down lists. Again, most browsers won&#8217;t let you do very much in the way of styling. IE lets you mess with scrollbars and gecko and webkit let you adjust line-heights and padding, but really, you are STILL left with the default select. However, utilizing some html, css and JavaScript (through jQuery) we can have our own pretty nifty looking drop down. This is part of a UI suite I&#8217;m hoping to work on called Clair. </p>
<div id="attachment_481" class="wp-caption aligncenter" style="width: 310px"><a href="http://wheremy.feethavebeen.com/wp-content/uploads/2010/08/all-browser.png"><img src="http://wheremy.feethavebeen.com/wp-content/uploads/2010/08/all-browser-300x260.png" alt="" title="Custom dropdown" width="300" height="260" class="size-medium wp-image-481" /></a><p class="wp-caption-text">Custom Dropdown</p></div>
<p>The functionality of our drop-down will mimic that of a regular dropdown box with one exception. Since we can not style the scrollbar, our drop-down will never display one. Instead, it will just keep expanding as you add new links. </p>
<p><strong>HTML</strong><br />
To start off with, our select needs a few different elements to work properly. First off, we need a container that will hold our select. We will also require a list of elements that we want to appear when you click the drop-down. Finally, we need a default element to hold the current selected item and an arrow to signify that we can click on it to display more options. I&#8217;ve assigned the classes and Id&#8217;s to the elements as necessary. <code>clair-select-active</code> is the default item that will be displayed as well as what is displayed when an element is clicked on.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;div class=&quot;clair-select-container&quot;&gt;
  &lt;div class=&quot;clair-select&quot;&gt;
    &lt;div id=&quot;clair-select-active&quot;&gt;Where My.Feet Have Been&lt;/div&gt;
    &lt;ul class=&quot;clair-select-links&quot;&gt;
      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Nookish&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Orange Pine Co&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Where My.Feet Have Been&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Your Website&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/div&gt;
&lt;/div&gt;</pre></div></div>

<p><strong>CSS</strong><br />
Before we get to the clair specific styles, these are the default ones applied to the entire page:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">body<span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> Arial<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span> 
  <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">normal</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">14pt</span><span style="color: #00AA00;">;</span> 
  <span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'bg.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> 
  <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
a <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#CCC</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>The first style we get is the <code>clair-select</code> and the <code>clair-select-container</code> These style our entire select container.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">.clair-select-container<span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span> <span style="color: #933;">0px</span> <span style="color: #933;">40px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.clair-select</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span> 
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#CCC</span><span style="color: #00AA00;">;</span>
  -moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span><span style="color: #00AA00;">;</span>
  -webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span><span style="color: #00AA00;">;</span>
  -o-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span><span style="color: #00AA00;">;</span>
  -khtml-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span><span style="color: #00AA00;">;</span>
  border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span> <span style="color: #933;">12px</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">14px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> inline-<span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#555</span><span style="color: #00AA00;">;</span> 
  <span style="color: #000000; font-weight: bold;">border-width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #933;">0px</span> <span style="color: #933;">0px</span> <span style="color: #933;">1px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">230px</span><span style="color: #00AA00;">;</span>
  -moz-box-sizing<span style="color: #00AA00;">:</span> border-box<span style="color: #00AA00;">;</span>
  box-sizing<span style="color: #00AA00;">:</span> border-box<span style="color: #00AA00;">;</span>
  opacity<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0.7</span><span style="color: #00AA00;">;</span>
  filter<span style="color: #00AA00;">:</span> alpha<span style="color: #00AA00;">&#40;</span>opacity <span style="color: #00AA00;">=</span> <span style="color: #cc66cc;">70</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">z-index</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">2</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>The purpose of <code>clair-select-container</code> is to make sure when we expand our select dropdown it doesn&#8217;t push elements out of the way. Instead of floats nicely above them, and our slight opacity setting will display a faint outline of what it&#8217;s coverting. </p>
<p>There is a lot of vendor specific styling going on in <code>clair-select</code>, but the only one that I think warrants explanation is <code>box-sizing</code> and <code>filter</code>. </p>
<ul>
<li><code>box-sizing</code>: is a CSS3 spec that allows us to change the way that the browser interprets the &#8220;box-model&#8221; I&#8217;ll have to do another post to fully explain the box-model, but essentially it is the difference between including padding and border sizes within the &#8220;width&#8221; element, or adding it on afterwards. This forces Firefox to render the box-model the way Internet Explorer would  <a class="simple-footnote" title="The IE way, takes your width and keeps your content that size, and adds borders and padding within it" id="return-note-475-1" href="#note-475-1"><sup>1</sup></a>. </li>
<li><code>filter</code>: is a <a href="http://msdn.microsoft.com/en-us/library/ms532847(VS.85).aspx">Microsoft proprietary spec</a> that allows us to use a number of IE only effects. The particular effect I am utilizing is alpha-blending which allows us to change the opacity of the element. I&#8217;ve turned the opacity done just a little so that things are still readable, while allowing us to see the background. This has the added benefit of a neat visual effect whereby it looks like our element is slightly inset.</li>
</ul>
<p>The next style we&#8217;re going to add is that of the active element. All we do here is add the arrow as a background image and position it to appear on the right side of the element.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#clair-select-active</span><span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'down.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> 
  <span style="color: #000000; font-weight: bold;">background-repeat</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Finally, we&#8217;re going to style all the links. Nothing too fancy here. We&#8217;re just getting rid of bullets, spacing everything out a little and treating the anchor tags as block elements within our li&#8217;s.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.clair-select-links</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span> 
  <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span> <span style="color: #933;">0px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.clair-select-links</span> li<span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.clair-select-links</span> li a<span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">normal</span><span style="color: #00AA00;">;</span> 
  <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.clair-select-links</span> li a<span style="color: #3333ff;">:hover</span><span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#282828</span><span style="color: #00AA00;">;</span>
  -moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">8px</span><span style="color: #00AA00;">;</span>
  -webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">8px</span><span style="color: #00AA00;">;</span>
  -o-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">8px</span><span style="color: #00AA00;">;</span>
  -khtml-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">8px</span><span style="color: #00AA00;">;</span>
  border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">8px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#DDD</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p><strong>JavaScript</strong><br />
To add functionality to our drop-down we need a bit of JavaScript. I&#8217;m utilizing jQuery, but your own JavaScript library should have similar functions. We need to add two kinds of functionality. </p>
<ol>
<li>We need to switch between minimized and maximized states whenever a user clicks on the <code>clair-select-active</code> element.</li>
<li>We need to switch to minimized and populate <code>clair-select-active</code> with the text from the menu item</li>
</ol>

<div class="wp_syntax"><div class="code"><pre class="js" style="font-family:monospace;">$(document).ready(function(e) {
  // This is just for cross-browser prettiness
  $('#clair-select-active').css('cursor','pointer');
&nbsp;
  // This will toggle everything as necessary
  $('#clair-select-active').click(function(e) {
    if($('.clair-select-links').css('display') == 'block') {
      $('.clair-select-links').slideUp(); 
    }
    else {
      $('.clair-select-links').slideDown();
    }
  });
&nbsp;
  // This will populate clair-select-active with whatever you click on
  $('.clair-select-links a').click(function(e) {
    e.preventDefault(); 
    $('#clair-select-active').html($(this).html()); 
    $('.clair-select-links').slideUp(); 
  });
});</pre></div></div>

<p>And that&#8217;s it, you&#8217;ve built a custom select drop-down. With a little JavaScript trickery, we can even go so far as to include it within forms. We&#8217;d just need a hidden form element and then when we populate <code>clair-select-active</code> we would also populate the value attribute of our form element.</p>
<p>This solution works in the following scenarios: </p>
<ul>
<li>IE 7+</li>
<li>Firefox 3.5+</li>
<li>Chrome 3+</li>
<li>Opera 10+</li>
</ul>
<p>You can download all the files used in this tutorial here: <a href='http://wheremy.feethavebeen.com/wp-content/uploads/2010/08/custom-select.zip'>Custom Select Files</a></p>
<div class="simple-footnotes"><p class="notes">Notes:</p><ol><li id="note-475-1">The IE way, takes your width and keeps your content that size, and adds borders and padding within it <a href="#return-note-475-1">&#8617;</a></li></ol></div>]]></content:encoded>
			<wfw:commentRss>http://wheremy.feethavebeen.com/2010/08/custom-select-element/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Model &#8211; View &#8211; Controller</title>
		<link>http://wheremy.feethavebeen.com/2010/06/model-view-controller/</link>
		<comments>http://wheremy.feethavebeen.com/2010/06/model-view-controller/#comments</comments>
		<pubDate>Fri, 25 Jun 2010 19:45:50 +0000</pubDate>
		<dc:creator>xangelo</dc:creator>
				<category><![CDATA[Concepts]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://wheremy.feethavebeen.com/?p=377</guid>
		<description><![CDATA[The Model-View-Controller (MVC) paradigm of programming is one that is often misused by most developers because it is simply the least understood. When reading tutorials on MVC principles most developers will launch right into the code, which is easy to follow for the purpose of the tutorial. But when those same users try and do [...]]]></description>
			<content:encoded><![CDATA[<p>The Model-View-Controller (MVC) paradigm of programming is one that is often misused by most developers because it is simply the least understood. When reading tutorials on MVC principles most developers will launch right into the code, which is easy to follow for the purpose of the tutorial. But when those same users try and do it themselves, they find out that it&#8217;s a lot harder than it seems. This post aims to correct that by explaining the principles behind the MVC framework and the pro&#8217;s and con&#8217;s of using it.</p>
<p>In web development, every page will have it&#8217;s own Model, View and Controller. This is to ensure that only the information you are requesting is loaded. A lot of those new to the MVC approach will attempt to create a master controller which will then delegate this information to each Model as requested. In MVC, this approach doesn&#8217;t quite work. By creating separate entities for each requested page you will find that not only is it easier to maintain and update, but that MVC isn&#8217;t that hard to understand at all.</p>
<p><strong>The Big Picture<br />
</strong>The easiest way to understand MVC is to step back and look at the whole picture in terms of real-life. In this example, our Controller is going to be the Librarian, the Model is going to be the Library Catalogue and the View is going to be a Book. A user will come up to the Librarian and say &#8220;Hey, do you have Book XYZ?&#8221; The Librarian of course has no idea. It&#8217;s not their job to know where each Book is, but simply to know where to find the information that you are requesting. Regardless of what you are requesting the Librarian will look through a Library Catalogue, but they may look in different kinds of Catalogues. For example, if you say &#8220;Hey, do you have the Horror Book XYZ?&#8221; they can ignore every other category except Horror. Likewise if you say &#8220;Hey, do you have the Romance Book XYZ?&#8221; they can ignore every other category except Romance.</p>
<p><strong>The Pieces of the Puzzle &#8211; The Controller<br />
</strong>The Controller the is the primary building block of an MVC system. Everything you build is managed by the Controller (it Controls see? Programmers love these little word games). The Controller figures out what the user is trying to do and accordingly it goes through the appropriate Model and returns those results to the appropriate View. You can think of the Controller as a messenger. Basically when the user visits a page they are saying &#8220;I would like to see the [Gallery] page&#8221;. The Gallery Controller will see this and go right over to the GalleryModel and say &#8220;The user has requested this information&#8221;. It then waits for GalleryModel to respond, and then it takes those results and runs over to GalleryView and goes &#8220;Pretty this up&#8221;. It then shows you the prettied-up version.</p>
<p><strong>The Model<br />
</strong>The Model is also known as your Data Manipulation layer. This should contain functions that interface with the database. Insertion, Updating and Deletion should all occur here, with the results of each passed back to the caller. This centralizes all your DB calls to a single file for a single controller. In this way you know that modifying your &#8220;Gallery&#8221; table means only modifying your GalleryModel and GalleryView. It doesn&#8217;t seem like a big issue to inter-twine your database manipulation and controller at this stage simply because it isn&#8217;t. Of course you can integrate your Model directly with the Controller, but by segmenting these you can ensure a much easier re-use of code. Think about it this way &#8211; a gallery model can be copied and modified a little to turn it into a blog model. Since the Model doesn&#8217;t care about what to DO with the fields, you just need to update what fields it SHOULD be dealing with.</p>
<p><strong>The View<br />
</strong>The View is the easiest piece to explain. It simply acts as a display mechanism. It accepts some values from the Controller, mixes it with HTML and spits the result back to the controller. Think of it is a node-based theme engine. For example, you could have a function in your GalleryView that just accepted the URL of a thumbnail and added some HTML which, when styled, made it resemble a Polariod. At a later point in time, if you want to change this, modifying this single function will ensure that everything is changed uniformly.</p>
<p><strong>The Big Picture &#8211; Now with the right words<br />
</strong>So now we can revisit our Librarian and ask for a new book. We ask the LibraryController for &#8220;Horror book XYZ&#8221;. The LibraryController invokes the LibraryModel and executes the findBook() function passing it the genre (horror) and book name (XYZ). The LibraryModel executes a quick Database Query to figure out the results. Just so happens there are 5 books in that genre that contain XYZ (XYZ, WXYZ, AXYZ, XYZZ, XXYZ). It passes the result set BACK to LibraryController. LibraryControlled takes the result set and invokes LibraryView, calling the formatBookList() function using the result set as the argument. formatBookList() adds some HTML mockup to each entry and makes everything look good and then passes the HTML back to LibraryController. LibraryController shows you the result.</p>
<p><strong>Variations<br />
</strong>Some descriptions of MVC will modify it so that the Controller ignores the view and instead the Model is what passes the data to the View. Either way still conforms with MVC standards, which really just involve separting everything.</p>
<p><strong>Advanced Concepts</strong></p>
<p><strong><br />
Routers<br />
</strong>When dealing with server-side languages on the web we have to remember that things don&#8217;t work the same as in a desktop environment. Event-driven programming may work fine for C# and Java, but doesn&#8217;t work the same way for PHP. In PHP, our equivalent fo Event-driven programming would be URL-based programming. An &#8220;event&#8221; as far as PHP is concerned, is the user trying to visit a page. This page should trigger some kind of action. In most MVC frameworks (all I would think), you get something called a &#8220;Router&#8221;. This Router class is essentially a way of registering URLS to certain Controllers. For example visiting www.example.com/gallery/view/48 would cause the Router (or page that invokes the Router) to invoke the GalleryController and make a call to the view() function passing it 48 as an argument. In this way they abstract away explicitly invoking galleryies and can have a single index.php page which invokes the Router and makes the calls as necessary.</p>
<p><strong>Multiple Inheritance<br />
</strong>While PHP doesn&#8217;t allow for Multiple inheritance (ie GalleryController extends c1, c2, c3) it does allow for cascading inheritance (GalleryController extends c3; c3 extends c2; c2 extends c1; and now GalleryController can do everything c1, c2 and c3 can). Because of this we can actually speed up our Model/Controller creation by extending a singple base Model or Controller class. These classes would ideally have common functions that all Models or Controllers could potentially need at some point. One example would be to force all Models to inherit from BaseModel which could be a custom created Database Manipulation functions that all Models would need.</p>
]]></content:encoded>
			<wfw:commentRss>http://wheremy.feethavebeen.com/2010/06/model-view-controller/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Aggro Detection with Javascript</title>
		<link>http://wheremy.feethavebeen.com/2009/12/aggro-detection-with-javascript/</link>
		<comments>http://wheremy.feethavebeen.com/2009/12/aggro-detection-with-javascript/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 14:00:35 +0000</pubDate>
		<dc:creator>xangelo</dc:creator>
				<category><![CDATA[Concepts]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://wheremy.feethavebeen.com/?p=358</guid>
		<description><![CDATA[So you want to make some games? Sure it sounds easy, but until you dive into it you&#8217;ll never notice all the little things that go into the backend of it that make or break your game. While this isn&#8217;t as big a deal in current browser-based games (they&#8217;re either muds, flash or static maps) [...]]]></description>
			<content:encoded><![CDATA[<p>So you want to make some games? Sure it sounds easy, but until you dive into it you&#8217;ll never notice all the little things that go into the backend of it that make or break your game. While this isn&#8217;t as big a deal in current browser-based games (they&#8217;re either muds, flash or static maps) things are changing in the browser. Everything is getting faster, and things like javascript based animation is actually feasible! So what is an aspiring game developer to do except buckle in and start programming their games?</p>
<p>Once you begin researching you&#8217;ll notice that while a lot of browser-based text games take into account Collision detection, they seem to be missing Aggro detection. Aggro stands for either aggravation or aggression and is essentially a way to tell if a monster will attack you or not.. As you&#8217;ve probably noticed some monsters tend to rush at you from across the map, while others seem to completely ignore you until you attack them. This is Aggro.</p>
<p>One of the easiest ways to detect aggro is to simply add a variable to your monsters to signify &#8220;sight&#8221;. This sight variable will dictate how far away you need to be before a monster will attack you. Set this to 100 to have a monster rush at you from across your map or set it to 0 so that it will never attack unless you attack first.</p>
<p>Detection aggro is as simple as following two formula&#8217;s. The first will be to figure out the distance between you and the monster and the second will simply be a quick check to see if you fall within the monsters aggro radius. To start off, you need to grab the <a href="http://www.jquery.com">jQuery</a> javascript framework. While you CAN do this from scratch, jQuery lets you do it a lot easier, plus you can probably add a bit more jazz to your current game if you&#8217;re not already using it. If you&#8217;re unsure of how jQuery works, take a look at our quick <a href="http://wheremy.feethavebeen.com/2009/11/jquery-primer-an-intro-to-client-side-functionality/">intro to jQuery</a> or just check out the <a href="http://docs.jquery.com/Main_Page">jQuery documentation</a>. Now just cobble together a quick webpage and include the jQuery library. I&#8217;m using the minified version 1.3.2 of jQuery, so if you&#8217;re not using the same one, make sure you replace that line.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;html&gt;
&lt;head&gt;
	&lt;title&gt;Collision Detection&lt;/title&gt;
	&lt;style type=&quot;text/css&quot;&gt;
	table#grid{
		border-style: solid; 
		border-width: 0px 1px 1px 0px; 
		border-color: #CCC; 
		padding: 0px;
	}
	table#grid tr th{
		border-style: solid; 
		border-width: 1px 0px 0px 1px; 
		border-color: #CCC; 
		text-align: center; 
		color: #333; 
		font-size: 0.7em; 
		font-weight: bold; 
		font-family: &quot;Arial&quot;;
		background-color: #EDEDED;
	}
	table#grid tr th.run{
		width: 12px;
	}
	table#grid tr td{
		width: 50px; 
		height: 50px; 
		border-style: solid; 
		border-width: 1px 0px 0px 1px; 
		border-color: #CCC; 
		text-align: center; 
		color: #E0E0E0; 
		font-size: 0.7em; 
		font-weight: normal; 
		font-family: &quot;Arial&quot;;
	}
	table#grid tr td:hover{
		color: #333;
		background-color: #F3F3F3;	
	}
	.player{
		background-color: #333; 
	}
	.monsterA{
		color: #333; 
		background-color: #AA0000;
	}
	div#debug{
		border-style: solid; 
		border-color: #333; 
		border-width: 1px; 
		float: right; 
		border-color: #EDEDED;
		text-align: left; 
		color: #333; 
		font-size: 0.9em; 
		font-weight: normal; 
		font-family: &quot;Arial&quot;;
		width: 300px; 
		padding: 10px;
	}
	.monsterN{
		background-color: #00AA00;
	}
	&lt;/style&gt;
	&lt;script type=&quot;text/javascript&quot; src=&quot;jquery-1.3.2.min.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&nbsp;
&lt;/body&gt;
&lt;/html&gt;</pre></div></div>

<p>You&#8217;ll notice a bunch of CSS in there, but you can ignore that. It&#8217;s pretty straight forward and really it&#8217;s just meant to pretty things up a little. Now we&#8217;re going to add a quick grid so that you can get an easy visual representation of where you are and where your monsters are and if they will aggro or not. You can copy and paste the following line a few times, and change the y coordinate (x,y) to match which row you&#8217;re on.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;tr&gt;
	&lt;td&gt;0,1&lt;/td&gt;&lt;td&gt;1,1&lt;/td&gt;&lt;td&gt;2,1&lt;/td&gt;&lt;td&gt;3,1&lt;/td&gt;&lt;td&gt;4,1&lt;/td&gt;&lt;td&gt;5,1&lt;/td&gt;&lt;td&gt;6,1&lt;/td&gt;&lt;td&gt;7,1&lt;/td&gt;&lt;td&gt;8,1&lt;/td&gt;&lt;td&gt;9,1&lt;/td&gt;
&lt;/tr&gt;</pre></div></div>

<p>Finally, I&#8217;ve just added a &#8220;debug&#8221; section, so you can get a textual representation of what&#8217;s going on. It&#8217;s just a div placed above the grid.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;debug&quot;&gt;
	&lt;b&gt;Debug&lt;/b&gt;&lt;br&gt;&lt;br&gt;
&lt;/div&gt;</pre></div></div>

<p><strong>The Code</strong><br />
Now for the code that will give us a visual representation of our player and our monsters. First off we are going to initiate a few variables that we will be using throughout our script. They&#8217;re pretty self explanatory.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> playerPlaced <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span> 
<span style="color: #003366; font-weight: bold;">var</span> monster <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> 
<span style="color: #003366; font-weight: bold;">var</span> player <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Now we&#8217;re going to set it up so that when we click a square it will check if our player is already placed or not. If he is NOT placed, then we are going to place him and update our &#8220;debug&#8221; section.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#grid tr td'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> distance<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>playerPlaced<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	player<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'loc'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">','</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
	player<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'sight'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> 
	$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'@'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
	$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'player'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
	playerPlaced <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span> 
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#debug'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Player: '</span><span style="color: #339933;">+</span>player<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'loc'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">'&lt;br&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Notice that we&#8217;ve set player['sight'] to 0. Why? Simply because your player doesn&#8217;t have an aggro radius. He may or may not attack at your discretion, so it&#8217;s irrelevant. A monster however, will ALWAYS attack if you get within its aggro radius (assuming no other modifiers).</p>
<p>The next bit will just place our monsters if there is already a player on the field. When we do, however, we are going to call some functions that will take care of calculating distance and checking if the monster will aggro. We&#8217;ll go over those first, since they&#8217;re more complicated.</p>
<p><strong>Distance</strong><br />
To calculate the distance of two points we are simply going to take the x,y coordinates of both our monster and player and perform some math on them. The formula that we will be using is actually the distance formula between two points (and you wondered when you would ever use it&#8230;) and something that&#8217;s been drilled into us in every math class. The formula itself is a basically sqrt(sq(x1-x2)+sq(y1-y2)) so translating that to our game code it will look more like</p>
<p>sqrt(sq(player[x]-monster[x])+sq(player[y]-monster[y]))</p>
<p>The squaring and square rooting would take us a lot more work, if JavaScript didn&#8217;t already have those built in! Our actual distance formula in JavaScript (after being placed in a function) will look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> getDistance<span style="color: #009900;">&#40;</span>from<span style="color: #339933;">,</span>to<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	distance <span style="color: #339933;">=</span> Math.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span>Math.<span style="color: #660066;">sqrt</span><span style="color: #009900;">&#40;</span>Math.<span style="color: #660066;">pow</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>from<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-</span>to<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> Math.<span style="color: #660066;">pow</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>from<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-</span>to<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
	<span style="color: #000066; font-weight: bold;">return</span> distance<span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>Intersection</strong><br />
Basically intersection in our scenario will take a look at the player and see if he falls within the aggro radius of the monster. It&#8217;s a very simple check that just goes if (distance &lt; aggroRad) then it will aggro.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> willAggro<span style="color: #009900;">&#40;</span>aggro<span style="color: #339933;">,</span>distance<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>distance <span style="color: #339933;">&gt;</span> aggro<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span> 
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>Monster Insertion</strong><br />
Finally, we&#8217;re going to do our check to see if a monster will aggro a player or not depending on its distance to the player.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">monster<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'loc'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">','</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
monster<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'sight'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span> 
$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'X'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
distance <span style="color: #339933;">=</span> getDistance<span style="color: #009900;">&#40;</span>player<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'loc'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>monster<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'loc'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>willAggro<span style="color: #009900;">&#40;</span>monster<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'sight'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>distance<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'monsterA'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'monsterN'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#debug'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;b&gt;Monster:&lt;/b&gt; '</span><span style="color: #339933;">+</span>monster<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'loc'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#debug'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">' &lt;b&gt;Distance:&lt;/b&gt; '</span><span style="color: #339933;">+</span>distance<span style="color: #339933;">+</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#debug'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">' &lt;b&gt;Aggro:&lt;/b&gt; '</span><span style="color: #339933;">+</span>willAggro<span style="color: #009900;">&#40;</span>monster<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'sight'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>distance<span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">'&lt;br&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>And that&#8217;s all there is to it. If you run this page and take a look, you&#8217;ll notice that clicking a grid will place your player and clicking anywhere else will cause the monsters to appear in either green (if too far away to aggro) or red (if it will aggro). This is also noted in the debug section!</p>
<p>Here is our completed javascript section</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> playerPlaced <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span> 
	<span style="color: #003366; font-weight: bold;">var</span> monster <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> 
	<span style="color: #003366; font-weight: bold;">var</span> player <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#grid tr td'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> distance<span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>playerPlaced<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			player<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'loc'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">','</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
			player<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'sight'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> 
			$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'@'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
			$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'player'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
			playerPlaced <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span> 
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#debug'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Player: '</span><span style="color: #339933;">+</span>player<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'loc'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">'&lt;br&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
			monster<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'loc'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">','</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
			monster<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'sight'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span> 
			$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'X'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			distance <span style="color: #339933;">=</span> getDistance<span style="color: #009900;">&#40;</span>player<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'loc'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>monster<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'loc'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>willAggro<span style="color: #009900;">&#40;</span>monster<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'sight'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>distance<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'monsterA'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
				$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'monsterN'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#debug'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;b&gt;Monster:&lt;/b&gt; '</span><span style="color: #339933;">+</span>monster<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'loc'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#debug'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">' &lt;b&gt;Distance:&lt;/b&gt; '</span><span style="color: #339933;">+</span>distance<span style="color: #339933;">+</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#debug'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">' &lt;b&gt;Aggro:&lt;/b&gt; '</span><span style="color: #339933;">+</span>willAggro<span style="color: #009900;">&#40;</span>monster<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'sight'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>distance<span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">'&lt;br&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> getDistance<span style="color: #009900;">&#40;</span>from<span style="color: #339933;">,</span>to<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	distance <span style="color: #339933;">=</span> Math.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span>Math.<span style="color: #660066;">sqrt</span><span style="color: #009900;">&#40;</span>Math.<span style="color: #660066;">pow</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>from<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-</span>to<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> Math.<span style="color: #660066;">pow</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>from<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-</span>to<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
	<span style="color: #000066; font-weight: bold;">return</span> distance<span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span>	
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> willAggro<span style="color: #009900;">&#40;</span>aggro<span style="color: #339933;">,</span>distance<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>distance <span style="color: #339933;">&gt;</span> aggro<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span> 
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This is a very simple way to check aggro and the reason I placed it in its own function was incase you needed to modify it in any way (for example if a monster was under 10 levels its aggro would be 0 always). <strong> </strong></p>
]]></content:encoded>
			<wfw:commentRss>http://wheremy.feethavebeen.com/2009/12/aggro-detection-with-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Real-World OOP with PHP and MySQL</title>
		<link>http://wheremy.feethavebeen.com/2009/10/real-world-oop-with-php-and-mysql/</link>
		<comments>http://wheremy.feethavebeen.com/2009/10/real-world-oop-with-php-and-mysql/#comments</comments>
		<pubDate>Fri, 09 Oct 2009 14:00:40 +0000</pubDate>
		<dc:creator>xangelo</dc:creator>
				<category><![CDATA[Concepts]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[net]]></category>
		<category><![CDATA[tuts]]></category>

		<guid isPermaLink="false">http://wheremy.feethavebeen.com/?p=198</guid>
		<description><![CDATA[Check out an in depth tutorial covering Object Oriented design practices through the development of your own MySQL interaction object using PHP. It's a mouthful, but it takes you from know OOP knowledge to a working OOP application.]]></description>
			<content:encoded><![CDATA[<p>Due to actual copyright constraints I can&#8217;t post the actual contents of this tutorial up here, but I can post the excerpt and provide you with a link to check it out, just click the image to head over to <a href="http://net.tutsplus.com/">Net-Tuts</a> and check it out</p>
<p><a href="http://net.tutsplus.com/tutorials/php/real-world-oop-with-php-and-mysql/"><img class="aligncenter size-full wp-image-199" title="Nettuts - Real World OOP" src="http://wheremy.feethavebeen.com/wp-content/uploads/2009/10/Screenshot1.png" alt="Nettuts - Real World OOP" width="633" height="216" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://wheremy.feethavebeen.com/2009/10/real-world-oop-with-php-and-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OOP, yea you know me</title>
		<link>http://wheremy.feethavebeen.com/2009/03/oop-yea-you-know-me/</link>
		<comments>http://wheremy.feethavebeen.com/2009/03/oop-yea-you-know-me/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 13:25:32 +0000</pubDate>
		<dc:creator>xangelo</dc:creator>
				<category><![CDATA[Concepts]]></category>

		<guid isPermaLink="false">http://wheremy.feethavebeen.com/?p=59</guid>
		<description><![CDATA[I just can&#8217;t stay away from this stuff. I told myself that I would convert this into a personal blog, but that I would try and keep the coding and such out of it. It would be a day-to-day account of my life. But damn. My life can get boring some days you know? Who [...]]]></description>
			<content:encoded><![CDATA[<p>I just can&#8217;t stay away from this stuff. I told myself that I would convert this into a personal blog, but that I would try and keep the coding and such out of it. It would be a day-to-day account of my life. But damn. My life can get boring some days you know? Who want&#8217;s to read about me sitting around in my snuggie (just a snuggie) and reading for 6 hours? No one. That&#8217;s who. And old people I guess.. things like that would probably be exciting reading to them. And stalkers. But I&#8217;m sure I don&#8217;t have any of those. And even if I did, they&#8217;d probably already know that stuff.</p>
<p>Anyways, what I&#8217;m actually talking about today is Object Oriented Programming. To many it&#8217;s a very confusing concept and they&#8217;re flooded with questions such as when to use it, why would I use it, what IS it? And to others it comes as easy as breathing.</p>
<p>*NOTE* OOP is a slightly advanced concept. While you should try and learn it as soon as possible, you should have at least a moderate grasp of classes and functions.</p>
<p><strong>What is it?</strong><br />
OOP is a way of programming that breaks down an object into pieces. Essentially an object would be something that you&#8217;re trying to achieve. OOP breaks this down so that you don&#8217;t have to continually write the same code. Instead, you can just copy over the class file, and then use the same functions as you normally would. That is the bonus of OOP.<br />
To think of it another way, imagine a robot. That robot is what we are trying to build. But a robot is made of different pieces right? 2 arms, 2 feet, a body and a head. In Object Oriented Programming, you would take each piece and make it it&#8217;s own class.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;</pre></div></div>

<p><strong>How does it work?</strong><br />
What we would essentially do now, is populate this class with things that the arm can do. In this example, lets just make it very simple. All the arm can do is Judo chop and Punch. To accomplish this, all we would need to do is create two functions within our class. However, note that I said we have TWO arms. We would need some way of differentiating the right arm from the left right? The easiest way to do this, is to create a &#8220;constructor&#8221; function that would accept the name of the arm and store it for access later on.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">name <span style="color: #339933;">=</span> <span style="color: #000088;">$name</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
&nbsp;
 <span style="color: #000000; font-weight: bold;">function</span> punch<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>name<span style="color: #339933;">.</span><span style="color: #0000ff;">' punches'</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
&nbsp;
 <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #990000;">chop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>name<span style="color: #339933;">.</span><span style="color: #0000ff;">' judo chops'</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
?<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span></pre></div></div>

<p>From that piece of code alone, we can actually create as many arms as we need. And that is the beauty of OOP. Now my robot can run on the same piece of code, regardless if it has 2 arms, or 50 arms. Imagine, an awesome 50 armed robot running off no extra code?</p>
<p><strong>When would you use it?</strong><br />
As often as it makes sense. If you&#8217;re building any application, your best bet would be OOP. However, if you&#8217;re working on something like a website, there really isn&#8217;t a need for it. You&#8217;ll find people from all over the internet who say that you should use OOP all the time, and others who claim that it is the worst thing to happen to programming. Ignore them. In the end, it&#8217;s up to you to decide when you need to use OOP. If you find that you seem to be using a same bit of code all the time, wrap it in a function. If you find a group of functions you use all the time, and they&#8217;re related, wrap it in a class. If you have a group of classes you use all the time, wrap it in a framework.</p>
]]></content:encoded>
			<wfw:commentRss>http://wheremy.feethavebeen.com/2009/03/oop-yea-you-know-me/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Gone Phishing</title>
		<link>http://wheremy.feethavebeen.com/2009/03/gone-phishing/</link>
		<comments>http://wheremy.feethavebeen.com/2009/03/gone-phishing/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 04:54:41 +0000</pubDate>
		<dc:creator>xangelo</dc:creator>
				<category><![CDATA[Concepts]]></category>

		<guid isPermaLink="false">http://wheremy.feethavebeen.com/?p=23</guid>
		<description><![CDATA[Two days in and I&#8217;m already breaking from routine. But this is something that I just have to post. It isn&#8217;t necessarily a big deal, and it&#8217;s something that has been going on for a quite some time, but I would just like to prove how easy this actually is. Trout or Salmon? Neither. We&#8217;re [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;">
<div id="attachment_24" class="wp-caption aligncenter" style="width: 236px"><img class="size-medium wp-image-24" title="Phishing" src="http://wheremy.feethavebeen.com/wp-content/uploads/2009/03/phishing-226x300.jpg" alt="Please leave message." width="226" height="300" /><p class="wp-caption-text">Picture by toasty http://flickr.com/photos/toasty/</p></div>
<p>Two days in and I&#8217;m already breaking from routine. But this is something that I just have to post. It isn&#8217;t necessarily a big deal, and it&#8217;s something that has been going on for a quite some time, but I would just like to prove how easy this actually is.</p>
<p><strong>Trout or Salmon?</strong><br />
Neither. We&#8217;re going after sucker fish. The ones who know enough about computers to do their banking online, but not enough to question the incorrect SSL certificate. They think they know enough about computers to make them invulnerable to anything, which is why phishing attempts work so well.</p>
<p><strong>The Concept</strong><br />
There are numerous ways to go about phishing scams. The easiest of which involves just copying the code from the actual website. But we run into issues. The most basic of these is that if we keep the current code, and if the website uses relative links to their images, we&#8217;re screwed. We have to either replicate their directory structure, or hope to hotlink the images. Of course, a little .htaccess hack, and anyone linking to any images on the server that isn&#8217;t FROM the server, can easily be blocked. Sure it would work, but we&#8217;re lazy people right? We need the quickest solution. And the quickest solution, is an IFrame.</p>
<p>Essentially we are going to include the website we want in an IFrame and absolute position the input/submit form elements over the ones that are already present on the page. If that sounds like a load of BS to you, then attempting this is out of your league. If it doesn&#8217;t, you&#8217;ve probably already thought about this before and just never got around to it.</p>
<p><strong>K.I.S.S &#8211; Keep It Simple Stupid</strong><br />
The beauty of this code is that it can be accomplished in essentially under 7 lines. As a bonus, if the user is really foiled into entering their information, you can easily redirect them back to the website they were trying to access. To them, it will seem as if they just entered the information incorrectly and they will proceed to do it again without questioning. After all, who things that they would be the subject of a scam like this?</p>
<p>Here is a brief overview of the code without the pixel perfect placements:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>form action<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;catcher.php&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>input name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;username&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;</span>input name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;password&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;password&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;</span>input style<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;dispay: none;&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submit&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;/</span>form<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>iframe name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;myframe&quot;</span> src<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;yoursite.htm&quot;</span> width<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;100%&quot;</span> height<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;800&quot;</span><span style="color: #339933;">&gt;&lt;/</span>iframe<span style="color: #339933;">&gt;</span></pre></div></div>

<p>It&#8217;s a very simple solution. Now once you&#8217;ve included the website that you want, it&#8217;s really just a matter of adjusting the size and placement of the input boxes with CSS. Then, if you&#8217;ll notice, I turned the submit button invisible. What we are going to do is actually place that button over top of the actual submit button on the website. This way, the user thinks that they are clicking on the submit button, but in reality they are clicking on our invisible button.</p>
<p><strong>When to use it?</strong></p>
<ol>
<li>The user is stupid. They won&#8217;t notice the slight url change (ideally you will purchase a domain name resembling the name of the website you wish to spoof)</li>
<li>The login form is present near the top of the website you are visiting. This is important, as if it&#8217;s located somewhere else, when you absolute position your login elements they will float above nothing and the user will be suspicious.</li>
<li>You won&#8217;t be breaking any laws. This one is really a disclaimer. I don&#8217;t expect readers to run out and do this, this is more of a proof of concept hack that I&#8217;m sharing.</li>
</ol>
<p><strong>What can they do about it?</strong></p>
<ol>
<li>Not a whole lot. If the user has javascript enabled then the website simply has to add a bit of code to their page that will break it out of the iFrame. A lot of websites already do this, but most don&#8217;t (for whatever reason).</li>
<li>If a user has Java Script disabled then they&#8217;re out of luck. The website can&#8217;t do a damn thing to break out of it.</li>
<li>Pretty much impossible to detect. Sure a shrewd admin can backtrace the IP through the log files, but they wouldn&#8217;t have a reason to.</li>
</ol>
<p><strong></p>
<div id="attachment_25" class="wp-caption alignright" style="width: 160px"><strong><img class="size-thumbnail wp-image-25" title="tackle" src="http://wheremy.feethavebeen.com/wp-content/uploads/2009/03/tackle-150x150.jpg" alt="Not Bait and Switch" width="150" height="150" /></strong><p class="wp-caption-text">Not Bait and Switch</p></div>
<p>Bait and Tackle</strong><br />
Of course, a hack like this is wholly incomplete. What would be necessary would be something like an auto-redirect or a url masker installed on the users computer. Then whenever they accessed a website of your choosing, they would automatically be directed to your website. The bonus of something like that is that no matter what happens, you can pretty much guarantee that they&#8217;ll end up at your site for you to start your phishing.</p>
<p><strong>End Note<br />
</strong>Don&#8217;t mistake my incompleteness for inaccuracy. For those who would actually seek to use this information for actual phishing scams, a few important pieces of information were removed, such as how to hide form elements (and numerous others). Those who are actually looking to learn from this should know a few other things that could make this idea more complete. If there is enough interest, I may put up answers to a few questions, such as how to not have to copy their entire website.</p>
]]></content:encoded>
			<wfw:commentRss>http://wheremy.feethavebeen.com/2009/03/gone-phishing/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

