<?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>Bytearray - Programming, Computers and Technology &#187; PHP</title>
	<atom:link href="http://bytearray.brixtonjunkies.com/category/code/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://bytearray.brixtonjunkies.com</link>
	<description></description>
	<lastBuildDate>Tue, 03 Nov 2009 11:52:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.3</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Flex: Multiple File Uploader</title>
		<link>http://bytearray.brixtonjunkies.com/2009/10/01/flex-multiple-file-uploader/</link>
		<comments>http://bytearray.brixtonjunkies.com/2009/10/01/flex-multiple-file-uploader/#comments</comments>
		<pubDate>Thu, 01 Oct 2009 14:32:27 +0000</pubDate>
		<dc:creator>alchemist</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[file uploader]]></category>
		<category><![CDATA[flex uploader]]></category>
		<category><![CDATA[multi uploader]]></category>
		<category><![CDATA[uploader]]></category>

		<guid isPermaLink="false">http://bytearray.brixtonjunkies.com/?p=529</guid>
		<description><![CDATA[Uploading is such a common task and can often be a little painful so I decided to write a small library in Flex which simplifies the task. I have released it under GPL license so feel free to use and modify it according to the conditions  
The Flex client side uploader supports multiple file [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://bytearray.brixtonjunkies.com/wp-content/uploads/2009/10/uploader.jpg"><img class="size-full wp-image-528  alignleft" title="Flex Multi Uploader" src="http://bytearray.brixtonjunkies.com/wp-content/uploads/2009/10/uploader.jpg" alt="Flex Multi Uploader" width="378" height="178" /></a>Uploading is such a common task and can often be a little painful so I decided to write a small library in Flex which simplifies the task. I have released it under GPL license so feel free to use and modify it according to the conditions <img src='http://bytearray.brixtonjunkies.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The Flex client side uploader supports multiple file upload with queuing and multiple threads, meaning more than one upload can be active at a time. It is also written in component style so creating an instance of the uploader is very simple and can be achieved in only a few lines of code <em>(see the example below).</em> It also supports posted additional data with the file upload, handy if you need to pass instructions to the back-end upload script.</p>
<p>The back-end script is not included in the library but could easily be implemented in any language. I have however supplied a <strong>PHP</strong> example below of how to implement the back-end script to support the Flex uploader <em>(see the example below).</em> </p>
<p>One final note, this code is not polished, it&#8217;s definitely Alpha&#8230;but still very usable. If you have any issues or questions please let me know, cheers.</p>
<p><em><strong>Simple example implementation of uploader library</strong></em></p>
<pre class="brush: as3;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
				xmlns:cc=&quot;FileUploader.Renderers.*&quot;
				layout=&quot;absolute&quot;
			    creationComplete=&quot;{init()}&quot;
			    width=&quot;1018&quot;
			    height=&quot;455&quot;
				&gt;
	&lt;mx:Script&gt;
		&lt;![CDATA[

			private function init():void{
				fileUploader.addPostData('mydata','1234567890');
			}

		]]&gt;
	&lt;/mx:Script&gt;

	&lt;cc:FileUploadComp id=&quot;fileUploader&quot;
					   x=&quot;0&quot;
					   top=&quot;8&quot;
					   left=&quot;8&quot;
					   width=&quot;1000&quot;
					   maxThreadsEnabled=&quot;true&quot;
					   uploadUrl=&quot;http://a.b.c.d/MyUploaderScript.php&quot;
					   /&gt;
&lt;/mx:Application&gt;
</pre>
<p><em><br />
<strong>PHP backend example implementation of uploader code</strong></em></p>
<pre class="brush: php;">
&lt;?php
	$tmpFileName = isset($_FILES['Filedata']['tmp_name']) ? $_FILES['Filedata']['tmp_name'] : '';
	$orgFileName = isset($_FILES['Filedata']['name']) ? $_FILES['Filedata']['name'] : '';
	$mydata = isset($_REQUEST['mydata']) ? $_REQUEST['mydata'] : '';

	error_log('tmpfile: ' . $tmpFileName);
	error_log('filename: ' . $orgFileName);
	error_log('mydata: ' . $mydata);	

	if (true){
		print 'ok';
	}
	else{
		header('Status: 500 ' . $resultAry[1]);
		header('HTTP/1.1 500 ' . $resultAry[1]);

		$outputStr = '&lt;!DOCTYPE HTML PUBLIC \&quot;-//IETF//DTD HTML 2.0//EN\&quot;&gt;' .
				 '&lt;html&gt;&lt;head&gt;' .
				 '&lt;title&gt;500 ' . $resultAry[1] . '&lt;/title&gt;' .
				 '&lt;/head&gt;&lt;body&gt;' .
				 '&lt;h1&gt;500 ' . $resultAry[1] . '&lt;/h1&gt;' .
				 '&lt;hr&gt;' .
				 $_SERVER['SERVER_SIGNATURE'] .
				 '&lt;/body&gt;&lt;/html&gt;';
		print $outputStr;
	}
?&gt;
</pre>
<p>Also here&#8217;s and example of a Flash <strong>crossdomain.xml</strong><em> (this one is reasonably open!)</em> which will be needed in the <strong>root</strong> of your site&#8230;otherwise flex will complain. </p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;!DOCTYPE cross-domain-policy SYSTEM &quot;http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd&quot;&gt;
&lt;cross-domain-policy&gt;
	&lt;allow-access-from domain=&quot;*&quot; to-ports=&quot;*&quot;/&gt;
	&lt;site-control permitted-cross-domain-policies=&quot;all&quot;/&gt;
&lt;/cross-domain-policy&gt;
</pre>
<p style="text-align: center;"><a rel="nofollow" href="http://bytearray.brixtonjunkies.com/wp-content/uploads/uploader/FlexUploaderExample.html" target="_blank">Demo Flex Uploader</a></p>
<p style="text-align: center;"><a href="http://bytearray.brixtonjunkies.com/wp-content/uploads/2009/10/FlexFileUploader.zip">DOWNLOAD (version 1.0a)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://bytearray.brixtonjunkies.com/2009/10/01/flex-multiple-file-uploader/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Wordpress: Custom Post Order</title>
		<link>http://bytearray.brixtonjunkies.com/2009/09/25/wordpress-custom-post-order/</link>
		<comments>http://bytearray.brixtonjunkies.com/2009/09/25/wordpress-custom-post-order/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 10:08:10 +0000</pubDate>
		<dc:creator>alchemist</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[query_posts]]></category>

		<guid isPermaLink="false">http://bytearray.brixtonjunkies.com/?p=484</guid>
		<description><![CDATA[I recently had a requirement for custom ordering on Wordpress categories and thought that I would share how I did it.
All that is needed is this piece of code which essentially modifies the SQL statement being generated. Note that the argument assigned to orderby is the column name, hence it is case sensitive (I found [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had a requirement for custom ordering on Wordpress categories and thought that I would share how I did it.</p>
<p>All that is needed is this piece of code which essentially modifies the SQL statement being generated. Note that the argument assigned to <strong>orderby</strong> is the column name, hence it is case sensitive <em>(I found out that ID breaks the naming conversion on the post table)</em>;</p>
<pre class="brush: php;">
&lt;?php
   if (is_category(array($myCatId))){
      query_posts($query_string . &quot;&amp;orderby=ID&amp;order=DESC&quot;);
   }
?&gt;
</pre>
<p><em>Code needs to be placed before this line</em></p>
<pre class="brush: php;">
&lt;?php if (have_posts()) : while (have_posts()) : the_post(); update_post_caches($posts); ?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://bytearray.brixtonjunkies.com/2009/09/25/wordpress-custom-post-order/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wordpress Adsense &#8211; Ad Targeting Redirect</title>
		<link>http://bytearray.brixtonjunkies.com/2009/08/20/wordpress-adsense-ad-targeting-redirect/</link>
		<comments>http://bytearray.brixtonjunkies.com/2009/08/20/wordpress-adsense-ad-targeting-redirect/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 16:16:47 +0000</pubDate>
		<dc:creator>alchemist</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[ad targeting]]></category>
		<category><![CDATA[adsense]]></category>
		<category><![CDATA[header redirect]]></category>
		<category><![CDATA[permalink]]></category>

		<guid isPermaLink="false">http://bytearray.brixtonjunkies.com/?p=60</guid>
		<description><![CDATA[When I was a Adsense n00b I made the mistake of adding adding a witty statement in my tagline in wordpress which confused adsense in terms of the content of my site, despite all the search engine optimization I had done . The symptom was: only the main index of my site had ads targeted [...]]]></description>
			<content:encoded><![CDATA[<p>When I was a Adsense n00b I made the mistake of adding adding a witty statement in my tagline in wordpress which confused adsense in terms of the content of my site, despite all the search engine optimization I had done . The symptom was: <span style="text-decoration: underline;">only</span> the main index of my site had ads targeted solely on the wordpress &#8220;tagline&#8221; <em>(the strip of text under the main title)</em>,  all other pages on my site were targeted correctly. I thought this would be a matter of simply changing the tagline&#8230;but no, google doesn&#8217;t forget! I wont go into detail about the type of ads that were being targeted, lets just say they weren&#8217;t ideal.</p>
<p>A simple effective work around is a header redirect <em>(permalink friendly)</em> on the main site index which can be prefixed to the wordpress index.php in your wordpress top level directory. </p>
<pre class="brush: php;">
&lt;?php

// set $redirectHome = false to disable the redirect

$redirectHome = true;
if ($redirectHome){
        // Redirects index page
        $uriStr = $_SERVER['REQUEST_URI'];
        if (($uriStr == '/') || ($uriStr == '')){
                header('Location: /?index',true,301);
                die();
        }
        // Makes sure pages off the main index are not renamed
        $matchAry = array();
        if (preg_match('/(\/page\/\d+\/)\?index/',$uriStr,$matchAry)){
                header('Location: ' . $matchAry[1],true,301);
                die();
        }
}

/**
 * Original Wordpress index.php goes here
 */
</pre>
<p>This works because Google thinks &#8220;/?index&#8221; is a new page <em>(it&#8217;s not though, it&#8217;s the main index with a query string attached)</em> and the media bot crawls it and targets it accordingly as a new page. And as long as you&#8217;ve made your amendments to your previously incorrect content, in my case the &#8220;tagline&#8221; then this time around your ads should be accurately targeted&#8230;hopefully <img src='http://bytearray.brixtonjunkies.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The curious thing is, it seems no matter what only my original main index is targeted incorrectly still months later. I&#8217;ve seen other posts relating to incorrect ad targeting on the main index only. It seems like Google&#8217;s media crawler doesn&#8217;t like something about Wordpress, I would like to hear from others that have experienced this.</p>
]]></content:encoded>
			<wfw:commentRss>http://bytearray.brixtonjunkies.com/2009/08/20/wordpress-adsense-ad-targeting-redirect/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Hello World Example</title>
		<link>http://bytearray.brixtonjunkies.com/2009/08/11/hello-world-example/</link>
		<comments>http://bytearray.brixtonjunkies.com/2009/08/11/hello-world-example/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 16:08:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://bytearray.brixtonjunkies.com/?p=1</guid>
		<description><![CDATA[No site would be complete without the textbook hello world example&#8230;so here it is  

&#60;?php

/**
 * Hello World Example
 */

function foo($bar){
     print $bar;
}

$bar = 'Hello World';
foo($bar);

?&#62;

]]></description>
			<content:encoded><![CDATA[<p>No site would be complete without the textbook hello world example&#8230;so here it is <img src='http://bytearray.brixtonjunkies.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<pre class="brush: php;">
&lt;?php

/**
 * Hello World Example
 */

function foo($bar){
     print $bar;
}

$bar = 'Hello World';
foo($bar);

?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://bytearray.brixtonjunkies.com/2009/08/11/hello-world-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
