<?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>Japh &#187; Development</title>
	<atom:link href="http://japh.com.au/category/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://japh.com.au</link>
	<description>Web developer, technologist, innovator. I love the internet.</description>
	<lastBuildDate>Tue, 13 Jul 2010 10:48:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Get yourself a Satellite developer</title>
		<link>http://japh.com.au/general/get-yourself-a-satellite-developer/</link>
		<comments>http://japh.com.au/general/get-yourself-a-satellite-developer/#comments</comments>
		<pubDate>Sat, 30 May 2009 05:08:34 +0000</pubDate>
		<dc:creator>Japh</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[General Chatter]]></category>

		<guid isPermaLink="false">http://japh.com.au/?p=151</guid>
		<description><![CDATA[The new Satellite website is now live!
If you don&#8217;t already know, I recently started full-time freelance development.  The idea is that anyone who needs development work done, wherever they are, can contact me to help out on their project.
Whether you are a freelance designer who needs some development done (or even some training), or [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>The new <a title="Satellite - International Web Development" href="http://satellitedev.com">Satellite website</a> is now live!</p>
<p>If you don&#8217;t already know, I recently started full-time freelance development.  The idea is that anyone who needs development work done, wherever they are, can contact me to help out on their project.</p>
<p>Whether you are a freelance designer who needs some development done (or even some training), or a freelance developer who needs an extra pair of hands, or even a bigger business who needs to bring someone else in on a project&#8230;  <a title="Satellite - International Web Development" href="http://satellitedev.com">I&#8217;m available for hire!</a></p>
<p>I would love to hear any feedback on the new website too, so feel free to leave any comments in that regard as well.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://japh.com.au/general/get-yourself-a-satellite-developer/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Custom default Gravatar in WordPress 2.7</title>
		<link>http://japh.com.au/php/custom-default-gravatar-in-wordpress/</link>
		<comments>http://japh.com.au/php/custom-default-gravatar-in-wordpress/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 03:45:06 +0000</pubDate>
		<dc:creator>Japh</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://japh.com.au/?p=124</guid>
		<description><![CDATA[If you&#8217;ve been using WordPress for a little while, and don&#8217;t really much like the default options you have to choose from when a commenter doesn&#8217;t have their own Gravatar, why not make your own?
Make yourself a little square image to use that matches in with your theme, and then insert the following line of [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve been using WordPress for a little while, and don&#8217;t really much like the default options you have to choose from when a commenter doesn&#8217;t have their own Gravatar, why not make your own?</p>
<p>Make yourself a little square image to use that matches in with your theme, and then insert the following line of code:</p>

<div class="wp_codebox"><table><tr id="p1242"><td class="code" id="p124code2"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> get_avatar<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$comment</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">86</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'http://example.com/custom-default-av.png'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><strong>Note:</strong> you must provide the full absolute URL for your image.</p>
<p>What this line does, is show a Gravatar for the user if they have one, and if not, show your custom one instead. The number &#8220;86&#8243; is the pixel width and height you want the Gravatars to display at.</p>
<p>Remember that this will only work in WordPress 2.7+, or possibly in older versions if you have the Gravatar plugin installed (not tested).</p>
<p><strong>Update:</strong> If you don&#8217;t know what a Gravatar is, check out the comments.  The avatar&#8217;s shown beside each comment are automatically pulled in from Gravatar&#8217;s service, so you upload your avatar once, and it appears everywhere when you comment etc.  Get yourself one here: <a href="http://gravatar.com/">Gravatar</a></p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://japh.com.au/php/custom-default-gravatar-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Time-sensitive CSS</title>
		<link>http://japh.com.au/html/time-sensitive-css/</link>
		<comments>http://japh.com.au/html/time-sensitive-css/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 09:18:28 +0000</pubDate>
		<dc:creator>Japh</dc:creator>
				<category><![CDATA[Cascading Stylesheets]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://japh.com.au/?p=115</guid>
		<description><![CDATA[Have you ever wanted to load a specific stylesheet depending on what time it is?  It is actually very easy to do!
View Demo
I&#8217;m using jQuery in this just because it makes it look a little simpler, it&#8217;s not much more complex to do without jQuery&#8230; but let&#8217;s face it, you&#8217;re probably already using jQuery [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Have you ever wanted to load a specific stylesheet depending on what time it is?  It is actually very easy to do!</p>
<p><a href="/demos/115/">View Demo</a></p>
<p>I&#8217;m using jQuery in this just because it makes it look a little simpler, it&#8217;s not much more complex to do without jQuery&#8230; but let&#8217;s face it, you&#8217;re probably already using jQuery anyway, so why not  <img src='http://japh.com.au/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Make yourself a new file to put your javascript into, I&#8217;ve called mine &#8220;script.js&#8221;.  Include the new javascript file by putting this line in your HTML &lt;head&gt;&lt;/head&gt; section with the following line:</p>

<div class="wp_codebox"><table><tr id="p1155"><td class="code" id="p115code5"><pre class="html" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot; src=&quot;script.js&quot;&gt;&lt;/script&gt;</pre></td></tr></table></div>

<p>Now open your &#8220;script.js&#8221; file, and put the following lump of code into it:</p>

<div class="wp_codebox"><table><tr id="p1156"><td class="code" id="p115code6"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// This line depends on jQuery, and tells the browser to kick off this stuff once</span>
<span style="color: #006600; font-style: italic;">// everything's fully loaded</span>
$<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: #006600; font-style: italic;">// These two lines make set a Date variable with the current date and time</span>
    <span style="color: #003366; font-weight: bold;">var</span> currentDate <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> currentHour <span style="color: #339933;">=</span> currentDate.<span style="color: #660066;">getHours</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">// Here we're creating a new &lt;link /&gt; to insert in the &lt;head&gt;&lt;/head&gt;</span>
    <span style="color: #003366; font-weight: bold;">var</span> newCSS <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'link'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    newCSS.<span style="color: #660066;">type</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'text/css'</span><span style="color: #339933;">;</span>
    newCSS.<span style="color: #660066;">rel</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'stylesheet'</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">// This is where you can determine when to use which stylesheet.</span>
    <span style="color: #006600; font-style: italic;">// If the current hour is before 9am or 8pm (or later), use &quot;night.css&quot;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>currentHour <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">9</span> <span style="color: #339933;">||</span> currentHour <span style="color: #339933;">&gt;=</span> <span style="color: #CC0000;">20</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        newCSS.<span style="color: #660066;">href</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'css/night.css'</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #006600; font-style: italic;">// Otherwise, use &quot;day.css&quot;</span>
    <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
        newCSS.<span style="color: #660066;">href</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'css/day.css'</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #006600; font-style: italic;">// This line actually does the deed, and attaches the selected stylesheet</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;head&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>newCSS<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">// This line isn't necessary, it's just showing the actual time in the demo.</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.satellite&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>currentDate.<span style="color: #660066;">toTimeString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</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></pre></td></tr></table></div>

<p>Read the commenting to understand what&#8217;s actually going on there, but that should do it!  Easier than you thought, I bet  <img src='http://japh.com.au/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>If you have any questions or suggestions, leave a comment!</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://japh.com.au/html/time-sensitive-css/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Sending scheduled emails with PHP</title>
		<link>http://japh.com.au/development/sending-scheduled-emails-with-php/</link>
		<comments>http://japh.com.au/development/sending-scheduled-emails-with-php/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 14:09:33 +0000</pubDate>
		<dc:creator>Japh</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP cron email]]></category>

		<guid isPermaLink="false">http://japheththomson.com/?p=83</guid>
		<description><![CDATA[Ok, so there are two main topics being covered here:

Sending emails with PHP
Running PHP scripts with a cronjob


Sending emails with PHP
Step 1
First of all, we&#8217;re going to install the PEAR::Mail package.  PHP&#8217;s built-in mail() function isn&#8217;t particularly secure, so using an actual SMTP email account seems nicer  :)
If you don&#8217;t already have PEAR::Mail installed, you [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Ok, so there are two main topics being covered here:</p>
<ol>
<li>Sending emails with PHP</li>
<li>Running PHP scripts with a cronjob</li>
</ol>
<p><span id="more-83"></span></p>
<h3>Sending emails with PHP</h3>
<p><strong>Step 1</strong></p>
<p>First of all, we&#8217;re going to install the PEAR::Mail package.  PHP&#8217;s built-in mail() function isn&#8217;t particularly secure, so using an actual SMTP email account seems nicer  :)</p>
<p>If you don&#8217;t already have PEAR::Mail installed, you may need to request from your host that they install it.  If you have SSH / shell access to your server, you can probably do it yourself by running the following command:</p>

<div class="wp_codebox"><table><tr id="p8312"><td class="code" id="p83code12"><pre class="php" style="font-family:monospace;">pear install <a href="http://www.php.net/mail"><span style="color: #990000;">mail</span></a></pre></td></tr></table></div>

<p>Now you should be able to use this library with the following code in the top of your PHP script:</p>

<div class="wp_codebox"><table><tr id="p8313"><td class="code" id="p83code13"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Mail.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>This may seem odd, because you have no Mail.php file in your web root, but trust me it works.  This is because PEAR is in PHP&#8217;s path variables, so if it doesn&#8217;t find the Mail.php file in your web root, it already knows to look there.</p>
<p><strong>Step 2</strong></p>
<p>The next part is actually writing some PHP that will send a message.  You will need a few details of your mail server for this bit, such as SMTP server name, your username and your password.  You will also need an email address to send to, and one to send from, of course!</p>

<div class="wp_codebox"><table><tr id="p8314"><td class="code" id="p83code14"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">&quot;Mail.php&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Inclusion of PEAR::Mail</span>
<span style="color: #000088;">$from</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Joe Bloggs &lt;j.bloggs@domain.com&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$to</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;John Citizen &lt;citizenj@exampledomain.com&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$subject</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Test message&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$message</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Test message.'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$host</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;smtp.domain.com&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$username</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;jbloggs&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$password</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;password&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$headers</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a> <span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'From'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$from</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'To'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$to</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'Subject'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$subject</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Now we will create an SMTP object with the appropriate details</span>
<span style="color: #000088;">$smtp</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mail"><span style="color: #990000;">Mail</span></a><span style="color: #339933;">::</span><span style="color: #004000;">factory</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'smtp'</span><span style="color: #339933;">,</span>
    <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a> <span style="color: #009900;">&#40;</span>
        <span style="color: #0000ff;">'host'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$host</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'auth'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'username'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$username</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'password'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$password</span>
    <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Here we actually send the email</span>
<span style="color: #000088;">$mail</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$smtp</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">send</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$to</span><span style="color: #339933;">,</span> <span style="color: #000088;">$headers</span><span style="color: #339933;">,</span> <span style="color: #000088;">$message</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// And check for errors, or if the email was sent successfully</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>PEAR<span style="color: #339933;">::</span><span style="color: #004000;">isError</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mail</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;p&gt;&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;/p&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;p&gt;Message successfully sent!&lt;/p&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>I&#8217;ve put some comments in this script, just to make sure you know what&#8217;s going on, but basically that&#8217;s it!</p>
<h3>Running PHP scripts with a cronjob</h3>
<p><strong>Step 3</strong></p>
<p>Using cronjobs seems difficult, and some people are put off by the slightly archaic looking format&#8230;  but they&#8217;re actually very simple.  You put multiple entries (cronjobs) into the crontab, and then they run!  Look at the following crontab entry:</p>

<div class="wp_codebox"><table><tr id="p8315"><td class="code" id="p83code15"><pre class="php" style="font-family:monospace;"><span style="color: #cc66cc;">0</span> <span style="color: #339933;">*</span> <span style="color: #339933;">*</span> <span style="color: #339933;">*</span> <span style="color: #339933;">*</span> <span style="color: #339933;">/</span>usr<span style="color: #339933;">/</span>local<span style="color: #339933;">/</span>bin<span style="color: #339933;">/</span>php <span style="color: #339933;">-</span>q <span style="color: #339933;">/</span>path<span style="color: #339933;">/</span>to<span style="color: #339933;">/</span>script<span style="color: #339933;">/</span>schedule<span style="color: #339933;">.</span>php</pre></td></tr></table></div>

<p>What this says is, everytime the minute is 0 (i.e. on the hour), run that command.  Look at this crontab entry:</p>

<div class="wp_codebox"><table><tr id="p8316"><td class="code" id="p83code16"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">*/</span><span style="color: #cc66cc;">5</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">*</span> <span style="color: #339933;">*</span> <span style="color: #339933;">*</span> <span style="color: #339933;">/</span>usr<span style="color: #339933;">/</span>local<span style="color: #339933;">/</span>bin<span style="color: #339933;">/</span>php <span style="color: #339933;">-</span>q <span style="color: #339933;">/</span>path<span style="color: #339933;">/</span>to<span style="color: #339933;">/</span>script<span style="color: #339933;">/</span>schedule<span style="color: #339933;">.</span>php</pre></td></tr></table></div>

<p>This one says, each time the minute is a multiple of 5 (i.e. every 5 minutes) and the hour is 2 (i.e. 2:00am), run that command.</p>
<p>So that&#8217;s basically it!  With both those entries in the crontab, our emails will be sent every hour on the hour, and also every 5 minutes between 2:00am and 2:59am.</p>
<p>Hopefully this helps some people.  If you have any questions, or if I made any mistakes, feel free to let me know in the comments  :)</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://japh.com.au/development/sending-scheduled-emails-with-php/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Tracking memory usage</title>
		<link>http://japh.com.au/general/tracking-memory-usage/</link>
		<comments>http://japh.com.au/general/tracking-memory-usage/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 12:35:51 +0000</pubDate>
		<dc:creator>Japh</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[General Chatter]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://japheththomson.com/?p=67</guid>
		<description><![CDATA[Recently I received a warning from my host that I was WAY over my memory limit.  I had some long running processes going, and a few cron scripts that altogether were using about 220mb out of my 120mb of allowed memory usage&#8230;  oops!
Anyway, there&#8217;s currently no way from my control panel to see [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Recently I received a warning from my host that I was WAY over my memory limit.  I had some long running processes going, and a few cron scripts that altogether were using about 220mb out of my 120mb of allowed memory usage&#8230;  oops!</p>
<p>Anyway, there&#8217;s currently no way from my control panel to see how memory I&#8217;m currently using, I have to run a command from a terminal, and certainly no way to tell usage over time.  So, after looking at a thread my hosting provider pointed me to, I decided to have a play with the Google Charts API!<br />
<span id="more-67"></span><br />
This is a pretty rudimentary solution, but it&#8217;s working so far for me.</p>
<p><strong>1. A very simple bash script</strong></p>

<div class="wp_codebox"><table><tr id="p6721"><td class="code" id="p67code21"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #c20cb9; font-weight: bold;">ps</span> <span style="color: #660033;">-u</span> username <span style="color: #660033;">-o</span> pid,rss,<span style="color: #7a0874; font-weight: bold;">command</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-e</span> mpm <span style="color: #660033;">-v</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{sum+=$2} END {print &quot;,&quot;, sum}'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>webroot<span style="color: #000000; font-weight: bold;">/</span>mem<span style="color: #000000; font-weight: bold;">/</span>memdata.csv</pre></td></tr></table></div>

<p>The script basically just outputs the current memory usage at the time of running and appends it to a CSV file.</p>
<p><strong>2. Add the script to the crontab</strong></p>
<p>By running the following command (or one similar), I edit my crontab:</p>

<div class="wp_codebox"><table><tr id="p6722"><td class="code" id="p67code22"><pre class="bash" style="font-family:monospace;">crontab <span style="color: #660033;">-e</span></pre></td></tr></table></div>

<p>I then insert this line:</p>

<div class="wp_codebox"><table><tr id="p6723"><td class="code" id="p67code23"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">0</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">/</span>full<span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>script<span style="color: #000000; font-weight: bold;">/</span>memlogger</pre></td></tr></table></div>

<p>So now that bash script will be run every hour, on the hour.</p>
<p><strong>3. Writing a PHP script to display a Google Chart</strong></p>

<div class="wp_codebox"><table><tr id="p6724"><td class="code" id="p67code24"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// Settings</span>
<span style="color: #000088;">$max_mem</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">120</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Your memory limit, in MB</span>
<span style="color: #000088;">$data_file</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'memdata.csv'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$chart_width</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">550</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$chart_height</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">400</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #339933;">&lt;!</span>DOCTYPE html <span style="color: #000000; font-weight: bold;">PUBLIC</span> <span style="color: #0000ff;">&quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;</span> <span style="color: #0000ff;">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>html xmlns<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.w3.org/1999/xhtml&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>head<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>meta http<span style="color: #339933;">-</span>equiv<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Content-Type&quot;</span> content<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/html; charset=utf-8&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;</span>title<span style="color: #339933;">&gt;</span>Memory Usage<span style="color: #339933;">&lt;/</span>title<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>head<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>body<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>h2<span style="color: #339933;">&gt;</span>Memory Usage<span style="color: #339933;">&lt;/</span>h2<span style="color: #339933;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$md</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/file_get_contents"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data_file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$md</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/(\s+|\n)/'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$md</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$md</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span> <span style="color: #000088;">$md</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a href="http://www.php.net/array_shift"><span style="color: #990000;">array_shift</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$md</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$max</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$min</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$md</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$v</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$v</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$max</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$max</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$v</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$base</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$max</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$base</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$max_mem</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">1024</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #000088;">$max</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$base</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/round"><span style="color: #990000;">round</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$base</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;&lt;</span>img src<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://chart.apis.google.com/chart?cht=lc&amp;chd=t:&lt;?php echo implode(',', <span style="color: #006699; font-weight: bold;">$md</span>); ?&gt;&amp;chs=&lt;?php echo <span style="color: #006699; font-weight: bold;">$chart_width</span>; ?&gt;x&lt;?php echo <span style="color: #006699; font-weight: bold;">$chart_height</span>; ?&gt;&amp;chxt=y,r&amp;chxr=0,&lt;?php echo <span style="color: #006699; font-weight: bold;">$min</span>; ?&gt;,&lt;?php echo <span style="color: #006699; font-weight: bold;">$max</span>; ?&gt;|1,&lt;?php echo <span style="color: #006699; font-weight: bold;">$min</span>; ?&gt;,&lt;?php echo <span style="color: #006699; font-weight: bold;">$max</span>; ?&gt;&amp;chds=&lt;?php echo <span style="color: #006699; font-weight: bold;">$min</span>; ?&gt;,&lt;?php echo <span style="color: #006699; font-weight: bold;">$max</span>; ?&gt;&amp;chm=r,FF0000,0,&lt;?php echo <span style="color: #006699; font-weight: bold;">$base</span>; ?&gt;,&lt;?php echo <span style="color: #006699; font-weight: bold;">$base</span>+0.005; ?&gt;&quot;</span> <span style="color: #339933;">/&gt;&lt;/</span>p<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>body<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>html<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>This code basically just imports the data into an array, and then works a few things out for proper axis labelling, and away it goes!  It&#8217;s pretty quick and dirty, and could probably have been done nicer&#8230;  maybe I&#8217;ll come back and fix it up some time.</p>
<p>It also uses your memory limit amount to show a red line on the graph if you go over  <img src='http://japh.com.au/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Here&#8217;s the chart using some sample data:<br />
<img src="http://japh.com.au/wp-content/uploads/2009/02/memory-usage-chart-300x245.jpg" alt="Memory Usage Chart" title="Memory Usage Chart" width="300" height="245" class="alignnone size-medium wp-image-75" /></p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://japh.com.au/general/tracking-memory-usage/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>APIs and The Grey Album</title>
		<link>http://japh.com.au/general/apis-and-the-grey-album/</link>
		<comments>http://japh.com.au/general/apis-and-the-grey-album/#comments</comments>
		<pubDate>Tue, 06 Jan 2009 14:05:09 +0000</pubDate>
		<dc:creator>Japh</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[General Chatter]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Flickr]]></category>
		<category><![CDATA[photo album]]></category>

		<guid isPermaLink="false">http://japheththomson.com/?p=43</guid>
		<description><![CDATA[Lately I&#8217;ve been playing around with a few different APIs.  Getting the hang of using them and seeing what they can do.  I&#8217;ve had a brief play with both the Flickr and Twitter APIs, and they&#8217;re both actually very user-friendly yet powerful.
I decided to build a simple photo album script using mostly PHP [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Lately I&#8217;ve been playing around with a few different APIs.  Getting the hang of using them and seeing what they can do.  I&#8217;ve had a brief play with both the Flickr and Twitter APIs, and they&#8217;re both actually very user-friendly yet powerful.</p>
<p>I decided to build a simple photo album script using mostly PHP and jQuery to do the tricky parts, and the SimplePie library for actually importing the photo stream.  I&#8217;ve called it <a title="The Grey Album" href="http://japheththomson.com/greyalbum/">The Grey Album</a>, and though I probably wouldn&#8217;t call it a complete and comprehensive script, it seems to do the job.  Any feedback is most welcome!</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://japh.com.au/general/apis-and-the-grey-album/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Migrating from Windows to Ubuntu</title>
		<link>http://japh.com.au/development/migrating-from-windows-to-ubuntu/</link>
		<comments>http://japh.com.au/development/migrating-from-windows-to-ubuntu/#comments</comments>
		<pubDate>Fri, 17 Oct 2008 08:18:53 +0000</pubDate>
		<dc:creator>Japh</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://japheththomson.com/2008/10/17/migrating-from-windows-to-ubuntu/</guid>
		<description><![CDATA[I&#8217;ve always been interested in Linux as an operating system, but found too many reasons to go back to Windows.  Linux was just a fun, geeky thing to play around with, but not really viable for everyday use.
I had dabbled in various Linux distributions.  Gave Redhat and Mandrake a go, then installed Gentoo [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve always been interested in Linux as an operating system, but found too many reasons to go back to Windows.  Linux was just a fun, geeky thing to play around with, but not really viable for everyday use.<span id="more-28"></span></p>
<p>I had dabbled in various Linux distributions.  Gave Redhat and Mandrake a go, then installed Gentoo for a while, which was a brilliant learning experience.  Then almost a year ago, I started playing around with Ubuntu a bit, and then I bought an Eee PC with Xandros installed to take travelling for a few months.  The Eee PC was extremely handy to have while travelling, and I found that Linux was just fine for all the things I needed to do.  So when I got back to work, I decided to just continue on, install Ubuntu and see how I went.</p>
<p>Essentially, I haven&#8217;t looked back.  I now primarily use Ubuntu on my workstation at work, and on all my computers at home.  As a web developer, I primarily work with open source technologies (PHP, Apache, MySQL, Python, etc.).  I usually deploy my projects to a Linux-based server, so it actually makes a lot of sense to be building sites on Linux rather than Windows.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://japh.com.au/development/migrating-from-windows-to-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DIY Dynamic DNS</title>
		<link>http://japh.com.au/networking/diy-dynamic-dns/</link>
		<comments>http://japh.com.au/networking/diy-dynamic-dns/#comments</comments>
		<pubDate>Wed, 08 Oct 2008 11:17:05 +0000</pubDate>
		<dc:creator>Japh</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://japheththomson.com/?p=10</guid>
		<description><![CDATA[I&#8217;ve setup my home network with a domain and wanted to be able to access my home server, from my office, on a subdomain.
However, as is probably the case for most of you, I have a dynamic IP address assigned to my router when it connects to the Internet through my ISP.  So I [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve setup my home network with a domain and wanted to be able to access my home server, from my office, on a subdomain.</p>
<p>However, as is probably the case for most of you, I have a dynamic IP address assigned to my router when it connects to the Internet through my ISP.  So I decided I&#8217;d have to setup my own dynamic DNS process!</p>
<p>First things first, it was necessary to create the subdomain I wanted and point it to my home router&#8217;s external IP address, and also to change the configuration on my router to forward all traffic on port 80 to my home server&#8217;s internal IP address.<br />
<span id="more-10"></span><br />
Next I needed a small script, PHP in this case, on my web server that simply outputs a tiny bit of XML with the current IP address of the visitor.</p>

<div class="wp_codebox"><table><tr id="p1027"><td class="code" id="p10code27"><pre class="php" style="font-family:monospace;"><span style="color: #0000ff;">'; ?&amp;gt;
&lt;!--[CDATA[&lt;?php echo $_SERVER['</span>REMOTE_ADDR<span style="color: #0000ff;">']--&gt;]]&amp;gt;</span></pre></td></tr></table></div>

<p>Then I wrote a small Python script that retrieves the IP address from the PHP script, and calls <a title="WebFaction - Hosting for an agile web" href="http://www.webfaction.com/services/hosting?affiliate=japheth" target="_blank">WebFaction</a>&#8217;s server API to update the DNS record.  This script runs on a crontab every hour, so if my IP address changes, I only have to wait an hour at most for an update.</p>

<div class="wp_codebox"><table><tr id="p1028"><td class="code" id="p10code28"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">urllib</span>
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">xml</span>.<span style="color: black;">dom</span> <span style="color: #ff7700;font-weight:bold;">import</span> minidom
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">xmlrpclib</span>
dyndomain = <span style="color: #483d8b;">'homeserver.example.com'</span>
ip_url = <span style="color: #dc143c;">urllib</span>.<span style="color: black;">urlopen</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://www.example.com/ip.php'</span><span style="color: black;">&#41;</span>
ip_dom = minidom.<span style="color: black;">parse</span><span style="color: black;">&#40;</span>ip_url<span style="color: black;">&#41;</span>
ip_string = ip_dom.<span style="color: black;">toxml</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
ip_address = ip_dom.<span style="color: black;">getElementsByTagName</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;ip&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>.<span style="color: black;">childNodes</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>.<span style="color: black;">data</span>
<span style="color: #ff7700;font-weight:bold;">print</span> ip_address
server = <span style="color: #dc143c;">xmlrpclib</span>.<span style="color: black;">ServerProxy</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'https://api.webfaction.com/'</span><span style="color: black;">&#41;</span>
session_id, account = server.<span style="color: black;">login</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'username'</span>, <span style="color: #483d8b;">'password'</span><span style="color: black;">&#41;</span>
server.<span style="color: black;">delete_dns_override</span><span style="color: black;">&#40;</span>session_id, dyndomain<span style="color: black;">&#41;</span>
server.<span style="color: black;">create_dns_override</span><span style="color: black;">&#40;</span>session_id, dyndomain, ip_address, <span style="color: #483d8b;">''</span>, <span style="color: #483d8b;">''</span>, <span style="color: #483d8b;">''</span>, <span style="color: #483d8b;">''</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>Next I may add logging, so I can see when my IP address changes, but that&#8217;s optional really.</p>
<p><strong>Note:</strong> Also, if someone can recommend a really good code-highlighter plugin for WordPress, I&#8217;d be <em>very</em> grateful!</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://japh.com.au/networking/diy-dynamic-dns/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Fun with wild-card domain names</title>
		<link>http://japh.com.au/php/fun-with-wild-card-domain-names/</link>
		<comments>http://japh.com.au/php/fun-with-wild-card-domain-names/#comments</comments>
		<pubDate>Tue, 16 Sep 2008 00:25:59 +0000</pubDate>
		<dc:creator>Japh</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[DNS]]></category>

		<guid isPermaLink="false">http://japheththomson.com/2008/09/16/fun-with-wild-card-domain-names/</guid>
		<description><![CDATA[After seeing quite a few websites with dynamic content based on the domain name, I wanted to give it a try to see how difficult it was to achieve.
Here&#8217;s what I came up with: DueABootin.com
As it turns out, it wasn&#8217;t very difficult at all!  (Especially being hosted through WebFaction, they make it even easier!)

First, I [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>After seeing quite a few websites with dynamic content based on the domain name, I wanted to give it a try to see how difficult it was to achieve.</p>
<p>Here&#8217;s what I came up with: <a title="DueABootin.com" href="http://reader.of.my.blog.dueabootin.com" target="_blank">DueABootin.com</a></p>
<p>As it turns out, it wasn&#8217;t very difficult at all!  (Especially being hosted through <a title="WebFaction - Hosting for an agile web" href="http://www.webfaction.com/services/hosting?affiliate=japheth" target="_blank">WebFaction</a>, they make it even easier!)<br />
<span id="more-7"></span><br />
First, I added the domain to my control panel, an added a subdomain of &#8220;*&#8221;, as you can see in the screenshot below.</p>
<p><img title="WebFaction Control Panel - DueABootin.com" src="http://japheththomson.com/img/wf_cp_dueabootin.png" alt="WebFaction Control Panel - DueABootin.com" width="371" height="202" /></p>
<p>And that&#8217;s really the hardest part, because PHP provides a nice little pre-defined variable called $_SERVER['HTTP_HOST'] which then gives us &#8220;example.dueabootin.com&#8221;, which we can pull apart and do with what we like.</p>
<p><strong>Update: I&#8217;ve had a bit of a look into how difficult it might be to achieve the same results with cPanel, and it&#8217;s not much more difficult.</strong></p>
<p>Create a new sub-domain called &#8220;*&#8221; which does not re-direct, just points to public_html/, and you should be fine.  If that alone doesn&#8217;t work, then you may need to add an A record to your DNS zone file something like:</p>
<p>*.example.com.  14400  IN  A  192.168.1.101</p>
<p>(don&#8217;t forget the trailing &#8220;.&#8221; after &#8220;.com&#8221;)</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://japh.com.au/php/fun-with-wild-card-domain-names/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>A shell for your HTML</title>
		<link>http://japh.com.au/html/a-shell-for-your-html/</link>
		<comments>http://japh.com.au/html/a-shell-for-your-html/#comments</comments>
		<pubDate>Sun, 23 Sep 2007 13:53:35 +0000</pubDate>
		<dc:creator>Japh</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.japheththomson.com/?p=5</guid>
		<description><![CDATA[Ok, so I promised you the basic structure of an HTML page.  So here is it:

&#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62;
&#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&#62;
&#60;head&#62;
&#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=utf-8&#34; /&#62;
&#60;title&#62;My First HTML Page&#60;/title&#62;
&#60;/head&#62;
&#60;body&#62;
&#60;p&#62;This is the first paragraph on the page.&#60;/p&#62;
&#60;p&#62;This is the second paragraph on the page, and it's a little bit longer than the first [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Ok, so I promised you the basic structure of an HTML page.  So here is it:</p>

<div class="wp_codebox"><table><tr id="p531"><td class="code" id="p5code31"><pre class="html" style="font-family:monospace;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;My First HTML Page&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;p&gt;This is the first paragraph on the page.&lt;/p&gt;
&lt;p&gt;This is the second paragraph on the page, and it's a little bit longer than the first one.  Try resizing your window to make it narrower to see the text wrap but maintain the paragraph spacing.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p><span id="more-5"></span>Now I&#8217;ll explain what it all means!</p>
<p>The first line tells the user&#8217;s browser some basic information about how to treat the code it finds in the document.  It&#8217;s HTML, in fact, it says that it&#8217;s XHTML 1.0 Transitional.  At this point, that won&#8217;t mean much to you, and it also won&#8217;t really matter to you.  Essentially, the internet is currently transitioning from using HTML, to using XML for defining or describing the structure of a web page.  So if you&#8217;re interested in <a title="XHTML - Wikipedia" href="http://en.wikipedia.org/wiki/XHTML" target="_blank">reading more about XHTML, check out Wikipedia</a>.</p>
<p>The next line is the opening html tag.  Everything on your page should be placed within your opening and closing html tags.</p>
<p>Within your html tags, you should have a set of head tags, and a set of body tags.  Everything on your page should be within one of these two.  Content between the body tags, and various other things that we&#8217;ll get to later, between the head tags.</p>
<p>Two things we can see here already in the head tags, are a meta tag, and a title tag.  Meta tags have a number of different uses.  This particular one is defining the character set to be used on the page (UTF-8 in this case), you can also use them to define keywords for search engines and things like that.</p>
<p>The title tag defines what will appear in the user&#8217;s title bar on their browser.  For example, on this page if you look up in the title bar of your browser, you&#8217;ll see it says &#8220;Japheth Thomson&#8221;, possibly followed by some arrows and some other text (depending how you got to this article).</p>
<p>For now, you can just copy and paste the code above into a new text file, save it as template.html, and then open it in a browser to see what happens.</p>
<p>You should get a blank white page, with the words &#8220;Untitled Document&#8221; in your title bar.  Once you&#8217;ve got that working fine, try having a play with inserting paragraph tags as I talked about in my previous post to see what happens.</p>
<p>As an example, you should end up with something like this:</p>

<div class="wp_codebox"><table><tr id="p532"><td class="code" id="p5code32"><pre class="html" style="font-family:monospace;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;My First HTML Page&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;p&gt;This is paragraph number on this HTML page.&lt;/p&gt;
&lt;p&gt;This is the second paragraph.  It's a bit longer than the first so that if you resize your window at all, you'll be able to see the text wrapping and maintaining the paragraph spacing above and below it.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>



<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://japh.com.au/html/a-shell-for-your-html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
