<?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>Develop Websites</title>
	<atom:link href="http://www.developwebsites.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.developwebsites.net</link>
	<description>Learn HTML, JavaScript, CSS, PHP, MySQL, SEO</description>
	<lastBuildDate>Sat, 07 Aug 2010 13:58:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Test Layouts By Resizing Your Browser Window with JavaScript</title>
		<link>http://www.developwebsites.net/test-layouts-resizing-browser-javascript/</link>
		<comments>http://www.developwebsites.net/test-layouts-resizing-browser-javascript/#comments</comments>
		<pubDate>Sat, 07 Aug 2010 13:55:35 +0000</pubDate>
		<dc:creator>Barnaby Knowles</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.developwebsites.net/?p=172</guid>
		<description><![CDATA[A simple line of JavaScript can resize your web browser and let you test your website design by simulating a different screen resolution.]]></description>
			<content:encoded><![CDATA[<h2>Test Website Layouts</h2>
<p>Website visitors browse with many different screen resolutions, largely determined by the size of their monitor. You should test your website&#8217;s layout to make sure that it doesn&#8217;t break of look wrong when viewed using the most common screen resolutions.</p>
<p>So how do you test that? Change your own screen resolution a handful of times to see what happens? There is an easier way, thanks to a little piece of JavaScript!</p>
<p><span id="more-172"></span></p>
<h2>Change Your Screen Resolution</h2>
<p>You could reset your own screen resolutions and check your website design that way. But that would be a lot of hassle. On the other hand you could resize your web browser to replicate the effect of a different screen resolution. But how do you know when you&#8217;ve resized your browser to the desired height and width?</p>
<h2>JavaScript Can Resize Your Web Browser</h2>
<p>Using JavaScript it&#8217;s possible to resize your web browser to the precise size that you want to test. Enter the code below into your address bar and your web browser will be resized accordingly!</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">javascript<span style="color: #339933;">:</span>resizeTo<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">800</span><span style="color: #339933;">,</span><span style="color: #CC0000;">600</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>Change the numeric values to alter the width and height, respectively.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.developwebsites.net/test-layouts-resizing-browser-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Repair a Crashed MySQL Table</title>
		<link>http://www.developwebsites.net/repair-crashed-mysql-table/</link>
		<comments>http://www.developwebsites.net/repair-crashed-mysql-table/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 13:21:27 +0000</pubDate>
		<dc:creator>Barnaby Knowles</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.developwebsites.net/?p=147</guid>
		<description><![CDATA[MySQL tables can crash. Learn how to repair them!]]></description>
			<content:encoded><![CDATA[<h2>MySQL Tables Can Crash!</h2>
<p>I didn&#8217;t know until it happened to me recently, but MySQL tables can crash. When one of my tables crashed the first I knew about it was when I tried to browse it using phpMyAdmin and received an error message.</p>
<p><span id="more-147"></span></p>
<h2>Repair a MySQL Table</h2>
<p>My first through was to use the &#8220;Repaid table&#8221; link that is available under phpMyAdmin&#8217;s &#8220;Table maintenence&#8221; section. Unfortunately once the table has crashes it&#8217;s not possible to access that link!</p>
<p>After a bit of searching I located the underlying SQL query that you can run to repair a crashed MySQL table:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">REPAIR <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`table_name`</span>;</pre></div></div>

<p>That line of SQL got my MySQL table back up and running again straight away.</p>
<h2>Useful Links</h2>
<ul>
<li><a href="http://articles.techrepublic.com.com/5100-10878_11-5193721.html" rel="external">Checking and repairing MySQL tables</a> (TechRepublic)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.developwebsites.net/repair-crashed-mysql-table/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Online Regex Tester</title>
		<link>http://www.developwebsites.net/online-regex-tester/</link>
		<comments>http://www.developwebsites.net/online-regex-tester/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 13:02:05 +0000</pubDate>
		<dc:creator>Barnaby Knowles</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[regular expression]]></category>

		<guid isPermaLink="false">http://www.developwebsites.net/?p=126</guid>
		<description><![CDATA[This Flash-based tool allows you to test regex (regular expressions) online.]]></description>
			<content:encoded><![CDATA[<p>Ever wanted to test a regex (regular expression) quickly and easily? Now you can!</p>
<p><span id="more-126"></span></p>
<h2>Testing Regular Expressions</h2>
<p>If you&#8217;ve ever wanted to quickly test a regular expression (regex) your options are limited.</p>
<ul>
<li>You can create a PHP script and use preg_match()</li>
<li>You can set up an offline web page and use JavaScript</li>
<li>You can download regex testing software</li>
</ul>
<h2>Test Your Regex Online!</h2>
<p>I recently found a Flash-based website that allow you to test regular expressions using a variety of options and it has proved to be invaluable when I need to quickly check whether a regex will work!</p>
<p>Enjoy!</p>
<p><a href="http://gskinner.com/RegExr/" rel="external">http://gskinner.com/RegExr/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.developwebsites.net/online-regex-tester/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convert DOCX to DOC Online for Free</title>
		<link>http://www.developwebsites.net/convert-docx-doc-online-free/</link>
		<comments>http://www.developwebsites.net/convert-docx-doc-online-free/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 07:55:13 +0000</pubDate>
		<dc:creator>Barnaby Knowles</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[doc]]></category>
		<category><![CDATA[docx]]></category>
		<category><![CDATA[Word]]></category>

		<guid isPermaLink="false">http://www.developwebsites.net/?p=151</guid>
		<description><![CDATA[Convert DOCX to DOC files online for free.]]></description>
			<content:encoded><![CDATA[<h2>Microsoft Word .docx Problem</h2>
<p>As of Word 2007, Microsoft Office introduced a new file format (and extension) for Word, Excel, and PowerPoint documents. Prior to this, Word documents had the .doc extension, but new documents end in .docx. This can be a problem if you have a version of Microsoft Word prior to 2007, as there is no support for the new .docx format, and if someone send you a file in this format, you can&#8217;t open it!</p>
<p><span id="more-151"></span></p>
<h2>Microsoft&#8217;s Workaround</h2>
<p>Microsoft has released its &#8220;Microsoft Office Compatibility Pack for Word, Excel, and PowerPoint File Formats&#8221;, which allows you to &#8220;open, edit, and save documents, workbooks, and presentations in the Open XML file formats which were introduced to Microsoft Office Word, Excel, and PowerPoint beginning with Office 2007.&#8221;</p>
<p>The compatibility pack can be downloaded <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=941B3470-3AE9-4AEE-8F43-C6BB74CD1466&#038;displaylang=en" rel="external nofollow">here</a>.</p>
<h2>Problems</h2>
<p>What happens if you can&#8217;t install the compatibility pack? Maybe you are using a PC on which you don&#8217;t have rights to install new software. Maybe you don&#8217;t want to add more bloat just to open 1 document that a friend sent you. I could go on.</p>
<h2>Convert DOCX to DOC Online</h2>
<p>If you do a quick search you&#8217;ll find that there are tools online that allow you to upload a .docx file and convert it to a .doc format that you can open.</p>
<p>However, these tools aren&#8217;t without their drawbacks. Some are not free, and most require you to give them a valid email address.</p>
<h2>The Solution</h2>
<p>After a bit of searching I found one website that will convert DOCX to DOC files for free without requiring you to give out your email address:</p>
<p><a href="http://doc.investintech.com" rel="external">http://doc.investintech.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.developwebsites.net/convert-docx-doc-online-free/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Line (Line Break) in Excel</title>
		<link>http://www.developwebsites.net/new-line-excel/</link>
		<comments>http://www.developwebsites.net/new-line-excel/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 13:04:33 +0000</pubDate>
		<dc:creator>Barnaby Knowles</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Excel]]></category>

		<guid isPermaLink="false">http://www.developwebsites.net/?p=149</guid>
		<description><![CDATA[Use Alt + Enter to insert a new line in Excel.]]></description>
			<content:encoded><![CDATA[<p>Ever had trouble dropping onto a new line in Excel? I had tried all sorts of ways to insert a new line into an Excel spreadsheet without success.</p>
<p><span id="more-149"></span></p>
<h2>How to Insert a New Line in Excel</h2>
<p>Finally, I hit upon the solution:</p>
<p>Alt + Enter</p>
<p>It&#8217;s as simple as that! Use Alt + Enter to insert a new line of text.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.developwebsites.net/new-line-excel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sending Email with PHP mail() on a Windows Server</title>
		<link>http://www.developwebsites.net/php-mail-windows/</link>
		<comments>http://www.developwebsites.net/php-mail-windows/#comments</comments>
		<pubDate>Fri, 26 Mar 2010 23:05:08 +0000</pubDate>
		<dc:creator>Barnaby Knowles</dc:creator>
				<category><![CDATA[Microsoft IIS Server, ASP, ASP.NET]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.developwebsites.net/?p=135</guid>
		<description><![CDATA[Sending email using PHP on a Windows IIS server is not as simple as it is when using a Linux server.]]></description>
			<content:encoded><![CDATA[<h2>The Problem</h2>
<p>Sending email using PHP on a Windows IIS server is not as simple as it is when using a Linux server. On a typical setup the <em>mail()</em> function probably won&#8217;t work without some tweaking.</p>
<p><span id="more-135"></span></p>
<h2>Why?</h2>
<p>When sending email using PHP&#8217;s <em>mail()</em> function on a Linux server, PHP uses <em>sendmail</em> to process the email, but the same is not possible on Windows IIS servers. On Windows servers you may be required to specify an SMTP server to connect to, the port and the sending email address.</p>
<h2>The Solution</h2>
<p>The settings outlined above may already be specified on your <em>php.ini</em> configuration file, but on a shared server that will probably not be the case. Instead you can specify them within your script using PHP&#8217;s <em>ini_set()</em> function.</p>
<p>The code below shows how the SMTP server, port and sender email address can be set:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">ini_set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'SMTP'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'mail.example.com'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">ini_set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'smtp_port'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'25'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">ini_set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'sendmail_from'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'example@example.com'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.developwebsites.net/php-mail-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple WordPress Speed Optimisation</title>
		<link>http://www.developwebsites.net/simple-wordpress-speed-optimisation/</link>
		<comments>http://www.developwebsites.net/simple-wordpress-speed-optimisation/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 23:09:55 +0000</pubDate>
		<dc:creator>Barnaby Knowles</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.developwebsites.net/?p=113</guid>
		<description><![CDATA[One common complaint is that WordPress is slow, and gets slower as more posts are added. One simple change to your .htaccess file can optimise WordPress and speed your blog up dramatically.]]></description>
			<content:encoded><![CDATA[<p>WordPress is a great piece of blogging software. With very little experience you can have your own blog set up within minutes. However, WordPress does have its faults. One common complaint is that WordPress is slow, and gets slower as more posts are added. Fear not, because help is at hand! One simple change to your .htaccess file can optimise WordPress and speed your blog up dramatically.</p>
<p><span id="more-113"></span></p>
<h2>Background</h2>
<p>The default WordPress .htaccess file looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;">&lt;<span style="color: #000000; font-weight:bold;">IfModule</span> mod_rewrite.c&gt;
<span style="color: #00007f;">RewriteEngine</span> <span style="color: #0000ff;">On</span>
<span style="color: #00007f;">RewriteBase</span> /
<span style="color: #00007f;">RewriteCond</span> %{REQUEST_FILENAME} !-f
<span style="color: #00007f;">RewriteCond</span> %{REQUEST_FILENAME} !-d
<span style="color: #00007f;">RewriteRule</span> . /index.php [L]
&lt;/<span style="color: #000000; font-weight:bold;">IfModule</span>&gt;</pre></div></div>

<p>The URL rewriting code is needed for permalinks, but it is inefficient. With a little optimisation we can speed WordPress up a great deal.</p>
<p>The default WordPress .htaccess file will intercept every single request made by a visitor&#8217;s web browser, whether it be for a page, an image file, a JavaScript file or anything else, and make Apache check whether the requested resource exists as a file or a directory. If it does then it is served straight to the visitor, if it does not exist then WordPress takes over and searches for a post that matches the requested resource.</p>
<h2>The Problem</h2>
<p>The default WordPress .htaccess setup is not efficient because it forces Apache to check whether every single requested resource is a real file or directory that exists on the server. If you&#8217;ve ever looked at the source code of a WordPress template you&#8217;ll see that they include multiple CSS files, JavaScript files and images.</p>
<p>When a visitor loads your blog their web browser requests all of these files and Apache has to check whether each one of them exists before either serving them or letting WordPress take over. This is very inefficient and can be a major cause of WordPress blogs running slowly.</p>
<h2>The Solution</h2>
<p>In a nutshell you need to modify your .htaccess file so that the existence of certain file types such as CSS, JavaScript and images will not be checked by Apache. We know that these resources will be real files and so there is no need to check for their existence because WordPress is never going to handle those requests.</p>
<p>Replace the WordPress portion of your .htaccess file with the following:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #adadad; font-style: italic;"># BEGIN WordPress</span>
<span style="color: #adadad; font-style: italic;">#</span>
<span style="color: #00007f;">RewriteEngine</span> <span style="color: #0000ff;">on</span>
<span style="color: #adadad; font-style: italic;">#</span>
<span style="color: #adadad; font-style: italic;"># Unless you have set a different RewriteBase preceding this point,</span>
<span style="color: #adadad; font-style: italic;"># you may delete or comment-out the following RewriteBase directive</span>
<span style="color: #adadad; font-style: italic;"># RewriteBase /</span>
<span style="color: #adadad; font-style: italic;">#</span>
<span style="color: #adadad; font-style: italic;"># If this request is for &quot;/&quot; or has already been rewritten to WordPress</span>
<span style="color: #00007f;">RewriteCond</span> $<span style="color: #ff0000;">1</span> ^(index\.php)?$ [OR]
<span style="color: #adadad; font-style: italic;"># Or if request is for image, css, or js file</span>
<span style="color: #00007f;">RewriteCond</span> $<span style="color: #ff0000;">1</span> \.(gif|jpg|ico|css|js)$ [NC,OR]
<span style="color: #adadad; font-style: italic;"># Or if URL resolves to existing file</span>
<span style="color: #00007f;">RewriteCond</span> %{REQUEST_FILENAME} -f [OR]
<span style="color: #adadad; font-style: italic;"># Or if URL resolves to existing directory</span>
<span style="color: #00007f;">RewriteCond</span> %{REQUEST_FILENAME} -d
<span style="color: #adadad; font-style: italic;"># Then skip the rewrite to WordPress</span>
<span style="color: #00007f;">RewriteRule</span> ^(.*)$ - [S=<span style="color: #ff0000;">1</span>]
<span style="color: #adadad; font-style: italic;"># Else rewrite the request to WordPress</span>
<span style="color: #00007f;">RewriteRule</span> . /index.php [L]
<span style="color: #adadad; font-style: italic;">#</span>
<span style="color: #adadad; font-style: italic;"># END WordPress</span></pre></div></div>

<p>As the comments explain, this simply tells Apache that it doesn&#8217;t have to check for the existence of the file types listed.</p>
<h2>An Admission</h2>
<p>I must admit that I can&#8217;t take credit for this optimisation. I stumbled across it in a topic posted on <a href="http://www.webmasterworld.com/apache/4053973.htm" rel="external">WebmasterWorld</a> by one of the administrators, <em>jdMorgan</em>. In that topic a twofold .htaccess speed increase was mentioned, so it&#8217;s unclear how that would translate to a WordPress blog overall. Overall speed increases would depend a lot on the plugins installed, as a slow or badly optimised plugin could slow a blog right down.</p>
<h2>This Optimisation in Action</h2>
<p>I was working with a WordPress blog that was taking up to 6 seconds to load when checked with a website load time checker. The blog in question had a custom theme and a number of plugins, which meant lots of CSS and JavaScript files in the head, as well as a generous number of images. After making the optimisation detailed above the blog load time dropped consistently to around 0.9 seconds!</p>
<h2>Conclusion</h2>
<p>I won&#8217;t claim that this WordPress optimisation will speed up your blog&#8217;s load time by 80% like it did for me, but with gains like that to be made I feel it&#8217;s certainly worth bringing to your attention!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.developwebsites.net/simple-wordpress-speed-optimisation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Redirect Single Pages with Classic ASP</title>
		<link>http://www.developwebsites.net/redirect-pages-classic-asp/</link>
		<comments>http://www.developwebsites.net/redirect-pages-classic-asp/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 22:01:03 +0000</pubDate>
		<dc:creator>Barnaby Knowles</dc:creator>
				<category><![CDATA[Microsoft IIS Server, ASP, ASP.NET]]></category>
		<category><![CDATA[Classic ASP]]></category>

		<guid isPermaLink="false">http://www.developwebsites.net/?p=77</guid>
		<description><![CDATA[Single page redirects in Classic ASP can be useful if your content has moved or if you want to make sure that visitors are viewing your canonical URL. If you can't access IIS to set up the redirects and the global.asa won't work, placing this code in your Classic ASP file will accomplish the redirect that you need.]]></description>
			<content:encoded><![CDATA[<h2>The Goal</h2>
<p>If you have some ASP pages that you want redirecting to new URLs with the correct &#8220;301 Moved Permanently&#8221; status, this simple solution is easy to implement.</p>
<p><span id="more-77"></span></p>
<h2>global.asa</h2>
<p>URL redirects can be implemented using the global.asa file, but unfortunately that only works if the pages that you want to redirect actually exist on the server, so you can&#8217;t delete the old files and use <em>global.asa</em> to redirect requests.</p>
<h2>The Solution</h2>
<p>Place the following code at the top of your Classic ASP file and simply change the locations:</p>

<div class="wp_syntax"><div class="code"><pre class="asp" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;%</span><span style="color: #006600; font-weight: bold;">@</span>LANGUAGE<span style="color: #006600; font-weight: bold;">=</span><span style="color: #cc0000;">&quot;VBSCRIPT&quot;</span><span style="color: #000000; font-weight: bold;">%&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;%</span>
<span style="color: #008000;">' Redirect to the new location with the correct 301 Moved Permanently status</span>
<span style="color: #990099; font-weight: bold;">Response</span>.<span style="color: #330066;">Status</span> <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #cc0000;">&quot;301 Moved Permanently&quot;</span>
<span style="color: #990099; font-weight: bold;">Response</span>.<span style="color: #330066;">AddHeader</span> <span style="color: #cc0000;">&quot;Location&quot;</span>, <span style="color: #cc0000;">&quot;http://www.example.com/new-page.php&quot;</span>
<span style="color: #000000; font-weight: bold;">%&gt;</span></pre></div></div>

<p>I would expect that if you&#8217;re redirecting one page to an entirely new page there won&#8217;t be any actual page content in your first script, so there&#8217;s no need to use <em>Response.End()</em> to kill it after the headers are sent.</p>
<h2>Canonical Redirects</h2>
<p>Duplicate content can harm your website&#8217;s search engine ranking. If your pages can by found at both http://example.com/page.asp and http://www.example.com/page.asp this can be detrimental to your website.</p>
<p>By modifying the above Classic ASP code we can redirect visitors landing at http://example.com/page.asp to the correct content at http://www.example.com/page.asp</p>
<p>What we need to do is check the <em>SERVER_NAME</em> variable and if the &#8220;www.&#8221; part of your URL is not present then redirect the visitor to the same page but on the correct &#8220;www.&#8221; URL.</p>

<div class="wp_syntax"><div class="code"><pre class="asp" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;%</span><span style="color: #006600; font-weight: bold;">@</span>LANGUAGE<span style="color: #006600; font-weight: bold;">=</span><span style="color: #cc0000;">&quot;VBSCRIPT&quot;</span><span style="color: #000000; font-weight: bold;">%&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;%</span>
<span style="color: #008000;">' If the domain is not www.example.com send the visitor to the correct domain with a</span>
<span style="color: #008000;">' 301 Moved Permanently status and append the correct page to the URL. Finally kill the</span>
<span style="color: #008000;">' script so that processing stops here</span>
<span style="color: #990099; font-weight: bold;">If</span> <span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #330066;">InStr</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #990099; font-weight: bold;">Request</span>.<span style="color: #330066;">ServerVariables</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;SERVER_NAME&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span>,<span style="color: #cc0000;">&quot;www.example.com&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span> <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #800000;">0</span><span style="color: #006600; font-weight:bold;">&#41;</span> <span style="color: #990099; font-weight: bold;">then</span>
   <span style="color: #990099; font-weight: bold;">Response</span>.<span style="color: #330066;">Status</span> <span style="color: #006600; font-weight: bold;">=</span> <span style="color: #cc0000;">&quot;301 Moved Permanently&quot;</span>
   <span style="color: #990099; font-weight: bold;">Response</span>.<span style="color: #330066;">AddHeader</span> <span style="color: #cc0000;">&quot;Location&quot;</span>, <span style="color: #cc0000;">&quot;http://www.example.com&quot;</span> _
     + <span style="color: #990099; font-weight: bold;">Request</span>.<span style="color: #330066;">ServerVariables</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #cc0000;">&quot;PATH_INFO&quot;</span><span style="color: #006600; font-weight:bold;">&#41;</span>
   <span style="color: #990099; font-weight: bold;">Response</span>.<span style="color: #990099; font-weight: bold;">End</span><span style="color: #006600; font-weight:bold;">&#40;</span><span style="color: #006600; font-weight:bold;">&#41;</span>
<span style="color: #990099; font-weight: bold;">End</span> <span style="color: #990099; font-weight: bold;">If</span>
<span style="color: #000000; font-weight: bold;">%&gt;</span></pre></div></div>

<p>When programming canonical redirects like this it&#8217;s likely that your script will contain actual content rather than simply exist for the sake of the redirect. PHP scripts that issue redirects like this will continue to run until complete after issuing the headers. I can only assume that ASP is the same and so in this case <em>Response.End()</em> is added to prevent the script from proceeding after the redirect is issued.</p>
<h2>Conclusion</h2>
<p>Single page redirects in Classic ASP can be useful if your content has moved or if you want to make sure that visitors are viewing your canonical URL. If you can&#8217;t access IIS to set up the redirects and the <em>global.asa</em> won&#8217;t work, placing this code in your Classic ASP file will accomplish the redirect that you need.</p>
<h2>See Also</h2>
<p><a href="/redirect-pages-asp-net/">Redirecting single pages with ASP.NET</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.developwebsites.net/redirect-pages-classic-asp/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Essential MySQL Functions</title>
		<link>http://www.developwebsites.net/essential-mysql-functions/</link>
		<comments>http://www.developwebsites.net/essential-mysql-functions/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 20:27:25 +0000</pubDate>
		<dc:creator>Barnaby Knowles</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.developwebsites.net/?p=69</guid>
		<description><![CDATA[MySQL can do far more than just insert, update and select data. In fact the world's most popular open source database has a whole host of incredibly useful functions built in that you might never know about until you find one day that you need them - and then you wonder how you coped without them!]]></description>
			<content:encoded><![CDATA[<h2>MySQL Functions</h2>
<p>MySQL can do far more than just insert, update and select data. In fact the world&#8217;s most popular open source database has a whole host of incredibly useful functions built in that you might never know about until you find one day that you need them &#8211; and then you wonder how you coped without them!</p>
<p><span id="more-69"></span></p>
<h2>Essential Functions</h2>
<p>There are literally hundreds of build-in functions available in MySQL, and it would be pointless covering them all, seeing as the <a href="http://dev.mysql.com/doc/" rel="external">MySQL manual</a> does that already! Instead I am going to introduce you to some useful functions that you may well have heard of before, and hopefully some that you never encountered until now. This post is intended to grow as and when I have the time to add new functions.</p>
<p>Note: in general MySQL is not case-sensitive, so the examples show below should work in either uppercase or lowercase. It is recommended to use certain uppercase words throughout a query for ease of understanding.</p>
<h2>DATE_FORMAT()</h2>
<p>Usage: DATE_FORMAT(<i>date</i>,<i>format</i>)</p>
<p><em>DATE_FORMAT()</em>, as the name suggests, formats the date value according to the format string.</p>
<p>If you&#8217;ve stored a date (or datetime) in one of MySQL&#8217;s native formats, you can select it in your chosen display format (e.g. &#8220;Sunday 24th January&#8221;). This is rather like PHP&#8217;s <em>date()</em> function, except that it works with MySQL date stamps rather than Unix timestamps.</p>
<p><b>Examples:</b></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> DATE_FORMAT<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'2010-01-24'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'%W %D %M'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;"># Returns 'Sunday 24th January'</span>
&nbsp;
<span style="color: #993333; font-weight: bold;">SELECT</span> DATE_FORMAT<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`date_column`</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'%W %D %M'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">`date`</span> <span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #ff0000;">`table`</span>;
<span style="color: #808080; font-style: italic;"># Returns the stored date(s) formatted as you chose</span></pre></div></div>

<p>When formatting a date you can give it a different name using the &#8220;AS&#8221; modifier so that you can still use the original column name in an &#8220;ORDER BY&#8221; clause.</p>
<p><b>MySQL Manual:</b> <a href="http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format" rel="external">DATE_FORMAT()</a></p>
<h2>REPLACE()</h2>
<p>Usage: REPLACE(<i>column name</i>, <i>old value</i>, <i>new value</i>)</p>
<p><em>REPLACE()</em> is commonly used in an UPDATE query to change one string to another. It lets you replace a string within a larger string, for example changing a word or phrase within a larger block of text without having to update the whole text block itself. It&#8217;s provides a nifty search and replace facility.</p>
<p><b>Example:</b></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">UPDATE</span> <span style="color: #ff0000;">`table_name`</span> <span style="color: #993333; font-weight: bold;">SET</span> <span style="color: #ff0000;">`column_name`</span> <span style="color: #66cc66;">=</span> <span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`column_name`</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'old text'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'new text'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;"># Changes any 'old text' strings to 'new text' in the column specified</span></pre></div></div>

<p><b>MySQL Manual:</b> <a href="http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_replace" rel="external">REPLACE()</a></p>
<h2>CONCAT()</h2>
<p>Usage: CONCAT(<i>str1</i>, <i>str2</i>, &#8230;)</p>
<p><em>CONCAT()</em> returns a string that results from concatenating the arguments given. Arguments can be strings or even column names.</p>
<p><b>Examples:</b></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> CONCAT<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'My'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'S'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'QL'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;"># Returns 'MySQL'</span>
&nbsp;
<span style="color: #993333; font-weight: bold;">SELECT</span> CONCAT<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`first_name`</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">' '</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">`last_name`</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">`full_name`</span> <span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #ff0000;">`users`</span>;
<span style="color: #808080; font-style: italic;"># Returns 'John Smith' where column `first_name` is 'John' and `last_name` is 'Smith' etc...</span></pre></div></div>

<p>As well as being useful for selecting concatenated columns and text together, <em>CONCAT()</em> can also be used in UPDATE queries etc&#8230;</p>
<p><b>MySQL Manual:</b> <a href="http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_concat" rel="external">CONCAT()</a></p>
<h2>NOW()</h2>
<p>Usage: NOW()</p>
<p><em>NOW()</em> returns the current date and time as a value in &#8216;YYYY-MM-DD HH:MM:SS&#8217; format.</p>
<p><b>Examples:</b></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">UPDATE</span> <span style="color: #ff0000;">`table`</span> <span style="color: #993333; font-weight: bold;">SET</span> <span style="color: #ff0000;">`updated`</span> <span style="color: #66cc66;">=</span> NOW<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color: #ff0000;">`id`</span> <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">1</span>;
<span style="color: #808080; font-style: italic;"># Set the `updated` column to the current date and time for the record specified</span></pre></div></div>

<p><em>NOW()</em> makes setting a column value as the current date and time a piece of cake!</p>
<p><b>MySQL Manual:</b> <a href="http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_now" rel="external">NOW()</a></p>
<h2>UNIX_TIMESTAMP()</h2>
<p>Usage: UNIX_TIMESTAMP([<i>date</i>])</p>
<p><em>UNIX_TIMESTAMP()</em> returns a Unix timestamp if called without the date option, or the Unix timestamp of the date argument is one is supplied. The date may be a <em>DATE</em> string, a <em>DATETIME</em> string, a <em>TIMESTAMP</em>, or a number in the format YYMMDD or YYYYMMDD.</p>
<p>This is similar to the <em>NOW()</em> function except that you would use it if your date columns are Unix timestamp integers rather than datetime formats.</p>
<p><b>Examples:</b></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">UPDATE</span> <span style="color: #ff0000;">`table`</span> <span style="color: #993333; font-weight: bold;">SET</span> <span style="color: #ff0000;">`updated`</span> <span style="color: #66cc66;">=</span> UNIX_TIMESTAMP<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color: #ff0000;">`id`</span> <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">1</span>;
<span style="color: #808080; font-style: italic;"># Set the `updated` column to the current Unix timestamp for the record specified</span>
&nbsp;
<span style="color: #993333; font-weight: bold;">SELECT</span> UNIX_TIMESTAMP<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'2010-02-11 19:31:57'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;"># Select the Unix timestamp for a given date and time</span></pre></div></div>

<p><b>MySQL Manual:</b> <a href="http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_unix-timestamp" rel="external">UNIX_TIMESTAMP()</a></p>
<h2>FROM_UNIXTIME()</h2>
<p>Usage: FROM_UNIXTIME(<i>Unix timestamp[,format]</i>)</p>
<p><em>FROM_UNIXTIME()</em> does the reverse of <em>UNIX_TIMESTAMP()</em>, it takes a Unix timestamp and returns a representation of the datetime format &#8211; &#8216;YYYY-MM-DD HH:MM:SS&#8217;. If the <i>format</i> argument is given, the result is formatted according to the <i>format</i> string, which is used the same way as the <em>DATE_FORMAT()</em> function.</p>
<p><b>Examples:</b></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> FROM_UNIXTIME<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1265917455</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;"># Returns 2010-02-11 19:44:15</span>
&nbsp;
<span style="color: #993333; font-weight: bold;">SELECT</span> FROM_UNIXTIME<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1265917455</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'%D %M %Y'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;"># Returns 11th February 2010</span></pre></div></div>

<p><b>MySQL Manual:</b> <a href="http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_from-unixtime" rel="external">FROM_UNIXTIME()</a></p>
<h2>IF()</h2>
<p>Usage: IF(<i>expr1</i>,<i>expr2</i>,<i>expr3</i>)</p>
<p><em>IF()</em> can be used inside an SQL statement to return different values by evaluating the expression given.</p>
<p>If <i>expr1</i> is TRUE then <em>IF()</em> returns <i>expr2</i>; otherwise it returns <i>expr3</i>.</p>
<p><b>Examples:</b></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #993333; font-weight: bold;">IF</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&lt;</span> <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'yes'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'no'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;"># Returns 'yes' because 1 is less than 2</span>
&nbsp;
<span style="color: #993333; font-weight: bold;">UPDATE</span> <span style="color: #ff0000;">`people`</span> <span style="color: #993333; font-weight: bold;">SET</span> <span style="color: #ff0000;">`legal_status`</span> <span style="color: #66cc66;">=</span> <span style="color: #993333; font-weight: bold;">IF</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`age`</span> <span style="color: #66cc66;">&gt;=</span> <span style="color: #cc66cc;">18</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'adult'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'minor'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;"># Updates all people whose age is 18 or over to 'adult', otherwise to 'minor'</span></pre></div></div>

<p><em>IF()</em> is useful for updating a record where new values can vary depending on the existing data. Rather than selecting the current data, checking it with PHP and then deciding what the new values should be, you may be able to make your choice within the one single UPDATE statement itself by using the <em>IF()</em> function.</p>
<p><b>MySQL Manual:</b> <a href="http://dev.mysql.com/doc/refman/5.0/en/control-flow-functions.html#function_if" rel="external">IF()</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.developwebsites.net/essential-mysql-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Check Your Linux SSH Log To Stop Hackers</title>
		<link>http://www.developwebsites.net/check-linux-ssh-log/</link>
		<comments>http://www.developwebsites.net/check-linux-ssh-log/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 23:38:53 +0000</pubDate>
		<dc:creator>Barnaby Knowles</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://www.developwebsites.net/?p=66</guid>
		<description><![CDATA[Your web server may be ticking over nicely and everything looks fine and dandy. However, unbeknownst to you your server could be under constant attack by hackers! How can you find out if this is happening? One of the first things to check is your SSH log.]]></description>
			<content:encoded><![CDATA[<h2>Silent Attacks</h2>
<p>Your web server may be ticking over nicely and everything looks fine and dandy. However, unbeknownst to you your server could be under constant attack by hackers! How can you find out if this is happening? One of the first things to check is your SSH log.</p>
<p><span id="more-66"></span></p>
<h2>What Is SSH?</h2>
<p>SSH (secure shell) is a network protocol that allows Linux users to log into their shell accounts remotely over a secure connection that cannot be viewed by any third-parties that may be snooping.</p>
<p>SSH is used by Linux system administrators to connect to web servers. Logging in as the &#8220;root&#8221; user via SSH gives you complete control of the system and is a hacker&#8217;s ultimate goal.</p>
<p>SSH uses the standard TCP port 22 by default. Due to this it is possible for anyone (i.e. hackers) to connect to a web server via SSH on port 22 and try to gain access. Popular methods of attack are brute force and dictionary attacks. the chances are that this is happening to your web server without your knowledge.</p>
<h2>Check If You Are Under Attack</h2>
<p>Fortunately Linux systems log SSH activity so it&#8217;s possible to check back through your SSH logs and see if anyone is trying to login to your system.</p>
<h2>Locations of SSH Logs</h2>
<p>On Redhat systems the logs are stored at <em>/var/log/secure</em> and on other Linux flavours you should check <em>/var/log/auth.log</em></p>
<h2>How To View SSH Logs</h2>
<p>You can view your SSH log in a couple of different ways. Firstly you can download the log via SFTP. (SFTP is secure FTP and is possible if you connect via SSH.)</p>
<p>However, the log can be large and you may not want to view all of it. The second option is to log in via SSH and use the Linux <em>tail</em> command to display the last x number of lines. When you&#8217;re logged in via SSH use the following command to view your SSH log:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>auth.log <span style="color: #660033;">-n</span> <span style="color: #000000;">100</span></pre></div></div>

<p>That will display the last 100 lines of the SSH log on a non-Redhat system. Change the path to the log and the number of lines to display to suit your particular setup.</p>
<p>The log contains more than just SSH logins, so you&#8217;ll need to look through and identify any failed attempts to login via SSH. Failed attempts should show the username that the hacker tried and their IP address.</p>
<p>Hopefully there won&#8217;t be many hacking attempts, but if you&#8217;ve never investigated this issue before you might be surprised to learn how many people are trying to break into your system!</p>
<h2>Prevent Hacking Attempts</h2>
<p>The good news is that you can take proactive steps to prevent hackers gaining access to your system.</p>
<p>The first things that you can do is to take the SSH service off port 22 and put it on another random free port. That way  if a hacker tries to attack you on port 22 he will get nowhere, and he has no idea which other ports to try!</p>
<p>Secondly you can use the <a href="http://denyhosts.sourceforge.net" rel="external">DenyHosts</a> tool. This will periodically access your SSH log and add a firewall rule blocking anyone trying to access your system via SSH who has multiple failed attempts logged.</p>
<h2>Conclusion</h2>
<p>There may be hackers trying to gain access to your server without your knowledge. However, you can track their attempts and take action to severely limit the chances of an unauthorised user gaining access to your system.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.developwebsites.net/check-linux-ssh-log/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

