<?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>Peter Mac And Associates&#187; PHP</title>
	<atom:link href="http://www.petermac.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.petermac.com</link>
	<description>Australian freelance programmer and website design</description>
	<lastBuildDate>Tue, 24 Aug 2010 07:28:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Using magic_quotes_gpc or addslashes()</title>
		<link>http://www.petermac.com/using-magic_quotes_gpc-or-addslashes/</link>
		<comments>http://www.petermac.com/using-magic_quotes_gpc-or-addslashes/#comments</comments>
		<pubDate>Tue, 10 Oct 2006 09:18:25 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.petermac.com/?p=11</guid>
		<description><![CDATA[I&#8217;ve worked on a bundle of web based applications over the years and time and time again I&#8217;ve seen the recurring problem of the slash. Yes, we&#8217;ve probably all seen it in one or more forums where the apostrophe some user entered, probably with the name O&#8217;Brein ends up as O\\Brein. Why does this happen [...]]]></description>
			<content:encoded><![CDATA[<p class="western">I&#8217;ve worked on a bundle of web based applications over the years and time and time again I&#8217;ve seen the recurring problem of the slash.  Yes, we&#8217;ve probably all seen it in one or more forums where the apostrophe some user entered, probably with the name O&#8217;Brein ends up as O\\Brein.</p>
<p class="western">Why does this happen in sites running on PHP?  The answer is a duplication of escapes. Yep, a Houdini Supreme.</p>
<p class="western">Firstly a systems administrator has installed PHP and set the value for magic_quotes_gpc = on in the system&#8217;s php.ini (usually located in /etc/).  This will automatically add slashes to all GET/POST/COOKIE data. This makes it safe before writing it to a database. Mr O&#8217;Brein becomes Mr O\\&#8217;Brein when magic_quotes_gpc is set to on.</p>
<p class="western">Secondly, a programmer has come along and thinking they&#8217;re doing the right thing takes all user input and uses the addslashes() funtion to escape all quotes. This results in a doubling of the escapes so, Mr O&#8217;\\Brien now becomes MR O\\\\&#8217;Brein.</p>
<p class="western">When this data is rendered, we see the automatic removal of only one set of escapes but the other set is left behind&#8230;yuck!!</p>
<p class="western">
<p class="western">When programmers see this they think&#8230;”I&#8217;ll just use the stripslashes() method, I mean, that&#8217;s what it&#8217;s there for”.  As the light from the idea bulb fades, they realise they&#8217;re fixing a problem that should never have occurred in the first place. You need to go to the source of your data and clean it up, make sure you&#8217;re either using magic_quotes_gpc=on OR addslashes.  My preference is to use addslashes all the time and turn  magic_quotes_gpc off, this way the logic of your code explicitly sets user input to be what you want.</p>
<p class="western">
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.petermac.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.petermac.com/using-magic_quotes_gpc-or-addslashes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP mail function with postfix</title>
		<link>http://www.petermac.com/php-mail-function-with-postfix/</link>
		<comments>http://www.petermac.com/php-mail-function-with-postfix/#comments</comments>
		<pubDate>Wed, 06 Sep 2006 01:09:17 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.petermac.com/?p=10</guid>
		<description><![CDATA[I recently modified a web server to run Postfix instead of sendmail as it&#8217;s main MTA. The result was fairly pleasing and a Postfix/Imap/Webmail implementation meant my client was able to pick up and manage mail while travelling. One problem encountered however was the mail server was also a web server. Any time emails were [...]]]></description>
			<content:encoded><![CDATA[<p>I recently modified a web server to run Postfix instead of sendmail as it&#8217;s main MTA. The result was fairly pleasing and a Postfix/Imap/Webmail implementation meant my client was able to  pick up and manage mail while travelling.  One problem encountered however was the mail server was also a web server. Any time emails were sent using online forms, the resulting mail looked something like the following&#8230;</p>
<p><span class="code">: No recipients specified<br />
</span><span class="code">Reporting-MTA: dns; mail.threerock.com<br />
X-Postfix-Queue-ID: 93E255C4E41<br />
X-Postfix-Sender: rfc822; apache@threerock.com<br />
Arrival-Date: Wed,  6 Sep 2006 08:26:14 +1000 (EST)</span> <span class="code">Final-Recipient: rfc822; unknown<br />
Action: failed<br />
Status: 5.0.0<br />
Diagnostic-Code: X-Postfix; No recipients specified</span> <span class="code">Received: by mail.threerock.com (Postfix, from userid 76)<br />
id 93E255C4D4; Wed,  6 Sep 2006 08:26:14 +1000 (EST)<br />
To: admin@threerock.com<br />
Subject: Threerock Support &#8211; Report a Bug<br />
From: &#8220;peter mac&#8221;</span></p>
<p>Reply-To: admin@threerock.com<br />
Message-Id: 20060905222614.93E255C4D4@mail.threerock.com<br />
Date: Wed,  6 Sep 2006 08:26:14 +1000 (EST)</p>
<p>After a bit of research and many different opinions from online groups, the fix turned out to be a simple change to the php.ini file (located in this case at /etc/php.ini)The change is as follows:look for the section [mail function] and create (if it doesn&#8217;t already exist) a key</p>
<p>sendmail_path = /usr/sbin/sendmail -t -i -f someone@yourdomain.com</p>
<p>Firstly check the path to your sendmail executable by typing</p>
<p>$ which sendmail</p>
<p>Secondly enter a valid username/domainname. This is the user the email will appear to come from. Examples are support@yourdomain.com, admin@yourdomain.com etc.</p>
<p>After saving your php.ini file, you will have to restart your httpd process.</p>
<p>$ /etc/rc.d/init.d/httpd restart</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.petermac.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.petermac.com/php-mail-function-with-postfix/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
