<?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>david schultz dot org &#187; php</title>
	<atom:link href="http://www.davidschultz.org/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.davidschultz.org</link>
	<description>(dot com was taken)</description>
	<lastBuildDate>Thu, 29 Jul 2010 18:23:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>How to install Google Affiliate pixel tracking code in Magento</title>
		<link>http://www.davidschultz.org/2009/11/12/how-to-install-google-affiliate-pixel-tracking-code-in-magento/</link>
		<comments>http://www.davidschultz.org/2009/11/12/how-to-install-google-affiliate-pixel-tracking-code-in-magento/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 01:55:01 +0000</pubDate>
		<dc:creator>David Schultz</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[troubleshooting]]></category>

		<guid isPermaLink="false">http://www.davidschultz.org/?p=317</guid>
		<description><![CDATA[Took me a day of scouring the web to figure out how to get this to work. After adding this code do a test order and view source and confirm it worked. #copy and paste to the bottom of #app/design/frontend/default/theme_name/template/checkout/success.phtml $companyID = "K123456"; #provided by Google $category = urlencode("Your product category"); $lastorderid = Mage::getSingleton('checkout/session')->getLastOrderId(); $_order [...]

<h3>Related Posts:</h3>
<ol>
		<li><a href="http://www.davidschultz.org/2008/03/28/google-improves-streetmaps-2/" rel="bookmark">Google improves streetmaps</a><!-- (4.60055)--></li>
		<li><a href="http://www.davidschultz.org/2009/10/16/the-best-marketing-is-none-at-all/" rel="bookmark">The best marketing is none at all</a><!-- (3.80556)--></li>
		<li><a href="http://www.davidschultz.org/2008/03/14/in-a-crowded-market-clarity-doesnt-sell/" rel="bookmark">In a crowded market clarity doesn&#8217;t sell</a><!-- (3.71909)--></li>
	</ol>
]]></description>
			<content:encoded><![CDATA[<p>Took me a day of scouring the web to figure out how to get this to work.  After adding this code do a test order and view source and confirm it worked.</p>
<pre name="code" class="php">
#copy and paste to the bottom of
#app/design/frontend/default/theme_name/template/checkout/success.phtml
$companyID = "K123456"; #provided by Google
$category = urlencode("Your product category");
$lastorderid = Mage::getSingleton('checkout/session')->getLastOrderId();
$_order = Mage::getModel('sales/order')->load($lastorderid);
$orderID = $this->getOrderId(); #get the order ID
$aProduct = array();
$totalAmt = 0;
$prdsku = "";
$prdnm = "";
$prdqn = "";
$prdpr = "";
$prcatid = "";

###########store order data in array of objects###########
foreach ($_order->getAllItems() as $item) {
	$oProduct = new stdClass();
	$oProduct->sku = $item->getSku(); #sku
	$oProduct->price = $item->getPrice(); #price
	$totalAmt = $totalAmt + ($oProduct->price * $item->getQtyOrdered()); #total amt (excl.tax/shipping)
	$oProduct->qty = $item->getQtyOrdered(); #quantity
	$oProduct->name = $item->getName(); #product name
	$oProduct->category = $category;
	array_push($aProduct, $oProduct);
	$oProduct = NULL; #nuke it
}
###########build query string variables###########
for ($i=0; $i < count($aProduct); $i++) {
	if ($i == count($aProduct)-1) {
		$prdsku .= urlencode($aProduct[$i]->sku);
		$prdnm .= urlencode($aProduct[$i]->name);
		$prdqn .= urlencode($aProduct[$i]->qty);
		$prdpr .= urlencode($aProduct[$i]->price);
		$prcatid .= urlencode($aProduct[$i]->category);
	} else {
		$prdsku .= urlencode($aProduct[$i]->sku) . "^";
		$prdnm .= urlencode($aProduct[$i]->name) . "^";
		$prdqn .= urlencode($aProduct[$i]->qty) . "^";
		$prdpr .= urlencode($aProduct[$i]->price) . "^";
		$prcatid .= urlencode($aProduct[$i]->category) ."^";
	}
}
?>

<img src="https://clickserve.cc-dt.com/link/order?vid=<?=$companyID?>&#038;oid=<?=$orderID?>&#038;amt=<?=urlencode($totalAmt)?>&#038;prdsku=<?=$prdsku?>&#038;prdnm=<?=$prdnm?>&#038;prdqn=<?=$prdqn?>&#038;prdpr=<?=$prdpr?>&#038;prcatid=<?=$prcatid?>" width=1 height=1>
</pre>


<h3>Related Posts:</h3>
<ol>
		<li><a href="http://www.davidschultz.org/2008/03/28/google-improves-streetmaps-2/" rel="bookmark">Google improves streetmaps</a><!-- (4.60055)--></li>
		<li><a href="http://www.davidschultz.org/2009/10/16/the-best-marketing-is-none-at-all/" rel="bookmark">The best marketing is none at all</a><!-- (3.80556)--></li>
		<li><a href="http://www.davidschultz.org/2008/03/14/in-a-crowded-market-clarity-doesnt-sell/" rel="bookmark">In a crowded market clarity doesn&#8217;t sell</a><!-- (3.71909)--></li>
	</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.davidschultz.org/2009/11/12/how-to-install-google-affiliate-pixel-tracking-code-in-magento/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>How to setup a linux cronjob in 3 steps</title>
		<link>http://www.davidschultz.org/2008/10/16/how-to-setup-a-linux-cronjob-in-3-steps/</link>
		<comments>http://www.davidschultz.org/2008/10/16/how-to-setup-a-linux-cronjob-in-3-steps/#comments</comments>
		<pubDate>Thu, 16 Oct 2008 14:01:05 +0000</pubDate>
		<dc:creator>David Schultz</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://www.davidschultz.org/2008/10/16/how-to-setup-a-linux-cronjob-in-3-steps/</guid>
		<description><![CDATA[Since web apps are executed only after an HTTP request, you may have situations where scripts need to run in the background on a scheduled basis. On Linux, to do this you&#8217;ll need to get to know the crontab. The way it works is kind of like an airport. The service is always running, however [...]

<h3>Related Posts:</h3>
<ol>
		<li><a href="http://www.davidschultz.org/2008/03/04/how-to-setup-a-static-route-in-osx-leopard/" rel="bookmark">How to setup a static route in OSX Leopard</a><!-- (8.11254)--></li>
		<li><a href="http://www.davidschultz.org/2008/01/14/emi-lays-off-2000-hmm-i-wonder-why/" rel="bookmark">EMI lays off 2,000 &#8211; hmm i wonder why</a><!-- (6.35239)--></li>
		<li><a href="http://www.davidschultz.org/2009/01/28/campbell-brown-interview-with-blago/" rel="bookmark">Campbell Brown interview with Blago</a><!-- (6.12207)--></li>
	</ol>
]]></description>
			<content:encoded><![CDATA[<p>Since web apps are executed only after an HTTP request, you may have situations where scripts need to run in the background on a scheduled basis.  On Linux, to do this you&#8217;ll need to get to know the crontab.  The way it works is kind of like an airport.  The service is always running, however planes only depart at their scheduled times.  The crontab is kinda like that, a daemon that runs constantly in the background and checks once a minute to see if any jobs need to be executed.  </p>
<p>Let&#8217;s say you have a script located at <code>http://www.acme.com/myscript.php</code> that needs to run the first of every month at 9am.  Here&#8217;s how you&#8217;d set it up:</p>
<p>1.  Look for a file in your <code>/etc</code> folder called <code>crontab</code>.<br />
2.  You need to install a new crontab job, to do this type <code>crontab -e</code>.<br />
3.  Now the tricky part, the syntax:<br />
<img src="http://farm4.static.flickr.com/3230/2947143834_f1fda7947e.jpg?v=0" alt="" /><br />
and here&#8217;s how that translates in our example: </p>
<p><code>0 9 1 * * curl http://www.acme.com/myscript.php</code></p>
<p>Lets break it down.  0 is for the minute, 9 is the hour &#8211; so 9 hours &#038; 0 minutes which is 9am.  Day of the month, 1 &#8211; easy.  We want to do this for every month &#038; week, which is accomplished using the wildcard or * character.  Next comes what we want to execute.  It&#8217;s not enough to just type the URL of the script, you&#8217;ll need to use the CURL system function to make the HTTP request for you.  </p>
<p>Here is some more information on <a href="http://en.wikipedia.org/wiki/CURL">CURL</a> &#038; <a href="http://en.wikipedia.org/wiki/Cron">Cron jobs</a> for your reading pleasure, hope this tutorial helps!</p>


<h3>Related Posts:</h3>
<ol>
		<li><a href="http://www.davidschultz.org/2008/03/04/how-to-setup-a-static-route-in-osx-leopard/" rel="bookmark">How to setup a static route in OSX Leopard</a><!-- (8.11254)--></li>
		<li><a href="http://www.davidschultz.org/2008/01/14/emi-lays-off-2000-hmm-i-wonder-why/" rel="bookmark">EMI lays off 2,000 &#8211; hmm i wonder why</a><!-- (6.35239)--></li>
		<li><a href="http://www.davidschultz.org/2009/01/28/campbell-brown-interview-with-blago/" rel="bookmark">Campbell Brown interview with Blago</a><!-- (6.12207)--></li>
	</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.davidschultz.org/2008/10/16/how-to-setup-a-linux-cronjob-in-3-steps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to authenticate against Active Directory using PHP</title>
		<link>http://www.davidschultz.org/2008/04/10/how-to-authenticate-against-active-directory-using-php/</link>
		<comments>http://www.davidschultz.org/2008/04/10/how-to-authenticate-against-active-directory-using-php/#comments</comments>
		<pubDate>Thu, 10 Apr 2008 15:09:23 +0000</pubDate>
		<dc:creator>David Schultz</dc:creator>
				<category><![CDATA[active directory]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[ldap]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://www.davidschultz.org/2008/04/10/how-to-authenticate-against-active-directory-using-php/</guid>
		<description><![CDATA[If you are like most companies out there, your IT department probably has everyone signing on to a Microsoft Active Directory domain. Wouldn&#8217;t it be nice to support single sign on, avoid all those seperate username/passwords littered across your intranet &#038; save yourself some database programming? Here&#8217;s how. First things first, you&#8217;ll need to make [...]

<h3>Related Posts:</h3>
<ol>
		<li><a href="http://www.davidschultz.org/2009/07/06/tutorial-iphone-twitter-push-notifications-using-tweetie/" rel="bookmark">Tutorial: iPhone twitter push notifications using Tweetie</a><!-- (6.45347)--></li>
		<li><a href="http://www.davidschultz.org/2008/03/04/how-to-setup-a-static-route-in-osx-leopard/" rel="bookmark">How to setup a static route in OSX Leopard</a><!-- (5.58784)--></li>
		<li><a href="http://www.davidschultz.org/2008/04/11/pick-of-the-week-tripitcom/" rel="bookmark">Pick of the week: tripit.com</a><!-- (5.28942)--></li>
	</ol>
]]></description>
			<content:encoded><![CDATA[<p>If you are like most companies out there, your IT department probably has everyone signing on to a <a href="http://en.wikipedia.org/wiki/Active_Directory">Microsoft Active Directory</a> domain.  Wouldn&#8217;t it be nice to support single sign on, avoid all those seperate username/passwords littered across your intranet &#038; save yourself some database programming?   Here&#8217;s how.  </p>
<p>First things first, you&#8217;ll need to make sure you have LDAP support installed.  You can double check this by creating a php info page:<br />
<code><br />
echo phpinfo();<br />
</code><br />
<img src="http://farm4.static.flickr.com/3117/2403576964_a272f3d4a9.jpg?v=0" alt="" /></p>
<p>If you run this page &#038; see the LDAP support in there, you are good to go.  If not, you&#8217;ll need to recompile PHP with ldap support by adding the <em>&#8211;with-ldap[=DIR]</em> option to the configure options.  For sake of brevity i&#8217;ll assume you understand how to make an HTML login form.  Once you have created this, you will want to capture the username &#038; password that the user submits.  Now you&#8217;ll need to connect to the ldap server:</p>
<p><code><br />
session_start(); #make sure this is at the top of your PHP file.<br />
$adServer = "127.0.0.1"; #replace with your AD server ip/hostname<br />
$ldapconn = ldap_connect($adServer)<br />
	or $this->msg = "Could not connect to LDAP server.";</p>
<p></code></p>
<p>Now that we&#8217;re connected, you can attempt to authenticate the username/password submitted, which will return a boolean value:</p>
<p><code><br />
$ldaprdn = $adServer . "\\" . $_POST["email"];<br />
$ldapbind = ldap_bind($ldapconn, $ldaprdn, $_POST["password"]);<br />
</code><br />
<code><br />
if ($ldapbind) {<br />
	$msg = "Successfully Authenticated";<br />
	$_SESSION['email'] = $email;<br />
	$_SESSION['password'] = $password;<br />
	return true;<br />
} else {<br />
	$msg = "Invalid email address / password";<br />
	return false;<br />
}<br />
</code></p>
<p>Now that you have stored the authenticated username/password in the users session data, you just need to run this same script before each page loads as you would with mysql user authentication.</p>
<p>From my experience, half the battle was getting my app to talk to the AD server, so best to be clear with your IT guys as to what you are attempting &#038; what you need to minimize frustration .  This was a pretty quick overview, so if you have any questions feel free to drop a comment and i will be happy to help.  You can also check out the <a href="http://ca3.php.net/manual/en/ref.ldap.php">great documentation</a> @ php.net.  </p>


<h3>Related Posts:</h3>
<ol>
		<li><a href="http://www.davidschultz.org/2009/07/06/tutorial-iphone-twitter-push-notifications-using-tweetie/" rel="bookmark">Tutorial: iPhone twitter push notifications using Tweetie</a><!-- (6.45347)--></li>
		<li><a href="http://www.davidschultz.org/2008/03/04/how-to-setup-a-static-route-in-osx-leopard/" rel="bookmark">How to setup a static route in OSX Leopard</a><!-- (5.58784)--></li>
		<li><a href="http://www.davidschultz.org/2008/04/11/pick-of-the-week-tripitcom/" rel="bookmark">Pick of the week: tripit.com</a><!-- (5.28942)--></li>
	</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.davidschultz.org/2008/04/10/how-to-authenticate-against-active-directory-using-php/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Phpmyadmin error: &#8220;Cannot start session without errors&#8221;</title>
		<link>http://www.davidschultz.org/2008/03/31/phpmyadmin-error-cannot-start-session-without-errors/</link>
		<comments>http://www.davidschultz.org/2008/03/31/phpmyadmin-error-cannot-start-session-without-errors/#comments</comments>
		<pubDate>Mon, 31 Mar 2008 15:12:09 +0000</pubDate>
		<dc:creator>David Schultz</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[troubleshooting]]></category>

		<guid isPermaLink="false">http://www.davidschultz.org/2008/03/31/phpmyadmin-error-cannot-start-session-without-errors/</guid>
		<description><![CDATA[I have been trying to get phpmyadmin working on my Fedora 8 server i&#8217;ve been setting up, and struggled for the past day or so on this error: Cannot start session without errors, please check errors given in your PHP and/or webserver log file and configure your PHP installation properly. Turns out it&#8217;s very easy [...]

<h3>Related Posts:</h3>
<ol>
		<li><a href="http://www.davidschultz.org/2008/05/05/sendmail-says-statdeferred-connection-reset/" rel="bookmark">Sendmail says: stat=Deferred: Connection reset</a><!-- (8.29688)--></li>
		<li><a href="http://www.davidschultz.org/2009/11/12/how-to-install-google-affiliate-pixel-tracking-code-in-magento/" rel="bookmark">How to install Google Affiliate pixel tracking code in Magento</a><!-- (4.39934)--></li>
		<li><a href="http://www.davidschultz.org/2008/03/04/how-to-setup-a-static-route-in-osx-leopard/" rel="bookmark">How to setup a static route in OSX Leopard</a><!-- (4.25633)--></li>
	</ol>
]]></description>
			<content:encoded><![CDATA[<p>I have been trying to get <a href="http://www.phpmyadmin.net/">phpmyadmin</a> working on my Fedora 8 server i&#8217;ve been setting up, and struggled for the past day or so on this error:</p>
<blockquote><p>Cannot start session without errors, please check errors given in your PHP and/or webserver log file and configure your PHP installation properly.</p></blockquote>
<p>Turns out it&#8217;s very easy to fix.  First thing you&#8217;ll want to do is have a look at your error logs.  For me this was in /var/log/lighttpd/error.log (<a href="http://www.lighttpd.net/">i&#8217;m using lighttpd</a> instead of Apache).  Have a look at your error log and you will probably see errors referencing permission errors writing to your session directory.  </p>
<p>Simply chmod 777 that directory and you should be good to go.  </p>


<h3>Related Posts:</h3>
<ol>
		<li><a href="http://www.davidschultz.org/2008/05/05/sendmail-says-statdeferred-connection-reset/" rel="bookmark">Sendmail says: stat=Deferred: Connection reset</a><!-- (8.29688)--></li>
		<li><a href="http://www.davidschultz.org/2009/11/12/how-to-install-google-affiliate-pixel-tracking-code-in-magento/" rel="bookmark">How to install Google Affiliate pixel tracking code in Magento</a><!-- (4.39934)--></li>
		<li><a href="http://www.davidschultz.org/2008/03/04/how-to-setup-a-static-route-in-osx-leopard/" rel="bookmark">How to setup a static route in OSX Leopard</a><!-- (4.25633)--></li>
	</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.davidschultz.org/2008/03/31/phpmyadmin-error-cannot-start-session-without-errors/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 3.358 seconds -->
