<?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>Brain Goo &#187; php</title>
	<atom:link href="http://www.popmartian.com/tipsntricks/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.popmartian.com/tipsntricks</link>
	<description>Carpe Crap 'em</description>
	<lastBuildDate>Mon, 10 Oct 2011 14:42: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>Quick Character Escaping in PHP</title>
		<link>http://www.popmartian.com/tipsntricks/2007/10/10/quick-character-escaping-in-php/</link>
		<comments>http://www.popmartian.com/tipsntricks/2007/10/10/quick-character-escaping-in-php/#comments</comments>
		<pubDate>Wed, 10 Oct 2007 17:48:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.popmartian.com/tipsntricks/2007/10/10/quick-character-escaping-in-php/</guid>
		<description><![CDATA[When writing PHP web apps, I tend to run in to a portability issue when dealing with SQL connectivity. Since I can&#8217;t count on having the PEAR DB module available, I rolled my own set of functions to interact with a MySQL database. The problem lies in escaping characters in your SQL queries. Do I [...]]]></description>
			<content:encoded><![CDATA[<p>When writing PHP web apps, I tend to run in to a portability issue when dealing with SQL connectivity.  Since I can&#8217;t count on having the PEAR DB module available, I rolled my own set of functions to interact with a MySQL database.</p>
<p>The problem lies in escaping characters in your SQL queries.  Do I <code>addslashes()</code>?  Is magic_quotes_gpc enabled?</p>
<p>My quick-and-dirty solution is the following function:</p>
<p><code><br />
function request_cleanup()<br />
{<br />
&nbsp;&nbsp;if(get_magic_quotes_gpc() == 0)<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;foreach($_REQUEST as $req_key => $req_value)<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$_REQUEST[$req_key]=addslashes($_REQUEST[$req_key]);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;}<br />
}<br />
</code></p>
<p>By calling that function on every page that deals with inserting content in to the database, I know will will get my content escaped correctly.</p>
<p>Of course it escapes all submitted content, including that which isn&#8217;t going in to the database so don&#8217;t forget to <code>stripslashes()</code> when you are working with data that doesn&#8217;t need it.</p>
<p>Example:<br />
<code><br />
request_cleanup();</p>
<p>$notes = $_REQUEST['notes '];<br />
$confirmation = stripslashes($_REQUEST['notes ']);</p>
<p>$SQL = "INSERT INTO notes (note) VALUES ('$notes')";<br />
sql_proc($SQL);</p>
<p>print "Your note was: $confirmation";<br />
</code></p>
<img src="http://www.popmartian.com/tipsntricks/?ak_action=api_record_view&id=18&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.popmartian.com/tipsntricks/2007/10/10/quick-character-escaping-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stop spam-bots in PHPBB 2.x.  Cheap, easy BOT stopper</title>
		<link>http://www.popmartian.com/tipsntricks/2007/06/05/stop-spam-bots-in-phpbb-cheap-easy-bot-stopper/</link>
		<comments>http://www.popmartian.com/tipsntricks/2007/06/05/stop-spam-bots-in-phpbb-cheap-easy-bot-stopper/#comments</comments>
		<pubDate>Tue, 05 Jun 2007 22:21:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[How Tos]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[phpbb]]></category>
		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://www.popmartian.com/tipsntricks/2007/06/05/stop-auto-bots-in-phpbb-cheap-easy-bot-stopper/</guid>
		<description><![CDATA[WARNING!  As of this writing, this information pertains to the 2.x branch of phpBB.  I strongly recommend you upgrade to the latest phpBB.  As of April 28, 2009 that version is 3.0.4.  Please see http://phpbb.com NOTICE: I have an updated phpBB patch for the 3.0.x version of phpBB.  Please search this blog for phpBB or [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>WARNING!  As of this writing, this information pertains to the 2.x branch of phpBB.  I strongly recommend you upgrade to the latest phpBB.  As of April 28, 2009 that version is 3.0.4.  Please see <a href="http://phpbb.com">http://phpbb.com</a></p>
<p>NOTICE: I have an updated phpBB patch for the 3.0.x version of phpBB.  Please search this blog for phpBB or look at the phpbb category for more tips and tricks.</p></blockquote>
<p>In your active template file profile_add_body.tpl find the line:</p>
<p><code> </code></p>
<pre>&lt;!-- Visual Confirmation --&gt;</pre>
<p><strong>ABOVE</strong> that line, add:</p>
<pre>&lt;!-- BOT HACK --&gt;
   &lt;tr&gt;
      &lt;td class="row1"&gt;&lt;span class="gen"&gt;Are you a robot? *&lt;/span&gt;&lt;/td&gt;
      &lt;td class="row2"&gt;&lt;select class="post" name="imarobot"&gt;
      &lt;option value="yes"&gt;yes&lt;/option&gt;
      &lt;option value="yes"&gt;of course&lt;/option&gt;
      &lt;option value="nope"&gt;Humans choose this one&lt;/option&gt;
      &lt;/select&gt; &lt;span class="gen"&gt;Bot buster... choose the right one.&lt;/span&gt;&lt;/td&gt;
   &lt;/tr&gt;
&lt;!-- BOT HACK --&gt;</pre>
<p>In your forum file includes/usercp_register.php find this section of code:</p>
<p><code> </code></p>
<pre>   else if ( $mode == 'register' )
   {
      if ( empty($username) || empty($new_password) || empty($password_confirm) || empty($email) )
      {
         $error = TRUE;
         $error_msg .= ( ( isset($error_msg) ) ? '&lt;br /&gt;' : '' ) . $lang['Fields_empty'];
      }</pre>
<p><strong>AFTER</strong> that part, add this:</p>
<p><code> </code></p>
<pre>// BOT HACK
         if ( empty($HTTP_POST_VARS['imarobot']) )
         {
            die('NO BOTS');
         }
         else
         {
            if ($HTTP_POST_VARS['imarobot'] != 'nope')
            {
               die('NO BOTS');
            }
         }
// BOT HACK</pre>
<p>And there you go.</p>
<img src="http://www.popmartian.com/tipsntricks/?ak_action=api_record_view&id=9&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.popmartian.com/tipsntricks/2007/06/05/stop-spam-bots-in-phpbb-cheap-easy-bot-stopper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Header injection</title>
		<link>http://www.popmartian.com/tipsntricks/2007/05/21/php-header-injection/</link>
		<comments>http://www.popmartian.com/tipsntricks/2007/05/21/php-header-injection/#comments</comments>
		<pubDate>Mon, 21 May 2007 17:43:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[How Tos]]></category>
		<category><![CDATA[Mail Post]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.popmartian.com/tipsntricks/2007/05/21/php-header-injection/</guid>
		<description><![CDATA[I regularly shut down web sites that use the PHP mail() function. While the users of the sites mean well, they generally don&#8217;t do any checking before sending data to mail(). I&#8217;m not going to weigh in mail(). Enough has been said about it. Just remember to take your code and code security seriously. Remember, [...]]]></description>
			<content:encoded><![CDATA[<p>I regularly shut down web sites that use the PHP mail() function.  While the users of the sites mean well, they generally don&#8217;t do any checking before sending data to mail().  I&#8217;m not going to weigh in mail().  Enough has been said about it.  Just remember to take your code and code security seriously.</p>
<p>Remember, never trust data submitted by site visitors.  Sanitize the heck out of it.</p>
<p>Jelly and Custard has an excellent explanation of PHP Header Injection when using the PHP mail() function.</p>
<p><a href="http://www.jellyandcustard.com/2006/02/24/email-header-injection-in-php/" target="_blank">http://www.jellyandcustard.com/2006/02/24/email-header-injection-in-php/</a></p>
<p><a href="http://www.jellyandcustard.com" target="_blank">http://www.jellyandcustard.com</a> is an excellent PHP blog.</p>
<img src="http://www.popmartian.com/tipsntricks/?ak_action=api_record_view&id=7&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.popmartian.com/tipsntricks/2007/05/21/php-header-injection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

