<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Team Tutorials</title>
	<atom:link href="http://teamtutorials.com/feed" rel="self" type="application/rss+xml" />
	<link>http://teamtutorials.com</link>
	<description></description>
	<lastBuildDate>Tue, 27 Dec 2011 18:58:24 +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" />
		<item>
		<title>What&#8217;s new in HTML 5</title>
		<link>http://teamtutorials.com/web-development-tutorials/whats-new-in-html-5?utm_source=rss&#038;utm_medium=rss&#038;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/photoshop-tutorials/web-hosting-layout-tutorial" title="Web Hosting Layout Tutorial">Web Hosting Layout Tutorial</a></li><li><a href="http://teamtutorials.com/software-tutorials/how-to-mount-an-image-to-a-virtual-drive" title="How to Mount an Image to a Virtual Drive">How to Mount an Image to a Virtual Drive</a></li><li><a href="http://teamtutorials.com/photoshop-tutorials/creating-a-pill-icon-in-photoshop" title="Creating a Pill Icon in Photoshop">Creating a Pill Icon in Photoshop</a></li><li><a href="http://teamtutorials.com/web-development-tutorials/access-a-mysql-database-using-pdo" title="Access a MySQL Database Using PDO">Access a MySQL Database Using PDO</a></li><li><a href="http://teamtutorials.com/web-development-tutorials/pulling-drop-down-values-from-a-database-using-javascript-and-php" title="Pulling Drop-down values from a database using Javascript and PHP">Pulling Drop-down values from a database using Javascript and PHP</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://teamtutorials.com/web-development-tutorials/whats-new-in-html-5/feed</wfw:commentRss>
		<slash:comments>1</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&#038;utm_medium=rss&#038;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/windows-tutorials/show-file-extension-in-windows-xp" title="Show File Extension in Windows XP">Show File Extension in Windows XP</a></li><li><a href="http://teamtutorials.com/windows-tutorials/hide-windows-network-shares" title="Hide Windows Network Shares">Hide Windows Network Shares</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/photoshop-tutorials/photoshop-creative-design-menu-tutorial" title="Photoshop Creative Design Menu Tutorial">Photoshop Creative Design Menu Tutorial</a></li><li><a href="http://teamtutorials.com/web-development-tutorials/introduction-to-online-advertising" title="Introduction To Online Advertising">Introduction To Online Advertising</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&#038;utm_medium=rss&#038;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/site-news/news-comment-rewards" title="News &#8211; Comment Rewards">News &#8211; Comment Rewards</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><li><a href="http://teamtutorials.com/site-news/new-features" title="New Features">New Features</a></li><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/xml-sitemap-optimization-with-wordpress" title="XML Sitemap Optimization with Wordpress">XML Sitemap Optimization with Wordpress</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://teamtutorials.com/web-development-tutorials/fix-the-timthumb-php-wordpress-exploit/feed</wfw:commentRss>
		<slash:comments>2</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&#038;utm_medium=rss&#038;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&#038;utm_medium=rss&#038;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/web-development-tutorials/pulling-drop-down-values-from-a-database-using-javascript-and-php" title="Pulling Drop-down values from a database using Javascript and PHP">Pulling Drop-down values from a database using Javascript and PHP</a></li><li><a href="http://teamtutorials.com/web-development-tutorials/wordpress-tutorials/monetize-your-wordpress-blog-with-adsense-injection-plug-in" title="Monetize Your Wordpress Blog with Adsense Injection Plug-in">Monetize Your Wordpress Blog with Adsense Injection Plug-in</a></li><li><a href="http://teamtutorials.com/web-development-tutorials/validating-email-address-with-php-and-ajax" title="Validating Email Address with PHP and AJAX">Validating Email Address with PHP and AJAX</a></li><li><a href="http://teamtutorials.com/photoshop-tutorials/custom-web-search-box" title="Custom Web Search Box">Custom Web Search Box</a></li><li><a href="http://teamtutorials.com/windows-tutorials/show-hidden-files-and-folders-in-windows-xp" title="Show Hidden Files and Folders in Windows XP">Show Hidden Files and Folders in Windows XP</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&#038;utm_medium=rss&#038;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&#038;utm_medium=rss&#038;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>
		<item>
		<title>Function &#8211; Splitting a string</title>
		<link>http://teamtutorials.com/programming-tutorials/function-splitting-a-string?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=function-splitting-a-string</link>
		<comments>http://teamtutorials.com/programming-tutorials/function-splitting-a-string#comments</comments>
		<pubDate>Tue, 19 Oct 2010 03:59:50 +0000</pubDate>
		<dc:creator>Mike Maguire</dc:creator>
				<category><![CDATA[General Functions]]></category>
		<category><![CDATA[Programming Tutorials]]></category>

		<guid isPermaLink="false">http://teamtutorials.com/?p=2620</guid>
		<description><![CDATA[Splitting a String on a Character There are a lot of functions out there that are very simple and easy to understand but are absolutely necessary to make fully functional applications. This week, we are going to begin with a simple string function: split. The split function (explode in PHP) allow the programmer to take [...]]]></description>
			<content:encoded><![CDATA[<p>Splitting a String on a Character</p>
<p>There are a lot of functions out there that are very simple and easy to understand but are absolutely necessary to make fully functional applications. This week, we are going to begin with a simple string function: split. The split function (explode in PHP) allow the programmer to take a string and split that string into an array of strings on a character. For example, you could split a sentence into words by splitting on a space. As I said, this is a very simple function to use and understand.</p>
<p><strong>Visual Basic</strong></p>
<pre class="brush: vb; title: Code Snippet:; notranslate">
'Build the string we want to split
Dim stringToSplit As String = &quot;this,is,a,string,that,needs,split&quot;

'Array of strings to store the split values in
Dim stringArray As String()

'Split the sting based on a character value
stringArray = stringToSplit.Split(&quot;,&quot;C)

'Iterate through the results from the split
For Each splitString As String In stringArray
	'add each string to a listbox
	lstStrings.Items.Add(splitString)
Next
</pre>
<p>We take a string and split it on a comma and add it to a list box control named lstStrings.</p>
<p><strong>C#</strong></p>
<pre class="brush: csharp; title: Code Snippet:; notranslate">
            //Build the string we want to split
            string stringToSplit = &quot;this,is,a,string,that,needs,split&quot;;

            //Array of strings to store the split values in
            string[] stringArray;

            //Split the sting based on a character value
            stringArray = stringToSplit.Split(',');

            //Iterate through the results from the split
            foreach (string splitString in stringArray)
            {
                //add each string to a listbox
                lstStrings.Items.Add(splitString);
            }
</pre>
<p>We take a string and split it on a comma and add it to a list box control named lstStrings.</p>
<p><strong>PHP</strong></p>
<pre class="brush: php; title: Code Snippet:; notranslate">
//Create a string to split
$stringToSplit = &quot;this,is,a,string,that,needs,split&quot;;

//Just showing this value is an array (not neccessary with PHP)
$stringArray = array();

//Split the string on a character (explode in PHP is a split function)
$stringArray = explode($stringToSplit,',');

//Start table HTML
$html = &quot;&lt;table&gt;&quot;;
//Iterate through the array
foreach($stringArray as $stringSingle)
{
    //Build the rows for the table
   $html .= &quot;&lt;tr&gt;&quot;.$stringSingle.&quot;&lt;/tr&gt;&quot;;
}

//End table HTML
$html .= &quot;&lt;/table&gt;&quot;;

//Output the table
echo $html;
</pre>
<p>We take a string and split it into an array. Then we iterate through the array and put the values into a table.</p>
<p><strong>Java</strong></p>
<pre class="brush: java; title: Code Snippet:; notranslate">
        //Create a string to split
        String stringToSplit = &quot;this,is,a,string,that,needs,split&quot;;

        //Create array for string to be split into and run split on it
        final String stringArray[] = stringToSplit.split(&quot;,&quot;);

        //Iterate through the array
        for(int r=0;r&lt;stringArray.length; r++)
        {
            stringList.setModel(new javax.swing.AbstractListModel() {
                String[] strings = stringArray;
                public int getSize() { return strings.length; }
                public Object getElementAt(int i) { return strings[i]; }
            });
        }
</pre>
<p>Split the string and then add the values to a jList control. </p>
<p>As you can see, each language has it’s unique way of using this function but I think we can all agree that this is simple to understand and can be very helpful in our applications. Nice thing about this function is that if the string doesn’t contain the character you want to split on, it will still work as you will just get one string since there is nothing to split. It won’t throw an error. </p>
<p>That concludes this week’s tutorial. Hopefully it was easy to follow and understand and we’ll see you next week. Thanks for viewing.  </p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://teamtutorials.com/database-tutorials/configuring-and-creating-a-database-in-ms-sql-2008" title="Configuring and Creating a Database in MS SQL 2008">Configuring and Creating a Database in MS SQL 2008</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/show-hidden-files-and-folders-in-windows-xp" title="Show Hidden Files and Folders in Windows XP">Show Hidden Files and Folders in Windows XP</a></li><li><a href="http://teamtutorials.com/programming-tutorials/simple-vb-code-command-buttons" title="Simple VB Code with Command Buttons">Simple VB Code with Command Buttons</a></li><li><a href="http://teamtutorials.com/other-tutorials/get-free-answers-from-experts-exchange" title="Get Free Answers from Experts-Exchange">Get Free Answers from Experts-Exchange</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://teamtutorials.com/programming-tutorials/function-splitting-a-string/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Forums and Posts</title>
		<link>http://teamtutorials.com/site-news/forums-and-posts?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=forums-and-posts</link>
		<comments>http://teamtutorials.com/site-news/forums-and-posts#comments</comments>
		<pubDate>Mon, 18 Oct 2010 19:24:56 +0000</pubDate>
		<dc:creator>Mike Maguire</dc:creator>
				<category><![CDATA[Site News and Updates]]></category>

		<guid isPermaLink="false">http://teamtutorials.com/?p=2616</guid>
		<description><![CDATA[There have been a lot of changes going on recently and the site has been getting pushed to the side. We are going to start trying to get some new content posted regularly again. The forums that we added back a while ago are now functional again (never noticed they weren&#8217;t working). Feel free to [...]]]></description>
			<content:encoded><![CDATA[<p>     There have been a lot of changes going on recently and the site has been getting pushed to the side. We are going to start trying to get some new content posted regularly again. The forums that we added back a while ago are now functional again (never noticed they weren&#8217;t working). Feel free to post anything on there and we will do our best to help you out.</p>
<p>     We have also seen some requests to go over some basic programming functions that are available in several different languages so starting this week we will be posting general function tutorials that will explain what a function does and what it can most commonly be used for as well as an example in PHP, .NET (C# and VB), and Java. Hopefully these will come in handy to those of you looking to get started in programming. As always, let us know if there is anything you can think of that you would like to see and we will do our best to give it to you.</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://teamtutorials.com/windows-tutorials/configure-windows-xp-automatic-updates" title="Configure Windows XP Automatic Updates">Configure Windows XP Automatic Updates</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/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/photoshop-tutorials/easy-abstract-photoshop-tutorial" title="Easy Abstract Photoshop Tutorial">Easy Abstract Photoshop Tutorial</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></ul>]]></content:encoded>
			<wfw:commentRss>http://teamtutorials.com/site-news/forums-and-posts/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Simple XML to XHTML Transformation</title>
		<link>http://teamtutorials.com/web-development-tutorials/simple-xml-to-xhtml-transformation?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=simple-xml-to-xhtml-transformation</link>
		<comments>http://teamtutorials.com/web-development-tutorials/simple-xml-to-xhtml-transformation#comments</comments>
		<pubDate>Mon, 03 May 2010 21:38:37 +0000</pubDate>
		<dc:creator>John Ward</dc:creator>
				<category><![CDATA[HTML Tutorials]]></category>
		<category><![CDATA[Web Development Tutorials]]></category>
		<category><![CDATA[xhtml]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[XSLT]]></category>

		<guid isPermaLink="false">http://teamtutorials.com/?p=2581</guid>
		<description><![CDATA[In this tutorial we are going to use XSLT to transform a simple XML document into an XHTML web page.  XSLT stands for eXtensible Style Sheet Transformations. With our XSL document we will pretty much grab the values we need from the source XML and display them nicely in XHTML.]]></description>
			<content:encoded><![CDATA[<p>In this tutorial we are going to use XSLT to transform a simple XML document into an XHTML web page.  XSLT stands for eXtensible Style Sheet Transformations. With our XSL document we will pretty much grab the values we need from the source XML and display them nicely in XHTML. In order to complete this tutorial you should have a basic understanding of XML documents, HTML/XHTML, and CSS.</p>
<p>First off you need some sample XML. I made a quick list of cars I have owned.</p>
<pre class="brush: xml; title: Code Snippet:; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;autos&gt;
	&lt;car&gt;
		&lt;year&gt;1995&lt;/year&gt;
		&lt;make&gt;Eagle&lt;/make&gt;
		&lt;model&gt;Talon&lt;/model&gt;
		&lt;trim&gt;ESi&lt;/trim&gt;
	&lt;/car&gt;
	&lt;car&gt;
		&lt;year&gt;1998&lt;/year&gt;
		&lt;make&gt;Mitsubishi&lt;/make&gt;
		&lt;model&gt;Eclipse&lt;/model&gt;
		&lt;trim&gt;GS-T Spyder&lt;/trim&gt;
	&lt;/car&gt;
	&lt;car&gt;
		&lt;year&gt;2004&lt;/year&gt;
		&lt;make&gt;Cadillac&lt;/make&gt;
		&lt;model&gt;CTS&lt;/model&gt;
		&lt;trim&gt;Sport&lt;/trim&gt;
	&lt;/car&gt;
&lt;/autos&gt;
</pre>
<p>We are going to add an XML stylesheet to the document, similar to a CSS file with HTML. In order to add the file we need to add the xml-stylesheet tag to our root document.</p>
<pre class="brush: xml; title: Code Snippet:; notranslate">
&lt;?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;output.xsl&quot;?&gt;
</pre>
<p>Which should give you this.</p>
<pre class="brush: xml; title: Code Snippet:; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;output.xsl&quot;?&gt;
&lt;autos&gt;
	&lt;car&gt;
		&lt;year&gt;1995&lt;/year&gt;
		&lt;make&gt;Eagle&lt;/make&gt;
		&lt;model&gt;Talon&lt;/model&gt;
		&lt;trim&gt;ESi&lt;/trim&gt;
	&lt;/car&gt;
	&lt;car&gt;
		&lt;year&gt;1998&lt;/year&gt;
		&lt;make&gt;Mitsubishi&lt;/make&gt;
		&lt;model&gt;Eclipse&lt;/model&gt;
		&lt;trim&gt;GS-T Spyder&lt;/trim&gt;
	&lt;/car&gt;
	&lt;car&gt;
		&lt;year&gt;2004&lt;/year&gt;
		&lt;make&gt;Cadillac&lt;/make&gt;
		&lt;model&gt;CTS&lt;/model&gt;
		&lt;trim&gt;Sport&lt;/trim&gt;
	&lt;/car&gt;
&lt;/autos&gt;
</pre>
<p>Next you will need to create a new document that I called output.xsl. This file will be used to tell the browser how to display our XML. Here is a pretty standard starting template.</p>
<pre class="brush: xml; title: Code Snippet:; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;&gt;
    &lt;xsl:output method=&quot;html&quot; encoding=&quot;utf-8&quot; doctype-public=&quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; doctype-system=&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;/&gt;

    &lt;xsl:template match=&quot;/&quot;&gt;
        &lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
        &lt;head&gt;
            &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;/&gt;
            &lt;title&gt;My Cars&lt;/title&gt;
        &lt;/head&gt;

        &lt;body&gt;
        &lt;/body&gt;
        &lt;/html&gt;
    &lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;
</pre>
<p>Now we need to create a typical HTML table to display our results in.</p>
<pre class="brush: xml; title: Code Snippet:; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;&gt;
    &lt;xsl:output method=&quot;html&quot; encoding=&quot;utf-8&quot; doctype-public=&quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; doctype-system=&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;/&gt;

    &lt;xsl:template match=&quot;/&quot;&gt;
        &lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
        &lt;head&gt;
            &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;/&gt;
            &lt;title&gt;My Cars&lt;/title&gt;
        &lt;/head&gt;

        &lt;body&gt;
	        &lt;table&gt;
            	&lt;tr&gt;
			&lt;th&gt;Year&lt;/th&gt;
                    &lt;th&gt;Make&lt;/th&gt;
                    &lt;th&gt;Model&lt;/th&gt;
                    &lt;th&gt;Trim&lt;/th&gt;
                &lt;/tr&gt;
            &lt;/table&gt;
        &lt;/body&gt;
        &lt;/html&gt;
    &lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;
</pre>
<p>Now we are going to determine which fields we want to display in the rest of the table rows. We will do this by using the xsl:for-each tag. This will pretty much create a for each loop and loop through which ever values you specify. We want whatever data is container withing the car tag within the autos tag. So you would do something like this:</p>
<pre class="brush: xml; title: Code Snippet:; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;&gt;
    &lt;xsl:output method=&quot;html&quot; encoding=&quot;utf-8&quot; doctype-public=&quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; doctype-system=&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;/&gt;

    &lt;xsl:template match=&quot;/&quot;&gt;
        &lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
        &lt;head&gt;
            &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;/&gt;
            &lt;title&gt;My Cars&lt;/title&gt;
        &lt;/head&gt;

        &lt;body&gt;
	        &lt;table&gt;
            	&lt;tr&gt;
					&lt;th&gt;Year&lt;/th&gt;
                    &lt;th&gt;Make&lt;/th&gt;
                    &lt;th&gt;Model&lt;/th&gt;
                    &lt;th&gt;Trim&lt;/th&gt;
                &lt;/tr&gt;
                &lt;xsl:for-each select=&quot;autos/car&quot;&gt;

                &lt;/xsl:for-each&gt;
            &lt;/table&gt;
        &lt;/body&gt;
        &lt;/html&gt;
    &lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;
</pre>
<p>Then we simple tell XSLT how to display the values (in tables and cells in this case) and what values we want.</p>
<pre class="brush: xml; title: Code Snippet:; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;&gt;
    &lt;xsl:output method=&quot;html&quot; encoding=&quot;utf-8&quot; doctype-public=&quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; doctype-system=&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;/&gt;

    &lt;xsl:template match=&quot;/&quot;&gt;
        &lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
        &lt;head&gt;
            &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;/&gt;
            &lt;title&gt;My Cars&lt;/title&gt;
        &lt;/head&gt;

        &lt;body&gt;
	        &lt;table&gt;
            	&lt;tr&gt;
					&lt;th&gt;Year&lt;/th&gt;
                    &lt;th&gt;Make&lt;/th&gt;
                    &lt;th&gt;Model&lt;/th&gt;
                    &lt;th&gt;Trim&lt;/th&gt;
                &lt;/tr&gt;
                &lt;xsl:for-each select=&quot;autos/car&quot;&gt;
                &lt;tr&gt;
                    &lt;td&gt;&lt;xsl:value-of select=&quot;year&quot;/&gt;&lt;/td&gt;
                    &lt;td&gt;&lt;xsl:value-of select=&quot;make&quot;/&gt;&lt;/td&gt;
                    &lt;td&gt;&lt;xsl:value-of select=&quot;model&quot;/&gt;&lt;/td&gt;
                    &lt;td&gt;&lt;xsl:value-of select=&quot;trim&quot;/&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;/xsl:for-each&gt;
            &lt;/table&gt;
        &lt;/body&gt;
        &lt;/html&gt;
    &lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;
</pre>
<p>Then to finish it off you can style your table with some CSS.</p>
<pre class="brush: xml; title: Code Snippet:; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;&gt;
    &lt;xsl:output method=&quot;html&quot; encoding=&quot;utf-8&quot; doctype-public=&quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; doctype-system=&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;/&gt;

    &lt;xsl:template match=&quot;/&quot;&gt;
        &lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
        &lt;head&gt;
            &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;/&gt;
            &lt;title&gt;My Cars&lt;/title&gt;

            &lt;style&gt;
				td{
					border-bottom:1px dashed #ccc;
					padding-left:4px;
				}
				th{
					background: #bacfec;
					text-align:center;
					padding: 0 15px 0 15px;
				}
			&lt;/style&gt;
        &lt;/head&gt;

        &lt;body&gt;
	        &lt;table&gt;
            	&lt;tr&gt;
					&lt;th&gt;Year&lt;/th&gt;
                    &lt;th&gt;Make&lt;/th&gt;
                    &lt;th&gt;Model&lt;/th&gt;
                    &lt;th&gt;Trim&lt;/th&gt;
                &lt;/tr&gt;
                &lt;xsl:for-each select=&quot;autos/car&quot;&gt;
                &lt;tr&gt;
                    &lt;td&gt;&lt;xsl:value-of select=&quot;year&quot;/&gt;&lt;/td&gt;
                    &lt;td&gt;&lt;xsl:value-of select=&quot;make&quot;/&gt;&lt;/td&gt;
                    &lt;td&gt;&lt;xsl:value-of select=&quot;model&quot;/&gt;&lt;/td&gt;
                    &lt;td&gt;&lt;xsl:value-of select=&quot;trim&quot;/&gt;&lt;/td&gt;
                &lt;/tr&gt;
                &lt;/xsl:for-each&gt;
            &lt;/table&gt;
        &lt;/body&gt;
        &lt;/html&gt;
    &lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;
</pre>
<p>Its that simple. We started a simple XSL file and output an XHTML page using XSL.</p>
<h3>Download the Source Code</h3>
<p>[tweet2download file="source.zip" tweet="Simple XML to XHTML Transformation http://su.pr/1ci3ZU @teamtutorials" follow="@teamtutorials" /]</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://teamtutorials.com/web-development-tutorials/hide-and-show-a-div-using-javascript" title="Hide and Show a Div Using Javascript">Hide and Show a Div Using Javascript</a></li><li><a href="http://teamtutorials.com/other-tutorials/receiving-dynamic-textbox-data" title="Receiving Dynamic Textbox Data">Receiving Dynamic Textbox Data</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/web-development-tutorials/styling-html-tables-with-tablecloth" title="Styling HTML Tables with TableCloth">Styling HTML Tables with TableCloth</a></li><li><a href="http://teamtutorials.com/web-development-tutorials/installing-code-editor" title="Installing Code Editor">Installing Code Editor</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://teamtutorials.com/web-development-tutorials/simple-xml-to-xhtml-transformation/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

