<?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>Sheepdog IT &#187; php</title>
	<atom:link href="http://www.sheepdogit.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sheepdogit.com</link>
	<description>Herding Penguins for over 5 years</description>
	<lastBuildDate>Tue, 15 Jun 2010 20:35:17 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>&quot;No input file specified&quot; mod_rewrite Problem</title>
		<link>http://www.sheepdogit.com/2008/07/29/no-input-file-specified-mod_rewrite-problem/</link>
		<comments>http://www.sheepdogit.com/2008/07/29/no-input-file-specified-mod_rewrite-problem/#comments</comments>
		<pubDate>Wed, 30 Jul 2008 05:14:52 +0000</pubDate>
		<dc:creator>Bozzie</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://bozziesfw.wordpress.com/?p=68</guid>
		<description><![CDATA[I made several changes to some mod_rewrite rules which were working fine on my local Apache server.  I then published to a staging site hosted on GoDaddy for further testing.  The rules which directed permalinks to a PHP program stopped working; &#8220;no input file specified&#8221; appeared on my browser instead.  No access to [...]]]></description>
			<content:encoded><![CDATA[<p>I made several changes to some <em>mod_rewrite</em> rules which were working fine on my local Apache server.  I then published to a staging site hosted on GoDaddy for further testing.  The rules which directed permalinks to a PHP program stopped working; &#8220;no input file specified&#8221; appeared on my browser instead.  No access to the error logs on this bargain basement hosting plan makes debugging all but impossible.</p>
<p>I finally found <a title="No input file specified." href="http://forums.pligg.com/installation-upgrade-help/9711-solution-no-input-file-specified.html">this post</a> which presented a solution:</p>
<blockquote><p>&#8220;Turn off MultiViews. It seems when MultiViews is enabled there is confusion between MultiViews and the RewriteRules. So if you go to /user there will be no problem, MultiViews will translate it to /user.php. However when you go to /user/blah/login/blah or one of the other more complex clean URLs it gets confused.&#8221;</p></blockquote>
<p>Adding <em>&#8220;Options -Multiviews&#8221;</em> to my .htaccess file fixed the problem.  Not sure why this only happens on my GoDaddy account and not locally or at our other hosting accounts.  Is this the one and only error that results from Multiviews and ModRewrite colliding, or are there others?  If so, maybe I&#8217;ll shut off Multiviews on all my web sites until I need to add multiple language support.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sheepdogit.com/2008/07/29/no-input-file-specified-mod_rewrite-problem/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP Array Index Implicit Casts and uniqid()</title>
		<link>http://www.sheepdogit.com/2007/07/12/php-array-index-implicit-casts-and-uniqid/</link>
		<comments>http://www.sheepdogit.com/2007/07/12/php-array-index-implicit-casts-and-uniqid/#comments</comments>
		<pubDate>Thu, 12 Jul 2007 15:26:02 +0000</pubDate>
		<dc:creator>Bozzie</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://bozziesfw.wordpress.com/2007/07/12/php-array-index-implicit-casts-and-uniqid/</guid>
		<description><![CDATA[In addition to performing implicit string-to-number casts for arithmetic expressions,  PHP implicitly casts array keys in the same manner.  Thus, even if one puts an integer in quotes as an array key, PHP will convert it back to an integer.  However (as we learn from the response to Bug 21954) explicitly casting [...]]]></description>
			<content:encoded><![CDATA[<p>In addition to performing implicit string-to-number casts for arithmetic expressions,  PHP implicitly casts array keys in the same manner.  Thus, even if one puts an integer in quotes as an array key, PHP will convert it back to an integer.  However (as we learn from the response to <a href="http://bugs.php.net/bug.php?id=21954">Bug 21954</a>) <em>explicitly</em> casting the index to a string works.</p>
<p>So even though PHP claims to offer associative and indexed arrays, the implicit casting will be busily converting associative keys to index keys behind the curtain.  Things get particularly ugly with integers g.t. 2^32 (above bug report plus <a href="http://bugs.php.net/bug.php?id=34419">Bug 34419</a>).  And notice the snippy resolution comment: &#8220;<em>This hasn&#8217;t changed, will not change, and is not a bug.</em>&#8221;  So large integers that start off as strings are cast to integers, but being too large, are then converted to floats. That&#8217;s intuitive.</p>
<p>I was storing objects in an associative array, using the objects&#8217; id as the keys and I was generating the ids with <em>uniqid().</em> Uniqid generates 13 character strings that appear to be hexadecimal values cast to a string.  Most of these values will have an [<em>a-f</em>] character, but occasionally they contain only digits.  In this unfortunate case, these are cast to long integers then cast again to a float.  Except that I serialized one such array and saw a negative integer listed as the array key!  Whatever the exact mechanism, after unserialization I was unable to retrieve one object from an array, even using <em>array_keys().</em></p>
<p>This is a PHP language design flaw, in my opinion. The default unique-id generator generates values that randomly map into two disjoint sets of array keys: associative string keys or numeric index keys.  Given the schizophrenic array index casts, one would certainly expect uniqid() to uniformly generate strings or integers.  So at a cost of about 12 hours, I now know to use the optional prefix argument all the time.</p>
<p>Such problems are avoided in Perl because arrays are declared to be associative or numeric, so keys aren&#8217;t being cast behind one&#8217;s back.  PHP is younger than Perl, which I judge to be largely free from these types of asymmetries.  And I didn&#8217;t look through all of the remaining PHP bug reports after finding the info I needed: since two years have elapsed, maybe PHP has improved this by now.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sheepdogit.com/2007/07/12/php-array-index-implicit-casts-and-uniqid/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Web Hosting Notes, Requirements, Comparison</title>
		<link>http://www.sheepdogit.com/2007/06/03/web-hosting-notes-requirements-comparison/</link>
		<comments>http://www.sheepdogit.com/2007/06/03/web-hosting-notes-requirements-comparison/#comments</comments>
		<pubDate>Sun, 03 Jun 2007 11:12:04 +0000</pubDate>
		<dc:creator>Bozzie</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[WebHosting]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://bozziesfw.wordpress.com/2007/06/03/linux-isp-notes-requirements-comparison/</guid>
		<description><![CDATA[I now have 3 different Apache hosting environments: my openSUSE 10.2 workstation, GoDaddy, and A2Hosting. Signing up for a month is the only way to determine if a web application will work on an ISP&#8217;s service.  Their hosting environments are all slightly different.  Here are the issues I&#8217;ve encountered getting a PHP web [...]]]></description>
			<content:encoded><![CDATA[<p>I now have 3 different Apache hosting environments: my openSUSE 10.2 workstation, GoDaddy, and A2Hosting. Signing up for a month is the only way to determine if a web application will work on an ISP&#8217;s service.  Their hosting environments are all slightly different.  Here are the issues I&#8217;ve encountered getting a PHP web application running on each system.</p>
<h3>openSUSE 10.2</h3>
<ul>
<li>Apache2, PHP 5.2, mod_php, mod_rewrite.</li>
<li>PHP <i>magic_quotes_gpc</i> is set to <i>off</i> in openSUSE (the proper choice, but <i>not</i> the PHP default as I painfully learned when installing at the ISPs).</li>
<li>PEAR supported in the Apache PHP include path.</li>
<li>Subdirectories written into by the application (e.g. Smarty template compilation area) need world-write privilege.</li>
</ul>
<h3>GoDaddy Hosting</h3>
<ul>
<li>Apache1.3, PHP4 (5.1.4 optional), CGI/fastCGI, mod_rewrite.</li>
<li> Cannot use <i>php_flag</i> because using CGI, must use <i>php5.ini</i> instead.</li>
<li>Switch from PHP 4 to 5 in <i>.htaccess</i>:<br />
<i>AddHandler x-httpd-php5 .php<br />
AddHandler x-httpd-php  .php4</i></li>
<li>PHP <i>magic_quotes_gpc</i> on by default, turn off with local <i>php5.ini</i> file.</li>
<li>AllowOverride Options disabled, can&#8217;t use in <i>.htaccess</i>.</li>
<li>Files created by web site users (i.e. by the <i>httpd</i> user) have the same uid/gid as my ftp login user.  An excellent configuration approach, as I don&#8217;t need to give world write privileges to local data subdirectories.</li>
<li>ini_set(&#8217;session.cache_limiter&#8217;, &#8216;private&#8217;) causes server 500 error.</li>
</ul>
<h3>A2 Hosting</h3>
<ul>
<li>Apache 1.x (server_signature empty), PHP 5.2, mod_php, mod_rewrite.</li>
<li>PHP <i>magic_quotes_gpc</i> is on by default, turn off using <i>php_flag</i> (here is the <a href="http://us.php.net/manual/en/configuration.changes.php#configuration.changes.apache" title="PHP Manual"><i>Running PHP as an Apache Module</i></a> PHP man page describing how to use <i>php.ini </i>directives within <i>.htaccess</i>).</li>
<li>Subdirectories written to by the application need world-write privilege.  My ftp area is a <i>public_html</i> directory, so A2 uses <i>mod_userdir.</i> The home directory looks similar to my local workstation.</li>
<li>ini_set(&#8217;session.cache_limiter&#8217;, &#8216;private&#8217;) works fine. Moved this parameter to a <i>php_flag</i> directive.</li>
<li>A2 mentions PEAR support on their web page, but they don&#8217;t add the directory to the PHP include path and only offer a handful of modules.  Will add modules per customer request, but what will happen if they move my account to a different server?</li>
</ul>
<h3>Web Hosting Requirements</h3>
<ul>
<li>PHP Extensions: CURL, XMLWriter.</li>
<li>Apache Modules: rewrite.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.sheepdogit.com/2007/06/03/web-hosting-notes-requirements-comparison/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AWS S3, PHP Security for Shared Servers</title>
		<link>http://www.sheepdogit.com/2007/04/16/aws-s3-php-security-shared-server/</link>
		<comments>http://www.sheepdogit.com/2007/04/16/aws-s3-php-security-shared-server/#comments</comments>
		<pubDate>Tue, 17 Apr 2007 00:00:48 +0000</pubDate>
		<dc:creator>Bozzie</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[s3]]></category>

		<guid isPermaLink="false">http://bozziesfw.wordpress.com/2007/04/16/aws-s3-php-security-for-shared-servers/</guid>
		<description><![CDATA[The Amazon Web Services Simple Storage Service (AWS S3) agreement makes it clear that you the user are completely liable for any unauthorized use of your secret key.  However, their PHP, Python, and Ruby code examples usually start off with &#8220;$secretKey = &#60;insert your key here&#62;&#8221; followed by a caution to &#8220;only use this [...]]]></description>
			<content:encoded><![CDATA[<p>The Amazon Web Services Simple Storage Service (AWS S3) agreement makes it clear that you the user are completely liable for any unauthorized use of your secret key.  However, their PHP, Python, and Ruby code examples usually start off with &#8220;$secretKey = &lt;insert your key here&gt;&#8221; followed by a caution to &#8220;only use this example code on a secure server.&#8221;</p>
<p>I want to host a PHP application on a shared, remote server where I have only <em>ftp</em> access. I have to assume such a server is not secure, since any  sysadmin at the hosting service can browse at will.  I&#8217;m surely not the first person to host an S3 application on a remote server, yet there are only unanswered threads in the AWS forums regarding best security practices.  So I&#8217;m guessing that some users are uploading the AWS secret keys and hoping for the best.</p>
<p>Here are the ways I&#8217;ve considered for using S3 from a Shared, Remote Web server:</p>
<ol>
<li><strong>Upload Secret Key &#8211; </strong>either in plain text or nominally concealed by an XOR hash or hex encoding.  It would be concealment only, not encryption, since PHP is not compiled.</li>
<li><strong>Encrypt and Upload &#8211; </strong>use another language (Java) or extension (Zend engine) that provides some security.  AWS has some sample Java code that does this.</li>
<li><strong>Use Public Buckets &#8211; </strong>from a secure machine, create a public_read_write bucket on S3.  The PHP application on the shared server can then use anonymous access to read and write objects without requiring the secret key.</li>
<li><strong>User Grantee &#8211; </strong>the AWS documentation states that access can be granted to anyone who has an account on <em>amazon.com</em>, even those without an AWS account.  Obviously, such a person would not have a secret key.  So the shared server application could use an amazon account to access a bucket with such a grant.  However, the <a href="http://docs.amazonwebservices.com/AmazonS3/2006-03-01/" title="Authenticating REST Requests">documentation</a> does not explain how to sign a request with a canonical account name without a secret key.</li>
</ol>
<p>I rejected options 2 &amp; 4 as having too many unknowns at this stage of development.  Adding a new language just to encrypt a key is a big hit in complexity.  Similarly, with no cookbook example and the rather hastily assembled user documentation, I expect lots of trial and error for option 4.  But once documented, option 4 would be my clear first choice.</p>
<p>Options 1 &amp; 3 shift risk between a particular bucket and one&#8217;s secret key.  With option 3, anyone who discovers the publicly read/writable bucket can use it immediately without even needing to find my PHP source code.  But since they don&#8217;t have my secret key, I still have control over the bucket and can turn it off (delete it or make it private).</p>
<p>Option 1 exposes no public buckets on the web.  But the worst case (someone gaining access to the remote server and stealing the secret key) has a big exposure.  Only Amazon customer service can turn off a secret key, and they&#8217;re available only by email and only during business hours. If they take a week to shut off the key, I&#8217;d be liable for all of the charges.</p>
<p>My choice is option 3.  I&#8217;m more comfortable with the risk profile being concentrated onto one bucket.  Also, option 4 is a straighforward upgrade once more documentation becomes available.  One unknown: is there any easy way for hackers to scan AWS S3 searching for public buckets? Let&#8217;s hope not.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sheepdogit.com/2007/04/16/aws-s3-php-security-shared-server/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>AWS S3 PHP Interface Classes</title>
		<link>http://www.sheepdogit.com/2007/04/11/aws-s3-php-interface/</link>
		<comments>http://www.sheepdogit.com/2007/04/11/aws-s3-php-interface/#comments</comments>
		<pubDate>Wed, 11 Apr 2007 10:26:47 +0000</pubDate>
		<dc:creator>Bozzie</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[s3]]></category>

		<guid isPermaLink="false">http://bozziesfw.wordpress.com/2007/04/11/aws-s3-php-interface-classes/</guid>
		<description><![CDATA[I&#8217;ve been investigating the following code bundles to help me to get underway with the Amazon Web Services Simple Storage Service (AWS S3):

 Test Utility for Amazon S3 in PHP &#8211; from the AWS Developer Connection, it provides s3-test-utility-php.zip which contains: s3.php, index.php, and readme.html.  Using  the browser GUI provided by index.php to [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been investigating the following code bundles to help me to get underway with the Amazon Web Services Simple Storage Service (AWS S3):</p>
<ul>
<li> <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=482&amp;categoryID=47" title="Test Utility for Amazon S3 in PHP">Test Utility for Amazon S3 in PHP</a> &#8211; from the AWS Developer Connection, it provides <em>s3-test-utility-php.zip</em> which contains: <em>s3.php, index.php,</em> and <em>readme.html.</em>  Using  the browser GUI provided by <em>index.php </em>to control  <em>s3.php,</em> I was able to create a bucket and upload an object.  Code is documented and lists the derivation history of the code (see Storage3 and Mission Data Blog below).</li>
<li><span class="aws-h1"><a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=126&amp;categoryID=47" title="Amazon S3 Sample in PHP">Amazon S3 Sample in PHP</a> &#8211; an alternative <em>s3.php</em> that has some common heritage with the Test Utility <em>s3.php.</em></span></li>
<li><span class="aws-h1"><a href="http://blog.apokalyptik.com/storage3" title="Storage3">Storage3 Project</a> &#8211; the predecessor of the AWS Test Utility package, provides file <span style="font-style:italic;">Storage3.php</span> plus the required PEAR modules (making it easy to install on a remote server where PEAR can&#8217;t be invoked).</span></li>
<li><span class="aws-h1"><a href="http://www.missiondata.com/blog/linux/49/s3-streaming-with-php/" title="Mission Data putObjectStream()">Mission Data Blog</a> &#8211; presents the original <span style="font-style:italic;">putObjectStream()</span> method that has now been modified to use a file in the AWS Test Utility. </span></li>
</ul>
<p>I want to stream data directly to S3 (without first saving to a file) thus the current form of the AWS Test Utility package won&#8217;t work directly.  I can either use the Storage3 project or substitute the Mission Data <span style="font-style:italic;">putObjectStream() </span>method back into the AWS Test Utility s3 class.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sheepdogit.com/2007/04/11/aws-s3-php-interface/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install PEAR Packages for AWS S3, openSUSE 10.2</title>
		<link>http://www.sheepdogit.com/2007/03/06/aws-s3-pear-packages/</link>
		<comments>http://www.sheepdogit.com/2007/03/06/aws-s3-pear-packages/#comments</comments>
		<pubDate>Tue, 06 Mar 2007 08:36:39 +0000</pubDate>
		<dc:creator>Bozzie</dc:creator>
				<category><![CDATA[SUSE]]></category>
		<category><![CDATA[SysAdmin]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://bozziesfw.wordpress.com/2007/03/06/aws-s3-pear-packages/</guid>
		<description><![CDATA[Amazon S3 instructions require the following PEAR packages:HMAC, HTTP_Request, Net_Socket, and Net_URL.  After my problems with PEAR in SuSE 10.0, I want good notes of what I did here:

All commands run as root. 
pear remote-list
WARNING: channel &#8220;pear.php.net&#8221; has updated its protocols, use &#8220;channel-update pear.php.net&#8221; to update.
pear update-channels &#8211; successful.
pear info &#60;pkg&#62; &#8211; always responded [...]]]></description>
			<content:encoded><![CDATA[<p>Amazon S3 instructions require the following PEAR packages:HMAC, HTTP_Request, Net_Socket, and Net_URL.  After my problems with PEAR in SuSE 10.0, I want good notes of what I did here:</p>
<ul>
<li>All commands run as root. <code></code></li>
<li><code style="font-size:1.4em;">pear remote-list</code><br />
WARNING: channel &#8220;pear.php.net&#8221; has updated its protocols, use &#8220;channel-update pear.php.net&#8221; to update.</li>
<li><code style="font-size:1.4em;">pear update-channels</code> &#8211; successful.</li>
<li><code style="font-size:1.4em;">pear info &lt;pkg&gt;</code> &#8211; always responded &#8220;No information found for &#8216;pkg&#8217;.  I tried both installed packages and the packages I wanted to install.</li>
<li><code style="font-size:1.4em;">pear remote-list</code> &#8211; listed available packages and Net_Socket was not listed, even though I could see it on the PEAR web site.</li>
<li><code style="font-size:1.4em;">pear install HTTP_Request</code> -<br />
install ok: channel://pear.php.net/Net_Socket-1.0.6<br />
install ok: channel://pear.php.net/Net_URL-1.0.14<br />
install ok: channel://pear.php.net/HTTP_Request-1.4.0</li>
<li><code style="font-size:1.4em;">pear info HTTP_Request</code> &#8211; now it lists information about this package.  Something isn&#8217;t working; I certainly should be able to get info about a package before installing.</li>
<li><code style="font-size:1.4em;">pear list</code> -<br />
Installed packages, channel pear.php.net:<code style="font-size:1.4em;"><br />
Package        Version State<br />
Archive_Tar    1.3.1   stable<br />
Console_Getopt 1.2     stable<br />
Crypt_HMAC     1.0.1   stable<br />
HTTP_Request   1.4.0   stable<br />
Net_Socket     1.0.6   stable<br />
Net_URL        1.0.14  stable<br />
PEAR           1.4.11  stable</code></li>
<li>This shows another problem.  YaST offered a few PEAR packages at install time and I selected a few including PEAR::DB.  The DB package appears in <em>/usr/share/php5/PEAR</em> along with Archive Tar and Console Getopt, yet is not listed above.  Why not?</li>
<li><code style="font-size:1.4em;">pear run-tests -pr Crypt_HMAC</code> &#8211; &#8220;running 0 tests&#8221;, even though HMAC has a test.php file under the test subdirectory.  So I don&#8217;t understand this command either.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.sheepdogit.com/2007/03/06/aws-s3-pear-packages/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
