<?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>Studge &#187; Web Development</title>
	<atom:link href="http://studge.com/category/web-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://studge.com</link>
	<description></description>
	<lastBuildDate>Wed, 17 Sep 2008 17:21:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Open Addict Blocks Internet Explorer</title>
		<link>http://studge.com/open-addict-blocks-internet-explorer/</link>
		<comments>http://studge.com/open-addict-blocks-internet-explorer/#comments</comments>
		<pubDate>Thu, 19 Jul 2007 01:08:46 +0000</pubDate>
		<dc:creator>Studge</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://studge.com/open-addict-blocks-internet-explorer/</guid>
		<description><![CDATA[Rich Morgan, of Open Addict, has recently made a move to block Microsoft&#8217;s Internet Explorer from rendering his site. This move is justified by the fact the Microsoft does not seem concerned with helping to adopt web standards which causes web developers to have to tweak their sites and implement various, dirty workarounds to look [...]]]></description>
			<content:encoded><![CDATA[<p>Rich Morgan, of <a href="http://openaddict.com/">Open Addict</a>, has recently made a move to block Microsoft&#8217;s Internet Explorer from rendering his site.<span id="more-58"></span> This move is justified by the fact the Microsoft does not seem concerned with helping to adopt web standards which causes web developers to have to tweak their sites and implement various, dirty workarounds to look the way they are intended in IE.</p>
<p>I just updated the theme of this blog and, to no surprise, it does not render correctly in IE 6 or IE 7.  It looks exactly the same in Firefox, Opera and Konqueror though.  At Rich&#8217;s <a href="http://www.openaddict.com/forums/viewtopic.php?p=5512">forum</a>, he suggests that more people rally with him on this cause.  I am not yet prepared to cut IE users out entirely, but it is definitely in my head now.  If you are interested, he has also posted the short PHP code to stop IE from browsing:</p>
<div class="code">
<pre><code>&lt;?php
  if (eregi("MSIE",getenv("HTTP_USER_AGENT")) ||
  eregi("Internet Explorer",getenv("HTTP_USER_AGENT"))) {
    Header("Location: http://www.domain.com/ie_reject.html");
    exit;
  }
?&gt;</code></pre>
</div>
<p>You can place this snippet at the top of any page that you do not want to be seen in an IE browser.  Replace <code>domain.com</code> with your own domain name and be sure to create <code>ie_reject.html</code> with a little message explaining what just happened.  Rich&#8217;s message IE page can be seen <a href="http://www.openaddict.com/ie_reject.html">here</a>.</p>
<p>It would be absolutely amazing if this type of behavior became widespread, but I don&#8217;t have much faith in the movement.  Unfortunately, there are larger revolutions on the horizon.</p>
]]></content:encoded>
			<wfw:commentRss>http://studge.com/open-addict-blocks-internet-explorer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drunk Driving in Austin Without Insurance While Looking for a Student Loan Consolidation Deal</title>
		<link>http://studge.com/drunk-driving-in-austin-without-insurance-while-looking-for-a-student-loan-consolidation-deal/</link>
		<comments>http://studge.com/drunk-driving-in-austin-without-insurance-while-looking-for-a-student-loan-consolidation-deal/#comments</comments>
		<pubDate>Tue, 05 Jun 2007 19:52:52 +0000</pubDate>
		<dc:creator>Studge</dc:creator>
				<category><![CDATA[Entertainment]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://studge.com/drunk-driving-in-austin-without-insurance-while-looking-for-a-student-loan-consolidation-deal/</guid>
		<description><![CDATA[Listed here is the top 20 highest paying Adwords keywords of 2006. This list paints a surprising portrait of Google&#039;s user base. Prices are in US Dollars.

$78.31 austin dwi
$73.67 school loan consolidation
$72.28 college loan consolidation
$70.76 car insurance quotes
$70.62 auto insurance quotes
$70.10 school consolidation
$67.72 consolidation college
$63.67 consolidation student
$63.59 student loan consolidation rates
$63.53 sell structured settlement
$63.12 structured [...]]]></description>
			<content:encoded><![CDATA[<p>Listed here is the top 20 highest paying Adwords keywords of 2006. This list paints a surprising portrait of Google&#039;s user base. Prices are in US Dollars.<span id="more-53"></span></p>
<ol>
<li>$78.31 austin dwi</li>
<li>$73.67 school loan consolidation</li>
<li>$72.28 college loan consolidation</li>
<li>$70.76 car insurance quotes</li>
<li>$70.62 auto insurance quotes</li>
<li>$70.10 school consolidation</li>
<li>$67.72 consolidation college</li>
<li>$63.67 consolidation student</li>
<li>$63.59 student loan consolidation rates</li>
<li>$63.53 sell structured settlement</li>
<li>$63.12 structured settlements</li>
<li>$62.05 federal student loan consolidation</li>
<li>$61.91 austin dwi attorney</li>
<li>$61.80 term life quote</li>
<li>$61.66 austin dwi attorney</li>
<li>$61.64 term life insurance quote</li>
<li>$61.54 auto insurance quote</li>
<li>$59.66 term insurance quote</li>
<li>$58.79 federal consolidation</li>
<li>$57.75 consolidate student loan</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://studge.com/drunk-driving-in-austin-without-insurance-while-looking-for-a-student-loan-consolidation-deal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create a Site Authentication Login with PHP and MySQL</title>
		<link>http://studge.com/create-a-site-authentication-login-with-php-and-mysql/</link>
		<comments>http://studge.com/create-a-site-authentication-login-with-php-and-mysql/#comments</comments>
		<pubDate>Wed, 23 May 2007 16:11:55 +0000</pubDate>
		<dc:creator>Studge</dc:creator>
				<category><![CDATA[(X)HTML]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://studge.com/create-a-site-authentication-login-with-php-and-mysql/</guid>
		<description><![CDATA[Setting up restricted access to certain pages is a breeze.  Here I will show a quick way to control who can view specific pages using a form based login system and a MySQL database of allowed users.
First we will set up the database table for storing the user login information.  We will be [...]]]></description>
			<content:encoded><![CDATA[<p>Setting up restricted access to certain pages is a breeze.  Here I will show a quick way to control who can view specific pages using a form based login system and a MySQL database of allowed users.<span id="more-51"></span></p>
<p>First we will set up the database table for storing the user login information.  We will be encrypting the passwords later on, here is the SQL code for the table:
<div class="code">
<pre><code>CREATE TABLE `users` (
  `id` int(4) NOT NULL auto_increment,
  `username` varchar(32) NOT NULL,
  `password` varchar(32) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM</code></pre>
</div>
<p>I insert the users manually through my phpMyAdmin front-end.  If I am doing a site that has multiple users, then chances are good that I will be using a content management system, such as <a href="http://drupal.org/">Drupal</a>.  I use this authentication method for smaller sites and do not find it necessary to write a script for inserting users, but creating one would be relatively simple.  The one thing you need to be sure to do when inserting a new user is to select MD5 under the function section for the password (see screenshot below).  <a href="http://en.wikipedia.org/wiki/MD5">MD5</a> is a form of encryption that is easy to implement with PHP.</p>
<div class="centered-image"><img class="upped_image" src='http://studge.com/wp-content/uploads/2007/05/screenshot.jpg' alt='phpMyAdmin Screenshot' /></div>
<p>Now we have the MySQL end taken care of and we can focus on securing the pages.  For each page that we only want to be seen by authorized eyes, we need to put in some PHP code.  I put this code snippet as the first text after the <code>&lt;body&gt;</code> tag.  If you are using PHP4, then the code must be the very first text at the top of the web document.
<div class="code">
<pre><code >&lt;?php
  session_start();

  if (!isset($_SESSION['is_logged_in'])) {
    header("Location:login.php");
    die();
    }
?&gt;</code></pre>
</div>
<p>This snippet checks to see if a user has been authenticated for this session.  If not, then the user is redirected to a login form and the script dies.  If the user has been authenticated for this session, then the page continues to display the contents.  Now we need to create a login page.  The code above specifically refers to <code>login.php</code> so we will name the new page just that.  Here is my code for the login page:
<div class="code">
<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
    &lt;title&gt;Login&lt;/title&gt;
  &lt;/head&gt;

  &lt;body&gt;
    &lt;form method="POST" action="check.php"&gt;
      Username:&lt;br /&gt;
      &lt;input type="text" name="username" /&gt;
      &lt;br /&gt;&lt;br /&gt;
      Password:&lt;br /&gt;
      &lt;input type="password" name="password" /&gt;
      &lt;br /&gt;&lt;br /&gt;
      &lt;input type="submit" id="subbut" value="Submit" /&gt;
    &lt;/form&gt;
  &lt;/body&gt;
&lt;/html&gt;</code></pre>
</div>
<p>You should notice in the above code that the form is posting to a file named <code>check.php</code>.  This file will query our previously created MySQL database to verify the user&#039;s credentials.  Here is how it is coded:
<div class="code">
<pre><code>&lt;?php
  session_start();

  if($_SERVER['REQUEST_METHOD'] == "POST") {
    mysql_connect("mysql.example.com", "username", "password");
    @mysql_select_db("database") or die( "Unable to connect to database");
    $username = mysql_real_escape_string($_POST['username']);
    $password = mysql_real_escape_string($_POST['password']);
    $result = mysql_query("SELECT * FROM users WHERE username='$username' AND
      password=md5('$password')");

    if(mysql_num_rows($result) &gt; 0) {
      $_SESSION['is_logged_in'] = 1;
    }
  }

  if(!isset($_SESSION['is_logged_in'])) {
    header("location:login.php");
  } else {
    header("location:authenticated.php");
  }
?&gt;</code></pre>
</div>
<p>I have created a page that requires this authentication for you to view, you can visit it <a href="http://studge.com/testbed/authenticated.php">here</a>.  It is named <code>authenticated.php</code> and that is why the <code>else</code> statement above references that page.  It will redirect you to the <code>login.php</code> page unless you have been authenticated.  The username and password are <code>user</code> and <code>password</code> respectively.  On the authenticated test page you are given to option of logging out.  This was done by creating a file named <code>logout.php</code> with the following code:
<div class="code">
<pre><code>&lt;?php
  session_start();
  session_destroy();

  header("location:authenticated.php");
?&gt;</code></pre>
</div>
<p>That&#039;s all there is to it.  If you have any questions you can leave a comment or use the <a href="http://studge.com/contact/">contact</a> page and I will get back to you as soon as possible.</p>
]]></content:encoded>
			<wfw:commentRss>http://studge.com/create-a-site-authentication-login-with-php-and-mysql/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Displaying Click Counts with PHP and MySQL</title>
		<link>http://studge.com/displaying-click-counts-with-php-and-mysql/</link>
		<comments>http://studge.com/displaying-click-counts-with-php-and-mysql/#comments</comments>
		<pubDate>Sat, 19 May 2007 17:01:34 +0000</pubDate>
		<dc:creator>Studge</dc:creator>
				<category><![CDATA[(X)HTML]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://studge.com/displaying-click-counts-with-php-and-mysql/</guid>
		<description><![CDATA[Terry at SuperAff.com has asked about a follow up to a previous post Hiding Links With PHP and Counting Clicks with MySQL. In this article I demonstrated how to hide links (affiliate or otherwise) and count how many times each was clicked.  Here I will show how to throw together a simple MySQL query [...]]]></description>
			<content:encoded><![CDATA[<p>Terry at <a href="http://superaff.com/archives/2007/05/18/how-to-cloak-affiliate-links-click-tracking-with-php/">SuperAff.com</a> has asked about a follow up to a previous post <a href="http://studge.com/hiding-links-with-php-and-counting-clicks-with-mysql/">Hiding Links With PHP and Counting Clicks with MySQL</a>. In this article I demonstrated how to hide links<span id="more-50"></span> (affiliate or otherwise) and count how many times each was clicked.  Here I will show how to throw together a simple MySQL query to show you the click count.</p>
<p>First, you need to follow the aforementioned post to set up the click counter.  In the interest of not repeating myself, I will omit that code from this post.  Following is the PHP code that we will use:
<div class="code">
<pre><code >&lt;?php
  mysql_connect("mysql.example.com", "username", "password");
  @mysql_select_db("database") or die( "Unable to connect to database");
  $result = mysql_query("SELECT * FROM linkcount");

  $num = mysql_num_rows($result);

  mysql_close();

  echo "&lt;table&gt;&lt;tr&gt;&lt;td&gt;Link&lt;/td&gt;&lt;td&gt;Count&lt;/td&gt;&lt;/tr&gt;";

  for ($i=0; $i&lt;$num; $i++) {
	  if ($tmp = mysql_fetch_array($result)) {
		  extract($tmp);

		  echo "&lt;tr&gt;&lt;td&gt;$id&lt;/td&gt;";
		  echo "&lt;td&gt;$count&lt;/td&gt;&lt;/tr&gt;";
	  }
  }

  echo "&lt;/table&gt;";
?&gt;</code></pre>
</div>
<p>There are many different ways to code a front-end like this.  I am by no means a PHP expert, but I know enough to usually get the job done.  This code will give you a good starting point and you can elaborate on the code with some simple HTML to dress up the display table a bit.  I would usually advise against using tables in your web development ventures, but when it comes to returning MySQL queries there really isn&#039;t a better way.</p>
<p>To display these results in a Wordpress post, you will need a plugin to allow running custom PHP code.  Wordpress does not allow the execution of PHP code by default.  In this blog I only show the code and do not have a real need to embed it &#8211; so I do not currently use one of these plugins.  However, you can view the results of the above code <a href="http://studge.com/testbed/display-clicks.php">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://studge.com/displaying-click-counts-with-php-and-mysql/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Drupal SEO</title>
		<link>http://studge.com/drupal-seo/</link>
		<comments>http://studge.com/drupal-seo/#comments</comments>
		<pubDate>Sat, 12 May 2007 12:46:35 +0000</pubDate>
		<dc:creator>Studge</dc:creator>
				<category><![CDATA[SEO]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://studge.com/drupal-seo/</guid>
		<description><![CDATA[Drupal is hands down my favorite content management system, but in order to use it there are a few initial steps you need to follow to get it working at our expected SEO performance level.
Note: This article will not cover the installation of Drupal. The first thing I do is turn on the clean URLs. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://drupal.org">Drupal</a> is hands down my favorite content management system, but in order to use it there are a few initial steps you need to follow to get it working at our expected SEO performance level.<span id="more-49"></span></p>
<p><em>Note: This article will not cover the installation of Drupal.</em> The first thing I do is turn on the clean URLs.  This option is available when logged in as an administrator under Administer>Site Configuration>Clean URLs.  Drupal requires that you run the test first to determine whether or not your server is set up with PHP&#039;s <a href="http://en.wikipedia.org/wiki/Mod_rewrite">mod_rewrite</a> module.  This will enable the use of meaningful URLs, rather than PHP posting text.  To further compliment the use of clean URLs, we are going to install a Drupal module that will automatically name our posts and pages for us.  This module is <a href="http://drupal.org/project/pathauto">pathauto</a>, download the appropriate package and upload the <code>pathauto</code> folder into the <code>modules</code> folder on your server.  Be sure to enable it under Drupal&#039;s module section.  If you have already created content and are only now installing this module, then it is important that you navigate to the pathauto configuration section and have it bulk generate index aliases.</p>
<p>One problem with Drupal is the creation of duplicate pages.  For example: if you create a new post, then you will be presented with four different URLs for the same content:
<div class="code">
<pre><code>http://example.com/new-post

http://example.com/new-post/

http://example.com/node/2

http://example.com/node/2/</code></pre>
</div>
<p>This practice looks bad to search engines.  So, we need to edit our <code>.htaccess</code> file, located at the root of our webserver, to prevent it from using the trailing slash.  We will then edit our <code>robots.txt</code> file to prevent the search engines from indexing the <code>/node</code> area, thus preventing it from being an issue.</p>
<p>First we open out <code>.htaccess</code> file and add the following to the beginning of the file (replace <code>example\.com</code> with your domain name):
<div class="code">
<pre><code># remove trailing slashes
RewriteCond %{HTTP_HOST} ^(www.)?example\\.com$ [NC]
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]</code></pre>
</div>
<p>Next we need to edit our <code>robots.txt</code> file to prevent the search engines from indexing our <code>/node</code> area.  Add the following line:
<div class="code">
<pre><code>Disallow: /node/</code></pre>
</div>
<p>That should take care of the basic SEO setbacks that come with a default installation of Drupal.  You may also want to implement the <a href="http://drupal.org/project/gsitemap">XML Sitemap</a> module to automatically produce a sitemap when new content is created.  It will also notify several search engines when it is updated.</p>
]]></content:encoded>
			<wfw:commentRss>http://studge.com/drupal-seo/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Top 5 Must Have Linux Web Developer Applications</title>
		<link>http://studge.com/top-5-must-have-linux-web-developer-applications/</link>
		<comments>http://studge.com/top-5-must-have-linux-web-developer-applications/#comments</comments>
		<pubDate>Thu, 19 Apr 2007 16:54:26 +0000</pubDate>
		<dc:creator>Studge</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://studge.com/top-5-must-have-linux-web-developer-applications/</guid>
		<description><![CDATA[I consider myself a web developer, not necessarily a web designer, but certainly a developer. As such, I do not require the latest Adobe suite of programs to get the job done.  There are plenty of open source Linux applications that can help accomplish this for free.
I see five different areas of software that [...]]]></description>
			<content:encoded><![CDATA[<p>I consider myself a web developer, not necessarily a web designer, but certainly a developer. As such, I do not require the latest <a href="http://www.adobe.com/products/">Adobe</a> suite of programs to get the job done.<span id="more-40"></span>  There are plenty of open source Linux applications that can help accomplish this for free.</p>
<p>I see five different areas of software that I use during development.  I first, of course, need a development environment to generate my code.  I need software to manipulate images that will be used in my sites.  I need a program to encode videos into web friendly formats.  After all of this, I need to get my files onto the web server. Lastly I need to be able to view the completed work to see how it turned out and determine where I need to tweak my code.</p>
<h3>IDE</h3>
<p><strong><a href="http://www.jedit.org/">jEdit</a></strong> is my <a href="http://studge.com/jedit-is-my-new-ide/">IDE of choice</a>.  I have tried others and could never find one the encompassed all of my needs.  jEdit&#039;s robust module system allows enough expansion to cover almost any developers&#039; needs.  Most important of these is the FTP plugin for editing code directly on the server.  The CSS auto complete feature is a nice plus too, though it was never a requirement that I had set out to find.</p>
<h3>Image Manipulation</h3>
<p><strong><a href="http://www.gimp.org/">The GIMP</a></strong> is a no brainer here.  It is the standard for image editing and creation in a Linux environment.  A lot of people say that is severely handicapped in comparison to Photoshop.  I am not a professional designer but have been able to do <em>everything</em> I have ever needed to do to an image with The GIMP.  A legal version of Photoshop would cost me over $600, that&#039;s a cost I can&#039;t really justify for an individual &#8211; sans self-employed, professional designers.  If you are into design that much, then you are probably a Mac elitist anyway &#8211; so why are you using Linux?  I have found that I can almost always follow a good Photoshop tutorial I have found on the web and mimic it using The GIMP with equal results.  I may have to add a couple more steps to the process, but that is fine considering I did not have to fork over any money to do it.  Note: This argument does not acknowledge the option of Photoshop piracy.</p>
<h3>Video Encoding</h3>
<p><strong><a href="http://www.mplayerhq.hu/">MPlayer</a></strong>&#039;s movie encoder is fast on the command line.  I am able to take nearly any video format and then resize it and <a href="http://studge.com/creating-flash-video-in-linux/">convert it into a Flash video</a>.  That makes it have a smaller filesize and also ensures that it will be in a format that is usable to most visitors.</p>
<h3>File Transfer</h3>
<p>I can edit my code directly on the server with jEdit, but I have to get my images, videos and whatever else I am delivering up on the server.  <a href="http://www.gftp.org/">gFTP</a> is the only FTP client I have ever used in Linux.  I have never found a reason to look elsewhere because it does everything I need.  It allows bookmarking so I can connect to my sites with a click and get my files up.</p>
<h3>Web Browser</h3>
<p>Of course I use <a href="http://mozilla.com/firefox">Firefox</a> to test sites with.  It is also my main browser for surfing the web.  But Firefox is not representative of the users who will be visiting sites.  Unfortunately most people still use Microsoft&#039;s travesty of a browser &#8211; Internet Explorer. Luckily I do not need to keep that OS available as an option on my machines just to use that broken browser.  <a href="http://www.tatanka.com.br/ies4linux/page/Main_Page">IEs4Linux</a> is a script developed by Sérgio Lopes that enables the download and installation of IE 5, 5.5 and 6 through <a href="http://www.winehq.com/">Wine</a>, the Windows emulator.  I do not use all of the versions of IE that he makes available, just IE 6 and 7.  To get IE 7 you currently need to use the beta version of IEs4Linux.</p>
]]></content:encoded>
			<wfw:commentRss>http://studge.com/top-5-must-have-linux-web-developer-applications/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Creating Flash Video in Linux</title>
		<link>http://studge.com/creating-flash-video-in-linux/</link>
		<comments>http://studge.com/creating-flash-video-in-linux/#comments</comments>
		<pubDate>Sat, 14 Apr 2007 11:46:19 +0000</pubDate>
		<dc:creator>Studge</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://studge.com/creating-flash-video-in-linux/</guid>
		<description><![CDATA[Serving videos on your sites can really eat up your bandwidth.  This can cost a lot of money, but so can buying Adobe&#039;s Flash software just to create videos in their format. It currently sells for about $700.
I personally use MPlayer as my video player of choice in Linux.  It has an encoding [...]]]></description>
			<content:encoded><![CDATA[<p>Serving videos on your sites can really eat up your bandwidth.  This can cost a lot of money, but so can buying Adobe&#039;s Flash software just to create videos in their format.<span id="more-36"></span> It currently sells for about $700.</p>
<p>I personally use <a href="http://www.mplayerhq.hu/">MPlayer</a> as my video player of choice in Linux.  It has an encoding program call MEncoder that we will use to convert our video.  MEncoder should convert any video that MPlayer will play.  If you are using <a href="http://fedoraproject.org/">Fedora Core</a>, as I do, then you can find both MPlayer and MEncoder in the Fedora repositories.  First we need a video to start with.  For the purpose of this example we will use <a href="http://studge.com/media/testvid.avi">this</a> video.  It is a short, 2.4MB video of <a href="http://builttospill.com/">Built To Spill</a> front-man Doug Martsch doing an acoustic version of &#8220;Car&#8221; somewhere, I do not recall the specific details.  The video is <a href="http://en.wikipedia.org/wiki/DivX">DivX 4</a> with <a href="http://en.wikipedia.org/wiki/Mp3">MP3</a> audio and is 480 x 360 pixels at approximately 15 frames per second.  The following command will convert it to the Flash video (<a href="http://en.wikipedia.org/wiki/Flv">FLV</a>) format. <strong>NOTE</strong> The backslash at the end of each line is used to break up commands in the shell:
<div class="code">
<pre><code>[user@localhost ~]$ mencoder testvid.avi \
-ofps 15 -o testvid.flv -of lavf \
-oac mp3lame -lameopts abr:br=64 -srate 22050 -ovc lavc \
-lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -lavcopts \
vcodec=flv:keyint=50:vbitrate=300:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -vf scale 320:240</code></pre>
</div>
<p>This produces a Flash video that is the same resolution as our source video.  One thing you should look out for is matching the frame-rate of your source video.  The section in the second line of the command, <code>-ofps 15</code>, tells MEncoder to make the new video have 15 frames per second.  You can find your video&#039;s frame-rate easily with the <code>file</code> command:
<div class="code">
<pre><code>[user@localhost ~]$ file testvid.avi
testvid.avi: RIFF (little-endian) data, AVI, 480 x 360, ~15 fps,
   video: DivX 4, audio: MPEG-1 Layer 3 (stereo, 44100 Hz)</code></pre>
</div>
<p>We are also changing the output video&#039;s resolution, when we convert it, from 480 x 360 pixels to 320 x 240 pixels. You can omit the last line, <code>-vf scale 320:240</code>, if you do not wish to alter the resolution.  </p>
<p>We are finished.  You just need to upload your new FLV file to your server and integrate it into your site.  I will not cover that process because it will be different for each user dependent upon your particular hosting service and/or CMS. We have managed to reduce the filesize of our video from 2.4MB down to 933.2KB.  We have also managed to standardize our video so that it does not depend on the vast array of browser video plugins that our site visitors could be using &#8211; just Flash.  Here&#039;s the video we have produced:</p>
<div class="centered-image">
<div class="flvPlayer">				<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="320" height="260"><param name="movie" value="https://media.dreamhost.com/mediaplayer.swf?file=http://studge.com/media/testvid.flv&amp;autoStart=false;" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><embed src="https://media.dreamhost.com/mediaplayer.swf?file=http://studge.com/media/testvid.flv&amp;autoStart=false;" quality="high" wmode="transparent" width="320" height="260" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /><br />
				</object></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://studge.com/creating-flash-video-in-linux/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
<enclosure url="http://studge.com/media/testvid.avi" length="2561802" type="video/x-msvideo" />
		</item>
		<item>
		<title>JavaScript Validation for HTML Forms</title>
		<link>http://studge.com/javascript-validation-for-html-forms/</link>
		<comments>http://studge.com/javascript-validation-for-html-forms/#comments</comments>
		<pubDate>Tue, 10 Apr 2007 13:07:19 +0000</pubDate>
		<dc:creator>Studge</dc:creator>
				<category><![CDATA[(X)HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://studge.com/javascript-validation-for-html-forms/</guid>
		<description><![CDATA[One of the most frustrating things with using forms on a site is getting back bad information in your results. Probably the most common instance is when a user enters a bad email address, such as webmaster#studgecom.  We can utilize JavaScript to check for composition error such as this and to make sure that [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most frustrating things with using forms on a site is getting back bad information in your results.<span id="more-35"></span> Probably the most common instance is when a user enters a bad email address, such as <code>webmaster#studgecom</code>.  We can utilize JavaScript to check for composition error such as this and to make sure that certain, required fields are filled in.</p>
<p>First, we are going to write up a simple form that requests a user&#039;s name, email address and favorite color.  Here is the essence of the form:</p>
<div class="code">
<pre><code>&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;Form for JavaScript Validation - 1st version&lt;/title&gt;
  &lt;/head&gt;

  &lt;body&gt;
    &lt;form method="POST" action="jstest.php"&gt;
    	Name:&lt;input type="text" name="name" /&gt;&lt;br /&gt;
	Email address:&lt;input type="text" name="email" /&gt;&lt;br /&gt;
	Favorite color:&lt;input type="text" name="color" /&gt;&lt;br /&gt;
	&lt;input type="submit" name="submit" value="Submit" /&gt;
    &lt;/form&gt;
  &lt;/body&gt;
&lt;/html&gt;</code></pre>
</div>
<p>You can try it <a href="http://studge.com/testbed/jstest1.html" target="_blank">here</a>. It sends the form data to a PHP script named <code>jstest.php</code>.  This script merely displays the information that the user put into the form.  Here is code for it:
<div class="code">
<pre><code>&lt;?php
  echo "Thank you <strong>" . $_POST['name'] . "</strong>&lt;br /&gt;";
  echo "We will contact you at <strong>" . $_POST['email'] .
    "</strong> regarding the color <strong>" . $_POST['color'] . "</strong>";
?&gt;</code></pre>
</div>
<p>As it is written now, the form provides no sort of validation and the user can submit anything or nothing in the availabe fields.  So we need to write a JavaScript script to handle the validation.  We will <strong>require</strong> the user to input their name, email address and favorite color.  The user must also input the email address in a valid format. We will call this file <code>jstest.js</code> and here is what it looks like:
<div class="code">
<pre><code>function validate_required(field,alerttxt) {
	with (field) {
		if (value==null||value=="") {
			alert(alerttxt);
			return false;
		}
		else {
			return true;
		}
	}
}

function validate_email(field,alerttxt) {
	with (field) {
		apos=value.indexOf("@")
		dotpos=value.lastIndexOf(".")
		if (apos&lt;1||dotpos-apos&lt;2) {
			alert(alerttxt);
			return false;
		} else {
			return true;
		}
	}
}

function validate_form(thisform) {
	with (thisform) {
		if (validate_required(name,"Please specify your name!")==false) {
			name.focus();
			return false;
		}
		if (validate_required(email,"Email must be filled out!")==false) {
			email.focus();
			return false;
		}
		if (validate_email(email,"Not a valid e-mail address!")==false) {
			email.focus();
			return false;
		}
		if (validate_required(color,"Forgot favorite color!")==false) {
			color.focus();
			return false;
		}
	}
}</code></pre>
</div>
<p>Now we have a script to validate the form, but it does nothing until we implement it into the form&#039;s code.  Here is the full form code (sans styling):
<div class="code">
<pre><code>&lt;html&gt;
&lt;head&gt;
  &lt;script type="text/javascript" src="jstest.js"&gt;&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
  &lt;form method="POST"
        onsubmit="return validate_form(this)" action="jstest.php"&gt;
    Name:&lt;input type="text" name="name" /&gt;&lt;br /&gt;
    Email address:&lt;input type="text" name="email" /&gt;&lt;br /&gt;
    Favorite color:&lt;input type="text" name="color" /&gt;&lt;br /&gt;
    &lt;input type="submit" name="Submit" value="Submit" /&gt;
  &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>
</div>
<p>You can try the finished, with validation, <a href="http://studge.com/testbed/jstest2.html" target="_blank">here</a>.  You should be able to adapt the above code to your specific form needs.</p>
]]></content:encoded>
			<wfw:commentRss>http://studge.com/javascript-validation-for-html-forms/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Hiding Links With PHP and Counting Clicks with MySQL</title>
		<link>http://studge.com/hiding-links-with-php-and-counting-clicks-with-mysql/</link>
		<comments>http://studge.com/hiding-links-with-php-and-counting-clicks-with-mysql/#comments</comments>
		<pubDate>Sat, 07 Apr 2007 17:44:57 +0000</pubDate>
		<dc:creator>Studge</dc:creator>
				<category><![CDATA[(X)HTML]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://studge.com/hiding-links-with-php-and-counting-clicks-with-mysql/</guid>
		<description><![CDATA[There are many reasons why one might want to hide their links &#8211; perhaps you are are an affiliate marketer, the link is really long and dirty or you are simply wanting to implement a system that counts how many times a certain link is clicked (more on that later).
Affiliate marketers like to make their [...]]]></description>
			<content:encoded><![CDATA[<p>There are many reasons why one might want to hide their links &#8211; perhaps<span id="more-38"></span> you are are an affiliate marketer, the link is really long and dirty or you are simply wanting to implement a system that counts how many times a certain link is clicked (more on that later).</p>
<p>Affiliate marketers like to make their links appear to be on their site and handle the redirection themselves, it improves the overall trustworthiness and cleanliness of the site in general.  In keeping with the <a href="http://en.wikipedia.org/wiki/Clean_URLs#Clean_URLs">clean URLs</a> process, though I&#8217;m not sure if this really counts, you may want to clean up a link for whatever reason.  The last reason I can think of, and the most useful, is that you what to implement a system to manage your links and count them at the same time.  This can be a valuable tool in any online marketing campaign as you try to feel out what works on your sites.  First off, we are going to need a PHP script to send all of our link requests to.  For this example, we will create a script at the root of our domain called <code>redirect.php</code>.  The following is the first bit of code that will handle the actual redirection for the links, for our example it will redirect to Google, Yahoo and Wikipedia:</p>
<div class="code">
<pre><code >&lt;?php
  $id = $_GET['id'];
  $links = array(
    "google" =&gt; "http://google.com",
    "yahoo" =&gt; "http://yahoo.com",
    "wikipedia" =&gt; "http://wikipedia.org"
    );

  header("Location:".$links[$id]);
  exit;
?&gt;</code></pre>
</div>
<p>Now we can use the following links to get to our specified locations:
<ul>
<li><a href="http://studge.com/testbed/redirect.php?id=google">Google</a> <code>http://studge.com/testbed/redirect.php?id=google</code></li>
<li><a href="http://studge.com/testbed/redirect.php?id=yahoo">Yahoo!</a> <code>http://studge.com/testbed/redirect.php?id=yahoo</code></li>
<li><a href="http://studge.com/testbed/redirect.php?id=wikipedia">Wikipedia</a> <code>http://studge.com/testbed/redirect.php?id=wikipedia</code></li>
</ul>
<p>Now we can also set up a system to count how many clicks our new links are getting.  I am going to use a MySQL database for this feature.  I will need to set up the following table:</p>
<div class="code">
<pre><code>CREATE TABLE `linkcount` (
`id` VARCHAR( 50 ) NOT NULL ,
`count` INT( 10 ) NOT NULL default '0' ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM ;</code></pre>
</div>
<p>We are going to edit the redirection code to access the database and create an entry for the link if it does not already exist.  Then we will increment the count field by one each time it is called. This example uses the fictional database server <code>mysql.example.com</code>, using a database called <code>database</code> with a table called <code>linkcount</code>:
<div class="code">
<pre><code>&lt;?php
  mysql_connect("mysql.example.com", "username", "password");
  @mysql_select_db("database") or die( "Unable to connect to database");
  $id = mysql_real_escape_string($_GET['id']);
  $result = mysql_query("SELECT * FROM linkcount WHERE id='$id'");

  if(mysql_num_rows($result) == 0) {
  	mysql_query("INSERT INTO linkcount (id) VALUES ('$id')")
          or die(mysql_error());
	mysql_query("UPDATE linkcount SET count=count+1 WHERE id='$id'")
          or die(mysql_error());
  } else {
	mysql_query("UPDATE linkcount SET count=count+1 WHERE id='$id'")
          or die(mysql_error());
  }

  mysql_close();

  $links = array(
    "google" =&gt; "http://google.com",
    "yahoo" =&gt; "http://yahoo.com",
    "wikipedia" =&gt; "http://wikipedia.org"
    );

  header("Location:".$links[$id]);
  exit;
?&gt;</code></pre>
</div>
<p>That is all it takes.  From here you may want to write a front-end to display your click results or you could even display the count next to the specific link in your sites navigation menu to rank the most popular outgoing links.</p>
<p><strong>Edit:</strong> A follow-up has been written to this post that describes a simple script for displaying the click results: <a href="http://studge.com/displaying-click-counts-with-php-and-mysql/">Displaying Click Counts with PHP and MySQL</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://studge.com/hiding-links-with-php-and-counting-clicks-with-mysql/feed/</wfw:commentRss>
		<slash:comments>40</slash:comments>
		</item>
		<item>
		<title>301 Redirect and Dreamhost</title>
		<link>http://studge.com/301-redirect-and-dreamhost/</link>
		<comments>http://studge.com/301-redirect-and-dreamhost/#comments</comments>
		<pubDate>Sun, 25 Mar 2007 01:45:19 +0000</pubDate>
		<dc:creator>Studge</dc:creator>
				<category><![CDATA[SEO]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://studge.com/301-redirect-and-dreamhost/</guid>
		<description><![CDATA[I recently needed to redirect a domain name to another domain name.  This was due to having both the .com and the .net extension.  I wanted to forward the .net domain to the .com domain.  Dreamhost provides a redirect option in their control panel.  I implemented this feature and then started [...]]]></description>
			<content:encoded><![CDATA[<p>I recently needed to redirect a domain name to another domain name.  This was due to having both the .com and the .net extension.  I wanted to forward the .net domain to the .com domain.<span id="more-33"></span>  <a href="http://www.dreamhost.com/r.cgi?208105">Dreamhost</a> provides a redirect option in their control panel.  I implemented this feature and then started testing it a bit &#8211; what I came to find out was not very encouraging.  If I typed in http://example.net/ in my browser, then I was flawlessly redirected to http://example.com/.  Great &#8211; that is naturally what I expected.  However, a problem arose when I went to specific locations of the .net domain.  </p>
<p>The domain had already been submitted to the search engines and, as such, had already been indexed.  This meant that there were locations that may be checked.  While using Dreamhost&#039;s redirect option, users trying to go to http://example.net/contact/ would be redirected to http://example.comcontact/.  This is, of course, a completely bogus URL and would return a page error.  Having a request redirected to a location like this would lower your sites standing in the search engines&#039; indexes.  The solution came by implementing my own <strong>301 Redirect</strong> in the domain&#039;s .htacess file.  I wiped out the existing .htaccess file from that domain (it was leftover from the previously installed CMS).  I then created a new one in its place that only consisted of the following one line:
<div class="code">
<pre><code>Redirect 301 / http://example.com/&lt;/pre&gt;</code></div>
<p>That was it.  After that, any specific requests sent to the .net domain were translated over to the .com URL and redirected accordingly.</p>
]]></content:encoded>
			<wfw:commentRss>http://studge.com/301-redirect-and-dreamhost/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.570 seconds -->
<!-- Cached page served by WP-Cache -->
