<?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>Andy Dixon &#187; PHP</title>
	<atom:link href="http://www.andydixon.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.andydixon.com</link>
	<description>Do the Oblivious</description>
	<lastBuildDate>Wed, 08 Feb 2012 00:24:39 +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>Using xDebug to profile slow PHP Sites</title>
		<link>http://www.andydixon.com/2012/01/06/using-xdebug-to-profile-slow-php-sites/</link>
		<comments>http://www.andydixon.com/2012/01/06/using-xdebug-to-profile-slow-php-sites/#comments</comments>
		<pubDate>Fri, 06 Jan 2012 17:00:47 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[kcachegrind]]></category>
		<category><![CDATA[pear]]></category>
		<category><![CDATA[pecl]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php5]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[xdebug]]></category>

		<guid isPermaLink="false">http://www.andydixon.com/?p=801</guid>
		<description><![CDATA[I have recently started using xDebug more and more for a PHP site I am working on, and after spending ages going through the code manually, I have started to use xdebug to properly identify where the issue lies. This tutorial will go through the process of setting up xDebug on Ubuntu, and a brief [...]]]></description>
			<content:encoded><![CDATA[<p>I have recently started using xDebug more and more for a PHP site I am working on, and after spending ages going through the code manually, I have started to use xdebug to properly identify where the issue lies.</p>
<p>This tutorial will go through the process of setting up xDebug on Ubuntu, and a brief explaination of how to use kCachegrind (I use KDE, and this is one of the best apps I have used).</p>
<p>Setting up:<br />
<code><br />
sudo apt-get install php5-dev php-pear kcachegrind<br />
</code><br />
Then install xdebug:<br />
<code><br />
sudo pecl install xdebug<br />
</code></p>
<p>Next, we need to locate the new module and update PHP so that it starts to use it:</p>
<p><code>find / -name 'xdebug.so'<br />
</code><br />
Grab the full path, we&#8217;re going to need it..</p>
<p>Next, you need to create a new config file and put this path into it.<br />
<code><br />
sudo nano -w /etc/php5/conf.d/xdebug.ini<br />
</code></p>
<p>If the file does not exist, add the following, replacing the path with the one you got a minute ago. You also need to decide on a location on where to store the profile files. Somewhere with a big chunk of space ideally. You need to put the full path into the <strong>profiler_output_dir</strong> parameter (I have a folder in my home directory):</p>
<p><code>zend_extension=/usr/lib/php5/20090626/xdebug.so<br />
xdebug.remote_enable=on<br />
xdebug.remote_handler=dbgp<br />
xdebug.remote_host=localhost<br />
xdebug.remote_port=9000<br />
xdebug.profiler_enable=1<br />
xdebug.profiler_output_dir=/home/andy/projects/profiles<br />
</code></p>
<p>Save it (ctrl+o , ctrl+x), and restart Apache:<code></p>
<p>sudo apache2ctl restart<br />
</code><br />
Done! Make sure yout profile folder exists..</p>
<p>Next time you profile a new file will be created, here is an example:<br />
<code><br />
andy@andy-desktop:~/projects$ ls -lah profiles/<br />
-rw-r--r-- 1 www-data www-data 64M 2012-01-05 15:06 cachegrind.out.13305<br />
-rw-r--r-- 1 www-data www-data 106M 2012-01-05 15:20 cachegrind.out.13538<br />
-rw-r--r-- 1 www-data www-data 106M 2012-01-05 15:21 cachegrind.out.13672<br />
-rw-r--r-- 1 www-data www-data 192M 2012-01-05 15:53 cachegrind.out.14182<br />
-rw-r--r-- 1 www-data www-data 364M 2012-01-05 16:08 cachegrind.out.14223<br />
-rw-r--r-- 1 www-data www-data 192M 2012-01-05 15:54 cachegrind.out.14236<br />
-rw-r--r-- 1 www-data www-data 61M 2012-01-05 16:19 cachegrind.out.14276<br />
-rw-r--r-- 1 www-data www-data 135M 2012-01-05 16:07 cachegrind.out.15357<br />
-rw-r--r-- 1 www-data www-data 61M 2012-01-05 16:35 cachegrind.out.16018<br />
</code></p>
<div id="attachment_805" class="wp-caption alignleft" style="width: 310px"><a href="http://www.andydixon.com/wp-content/uploads/2012/01/grind.png" rel="lightbox[801]"><img class="size-medium wp-image-805" title="kcachegrind in action" src="http://www.andydixon.com/wp-content/uploads/2012/01/grind-300x163.png" alt="kcachegrind in action" width="300" height="163" /></a><p class="wp-caption-text">kcachegrind in action</p></div>
<p>Now open your profle result file in kcachegrind and you can visually inspect which part of your script is eating cpu resources. Callmap &amp; Callgrap provide easy to understand visualizations to find bottlenecks in your script, and also find which lines are causing you the most grief!</p>
<p>&nbsp;</p>
<div style='clear:both'></div>
]]></content:encoded>
			<wfw:commentRss>http://www.andydixon.com/2012/01/06/using-xdebug-to-profile-slow-php-sites/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Decrypting WordPress Footers</title>
		<link>http://www.andydixon.com/2012/01/05/decrypting-wordpress-footers/</link>
		<comments>http://www.andydixon.com/2012/01/05/decrypting-wordpress-footers/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 17:24:20 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[decrypt]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.andydixon.com/?p=22</guid>
		<description><![CDATA[I was tasked with trying to figure out why some strange things were happening when pages were loaded on a WordPress website. Knowing from past experience, some people encrypt the footer file in themes &#8211; usually to keep a copyright intact, or links to dodgy businesses. On rare occasions, people can put backdoors in, allowing [...]]]></description>
			<content:encoded><![CDATA[<p>I was tasked with trying to figure out why some strange things were happening when pages were loaded on a WordPress website.</p>
<p>Knowing from past experience, some people encrypt the footer file in themes &#8211; usually to keep a copyright intact, or links to dodgy businesses.</p>
<p>On rare occasions, people can put backdoors in, allowing people to remotely wipe files or gain information on what is stored on the web server being used.</p>
<p>&nbsp;</p>
<p>Being a PHP coder myself, and that I use a Linux box with PHP installed on it, I was able to translate the file down to its source code.</p>
<p>1. Find the &#8220;eval&#8221; and change it to an &#8220;echo&#8221;.</p>
<p>2. Run it. In my case, I dropped into a Terminal window and went into the folder the file was (eg cd Desktop/theme/ [enter]) and then typed <strong>php -f footer.inc.php</strong> <strong>&gt;footer.inc.php </strong>[enter]</p>
<p>3. For each eval, repeat step 1. Do it one at a time, not running the rest of the code (comment it out) until you replace that eval line. This is for safety reasons, you never want the eval to run on your system. It could do anything, you have no idea.</p>
<p>Eventually, you get the final code output.</p>
<p>This is really annoying, and can be quite destructive if issues like this are not found. The guy I did it for was very grateful since the theme used could have easily deleted everything from his site if &#8216;<strong>&amp;deletefiles=1</strong>&#8216; was added to the end of any address to a WordPress page.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andydixon.com/2012/01/05/decrypting-wordpress-footers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get Mailbox contents into an Array in CakePHP</title>
		<link>http://www.andydixon.com/2012/01/02/get-mailbox-contents-into-an-array-in-cakephp/</link>
		<comments>http://www.andydixon.com/2012/01/02/get-mailbox-contents-into-an-array-in-cakephp/#comments</comments>
		<pubDate>Mon, 02 Jan 2012 16:33:15 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[basecamp]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[imap]]></category>
		<category><![CDATA[imap_open]]></category>
		<category><![CDATA[pop3]]></category>

		<guid isPermaLink="false">http://www.andydixon.com/?p=8</guid>
		<description><![CDATA[I have been wanting to write my own version of Basecamp for ages, but never had the time to do it. Since its been Christmas, to save my sanity from the usual rubbish they put on TV, I decided to try and make a start on it, and leave it to rot for the next [...]]]></description>
			<content:encoded><![CDATA[<p>I have been wanting to write my own version of Basecamp for ages, but never had the time to do it. Since its been Christmas, to save my sanity from the usual rubbish they put on TV, I decided to try and make a start on it, and leave it to rot for the next 12 months in Git.</p>
<p>What I came up with is a pretty nifty CakePHP 1.3  component (Not 2.0 because its been a bit of a bitch to me when I first started writing it in v2).</p>
<p>The component is GPL Affero licensed, and can be downloaded from:</p>
<p><a href="https://github.com/andydixon/CakeProcessMail">https://github.com/andydixon/CakeProcessMail</a></p>
<p>The component reads emails from an mail/usenet account, split and decode attachments and get plain text version of the message body into a big sexy array where you can then process them however you want. A simple loop could be used to do a file_put_contents to a file, or stick it all in a database.. Whatever you want, really.</p>
<p>Since writing docs is not one of my strong points, this is as much help as I have been so far on using the component:</p>
<p>Stick this file in the controller/components folder, and add it to the $components on the relavent controller.</p>
<p>Usage example:<br />
<code><br />
$this-&gt;Processmail-&gt;server = '{imap.gmail.com:993/imap/ssl/novalidate-cert}';<br />
$this-&gt;Processmail-&gt;login = '<a href="mailto:username@gmail.com">username@gmail.com</a>';<br />
$this-&gt;Processmail-&gt;password = 'password123';<br />
$messages = $this-&gt;Processmail-&gt;getMessages();<br />
debug($messages);<br />
</code></p>
<p>The server needs to be in the format of php&#8217;s <a title="PHP imap_open()" href="http://uk3.php.net/imap_open" target="_blank">imap_open()</a> function, and can handle POP,IMAP,NNTP and Unix Mail Spool</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andydixon.com/2012/01/02/get-mailbox-contents-into-an-array-in-cakephp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

