GizzmoAsus.co.uk

PHP Code

Open Source E-Commerce Systems

by on Mar.01, 2008, under PHP Code

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 the person who was developing it decided they only wanted to have a forum and not bother with the functionality of the online store.

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.

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’t look hard enough lol.

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’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.

I mentioned this to a collegue of mine at work and he suggested taking a look at a relatively new system called Magento. 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.

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’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 … 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.

After looking through the files and directory structure for the system it loooks like the system is developed using a ‘Model-View-Controller’ architecture. There is a very good article on MVC architecures over at www.phpwact.org/pattern/model_view_controller 

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
Leave a Comment more...

Pass $_post Variables Without Forms

by on Jan.11, 2008, under PHP Code

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' => 'post_value3'
);

Code

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 = "&";
		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;
}

Enjoy and please free to leave a comment if you use this code

VN:F [1.9.22_1171]
Rating: 5.0/5 (2 votes cast)
2 Comments more...

Convert Linebreaks to New Lines

by on Dec.21, 2007, under PHP Code

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 wasn’t reinventing the wheel and I came accross the following:

Code

/* 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("e; "e;, $tags); 
    foreach($tags as $tag) { 
        $text = eregi_replace('<' . $tag . '[^>]*>', '\n', $text); 
        $text = eregi_replace(']*>', '\n', $text); 
    } 
    return($text); 
}

// Usage: $text_to_filter = '

This is my
sample
text. 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"); ?>

Function Found at http://www.warkensoft.com 

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
Leave a Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!