<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-411192463440726289</id><updated>2011-11-27T19:22:22.603-05:00</updated><title type='text'>Web Quirks</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://phpquirks.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/411192463440726289/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://phpquirks.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Jason</name><uri>http://www.blogger.com/profile/00489496856755184870</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://4.bp.blogspot.com/-ICrk1TFfN4s/TimsDKoczDI/AAAAAAAAAcM/6Au4EVw5h1M/s220/jrennie-defense-crop.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-411192463440726289.post-5938734728776126984</id><published>2011-04-25T18:23:00.000-04:00</published><updated>2011-04-25T18:23:04.637-04:00</updated><title type='text'>How To Get Around The New York Times Paywall</title><content type='html'>&lt;p&gt;The &lt;a href="http://www.nytimes.com/"&gt;New York Times&lt;/a&gt; will now allow you to see a limited number of articles (20?) before "enforcing" a paywall, showing you a preview of each article and pointing you toward a subscription page.  But, this paywall is about as leaky as a BP blowout preventer.  Search for the title of the article on &lt;a href="http://news.google.com/"&gt;Google News&lt;/a&gt;, click the first link, and, voila!  Paywall removed.  Apparently, the NYTimes wants to have its cake and eat it too.  They want to keep all the revenue generated by ads and search traffic, and add a paid subscription revenue stream.  I pay $5/year for ad-free access to &lt;a href="http://www.wunderground.com/"&gt;The Wunderground&lt;/a&gt;.  I don't see why I should be paying almost $200/year for a subscription that doesn't even get rid of the ads, especially when I can find comparable content elsewhere...&lt;br /&gt;
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/411192463440726289-5938734728776126984?l=phpquirks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpquirks.blogspot.com/feeds/5938734728776126984/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpquirks.blogspot.com/2011/04/how-to-get-around-new-york-times.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/411192463440726289/posts/default/5938734728776126984'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/411192463440726289/posts/default/5938734728776126984'/><link rel='alternate' type='text/html' href='http://phpquirks.blogspot.com/2011/04/how-to-get-around-new-york-times.html' title='How To Get Around The New York Times Paywall'/><author><name>Jason</name><uri>http://www.blogger.com/profile/00489496856755184870</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://4.bp.blogspot.com/-ICrk1TFfN4s/TimsDKoczDI/AAAAAAAAAcM/6Au4EVw5h1M/s220/jrennie-defense-crop.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-411192463440726289.post-2812376054631412252</id><published>2011-04-05T22:30:00.003-04:00</published><updated>2011-04-06T10:20:18.582-04:00</updated><title type='text'>Rewriting the Envelope "From" Address</title><content type='html'>&lt;p&gt;I use &lt;a href="http://authsmtp.com"&gt;AuthSMTP&lt;/a&gt; for mail delivery when sending automated emails via my web server.  Recently, I noticed that they were failing:&lt;br /&gt;
&lt;blockquote&gt;Real domain name required for sender address (in reply to MAIL FROM command)&lt;br /&gt;
&lt;/blockquote&gt;The web server was using &lt;code&gt;www-data@localhost&lt;/code&gt; as the envelope "from" address and AuthSMTP didn't like such a bogus domain.&lt;br /&gt;
&lt;/p&gt;&lt;p&gt;While reading/searching the &lt;a href="http://www.postfix.org/documentation.html"&gt;postfix documentation&lt;/a&gt;, I discovered that postfix can rewrite such local/bogus email addresses automagically.  See the section on &lt;a href="http://www.postfix.org/ADDRESS_REWRITING_README.html#generic"&gt;Generic mapping for outgoing SMTP mail&lt;/a&gt;.&lt;br /&gt;
&lt;/p&gt;&lt;p&gt;But postfix died after I customized the example and tried to restart postfix.  The example forgot to mention that the mapping needs to be encoded in a database format in order for postfix to read it.  After you create a file named &lt;code&gt;generic&lt;/code&gt; in &lt;code&gt;/etc/postfix&lt;/code&gt;, you need to run:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;sudo postmap hash:generic
&lt;/code&gt;&lt;/pre&gt;from the &lt;code&gt;/etc/postfix&lt;/code&gt; directory.  This will create a Berkeley DB file with the same information as your plain-text file.&lt;br /&gt;
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/411192463440726289-2812376054631412252?l=phpquirks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpquirks.blogspot.com/feeds/2812376054631412252/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpquirks.blogspot.com/2011/04/rewriting-envelope-from-address.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/411192463440726289/posts/default/2812376054631412252'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/411192463440726289/posts/default/2812376054631412252'/><link rel='alternate' type='text/html' href='http://phpquirks.blogspot.com/2011/04/rewriting-envelope-from-address.html' title='Rewriting the Envelope &quot;From&quot; Address'/><author><name>Jason</name><uri>http://www.blogger.com/profile/00489496856755184870</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://4.bp.blogspot.com/-ICrk1TFfN4s/TimsDKoczDI/AAAAAAAAAcM/6Au4EVw5h1M/s220/jrennie-defense-crop.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-411192463440726289.post-2587493397067919715</id><published>2010-09-17T22:29:00.003-04:00</published><updated>2010-09-20T10:05:28.066-04:00</updated><title type='text'>$GLOBALS or global?</title><content type='html'>&lt;p&gt;I recently upgraded to &lt;a href="http://www.ubuntu.com/"&gt;Ubuntu 10.04&lt;/a&gt; which includes &lt;a href="http://www.php.net/"&gt;php&lt;/a&gt; 5.3.2.  Not long after upgrading, I noticed that transactions in my stock tracking program were no longer sorting correctly.  At first, I thought the sort function, &lt;a href="http://php.net/manual/en/function.uksort.php"&gt;&lt;tt&gt;uksort&lt;/tt&gt;&lt;/a&gt;, might have subtly changed.  But, no, the manual didn't mention anything, and the manual and comment examples appeared to line-up with my code nicely.&lt;br /&gt;
&lt;/p&gt;&lt;p&gt;Next, I checked the apache error log where I got my first clue as to the madness I was about to uncover:&lt;br /&gt;
&lt;pre&gt;PHP Warning:  uksort(): Array was modified by the user comparison function in ... on line 195
&lt;/pre&gt;I double-checked my code.  Nope.  No modification of the array being sorted.  What gives?  I was using a &lt;a href="http://php.net/manual/en/language.variables.scope.php"&gt;&lt;tt&gt;global&lt;/tt&gt;&lt;/a&gt; statement so that I could access the array being sorted...&lt;br /&gt;
&lt;/p&gt;&lt;p&gt;A &lt;a href="http://www.google.com/search?q=php+global"&gt;Google search on the &lt;tt&gt;global&lt;/tt&gt; statement&lt;/a&gt; turned up another way to access global variables, the &lt;a href="http://php.net/manual/en/reserved.variables.globals.php"&gt;&lt;tt&gt;$GLOBALS&lt;/tt&gt;&lt;/a&gt; array.  Could php be overzealously assuming that access of a variable via a &lt;tt&gt;global&lt;/tt&gt; statement constitutes modification?  Well, maybe using &lt;tt&gt;$GLOBALS&lt;/tt&gt; would solve that problem.&lt;br /&gt;
&lt;/p&gt;&lt;p&gt;I switched from &lt;tt&gt;global&lt;/tt&gt; to &lt;tt&gt;$GLOBALS&lt;/tt&gt;, and, voila, sorting worked again!  Apparently php does equate using a global variable via the &lt;tt&gt;global&lt;/tt&gt; statement to modification of that variable.  Geez!&lt;br /&gt;
&lt;/p&gt;&lt;p&gt;P.S. &lt;tt&gt;uksort&lt;/tt&gt; was returning a false value indicating that the sort had failed.&lt;br /&gt;
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/411192463440726289-2587493397067919715?l=phpquirks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpquirks.blogspot.com/feeds/2587493397067919715/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpquirks.blogspot.com/2010/09/globals-or-global.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/411192463440726289/posts/default/2587493397067919715'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/411192463440726289/posts/default/2587493397067919715'/><link rel='alternate' type='text/html' href='http://phpquirks.blogspot.com/2010/09/globals-or-global.html' title='$GLOBALS or global?'/><author><name>Jason</name><uri>http://www.blogger.com/profile/00489496856755184870</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://4.bp.blogspot.com/-ICrk1TFfN4s/TimsDKoczDI/AAAAAAAAAcM/6Au4EVw5h1M/s220/jrennie-defense-crop.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-411192463440726289.post-4640281920917511662</id><published>2010-01-07T10:07:00.004-05:00</published><updated>2010-09-20T10:05:16.760-04:00</updated><title type='text'>GoDaddy disallows 3rd party SMTP relay</title><content type='html'>&lt;p&gt;My wife has been using &lt;a href="http://www.godaddy.com/"&gt;GoDaddy&lt;/a&gt; to host her web site, &lt;a href="http://www.helenrennie.com/kitchen/"&gt;Helen's Kitchen&lt;/a&gt;, for about four years now.  She's generally been happy with it.  That is, until now. &lt;/p&gt;&lt;p&gt;First, I should clarify.  The web and mysql server services provided by GoDaddy are still solid---besides occasional slowness and an occasional brief outage, there has been little to complain about (though wading through the 1000 useless offers in order to do anything on the GoDaddy site is a bit of a pain).  The problem has been with email relaying.  Helen's site sends her and customers email(s) when users sign up for classes.  Once or twice in the past, there have been multi-hour email backups where emails would not be sent from GoDaddy's servers until many hours after they were entered into the mail queue by Helen's web site.  These were annoying, but GoDaddy was responsive and addressed the problem fairly quickly. &lt;/p&gt;&lt;p&gt;E-mail is once again a problem.  But, whereas GoDaddy has fixed the problem quickly in the past, Helen is now waiting on emails that were queued &lt;b&gt;4&lt;/b&gt; days ago.  And, it is very clearly a problem of GoDaddy simply getting the messages out-the-door and not due to intermediate servers.  As of 2 days ago, GoDaddy had officially recognized the problem and was "working on it."  But, the problem still hadn't been resolved as of late last night.  Our first response was to seek a 3rd party SMTP relay provider.  But after signing-up with &lt;a href="http://www.authsmtp.com/"&gt;AuthSMTP&lt;/a&gt;, and running a successful test from my home machine, we learned that GoDaddy blocks all outgoing TCP connections from their shared web hosting servers, making it &lt;b&gt;quite&lt;/b&gt; challenging to send email via a 3rd party provider. &lt;/p&gt;&lt;p&gt;GoDaddy representatives keep telling us that we should just upgrade to a virtual dedicated server (for 5x the price!).  This would allow us to make outgoing TCP connections.  But, a quick chat with a &lt;a href="http://www.justhost.com/"&gt;justhost&lt;/a&gt; representative indicates that they would allow an outgoing TCP connection (so that we could do 3rd party SMTP relaying) once we convince them we aren't going to use it to spam.  So, I don't understand why we should pay GoDaddy more money when the level of service seems to be falling.  What I find especially surprising about all this is that the requirements for my wife's web site are &lt;i&gt;tiny&lt;/i&gt;: 1000s of uniques/month; the entire database is less than 100k uncompressed.  So, we might just have to switch to another web provider... &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/411192463440726289-4640281920917511662?l=phpquirks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpquirks.blogspot.com/feeds/4640281920917511662/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpquirks.blogspot.com/2010/01/godaddy-disallows-3rd-party-smtp-relay.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/411192463440726289/posts/default/4640281920917511662'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/411192463440726289/posts/default/4640281920917511662'/><link rel='alternate' type='text/html' href='http://phpquirks.blogspot.com/2010/01/godaddy-disallows-3rd-party-smtp-relay.html' title='GoDaddy disallows 3rd party SMTP relay'/><author><name>Jason</name><uri>http://www.blogger.com/profile/00489496856755184870</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://4.bp.blogspot.com/-ICrk1TFfN4s/TimsDKoczDI/AAAAAAAAAcM/6Au4EVw5h1M/s220/jrennie-defense-crop.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-411192463440726289.post-5349263539327767259</id><published>2009-10-12T15:26:00.000-04:00</published><updated>2009-10-12T16:29:30.049-04:00</updated><title type='text'>Better access to properties/attributes</title><content type='html'>Iterating through an object's properties/attributes is something you can easily do with &lt;tt&gt;__dict__&lt;/tt&gt; in Python.  PHP doesn't automatically give you this feature, but you can build it in via the &lt;tt&gt;__get&lt;/tt&gt; and &lt;tt&gt;__set&lt;/tt&gt; overloads.  It requires that you follow a certain class definition pattern, but it should not be hard to add this pattern after a class is established:
&lt;pre&gt;
class Foo {
  private $data = array();
  function __get($k) {
    return $this-&gt;data[$k];
  }
  function __set($k, $v) {
    $this-&gt;data[$k] = $v;
  }
  function __isset($k) {
    return isset($this-&gt;data[$k]);
  }
  function __unset($k) {
    unset($this-&gt;data[$k]);
  }
}
&lt;/pre&gt;
The &lt;tt&gt;$data&lt;/tt&gt; attribute acts as the object itself; &lt;tt&gt;__get&lt;/tt&gt; and &lt;tt&gt;__set&lt;/tt&gt; translate between object property and array entry requests.  &lt;tt&gt;__isset&lt;/tt&gt; and &lt;tt&gt;__unset&lt;/tt&gt; handle &lt;tt&gt;sset()&lt;/tt&gt; and &lt;tt&gt;unset()&lt;/tt&gt; calls (only PHP 5.1.0+).  Documentation can be found in the &lt;a href="http://www.php.net/manual/en/language.oop5.overloading.php"&gt;Overloading section of the PHP manual&lt;/a&gt;.

Once you've implemented this pattern, it's trivial to access the object's attributes as an &lt;a href="http://php.net/manual/en/language.types.array.php"&gt;array&lt;/a&gt; which means that it's easy to iterate over entries.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/411192463440726289-5349263539327767259?l=phpquirks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpquirks.blogspot.com/feeds/5349263539327767259/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://phpquirks.blogspot.com/2009/10/better-access-to-propertiesattributes.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/411192463440726289/posts/default/5349263539327767259'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/411192463440726289/posts/default/5349263539327767259'/><link rel='alternate' type='text/html' href='http://phpquirks.blogspot.com/2009/10/better-access-to-propertiesattributes.html' title='Better access to properties/attributes'/><author><name>Jason</name><uri>http://www.blogger.com/profile/00489496856755184870</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://4.bp.blogspot.com/-ICrk1TFfN4s/TimsDKoczDI/AAAAAAAAAcM/6Au4EVw5h1M/s220/jrennie-defense-crop.jpg'/></author><thr:total>0</thr:total></entry></feed>
