<?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>Jon Todd &#187; Web Development</title>
	<atom:link href="http://www.jontodd.com/tag/web-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jontodd.com</link>
	<description>Optimal</description>
	<lastBuildDate>Tue, 03 Nov 2009 22:33:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Randomly Select Photos From a Folder with PHP</title>
		<link>http://www.jontodd.com/2007/07/13/randomly-select-photos-from-a-folder-with-php/</link>
		<comments>http://www.jontodd.com/2007/07/13/randomly-select-photos-from-a-folder-with-php/#comments</comments>
		<pubDate>Fri, 13 Jul 2007 14:14:46 +0000</pubDate>
		<dc:creator>Jon Todd</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.jontodd.com/2007/07/13/randomly-select-photos-from-a-folder-with-php/</guid>
		<description><![CDATA[Joe Adu asked me how he could put photos in a folder and have php randomly choose one of the photos and display them. Then if more photos are added to the folder they would automatically enter in to the rotation. ###Step 1: Looping through a directory with php: $dir = '/absolute/path/to/folder/on/server'; $files = array&#40;&#41;; [...]]]></description>
			<content:encoded><![CDATA[<p>Joe Adu asked me how he could put photos in a folder and have php randomly choose one of the photos and display them. Then if more photos are added to the folder they would automatically enter in to the rotation.</p>
<p><span id="more-115"></span></p>
<p>###Step 1: Looping through a directory with php:</p>

<div class="wp_syntax"><div class="code"><pre class="php">  <span style="color: #ff0000">$dir</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'/absolute/path/to/folder/on/server'</span><span style="color: #66cc66;">;</span>
  <span style="color: #ff0000">$files</span> <span style="color: #66cc66;">=</span> <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
  <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #000066;">is_dir</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$dir</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$handle</span> <span style="color: #66cc66;">=</span> <span style="color: #000066;">opendir</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$dir</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
        <span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">false</span> <span style="color: #66cc66;">!==</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$file</span> <span style="color: #66cc66;">=</span> <span style="color: #000066;">readdir</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$handle</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #ff0000">$files</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000">$file</span><span style="color: #66cc66;">;</span>
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #000066;">closedir</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$handle</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
    <span style="color: #66cc66;">&#125;</span>
    <span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span>
      <span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;Could not open dir: $dir <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">;</span>
      <span style="color: #000066;">exit</span><span style="color: #66cc66;">;</span>
    <span style="color: #66cc66;">&#125;</span>
  <span style="color: #66cc66;">&#125;</span>
  <span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span>
    <span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;'$dir' is not a valid directory<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">;</span>
    <span style="color: #000066;">exit</span><span style="color: #66cc66;">;</span>
  <span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>This fills the array called &#8220;$files&#8221; with all of the files in the directory.</p>
<p>###Step 2: Randomly select a file</p>

<div class="wp_syntax"><div class="code"><pre class="php">    <span style="color: #ff0000">$randomFile</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000">$files</span><span style="color: #66cc66;">&#91;</span><span style="color: #000066;">rand</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">,</span><span style="color: #000066;">count</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$files</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">;</span></pre></div></div>

<p>This selects a photo at random in one line</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jontodd.com/2007/07/13/randomly-select-photos-from-a-folder-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Two Geeks, One Company: Adventex Design</title>
		<link>http://www.jontodd.com/2007/07/03/two-geeks-one-company-adventex-design/</link>
		<comments>http://www.jontodd.com/2007/07/03/two-geeks-one-company-adventex-design/#comments</comments>
		<pubDate>Tue, 03 Jul 2007 17:02:12 +0000</pubDate>
		<dc:creator>Jon Todd</dc:creator>
				<category><![CDATA[Bowdoin]]></category>
		<category><![CDATA[Computers]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.jontodd.com/2007/07/03/two-geeks-one-company-adventex-design/</guid>
		<description><![CDATA[So Tom pointed me to [some photos](http://www.bowdoin.edu/~ltoma/honors05-pics/Sites.html) from the good old days working long hours in the computer science lab at Bowdoin. I guess I always thought I was a pretty chill/normal CS kid but the truth is in the photos and I&#8217;m not going to lie, we look like total dorks. Tom&#8217;s going to [...]]]></description>
			<content:encoded><![CDATA[<p>So Tom pointed me to [some photos](http://www.bowdoin.edu/~ltoma/honors05-pics/Sites.html) from the good old days working long hours in the computer science lab at Bowdoin. I guess I always thought I was a pretty chill/normal CS kid but the truth is in the photos and I&#8217;m not going to lie, we look like total dorks. Tom&#8217;s going to kill me for putting this up here but it&#8217;s a nice segue into what we&#8217;re both doing now.</p>
<p>This past winter Tom and I went into the web consulting biz together under the company Adventex Design which I started back in 2000. Currently we&#8217;re working on some top secret projects which we hope you&#8217;ll be hearing about soon <img src='http://www.jontodd.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  If you or someone you know has some programming talent and experience with web applications we&#8217;d be interested in chatting with you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jontodd.com/2007/07/03/two-geeks-one-company-adventex-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IE Repeats Text In Last Float</title>
		<link>http://www.jontodd.com/2006/10/16/ie-repeats-text-in-last-float/</link>
		<comments>http://www.jontodd.com/2006/10/16/ie-repeats-text-in-last-float/#comments</comments>
		<pubDate>Mon, 16 Oct 2006 21:27:56 +0000</pubDate>
		<dc:creator>Jon Todd</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.jontodd.com/2006/10/16/ie-repeats-text-in-last-float/</guid>
		<description><![CDATA[Are you having problems with text being duplicated at the end of one of your floated div tags? It might not really be your fault. After spending about an hour verifying that my code was in fact OK I stumbled upon an article about the IE Duplicate Characters Bug. Apparently this problem is caused by [...]]]></description>
			<content:encoded><![CDATA[<p>Are you having problems with text being duplicated at the end of one of your floated div tags? It might not really be your fault. After spending about an hour verifying that my code was in fact OK I stumbled upon an article about the <a href="http://www.positioniseverything.net/explorer/dup-characters.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.positioniseverything.net');">IE Duplicate Characters Bug</a>.</p>
<p><span id="more-103"></span> Apparently this problem is caused by comments inbetween floated DIVs being mistreated by Internet Explorer. The simple fix is to either remove the comments or use comments of the form:</p>
<p><code><!--[if !IE]>This is my comment< ![endif]--></code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jontodd.com/2006/10/16/ie-repeats-text-in-last-float/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remove last comma of string in PHP</title>
		<link>http://www.jontodd.com/2006/09/11/remove-last-comma-of-string-in-php/</link>
		<comments>http://www.jontodd.com/2006/09/11/remove-last-comma-of-string-in-php/#comments</comments>
		<pubDate>Mon, 11 Sep 2006 06:06:07 +0000</pubDate>
		<dc:creator>Jon Todd</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.jontodd.com/2006/09/11/remove-last-comma-of-string-in-php/</guid>
		<description><![CDATA[After building a list of items in a string (ie &#8220;x1,x2,x3,x4,&#8221;) I typically find myself needing to remove the last comma. After using this for the longest time: $str = substr($str,0,strlen($str)-1); I found: $str = substr($str,'',-1); This will actually remove the last character whatever it is so be careful, for my uses it&#8217;s perfect. I [...]]]></description>
			<content:encoded><![CDATA[<p>After building a list of items in a string (ie &#8220;x1,x2,x3,x4,&#8221;) I typically find myself needing to remove the last comma. After using this for the longest time:</p>
<p><code> $str = substr($str,0,strlen($str)-1); </code></p>
<p>I found:</p>
<p><code> $str = substr($str,'',-1);</code></p>
<p>This will actually remove the last character whatever it is so be careful, for my uses it&#8217;s perfect.</p>
<p>I know this is not novel but it&#8217;s elegant and these are the things that make my day.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jontodd.com/2006/09/11/remove-last-comma-of-string-in-php/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Google Mapping Added</title>
		<link>http://www.jontodd.com/2006/08/22/google-mapping-added/</link>
		<comments>http://www.jontodd.com/2006/08/22/google-mapping-added/#comments</comments>
		<pubDate>Tue, 22 Aug 2006 06:07:34 +0000</pubDate>
		<dc:creator>Jon Todd</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.jontodd.com/2006/08/22/google-mapping-added/</guid>
		<description><![CDATA[Yeah so I&#8217;ve wasted a lot of time today and at least I have something to show for it. Google maps. They&#8217;re awesome and getting better all the time. I&#8217;ve cleaned up the photo gallery and added a google map functinality that shows the location of where each photo was taken. It was quite complicated [...]]]></description>
			<content:encoded><![CDATA[<p>Yeah so I&#8217;ve wasted a lot of time today and at least I have <a href="http://www.jontodd.com/wp-gallery2.php?g2_view=map.ShowMap&#038;g2_Mode=Normal&#038;g2_Group=&#038;g2_album=Acadia+2006" >something to show for it</a>. Google maps. They&#8217;re awesome and getting better all the time. I&#8217;ve cleaned up the photo gallery and added a google map functinality that shows the location of where each photo was taken. It was quite complicated to get this just the way I wanted but I&#8217;ll go into further detail in later posts about collecting the data and other details; for now I&#8217;m anouncing the revision of my gallery and the ability to view maps of selected albums. Click on the photo for the Acadia post or navigate to an album in the gallery and then select &#8220;View Album on a Map.&#8221;</p>
<p>For those of you who make posts on this site, I&#8217;m going to make sure you can upload photos and map data just as I have. You&#8217;ll then be able to include photos from the gallery directly in the posts with the g2 button in the writing interface.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jontodd.com/2006/08/22/google-mapping-added/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Session Cookie Multiple Domains</title>
		<link>http://www.jontodd.com/2006/08/10/php-session-cookie-multiple-domains/</link>
		<comments>http://www.jontodd.com/2006/08/10/php-session-cookie-multiple-domains/#comments</comments>
		<pubDate>Thu, 10 Aug 2006 05:34:08 +0000</pubDate>
		<dc:creator>Jon Todd</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.jontodd.com/2006/08/10/php-session-cookie-multiple-domains/</guid>
		<description><![CDATA[It is quite hard to find good information on this topic so I will include my setup and am open to critiques. If you are looking to keep session variables for your site users who might be using multiple sub-domains on your site there is a relatively easy way to set this up though not [...]]]></description>
			<content:encoded><![CDATA[<p>It is quite hard to find good information on this topic so I will include my setup and am open to critiques.</p>
<p>If you are looking to keep session variables for your site users who might be using multiple sub-domains on your site there is a relatively easy way to set this up though not well documented till now.</p>
<p>You want <strong>xxx</strong>.domain.com, <strong>www</strong>.domain.com and maybe even just domain.com to share the same session?<br />
<span id="more-83"></span> <strong>Session Cookies Problem<br />
</strong></p>
<p>Before I go on, I&#8217;m assuming you store your session id in cookies. If you don&#8217;t then this won&#8217;t help you, sorry. If you are then I can enlighten you with the problem with sharing sessions. Simply put, the cookies that store your session ID is host_name specific. Thus two different cookies are used to store domain.com and <strong>www</strong>.domain.com. Furthermore, to the best of my knowledge and what would seem to be for security reasons, your browser and php for that matter won&#8217;t let you read other domain&#8217;s cookies. Make&#8217;s sense really. Wouldn&#8217;t want malicious.cracker.com reading your bank session cookies while you&#8217;re checking your balance.</p>
<p><strong>My Fix</strong></p>
<p>So you need to change the <a href="http://us2.php.net/session" onclick="javascript:pageTracker._trackPageview('/outbound/article/us2.php.net');">php session</a> configuration option for session.cookie_domain from the default of &#8220;&#8221; (which inserts your hostname) to:</p>
<p><strong>&#8220;.domain.com&#8221;</strong></p>
<p>You can do this with: <a href="http://us2.php.net/manual/en/function.session-set-cookie-params.php" onclick="javascript:pageTracker._trackPageview('/outbound/article/us2.php.net');">session_set_cookie_params()</a> before doing your session_start() or if you have php start your sessions for you automatically you might consider throwing:</p>
<p><code>php_value session.cookie_domain ".domain.com"</code>into the <a href="https://zend.net/manual/configuration.changes.php" onclick="javascript:pageTracker._trackPageview('/outbound/article/zend.net');">.htaccess</a> file for the site. If you put the .htaccess file in the directory for xxx.domain.com then all sessions started on xxx.domain.com will be shared on all other domains like www.domain.com. This means however that sessions started in www.domain.com won&#8217;t carry over unless the .htaccess file is also present in it&#8217;s root directory.</p>
<p><strong>Important Note</strong></p>
<p>The first dot in &#8220;.domain.com&#8221; is not always nessesary however for support of all browsers it is suggested.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jontodd.com/2006/08/10/php-session-cookie-multiple-domains/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
