<?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>GizzmoAsus&#039; Blog &#187; PHP Code</title>
	<atom:link href="http://www.gizzmoasus.co.uk/category/php-code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gizzmoasus.co.uk</link>
	<description>GizzmoAsus&#039; Lil place of the net</description>
	<lastBuildDate>Mon, 19 Jul 2010 21:29:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Open Source E-Commerce Systems</title>
		<link>http://www.gizzmoasus.co.uk/03/open-source-e-commerce-systems/</link>
		<comments>http://www.gizzmoasus.co.uk/03/open-source-e-commerce-systems/#comments</comments>
		<pubDate>Sat, 01 Mar 2008 18:09:41 +0000</pubDate>
		<dc:creator>GizzmoAsus</dc:creator>
				<category><![CDATA[PHP Code]]></category>

		<guid isPermaLink="false">http://www.gizzmoasus.co.uk/blog/?p=42</guid>
		<description><![CDATA[Its been a while my last post so I thouhgt I would review an e-commerce system I have recently been playing with.
A couple of weeks back a friend of mine asked me if I could create him an on-line store for his company, Racebits. At the moment there is very little happening with Racebits because [...]]]></description>
			<content:encoded><![CDATA[<p>Its been a while my last post so I thouhgt I would review an e-commerce system I have recently been playing with.</p>
<p>A couple of weeks back a friend of mine asked me if I could create him an on-line store for his company, Racebits. At the moment there is very little happening with Racebits because the person who was developing it decided they only wanted to have a forum and not bother with the functionality of the online store.</p>
<p>The current system comprises of the open source cart system osCommerce, a bolt on forum called MyBB and thats it. The objective is to utilise one system which can combine both systems and utilise one member-base for both systems, along with a consistant look and feel.</p>
<p>Due to the company being a sales company I looked around for a system which would be suitable but there appears to be none which fit the criteria and are any good or maybe I didn&#8217;t look hard enough lol.</p>
<p>I decided to play around with Zen Cart too which is supposed to be the best there is for an Open Source E-commerce site. So I set about installing it and it all went fine so I proceeded to install the example dataset and visited the home page and my first impressions were not that good to be honest. I found the layout and content cluttered and it seemed disorganised to me. I know I can change all the layout and the content for the system but when a default install looks as gash as this I feel like its going to take a huge amount of time and work. The other thing I found with Zen Cart is that the documentation isn&#8217;t that well developed, although there is a lot of it, and it looks like its made up from a load of forum posts and guides that the community has created. My final thought about Zen Cart is that it seems somewhat antiquated from what you would expect from a modern day system.</p>
<p>I mentioned this to a collegue of mine at work and he suggested taking a look at a relatively new system called <a target="_blank" href="http://www.magentocommerce.com/">Magento</a>. So I did, and from first impressions this looks like an awesome system, albeit a little under developed. It has a very clean and intuitive interface and the final system looks like its going to be full of all those little features you wish you got with the others lol.</p>
<p>So I decided to install it on my dev server, after looking at the requirements it appears to need the latest version of everything, which isn&#8217;t a bad thing. The install process was pretty straight forward and it included an auto update process to ensure that it was installing the latest version &#8230; nice touch. They also provide a way of using the system with php4 which uses the cgi-bin version of php5 so I tried to use this on my live server to see if it could be easily done and ran into a few problems. I am looking into a solution and if I find one then I will update this post to reflect the changes. There are also reports about the ability to merge Magento with Joolma and JFusion. Not sure whether this will work or not but I will have a play this evening and report back. If it does integrate with joomla then the possibilites are endless lol.</p>
<p>After looking through the files and directory structure for the system it loooks like the system is developed using a &lsquo;Model-View-Controller&rsquo; architecture. There is a very good article on MVC architecures over at&nbsp;<a target="_blank" href="http://www.phpwact.org/pattern/model_view_controller">www.phpwact.org/pattern/model_view_controller</a>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gizzmoasus.co.uk/03/open-source-e-commerce-systems/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pass $_post Variables Without Forms</title>
		<link>http://www.gizzmoasus.co.uk/01/pass-_post-variables-without-forms/</link>
		<comments>http://www.gizzmoasus.co.uk/01/pass-_post-variables-without-forms/#comments</comments>
		<pubDate>Fri, 11 Jan 2008 22:26:40 +0000</pubDate>
		<dc:creator>GizzmoAsus</dc:creator>
				<category><![CDATA[PHP Code]]></category>

		<guid isPermaLink="false">http://www.gizzmoasus.co.uk/blog/?p=38</guid>
		<description><![CDATA[Intro
Ever wanted to send variables to another script without clogging up the URI? Well the following is a function which allows you to do just that:
Usage
To use this function just call it  

 $something = sendPost($URL_of_the_file_you_want_to_pass_the_variables_to, $an_array_containing_the_variables_you_wish_to_send)
Note: The array needs to be made up in the following way:

$context = array(
	'post_variable1' => 'post_value1',
	'post_variable2' => 'post_value2',
	'post_variable3' [...]]]></description>
			<content:encoded><![CDATA[<h3>Intro</h3>
<p>Ever wanted to send variables to another script without clogging up the <acronym title="Unifromed Resource Identifier">URI</acronym>? Well the following is a function which allows you to do just that:</p>
<h3>Usage</h3>
<p>To use this function just call it <img src='http://www.gizzmoasus.co.uk/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<pre class="prettyprint">
 $something = sendPost($URL_of_the_file_you_want_to_pass_the_variables_to, $an_array_containing_the_variables_you_wish_to_send)</pre>
<p><em><strong>Note:</strong></em> The array needs to be made up in the following way:</p>
<pre class="prettyprint">
$context = array(
	'post_variable1' => 'post_value1',
	'post_variable2' => 'post_value2',
	'post_variable3' => 'post_value3'
);</pre>
<h3>Code</h3>
<pre class="prettyprint">
function sendPost($url, $context)
{
	$context = array_change_key_case($context, CASE_LOWER);
	$contextSize = sizeof($context);
	$contextKeys = array_keys($context);
	$data = "";
	foreach ($contextKeys as $key)
	{
		$amp = "&amp;";
		if (next($contextKeys) === FALSE) { $amp = ""; }
		$data .= urlencode($key)."=".urlencode($context[$key]).$amp;
	}

	list($host,$url) = explode('/',$url,2);
	$sock = fsockopen($host,80,$errno,$errstr,1);
	if (!$sock) { die("$errstr ($errno) in ".__FILE__." (".__LINE__.")\n"); }
	$http_request = "POST /".$url." HTTP/1.1\r\n";
	$http_request .= "Host: ".$host."\r\n";
	$http_request .= "Content-type: application/x-www-form-urlencoded\r\n";
	$http_request .= "Content-length: " . strlen($data) . "\r\n";
	$http_request .= "Accept: */*\r\n";
	$http_request .= "\r\n";
	$http_request .= "$data\r\n";
	$http_request .= "\r\n";
	fwrite($sock,$http_request);
	$response_headers = array();
	while ($str = trim(fgets($sock)))
		array_push($response_headers,$str);
	fclose($sock);
	$errors = true;
	$errorMsg = "";
	foreach($response_headers as $response_header){
		if($response_header == 'HTTP/1.1 200 OK'){
			$errors = false;
		}elseif($response_header == 'X-UFU: OK'){
			$errors = false;
		}
	}
	if (!$errors)
		return true;
	else
		return false;
}</pre>
<p>Enjoy and please free to leave a comment if you use this code</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gizzmoasus.co.uk/01/pass-_post-variables-without-forms/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Convert Linebreaks to New Lines</title>
		<link>http://www.gizzmoasus.co.uk/12/convert-linebreaks-to-new-lines/</link>
		<comments>http://www.gizzmoasus.co.uk/12/convert-linebreaks-to-new-lines/#comments</comments>
		<pubDate>Fri, 21 Dec 2007 20:22:52 +0000</pubDate>
		<dc:creator>GizzmoAsus</dc:creator>
				<category><![CDATA[PHP Code]]></category>

		<guid isPermaLink="false">http://www.gizzmoasus.co.uk/blog/?p=39</guid>
		<description><![CDATA[Intro
During my development process I am forever using the same information for both text-based emails and html-based emails. Then a thought came accross me, why not just use the same information and replace the
with \n using some form of regular expressions. This lead to me doing a quick search on the net to ensure I [...]]]></description>
			<content:encoded><![CDATA[<h3>Intro</h3>
<p>During my development process I am forever using the same information for both text-based emails and html-based emails. Then a thought came accross me, why not just use the same information and replace the<br />
with \n using some form of regular expressions. This lead to me doing a quick search on the net to ensure I wasn&#8217;t reinventing the wheel and I came accross the following:</p>
<h3>Code</h3>
<pre CLASS="prettyprint">
/* This function will convert line breaks or other tags passed in the
$tags variable to linebreaks.  Multiple $tags must be separated by
spaces, and must consist of the regular tag text.
Ie. $result = br2nl($text_to_filter, "br p blockquote") */    

function br2nl($text, $tags = 'br')
{
    $tags = explode(&quote; &quote;, $tags);
    foreach($tags as $tag) {
        $text = eregi_replace('<' . $tag . '[^>]*>', '\n', $text);
        $text = eregi_replace('</' . $tag . '[^>]*>', '\n', $text);
    }
    return($text);
}

// Usage: $text_to_filter = '

This is my sampletext. The default code listed here should replace the br's with new lines.

The second example is more advanced, stripping out both the BR's as well as the P tags.

';
// Example of replacing BR tags (default)
$result = br2nl($text_to_filter);
// Example of replacing both BR and P tags $result = br2nl($text_to_filter, "br p");
?></pre>
<p>Function Found at <a TITLE="Convert Linebreaks to Newlines" HREF="http://www.warkensoft.com/2007/06/php-function-to-convert-linebreaks-to-newlines/"> http://www.warkensoft.comÂ </a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gizzmoasus.co.uk/12/convert-linebreaks-to-new-lines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

