<?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>Darren Tarrant</title>
	<atom:link href="http://www.darrentarrant.co.uk/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.darrentarrant.co.uk/blog</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Mon, 06 Jun 2011 19:19:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>MySQL to MSSQL</title>
		<link>http://www.darrentarrant.co.uk/blog/?p=23</link>
		<comments>http://www.darrentarrant.co.uk/blog/?p=23#comments</comments>
		<pubDate>Mon, 06 Jun 2011 19:18:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[MySQL to MSSQL]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[WAMP]]></category>

		<guid isPermaLink="false">http://www.darrentarrant.co.uk/blog/?p=23</guid>
		<description><![CDATA[I have been working on a project recently which has required me to implement a WAMP server with MSSQL. The environment that was required was Windows Server 2008, MSSQL 2008 and we had MSSQL Studio. Of course, we installed PHP and Apache. We had to use a prior version of PHP as newer versions required [...]]]></description>
			<content:encoded><![CDATA[<p>I have been working on a project recently which has required me to implement a WAMP server with MSSQL. The environment that was required was Windows Server 2008, MSSQL 2008 and we had MSSQL Studio. Of course, we installed PHP and Apache. We had to use a prior version of PHP as newer versions required a different syntax for the mssql_query statments.</p>
<p>The porting of a MySQL database to MSSQL was not straightforward either. I used dbconvert, which is free but you can only export the first 50 rows of each table in free mode, after that you pay.</p>
<p>You can download this here:</p>
<p><a title="dbconvert" href="http://dbconvert.com/convert-mssql-to-mysql-pro.php" target="_blank">http://dbconvert.com/convert-mssql-to-mysql-pro.php</a></p>
<p>Then there was the problem of data types, since MSSQL seems to want varchar&#8217;s to be nvarchar and blob&#8217;s to be varbinary. A few good tips for this are as follows:</p>
<p>When selecting data from the db,  you need to cast nvarchar&#8217;s as text first, something like this:</p>
<p>cast(field1 as text) as field1</p>
<p>When updating a varbinary, you first need to cast it as such, like this:</p>
<p>field1=cast(&#8216;$value1&#8242; as varbinary(max))</p>
<p>The next problem was updating the database structure. If you receive an error when doing this in design mode (MSSQL Studio), such as this:</p>
<blockquote><p><em>Saving changes is not permitted. The changes that you have made require  the following tables to be dropped and re-created. You have either made changes to a table that can&#8217;t be re-created or  enabled the option Prevent saving changes that require the table to be  re-created.</em></p></blockquote>
<p>&#8230;then there is a few ways you can work around it. If your database does not record transaction changes, then you can use the global settings in MSSQL Studio to turn the &#8216;<strong>Prevent saving changes that require table re-creation&#8217; </strong>tick box off. Otherwise you need to use T-SQL to make your db changes. There is a blog post from MS here, which covers it:</p>
<p><a title="Microsoft Bug Report" href="http://support.microsoft.com/kb/956176" target="_blank">http://support.microsoft.com/kb/956176</a></p>
<p>Finally, to set a field on a table to autoincrement, you need to use the IDENTITY keyword, for example like this:</p>
<p>&nbsp;</p>
<p>CREATE TABLE [dbname].[dbo].tablename<br />
(<br />
id int IDENTITY(1,1)PRIMARY KEY,<br />
field1 varchar(max) NULL,<br />
&#8230;<br />
)</p>
<p>The numbers in parentheses after IDENTITY refer to the start value and the increment amount, so in the above example the start value is 1 and the rows increment by 1 each time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.darrentarrant.co.uk/blog/?feed=rss2&#038;p=23</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>301 redirects; addendum</title>
		<link>http://www.darrentarrant.co.uk/blog/?p=17</link>
		<comments>http://www.darrentarrant.co.uk/blog/?p=17#comments</comments>
		<pubDate>Fri, 01 Oct 2010 21:17:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[htaccess]]></category>
		<category><![CDATA[Search Engine Optimisation]]></category>
		<category><![CDATA[301 redirects]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[mod rewrite]]></category>

		<guid isPermaLink="false">http://www.darrentarrant.co.uk/blog/?p=17</guid>
		<description><![CDATA[To redirect a URL with a fixed query string, e.g to make this: http://www.old-domain.co.uk/index.php?pageid=1 Rewrite to this: http://www.new-domain.co.uk/index.php?pageid=1 Use the following code in your htaccess file on an Apache web server: RewriteCond %{QUERY_STRING} ^pageid=1$ RewriteRule ^index(.*) http://www.new-domain.co.uk/$i [R=301,L] To redirect a URL with a dynamic query string, e.g to make this: http://www.old-domain.co.uk/index.php?pageid=xxx Rewrite to this: [...]]]></description>
			<content:encoded><![CDATA[<p>To redirect a URL with a fixed query string, e.g to make this:</p>
<p>http://www.old-domain.co.uk/index.php?pageid=1</p>
<p>Rewrite to this:</p>
<p>http://www.new-domain.co.uk/index.php?pageid=1</p>
<p>Use the following code in your htaccess file on an Apache web server:</p>
<p><em>RewriteCond %{QUERY_STRING} ^pageid=1$</em></p>
<p><em>RewriteRule ^index(.*) http://www.new-domain.co.uk/$i [R=301,L]</em></p>
<p>To redirect a URL with a dynamic query string, e.g to make this:</p>
<p>http://www.old-domain.co.uk/index.php?pageid=xxx</p>
<p>Rewrite to this:</p>
<p>http://www.new-domain.co.uk/index.php?pageid=xxx</p>
<p>Remove the dollar at the end of the query string pattern, thus:<br />
<em>RewriteCond %{QUERY_STRING} ^pageid=</em></p>
<p><em>RewriteRule ^index(.*) http://www.new-domain.co.uk/$i [R=301,L]</em></p>
<p>To rewrite and remove the query string use this:</p>
<p><em>RewriteCond %{QUERY_STRING} ^pageid=</em></p>
<p><em>RewriteRule ^index(.*) http://www.new-domain.co.uk/? [R=301,L]</em></p>
<p>The question mark at the end effectively clears the query string and redirects to the root of the new domain.</p>
<p>Notes:<br />
The L in the square bracket at the end tells the server to stop processing the htaccess for this request, so is important to stop when a rule is matched.</p>
<p>RewriteCond %{QUERY_STRING}</p>
<p>This is the matching URL condition, i.e that the query string matches the pattern ^pageid=</p>
<p>The ^ fixes the match URL to start with the pattern and the $ fixes the  URL match to end with the pattern. So it follows that the two in  conjunction means that the pattern must be matched exactly. The only  exceptions to this would be if the pattern is a regex, but the start and  finish match would still hold.<br />
^pageid=1 &#8211; would also match pageid=11<br />
pageid=1$ &#8211; would also match xpageid=1</p>
<p>RewriteRule ^index(.*) http://www.new-domain.co.uk/? [R=301,L]</p>
<p>This is the matching rule. In other words, when Apache finds a match to the condition rule in the URL it executes this rule. That is to say, in the above example it 301 redirects (R=301) to the root new-domain.co.uk (http://www.new-domain.co.uk/?).</p>
<p>index(.*) refers to a further matching criteria, in that it only applies to files called index, the suffix can be anything.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.darrentarrant.co.uk/blog/?feed=rss2&#038;p=17</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Internet Explorer 32 styles bug</title>
		<link>http://www.darrentarrant.co.uk/blog/?p=12</link>
		<comments>http://www.darrentarrant.co.uk/blog/?p=12#comments</comments>
		<pubDate>Sat, 24 Oct 2009 23:07:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Browser Bugs]]></category>
		<category><![CDATA[31 styles ie]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[ie bug]]></category>
		<category><![CDATA[internet explorer]]></category>

		<guid isPermaLink="false">http://www.darrentarrant.co.uk/blog/?p=12</guid>
		<description><![CDATA[I have found a curious bug in all versions of Internet Explorer. It is new to me and i found no reference to it on the internet, so here goes. If you have access to a php server, insert the following code into a php file: &#60;?php for($i=1;$i&#60;=100;$i++){ ?&#62; &#60;style type = &#8220;text/css&#8221;&#62; .style&#60;? echo [...]]]></description>
			<content:encoded><![CDATA[<p>I have found a curious bug in all versions of Internet Explorer. It is new to me and i found no reference to it on the internet, so here goes.</p>
<p>If you have access to a php server, insert the following code into a php file:</p>
<p>&lt;?php</p>
<p>for($i=1;$i&lt;=100;$i++){<br />
?&gt;<br />
&lt;style type = &#8220;text/css&#8221;&gt;<br />
.style&lt;? echo $i; ?&gt;{<br />
border: purple 1px solid;<br />
height: 100px;<br />
width: 100px;<br />
}<br />
&lt;/style&gt;<br />
&lt;div class = &#8220;style&lt;? echo $i; ?&gt;&#8221;&gt;&lt;? echo $i; ?&gt;&lt;/div&gt;<br />
&lt;?<br />
}</p>
<p>?&gt;</p>
<p>This will output 100 boxes,  each with a separate class reference. There is also 100 class definitions. Viewing this in IE 6,7 and 8 you will see only the first 31 boxes have style!</p>
<p>The workaround for bugs similar to this is to use inline styles instead of class references and this seems to work around it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.darrentarrant.co.uk/blog/?feed=rss2&#038;p=12</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Javascript form injection</title>
		<link>http://www.darrentarrant.co.uk/blog/?p=10</link>
		<comments>http://www.darrentarrant.co.uk/blog/?p=10#comments</comments>
		<pubDate>Sat, 25 Oct 2008 20:53:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP security]]></category>
		<category><![CDATA[blacklist]]></category>
		<category><![CDATA[form injection]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[web forms]]></category>
		<category><![CDATA[whitelist]]></category>

		<guid isPermaLink="false">http://www.darrentarrant.co.uk/blog/?p=10</guid>
		<description><![CDATA[Imagine a very insecure form, which emailed a password or other sensitive information to a given email address. Imagine again, if you will, that this email address was hard coded into a hidden form field called, say, &#8216;to&#8217;. This is incredibly insecure and here&#8217;s why; With javascript turned on in your browser one can inject [...]]]></description>
			<content:encoded><![CDATA[<p>Imagine a very insecure form, which emailed a password or other sensitive information to a given email address. Imagine again, if you will, that this email address was hard coded into a hidden form field called, say, &#8216;to&#8217;. This is incredibly insecure and here&#8217;s why;</p>
<p>With javascript turned on in your browser one can inject their own email address in the place of this one to get the form. All one needs to do is to look at the source code to see how many forms there are on the page. Count from zero upwards to the form you need and reference it like this:</p>
<p>Navigate to a page with said for  in it. Let&#8217;s say it is the first form in the source code, therefore we reference it with a &#8217;0&#8242; (second one will be a &#8217;1&#8242; and so on). The form, we know from the source code, has a field called &#8216;to&#8217;, so we want to set it to a new value. Now type this into the browser address bar:</p>
<p>javascript:void(document.forms[0].to.value=&#8221;me@example.com&#8221;)</p>
<p>To check the value has changed type this:</p>
<p>javascript:alert(document.forms[0].to.value)</p>
<p>Now when you submit the form, it will be submitted with the &#8216;to&#8217; value of me@example.com. Simple. It is easy to imagine all sorts of variations on this theme, so awareness is an important tool in protecting against it.</p>
<p>To protect your forms against this, you must have some sort of server side checking in the target url to check for correct email addresses. There is two ways to do this; white listing and blacklisting. Whitelisting is a list, perhaps an array or database resource, of all allowed email addresses that can be accepted into the form processing script. All other values are logically rejected by the script. This is a more secure option. A blacklist, less useful but worth mentioning, is where you allow all values, except specified ones. Blacklisting is only really useful if you know that there are only specific examples of values you wish to disalllow (for example removing rude words from a message).</p>
<p>I hope this article has been insightful and helpful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.darrentarrant.co.uk/blog/?feed=rss2&#038;p=10</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mod rewrite for 301 redirects</title>
		<link>http://www.darrentarrant.co.uk/blog/?p=8</link>
		<comments>http://www.darrentarrant.co.uk/blog/?p=8#comments</comments>
		<pubDate>Sat, 25 Oct 2008 20:23:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Search Engine Optimisation]]></category>
		<category><![CDATA[301 redirect]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[mod rewrite]]></category>

		<guid isPermaLink="false">http://www.darrentarrant.co.uk/blog/?p=8</guid>
		<description><![CDATA[301 redirects are essential if you port a site that ranks well to a new page address or domain. It is common on a LAMP platform to use the htaccess file and mod rewrite to acheive this. Here are some useful examples of mod rewrite rules to help you along the way. With RewriteEngine On [...]]]></description>
			<content:encoded><![CDATA[<p>301 redirects are essential if you port a site that ranks well to a new page address or domain. It is common on a LAMP platform to use the htaccess file and mod rewrite to acheive this. Here are some useful examples of mod rewrite rules to help you along the way.</p>
<p>With RewriteEngine On<br />
and in RewriteRule<br />
^home\.php$ # Just file itself<br />
^home\.php(.*)$ # File plus zero or more chars<br />
^home\.php(.{0,})$ # File plus zero or more chars<br />
^home\.php(.{0,28})$ # File plus zero to 28 (or whatever) chars<br />
^home\.php(.+)$ # File plus one or more chars<br />
^home\.php(.{1,})$ # File plus one or more chars<br />
^home\.php(.{1,28})$ # File plus one to 28 (or whatever) chars<br />
^home\.php\?var=val$ # File with specific query string<br />
^home\.php([\?]([a-zA-Z0-9]+)=([a-zA-Z0-9]+))$ # File with regex for  basic query<br />
^home\.php#overHere$ # File with Hash part</p>
<p>So for example use the following script with the above expressions:</p>
<p>ReWrite Engine On</p>
<p>Rewrite Rule ^home\.php([\?]([a-zA-Z0-9]+)=([a-zA-Z0-9]+))$ http://www.new-domain.com/$i</p>
<p>This will rewrite any url on the old domain of the form http://www.old-domain.com/home.php?something=value to the new url: http://www.new-domain.com/home.php?something=value</p>
<p>With variations on the expressions above you can acheive most of what you are after to pass on that vital link juice.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.darrentarrant.co.uk/blog/?feed=rss2&#038;p=8</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Hacking upload scripts</title>
		<link>http://www.darrentarrant.co.uk/blog/?p=3</link>
		<comments>http://www.darrentarrant.co.uk/blog/?p=3#comments</comments>
		<pubDate>Thu, 18 Sep 2008 19:37:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP security]]></category>
		<category><![CDATA[1x1 jpeg hack]]></category>
		<category><![CDATA[file upload hack]]></category>
		<category><![CDATA[form upload]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.darrentarrant.co.uk/blog/?p=3</guid>
		<description><![CDATA[The 1&#215;1 JPEG hack, goes something like this&#8230;.. Many file upload forms use server side processing that checks for MIME type and filename/extension to see if a file is bonafide. These attributes of a file are always sent by the referrer, so they can be faked. You can set up a 1&#215;1 jpeg with fake [...]]]></description>
			<content:encoded><![CDATA[<p>The 1&#215;1 JPEG hack, goes something like this&#8230;..</p>
<p>Many file upload forms use server side processing that checks for MIME type and filename/extension to see if a file is bonafide. These attributes of a file are always sent by the referrer, so they can be faked. You can set up a 1&#215;1 jpeg with fake mime information and a fake extension, such as hack.jpg.php. This will both pass the MIME and file extension check of the file upload script. If a vulnerable script allows .php or any other executable file then all sorts of mayhem can occur.</p>
<p>To protect against this use a regular expression of the form:</p>
<p>$source = $_FILES['file1']['tmp_name'];<br />
$source_name = $_FILES['file1']['name'];<br />
$source_type = $_FILES['file1']['type'];</p>
<p>if(($source &lt;&gt; &#8220;none&#8221;) &amp;&amp; ($source &lt;&gt; &#8220;&#8221;) &amp;&amp; ((eregi(&#8220;.png$&#8221;,$source_name) &amp;&amp; eregi(&#8220;^image/png$|^image/x-png$&#8221;,$source_type))) { //allow the file}else{ //this is an invalid file}</p>
<p>This example protects against both MIME type and file extension fakes and uses PHP as it&#8217;s scripting language</p>
]]></content:encoded>
			<wfw:commentRss>http://www.darrentarrant.co.uk/blog/?feed=rss2&#038;p=3</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

