<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" xml:lang="en" xml:base="http://www.metatitan.com/wp-atom.php">
	<title type="text">Meta Titan</title>
	<subtitle type="text">Knowledge to help you build good websites</subtitle>

	<updated>2009-04-12T07:29:44Z</updated>
	<generator uri="http://wordpress.org/" version="2.7.1">WordPress</generator>

	<link rel="alternate" type="text/html" href="http://www.metatitan.com" />
	<id>http://www.metatitan.com/feed/atom</id>
	

			<link rel="self" href="http://feeds.feedburner.com/metatitan" type="application/atom+xml" /><entry>
		<author>
			<name>Matt</name>
						<uri>http://www.metatitan.com</uri>
					</author>
		<title type="html"><![CDATA[How to Build a Scraper Using PHP &amp; cURL]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/metatitan/~3/_mEWCS-z3BQ/how-to-build-a-scraper-using-php-curl.html" />
		<id>http://www.metatitan.com/?p=27</id>
		<updated>2009-04-12T07:19:14Z</updated>
		<published>2009-04-12T07:12:41Z</published>
		<category scheme="http://www.metatitan.com" term="PHP" />		<summary type="html"><![CDATA[Use the following knowledge at your own risk, scraping content is a pretty gray area. For this guide you will need FireFox and the Firebug extension. You&#8217;ll also need PHP installed with the cURL module.
For this example we&#8217;ll be grabbing the counters for &#8220;bloggers, new posts and words today&#8221; from WordPress.com. Let&#8217;s start off by [...]]]></summary>
		<content type="html" xml:base="http://www.metatitan.com/php/27/how-to-build-a-scraper-using-php-curl.html"><![CDATA[<p>Use the following knowledge at your own risk, scraping content is a pretty gray area. For this guide you will need <a href="http://www.mozilla.com/firefox/">FireFox</a> and the <a href="http://getfirebug.com/">Firebug</a> extension. You&#8217;ll also need PHP installed with the cURL module.</p>
<p>For this example we&#8217;ll be grabbing the counters for &#8220;bloggers, new posts and words today&#8221; from <a href="http://wordpress.com/">WordPress.com</a>. Let&#8217;s start off by creating a function to fetch the html contents of a webpage using cURL.</p>
<div class="codesnip-container" >
<div class="codesnip" style="font-family: monospace;"><span class="kw2">function</span> getDocument<span class="br0">&#40;</span><span class="re0">$url</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$ch</span> = curl_init<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; curl_setopt<span class="br0">&#40;</span><span class="re0">$ch</span>, CURLOPT_USERAGENT, <span class="st0">&#8216;Googlebot/2.1 (http://www.googlebot.com/bot.html)&#8217;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; curl_setopt<span class="br0">&#40;</span><span class="re0">$ch</span>, CURLOPT_URL,<span class="re0">$url</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; curl_setopt<span class="br0">&#40;</span><span class="re0">$ch</span>, CURLOPT_FAILONERROR, <span class="kw2">true</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; curl_setopt<span class="br0">&#40;</span><span class="re0">$ch</span>, CURLOPT_FOLLOWLOCATION, <span class="kw2">true</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; curl_setopt<span class="br0">&#40;</span><span class="re0">$ch</span>, CURLOPT_AUTOREFERER, <span class="kw2">true</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; curl_setopt<span class="br0">&#40;</span><span class="re0">$ch</span>, CURLOPT_RETURNTRANSFER,<span class="kw2">true</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; curl_setopt<span class="br0">&#40;</span><span class="re0">$ch</span>, CURLOPT_TIMEOUT, <span class="nu0">10</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$html</span> = curl_exec<span class="br0">&#40;</span><span class="re0">$ch</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="re0">$html</span>;<br />
<span class="br0">&#125;</span></div>
</div>
<p>We&#8217;ll be disguising ourselves as Googlebot. You can find a list of user agents to use at <a href="http://www.user-agents.org/">http://www.user-agents.org/</a>. Next we&#8217;ll create a DOM object out of the raw html code.</p>
<div class="codesnip-container" >
<div class="codesnip" style="font-family: monospace;"><span class="re0">$html</span> = <span class="re0">$this</span>-&gt;<span class="me1">getDocument</span><span class="br0">&#40;</span><span class="st0">&#8216;http://wordpress.com&#8217;</span><span class="br0">&#41;</span>;<br />
<span class="re0">$dom</span> = <span class="kw2">new</span> DOMDocument<span class="br0">&#40;</span><span class="br0">&#41;</span>; <br />
@<span class="re0">$dom</span>-&gt;<span class="me1">loadHtml</span><span class="br0">&#40;</span><span class="re0">$html</span><span class="br0">&#41;</span>;</div>
</div>
<p>Note the @, this eliminates any errors that might (and most likely will) get output due to the website not following html coding standards. Next, we will use FireBug to find the XPath of what you want to scrape. Right click on what you want to scrape and click &#8220;Inspect Element&#8221;. FireBug will pop up with the code highlighted. At the time of this blog post this is what pops up:</p>
<div class="codesnip-container" >
<div class="codesnip" style="font-family: monospace;"><span class="sc2"><a href="http://december.com/html/4/element/h6.html"><span class="kw2">&lt;h6&gt;</span></a></span><br />
<span class="sc2"><a href="http://december.com/html/4/element/span.html"><span class="kw2">&lt;span&gt;</span></a></span>204,045<span class="sc2"><span class="kw2">&lt;/span&gt;</span></span><br />
bloggers,<br />
<span class="sc2"><a href="http://december.com/html/4/element/span.html"><span class="kw2">&lt;span&gt;</span></a></span>133,640<span class="sc2"><span class="kw2">&lt;/span&gt;</span></span><br />
new posts,<br />
<span class="sc2"><a href="http://december.com/html/4/element/span.html"><span class="kw2">&lt;span&gt;</span></a></span>34,374,943<span class="sc2"><span class="kw2">&lt;/span&gt;</span></span><br />
words today.<br />
<span class="sc2"><span class="kw2">&lt;/h6&gt;</span></span></div>
</div>
<p>h6 is the container of the content we want to scrape, thus the xpath of the h6 tag is what we want. Right click on the h6 tag inside FireBug and click &#8220;Copy XPath&#8221;. This saves something like &#8220;/html/body/div/div[2]/div[2]/h6&#8243; to our clipboard. So we&#8217;ll add the following to our code:</p>
<div class="codesnip-container" >
<div class="codesnip" style="font-family: monospace;"><span class="re0">$xpath</span> = <span class="kw2">new</span> DOMXPath<span class="br0">&#40;</span><span class="re0">$dom</span><span class="br0">&#41;</span>; <br />
<span class="re0">$content</span> = <span class="re0">$xpath</span>-&gt;<span class="me1">query</span><span class="br0">&#40;</span><span class="st0">&quot;/html/body/div/div[2]/div[2]/h6&quot;</span><span class="br0">&#41;</span>;</div>
</div>
<p><strong>Note: </strong> If your xpath contains any &#8216;tbody&#8217;, remove them from the path.</p>
<p>The span tags with our desired content is now accessible through $content->item(0)->childNodes - You can chose to iterate through this if the list, or for simple uses like our example you can call the child item directly like so:</p>
<div class="codesnip-container" >
<div class="codesnip" style="font-family: monospace;"><a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&#8216;Bloggers: &#8216;</span> . <span class="re0">$content</span>-&gt;<span class="me1">item</span><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span>-&gt;<span class="me1">childNodes</span>-&gt;<span class="me1">item</span><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span>-&gt;<span class="me1">nodeValue</span> . <span class="st0">&#8216;&lt;br /&gt;&#8217;</span>;<br />
<a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&#8216;New Posts: &#8216;</span> . <span class="re0">$content</span>-&gt;<span class="me1">item</span><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span>-&gt;<span class="me1">childNodes</span>-&gt;<span class="me1">item</span><span class="br0">&#40;</span><span class="nu0">2</span><span class="br0">&#41;</span>-&gt;<span class="me1">nodeValue</span> . <span class="st0">&#8216;&lt;br /&gt;&#8217;</span>;<br />
<a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&#8216;Words Today: &#8216;</span> . <span class="re0">$content</span>-&gt;<span class="me1">item</span><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span>-&gt;<span class="me1">childNodes</span>-&gt;<span class="me1">item</span><span class="br0">&#40;</span><span class="nu0">4</span><span class="br0">&#41;</span>-&gt;<span class="me1">nodeValue</span>;</div>
</div>
<p>To get the most out of this technique you should brush up your knowledge of the <a href="http://ca.php.net/dom">Document Object Model</a>.</p>
]]></content>
		<link rel="replies" type="text/html" href="http://www.metatitan.com/php/27/how-to-build-a-scraper-using-php-curl.html#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://www.metatitan.com/php/27/how-to-build-a-scraper-using-php-curl.html/feed/atom" thr:count="0" />
		<thr:total>0</thr:total>
	<feedburner:origLink>http://www.metatitan.com/php/27/how-to-build-a-scraper-using-php-curl.html</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Matt</name>
						<uri>http://www.metatitan.com</uri>
					</author>
		<title type="html"><![CDATA[Best Dedicated Web Host? Meet SoftLayer]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/metatitan/~3/hfx4t5c_xDY/best-dedicated-web-host-meet-softlayer.html" />
		<id>http://www.metatitan.com/?p=25</id>
		<updated>2009-04-12T06:02:01Z</updated>
		<published>2009-04-12T06:02:01Z</published>
		<category scheme="http://www.metatitan.com" term="Hosting" />		<summary type="html"><![CDATA[Webmasters who create sites that grow beyond the capabilities of a Shared host are often faced with the daunting task of choosing a dedicated hosting provider. I&#8217;ve been all across town; hosting with ev1servers (now ThePlanet), iWeb Technologies, Mediatemple, and more who I dare not name as their respective levels of service do not deserve [...]]]></summary>
		<content type="html" xml:base="http://www.metatitan.com/hosting/25/best-dedicated-web-host-meet-softlayer.html"><![CDATA[<p>Webmasters who create sites that grow beyond the capabilities of a Shared host are often faced with the daunting task of choosing a dedicated hosting provider. I&#8217;ve been all across town; hosting with ev1servers (now ThePlanet), iWeb Technologies, Mediatemple, and more who I dare not name as their respective levels of service do not deserve the attention. The biggest problem I&#8217;ve run into with these companies is support. I remember an instance with iWeb where my server went down at 8pm, and since their high level technicians were off for the day I had to wait until 8am to get service. Now not every situation with the aforementioned dedicated companies was that extreme, but they have their issues.</p>
<p>Back in December of 07 one of my largest websites suffered a DDoS attack. My datacenter (iWeb) said the only solution would be to shut down my servers, null route the ips and wait it out. After a few sleepless nights I came across SoftLayer, read about their <a href="http://www.softlayer.com/facilities_network.html">Cisco Guard</a> DDoS protection system. I went into a chat with sales, explained my situation and they went over my logs with me, outlined what hardware I should order and how they intend on thwarting the attack.</p>
<p>They put me on the Cisco Guard, monitored the attack and noticed a pattern from the attacker - they were all on a rare useragent and from Asia. SoftLayer developed a solution for me that would block all traffic from Asia with the useragent, and the attack came to an immediate halt.</p>
<p>Moving to SoftLayer ended up being a great decision, I&#8217;ve been with them ever since and have ordered 8 servers there. Their support is scary-good, every time I&#8217;ve called them, day or night, they have answered within 1 ring. Every ticket I have posted have been acknowledged within 10 minutes and acted on shortly after. </p>
<p>The most interesting service they offer is $3 administrative tickets. They do standard support tickets, hardware failures, server outages, etc. for free, but they&#8217;ll also do practically ANY administrative work on your server for just $3 a pop. Need Apache/PHP installed? Done. Memcached? Done. JPG Delagates for ImageMagick? Done and done. This makes running a dedicated server as an amateur, or even an experienced professional who just doesn&#8217;t have time - easy as pie.</p>
<p>Their management portal is very slick, giving you so much control over your server that it&#8217;s hardly ever necessary to make a ticket asking for support. From rebooting your server to reloading the whole OS, it can all be done automatically with the push of a button.</p>
<p>I could gush all day about SoftLayer and how they&#8217;re on a whole different level than the competition - but I&#8217;d feel silly if I said any more here. I highly recommend them for a website (or group of websites) of any shape &#038; size. </p>
<p><a href="http://www.softlayer.com">http://www.softlayer.com</a></p>
]]></content>
		<link rel="replies" type="text/html" href="http://www.metatitan.com/hosting/25/best-dedicated-web-host-meet-softlayer.html#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://www.metatitan.com/hosting/25/best-dedicated-web-host-meet-softlayer.html/feed/atom" thr:count="0" />
		<thr:total>0</thr:total>
	<feedburner:origLink>http://www.metatitan.com/hosting/25/best-dedicated-web-host-meet-softlayer.html</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Matt</name>
						<uri>http://www.metatitan.com</uri>
					</author>
		<title type="html"><![CDATA[Rising from the ashes]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/metatitan/~3/YUmS2yeerxM/rising-from-the-ashes.html" />
		<id>http://www.metatitan.com/misc/24/rising-from-the-ashes.html</id>
		<updated>2009-04-12T05:03:01Z</updated>
		<published>2009-04-12T05:03:01Z</published>
		<category scheme="http://www.metatitan.com" term="Miscellaneous" />		<summary type="html"><![CDATA[I can&#8217;t believe it&#8217;s been well over a year since I last updated Meta Titan. I&#8217;ve been extremely busy with personal &#038; work projects and just haven&#8217;t had time to write new and interesting things for the site.
That&#8217;s all about to change, as I&#8217;ve dusted off the ol&#8217; WordPress, cleaned out the comment spam and [...]]]></summary>
		<content type="html" xml:base="http://www.metatitan.com/misc/24/rising-from-the-ashes.html"><![CDATA[<p>I can&#8217;t believe it&#8217;s been well over a year since I last updated Meta Titan. I&#8217;ve been extremely busy with personal &#038; work projects and just haven&#8217;t had time to write new and interesting things for the site.</p>
<p>That&#8217;s all about to change, as I&#8217;ve dusted off the ol&#8217; WordPress, cleaned out the comment spam and I&#8217;m currently preparing some articles &#038; tools for the site. Stay tuned!</p>
]]></content>
		<link rel="replies" type="text/html" href="http://www.metatitan.com/misc/24/rising-from-the-ashes.html#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://www.metatitan.com/misc/24/rising-from-the-ashes.html/feed/atom" thr:count="0" />
		<thr:total>0</thr:total>
	<feedburner:origLink>http://www.metatitan.com/misc/24/rising-from-the-ashes.html</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Matt</name>
						<uri>http://www.metatitan.com</uri>
					</author>
		<title type="html"><![CDATA[Classes vs IDs, CSS Practice]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/metatitan/~3/xYVzdYpv9Jc/classes-vs-ids-css-practice.html" />
		<id>http://www.metatitan.com/misc/22/classes-vs-ids-css-practice.html</id>
		<updated>2008-01-03T20:27:11Z</updated>
		<published>2008-01-03T20:22:29Z</published>
		<category scheme="http://www.metatitan.com" term="CSS" />		<summary type="html"><![CDATA[A good use of classes and IDs can save you a lot of time. You&#8217;ll end up with a site that&#8217;s easy to maintain, and frankly, your code will look a lot cleaner. There are certain rules and practices when using classes and IDs, the following guide looks over them.
First off, what defines an ID [...]]]></summary>
		<content type="html" xml:base="http://www.metatitan.com/css/22/classes-vs-ids-css-practice.html"><![CDATA[<p>A good use of classes and IDs can save you a lot of time. You&#8217;ll end up with a site that&#8217;s easy to maintain, and frankly, your code will look a lot cleaner. There are certain rules and practices when using classes and IDs, the following guide looks over them.</p>
<p>First off, what defines an ID and a class? Simply put, an ID is a unique identifier and should only be used once in your document. It&#8217;s good practice to use ID on structural blocks of your site such as a wrapper, header, footer, navigation bar, etc. A class can be used more broadly to define objects that can appear multiple times in your document, such as link styling, tables, etc.</p>
<p><strong>Example usage of an ID:</strong></p>
<p>In your html code:<br />
&lt;div id=&#8221;mainWrapper&#8221;&gt;content&lt;/div&gt;</p>
<p>In your stylesheet:<br />
div#mainWrapper { margin: 10px 30px; }</p>
<p><strong>Example usage of a Class:</strong></p>
<p>In your html code:<br />
&lt;span class=&#8221;test&#8221;&gt;Hello, World&lt;/span&gt;</p>
<p>In your stylesheet:<br />
span.test { color: #003366; font-weight: 900; } </p>
<p>When naming your classes and IDs, try and use generic and easy to identify names. For example, instead of calling something &#8220;yellowBar&#8221; try &#8220;topSidebar&#8221;. Who knows what color that bar will be 6 months from now! Also, pick a naming style that you&#8217;re comfortable with and stick to it - either lowercase (#helloworld) or camel case (#helloWorld) - you should never use spacing in names.</p>
]]></content>
		<link rel="replies" type="text/html" href="http://www.metatitan.com/css/22/classes-vs-ids-css-practice.html#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://www.metatitan.com/css/22/classes-vs-ids-css-practice.html/feed/atom" thr:count="0" />
		<thr:total>0</thr:total>
	<feedburner:origLink>http://www.metatitan.com/css/22/classes-vs-ids-css-practice.html</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Matt</name>
						<uri>http://www.metatitan.com</uri>
					</author>
		<title type="html"><![CDATA[How to Calculate PHP Load Times]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/metatitan/~3/Rf7ldV-WS3A/how-to-calculate-php-load-times.html" />
		<id>http://www.metatitan.com/php/21/how-to-calculate-php-load-times.html</id>
		<updated>2009-04-12T05:10:01Z</updated>
		<published>2007-12-13T12:42:06Z</published>
		<category scheme="http://www.metatitan.com" term="PHP" />		<summary type="html"><![CDATA[Here&#8217;s a popular request amongst those who are learning PHP. When developing PHP applications, it&#8217;s good practice to benchmark your pages to see if you need to further optimize your code. The following snippet will show you how much time it took your server to process your PHP document.
Insert this at or near the top [...]]]></summary>
		<content type="html" xml:base="http://www.metatitan.com/php/21/how-to-calculate-php-load-times.html"><![CDATA[<p>Here&#8217;s a popular request amongst those who are learning PHP. When developing PHP applications, it&#8217;s good practice to benchmark your pages to see if you need to further optimize your code. The following snippet will show you how much time it took your server to process your PHP document.</p>
<p>Insert this at or near the top of your PHP file.</p>
<div class="codesnip-container" >
<div class="codesnip" style="font-family: monospace;"><span class="re0">$m_time</span> = <a href="http://www.php.net/explode"><span class="kw3">explode</span></a><span class="br0">&#40;</span><span class="st0">&quot; &quot;</span>,<a href="http://www.php.net/microtime"><span class="kw3">microtime</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
<span class="re0">$m_time</span> = <span class="re0">$m_time</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span> + <span class="re0">$m_time</span><span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span>;<br />
<span class="re0">$loadstart</span> = <span class="re0">$m_time</span>;</div>
</div>
<p>Now place this snippet at or near the bottom of your file for the best results.</p>
<div class="codesnip-container" >
<div class="codesnip" style="font-family: monospace;"><span class="re0">$m_time</span> = <a href="http://www.php.net/explode"><span class="kw3">explode</span></a><span class="br0">&#40;</span><span class="st0">&quot; &quot;</span>,<a href="http://www.php.net/microtime"><span class="kw3">microtime</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
<span class="re0">$m_time</span> = <span class="re0">$m_time</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span> + <span class="re0">$m_time</span><span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span>;<br />
<span class="re0">$loadend</span> = <span class="re0">$m_time</span>;<br />
<span class="re0">$loadtotal</span> = <span class="br0">&#40;</span><span class="re0">$loadend</span> - <span class="re0">$loadstart</span><span class="br0">&#41;</span>;<br />
<a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&quot;&lt;small&gt;&lt;em&gt;Generated page in &quot;</span>. <a href="http://www.php.net/round"><span class="kw3">round</span></a><span class="br0">&#40;</span><span class="re0">$loadtotal</span>,<span class="nu0">3</span><span class="br0">&#41;</span> .<span class="st0">&quot; seconds&lt;/em&gt;&lt;/small&gt;&quot;</span>;</div>
</div>
<p>That&#8217;s it! I suggest adding this while you develop any PHP application, and include it even after the launch, so that you can see how well your scripts scale with the traffic you receive.</p>
]]></content>
		<link rel="replies" type="text/html" href="http://www.metatitan.com/php/21/how-to-calculate-php-load-times.html#comments" thr:count="6" />
		<link rel="replies" type="application/atom+xml" href="http://www.metatitan.com/php/21/how-to-calculate-php-load-times.html/feed/atom" thr:count="6" />
		<thr:total>6</thr:total>
	<feedburner:origLink>http://www.metatitan.com/php/21/how-to-calculate-php-load-times.html</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Matt</name>
						<uri>http://www.metatitan.com</uri>
					</author>
		<title type="html"><![CDATA[Backing up a MySQL Database Using Cron]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/metatitan/~3/zQ0pz86wJl0/backing-up-a-mysql-database-using-cron.html" />
		<id>http://www.metatitan.com/mysql/20/backing-up-a-mysql-database-using-cron.html</id>
		<updated>2007-12-10T15:53:28Z</updated>
		<published>2007-12-10T15:44:06Z</published>
		<category scheme="http://www.metatitan.com" term="MySQL" />		<summary type="html"><![CDATA[It sure has been awhile since I&#8217;ve updated, things have been pretty busy and I just haven&#8217;t had time. Anyway, the most important and often overlooked part of running a dynamic MySQL website is backing up your data often. Losing your file system often doesn&#8217;t hurt as much as losing all of your content, especially [...]]]></summary>
		<content type="html" xml:base="http://www.metatitan.com/mysql/20/backing-up-a-mysql-database-using-cron.html"><![CDATA[<p>It sure has been awhile since I&#8217;ve updated, things have been pretty busy and I just haven&#8217;t had time. Anyway, the most important and often overlooked part of running a dynamic MySQL website is backing up your data often. Losing your file system often doesn&#8217;t hurt as much as losing all of your content, especially when running a script that&#8217;s easily replaceable like vBulletin, Wordpress, etc. Backing up your data can be a chore, so this is the simple method I use for an automated backup of my databases.</p>
<p>1) SSH in your box</p>
<p>2) Open up your crontab, to do this type:<br />
<em>crontab -e</em></p>
<p>3) Add the job to your crontab, this is what I use:<br />
<em>30 0 * * * date=`date -I` ; mysqldump -a -u<strong>user</strong> -p<strong>password</strong> <strong>dbname</strong> &gt; <strong>/path/to/dump_$date.sql</strong></em></p>
<p>I&#8217;ll break down what&#8217;s going on in the above line and what you need to edit
<ul>
<li>30 0 * * * - This specifies the interval in which it will backup your data. Minutes, hours, days of the month, months, days of the week, respectively. In my case, I&#8217;m going to be running this every day at 12:30 AM. Asterisk out values which you do not need to limit.</li>
<li>user - Enter your mysql username here</li>
<li>password - Enter your mysql password here</li>
<li>It&#8217;s important to note that -uuser is not a typo, you need to prefix -u on your username, so if it&#8217;s jsmith, you will enter -ujsmith. Same goes for your password.</li>
<li>dbname - Enter the mysql database name which you want to backup</li>
<li>/path/to/dump_$date.sql - Enter the directory you wish to back up your data to, include $date if you want a datestamp on your backup names. Don&#8217;t back this up to a web accessible directory as anyone would be able to access your database information and view potentially sensitive data.</li>
</ul>
<p>Once your cron job is up and running you can then use a 3rd party backup service to automatically pull those backups across onto secure networks at set intervals (ie: every day at 12:40 AM). Talk to your hosting provider as many already provide backup services like this. You can also choose to manually download them onto your hard drive if you prefer a most cost effective approach. Just remember to go in weekly or monthly to delete older backups if necessary - those with large databases may eventually max out their hard drive space if left unattended.</p>
]]></content>
		<link rel="replies" type="text/html" href="http://www.metatitan.com/mysql/20/backing-up-a-mysql-database-using-cron.html#comments" thr:count="2" />
		<link rel="replies" type="application/atom+xml" href="http://www.metatitan.com/mysql/20/backing-up-a-mysql-database-using-cron.html/feed/atom" thr:count="2" />
		<thr:total>2</thr:total>
	<feedburner:origLink>http://www.metatitan.com/mysql/20/backing-up-a-mysql-database-using-cron.html</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Matt</name>
						<uri>http://www.metatitan.com</uri>
					</author>
		<title type="html"><![CDATA[New Look]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/metatitan/~3/E3-LUajTn_w/new-look.html" />
		<id>http://www.metatitan.com/misc/19/new-look.html</id>
		<updated>2007-10-30T14:15:25Z</updated>
		<published>2007-10-30T14:13:30Z</published>
		<category scheme="http://www.metatitan.com" term="Miscellaneous" />		<summary type="html"><![CDATA[It felt unfitting for a blog that teaches and discusses web development tips &#038; tricks to use a generic widely used WordPress theme. I&#8217;ve launched a new custom look for Meta Titan and I&#8217;m just working out the kinks and making adjustments.
I have a couple entries planned for this week so keep an eye out [...]]]></summary>
		<content type="html" xml:base="http://www.metatitan.com/misc/19/new-look.html"><![CDATA[<p>It felt unfitting for a blog that teaches and discusses web development tips &#038; tricks to use a generic widely used WordPress theme. I&#8217;ve launched a new custom look for Meta Titan and I&#8217;m just working out the kinks and making adjustments.</p>
<p>I have a couple entries planned for this week so keep an eye out for them!</p>
]]></content>
		<link rel="replies" type="text/html" href="http://www.metatitan.com/misc/19/new-look.html#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://www.metatitan.com/misc/19/new-look.html/feed/atom" thr:count="0" />
		<thr:total>0</thr:total>
	<feedburner:origLink>http://www.metatitan.com/misc/19/new-look.html</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Matt</name>
						<uri>http://www.metatitan.com</uri>
					</author>
		<title type="html"><![CDATA[Show/Hide Content With CSS &amp; Javascript]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/metatitan/~3/a5sDiDCqFxk/showhide-content-with-css-javascript.html" />
		<id>http://www.metatitan.com/css/18/showhide-content-with-css-javascript.html</id>
		<updated>2009-04-12T05:13:29Z</updated>
		<published>2007-10-28T05:51:50Z</published>
		<category scheme="http://www.metatitan.com" term="CSS" />		<summary type="html"><![CDATA[My apologies for the recent lack of updates and the briefness of this post, things have been (and still are) really busy on my end. Anyway, when building websites for my clients a popular request is to have content that can be toggled by the user. Today I&#8217;ll show you have to have this effect [...]]]></summary>
		<content type="html" xml:base="http://www.metatitan.com/css/18/showhide-content-with-css-javascript.html"><![CDATA[<p>My apologies for the recent lack of updates and the briefness of this post, things have been (and still are) really busy on my end. Anyway, when building websites for my clients a popular request is to have content that can be toggled by the user. Today I&#8217;ll show you have to have this effect done really quickly. Although this method does not support persistence (saving cookies to the users browser to remember what they have hidden/shown), I&#8217;m sure there are some who will find it useful.</p>
<p>Place this code in your &lt;head&gt; tags.</p>
<div class="codesnip-container" >
<div class="codesnip" style="font-family: monospace;"><span class="sc2"><a href="http://december.com/html/4/element/script.html"><span class="kw2">&lt;script</span></a> <span class="kw3">type</span>=<span class="st0">&quot;text/javascript&quot;</span><span class="kw2">&gt;</span></span><br />
function shToggle(content) {<br />
&nbsp; if (document.getElementById(content).style.display == &quot;none&quot;) <br />
&nbsp; &nbsp; document.getElementById(content).style.display = &quot;block&quot;<br />
&nbsp; else<br />
&nbsp; &nbsp; document.getElementById(content).style.display = &quot;none&quot;<br />
}<br />
<span class="sc2"><span class="kw2">&lt;/script&gt;</span></span></div>
</div>
<p>Now you can effectively show/hide content by placing <strong>id=&#8221;<em>elementname</em>&#8221; style=&#8221;display:none;&#8221;</strong> inside the element tag you wish to be toggle-able, and <strong> onclick=&#8221;shToggle(&#8217;<em>elementname</em>&#8216;); return false;&#8221;</strong> inside the link code of the image or text the user clicks to toggle it. You can see a live example of it on <a href="http://www.metatitan.com/files/showhide.html">this page</a>, or simply look at the example code snippet below.</p>
<div class="codesnip-container" >
<div class="codesnip" style="font-family: monospace;"><span class="sc2"><a href="http://december.com/html/4/element/strong.html"><span class="kw2">&lt;strong&gt;</span></a></span>What&#8217;s the name of Calgary&#8217;s NHL Team?<span class="sc2"><span class="kw2">&lt;/span&gt;</span></span><br />
<span class="sc2"><a href="http://december.com/html/4/element/a.html"><span class="kw2">&lt;a</span></a> <span class="kw3">href</span>=<span class="st0">&quot;javascript:void(0);&quot;</span> <span class="kw3">onclick</span>=<span class="st0">&quot;shToggle(&#8217;calgary&#8217;); return false;&quot;</span><span class="kw2">&gt;</span></span>show/hide answer<span class="sc2"><span class="kw2">&lt;/a&gt;</span></span></p>
<p><span class="sc2"><a href="http://december.com/html/4/element/div.html"><span class="kw2">&lt;div</span></a> <span class="kw3">id</span>=<span class="st0">&quot;calgary&quot;</span> <span class="kw3">style</span>=<span class="st0">&quot;display:none;&quot;</span><span class="kw2">&gt;</span></span>The Calgary Flames<span class="sc2"><span class="kw2">&lt;/div&gt;</span></span></div>
</div>
]]></content>
		<link rel="replies" type="text/html" href="http://www.metatitan.com/css/18/showhide-content-with-css-javascript.html#comments" thr:count="7" />
		<link rel="replies" type="application/atom+xml" href="http://www.metatitan.com/css/18/showhide-content-with-css-javascript.html/feed/atom" thr:count="7" />
		<thr:total>7</thr:total>
	<feedburner:origLink>http://www.metatitan.com/css/18/showhide-content-with-css-javascript.html</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Matt</name>
						<uri>http://www.metatitan.com</uri>
					</author>
		<title type="html"><![CDATA[Automating Photoshop; Actions and Batching Explained]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/metatitan/~3/OKvepJ_2Cv0/automating-photoshop-actions-and-batching-explained.html" />
		<id>http://www.metatitan.com/photoshop/17/automating-photoshop-actions-and-batching-explained.html</id>
		<updated>2007-10-23T05:23:23Z</updated>
		<published>2007-10-23T04:40:06Z</published>
		<category scheme="http://www.metatitan.com" term="Photoshop" />		<summary type="html"><![CDATA[If you work in Adobe Photoshop regularly, you&#8217;ll often find yourself engaged in repetitive loops that have a tendency to drain on your stamina and attention span. Today I&#8217;ll teach you how to use, and embrace the Action menu, a tool that will change the way you approach boring, monotonous tasks. Whether it&#8217;s mass resizing [...]]]></summary>
		<content type="html" xml:base="http://www.metatitan.com/photoshop/17/automating-photoshop-actions-and-batching-explained.html"><![CDATA[<p>If you work in Adobe Photoshop regularly, you&#8217;ll often find yourself engaged in repetitive loops that have a tendency to drain on your stamina and attention span. Today I&#8217;ll teach you how to use, and embrace the Action menu, a tool that will change the way you approach boring, monotonous tasks. Whether it&#8217;s mass resizing photos, embedding watermarks, adding filters, or perhaps something more or less complex, most of it can be automated.<br />
<span id="more-17"></span><br />
First let&#8217;s open up the Actions menu and learn what it&#8217;s all about. It can be found under <strong>Window>Actions</strong> if it&#8217;s nowhere in sight on your workspace. It&#8217;ll look something like this:</p>
<p><img src="http://www.metatitan.com/images/actions_legend.gif" alt="Adobe Photoshop Actions" /></p>
<p><strong>A: Actions menu.</strong> You can control a number options in this menu (a few are described below), and save an action file to your desktop or load a premade external one through it.<br />
<strong>B: Action Set.</strong> All actions must reside within these groups.<br />
<strong>C: Action &#038; Recorded Commands.</strong> The action name is followed by the commands you recorded on it. In this case &#8220;Vintage&#8221; is the name of my action, and &#8220;Surface blur&#8221;, &#8220;Desaturate&#8221;, etc. are my recorded commands.<br />
<strong>D: Dialog Box Toggle.</strong> If you have this checked on, it will bring up the dialog box for that command when you run the action. For example, if I have a group of commands and the only one that has dialog checked is &#8220;Make Text Layer&#8221;, then it will automate everything up until the text layer, and you&#8217;ll be able to enter your text. When you finish editing the text, the action set will automatically continue until the end.<br />
<strong>E: Toggle Item.</strong> Similar to hiding a layer, when this is unchecked the command will not run with the action.<br />
<strong>F: Playback Controls.</strong> The recording button is used to capture your commands into a new or existing action. The stop button will end the recording process. The play button will run an action or a command depending on what you have selected.<br />
<strong>G: Create a new action set.</strong><br />
<strong>H: Create a new action.</strong><br />
<strong>I: Delete the item you have selected.</strong> It can be a command, action, or action set.</p>
<p>Now that you have a good idea of what&#8217;s what on the palette, it&#8217;s time to make your own. Open up the file you want to record your action on and start by creating a new action set. When you have a set ready, click the &#8220;Create new action&#8221; button, you&#8217;ll be presented with the following dialog box.</p>
<p><img src="http://www.metatitan.com/images/newaction.gif" alt="Adobe Photoshop Create New Action" /></p>
<p>Name your action and make sure it&#8217;s going into the desired set. You can set a hotkey &#038; color for it if you want, which I&#8217;d recommend if it&#8217;s something you&#8217;ll be using often.</p>
<p>Click &#8220;Ok&#8221; and your new action will immediately begin recording. Have at it, every command you do from now until you press the &#8220;Stop&#8221; button will be recorded on your new action. Don&#8217;t worry about being totally perfect when recording, you can go back after it&#8217;s finished and delete certain things you screwed up and/or record more commands inside of the action.</p>
<p><strong>Inserting a Stop</strong><br />
Sometimes you might want the action to stop at a certain point, or just present a warning box to the user with a continue button. Simply click on where you want the stop to happen (the command right before it, however you can move commands around just like layers if you need to), then click on the action menu (labeled &#8220;A&#8221; on the diagram above), and click &#8220;Insert Stop&#8221;. You&#8217;ll be presented with a dialog box where you can enter a message and specify whether or not you&#8217;d like the action to be continuable. </p>
<p><strong>Opening a Photoshop Menu With Actions</strong><br />
Your action might need to launch an Adobe Photoshop menu (ie: the action will open Image>Canvas Size and won&#8217;t continue until the user enters the new size and presses Ok). To accomplish this, click on the action menu (labeled &#8220;A&#8221; above) and select &#8220;Insert Menu Item&#8221;. A dialog will launch, simply pick the menu you want to open from here (ie: go to Image>Canvas Size) and the dialog will show that it&#8217;s recorded your choice, click &#8220;Ok&#8221; and your menu action will appear on the list of commands.</p>
<p><strong>Recording a Path</strong><br />
Sometimes your actions might need to record paths from things like the pen tool or adobe illustrator vectors. To insert them during or after recording, click on the paths tab (Windows>Paths), select the one you want and open the actions menu (once again, labeled &#8220;A&#8221; in the above figure), click &#8220;Insert Path&#8221;.</p>
<h3>Batching Your Actions</h3>
<p>When you have a number of photos that need to go through your new action (some good examples: watermarking, resizing/compressing, changing file extension), you should use Adobe Photoshop&#8217;s built in batch tool. You&#8217;ll find this under <strong>File>Automate>Batch</strong>. You&#8217;ll see the following dialog when you open this up.</p>
<p><img src="http://www.metatitan.com/images/batch.gif" alt="Adobe Photoshop Batching" /></p>
<p>Pick the set and action you&#8217;d like to run and specify source of where your images are located. You&#8217;ve got the option of picking from a folder, import from an external device (like a scanner), or to run it on all the files you currently have open in Photoshop. </p>
<p>Once you&#8217;ve got your source appropriately specified, you can choose a destination for the finished files. Photoshop will let you either do nothing and leave the files open in Photoshop, Save &#038; Close the files in their original location, or save the files to a new location with the option of renaming each of them based on the naming template you select. </p>
<p>Finally, you can choose to either stop the batch when you run into errors or log them to a file on your hard drive. </p>
<p>When every thing&#8217;s set, click &#8220;Ok&#8221; and watch the magic.</p>
]]></content>
		<link rel="replies" type="text/html" href="http://www.metatitan.com/photoshop/17/automating-photoshop-actions-and-batching-explained.html#comments" thr:count="16" />
		<link rel="replies" type="application/atom+xml" href="http://www.metatitan.com/photoshop/17/automating-photoshop-actions-and-batching-explained.html/feed/atom" thr:count="16" />
		<thr:total>16</thr:total>
	<feedburner:origLink>http://www.metatitan.com/photoshop/17/automating-photoshop-actions-and-batching-explained.html</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Matt</name>
						<uri>http://www.metatitan.com</uri>
					</author>
		<title type="html"><![CDATA[Protecting Your PHP/MySQL Queries from SQL Injection]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/metatitan/~3/xHkGAB-yyIQ/protecting-your-phpmysql-queries-from-sql-injection.html" />
		<id>http://www.metatitan.com/php/16/protecting-your-phpmysql-queries-from-sql-injection.html</id>
		<updated>2009-04-12T05:14:27Z</updated>
		<published>2007-10-21T10:36:08Z</published>
		<category scheme="http://www.metatitan.com" term="MySQL" /><category scheme="http://www.metatitan.com" term="PHP" />		<summary type="html"><![CDATA[SQL injection is a serious concern for webmasters, as an experienced attacker can use this hacking technique to gain access to sensitive data and/or potentially cripple your database. If you haven&#8217;t secured your applications, I implore you to get yourself familiar with the following method and grind it into your coding routine. One unsafe query [...]]]></summary>
		<content type="html" xml:base="http://www.metatitan.com/php/16/protecting-your-phpmysql-queries-from-sql-injection.html"><![CDATA[<p>SQL injection is a serious concern for webmasters, as an experienced attacker can use this hacking technique to gain access to sensitive data and/or potentially cripple your database. If you haven&#8217;t secured your applications, I implore you to get yourself familiar with the following method and grind it into your coding routine. One unsafe query can result in a nightmare for you or your client.</p>
<p>I&#8217;ve read through a lot of guides, and they tend to over complicate this, so I&#8217;ll be as straight forward as possible. In PHP the easiest way is to pass your data through the <a href="http://www.php.net/mysql_real_escape_string">mysql_real_escape_string</a> function. By escaping special characters on fields where the user can manipulate the database, you will avoid being vulnerable. Take a look below at the example of what to do and what not to do.</p>
<div class="codesnip-container" >
<div class="codesnip" style="font-family: monospace;"><span class="co1">// This is a vulnerable query.</span><br />
<span class="re0">$query</span> = <span class="st0">&quot;SELECT * FROM products WHERE name=&#8217;$productname&#8217;&quot;</span>;<br />
<a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span><span class="re0">$query</span><span class="br0">&#41;</span>;</p>
<p><span class="co1">// This query is more secure</span><br />
<span class="re0">$query</span> = <a href="http://www.php.net/sprintf"><span class="kw3">sprintf</span></a><span class="br0">&#40;</span><span class="st0">&quot;SELECT * FROM products WHERE name=&#8217;%s&#8217;&quot;</span>,<br />
<a href="http://www.php.net/mysql_real_escape_string"><span class="kw3">mysql_real_escape_string</span></a><span class="br0">&#40;</span><span class="re0">$productname</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
<a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span><span class="re0">$query</span><span class="br0">&#41;</span>;</div>
</div>
<p>Since I primarily code in PHP, I can&#8217;t confidently provide techniques for other programming languages. The most important part of protecting yourself is stopping users from being able to pass unaltered database manipulative special characters, like single quotes.</p>
<p><a href="http://msdn.microsoft.com/msdnmag/issues/04/09/SQLInjection/">MSDN - SQL Injection Article</a><br />
<a href="http://en.wikipedia.org/wiki/SQL_injection">Wikipedia - SQL Inection</a><br />
<a href="http://www.securiteam.com/securityreviews/5DP0N1P76E.html">SecuriTeam - SQL Injection Walkthrough</a><br />
<a href="http://www.sitepoint.com/article/sql-injection-attacks-safe">SitePoint - SQL Injection Attacks, Are You safe?</a></p>
]]></content>
		<link rel="replies" type="text/html" href="http://www.metatitan.com/php/16/protecting-your-phpmysql-queries-from-sql-injection.html#comments" thr:count="40" />
		<link rel="replies" type="application/atom+xml" href="http://www.metatitan.com/php/16/protecting-your-phpmysql-queries-from-sql-injection.html/feed/atom" thr:count="40" />
		<thr:total>40</thr:total>
	<feedburner:origLink>http://www.metatitan.com/php/16/protecting-your-phpmysql-queries-from-sql-injection.html</feedburner:origLink></entry>
	</feed>
