<?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>Thu, 23 May 2013 23:28:46 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[PHPMaster.com: Generating One-Time Use URLs]]></title>
      <guid>http://www.phpdeveloper.org/news/19440</guid>
      <link>http://www.phpdeveloper.org/news/19440</link>
      <description><![CDATA[<p>
On PHPMaster.com there's a new tutorial posted showing you how to <a href="http://phpmaster.com/generating-one-time-use-urls/">generate one-time use URLs</a> that could be used for various things across an application, including things like account verification links.
</p>
<blockquote>
A one-time URL is a specially crafted address that is valid for one use only. It's usually provided to a user to gain privileged access to a file for a limited time or as part of a particular activity, such as user account validation. In this article I'll show how to generate, implement, and expire one-time URLs.
</blockquote>
<p>
Included in the post is the SQL to create a sample "pending_users" table that includes a "token" column for storing the generated hash. Code is also included for generating the hash and checking the incoming URL to see if it matches the requested user (and hasn't expired). 
</p>
<blockquote>
As a matter of general house keeping you could write a secondary script to keep expired tokens from accumulating in the database if a user never follows them. The script could be run periodically by an administrator, or preferably set up as a scheduled task or cron job and run automatically.
</blockquote>
Link: http://phpmaster.com/generating-one-time-use-urls]]></description>
      <pubDate>Wed, 10 Apr 2013 11:18:56 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: Building Your Own URL Shortener]]></title>
      <guid>http://www.phpdeveloper.org/news/18506</guid>
      <link>http://www.phpdeveloper.org/news/18506</link>
      <description><![CDATA[<p>
On PHPMaster.com today, there's a new tutorial walking you through the <a href="http://phpmaster.com/building-your-own-url-shortener/">creation of a URL shortner</a> - a simple tool that can be used to compact URLs into something easier to manage (and more friendly with services like Twitter).
</p>
<blockquote>
Most of us are familiar with seeing URLs like bit.ly or t.co on our Twitter or Facebook feeds. These are examples of shortened URLs, which are a short alias or pointer to a longer page link.  [...] In this article you'll learn how to create a fully functional URL shortener for your website that will work whether you use a front controller/framework or not. If you use a front controller, I'll discuss you how to easily integrate this URL shortener without having to dig into the controller's programming.
</blockquote>
<p>
They help you create a simple database to hold the link relationships, the PHP code to create the randomized hash that represents the link and the code to shorten it. There's also the PHP code to take it the other way and decode the shortened version into the full URL. You can find the full code (ready for checkout) over on <a href="https://github.com/phpmasterdotcom/BuildingYourOwnURLShortener">the PHPMaster.com Github account</a>.
</p>]]></description>
      <pubDate>Fri, 21 Sep 2012 12:58:00 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[David M&uuml;ller: Why URL validation with filter_var might not be a good idea]]></title>
      <guid>http://www.phpdeveloper.org/news/18498</guid>
      <link>http://www.phpdeveloper.org/news/18498</link>
      <description><![CDATA[<p>
<i>David M&uuml;ller</i> has a new post to his site today showing why <a href="http://www.d-mueller.de/blog/why-url-validation-with-filter_var-might-not-be-a-good-idea/">validating URLs with filter_var</a> is a good thing for the security of your application.
</p>
<blockquote>
Since PHP 5.2 brought us the filter_var function, the time of such [regular expressions-based] monsters was over. [With] the simple, yet effective syntax [and] with a third parameter, filter flags can be passed, [...] 4 flags are available [for URL filtering].
</blockquote>
<p>
He shows how to use it to filter out a simple <a href="http://en.wikipedia.org/wiki/Cross-site_scripting">XSS</a> issue (a "script" tag in the URL) and some examples of issues that the <a href="http://php.net/filter_var">filter_var</a> function doesn't prevent - like injection of other schemes (like "php://" or "javascript://"). He recommends adding a wrapper around the method to check for the correct scheme (ex. "http" or "https" for URLs) and reminds you that filter_var is not multibyte capable.
</p>]]></description>
      <pubDate>Thu, 20 Sep 2012 08:09:31 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Design Aeon: Check Dead Links From Database Using PHP CURL]]></title>
      <guid>http://www.phpdeveloper.org/news/18105</guid>
      <link>http://www.phpdeveloper.org/news/18105</link>
      <description><![CDATA[<p>
On DesignAeon.com there's a recent tutorial posted showing you how to extract URLs from your database and <a href="http://www.designaeon.com/check-dead-links-from-database-using-php-curl/">determine which ones are "dead"</a> automatically with the help of <a href="http://php.net/curl">cURL</a>.
</p>
<blockquote>
Checking Deadlinks From the database manually is a Headache ,So why not use a script which return the http status of the particular link and tell us if the link is dead or not.So how do we check the dead links from the database ? How do we programatically  check whether the link is dead or not ? To check broken or dead links from Database we will use curl .
</blockquote>
<p>
Included in the post is a <a href="http://www.designaeon.com/check-dead-links-from-database-using-php-curl/">sample script</a> that extracts the URLs from a field in the database (you'd need some extra smarts if you're pulling it from content) and running it though a "checklink" function. If the call to <a href="http://php.net/curl_getinfo">curl_getinfo</a> returns false, the link is marked dead.
</p>]]></description>
      <pubDate>Mon, 18 Jun 2012 09:45:55 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Gaurish Patil's Blog: URL rewriting in Yii to hide index.php]]></title>
      <guid>http://www.phpdeveloper.org/news/17844</guid>
      <link>http://www.phpdeveloper.org/news/17844</link>
      <description><![CDATA[<p>
In <a href="http://gaurishpatil.wordpress.com/2012/04/19/url-rewriting-in-yii-to-hide-index-php/">this new post</a> to his blog <i>Gaurish Patil</i> shows users of the <a href="http://www.yiiframework.com/">Yii framework</a> how they can update their configuration settings to hide the "index.php" in their requests and make cleaner URLs.
</p>
<blockquote>
Finally we figure out the basics of  Yii. While working on basic of Yii, I want to rewrite the url to SEO friendly. So I started to search on google, forum got useful information here http://www.yiiframework.com/doc/guide/1.1/en/topics.url To hide the index.php from url I did changes in config/main.php [...] and I created new .htaccess file in the same directory as my index.php file.
</blockquote>
<p>
The changes are pretty simple - it's mostly a change to the "urlManager" setting to provide some rules for mapping controller and actions to the right place. The .htaccess file uses Apache's mod_rewrite functionality to grab the requested URL and remap it back to lay on top of the "index.php" front controller for the request.
</p>]]></description>
      <pubDate>Fri, 20 Apr 2012 09:27:06 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Sharon Levy's Blog: PHP Version]]></title>
      <guid>http://www.phpdeveloper.org/news/17353</guid>
      <link>http://www.phpdeveloper.org/news/17353</link>
      <description><![CDATA[<p>
<i>Sharon Levy</i> has a new post to her blog showing a trick she's come up with to show the PHP version information (usually found in the <a href="http://php.net/phpinfo">phpinfo</a>) <a href="http://slevy1.wordpress.com/2011/12/12/php-version/#more-2225">even when it's disabled</a>.
</p>
<blockquote>
Sometimes the most crucial, basic piece of information can seem so hard to find. For example, suppose you wanted to find out what version of PHP your remote webhost provides to shared hosting users? What would you do? [...] For development purposes it can be helpful having phpinfo() available, but on a live shared host, you may discover as I did recently that it is no longer available; your host may have disabled it.
</blockquote>
<p>
She includes three other ways you can use to get the version of PHP you're working with:
</p>
<ul>
<li>If you have command line access, running "php -v"
<li>Using the <a href="http://php.net/phpversion">phpversion</a> function (or PHP_VERSION constant)
<li>Appending a certain value to the URL (only works in some cases)
</ul>]]></description>
      <pubDate>Thu, 05 Jan 2012 13:20:40 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Sameer Borate's Blog: Grabbing the referrer search engine keywords for a site]]></title>
      <guid>http://www.phpdeveloper.org/news/17009</guid>
      <link>http://www.phpdeveloper.org/news/17009</link>
      <description><![CDATA[<p>
On his blog today <i>Sameer Borate</i> has a new post with a handy bit of code you can use to <a href="http://www.codediesel.com/php/grabbing-the-referrer-search-engine-keywords-for-a-site/">find the keywords from a search engine referral</a> to help with tracking how visitors have come to your site.
</p>
<blockquote>
A couple of weeks back I had to write a solution for a client to track the referrer search engine from where the user came to his sites contact page, without using Google Analytics. If a user was to fill the contact form on the website, the referring search engine name and the keyword for which it was refereed was to be emailed along with the contact information. The following is a solution for the same.
</blockquote>
<p>
The code itself is pretty simple - it checks the $_SERVER['HTTP_REFERER'] and, based on an array of search engine types, looks for a certain "query" keyname in the URL and matches what follows (with <a href="http://php.net/preg_match">a regular expression</a>). This can be useful for not only determining what sort of audience is visiting your site, but could also be used to present a custom message to visitors from certain search engines (or, more complicated, to show different content based on search terms).
</p>]]></description>
      <pubDate>Tue, 18 Oct 2011 13:25:27 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Lars Tesmer's Blog: How to Unit Test a Class Making Calls to an URL (or the Filesystem) With PHPUnit]]></title>
      <guid>http://www.phpdeveloper.org/news/16889</guid>
      <link>http://www.phpdeveloper.org/news/16889</link>
      <description><![CDATA[<p>
<i>Lars Tesmer</i> has a suggestion for all of the unit testers out there (you do unit test your code, right?) when needing to test a piece of code that makes a call to something on the file system or a remote resource. Their examples come from tests written against the <a href="https://github.com/kriswallsmith/assetic">Assetic</a> codebase.
</p>
<blockquote>
For our most recent <a href="http://lars-tesmer.com/blog/categories/after-work-hacking/">After Work Hacking</a> my co-workers and me decided to write unit tests for the open source project <a href="https://github.com/kriswallsmith/assetic">Assetic</a>. That turned out to be a better decision than our last one, yet we still ran into an interesting challenge.
</blockquote>
<p>
In testing the HttpAsset class from the tool, they came across the problem - a call to a remote/file resource that could not be tested because of a <a href="http://php.net/manual/en/function.file-get-contents.php">file_get_contents</a> call that depends on an external source. They came up with a few options to try to test this example, some better than others:
</p>
<ul>
<li>Give it a real URL to test with
<li>Wrap the file_get_contents inside of a new class (ex. a "ContentFetcher")
<li>Use <a href="https://github.com/mikey179/vfsStream">vfsStream</a> to mock out the file system in the unit test
</ul>
<p>
In their case, vfsStream couldn't be used due to how the fetch call was made, but the tool can be very handy if you need to mock out an external file system resource.
</p>]]></description>
      <pubDate>Wed, 21 Sep 2011 12:04:47 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Lorna Mitchell's Blog: ]]></title>
      <guid>http://www.phpdeveloper.org/news/16648</guid>
      <link>http://www.phpdeveloper.org/news/16648</link>
      <description><![CDATA[<p>
<i>Lorna Mitchell</i> has a quick post to her blog today showing how you can use a simple curl call from PHP to <a href="http://www.lornajane.net/posts/2011/Shortening-URLs-from-PHP-with-Bit.ly">shorten urls with bit.ly</a> and pull back the result.
</p>
<blockquote>
I've been looking around for a really simple API that would be a nice place to get started using web services from PHP - and I realised that <a href="http://bit.ly/">bit.ly</a> actually fits the bill really well. They have straightforward <a href="http://code.google.com/p/bitly-api/wiki/ApiDocumentation">api docs</a> on google code, and it's also a pretty simple function!
</blockquote>
<p>
Her code is about three lines consisting of a <a href="http://php.net/curl_init">curl_init</a> call to the bit.ly server with the URL, a <a href="http://php.net/curl_setopt">curl_setopt</a> to tell it to return the information and a <a href="http://php.net/curl_exec">curl_exec</a> to execute. The result is a JSON string easily decoded with a "url" parameter containing the newly minted short URL. She also briefly mentions some of the other features of the bit.ly API including reverse translation and bundling of links.
</p>]]></description>
      <pubDate>Thu, 28 Jul 2011 12:03:02 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Martin Sik's Blog: How to "steal" Google's "did you mean" feature]]></title>
      <guid>http://www.phpdeveloper.org/news/16363</guid>
      <link>http://www.phpdeveloper.org/news/16363</link>
      <description><![CDATA[<p>
In <a href="http://www.martinsikora.com/how-to-steal-google-s-did-you-mean-feature">a a new tutorial</a> posted on his blog <i>Martin Sik</i> shows you how to "steal" the "did you mean..." functionality that Google's sites currently offer. His example uses cURL to get the current Google request URLs and fetch the associated results.
</p>
<blockquote>
I really like Google and the classic "did you mean" feature is really great, unfortunately when I wanted to implement it into my project a realized that it's not provided by any of Google's APIs. [...] I believe for most developers [having a large dictionary and extend the dictionary when new terms are available] are unachievable. And so it's for me. So I was thinking if I can bypass these drawbacks and let Google do all the job for me.
</blockquote>
<p>
The source code is included  with the post showing two methods - fetching a "did you mean" block to parse or how a term is attached to a Google URL and the results are returned in JSON and parsed for display. Obviously, this is an external dependency you could consider if you put it into your application, but it can be quite a powerful tool in the right situations.
</p>]]></description>
      <pubDate>Thu, 19 May 2011 12:49:32 -0500</pubDate>
    </item>
  </channel>
</rss>
