<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>Team Tutorials</title>
	
	<link>http://teamtutorials.com</link>
	<description />
	<lastBuildDate>Thu, 05 Apr 2012 19:38:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/TeamTutorials" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="teamtutorials" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">TeamTutorials</feedburner:emailServiceId><feedburner:feedburnerHostname xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">http://feedburner.google.com</feedburner:feedburnerHostname><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2FTeamTutorials" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2FTeamTutorials" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Ffeeds.feedburner.com%2FTeamTutorials" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.bloglines.com/sub/http://feeds.feedburner.com/TeamTutorials" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2FTeamTutorials" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2FTeamTutorials" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2FTeamTutorials" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.plusmo.com/add?url=http%3A%2F%2Ffeeds.feedburner.com%2FTeamTutorials" src="http://plusmo.com/res/graphics/fbplusmo.gif">Subscribe with Plusmo</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.thefreedictionary.com/_/hp/AddRSS.aspx?http%3A%2F%2Ffeeds.feedburner.com%2FTeamTutorials" src="http://img.tfd.com/hp/addToTheFreeDictionary.gif">Subscribe with The Free Dictionary</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.bitty.com/manual/?contenttype=rssfeed&amp;contentvalue=http%3A%2F%2Ffeeds.feedburner.com%2FTeamTutorials" src="http://www.bitty.com/img/bittychicklet_91x17.gif">Subscribe with Bitty Browser</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.live.com/?add=http%3A%2F%2Ffeeds.feedburner.com%2FTeamTutorials" src="http://tkfiles.storage.msn.com/x1piYkpqHC_35nIp1gLE68-wvzLZO8iXl_JMledmJQXP-XTBOLfmQv4zhj4MhcWEJh_GtoBIiAl1Mjh-ndp9k47If7hTaFno0mxW9_i3p_5qQw">Subscribe with Live.com</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://mix.excite.eu/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2FTeamTutorials" src="http://image.excite.co.uk/mix/addtomix.gif">Subscribe with Excite MIX</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.webwag.com/wwgthis.php?url=http%3A%2F%2Ffeeds.feedburner.com%2FTeamTutorials" src="http://www.webwag.com/images/wwgthis.gif">Subscribe with Webwag</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.podcastready.com/oneclick_bookmark.php?url=http%3A%2F%2Ffeeds.feedburner.com%2FTeamTutorials" src="http://www.podcastready.com/images/podcastready_button.gif">Subscribe with Podcast Ready</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.wikio.com/subscribe?url=http%3A%2F%2Ffeeds.feedburner.com%2FTeamTutorials" src="http://www.wikio.com/shared/img/add2wikio.gif">Subscribe with Wikio</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.dailyrotation.com/index.php?feed=http%3A%2F%2Ffeeds.feedburner.com%2FTeamTutorials" src="http://www.dailyrotation.com/rss-dr2.gif">Subscribe with Daily Rotation</feedburner:feedFlare><item>
		<title>How to Make a .com Website</title>
		<link>http://teamtutorials.com/web-development-tutorials/how-to-make-a-com-website?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=how-to-make-a-com-website</link>
		<comments>http://teamtutorials.com/web-development-tutorials/how-to-make-a-com-website#comments</comments>
		<pubDate>Thu, 05 Apr 2012 19:08:14 +0000</pubDate>
		<dc:creator>John Ward</dc:creator>
				<category><![CDATA[Web Development Tutorials]]></category>
		<category><![CDATA[basics]]></category>
		<category><![CDATA[domain]]></category>
		<category><![CDATA[hosting]]></category>
		<category><![CDATA[site]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://teamtutorials.com/?p=2973</guid>
		<description><![CDATA[The internet is ingrained in most of our day to day lives at this point. It&#8217;s hard for me to imagine a day that I do not touch the internet in some way. While most people utilize the internet every day, they do not know how to start their own website. This guide is aimed [...]]]></description>
			<content:encoded><![CDATA[<p>The internet is ingrained in most of our day to day lives at this point. It&#8217;s hard for me to imagine a day that I do not touch the internet in some way. While most people utilize the internet every day, they do not know how to start their own website. This guide is aimed at teaching beginners the basics of how to make a .com website, or really, any website regardless of the extension. If you want to learn how to make a .com website, be prepared for some reading!</p>
<p>I am going to cover several somewhat complex ideas today. Don&#8217;t be intimidated if you are not familiar with the concepts, I will do my best to explain these ideas in words that someone new to the web can understand. As always, if you have any questions feel free to post in the comments or even contact us. We do our best to respond to every question, but sometimes we can get overwhelmed.</p>
<p>Today we will cover the basics of creating a website including:</p>
<ol>
<li><strong><a href="#section1">Domain Name Registration</a></strong></li>
<li><strong><a href="#section2">Website Hosting Options</a></strong></li>
<li><strong><a href="#section3">Web Development and Markup</a></strong></li>
<li><strong><a href="#section4">Content Management Systems</a></strong></li>
<li><strong><a href="#section5">How to Get Visitors</a></strong></li>
<li><strong><a href="#section6">Making Money Your Website</a></strong></li>
</ol>
<h3><a name="section1"></a>The Domain Name System and Domain Registration</h3>
<p>The Domain Name System, or DNS, is a system of assigning human readable names to website addresses. When you visit ebay.com, you are actually being directed to an ebay server via the DNS system. The ebay website itself is actually location on the internet at the IP adress of 66.211.160.88. Think of IP Adresses as the location of your website on the internet. An IP adress works somewhat similar to the way a postal adress works. It notifies the carrier where you are located. To run a website you do not need to know the complex workings of DNS or IP adresses, but it is important to know of them.</p>
<p>Now imagine trying to remember a group of numbers like 66.211.160.88 for every website you would ever want to visit. This is originally how we accessed a website until the DNS system was create. The DNS system contains a record that will associate the name of your website with the IP adress of your website. That way any human can remember the location of your website and type it in.</p>
<p>You may wonder why I this is important to you? Well, the only thing that is really important as a website owner is that you have a registered domain name for your site. You&#8217;ll need to pick a name for your website and a top level domain (TLD). There are several available top level domains available for use. Some are reserved for special purposes such as a country code (.us, .uk, .asia) while others are for more general use (.com). The most popular three extensions that most people are familiar with are .com, .net, and .org with .com being the most common by far. The .com domain is actually intended for commercial websites, and most recently the United States has claimed the it was only intended for US based companies (I&#8217;m not going to go to far into detail). Anyone can register a .com, .org (originally intended for non-profit organizations), and .net (originally intended for networks) domain name from a domain name registrar. You should look into what other domain names are available. This is especially true if you do not live within the US and/or want to target countries outside of the United States. For more information on the purpose of top-level domains names take a look at <a href="http://en.wikipedia.org/wiki/List_of_Internet_top-level_domains">this article</a>.</p>
<p>Now that you have a basic understanding of what Domain Names are you need to decide what you want your domain to be. If you intend to register a .com domain be prepared to spend sometime finding a name that will not be registered already. Since .com is the most popular domain name, many of the website are already taken. Some .com domain names can even sell for millions of dollars if they have a good one word domain name. You can use the tools available at the domain name registrar that you choose to find a good domain name.</p>
<p>A domain name registar is the company that will sell you whatever-site-you-want.com. You will be paying yearly to reserve the name for your website. Normally, this should cost some where between $10-20 per year, but can vary depending on the TLD. Some unscrupulous companies will send out mail saying that you need to renew your domain name for $100 a year. They prey on the secretaries or accounts payable clerks who will send out checks like this. This is just something to be aware of. Never pay anyone except for the registrar that you initially choose to register your domain name with.</p>
<p>Two domain name registrars that I have used are <a href="http://teamtutorials.com/go/namecheap">namecheap.com</a> and <a href="http://teamtutorials.com/go/go-daddy">godaddy.com</a>. <a href="http://teamtutorials.com/go/go-daddy">Godaddy</a> is probably the most popular registrar and is pretty good for beginners as they offer a lot of ad on features. However, most of these features are not needed to run a website. I prefer <a href="http://teamtutorials.com/go/namecheap">namecheap</a> because they do not try to up sell you on every product they offer, their support is awesome, and their interface is easy to use. All you need is a domain name and a web host to get up and running.</p>
<h3><a name="section1"></a>What is Web Hosting?</h3>
<p>Once you&#8217;ve decided on a domain name for your website, you will need a place to keep your files. While you could technically keep those on any computer connect to the internet, it&#8217;s generally better to have a server designed for this specific purpose. That is where a web host comes in. They have thousands of servers all connected to the web just to host files for various websites. Hosted web servers are designed to respond to web requests and handle the traffic that a website can receive.</p>
<p>There are a few options you will need to consider when deciding on a web host. I&#8217;ll touch on each topic later:</p>
<ul>
<li>What type of server will you need (shared, VPS, dedicated server)?</li>
<li>Will you need managed support?</li>
<li>What operating system you want to use on your server (Windows, Linux)</li>
<li>Will you need a control panel (cPanel, etc)?</li>
</ul>
<h4>Shared Hosting</h4>
<p>First of all you need to decide what type of hosting you need. Web hosts offer several different server configurations for different types of customers. If you are just planning to run a website as a hobby, or if you are just starting a website you may want to go with share hosting. A share host is one physical web server that hosts multiple websites. Your website would be on the same server as up to hundreds of other websites, however you will still be abled to have your own domain name and manage your website to an extent.</p>
<p>In general, shared hosting doesn&#8217;t allow much flexibility when it comes to configuration. This done so that no one person can crash the server for all of the other websites. Like I said, shared hosting is good for hobby sites and low traffic sites. If you have big goals you may want to avoid share web hosting. The downsides are that you don&#8217;t have much control over the server and these server can&#8217;t handle large amount of traffic. If you generate too much traffic your web host will ask you to upgrade to a better server. Take it from someone who has crashed his shared of share hosting servers: if you have big goals you may want to pass on shared hosting and go for a virtual private server. The main benefit to share hosting is that is can be cheap. You can get shared hosting for about $4-12 per month.</p>
<h4>Virtual Private Servers</h4>
<p>Also known as a VPS, the virtual private server bridges the gap between share hosting and a full blown dedicated server. These physical servers with many virtual instances of server on them. These virtual instances cannot interfere with each other as they are contained with in their own virtual machine. The benefit to this is that you can have a the control over the server as if it was your own physical machine, but at a much cheaper costs.</p>
<h4>Dedicated Servers</h4>
<p>The most powerful servers you can buy are dedicated servers. These are physical machines in a datacenter that only run your website. You can usually run several of your own websites on your dedicated server. Dedicated servers can handle many more tasks as you will be able to utilize all of the hard disk space, memory(RAM), and processor cycles. These servers can be configured from a wide range of specification. A host can even setup multiple server in what is know as a cluster. If you get to the point that you need more than a single dedicated server then it is probably time to hire a server administrator to handle this for you. For most needs, a dedicated server is sufficient.</p>
<h4>Reseller Hosting</h4>
<p>This options provides you with all the benefits of a dedicated server, but also allows you to resell hosting to other websites. Unless you want to get in to the hosting reseller business this option is probably not necessary, but you could choose this if you plan to host a lot of your own domains.</p>
<h4>Hosting on the Cloud</h4>
<p>Another new option that is appearing is cloud hosting. This basically means that your data is host in a cluster of machines that the host will provide. For example amazon has a cloud hosting service known as s3. They host many sites all on there server farm which resides in &#8220;the cloud&#8221;. One thing that cloud based hosting can provide is an easy way to scale your server needs as your site grows. For your first website you probably want to stick with a shared or VPS solution, but keep in mind that the cloud option exists.</p>
<h4>Managed Hosting</h4>
<p>Managed servers are when a hosting company provides support for your server. This basically means you are leasing a server administrator in your hosting plan. Usually managed servers cost a little bit more than non-manage servers, but can be well worth it if you are not familiar with web servers. Even if you are a somewhat confortable with server configuration, a managed solution is a good idea. If you break something or can&#8217;t figure out why something is broken, then you can always lean on the support of the hosting company. I fully recommend using a host that provides managed hosting.</p>
<h4>Operating Systems</h4>
<p>Web servers come in different flavors. You could have a Windows Server that will run Internet Information Service to serve web pages or you could have any flavor of the Linux Operating system and apache or nginx (pronounced engine-x)as your server. While most of you are probably familiar with Windows, Linux with apache is the most popular web server on the internet. It may actually be difficult to find Windows based servers, but they are out there should you really want one. I recommend going with a Linux solution such as CentOS. CentOS is a free enterprise level operating system. Plus if you have managed support you don&#8217;t have to worry about knowing how to use Linux.</p>
<h4>Control Panels</h4>
<p>Another option for administration is a control panel. A control panel is a way to manage your server from the web. It provides an easy to use, graphical interface for configuration of your server. The most popular control panel is called cPanel. Finding a host that offers a control panel, such as cPanel, is highly recommended. Having a control panel will allow you to perform many administration duties without having server knowledge or having to rely on the support from the hosting company.</p>
<h4>Where to get hosting?</h4>
<p>Here are a few sites that you can look into for hosting. Our website is hosted by <a href="http://teamtutorials.com/go/surpass-hosting">surpass hosting</a>.</p>
<ul>
<li><a href="http://teamtutorials.com/go/host-gator">hostgator.com</a></li>
<li><a href="http://teamtutorials.com/go/go-daddy">godaddy.com</a></li>
<li><a href="http://teamtutorials.com/go/dreamhost">dreamhost</a></li>
<li><a href="http://teamtutorials.com/go/1and1">1&amp;1</a></li>
<li><a href="http://teamtutorials.com/go/bluehost">BlueHost</a></li>
</ul>
<p>Once you have a hosting server setup you will need to set your domain name to point to this new server. You&#8217;re domain name registrar will be able to help with this step.</p>
<h3><a name="section3"></a>Basic Web Development and Mark Up</h3>
<p>Once you have a domain name and web server you will need to build some actual webpages. For this task you will need to use HTML. HTML is a markup language that tells the browser how to display your website. You can create static web pages (meaning they do not change or pull in content from any other source) using HTML. For making website look presentable modern developers use CSS. CSS is short for cascading style sheets. Style sheets are additional rules that help the browser display your website in the way you want it to be seen. In addition to HTML and CSS there are also languages such as JavaScript, PHP, Ruby, and Perl involved in website development. We&#8217;re not going to go into each of those but luckily you can find some tutorials on those languages on teamtutorials.com. Don&#8217;t let a lack of web programming experience scare you away from creating your one website.</p>
<h3><a name="section4"></a>Content Management Systems</h3>
<p>Content management systems (CMS) are web applications built to allows normal users to administer a website and add content. Most content management systems will give you a nice, web-based, interface for updating your website. It does take a little bit of work to install a CMS, but there are well documented guides on how to do this. If you have a host with <a href="http://www.cpanel.net/">cPanel</a>, then it is likely that a program called Fantastico will be include. Fantastico can install several popular content management systems with the click of a button.</p>
<p>There are tons of content management systems available depending on the type of site you want to create. One of the most popular is called <a href="http://wordpress.org">WordPress</a>. WordPress was created for blogs, or online diary type sites. Blogs have matured to a popular form of media and WordPress has also matured. One reason I like WordPress is because you can always find the answer to your question with a quick online search. Other types of content management systems exist for forums (<a href="http://buddypress.org/">buddypress</a>, <a href="http://www.invisionpower.com/products/board/">ip.board</a>, <a href="https://www.vbulletin.com/">vbulletin</a>), help ticket systems, project management, and almost any other type of site you can imagine. This is also a topic that will take another post to explore but we have several WordPress tutorials available.</p>
<h3><a name="section4"></a>Getting Traffic</h3>
<p>Once you have a website, the next step is getting visitors. I can&#8217;t go to far into each topic, but I want to make you aware of some of the ways you can promote your website.</p>
<p>When I want to find something on the web I generally use a search engine such as google.com. You will want to make sure you website is available to search engined. There are several sites you can pay to &#8220;submit&#8221; your site to search engines. Never to this. Modern search engines will fine your site provided that it can be crawl. The process of getting your website to rank high in the search results is known as Search Engine Optimization or SEO.</p>
<p>Social networks are also a major traffic source on today&#8217;s internet. Sharing your content on sites like Facebook, Twitter, and LinkedIn is a good way to build traffic. If you have a good product or content your users may even share pages for you.</p>
<p>The other main source is advertising. We&#8217;re exposed to all types of advertising every day and the internet is no different. There are several types of advertising you can utilize. A few different types to research are Pay Per Click, Pay Per View, Display/Banner advertising, CPM or Cost Per Impression, affiliate programs.</p>
<h3><a name="section5"></a>Making Money From Your Website</h3>
<p>If you are making a website then chances are you intend to make money from this site. If you have no intention to make money that is ok, but you may want to still look into monetization to pay for your hosting and domain bills. There are many ways to make money off of a website. Some of these include advertising, charging for premium content or membership, affiliate marketing, and lead generation. If you are interested in any of these topics you can find tons of information online. Some of the information is good, most is not. We at <a href="http://teamtutorials.com">teamtutorials.com</a> will be putting together some good courses on traffic generation and how to make money off of your newly formed website.</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://teamtutorials.com/web-development-tutorials/sending-e-mail-to-validate-user-sign-up" title="Sending E-Mail to validate User Sign-up">Sending E-Mail to validate User Sign-up</a></li><li><a href="http://teamtutorials.com/web-development-tutorials/jquery-pop-over-effects" title="jQuery Pop Over Effects">jQuery Pop Over Effects</a></li><li><a href="http://teamtutorials.com/web-development-tutorials/password-verification-and-strength-checker" title="Password Verification and Strength Checker">Password Verification and Strength Checker</a></li><li><a href="http://teamtutorials.com/web-development-tutorials/dynamically-add-textbox-to-site" title="Dynamically Add Textbox to Site">Dynamically Add Textbox to Site</a></li><li><a href="http://teamtutorials.com/photoshop-tutorials/recreate-the-diggcom-header" title="Recreate the Digg.com Header">Recreate the Digg.com Header</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://teamtutorials.com/web-development-tutorials/how-to-make-a-com-website/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Simple Array Comparison with Ruby</title>
		<link>http://teamtutorials.com/web-development-tutorials/simple-array-comparison-with-ruby?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=simple-array-comparison-with-ruby</link>
		<comments>http://teamtutorials.com/web-development-tutorials/simple-array-comparison-with-ruby#comments</comments>
		<pubDate>Fri, 23 Mar 2012 13:18:01 +0000</pubDate>
		<dc:creator>John Ward</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Web Development Tutorials]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[set]]></category>

		<guid isPermaLink="false">http://teamtutorials.com/?p=2925</guid>
		<description><![CDATA[I ran into a task where I needed to find the differences with some data. Since I&#8217;ve not spent much time with ruby I decided to give it a shot. It was surprisingly simple to do what I needed to do in ruby. I&#8217;m not going to post the entire details right now, but wanted [...]]]></description>
			<content:encoded><![CDATA[<p>I ran into a task where I needed to find the differences with some data. Since I&#8217;ve not spent much time with ruby I decided to give it a shot. It was surprisingly simple to do what I needed to do in ruby. I&#8217;m not going to post the entire details right now, but wanted to leave a quick note here on comparing arrays.</p>
<p>I stored the data I needed to evaluate into an array. I wanted to find the items that appeared in array A but not in array B. Basically all we need to do is included the ruby set library and then it is very very simple to do this.</p>
<pre class="brush: php; title: Code Snippet:; notranslate">
require 'set'

#create array
a = [1,2,3,4]
b = [2,3,5,6]

#convert to set
a.to_set
b.to_set

#remove items in b from a
diff = (a - b)

#output what ever is left
puts diff
</pre>
<p>Since I already had my data in an array, I just converted it to a set object. Technically if you are creating a set you could use either of these methods:</p>
<pre class="brush: php; title: Code Snippet:; notranslate">
a = Set.new[1,2,3]
#or
a = [1,2,3].to_set
</pre>
<p>Mainly I wanted to add this little snippet so I can refer back to this at some point, but I figured it may help someone else who is new to ruby. For more information on set check out the  <a href="http://www.ruby-doc.org/stdlib-1.9.3/libdoc/set/rdoc/Set.html" target="_blank">set documentation</a>.</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://teamtutorials.com/windows-tutorials/how-to-make-a-custom-windows-install-w-nlite" title="How to make a Custom Windows Install w/ nLite">How to make a Custom Windows Install w/ nLite</a></li><li><a href="http://teamtutorials.com/site-news/teamtutorialscom-selected-as-harpzon-blog-of-the-week" title="News &#8211; TeamTutorials.com Selected as HarpzOn Blog of The Week">News &#8211; TeamTutorials.com Selected as HarpzOn Blog of The Week</a></li><li><a href="http://teamtutorials.com/windows-tutorials/speed-up-your-pc-by-increasing-page-file-size" title="Speed Up Your PC by Increasing Page File Size">Speed Up Your PC by Increasing Page File Size</a></li><li><a href="http://teamtutorials.com/windows-tutorials/create-a-windows-daily-backup-script" title="Create a Windows Daily Backup Script">Create a Windows Daily Backup Script</a></li><li><a href="http://teamtutorials.com/windows-tutorials/show-file-extension-in-windows-xp" title="Show File Extension in Windows XP">Show File Extension in Windows XP</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://teamtutorials.com/web-development-tutorials/simple-array-comparison-with-ruby/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Why Zen-Coding is an Awesome Time Saver</title>
		<link>http://teamtutorials.com/web-development-tutorials/why-zen-coding-is-an-awesome-time-saver?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=why-zen-coding-is-an-awesome-time-saver</link>
		<comments>http://teamtutorials.com/web-development-tutorials/why-zen-coding-is-an-awesome-time-saver#comments</comments>
		<pubDate>Thu, 01 Mar 2012 01:52:18 +0000</pubDate>
		<dc:creator>John Ward</dc:creator>
				<category><![CDATA[Productivity]]></category>
		<category><![CDATA[Web Development Tutorials]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[editors]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[shortcuts]]></category>

		<guid isPermaLink="false">http://teamtutorials.com/?p=2899</guid>
		<description><![CDATA[If you are a web developer doing any kind of CSS and HTML work then you need to be using the zen-coding plugins. So what exactly is zen-coding? It's not a new language, but more of shortcut system for generating structured code, such as HTML or XML, using a CSS selector like syntax. If you don't get it yet, you'll see the beauty within seconds of playing with the language.]]></description>
			<content:encoded><![CDATA[<p>If you are a web developer doing any kind of CSS and HTML work then you need to be using the zen-coding plugins. So what exactly is zen-coding? It&#8217;s not a new language, but more of shortcut system for generating structured code, such as HTML or XML, using a CSS selector like syntax. If you don&#8217;t get it yet, you&#8217;ll see the beauty within seconds of playing with the language.</p>
<p>There are currently plugins available for a wide range of popular text editors on what ever platform you use for development. I&#8217;ve become a MacBook fan lately. I installed the plugin for the popular Coda editor and was off and running in minutes. To see if there is a plugin available for your favorite editor check out the <a href="http://code.google.com/p/zen-coding/" target="_blank">official zen-coding page</a>. Download a version that will work with your favorite editor. </p>
<p>After I installed the Coda plugin I just had to setup the shortcut key I wanted to use for code completion. In my case this is control + e. Then you just have to get familiar with the syntax for generating structured code. If you are familiar with CSS at all then picking up the syntax should be very simple. If you are not familiar with the syntax, put the time in to learn. Trust me, once you know the syntax you will save tons of time coding.</p>
<p>I&#8217;ll give you a few short example to get you started.</p>
<p>Let&#8217;s say you wanted to general a basic html starter template. All you would have to type is:</p>
<pre class="brush: xml; title: Code Snippet:; notranslate">html&gt;head+body</pre>
<p>What this says is that you want to generate an HTML tag. The &#8216;>&#8217; character signals that you want the follow tag to be a child, or a nested element, of the head tag. The &#8216;+&#8217; signals that you want the body tag to be a sibling of of the head tag. Now in my editor all I do is type that line and press control + e and the editor will generate:</p>
<pre class="brush: xml; title: Code Snippet:; notranslate">
&lt;html&gt;
	&lt;head&gt;&lt;/head&gt;
	&lt;body&gt;&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>A better example might be if you wanted to create a div with the id of &#8216;container&#8217; and within that div you want to create an unordered list. Of course we&#8217;ll have to add list items to the unordered list and since this will be a menu, we&#8217;ll want to add links. Sure you could do this manually, or you could do it like this:</p>
<pre class="brush: xml; title: Code Snippet:; notranslate">div#container&gt;ul.menu&gt;li*5&gt;a[href=&quot;#&quot;]</pre>
<p>which will generate:</p>
<pre class="brush: xml; title: Code Snippet:; notranslate">
&lt;div id=&quot;container&quot;&gt;
	&lt;ul class=&quot;menu&quot;&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
&lt;/div&gt;
</pre>
<p>What if you wanted to add a unique class to each link? You could do something like this:</p>
<pre class="brush: xml; title: Code Snippet:; notranslate">div#container&gt;ul.menu&gt;li*5&gt;a[href=&quot;#&quot;].item-$</pre>
<p>You&#8217;ll get:</p>
<pre class="brush: xml; title: Code Snippet:; notranslate">
&lt;div id=&quot;container&quot;&gt;
	&lt;ul class=&quot;menu&quot;&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot; class=&quot;item-1&quot;&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot; class=&quot;item-2&quot;&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot; class=&quot;item-3&quot;&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot; class=&quot;item-4&quot;&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot; class=&quot;item-5&quot;&gt;&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
&lt;/div&gt;
</pre>
<p>There is much more you can do. You can group items using parenthesis and even add text to elements if you would like.</p>
<pre class="brush: xml; title: Code Snippet:; notranslate">
div#container&gt;(ul.menu&gt;li*5&gt;a[href=&quot;#&quot;].item-$)+p.stuff{hello world}
</pre>
<p>How about this:</p>
<pre class="brush: xml; title: Code Snippet:; notranslate">
&lt;div id=&quot;container&quot;&gt;
	&lt;ul class=&quot;menu&quot;&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot; class=&quot;item-1&quot;&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot; class=&quot;item-2&quot;&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot; class=&quot;item-3&quot;&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot; class=&quot;item-4&quot;&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot; class=&quot;item-5&quot;&gt;&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
	&lt;p class=&quot;stuff&quot;&gt;hello world&lt;/p&gt;
&lt;/div&gt;
</pre>
<p>I&#8217;ve only demonstrated some of the potential of the zen-coding project. With support for tags, ID and class attributes, custom attributes, multiplication of elements, grouping and nesting there is not much you can&#8217;t do. You can fully code an entire document in a single line of syntax if you wish. To find out more make sure you checkout the official <a href="http://code.google.com/p/zen-coding/" target="_blank">zen-coding page</a>, I will definitely be using it.</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://teamtutorials.com/site-news/teamtutorialscom-selected-as-harpzon-blog-of-the-week" title="News &#8211; TeamTutorials.com Selected as HarpzOn Blog of The Week">News &#8211; TeamTutorials.com Selected as HarpzOn Blog of The Week</a></li><li><a href="http://teamtutorials.com/database-tutorials/configuring-authentication-on-ms-sql-2008" title="Configuring Authentication on MS SQL 2008">Configuring Authentication on MS SQL 2008</a></li><li><a href="http://teamtutorials.com/site-news/back-to-cpanel-10" title="Back to cPanel 10">Back to cPanel 10</a></li><li><a href="http://teamtutorials.com/windows-tutorials/creating-the-quick-launch-toolbar-show-desktop-icon" title="Creating the Quick Launch Toolbar &#8220;Show Desktop Icon&#8221;">Creating the Quick Launch Toolbar &#8220;Show Desktop Icon&#8221;</a></li><li><a href="http://teamtutorials.com/photoshop-tutorials/photoshop-corporate-construction-company-layout" title="Photoshop Corporate Construction Company Layout">Photoshop Corporate Construction Company Layout</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://teamtutorials.com/web-development-tutorials/why-zen-coding-is-an-awesome-time-saver/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>What’s new in HTML 5</title>
		<link>http://teamtutorials.com/web-development-tutorials/whats-new-in-html-5?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=whats-new-in-html-5</link>
		<comments>http://teamtutorials.com/web-development-tutorials/whats-new-in-html-5#comments</comments>
		<pubDate>Tue, 27 Dec 2011 18:58:24 +0000</pubDate>
		<dc:creator>John Ward</dc:creator>
				<category><![CDATA[HTML Tutorials]]></category>
		<category><![CDATA[Web Development Tutorials]]></category>

		<guid isPermaLink="false">http://teamtutorials.com/?p=2884</guid>
		<description><![CDATA[It&#8217;s been way too long since we&#8217;ve posted anything. With all the news around HTML5 and CSS3 that continues to come out, I thought now might be a good time to talk about some things we will see in the upcoming HTML5 standard. HTML5 Doctype The doctype has been simplified in HTML5. Now all you [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been way too long since we&#8217;ve posted anything. With all the news around HTML5 and CSS3 that continues to come out, I thought now might be a good time to talk about some things we will see in the upcoming HTML5 standard.</p>
<h3>HTML5 Doctype</h3>
<p>The doctype has been simplified in HTML5. Now all you have to do is add the following doctype and your page is HTML5 ready.</p>
<pre class="brush: xml; title: Code Snippet:; notranslate">
&lt;!doctype html&gt;
</pre>
<h3>HTML Structure Tags</h3>
<p>The HTML5 standard recognized that most web pages have several type of elements in common. It added more semantic tags to handle these elements. In the previous standard we would use the div tag, but now there are several more descriptive tags available:</p>
<ul>
<li><strong>header</strong> &#8211; this tag is commonly used to identify the header of the page. However, from what I see in the specification, there is no reason this tag could not be used to denote the header of other content, such as a blog post.</li>
<li><strong>footer</strong> &#8211; the footer tag can be used to define the footer of the html page or the footer of another element.</li>
<li><strong>nav</strong> &#8211; the nav tag is short for navigation. The intention of this tag is to be used for major intersite navigation. Therefore I think it is best used for your site naviagtion (home,contact,about us, etc) but not for use to link to outside side such as you would see in a blogroll.
</li>
<li><strong>section</strong> &#8211; used to divide your page into sections. You may see this tag used in a blog to contain several blog posts. </li>
<li><strong>article</strong> &#8211; defines a particular article in a page. I see this tag being used to contain individual blog posts within the seciton tag.</li>
<li><strong>aside</strong> &#8211; right now aside is to be used to define other content on your pages that are not apart of the main content. The only real use I&#8217;ve seen is for side bars</li>
<li><strong>figure</strong> &#8211; defines an element that is related to your article. Something like an image or diagram. This also allows for use of the figcaption element to add a caption to the parent figure.</li>
<li><strong>mark</strong> &#8211; used to define an inline content that marked in some way. Could possible replace strong in some cases.</li>
<li><strong>time</strong> &#8211; used to indicate a time value</li>
<li><strong>meter</strong> &#8211; used to indicate a portion of a range. Such as a percentage of free space.</li>
<li><strong>progress</strong> &#8211; can be used to indicate the completion of a task</li>
</ul>
<h3>Dynamic Pages in HTML5?</h3>
<p>HTML5 has added some elements that take care of commonly used dynamic functions that would commonly be created using javascript.</p>
<ul>
<li><strong>details</strong> &#8211; provides details about an element. This would be like tooltips in non-Web applications.</li>
<li><strong>datagrid</strong> &#8211; creates a table that is built from a database or other dynamic source</li>
<li><strong>menu</strong> &#8211; an old tag brought back and given new life allowing you to create a menu system on your Web pages</li>
<li><strong>command</strong> &#8211; defines actions that should happen when a dynamic element is activated</li>
</ul>
<h3>New Multimedia Tags</h3>
<ul>
<li><strong>canvas</strong> &#8211; allows you to create dynamic graphics within your page.</li>
<li><strong>video</strong> &#8211; tag used to add video</li>
<li><strong>audio</strong> &#8211; add sound or music using the audio tag</li>
</ul>
<p>We&#8217;ve just barely scratched the surface of the upcoming standard. In the future we&#8217;ll take a deeper look into HTML5 and CSS3. Also I hope to post some examples of how to use these new tags.</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://teamtutorials.com/windows-tutorials/eliminating-viruses-with-avg-free-edition" title="Eliminating Viruses with AVG Free Edition">Eliminating Viruses with AVG Free Edition</a></li><li><a href="http://teamtutorials.com/web-development-tutorials/wordpress-tutorials/installing-and-configuring-the-popularity-contest-for-wordpress" title="Installing and Configuring the Popularity Contest for WordPress">Installing and Configuring the Popularity Contest for WordPress</a></li><li><a href="http://teamtutorials.com/windows-tutorials/how-to-add-users-in-windows-xp" title="How to Add Users in Windows XP">How to Add Users in Windows XP</a></li><li><a href="http://teamtutorials.com/windows-tutorials/sharing-a-printer-on-a-windows-network" title="Sharing a Printer on a Windows Network">Sharing a Printer on a Windows Network</a></li><li><a href="http://teamtutorials.com/web-development-tutorials/using-jquery-to-reorder-a-list-and-update-a-database" title="Using jQuery to Reorder a List and Update a Database">Using jQuery to Reorder a List and Update a Database</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://teamtutorials.com/web-development-tutorials/whats-new-in-html-5/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>8 Must Have iPhone Cheat Sheets for Web Developers</title>
		<link>http://teamtutorials.com/reviews/8-must-have-iphone-cheat-sheets-for-web-developers?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=8-must-have-iphone-cheat-sheets-for-web-developers</link>
		<comments>http://teamtutorials.com/reviews/8-must-have-iphone-cheat-sheets-for-web-developers#comments</comments>
		<pubDate>Mon, 08 Aug 2011 17:56:11 +0000</pubDate>
		<dc:creator>John Ward</dc:creator>
				<category><![CDATA[Reviews]]></category>
		<category><![CDATA[cheat sheet]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[ipad]]></category>
		<category><![CDATA[iphone]]></category>

		<guid isPermaLink="false">http://teamtutorials.com/?p=2840</guid>
		<description><![CDATA[When it comes to development, there are always simple things that we as developers forget. Ever get into a situation where you know how to do something in one language, but can&#8217;t quite figure out the correct syntax in another? I&#8217;ve put together a list of iOS &#8220;cheat sheet&#8221; apps that is sure to help [...]]]></description>
			<content:encoded><![CDATA[<p>When it comes to development, there are always simple things that we as developers forget. Ever get into a situation where you know how to do something in one language, but can&#8217;t quite figure out the correct syntax in another? I&#8217;ve put together a list of iOS &#8220;cheat sheet&#8221; apps that is sure to help with web development. If you are a developer than you <strong>must</strong> download these apps. You never know when you are going to need them!</p>
<div style="min-height:200px;">
<h2><a href="http://click.linksynergy.com/fs-bin/stat?id=8ctO0hHqN8E&#038;offerid=146261&#038;type=3&#038;subid=0&#038;tmpid=1826&#038;RD_PARM1=http%253A%252F%252Fitunes.apple.com%252Fus%252Fapp%252Fhtml-5-pro-quick-guide%252Fid400768551%253Fmt%253D8%2526uo%253D4%2526partnerId%253D30" target="itunes_store">HTML 5 Pro Quick Guide</a></h2>
<p>
<a href="http://click.linksynergy.com/fs-bin/stat?id=8ctO0hHqN8E&amp;offerid=146261&amp;type=3&amp;subid=0&amp;tmpid=1826&amp;RD_PARM1=http%253A%252F%252Fitunes.apple.com%252Fus%252Fapp%252Fhtml-5-pro-quick-guide%252Fid400768551%253Fmt%253D8%2526uo%253D4%2526partnerId%253D30"><img src="http://teamtutorials.com/wp-content/uploads/2011/08/html_5_pro-150x150.jpg" alt="" title="html_5_pro" width="150" height="150" class="alignleft size-thumbnail wp-image-2850" /></a>It&#8217;s the new thing and you better keep up with the standards or you&#8217;ll be left in the dust. More than just a cheat sheet or reference, the HTML5 Pro Quick Guide provides beginners with a simple introduction to the basics, and experts will find the advanced details they need. Loads of extras are included: HTML5 elements, HTML5 attributes, HTML5 events, syntax, document structure, DOCTYPE declarations, colors, font styles, HTML5 version information, and browser compatibility tables for the most popular browsers.
</p>
</div>
<div style="min-height:200px;">
<h2><a href="http://click.linksynergy.com/fs-bin/stat?id=8ctO0hHqN8E&#038;offerid=146261&#038;type=3&#038;subid=0&#038;tmpid=1826&#038;RD_PARM1=http%253A%252F%252Fitunes.apple.com%252Fus%252Fapp%252Fjavascript-cheat-sheet%252Fid302719350%253Fmt%253D8%2526uo%253D4%2526partnerId%253D30" target="itunes_store">JavaScript Cheat Sheet</a></h2>
<p>
<a href="http://click.linksynergy.com/fs-bin/stat?id=8ctO0hHqN8E&amp;offerid=146261&amp;type=3&amp;subid=0&amp;tmpid=1826&amp;RD_PARM1=http%253A%252F%252Fitunes.apple.com%252Fus%252Fapp%252Fjavascript-cheat-sheet%252Fid302719350%253Fmt%253D8%2526uo%253D4%2526partnerId%253D30"><img src="http://teamtutorials.com/wp-content/uploads/2011/08/javascript_cheat_sheet-150x150.jpg" alt="" title="javascript_cheat_sheet" width="150" height="150" class="alignleft size-thumbnail wp-image-2852" /></a><br />
Even seasoned web developers need a quick refresher course in JavaScript methods, properties and syntax from time to time. The JavaScript Cheat Sheet for iPhone and iPod Touch is designed to address that need. Use it as a quick reference for topics you’ve already learned but need a few reminders on, or if you’re still a beginner to JavaScript, use it to better understand what JavaScript is capable of.
</p>
</div>
<div style="min-height:200px;">
<h2><a href="http://click.linksynergy.com/fs-bin/stat?id=8ctO0hHqN8E&#038;offerid=146261&#038;type=3&#038;subid=0&#038;tmpid=1826&#038;RD_PARM1=http%253A%252F%252Fitunes.apple.com%252Fus%252Fapp%252Fhtml-cheat-sheet%252Fid303696538%253Fmt%253D8%2526uo%253D4%2526partnerId%253D30" target="itunes_store">HTML Cheat Sheet</a></h2>
<p><a href="http://click.linksynergy.com/fs-bin/stat?id=8ctO0hHqN8E&amp;offerid=146261&amp;type=3&amp;subid=0&amp;tmpid=1826&amp;RD_PARM1=http%253A%252F%252Fitunes.apple.com%252Fus%252Fapp%252Fhtml-cheat-sheet%252Fid303696538%253Fmt%253D8%2526uo%253D4%2526partnerId%253D30"><img src="http://teamtutorials.com/wp-content/uploads/2011/08/html_cheat_sheet-150x150.jpg" alt="" title="html_cheat_sheet" width="150" height="150" class="alignleft size-thumbnail wp-image-2854" /></a>This is a native app, not just a link out to internet references. It&#8217;s searchable and has an easy to use interface that helps you quickly find what you&#8217;re looking for. The categories are useful and well defined. The cheatsheet includes examples and quick reference lists for Tags, Attributes, Events, Colors, Character Sets, ASCII, ISO 8859-1 Symbols, ISO 8859-1 Characters, Math Symbols, Greek Letters, URL Encoding, Language Codes, HTTP Status Messages, and more.
</p>
</div>
<div style="min-height:200px;">
<h2><a href="http://click.linksynergy.com/fs-bin/stat?id=8ctO0hHqN8E&#038;offerid=146261&#038;type=3&#038;subid=0&#038;tmpid=1826&#038;RD_PARM1=http%253A%252F%252Fitunes.apple.com%252Fus%252Fapp%252Fgoogle-cheat-sheet%252Fid302761238%253Fmt%253D8%2526uo%253D4%2526partnerId%253D30" target="itunes_store">Google Cheat Sheet</a></h2>
<p><a href="http://click.linksynergy.com/fs-bin/stat?id=8ctO0hHqN8E&amp;offerid=146261&amp;type=3&amp;subid=0&amp;tmpid=1826&amp;RD_PARM1=http%253A%252F%252Fitunes.apple.com%252Fus%252Fapp%252Fgoogle-cheat-sheet%252Fid302761238%253Fmt%253D8%2526uo%253D4%2526partnerId%253D30"><img src="http://teamtutorials.com/wp-content/uploads/2011/08/google_cheat_sheet-150x150.jpg" alt="" title="google_cheat_sheet" width="150" height="150" class="alignleft size-thumbnail wp-image-2857" /></a>The Google Cheat Sheet for iPhone and iPod Touch is a quick reference to many of Google’s most popular tools and search techniques. It also covers the powerful, but lesser known tools Google provides to successfully search the web.</p>
</div>
<div style="min-height:200px;">
<h2><a href="http://click.linksynergy.com/fs-bin/stat?id=8ctO0hHqN8E&#038;offerid=146261&#038;type=3&#038;subid=0&#038;tmpid=1826&#038;RD_PARM1=http%253A%252F%252Fitunes.apple.com%252Fus%252Fapp%252Fcss-cheat-sheet%252Fid301093674%253Fmt%253D8%2526uo%253D4%2526partnerId%253D30" target="itunes_store">CSS Cheat Sheet</a></h2>
<p><a href="http://click.linksynergy.com/fs-bin/stat?id=8ctO0hHqN8E&amp;offerid=146261&amp;type=3&amp;subid=0&amp;tmpid=1826&amp;RD_PARM1=http%253A%252F%252Fitunes.apple.com%252Fus%252Fapp%252Fcss-cheat-sheet%252Fid301093674%253Fmt%253D8%2526uo%253D4%2526partnerId%253D30"><img src="http://teamtutorials.com/wp-content/uploads/2011/08/css_cheat_sheet-150x150.jpg" alt="" title="css_cheat_sheet" width="150" height="150" class="alignleft size-thumbnail wp-image-2855" /></a>Unlike apps that cobble together random references from the web, this cheatsheet is written and reviewed by professional web developers that use CSS on a daily basis. We keep up with changing specifications and provide free updates in the same simple, easy to use format.
</p>
</div>
<div style="min-height:200px;">
<h2><a href="http://click.linksynergy.com/fs-bin/stat?id=8ctO0hHqN8E&#038;offerid=146261&#038;type=3&#038;subid=0&#038;tmpid=1826&#038;RD_PARM1=http%253A%252F%252Fitunes.apple.com%252Fus%252Fapp%252Fphp-cheat-sheet%252Fid302760278%253Fmt%253D8%2526uo%253D4%2526partnerId%253D30" target="itunes_store">php Cheat Sheet</a></h2>
<p><a href="http://click.linksynergy.com/fs-bin/stat?id=8ctO0hHqN8E&amp;offerid=146261&amp;type=3&amp;subid=0&amp;tmpid=1826&amp;RD_PARM1=http%253A%252F%252Fitunes.apple.com%252Fus%252Fapp%252Fphp-cheat-sheet%252Fid302760278%253Fmt%253D8%2526uo%253D4%2526partnerId%253D30"><img src="http://teamtutorials.com/wp-content/uploads/2011/08/php_cheat_sheet-150x150.jpg" alt="" title="php_cheat_sheet" width="150" height="150" class="alignleft size-thumbnail wp-image-2862" /></a>This is a native app, not just a link out to internet references. It&#8217;s searchable and has an easy to use interface that helps you quickly find what you&#8217;re looking for. The categories are useful and well defined. The cheatsheet includes functions and descriptions for Date &#038; Time, File Handling, Errors, File System, Filter, FTP, HTTP, Libxml, Mail, Math, MySQL, SimpleXML, String, XML Zip, and many more.</p>
</div>
<div style="min-height:200px;">
<h2><a href="http://click.linksynergy.com/fs-bin/stat?id=8ctO0hHqN8E&#038;offerid=146261&#038;type=3&#038;subid=0&#038;tmpid=1826&#038;RD_PARM1=http%253A%252F%252Fitunes.apple.com%252Fus%252Fapp%252Fregex-cheat-sheet%252Fid307607212%253Fmt%253D8%2526uo%253D4%2526partnerId%253D30" target="itunes_store">RegEx Cheat Sheet</a></h2>
<p><a href="http://click.linksynergy.com/fs-bin/stat?id=8ctO0hHqN8E&amp;offerid=146261&amp;type=3&amp;subid=0&amp;tmpid=1826&amp;RD_PARM1=http%253A%252F%252Fitunes.apple.com%252Fus%252Fapp%252Fregex-cheat-sheet%252Fid307607212%253Fmt%253D8%2526uo%253D4%2526partnerId%253D30"><img src="http://teamtutorials.com/wp-content/uploads/2011/08/regex_cheat_sheet-150x150.jpg" alt="" title="regex_cheat_sheet" width="150" height="150" class="alignleft size-thumbnail wp-image-2858" /></a>The cheatsheet includes:</p>
<p>* Matching: Normal Classes [...] and [^...]<br />
* Matching: Any Character dot (.)<br />
* Class Shorthands (\w, \d, \s, \W, \D, \S)<br />
* POSIX Character Classes (about POSIX, [:alnum:], [:alpha:], [:blank:], etc.)<br />
* Unicode Properties<br />
* Unicode Combining Sequences (\X, and the standard properties list &#8211; properties and meanings)<br />
* Anchors and Zero-width Assertions (start and end of line/string, start of match, would boundary, look ahead and look behind)<br />
* Comments and mode modifiers<br />
* Grouping and Conditionals<br />
* and many more</p>
</div>
<div style="min-height:200px;">
<h2><a href="http://click.linksynergy.com/fs-bin/stat?id=8ctO0hHqN8E&#038;offerid=146261&#038;type=3&#038;subid=0&#038;tmpid=1826&#038;RD_PARM1=http%253A%252F%252Fitunes.apple.com%252Fus%252Fapp%252Fpython-cheat-sheet%252Fid326310651%253Fmt%253D8%2526uo%253D4%2526partnerId%253D30" target="itunes_store">Python Cheat Sheet</a></h2>
<p><a href="http://click.linksynergy.com/fs-bin/stat?id=8ctO0hHqN8E&amp;offerid=146261&amp;type=3&amp;subid=0&amp;tmpid=1826&amp;RD_PARM1=http%253A%252F%252Fitunes.apple.com%252Fus%252Fapp%252Fpython-cheat-sheet%252Fid326310651%253Fmt%253D8%2526uo%253D4%2526partnerId%253D30"><img src="http://teamtutorials.com/wp-content/uploads/2011/08/python_cheat_sheet-150x150.jpg" alt="" title="python_cheat_sheet" width="150" height="150" class="alignleft size-thumbnail wp-image-2869" /></a>This is a native app, not just a link out to internet references. It&#8217;s searchable and has an easy to use interface that helps you quickly find what you&#8217;re looking for. The categories are useful and well defined.</p>
<p>Unlike apps that cobble together random references from the web, this cheat sheet is written and reviewed by professional web developers that use Python on a daily basis. We keep up with changing specifications and provide free updates in the same simple, easy to use format.</p>
</div>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://teamtutorials.com/web-development-tutorials/setting-up-a-wamp-server" title="Setting Up a WAMP Server">Setting Up a WAMP Server</a></li><li><a href="http://teamtutorials.com/programming-tutorials/handling-error-to-prevent-application-crashes-in-vb" title="Handling Errors To Prevent Application Crashes in VB">Handling Errors To Prevent Application Crashes in VB</a></li><li><a href="http://teamtutorials.com/web-development-tutorials/stop-bandwidth-thieves-with-hotlink-protection-in-cpanel" title="Stop Bandwidth Thieves with HotLink Protection in cPanel">Stop Bandwidth Thieves with HotLink Protection in cPanel</a></li><li><a href="http://teamtutorials.com/windows-tutorials/complete-elimination-of-viruses-and-spyware-disabling-system-restore" title="Complete Elimination of Viruses and Spyware (Disabling System Restore)">Complete Elimination of Viruses and Spyware (Disabling System Restore)</a></li><li><a href="http://teamtutorials.com/windows-tutorials/using-windows-defrag-to-increase-computer-response-time" title="Using Windows Defrag to Increase Computer Response Time">Using Windows Defrag to Increase Computer Response Time</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://teamtutorials.com/reviews/8-must-have-iphone-cheat-sheets-for-web-developers/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fix the timthumb.php WordPress exploit</title>
		<link>http://teamtutorials.com/web-development-tutorials/fix-the-timthumb-php-wordpress-exploit?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=fix-the-timthumb-php-wordpress-exploit</link>
		<comments>http://teamtutorials.com/web-development-tutorials/fix-the-timthumb-php-wordpress-exploit#comments</comments>
		<pubDate>Tue, 02 Aug 2011 13:30:02 +0000</pubDate>
		<dc:creator>John Ward</dc:creator>
				<category><![CDATA[Web Development Tutorials]]></category>
		<category><![CDATA[WordPress Tutorials]]></category>
		<category><![CDATA[exploit]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[scritp]]></category>
		<category><![CDATA[timthumb]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://teamtutorials.com/?p=2828</guid>
		<description><![CDATA[There was a recent exploit found in a common file used to generate thumbnails. I found out about the exploit from Mark Maunder&#8217;s site. If you have a server running several wordpress blogs, like us, here is a way to fix all the exploits. If you don&#8217;t want to copy and paste skip to the [...]]]></description>
			<content:encoded><![CDATA[<p>There was a recent exploit found in a common file used to generate thumbnails. I found out about the exploit from<a href="http://markmaunder.com/2011/zero-day-vulnerability-in-many-wordpress-themes/"> Mark Maunder&#8217;s site</a>. If you have a server running several wordpress blogs, like us, here is a way to fix all the exploits.</p>
<p><strong>If you don&#8217;t want to copy and paste skip to the bottom of the post to download the fix.</strong></p>
<p>First, upload a fixed version of the tim thumb file names timthumb-fix.php</p>
<pre class="brush: plain; title: Code Snippet:; notranslate">
&lt;?php
/**
 * TimThumb script created by Ben Gillbanks, originally created by Tim McDaniels and Darren Hoyt
 * http://code.google.com/p/timthumb/
 *
 * GNU General Public License, version 2
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 *
 * Examples and documentation available on the project homepage
 * http://www.binarymoon.co.uk/projects/timthumb/
 */

define ('CACHE_SIZE', 1000);				// number of files to store before clearing cache
define ('CACHE_CLEAR', 20);					// maximum number of files to delete on each cache clear
define ('CACHE_USE', TRUE);					// use the cache files? (mostly for testing)
define ('CACHE_MAX_AGE', 864000);			// time to cache in the browser
define ('VERSION', '1.28');					// version number (to force a cache refresh)
define ('DIRECTORY_CACHE', './cache');		// cache directory
define ('MAX_WIDTH', 1500);					// maximum image width
define ('MAX_HEIGHT', 1500);				// maximum image height
define ('ALLOW_EXTERNAL', FALSE);			// allow external website (override security precaution - not advised!)
define ('MEMORY_LIMIT', '30M');				// set PHP memory limit
define ('MAX_FILE_SIZE', 1500000);			// file size limit to prevent possible DOS attacks (roughly 1.5 megabytes)
define ('CURL_TIMEOUT', 10);				// timeout duration. Tweak as you require (lower = better)

// external domains that are allowed to be displayed on your website
$allowedSites = array ();

// STOP MODIFYING HERE!
// --------------------

// sort out image source
$src = get_request ('src', '');
if ($src == '' || strlen ($src) &lt;= 3) {
    display_error ('no image specified');
}

// clean params before use
$src = clean_source ($src);

// get mime type of src
$mime_type = mime_type ($src);

// used for external websites only
$external_data_string = '';

// generic file handle for reading and writing to files
$fh = '';

// check to see if this image is in the cache already
// if already cached then display the image and die
check_cache ($mime_type);

// cache doesn't exist and then process everything
// check to see if GD function exist
if (!function_exists ('imagecreatetruecolor')) {
    display_error ('GD Library Error: imagecreatetruecolor does not exist - please contact your webhost and ask them to install the GD library');
}

if (function_exists ('imagefilter') &amp;&amp; defined ('IMG_FILTER_NEGATE')) {
	$imageFilters = array (
		1 =&gt; array (IMG_FILTER_NEGATE, 0),
		2 =&gt; array (IMG_FILTER_GRAYSCALE, 0),
		3 =&gt; array (IMG_FILTER_BRIGHTNESS, 1),
		4 =&gt; array (IMG_FILTER_CONTRAST, 1),
		5 =&gt; array (IMG_FILTER_COLORIZE, 4),
		6 =&gt; array (IMG_FILTER_EDGEDETECT, 0),
		7 =&gt; array (IMG_FILTER_EMBOSS, 0),
		8 =&gt; array (IMG_FILTER_GAUSSIAN_BLUR, 0),
		9 =&gt; array (IMG_FILTER_SELECTIVE_BLUR, 0),
		10 =&gt; array (IMG_FILTER_MEAN_REMOVAL, 0),
		11 =&gt; array (IMG_FILTER_SMOOTH, 0),
	);
}

// get standard input properties
$new_width =  (int) abs (get_request ('w', 0));
$new_height = (int) abs (get_request ('h', 0));
$zoom_crop = (int) get_request ('zc', 1);
$quality = (int) abs (get_request ('q', 90));
$align = get_request ('a', 'c');
$filters = get_request ('f', '');
$sharpen = (bool) get_request ('s', 0);

// set default width and height if neither are set already
if ($new_width == 0 &amp;&amp; $new_height == 0) {
    $new_width = 100;
    $new_height = 100;
}

// ensure size limits can not be abused
$new_width = min ($new_width, MAX_WIDTH);
$new_height = min ($new_height, MAX_HEIGHT);

// set memory limit to be able to have enough space to resize larger images
ini_set ('memory_limit', MEMORY_LIMIT);

if (file_exists ($src)) {

    // open the existing image
    $image = open_image ($mime_type, $src);
    if ($image === false) {
        display_error ('Unable to open image : ' . $src);
    }

    // Get original width and height
    $width = imagesx ($image);
    $height = imagesy ($image);
	$origin_x = 0;
	$origin_y = 0;

    // generate new w/h if not provided
    if ($new_width &amp;&amp; !$new_height) {
        $new_height = floor ($height * ($new_width / $width));
    } else if ($new_height &amp;&amp; !$new_width) {
        $new_width = floor ($width * ($new_height / $height));
    }

	// scale down and add borders
	if ($zoom_crop == 3) {

		$final_height = $height * ($new_width / $width);

		if ($final_height &gt; $new_height) {
			$new_width = $width * ($new_height / $height);
		} else {
			$new_height = $final_height;
		}

	}

	// create a new true color image
	$canvas = imagecreatetruecolor ($new_width, $new_height);
	imagealphablending ($canvas, false);

	// Create a new transparent color for image
	$color = imagecolorallocatealpha ($canvas, 0, 0, 0, 127);

	// Completely fill the background of the new image with allocated color.
	imagefill ($canvas, 0, 0, $color);

	// scale down and add borders
	if ($zoom_crop == 2) {

		$final_height = $height * ($new_width / $width);

		if ($final_height &gt; $new_height) {

			$origin_x = $new_width / 2;
			$new_width = $width * ($new_height / $height);
			$origin_x = round ($origin_x - ($new_width / 2));

		} else {

			$origin_y = $new_height / 2;
			$new_height = $final_height;
			$origin_y = round ($origin_y - ($new_height / 2));

		}

	}

	// Restore transparency blending
	imagesavealpha ($canvas, true);

	if ($zoom_crop &gt; 0) {

		$src_x = $src_y = 0;
		$src_w = $width;
		$src_h = $height;

		$cmp_x = $width / $new_width;
		$cmp_y = $height / $new_height;

		// calculate x or y coordinate and width or height of source
		if ($cmp_x &gt; $cmp_y) {

			$src_w = round ($width / $cmp_x * $cmp_y);
			$src_x = round (($width - ($width / $cmp_x * $cmp_y)) / 2);

		} else if ($cmp_y &gt; $cmp_x) {

			$src_h = round ($height / $cmp_y * $cmp_x);
			$src_y = round (($height - ($height / $cmp_y * $cmp_x)) / 2);

		}

		// positional cropping!
		if ($align) {
			if (strpos ($align, 't') !== false) {
				$src_y = 0;
			}
			if (strpos ($align, 'b') !== false) {
				$src_y = $height - $src_h;
			}
			if (strpos ($align, 'l') !== false) {
				$src_x = 0;
			}
			if (strpos ($align, 'r') !== false) {
				$src_x = $width - $src_w;
			}
		}

		imagecopyresampled ($canvas, $image, $origin_x, $origin_y, $src_x, $src_y, $new_width, $new_height, $src_w, $src_h);

    } else {

        // copy and resize part of an image with resampling
        imagecopyresampled ($canvas, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

    }

    if ($filters != '' &amp;&amp; function_exists ('imagefilter') &amp;&amp; defined ('IMG_FILTER_NEGATE')) {
        // apply filters to image
        $filterList = explode ('|', $filters);
        foreach ($filterList as $fl) {

            $filterSettings = explode (',', $fl);
            if (isset ($imageFilters[$filterSettings[0]])) {

                for ($i = 0; $i &lt; 4; $i ++) {
                    if (!isset ($filterSettings[$i])) {
						$filterSettings[$i] = null;
                    } else {
						$filterSettings[$i] = (int) $filterSettings[$i];
					}
                }

                switch ($imageFilters[$filterSettings[0]][1]) {

                    case 1:

                        imagefilter ($canvas, $imageFilters[$filterSettings[0]][0], $filterSettings[1]);
                        break;

                    case 2:

                        imagefilter ($canvas, $imageFilters[$filterSettings[0]][0], $filterSettings[1], $filterSettings[2]);
                        break;

                    case 3:

                        imagefilter ($canvas, $imageFilters[$filterSettings[0]][0], $filterSettings[1], $filterSettings[2], $filterSettings[3]);
                        break;

                    case 4:

                        imagefilter ($canvas, $imageFilters[$filterSettings[0]][0], $filterSettings[1], $filterSettings[2], $filterSettings[3], $filterSettings[4]);
                        break;

                    default:

                        imagefilter ($canvas, $imageFilters[$filterSettings[0]][0]);
                        break;

                }
            }
        }
    }

	// sharpen image
	if ($sharpen &amp;&amp; function_exists ('imageconvolution')) {

		$sharpenMatrix = array (
			array (-1,-1,-1),
			array (-1,16,-1),
			array (-1,-1,-1),
		);

		$divisor = 8;
		$offset = 0;

		imageconvolution ($canvas, $sharpenMatrix, $divisor, $offset);

	}

    // output image to browser based on mime type
    show_image ($mime_type, $canvas);

    // remove image from memory
    imagedestroy ($canvas);

	// if not in cache then clear some space and generate a new file
	clean_cache ();

	die ();

} else {

    if (strlen ($src)) {
        display_error ('image ' . $src . ' not found');
    } else {
        display_error ('no source specified');
    }

}

/**
 *
 * @global &lt;type&gt; $quality
 * @param &lt;type&gt; $mime_type
 * @param &lt;type&gt; $image_resized
 */
function show_image ($mime_type, $image_resized) {

    global $quality;

    $cache_file = get_cache_file ($mime_type);

	switch ($mime_type) {
		case 'jpg':
			imagejpeg ($image_resized, $cache_file, $quality);
			break;

		default:
		case 'png':
			imagepng ($image_resized, $cache_file, floor ($quality * 0.09));
			break;

	}

	show_cache_file ($mime_type);

}

/**
 *
 * @param &lt;type&gt; $property
 * @param &lt;type&gt; $default
 * @return &lt;type&gt;
 */
function get_request ($property, $default = 0) {

    if (isset ($_GET[$property])) {
        return $_GET[$property];
    } else {
        return $default;
    }

}

/**
 *
 * @param &lt;type&gt; $mime_type
 * @param &lt;type&gt; $src
 * @return &lt;type&gt;
 */
function open_image ($mime_type, $src) {

	switch ($mime_type) {
		case 'jpg':
			$image = imagecreatefromjpeg ($src);
			break;

		case 'png':
			$image = imagecreatefrompng ($src);
			break;

		case 'gif':
			$image = imagecreatefromgif ($src);
			break;
	}

    return $image;

}

/**
 * clean out old files from the cache
 * you can change the number of files to store and to delete per loop in the defines at the top of the code
 *
 * @return &lt;type&gt;
 */
function clean_cache () {

	// add an escape
	// Reduces the amount of cache clearing to save some processor speed
	if (rand (1, 50) &gt; 10) {
		return true;
	}

	flush ();

    $files = glob (DIRECTORY_CACHE . '/*', GLOB_BRACE);

	if (count ($files) &gt; CACHE_SIZE) {

        $yesterday = time () - (24 * 60 * 60);

        usort ($files, 'filemtime_compare');
        $i = 0;

		foreach ($files as $file) {

			$i ++;

			if ($i &gt;= CACHE_CLEAR) {
				return;
			}

			if (@filemtime ($file) &gt; $yesterday) {
				return;
			}

			if (file_exists ($file)) {
				unlink ($file);
			}

		}

    }

}

/**
 * compare the file time of two files
 *
 * @param &lt;type&gt; $a
 * @param &lt;type&gt; $b
 * @return &lt;type&gt;
 */
function filemtime_compare ($a, $b) {

	$break = explode ('/', $_SERVER['SCRIPT_FILENAME']);
	$filename = $break[count ($break) - 1];
	$filepath = str_replace ($filename, '', $_SERVER['SCRIPT_FILENAME']);

	$file_a = realpath ($filepath . $a);
	$file_b = realpath ($filepath . $b);

    return filemtime ($file_a) - filemtime ($file_b);

}

/**
 * determine the file mime type
 *
 * @param &lt;type&gt; $file
 * @return &lt;type&gt;
 */
function mime_type ($file) {

	$file_infos = getimagesize ($file);
	$mime_type = $file_infos['mime'];

	// no mime type
	if (empty ($mime_type)) {
		display_error ('no mime type specified');
	}

    // use mime_type to determine mime type
    if (!preg_match (&quot;/jpg|jpeg|gif|png/i&quot;, $mime_type)) {
		display_error ('Invalid src mime type: ' . $mime_type);
    }

	$mime_type = strtolower ($mime_type);
	$mime_type = str_replace ('image/', '', $mime_type);

	if ($mime_type == 'jpeg') {
		$mime_type = 'jpg';
	}

    return $mime_type;

}

/**
 *
 * @param &lt;type&gt; $mime_type
 */
function check_cache ($mime_type) {

	if (CACHE_USE) {

		if (!show_cache_file ($mime_type)) {
			// make sure cache dir exists
			if (!file_exists (DIRECTORY_CACHE)) {
				// give 777 permissions so that developer can overwrite
				// files created by web server user
				mkdir (DIRECTORY_CACHE);
				chmod (DIRECTORY_CACHE, 0777);
			}
		}

	}

}

/**
 *
 * @param &lt;type&gt; $mime_type
 * @return &lt;type&gt;
 */
function show_cache_file ($mime_type) {

	// use browser cache if available to speed up page load
	if (!empty ($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
		if (strtotime ($_SERVER['HTTP_IF_MODIFIED_SINCE']) &lt; strtotime ('now')) {
			header ('HTTP/1.1 304 Not Modified');
			die ();
		}
	}

	$cache_file = get_cache_file ($mime_type);

	if (file_exists ($cache_file)) {

		// change the modified headers
		$gmdate_expires = gmdate ('D, d M Y H:i:s', strtotime ('now +10 days')) . ' GMT';
		$gmdate_modified = gmdate ('D, d M Y H:i:s') . ' GMT';

		// send content headers then display image
		header ('Content-Type: ' . $mime_type);
		header ('Accept-Ranges: bytes');
		header ('Last-Modified: ' . $gmdate_modified);
		header ('Content-Length: ' . filesize ($cache_file));
		header ('Cache-Control: max-age=' . CACHE_MAX_AGE . ', must-revalidate');
		header ('Expires: ' . $gmdate_expires);

		if (!@readfile ($cache_file)) {
			$content = file_get_contents ($cache_file);
			if ($content != FALSE) {
				echo $content;
			} else {
				display_error ('cache file could not be loaded');
			}
		}

		die ();

    }

	return FALSE;

}

/**
 *
 * @staticvar string $cache_file
 * @param &lt;type&gt; $mime_type
 * @return string
 */
function get_cache_file ($mime_type) {

    static $cache_file;
	global $src;

	$file_type = '.png';

	if ($mime_type == 'jpg') {
		$file_type = '.jpg';
    }

    if (!$cache_file) {
		// filemtime is used to make sure updated files get recached
        $cache_file = DIRECTORY_CACHE . '/' . md5 ($_SERVER ['QUERY_STRING'] . VERSION . filemtime ($src)) . $file_type;
    }

    return $cache_file;

}

/**
 *
 * @param &lt;type&gt; $url
 * @return &lt;type&gt;
 */
function validate_url ($url) {
	$pattern = &quot;/\b(?:(?:https?):\/\/|www\.)[-a-z0-9+&amp;@#\/%?=~_|!:,.;]*[-a-z0-9+&amp;@#\/%=~_|]/i&quot;;
	return preg_match ($pattern, $url);
}

/**
 *
 * @global array $allowedSites
 * @param string $src
 * @return string
 */
function check_external ($src) {

	global $allowedSites;

	// work out file details
	$fileDetails = pathinfo ($src);
	$filename = 'external_' . md5 ($src);
	$local_filepath = DIRECTORY_CACHE . '/' . $filename . '.' . strtolower ($fileDetails['extension']);

	// only do this stuff the file doesn't already exist
	if (!file_exists ($local_filepath)) {

		if (strpos (strtolower ($src), 'http://') !== false || strpos (strtolower ($src), 'https://') !== false) {

			if (!validate_url ($src)) {
				display_error ('invalid url');
			}

			$url_info = parse_url ($src);

			// convert youtube video urls
			// need to tidy up the code

			if ($url_info['host'] == 'www.youtube.com' || $url_info['host'] == 'youtube.com') {
				parse_str ($url_info['query']);

				if (isset ($v)) {
					$src = 'http://img.youtube.com/vi/' . $v . '/0.jpg';
					$url_info['host'] = 'img.youtube.com';
				}
			}

			// check allowed sites (if required)
			if (ALLOW_EXTERNAL) {

				$isAllowedSite = true;

			} else {

				$isAllowedSite = false;
				foreach ($allowedSites as $site) {
					if (strpos (strtolower ($url_info['host']), $site) !== false) {
						$isAllowedSite = true;
					}
				}

			}

			// if allowed
			if ($isAllowedSite) {

				if (function_exists ('curl_init')) {

					global $fh;

					$fh = fopen ($local_filepath, 'w');
					$ch = curl_init ($src);

					curl_setopt ($ch, CURLOPT_TIMEOUT, CURL_TIMEOUT);
					curl_setopt ($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0');
					curl_setopt ($ch, CURLOPT_URL, $src);
					curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE);
					curl_setopt ($ch, CURLOPT_HEADER, 0);
					curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
					curl_setopt ($ch, CURLOPT_FILE, $fh);
					curl_setopt ($ch, CURLOPT_WRITEFUNCTION, 'curl_write');

					// error so die
					if (curl_exec ($ch) === FALSE) {
						unlink ($local_filepath);
						touch ($local_filepath);
						display_error ('error reading file ' . $src . ' from remote host: ' . curl_error ($ch));
					}

					curl_close ($ch);
					fclose ($fh);

                } else {

					if (!$img = file_get_contents ($src)) {
						display_error ('remote file for ' . $src . ' can not be accessed. It is likely that the file permissions are restricted');
					}

					if (file_put_contents ($local_filepath, $img) == FALSE) {
						display_error ('error writing temporary file');
					}

				}

				if (!file_exists ($local_filepath)) {
					display_error ('local file for ' . $src . ' can not be created');
				}

				$src = $local_filepath;

			} else {

				display_error ('remote host &quot;' . $url_info['host'] . '&quot; not allowed');

			}

		}

    } else {

		$src = $local_filepath;

	}

    return $src;

}

/**
 * callback for curl command to receive external images
 * limit the amount of data downloaded from external servers
 *
 * @global &lt;type&gt; $data_string
 * @param &lt;type&gt; $handle
 * @param &lt;type&gt; $data
 * @return &lt;type&gt;
 */
function curl_write ($handle, $data) {

	global $external_data_string, $fh;

	fwrite ($fh, $data);
	$external_data_string .= $data;

	if (strlen ($external_data_string) &gt; MAX_FILE_SIZE) {
		return 0;
	} else {
		return strlen ($data);
	}

}

/**
 * tidy up the image source url
 *
 * @param &lt;type&gt; $src
 * @return string
 */
function clean_source ($src) {

	$host = str_replace ('www.', '', $_SERVER['HTTP_HOST']);
	$regex = &quot;/^(http(s|):\/\/)(www\.|)&quot; . $host . &quot;\//i&quot;;

	$src = preg_replace ($regex, '', $src);
	$src = strip_tags ($src);
    $src = check_external ($src);

    // remove slash from start of string
    if (strpos ($src, '/') === 0) {
        $src = substr ($src, -(strlen ($src) - 1));
    }

    // don't allow users the ability to use '../'
    // in order to gain access to files below document root
    $src = preg_replace (&quot;/\.\.+\//&quot;, &quot;&quot;, $src);

    // get path to image on file system
    $src = get_document_root ($src) . '/' . $src;

	if (!is_file ($src)) {
		display_error ('source is not a valid file');
	}

	if (filesize ($src) &gt; MAX_FILE_SIZE) {
		display_error ('source file is too big (filesize &gt; MAX_FILE_SIZE)');
	}

	if (filesize ($src) &lt;= 0) {
		display_error ('source file &lt;= 0 bytes. Possible external file download error (file is too large)');
	}

    return realpath ($src);

}

/**
 *
 * @param &lt;type&gt; $src
 * @return string
 */
function get_document_root ($src) {

    // check for unix servers
    if (file_exists ($_SERVER['DOCUMENT_ROOT'] . '/' . $src)) {
        return $_SERVER['DOCUMENT_ROOT'];
    }

    // check from script filename (to get all directories to timthumb location)
    $parts = array_diff (explode ('/', $_SERVER['SCRIPT_FILENAME']), explode ('/', $_SERVER['DOCUMENT_ROOT']));

	$path = './';

	foreach ($parts as $part) {
		if (file_exists ($path . '/' . $src)) {
			return realpath ($path);
		}
		$path .= '../';
	}

    // special check for microsoft servers
    if (!isset ($_SERVER['DOCUMENT_ROOT'])) {
        $path = str_replace (&quot;/&quot;, &quot;\\&quot;, $_SERVER['ORIG_PATH_INFO']);
        $path = str_replace ($path, '', $_SERVER['SCRIPT_FILENAME']);

        if (file_exists ($path . '/' . $src)) {
            return realpath ($path);
        }
    }

    display_error ('file not found');

}

/**
 * generic error message
 *
 * @param &lt;type&gt; $errorString
 */
function display_error ($errorString = '') {

    header ('HTTP/1.1 400 Bad Request');
	echo '&lt;pre&gt;' . htmlentities ($errorString);
	echo '&lt;br /&gt;Query String : ' . htmlentities ($_SERVER['QUERY_STRING']);
	echo '&lt;br /&gt;TimThumb version : ' . VERSION . '&lt;/pre&gt;';
    die ();

}
</pre>
<p>Then upload our shell script as fix_timthumb.sh:</p>
<pre class="brush: plain; title: Code Snippet:; notranslate">
#!/bin/bash
find /home/ -name 'timthumb.php' -type f -printf '%h\n' | while read line
do
#Remove the old thumb
rm -rf $line/timthumb.php

#Copy fixed thumb
cp timthumb-fix.php $line/timthumb.php

echo $line &quot; done&quot;;
done
</pre>
<p>The all you have to do is execute this command:</p>
<pre class="brush: plain; title: Code Snippet:; notranslate">
sh -x fix_timthumb.sh
</pre>
<p>The script will find any timthumb.php file and replace it with your fixed file. You will probably need root access to do this.</p>
<p>[tweet2download file="timthum_fix.zip" tweet="Replace all timthumb.php files on your server http://su.pr/1Libna" follow="@teamtutorials" /]</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://teamtutorials.com/web-development-tutorials/stop-bandwidth-thieves-with-hotlink-protection-in-cpanel" title="Stop Bandwidth Thieves with HotLink Protection in cPanel">Stop Bandwidth Thieves with HotLink Protection in cPanel</a></li><li><a href="http://teamtutorials.com/site-news/team-tutorials-upgraded-to-wordpress-221" title="Team Tutorials Upgraded to Wordpress 2.2.1">Team Tutorials Upgraded to Wordpress 2.2.1</a></li><li><a href="http://teamtutorials.com/windows-tutorials/using-windows-vista-system-restore" title="Using Windows Vista System Restore">Using Windows Vista System Restore</a></li><li><a href="http://teamtutorials.com/web-development-tutorials/setting-up-a-wamp-server" title="Setting Up a WAMP Server">Setting Up a WAMP Server</a></li><li><a href="http://teamtutorials.com/windows-tutorials/auto-defrag-with-3rd-party-software" title="Auto-Defrag with 3rd Party Software">Auto-Defrag with 3rd Party Software</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://teamtutorials.com/web-development-tutorials/fix-the-timthumb-php-wordpress-exploit/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Creating a Pill Icon in Photoshop</title>
		<link>http://teamtutorials.com/photoshop-tutorials/creating-a-pill-icon-in-photoshop?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=creating-a-pill-icon-in-photoshop</link>
		<comments>http://teamtutorials.com/photoshop-tutorials/creating-a-pill-icon-in-photoshop#comments</comments>
		<pubDate>Fri, 29 Jul 2011 23:09:56 +0000</pubDate>
		<dc:creator>John Ward</dc:creator>
				<category><![CDATA[Photoshop Tutorials]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[effects]]></category>
		<category><![CDATA[photoshop]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://teamtutorials.com/?p=2748</guid>
		<description><![CDATA[In this tutorial you will be learning basic techniques in Photoshop, such as using layer styles, brush and pen tool and effects. The end product will be a glossy pill icon, useful as a logo or an illustration. The tutorial is suitable for absolute beginners.]]></description>
			<content:encoded><![CDATA[<p>In this tutorial you will be learning basic techniques in Photoshop, such as using layer styles, brush and pen tool and effects. The end product will be a glossy pill icon, useful as a logo or an illustration. The tutorial is suitable for absolute beginners.</p>
<p><strong>1. Create a new document</strong><br />
Create a new document by hitting Ctrl+N or Cmd+N on Mac with following values.<br />
<a href="http://teamtutorials.com/wp-content/uploads/2011/07/image1.png"><img class="alignnone size-medium wp-image-2752" title="image1" src="http://teamtutorials.com/wp-content/uploads/2011/07/image1.png" alt="" width="520" height="306" /></a></p>
<p>For easier workflow make sure you have Auto-Select Layer and Show Transform Controls ticked.<br />
<a href="http://teamtutorials.com/wp-content/uploads/2011/07/image2.png"><img class="alignnone size-medium wp-image-2754" title="image2" src="http://teamtutorials.com/wp-content/uploads/2011/07/image2.png" alt="" width="349" height="63" /></a></p>
<p><strong>2. Place and trace</strong><br />
Drag and drop the sketch.jpg file into the canvas and resize it with transformation tool to fit. Hit enter.<br />
<img class="alignnone size-medium wp-image-2755" title="image3" src="http://teamtutorials.com/wp-content/uploads/2011/07/image3-700x465.png" alt="" width="590" height="391" /></p>
<p>Lock the sketch bitmap layer by selecting it and clicking on the padlock icon.<br />
<a href="http://teamtutorials.com/wp-content/uploads/2011/07/image4.png"><img class="alignnone size-medium wp-image-2756" title="image4" src="http://teamtutorials.com/wp-content/uploads/2011/07/image4.png" alt="" width="234" height="136" /></a></p>
<p>Select the pen tool and click on &#8216;Shape Layer&#8217; in the toolbar.<br />
<a href="http://teamtutorials.com/wp-content/uploads/2011/07/image5.png"><img class="alignnone size-medium wp-image-2757" title="image5" src="http://teamtutorials.com/wp-content/uploads/2011/07/image5.png" alt="" width="180" height="467" /></a></p>
<p>Start tracing by clicking on any edge of sketch and adding points. Photoshop will create a new shape layer. Try to follow sketch lines to fill one part of the pill icon.<br />
<a href="http://teamtutorials.com/wp-content/uploads/2011/07/image6.png"><img class="alignnone size-medium wp-image-2758" title="image6" src="http://teamtutorials.com/wp-content/uploads/2011/07/image6.png" alt="" width="658" height="427" /></a></p>
<p>After closing the shape by clicking on the first point, select Direct Selection Tool (Ctrl+Shift+A) to manipulate any misplaced points. You can move them around by clicking twice.<br />
<a href="http://teamtutorials.com/wp-content/uploads/2011/07/image7.png"><img class="alignnone size-medium wp-image-2759" title="image7" src="http://teamtutorials.com/wp-content/uploads/2011/07/image7.png" alt="" width="628" height="372" /></a></p>
<p>When you&#8217;re happy with the shape, click on the layer and name it something descriptive by double clicking on name and click on eye icon to hide it.<br />
<a href="http://teamtutorials.com/wp-content/uploads/2011/07/image8.png"><img class="alignnone size-medium wp-image-2762" title="image8" src="http://teamtutorials.com/wp-content/uploads/2011/07/image8.png" alt="" width="244" height="204" /></a></p>
<p>Do same with the other part of the pill and get them aligned. Move the right part layer on top of the other by dragging and dropping. Hide the sketch layer.</p>
<p>Now select colors you&#8217;ll be using and fill shapes with them by double-clicking layer thumbnail. Colors used in tutorial are RGB(221, 62, 62) and RGB(224, 220, 220).<br />
<a href="http://teamtutorials.com/wp-content/uploads/2011/07/image9.png"><img class="alignnone size-medium wp-image-2763" title="image9" src="http://teamtutorials.com/wp-content/uploads/2011/07/image9.png" alt="" width="238" height="212" /></a></p>
<p>Select both layers and click &#8216;Duplicate layers&#8217; in right-click menu. Merge duplicates into one rasterized layer by selecting &#8216;Merge&#8217; from same menu.<br />
<a href="http://teamtutorials.com/wp-content/uploads/2011/07/image10.png"><img class="alignnone size-medium wp-image-2764" title="image10" src="http://teamtutorials.com/wp-content/uploads/2011/07/image10.png" alt="" width="242" height="224" /></a></p>
<p>Double click on created layer and click on Color overlay. Select white color and hit OK.<br />
<a href="http://teamtutorials.com/wp-content/uploads/2011/07/image11.png"><img class="alignnone size-medium wp-image-2765" title="image11" src="http://teamtutorials.com/wp-content/uploads/2011/07/image11.png" alt="" width="594" height="435" /></a></p>
<p>Resize and rotate the shape so it covers a little less than half of the pill.<br />
<a href="http://teamtutorials.com/wp-content/uploads/2011/07/image12.png"><img src="http://teamtutorials.com/wp-content/uploads/2011/07/image12-150x150.png" alt="" title="image12" width="150" height="150" class="alignnone size-thumbnail wp-image-2766" /></a><br />
Ctrl click on one layer&#8217;s vector mask thumbnail and hold Ctrl+Shift while clicking on another. This will select both layers&#8217; pixels. Hit Ctrl+Shift+I to inverse selection and hit Delete with &#8216;highlight&#8217; layer selected. Set layer&#8217;s opacity to 25%.<br />
<a href="http://teamtutorials.com/wp-content/uploads/2011/07/image131.png"><img class="alignnone size-medium wp-image-2767" title="image13" src="http://teamtutorials.com/wp-content/uploads/2011/07/image131.png" alt="" width="592" height="380" /></a></p>
<p><strong>3. Effects</strong><br />
Select the Brush tool and apply the following settings in right-click menu:<br />
<a href="http://teamtutorials.com/wp-content/uploads/2011/07/image14.png"><img class="alignnone size-medium wp-image-2768" title="image14" src="http://teamtutorials.com/wp-content/uploads/2011/07/image14.png" alt="" width="258" height="248" /></a></p>
<p>Now select pill layer&#8217;s pixels once again and paint a highlight on a new layer. Set its opacity to 50%.<br />
<a href="http://teamtutorials.com/wp-content/uploads/2011/07/image15.png"><img src="http://teamtutorials.com/wp-content/uploads/2011/07/image15-700x341.png" alt="" title="image15" width="590" height="287" class="alignnone size-medium wp-image-2769" /></a></p>
<p>With same selection create another layer, set brush size to 200px and select black color. Paint on the bottom of the pill.<br />
<img class="alignnone size-medium wp-image-2770" title="image16" src="http://teamtutorials.com/wp-content/uploads/2011/07/image16.png" alt="" width="532" height="346" /><br />
Apply following settings:<br />
<a href="http://teamtutorials.com/wp-content/uploads/2011/07/image17.png"><img class="alignnone size-medium wp-image-2771" title="image17" src="http://teamtutorials.com/wp-content/uploads/2011/07/image17.png" alt="" width="380" height="457" /></a></p>
<p>Paint on the end of the pill. Then set brush size to 400px and touch for highlight. Then paint another line of highlight on top edge of the pill.<br />
<a href="http://teamtutorials.com/wp-content/uploads/2011/07/image18.png"><img class="alignnone size-medium wp-image-2772" title="image18" src="http://teamtutorials.com/wp-content/uploads/2011/07/image18.png" alt="" width="577" height="380" /></a></p>
<p>Double click on the Right part and Left part layers and apply these layer styles:<br />
<a href="http://teamtutorials.com/wp-content/uploads/2011/07/image192.png"><img class="alignnone size-medium wp-image-2784" title="image19" src="http://teamtutorials.com/wp-content/uploads/2011/07/image192-590x216.png" alt="" width="590" height="216" /></a></p>
<p>Time to sort out our layers. Name them, group them, and let&#8217;s move on to final touch.</p>
<p><strong>4. Drop shadow</strong><br />
Duplicate and merge Right and Left part&#8217;s layers once again and move it behind them. Overlay it with black color with layer styles.<br />
<a href="http://teamtutorials.com/wp-content/uploads/2011/07/image20.png"><img class="alignnone size-medium wp-image-2774" title="image20" src="http://teamtutorials.com/wp-content/uploads/2011/07/image20.png" alt="" width="595" height="434" /></a></p>
<p>Choose Edit -&gt; Transform -&gt; Perspective and modify layer according to perspective.<br />
<a href="http://teamtutorials.com/wp-content/uploads/2011/07/image21.png"><img class="alignnone size-medium wp-image-2775" title="image21" src="http://teamtutorials.com/wp-content/uploads/2011/07/image21.png" alt="" width="581" height="390" /></a></p>
<p>Then fo under Filter -&gt; Blur -&gt; Gaussian Blur and type in 40px. Take layer&#8217;s opacity down to 80% and you&#8217;re done.<br />
<a href="http://teamtutorials.com/wp-content/uploads/2011/07/image221.png"><img class="alignnone size-medium wp-image-2776" title="image22" src="http://teamtutorials.com/wp-content/uploads/2011/07/image221.png" alt="" width="490" height="354" /></a></p>
<h3>Get the PSD</h3>
<p>[tweet2download file="files.zip" tweet="Creating a Pill Icon in Photoshop http://su.pr/4004am on @teamtutorials" follow="@teamtutorials" /]</p>
<p><em><br />
This tutorial was written by Heidi Pungartnik, web and graphic designer. You can follow her on twitter (<a href="http://twitter.com/#!/ashocka18" target="_blank">@ashocka18</a>) or visit her website at <a href="http://ashocka.com" target="_blank">aShocka.com</a>.<br />
</em></p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://teamtutorials.com/photoshop-tutorials/recreate-the-diggcom-header" title="Recreate the Digg.com Header">Recreate the Digg.com Header</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://teamtutorials.com/photoshop-tutorials/creating-a-pill-icon-in-photoshop/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Parsing XML Feed to an Array with XPath</title>
		<link>http://teamtutorials.com/web-development-tutorials/php-tutorials/parsing-xml-feed-to-an-array-with-xpath?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=parsing-xml-feed-to-an-array-with-xpath</link>
		<comments>http://teamtutorials.com/web-development-tutorials/php-tutorials/parsing-xml-feed-to-an-array-with-xpath#comments</comments>
		<pubDate>Sun, 16 Jan 2011 00:17:36 +0000</pubDate>
		<dc:creator>Mike Maguire</dc:creator>
				<category><![CDATA[PHP Tutorials]]></category>
		<category><![CDATA[Programming Tutorials]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://teamtutorials.com/?p=2649</guid>
		<description><![CDATA[Recently while working on a project, I found myself needed to parse several different types of files through the same mechanism (CSV, pipe delimited, XML, and more). I decided that it would be best to get each time of feed to a identical object that could then be run through the same methods regardless of the input type. This tutorial will walk you through using PHP and XPath to parse the values from an XML file and store them into array for later manipulation. ]]></description>
			<content:encoded><![CDATA[<p>Recently while working on a project, I found myself needed to parse several different types of files through the same mechanism (CSV, pipe delimited, XML, and more). I decided that it would be best to get each time of feed to a identical object that could then be run through the same methods regardless of the input type. This tutorial will walk you through using PHP and XPath to parse the values from an XML file and store them into array for later manipulation. </p>
<p>To start, for those that are unfamiliar with XPath. It is a mechanism which will allow you to easily navigate and retrieve elements and attributes from XML and HTML. It&#8217;s preety simple to understand and can make life a lot easier when dealing with these languages.<br />
Let&#8217;s take a look at the following XML example. An XPath is literally just a path to whatever attribute or element you are looking to get. </p>
<pre class="brush: xml; title: Code Snippet:; notranslate">
&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;catalog&gt;
   &lt;book id=&quot;bk101&quot;&gt;
      &lt;author&gt;Gambardella, Matthew&lt;/author&gt;
      &lt;title&gt;XML Developer's Guide&lt;/title&gt;
      &lt;genre&gt;Computer&lt;/genre&gt;
      &lt;price&gt;44.95&lt;/price&gt;
      &lt;publish_date&gt;2000-10-01&lt;/publish_date&gt;
      &lt;description&gt;An in-depth look at creating applications
      with XML.&lt;/description&gt;
   &lt;/book&gt;
   &lt;book id=&quot;bk102&quot;&gt;
      &lt;author&gt;Ralls, Kim&lt;/author&gt;
      &lt;title&gt;Midnight Rain&lt;/title&gt;
      &lt;genre&gt;Fantasy&lt;/genre&gt;
      &lt;price&gt;5.95&lt;/price&gt;
      &lt;publish_date&gt;2000-12-16&lt;/publish_date&gt;
      &lt;description&gt;A former architect battles corporate zombies,
      an evil sorceress, and her own childhood to become queen
      of the world.&lt;/description&gt;
   &lt;/book&gt;
&lt;/catalog&gt;
</pre>
<p>//catalog/book/title would return the nodes that match that. In this case, there would be 2.</p>
<p>This is the basic idea behind XPath. If you are interested in learning more or need more information please review the information that they have over at <a href="http://www.w3schools.com/xpath/default.asp">w3schools</a> on the subject. They will be able to provide everything you need to get started.</p>
<p>First lets create our method that will do the actually data collection for us:</p>
<pre class="brush: php; title: Code Snippet:; notranslate">
   function parseXML($feed_url,$field_xpaths)
    {
        //Get file from url
        $file_contents = file_get_contents($feed_url);

        //create xml object
        $xml = new SimpleXMLElement($file_contents);

        //Work through all fields we need to collect
        foreach($field_xpaths[0] as $key=&gt;$field_xpath)
        {
            $count = 0;

            //Get an array of fields that match the current xpath
            $xpath_returns = $xml-&gt;xpath($field_xpath);
            //Iterate through the array and assign values to the coupon array
            while(list( , $node) = each($xpath_returns))
            {
                $rows[$count][$key] = $node;
                $count++;
            }
        }

        return $rows;
    }
</pre>
<p>When you break this down, you see how simple this really is to achieve. The way this function is written, it will accept an array for the $field_xpaths variable. Then it will iterate the through the array treating each as it&#8217;s own xpath. Each value will use it&#8217;s key in the array as it&#8217;s name (in my example, these values are pulled from a database, so the column name is the name of the key for that value in the array). </p>
<p>It first grabs the entire contents of the file and associates a SimpleXMLElements object to them. This object will allow us to use XPath operators to navigate through our nodes. For each set in the array (key and value) we get all values that match the XPath provided. We then iterate through each value in the returned array and store it in a master array (in this case it&#8217;s just called rows). When this is done processing, all values for each xpath will be stored in an multi dimensional array that you can call by name. For example, I said that mine were from a database and one of my column names (which would then become a key in the array of results) was named store_name. I would then be able to access the stores at $rows[intCount]['store_name'].</p>
<pre class="brush: php; title: Code Snippet:; notranslate">
$field_locations = getFieldLocations($result['feed_id']); //Method to query the database and get the XPath values from it.
$feed_array = parseXML($result['feed_url'],$field_locations); //Calls the parser method.
</pre>
<p>The above code just calls the function and store the result into the array. You can now take this array and do what you need to with it. That concludes this tutorial. I hope it was easy to follow, and as always, feel free to comment or ask questions. Thanks for reading. </p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://teamtutorials.com/other-tutorials/force-computer-to-show-blue-screen-details" title="Force Computer To Show Blue Screen Details">Force Computer To Show Blue Screen Details</a></li><li><a href="http://teamtutorials.com/other-tutorials/combine-text-files-into-one-files-in-windows-mac-and-linux" title="Combine Text Files into One File in Windows, Mac, and Linux">Combine Text Files into One File in Windows, Mac, and Linux</a></li><li><a href="http://teamtutorials.com/web-development-tutorials/install-wordpress-using-fantastico-in-cpanel" title="Install Wordpress using Fantastico in cPanel">Install Wordpress using Fantastico in cPanel</a></li><li><a href="http://teamtutorials.com/web-development-tutorials/create-mysql-databse-with-cpanel-and-phpmyadmin" title="Create MySQL Databse with cPanel and phpMyAdmin">Create MySQL Databse with cPanel and phpMyAdmin</a></li><li><a href="http://teamtutorials.com/windows-tutorials/retrieving-xp-cd-key-from-the-registry" title="Retrieving XP CD-Key from the Registry">Retrieving XP CD-Key from the Registry</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://teamtutorials.com/web-development-tutorials/php-tutorials/parsing-xml-feed-to-an-array-with-xpath/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Combine Text Files into One File in Windows, Mac, and Linux</title>
		<link>http://teamtutorials.com/other-tutorials/combine-text-files-into-one-files-in-windows-mac-and-linux?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=combine-text-files-into-one-files-in-windows-mac-and-linux</link>
		<comments>http://teamtutorials.com/other-tutorials/combine-text-files-into-one-files-in-windows-mac-and-linux#comments</comments>
		<pubDate>Sun, 26 Dec 2010 23:47:34 +0000</pubDate>
		<dc:creator>John Ward</dc:creator>
				<category><![CDATA[Other Tutorials]]></category>
		<category><![CDATA[combine]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://teamtutorials.com/?p=2644</guid>
		<description><![CDATA[I ran into a problem where I had a zip file that had a document I wanted to copy split into 100 different .txt files. I needed to combine all of the text files into one large file so I could copy all the data. Windows You can combine text files in Windows using copy&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>I ran into a problem where I had a zip file that had a document I wanted to copy split into 100 different .txt files. I needed to combine all of the text files into one large file so I could copy all the data.</p>
<h2>Windows</h2>
<p>You can combine text files in Windows using copy&#8217;s binary mode. From the command prompt navigate to the folder with the .txt files and run the following command:</p>
<pre class="brush: plain; title: Code Snippet:; notranslate">
copy /b filename* all.txt /b
</pre>
<p>Where filename*  matches the pattern of your file names and all.txt is the output file.</p>
<h2>Mac / Linux / Unix</h2>
<p>You can combine files in the unix shell using cat and appending the output to a file:</p>
<pre class="brush: plain; title: Code Snippet:; notranslate">
cat filename* &gt; all.txt
</pre>
<p>Where filename*  matches the pattern of your file names and all.txt is the output file.</p>
<p>This should help save someone a lot of copy and pasting time.</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://teamtutorials.com/other-tutorials/disable-uacuser-access-control-in-windows-vista" title="Disable UAC(User Access Control) in Windows Vista">Disable UAC(User Access Control) in Windows Vista</a></li><li><a href="http://teamtutorials.com/web-development-tutorials/setting-up-a-wamp-server" title="Setting Up a WAMP Server">Setting Up a WAMP Server</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://teamtutorials.com/other-tutorials/combine-text-files-into-one-files-in-windows-mac-and-linux/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Access a MySQL Database Using PDO</title>
		<link>http://teamtutorials.com/web-development-tutorials/access-a-mysql-database-using-pdo?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=access-a-mysql-database-using-pdo</link>
		<comments>http://teamtutorials.com/web-development-tutorials/access-a-mysql-database-using-pdo#comments</comments>
		<pubDate>Tue, 02 Nov 2010 12:56:48 +0000</pubDate>
		<dc:creator>John Ward</dc:creator>
				<category><![CDATA[Database Tutorials]]></category>
		<category><![CDATA[MySQL Tutorials]]></category>
		<category><![CDATA[PHP Tutorials]]></category>
		<category><![CDATA[Web Development Tutorials]]></category>
		<category><![CDATA[connection]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[pdo]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://teamtutorials.com/?p=2628</guid>
		<description><![CDATA[This tutorial will show you how to access a mysql database using the PHP Data Objects interface, also known simply as PDO. One big advantage of using PDO versus other methods is the use of prepared statements which offers much better security than the mysql or mysqli libraries. Also PDO can connect to several different [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorial will show you how to access a mysql database using the PHP Data Objects interface, also known simply as PDO. One big advantage of using PDO versus other methods is the use of prepared statements which offers much better security than the mysql or mysqli libraries. Also PDO can connect to several different database systems by specifying another driver. It is almost as easy as switching the driver to change from one database system to another (except for DB specific SQL syntax).</p>
<p>This tutorial requires that you already have a mysql database to connect to or know how to create a mysql database and will set one up. If you do not know how to setup a MySQL database then you will want to check out some of our other tutorials.</p>
<p>As I mentioned above PDO supports multiple database systems. If you would like to see which drivers you have available on your server you can print the array of drivers using:</p>
<pre class="brush: php; title: Code Snippet:; notranslate">
print_r(PDO::getAvailableDrivers());
</pre>
<p>To connect to a MySQL database using PDO you simply need to create a new PDO object and provide the database information:</p>
<pre class="brush: php; title: Code Snippet:; notranslate">
//Database Credentials
$host = 'localhost';
$database = 'DatabaseName';
$username = 'dbuser';
$password = 'dbpassword';

try {
  $DBH = new PDO(&quot;mysql:host=$host;dbname=$database&quot;, $username, $password);

}
catch(PDOException $e) {
    echo $e-&gt;getMessage();
}

echo &quot;it works&quot;;
</pre>
<p>In the sample above you need to specify the correct information to connect to your database. The $host variable is the system that the database is hosted on. If the database is on the same server that you are executing PHP on then you can simply use localhost. The $database variable is the name of the specific database on the server. $username and $password are just that, the username and password of the database user.</p>
<p>Save the page with a .php extension and execute it. If the database connection works properly than you should simply see a message that says &#8220;it works&#8221; if not you will see some sort of error that should point you in the right direction to start debugging. Common errors are: wrong user/pass, not allowing a user to connect from other hosts, and syntax errors. If you are having trouble getting this connection to work feel free to ask in the comments.</p>
<p>Now that you have the database connection what do you do with it? I will show you that in future posts. </p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://teamtutorials.com/web-development-tutorials/how-to-return-mysql-results-to-a-table" title="How to Return MySQL Results to a Table">How to Return MySQL Results to a Table</a></li><li><a href="http://teamtutorials.com/web-development-tutorials/editing-mysql-data-using-php" title="Editing MySQL Data Using PHP">Editing MySQL Data Using PHP</a></li><li><a href="http://teamtutorials.com/web-development-tutorials/creating-checkboxes-based-on-sql-results" title="Creating Checkboxes Based on SQL Results">Creating Checkboxes Based on SQL Results</a></li><li><a href="http://teamtutorials.com/web-development-tutorials/php-tutorials/creating-a-form-that-will-search-a-mysql-database" title="Creating a Form that will Search a MySQL Database">Creating a Form that will Search a MySQL Database</a></li><li><a href="http://teamtutorials.com/web-development-tutorials/setting-up-a-wamp-server" title="Setting Up a WAMP Server">Setting Up a WAMP Server</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://teamtutorials.com/web-development-tutorials/access-a-mysql-database-using-pdo/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

