<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Simple PHP redirection script with log</title>
	<link>http://www.goblog.com.au/2008/03/05/simple-php-redirection-script-with-log/</link>
	<description></description>
	<pubDate>Thu, 28 Aug 2008 18:43:20 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.2</generator>

	<item>
		<title>By: Andrew</title>
		<link>http://www.goblog.com.au/2008/03/05/simple-php-redirection-script-with-log/#comment-967</link>
		<author>Andrew</author>
		<pubDate>Thu, 06 Mar 2008 14:32:23 +0000</pubDate>
		<guid>http://www.goblog.com.au/2008/03/05/simple-php-redirection-script-with-log/#comment-967</guid>
		<description>That's a much more elegant solution. 

I currently use the /redirect.php?id=100 method on other sites, (keyword-based actually, instead of numeric) but hadn't thought of your suggestion to simplify the painful problem of the list compilation.

Thanks for your contribution, it's appreciated.</description>
		<content:encoded><![CDATA[<p>That&#8217;s a much more elegant solution. </p>
<p>I currently use the /redirect.php?id=100 method on other sites, (keyword-based actually, instead of numeric) but hadn&#8217;t thought of your suggestion to simplify the painful problem of the list compilation.</p>
<p>Thanks for your contribution, it&#8217;s appreciated.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://www.goblog.com.au/2008/03/05/simple-php-redirection-script-with-log/#comment-966</link>
		<author>Mark</author>
		<pubDate>Thu, 06 Mar 2008 14:22:33 +0000</pubDate>
		<guid>http://www.goblog.com.au/2008/03/05/simple-php-redirection-script-with-log/#comment-966</guid>
		<description>Magic Quotes on should work for text fields but there are some vulnerabilities with database and file insertions I seem to recall. Also, I only mentioned it originally because yes, you may have magic quotes on, but if someone else reading this doesn't and then adds the code to their site then they might be opening themself up to attack. However, your code adjustment now should help.

From a personal point of view I hate using redirection scripts in this manner, i.e. taking the URL as a parameter and redirecting there. My preferred method when I've used this in the past was to maintain a database of redirection links so that the redirection was of this form instead:

/redirect.php?id=100

The benefit of this system is that it's easier to validate a number, you could, at a later date, alter all the redirection links site-wide if, for example, the place you're redirecting to changes their URL (has happened), and more importantly, it stops someone else bouncing off your page to someone they want to visit, faking the referrer to be your site.

On the downside, who wants to maintain a list of links? Nobody. Which is why I implemented a helper piece of code. Effectively, in the PHP of your page you'd replace any link with a piece of code:

from: visit &lt;a href="somesite" rel="nofollow"&gt;this site&lt;/a&gt;
to: visit 

the helper function linkto() would check to see if "somesite" was already in the database. If so then it gets replaced with:

&lt;a href="/redirect.php?id=existing_id_number" rel="nofollow"&gt;this site&lt;a&gt;

otherwise, "somesite" is added and

&lt;a href="/redirect.php?id=new_id_number" rel="nofollow"&gt;this site&lt;a&gt;

is output to the page instead.

It relied on you being able to add PHP to a page but it was in use on a number of websites a few years ago for tracking purposes.</description>
		<content:encoded><![CDATA[<p>Magic Quotes on should work for text fields but there are some vulnerabilities with database and file insertions I seem to recall. Also, I only mentioned it originally because yes, you may have magic quotes on, but if someone else reading this doesn&#8217;t and then adds the code to their site then they might be opening themself up to attack. However, your code adjustment now should help.</p>
<p>From a personal point of view I hate using redirection scripts in this manner, i.e. taking the URL as a parameter and redirecting there. My preferred method when I&#8217;ve used this in the past was to maintain a database of redirection links so that the redirection was of this form instead:</p>
<p>/redirect.php?id=100</p>
<p>The benefit of this system is that it&#8217;s easier to validate a number, you could, at a later date, alter all the redirection links site-wide if, for example, the place you&#8217;re redirecting to changes their URL (has happened), and more importantly, it stops someone else bouncing off your page to someone they want to visit, faking the referrer to be your site.</p>
<p>On the downside, who wants to maintain a list of links? Nobody. Which is why I implemented a helper piece of code. Effectively, in the PHP of your page you&#8217;d replace any link with a piece of code:</p>
<p>from: visit <a href="somesite" rel="nofollow">this site</a><br />
to: visit </p>
<p>the helper function linkto() would check to see if &#8220;somesite&#8221; was already in the database. If so then it gets replaced with:</p>
<p><a href="/redirect.php?id=existing_id_number" rel="nofollow">this site</a><a></p>
<p>otherwise, &#8220;somesite&#8221; is added and</p>
<p></a><a href="/redirect.php?id=new_id_number" rel="nofollow">this site</a><a></p>
<p>is output to the page instead.</p>
<p>It relied on you being able to add PHP to a page but it was in use on a number of websites a few years ago for tracking purposes.</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://www.goblog.com.au/2008/03/05/simple-php-redirection-script-with-log/#comment-963</link>
		<author>Andrew</author>
		<pubDate>Thu, 06 Mar 2008 13:02:43 +0000</pubDate>
		<guid>http://www.goblog.com.au/2008/03/05/simple-php-redirection-script-with-log/#comment-963</guid>
		<description>And that's why I should stick to doing frontend design ;-). 

But correct me if I'm wrong, having Magic Quotes on in your PHP server settings should prevent SQL injection anyway? I've added a conditional statement to check, and if it's not on, do some cleaning now anyway.</description>
		<content:encoded><![CDATA[<p>And that&#8217;s why I should stick to doing frontend design ;-). </p>
<p>But correct me if I&#8217;m wrong, having Magic Quotes on in your PHP server settings should prevent SQL injection anyway? I&#8217;ve added a conditional statement to check, and if it&#8217;s not on, do some cleaning now anyway.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://www.goblog.com.au/2008/03/05/simple-php-redirection-script-with-log/#comment-961</link>
		<author>Mark</author>
		<pubDate>Thu, 06 Mar 2008 11:07:32 +0000</pubDate>
		<guid>http://www.goblog.com.au/2008/03/05/simple-php-redirection-script-with-log/#comment-961</guid>
		<description>That code is vulnerable to SQL injection. You should clean up the $toURL before simply placing it in the SQL command.</description>
		<content:encoded><![CDATA[<p>That code is vulnerable to SQL injection. You should clean up the $toURL before simply placing it in the SQL command.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 5.198 seconds -->
