<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Sun, 12 Feb 2012 17:38:12 -0600</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Gonzalo Ayuso's Blog: How to protect from SQL Injection with PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/17514</guid>
      <link>http://www.phpdeveloper.org/news/17514</link>
      <description><![CDATA[<p>
In a recent post to his blog, <i>Gonzalo Ayuso</i> shares a few tips on <a href="http://gonzalo123.wordpress.com/2012/02/06/how-to-protect-from-sql-injection-with-php/">preventing SQL injection</a> attacks on your applications.
</p>
<blockquote>
Security is a part of our work as developers. We need to ensure our applications against malicious attacks. SQL Injection is one of the most common possible attacks. Basically SQL Injection is one kind of attack that happens when someone injects SQL statements in our application. You can find a lot of info about SQL Injection attack. Basically you need to follow the security golden rule: "Filter input, Escape output".
</blockquote>
<p>
He advocates the use of the PDO abstraction layer to filter out a lot of the issues. Using its prepared statements, you can easily strip out things that just adding slashes to user input wouldn't prevent. He also includes a reminder about database permissions - allowing only certain users the ability to, for example, delete can help provide one more level of security (in other words, don't use a "super user" in production).
</p>]]></description>
      <pubDate>Wed, 08 Feb 2012 08:07:05 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Brian Swan's Blog: Using SQL Azure to Store PHP Session Data]]></title>
      <guid>http://www.phpdeveloper.org/news/17024</guid>
      <link>http://www.phpdeveloper.org/news/17024</link>
      <description><![CDATA[<p>
In a recent post to his blog <i>Brian Swan</i> takes a look at working with sessions in PHP and, specifically, how to <a href="http://blogs.msdn.com/b/silverlining/archive/2011/10/19/using-sql-azure-to-store-php-session-data.aspx">save them to Azure</a> along with all of their data.
</p>
<blockquote>
In my <a href="http://blogs.msdn.com/b/silverlining/archive/2011/10/18/handling-php-sessions-in-windows-azure.aspx">last post</a>, I looked at the session handling functionality that is built into the <a href="http://phpazure.codeplex.com/">Windows Azure SDK for PHP</a>, which uses <a href="http://www.microsoft.com/windowsazure/features/storage/">Azure Tables or Azure Blobs</a> for storing session data. As I wrote that post, I wondered how easy it would be to use <a href="http://msdn.microsoft.com/en-us/library/ee336241.aspx">SQL Azure</a> to store session data, especially since using a database to store session data is a common and familiar practice when building distributed PHP applications.  As I found out, using SQL Azure to store session data was relatively easy (as I'll show in this post), but I did run into a couple of small hurdles that might be worth taking note of.
</blockquote>
<p>
He uses PHP's own <a href="http://us2.php.net/session_set_save_handler">session_set_save_handler</a> to point to his custom Azure handling class with the needed methods (like write, close and destroy). He breaks it out into three simple steps, some with a bit of code attached:
</p>
<ul>
<li>Create the database, table, and stored procedure
<li>Add the SqlAzureSessionHandler class to your project
<li>Instantiate SqlAzureSessionHandler before calling session functions as you normally would
</ul>
<p>
The code for the Azure handling class can be downloaded <a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-22-76-75/SqlAzureSessionHandler.zip">here</a>.
</p>]]></description>
      <pubDate>Fri, 21 Oct 2011 08:32:46 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Developer Drive Blog: How to Prevent a SQL Injection Attack]]></title>
      <guid>http://www.phpdeveloper.org/news/16994</guid>
      <link>http://www.phpdeveloper.org/news/16994</link>
      <description><![CDATA[<p>
From the Developer Drive blog there's a recent post with some suggestions on how you can help to <a href="http://www.developerdrive.com/2011/10/how-to-prevent-a-sql-injection-attack/">prevent SQL injections</a> in your PHP application and make it that much harder for would-be attackers to do what they shouldn't.
</p>
<blockquote>
Why do SQL injections happen so often?
The shortest answer is that SQL injections are so popular because of poor programming. Hackers know about the potential of a successful SQL injection attack and they search for vulnerabilities. Unfortunately, very often they don't have to search hard - vulnerabilities pop right in their face. [...] The good news is that fortunately, SQL injections are also relatively easy to prevent.
</blockquote>
<p>They list nine easy things you can do to help prevent the attacks:</p>
<ul>
<li>Patch your SQL server regularly
<li>Limit the use of dynamic queries
<li>Escape user input
<li>Store database credentials in a separate file
<li>Use the principle of least privilege
<li>Turn magic quotes off
<li>Disable shells
<li>Disable any other DB functionality you don't need
<li>Test your code
</ul>]]></description>
      <pubDate>Fri, 14 Oct 2011 09:25:12 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Sameer Borate's Blog: Splitting large MySQL dump files]]></title>
      <guid>http://www.phpdeveloper.org/news/16937</guid>
      <link>http://www.phpdeveloper.org/news/16937</link>
      <description><![CDATA[<p>
In a new post to his blog <i>Sameer Borate</i> includes a handy bit of code you can use to <a href="http://www.codediesel.com/php/splitting-large-mysql-dump-files/">split up a large MySQL dump file</a> into smaller, easier to digest chunks.
</p>
<blockquote>
One of the frustrating things with working with MySQL is of importing large sql dump files. Either you get a 'max execution time exceeded' error from PHP or a 'Max_allowed_packet_size' from MySQL. In a recent task I needed to import a table of around a million records on a remote host, which quickly became an exercise in frustration due to various limitations on the server. SSH was of no help as changing the configuration files was restricted to the root user. My last resort was to split the huge 'INSERT' statements into smaller size files. 
</blockquote>
<p>
His script needs a little extra time to run (he sets max execute to 600 seconds) and takes the SQL file in line by line, splitting them back out to over files based on a "count" value - "dump-split-*". Depending on the size of your files, using something like this might not be an option. You might need something more like the <a href="http://kb.iu.edu/data/afar.html">command line "split" feature</a> to keep it outside of PHP's memory management all together.
</p>]]></description>
      <pubDate>Mon, 03 Oct 2011 08:44:43 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Brian Swan's Blog: Do Stored Procedures Protect Against SQL Injection?]]></title>
      <guid>http://www.phpdeveloper.org/news/15922</guid>
      <link>http://www.phpdeveloper.org/news/15922</link>
      <description><![CDATA[<p>
<i>Brian Swan</i> has a new post answering a question he's gotten about the stored procedures that the SQL Server database includes and whether or not they <a href="http://blogs.msdn.com/b/brian_swan/archive/2011/02/16/do-stored-procedures-protect-against-sql-injection.aspx">help prevent SQL injections</a> in your applications.
</p>
<blockquote>
When I've asked people about their strategies for preventing SQL injection, one response is sometimes "I use stored procedures." But, stored procedures do not, by themselves, necessarily protect against SQL injection. The usefulness of a stored procedure as a protective measure has everything to do with how the stored procedure is written. Write a stored procedure one way, and you can prevent SQL Injection. Write it another way, and you are still vulnerable. 
</blockquote>
<p>
The short answer is "not always" but he gets into a more detailed answer with a sample login script and the SQL to create the stored procedure the "wrong way" (using the value dynamically in the SQL of the procedure) and the "right way" (assigning them directly like bound variables).
</p>]]></description>
      <pubDate>Thu, 17 Feb 2011 11:46:14 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Rafael Dohms' Blog: Using theFacebook PHP-SDK to run FQL]]></title>
      <guid>http://www.phpdeveloper.org/news/15729</guid>
      <link>http://www.phpdeveloper.org/news/15729</link>
      <description><![CDATA[<p>
<i>Rafael Dohms</i> has a new post to his blog today looking at using the <a href="http://blog.rafaeldohms.com.br/2011/01/12/using-the-facebook-php-sdk-to-run-fql/">Facebook PHP-SDK to run FQL</a> queries on the data for your applications.
</p>
<blockquote>
The new SDKs have not, as you can say, fallen far from the tree. While they are really great new and shiny, documentation on how to use them is still vague, missing or spread out in the internet in blogs like these, in posts from us users trying to share the information with other soon-to-be-suffering developers. So this is an example of this, i have been using these new resources and the new PHP-SDK and have ran into various walls, so I decided to start putting some of this on my blog, for 2 reasons: to spread the word, and to have notes for myself when I come back to this.
</blockquote>
<p>
<a href="http://blog.rafaeldohms.com.br/2011/01/12/using-the-facebook-php-sdk-to-run-fql/">The post</a> gives an example of using the "api" method provided by the <a href="https://github.com/facebook/php-sdk">PHP SDK</a> from Facebook to push an array of parameters, one being the query, to the remote API for parsing. He includes the code for a simple (namespaced) helper to take in the query and return the API's return data set.
</p>]]></description>
      <pubDate>Wed, 12 Jan 2011 13:19:21 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Sameer Borate' Blog: Creating SQL schemas with Doctrine DBAL]]></title>
      <guid>http://www.phpdeveloper.org/news/15621</guid>
      <link>http://www.phpdeveloper.org/news/15621</link>
      <description><![CDATA[<p>
On his blog today <i>Sameer Borate</i> has a new post looking at <a href="http://www.codediesel.com/mysql/creating-sql-schemas-with-doctrine-dbal">using Doctrine DBAL to make schemas</a> rather than having to make them by hand each time (can be very useful for reloads with fixtures).
</p>
<blockquote>
A tedious task during web development is that of database schema creation. A schema containing a few tables comprising of a small set of rows is quick, while that containing dozens of tables and large numbers of columns is a tedious process. I usually resort to a small php script with some regular expression tossed in to automatically create a schema from a text file definition. But that is a little buggy as I've to manually add the indexes and other small things. Now that Doctrine has released a DBAL library, this will provide a nice ability to automatically create sql schemas.
</blockquote>
<p>
He introduces the <a href="http://www.doctrine-project.org/projects">DBAL abstraction layer</a> and includes a basic script to create a schema for a MySQL database, manually adding the columns and setting up things like primary keys and foreign key constraints. He also includes the SQL statements that it will generate and execute on your Doctrine-based connection.
</p>]]></description>
      <pubDate>Wed, 22 Dec 2010 14:25:53 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Brian Swan's Blog: Consuming SQL Azure Data with the OData SDK for PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/14903</guid>
      <link>http://www.phpdeveloper.org/news/14903</link>
      <description><![CDATA[<p>
<i>Brian Swan</i> has a new post to his MSDN blog today about <a href="http://blogs.msdn.com/b/brian_swan/archive/2010/08/03/consuming-sql-azure-data-with-the-odata-sdk-for-php.aspx">using the OData SDK</a> to consume Azure data (ODP is the Open Data Protocol that's <a href="http://blogs.msdn.com/b/sqlazure/archive/2010/07/20/10040378.aspx">been defined</a>). The OData interfaces is a REST-based service used to grab data from multiple types of data sources.
</p>
<blockquote>
The SQL Azure OData Service incubation (currently in <a href="http://www.sqlazurelabs.com/">SQL Azure Labs</a>) provides an OData interface to SQL Azure databases that is hosted by Microsoft. Another way to think about this is that SQL Azure OData Service provides a REST interface to your SQL Azure data.
</blockquote>
<p>
He shows you how to create the SQL Azure Server, make a SQL Azure database and creating the SQL Azure OData service. Then, with that all set up, you can use <a href="http://blogs.msdn.com/b/brian_swan/archive/2010/03/18/using-the-odata-sdk-for-php.aspx">this other tutorial</a> to connect your script to this new service.
</p>]]></description>
      <pubDate>Wed, 04 Aug 2010 11:22:56 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Gennady Feldman's Blog: Oracle query validation]]></title>
      <guid>http://www.phpdeveloper.org/news/14561</guid>
      <link>http://www.phpdeveloper.org/news/14561</link>
      <description><![CDATA[<p>
<i>Gennady Feldman</i> has put together <a href="http://www.gena01.com/forum/gena01-blog/oracle-query-validation/msg1505/#msg1505">a new post for his site</a> today looking at a recent situation he had with validating SQL queries for use with an Oracle database.
</p>
<blockquote>
So we got an interesting use case at work where we have an admin interface to setup filters in our system. Our staff is able to enter expressions in the web interface and we have a way of checking that whatever they enter is valid or not. While trying to optimize the validation code to do stricter checking with lower overhead I ran into a little gotcha. oci_parse() function doesn't actually do validation. This was a huge surprise to me and something I didn't grok.
</blockquote>
<p>
Frustrated by the fact that the <a href="http://php.net/oci_parse">oci_parse</a> function didn't seem to really do much more than bind variables and prepare the SQL for insert, he searched until he came across an interesting optional flag for <a href="http://www.php.net/manual/en/function.oci-execute.php">oci_execute</a>, OCI_DESCRIBE_ONLY. This flag returns some explain information by default and, if the query is invalid, returns an error.
</p>]]></description>
      <pubDate>Wed, 26 May 2010 11:47:06 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Sameer Borate's Blog: Benchmarking Wordpress SQL using FirePHP]]></title>
      <guid>http://www.phpdeveloper.org/news/14026</guid>
      <link>http://www.phpdeveloper.org/news/14026</link>
      <description><![CDATA[<p>
WordPress users out there might find the latest post from <i>Sameer Borate</i> interesting if they're looking to squeeze the most performance out of their installation. It's a guide to using the <a href="https://addons.mozilla.org/en-US/firefox/addon/6149/">FirePHP</a> plugin for Firefox to <a href="http://www.codediesel.com/mysql/benchmarking-wordpress-sql-using-firephp/">benchmark your WordPress install's SQL</a>.
</p>
<blockquote>
The first thing you can do to rectify the situation is to find out where exactly the bottleneck resides by analyzing the time each SQL query takes to executes. Some inquisitive people among you may also be interested in knowing in what sequence the Wordpress SQL queries themselves are being run.
</blockquote>
<p>
His method of benchmarking the SQL for the application uses some of the built in query logging in WordPress and some code dropped into your footer of your template to grab that information and push it back out to the waiting FireBug panel in your browser. The result looks <a href="http://www.codediesel.com/wp-content/uploads/2010/02/firephp.gif">something like this</a>.
</p>]]></description>
      <pubDate>Mon, 15 Feb 2010 10:47:12 -0600</pubDate>
    </item>
  </channel>
</rss>

