<?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>Sean&#039;s Blog &#187; php</title>
	<atom:link href="http://seanbehan.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://seanbehan.com</link>
	<description>Web Programming, Ruby on Rails, Wordpress, PHP from Burlington, Vermont</description>
	<lastBuildDate>Wed, 18 Jan 2012 21:44:54 +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>Matt Mullenweg is Wrong. Thesis Should Carry Whatever License It Wants.</title>
		<link>http://seanbehan.com/php/matt-mullenweg-is-wrong-thesis-should-carry-whatever-license-it-wants/</link>
		<comments>http://seanbehan.com/php/matt-mullenweg-is-wrong-thesis-should-carry-whatever-license-it-wants/#comments</comments>
		<pubDate>Mon, 02 Aug 2010 02:23:49 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[chris pearson]]></category>
		<category><![CDATA[gpl]]></category>
		<category><![CDATA[legality]]></category>
		<category><![CDATA[matt mullenweg]]></category>
		<category><![CDATA[mixergy]]></category>
		<category><![CDATA[php license]]></category>
		<category><![CDATA[thesis]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=1083</guid>
		<description><![CDATA[There is a debate underway about the legality of Thesis, a popular, paid for WordPress theme, using a different license than the one WordPress uses, which is the GPL. Matt Mullenweg, founder of WordPress, contends that all themes for the platform should inherit the WordPress license and should be considered a part of the platform. [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fphp%2Fmatt-mullenweg-is-wrong-thesis-should-carry-whatever-license-it-wants%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Matt Mullenweg is Wrong. Thesis Should Carry Whatever License It Wants." data-url="http://seanbehan.com/php/matt-mullenweg-is-wrong-thesis-should-carry-whatever-license-it-wants/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>There is a debate underway about the legality of <a href="http://diythemes.com/" target="_blank">Thesis</a>, a popular, paid for WordPress theme, using a different license than the one WordPress uses, which is the <a href="http://www.gnu.org/licenses/gpl.html" target="_blank">GPL</a>. <a href="http://ma.tt" target="_blank">Matt Mullenweg</a>, founder of <a href="http://wordpress.org" target="_blank">WordPress</a>, contends that all themes for the platform should inherit the WordPress license and should be considered a part of the platform. Chris Pearson, creator of Thesis, obviously has a different opinion. There have been many <a href="http://wordpress.tv/2010/07/15/mixergy-interview-pearson-mullenweg/" target="_blank">heated debates</a> over the topic, but I haven&#8217;t heard an argument by either side that is compelling one way or the other.</p>
<p>My opinion, which I obviously think is compelling, though is not in any way rooted in any facet of the law or articulated in any legalese whatsoever, is that Matt Mullenweg is wrong. I love what Matt has done. I use and love the WordPress platform. I also think that his position is noble and rooted in the greater good for the WordPress community and open source in general.</p>
<p>I think what has been overlooked in his argument is an assumption we have about software, namely how it is supposed to work and what defines working software in relation to a pluggable software stack, such as WordPress. Technically, I could create an empty my-new-index.php file, place it inside the WordPress directory structure, and I have extended the platform. According to Matt, my software which does nothing, must inherit the WordPress license. Now if I want to sell (or redistribute) this do nothing piece of software for $50.00 (<a href="mailto:bseanvt@gmail.com?subject=send-me-my-50-dollar-index-file">available upon request</a>) I must also sell it with the GPL license. So technically, any piece of PHP code can placed inside of the WordPress directory structure and therefore, all PHP code must also carry the WordPress license!?!</p>
<p>There is obviously some rational limit and discretion available to us so that this sort of thing won&#8217;t ever happen!  We could say because the Thesis theme makes use of the WordPress API, it must be intended for use with WordPress. However, the WordPress API is a bunch of PHP functions and WordPress  itself uses the PHP API, which carries a different license (<a href="http://www.php.net/license/3_01.txt" target="_blank">The PHP License</a>). Which one takes precedence (if they were conflicting) ? Do all PHP applications, because they all must, by definition, use the PHP API, have to inherit the PHP License? This would be ridiculous and I&#8217;ve never seen a PHP app with the PHP license, so clearly using an API can&#8217;t include licensing requirements, so long as you aren&#8217;t modifying and redistributing the original API itself. For example, if I use a PEAR class, I don&#8217;t have to inherit the license for all of my work, I just can&#8217;t change the license of that class and or modify the original code without making it available again.  Thesis doesn&#8217;t (to my knowledge) modify or extend any of the WordPress core. It provides interface enhancements, outputted HTML generated not by WordPress, but by Thesis. WordPress just consumes the Thesis software because it exists in a certain location, placed by someone into the WordPress directory structure.</p>
<p>This is the nature of pluggable systems, or software stacks. They are meant to be interoperable with other pieces of software whose parts and purposes are not known ahead of time. This covers a lot of space, space that isn&#8217;t even in existence and which it would, if Matt were correct, claim licensing rights to, in the event &#8220;it&#8221; comes into existence and &#8220;works&#8221; with said piece of software. Clearly Thesis &#8220;works&#8221; with WordPress. But so does a blank file. I intend for that file to do nothing, and it performs (quite efficiently) that task!</p>
<p>At the end of the day, it is only because Thesis is marketed to the WordPress community and is intended to be used with the WordPress platform, that there is an argument about how the software should be licensed. But Thesis is not sold bundled with WordPress, nor is anyone who purchases it required to use it with WordPress. For all intents and purposes, it is a stand alone piece of code, that well, does nothing important or worthwhile. Can you really license functionality that may or may not exist depending on how the purchaser decides to implement their purchase, just like my overpriced(though well worth the investment), blank PHP file could be used in any PHP application?</p>
<p>I have a lot of questions (I haven&#8217;t read all the licenses either, so I may be in total error :). Though from what I&#8217;ve read and heard so far, it is only because we have an expectation of how the software will work when it is in the WordPress directory structure that there is a conflict with how Chris has licensed Thesis. This expectation is set by the marketing of the software, not necessarily the software itself. Aside from Trademark infringement, does the language used to sell a product carry over into the the actual license the code must carry? This wouldn&#8217;t make sense. Say for instance, &#8220;Runs on Windows&#8221;, would require another license too?</p>
<p>I think we&#8217;re going to see a lot more arguments over licensing conflicts like what we&#8217;re seeing with WordPress/Thesis. Software is the biggest it has ever been. Open Source software is integrated into the business world like never before and business models are built on top of many of the various projects which are out there, &#8220;free&#8221; to use. As this space expands, no doubt more and more gray areas will as well.</p>
<p>On a practical note, what would stop Chris from writing a simple wrapper  around the WordPress API his files use, license this with the GPL, use  his wrapper functions instead from inside Thesis and then keep the  current Thesis license?</p>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/php/matt-mullenweg-is-wrong-thesis-should-carry-whatever-license-it-wants/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to Check if the Current Logged In User can Edit a Course in MOODLE Using the Has_capability Function</title>
		<link>http://seanbehan.com/moodle/how-to-check-if-the-current-logged-in-user-can-edit-a-course-in-moodle-using-the-has_capability-function/</link>
		<comments>http://seanbehan.com/moodle/how-to-check-if-the-current-logged-in-user-can-edit-a-course-in-moodle-using-the-has_capability-function/#comments</comments>
		<pubDate>Fri, 30 Jul 2010 02:36:52 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[moodle]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[context]]></category>
		<category><![CDATA[course]]></category>
		<category><![CDATA[has_capbility]]></category>
		<category><![CDATA[teacher]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=1072</guid>
		<description><![CDATA[After an hour of fruitless searching through the docs and forums, I finally found an answer to my simple question, of course buried in the depths of the shark infested, murky water that is the Moodle code base . How do I check if a user is a course creator for a given course? I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fmoodle%2Fhow-to-check-if-the-current-logged-in-user-can-edit-a-course-in-moodle-using-the-has_capability-function%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="How to Check if the Current Logged In User can Edit a Course in MOODLE Using the Has_capability Function" data-url="http://seanbehan.com/moodle/how-to-check-if-the-current-logged-in-user-can-edit-a-course-in-moodle-using-the-has_capability-function/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>After an hour of fruitless searching through the docs and forums, I finally found an answer to my simple question, of course buried in the depths of the shark infested, murky water that is the Moodle code base .</p>
<p>How do I check if a user is a course creator for a given course? I&#8217;m still not 100% sure, the access control policy seems needlessly confusing on first glance and even after reading the heady and mostly pointless, expose on how roles/perms are calculated (Available Here: http://docs.moodle.org/en/How_permissions_are_calculated ) If you notice the section titled &#8220;Some Practical Examples&#8221; is 100% empty! (I&#8217;ve added my code to the wiki so not 100% empty any longer) The most useful part of the docs are completely empty! Instead boatloads of time went into a treatise on the internals and lovely graphs like this one <img class="alignnone" src="http://docs.moodle.org/en/images_en/9/9c/Role_calc_table2.png" alt="" width="756" height="256" /></p>
<p>But you could always hop into the forum dedicated just to this chunk of the code base (Available here: http://moodle.org/mod/forum/view.php?f=941&amp;page=0) and search through the 500 topics w/ 5000+(i didn&#8217;t actually count) nested discussions (including version 1.7 of moodle as well).</p>
<p>No, instead, ACK came to the rescue and I found a snippet that performed the task.</p>
<p>Without further ado</p>
<pre class="wp-code-highlight prettyprint">$context = get_context_instance(CONTEXT_COURSE, $course-&amp;gt;id);
if (has_capability('moodle/course:update', $coursecontext)) {
  /** do stuff here */
}
</pre>
<p>There it is. That could have saved me an hour if mentioned in the docs!</p>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/moodle/how-to-check-if-the-current-logged-in-user-can-edit-a-course-in-moodle-using-the-has_capability-function/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Moodle&#039;s Most Important Function Gets No Attention</title>
		<link>http://seanbehan.com/php/moodles-most-important-function-gets-no-attention/</link>
		<comments>http://seanbehan.com/php/moodles-most-important-function-gets-no-attention/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 23:36:07 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[moodle]]></category>
		<category><![CDATA[patterns]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=1067</guid>
		<description><![CDATA[Arguably the most important function in the Moodle API, is the create_course function. One would think&#8230; after all Moodle is an LMS. Courses are the bread and butter for course management platforms, right? Taking a look at the function in the course/lib.php file reveals almost nothing about the function! WTF? &#8230; btw, the function starts [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fphp%2Fmoodles-most-important-function-gets-no-attention%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Moodle&#039;s Most Important Function Gets No Attention" data-url="http://seanbehan.com/php/moodles-most-important-function-gets-no-attention/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>Arguably the most important function in the Moodle API, is the create_course function. One would think&#8230; after all Moodle is an LMS. Courses are the bread and butter for course management platforms, right? Taking a look at the function in the course/lib.php file reveals almost nothing about the function! WTF? &#8230; <em>btw, the function starts at line 3260</em></p>
<pre class="wp-code-highlight prettyprint">/**
 * Create a course and either return a $course object or false
 *
 * @param object $data  - all the data needed for an entry in the 'course' table
 */
function create_course($data) {
    global $CFG, $USER;
    /** omitted for your sanity */
}
</pre>
<p>Wow, I think I know less about this function now than before I went digging into the code. How do I assign a teacher to my new course, how do I populate the data object it takes as a parameter (is there a course setup function)? Since courses aren&#8217;t really objects in Moodle (just glorified arrays), am I just supposed to set them up by hand&#8230; $object-&gt;param = val?  Are there default values and/or required attributes that need to be set, otherwise my program is going to come to a halt? What about student enrollments? No example to help for how one might actually use this function? Do I have to really read through the code, starting at around line 3260, then jump between the rest of  this monstrous 4000 line piece of spaghetti coded file and try and make sense of it works (somehow).</p>
<p>How is it possible that the most important function (since the core problem Moodle solves is creating courses) in the entire application has no meaningful documentation? I think I have an answer. The entire code base is soooo convoluted and a giant waste of CPU cycles, that it would too embarrassing to actually document how it even works.</p>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/php/moodles-most-important-function-gets-no-attention/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Convert Array to Object in PHP</title>
		<link>http://seanbehan.com/php/convert-array-to-object-in-php/</link>
		<comments>http://seanbehan.com/php/convert-array-to-object-in-php/#comments</comments>
		<pubDate>Mon, 05 Jul 2010 17:58:30 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=1060</guid>
		<description><![CDATA[function array2obj($data) { return is_array($data) ? (object) array_map(__FUNCTION__,$data) : $data; } Source: http://www.serversidemagazine.com/php/how-to-convert-array-notation-to-object-notation]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fphp%2Fconvert-array-to-object-in-php%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Convert Array to Object in PHP" data-url="http://seanbehan.com/php/convert-array-to-object-in-php/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><pre class="wp-code-highlight prettyprint">
function array2obj($data) {
    return is_array($data) ? (object) array_map(__FUNCTION__,$data) : $data;
}
</pre>
<p>Source: <a href="http://www.serversidemagazine.com/php/how-to-convert-array-notation-to-object-notation">http://www.serversidemagazine.com/php/how-to-convert-array-notation-to-object-notation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/php/convert-array-to-object-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using the PHP Mail Function with Additional Headers</title>
		<link>http://seanbehan.com/php/using-the-php-mail-function-with-additional-headers/</link>
		<comments>http://seanbehan.com/php/using-the-php-mail-function-with-additional-headers/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 19:12:45 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[headers]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=791</guid>
		<description><![CDATA[Pass a fourth parameter to the mail() function with the header information. &#38;lt;?php $to = &#34;jane@example.com&#34;; $subject = &#34;Hello World!&#34;; $body = &#34;This will be sent from email-addr@example.com&#34;; $headers = &#34;From: email-addr@example.com\r\nX-Mailer: php&#34;; mail($to, $subject, $body, $headers);]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fphp%2Fusing-the-php-mail-function-with-additional-headers%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Using the PHP Mail Function with Additional Headers" data-url="http://seanbehan.com/php/using-the-php-mail-function-with-additional-headers/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>Pass a fourth parameter to the mail() function with the header information.</p>
<pre class="wp-code-highlight prettyprint">
&amp;lt;?php
$to = &quot;jane@example.com&quot;;
$subject = &quot;Hello World!&quot;;
$body = &quot;This will be sent from email-addr@example.com&quot;;
$headers = &quot;From: email-addr@example.com\r\nX-Mailer: php&quot;;
mail($to, $subject, $body, $headers);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/php/using-the-php-mail-function-with-additional-headers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generate MySQL Datetime Type Using PHP Date() Function</title>
		<link>http://seanbehan.com/php/generate-mysql-datetime-type-using-php-date-function/</link>
		<comments>http://seanbehan.com/php/generate-mysql-datetime-type-using-php-date-function/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 18:22:27 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[strftime]]></category>
		<category><![CDATA[type]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=779</guid>
		<description><![CDATA[If you want to insert a datetime that matches the default mysql datetime type format use this date('Y-m-d H:i:s');]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fphp%2Fgenerate-mysql-datetime-type-using-php-date-function%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Generate MySQL Datetime Type Using PHP Date() Function" data-url="http://seanbehan.com/php/generate-mysql-datetime-type-using-php-date-function/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>If you want to insert a datetime that matches the default mysql datetime type format use this</p>
<pre class="wp-code-highlight prettyprint">
date('Y-m-d H:i:s');
</pre>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/php/generate-mysql-datetime-type-using-php-date-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Paypal IPN Script</title>
		<link>http://seanbehan.com/php/php-paypal-ipn-script/</link>
		<comments>http://seanbehan.com/php/php-paypal-ipn-script/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 21:45:42 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[fsockopen]]></category>
		<category><![CDATA[ipn]]></category>
		<category><![CDATA[paypal]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=776</guid>
		<description><![CDATA[Simple script for posting a valid response back to Paypal service after a sale is completed using the Paypal Instant Checkout payment method. &#38;lt;?php // read the post from PayPal system and add 'cmd' $req = 'cmd=_notify-validate'; foreach ($_POST as $key =&#62; $value) { $value = urlencode(stripslashes($value)); $req .= &#34;&#38;$key=$value&#34;; } // post back to [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fphp%2Fphp-paypal-ipn-script%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="PHP Paypal IPN Script" data-url="http://seanbehan.com/php/php-paypal-ipn-script/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>Simple script for posting a valid response back to Paypal service after a sale is completed using the Paypal Instant Checkout payment method.</p>
<pre class="wp-code-highlight prettyprint">
&amp;lt;?php
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';

foreach ($_POST as $key =&gt; $value) {
  $value = urlencode(stripslashes($value));
  $req .= &quot;&amp;$key=$value&quot;;
}

// post back to PayPal system to validate
$header .= &quot;POST /cgi-bin/webscr HTTP/1.0\r\n&quot;;
$header .= &quot;Content-Type: application/x-www-form-urlencoded\r\n&quot;;
$header .= &quot;Content-Length: &quot; . strlen($req) . &quot;\r\n\r\n&quot;;
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);

// assign posted variables to local variables
$item_name        = $_POST['item_name'];
$item_number      = $_POST['item_number'];
$payment_status   = $_POST['payment_status'];
$payment_amount   = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id           = $_POST['txn_id'];
$receiver_email   = $_POST['receiver_email'];
$payer_email      = $_POST['payer_email'];

if (!$fp) {
// HTTP ERROR
} else {
  fputs ($fp, $header . $req);
  while (!feof($fp)) {
    $res = fgets ($fp, 1024);
    if (strcmp ($res, &quot;VERIFIED&quot;) == 0) {
      // check the payment_status is Completed
      // check that txn_id has not been previously processed
      // check that receiver_email is your Primary PayPal email
      // check that payment_amount/payment_currency are correct
      // process payment
    } else if (strcmp ($res, &quot;INVALID&quot;) == 0) {
      // log for manual investigation
    }
  }
fclose ($fp);
}
</pre>
<p>I grabbed this script from Paypal Docs&#8230; I never can find the info I need w/in their site so I&#8217;m posting here for reference.  <a href="https://www.paypal.com/us/cgi-bin/webscr?cmd=p/pdn/ipn-codesamples-pop-outside#php">https://www.paypal.com/us/cgi-bin/webscr?cmd=p/pdn/ipn-codesamples-pop-outside#php</a></p>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/php/php-paypal-ipn-script/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Listing Files and Directories with PHP</title>
		<link>http://seanbehan.com/php/listing-files-and-directories-with-php/</link>
		<comments>http://seanbehan.com/php/listing-files-and-directories-with-php/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 18:27:47 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[directories]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[ksort]]></category>
		<category><![CDATA[read]]></category>
		<category><![CDATA[stat]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=774</guid>
		<description><![CDATA[Listing all files and directories using PHP 5. &#38;lt;?php $files = array(); $dir = dir(&#34;.&#34;); while(false!==($file=$dir-&#38;gt;read())): if(($file{0}!=&#34;.&#34;) &#38;&#38; ($file{0}!=&#34;~&#34;) &#38;&#38; (substr($file, -3)!=&#34;LCK&#34;) &#38;&#38; ($file!=basename($_SERVER[&#34;PHP_SELF&#34;]))): $files[$file] = stat($file); // endif; endwhile; $dir-&#38;gt;close(); ksort($files); ?&#38;gt; &#38;lt;table border=1 cellpadding=5&#38;gt; &#38;lt;tr&#38;gt;&#38;lt;th&#38;gt;Name&#38;lt;/th&#38;gt;&#38;lt;th&#38;gt;Size&#38;lt;/th&#38;gt;&#38;lt;th&#38;gt;Date&#38;lt;/th&#38;gt;&#38;lt;/tr&#38;gt; &#38;lt;?php foreach($files as $name =&#38;gt; $stats): ?&#38;gt; &#38;lt;tr&#38;gt; &#38;lt;td&#38;gt;&#38;lt;?php print $name;?&#38;gt;&#38;lt;/td&#38;gt; &#38;lt;td&#38;gt;&#38;lt;?php print $stats['size']; ?&#38;gt;&#38;lt;/td&#38;gt; &#38;lt;td&#38;gt;&#38;lt;?php print date(&#34;m-d-Y [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fphp%2Flisting-files-and-directories-with-php%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Listing Files and Directories with PHP" data-url="http://seanbehan.com/php/listing-files-and-directories-with-php/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>Listing all files and directories using PHP 5.</p>
<pre class="wp-code-highlight prettyprint">
&amp;lt;?php
$files = array(); $dir = dir(&quot;.&quot;);
while(false!==($file=$dir-&amp;gt;read())):
  if(($file{0}!=&quot;.&quot;) &amp;&amp; ($file{0}!=&quot;~&quot;) &amp;&amp; (substr($file, -3)!=&quot;LCK&quot;)
    &amp;&amp; ($file!=basename($_SERVER[&quot;PHP_SELF&quot;]))):
      $files[$file] = stat($file); //
    endif;
endwhile;
$dir-&amp;gt;close(); ksort($files); ?&amp;gt;

&amp;lt;table border=1 cellpadding=5&amp;gt;
&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Name&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Size&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Date&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;
&amp;lt;?php foreach($files as $name =&amp;gt; $stats): ?&amp;gt;
  &amp;lt;tr&amp;gt;
    &amp;lt;td&amp;gt;&amp;lt;?php print $name;?&amp;gt;&amp;lt;/td&amp;gt;
    &amp;lt;td&amp;gt;&amp;lt;?php print $stats['size']; ?&amp;gt;&amp;lt;/td&amp;gt;
    &amp;lt;td&amp;gt;&amp;lt;?php print date(&quot;m-d-Y h:ia&quot;, $stats['mtime']); ?&amp;gt;&amp;lt;/td&amp;gt;
  &amp;lt;/tr&amp;gt;
&amp;lt;?php endforeach; ?&amp;gt;&amp;lt;/table&amp;gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/php/listing-files-and-directories-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Highlight String in PHP</title>
		<link>http://seanbehan.com/php/highlight-string-in-php/</link>
		<comments>http://seanbehan.com/php/highlight-string-in-php/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 16:57:29 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[file_get_contents]]></category>
		<category><![CDATA[highlight]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=765</guid>
		<description><![CDATA[Function for highlighting text/strings in PHP. $content = file_get_contents(&#34;http://php.net/&#34;); print highlight(&#34;PHP&#34;, $content); function highlight($match, $string){ return str_ireplace($match, &#34;&#38;lt;span style='background:yellow'&#38;gt;$match&#38;lt;/span&#38;gt;&#34;, $string); } Will output something like this ***Notice all the styles are gone :( &#8230; would need to parse the document body to maintain stylesheet and other &#8216;php&#8217; strings that might be in resources paths.]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fphp%2Fhighlight-string-in-php%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Highlight String in PHP" data-url="http://seanbehan.com/php/highlight-string-in-php/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>Function for highlighting text/strings in PHP.</p>
<pre class="wp-code-highlight prettyprint">
$content = file_get_contents(&quot;http://php.net/&quot;);

print highlight(&quot;PHP&quot;, $content);

function highlight($match, $string){
  return str_ireplace($match, &quot;&amp;lt;span style='background:yellow'&amp;gt;$match&amp;lt;/span&amp;gt;&quot;, $string);
}
</pre>
<p>Will output something like this<br />
<div class="wp-caption alignnone" style="width: 355px"><img alt="Highlighted PHP.Net" src="http://farm5.static.flickr.com/4003/4297402799_22d2a0e816_o.jpg" title="PHP Highlight" width="345" height="334" style="background:#eeeeee;padding:3px;border:solid 1px #CCC;"/><p class="wp-caption-text">Highlighted PHP.Net</p></div></p>
<p>***Notice all the styles are gone :( &#8230; would need to parse the document body to maintain stylesheet and other &#8216;php&#8217; strings that might be in resources paths.</p>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/php/highlight-string-in-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Absolutize Relative Links Using PHP and Preg_Replace_Callback</title>
		<link>http://seanbehan.com/php/absolutize-relative-links-using-php-and-preg_replace_callback/</link>
		<comments>http://seanbehan.com/php/absolutize-relative-links-using-php-and-preg_replace_callback/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 17:29:41 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[absolute links]]></category>
		<category><![CDATA[file_get_contents]]></category>
		<category><![CDATA[preg_replace_callback]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[relative links]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=727</guid>
		<description><![CDATA[I was in the market for a simple php script to replace hrefs with their absolute paths from scraped web pages. I wrote one myself. I used the preg_replace_callback function so that I could pass the parsed results as a single variable. &#38;lt;?php $domain = &#34;http://seanbehan.com&#34;; $pattern = &#34;/\bhref=[\&#34;&#124;'](.*?)[\&#34;&#124;']/&#34;; $string = file_get_contents($domain); // prepends relative [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fphp%2Fabsolutize-relative-links-using-php-and-preg_replace_callback%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Absolutize Relative Links Using PHP and Preg_Replace_Callback" data-url="http://seanbehan.com/php/absolutize-relative-links-using-php-and-preg_replace_callback/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>I was in the market for a simple php script to replace hrefs with their absolute paths from scraped web pages. I  wrote one myself. I used the preg_replace_callback function so that I could pass the parsed results as a single variable.</p>
<pre class="wp-code-highlight prettyprint">
&amp;lt;?php
$domain = &quot;http://seanbehan.com&quot;;
$pattern = &quot;/\bhref=[\&quot;|'](.*?)[\&quot;|']/&quot;;
$string = file_get_contents($domain);

// prepends relative links w/ $domain skips returns the match if already absolute
function replace_href($match){
  global $domain;
  if(substr($match[1], 0, 7)!==&quot;http://&quot; &amp;&amp; substr($match[1],0,8)!==&quot;https://&quot;){
    return &quot;href='&quot;.$domain.$match[1].&quot;'&quot;;
  } else {
    return &quot;href='&quot;.$match[1].&quot;'s&quot;;
  }
}
print preg_replace_callback($pattern, &quot;replace_href&quot;, $string);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/php/absolutize-relative-links-using-php-and-preg_replace_callback/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

