GizzmoAsus.co.uk

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

Online Directories – Customer Street

by on Jan.10, 2008, under Web

Well as some of you may have read I recently started working for a company based in Lancaster, Customer Street who deal with online directories and portals. Since starting there my main responsibility has been carrying out upgrades to the online directories in order to improve both functionality and usability. These can be found at:

Feel free to leave comments about what you think about them.

According to a few online ranking systems, UFindUs is the second largest online directory behind Yell.com and is constantly on the rise.

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
Leave a Comment 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...

Working at last

by on Dec.01, 2007, under Personal

Well since graduating, some of you may know that I have been job hunting with little success. I managed to find some temporary work with a company based at Preston called Xchanging. This involved processing (mainly) BAE temporary worker wage bills. Whilst this was an interesting change from the norm it really wasn’t what I wanted to do so I kept looking.

A couple of months back I went for a job interview with a company based in Lancaster for a developer position that had opened up. Unfortunately they decided to hire internally but then I recieved a phone call asking me if I wanted to work or them as a position had opened up. Needless to say I agreed and now a developer for the second largest online directory system on the internet (behind Yell). The work is mainly front-end changes for the time being but it is building up the experience I need to start working on the back-end infrastructure which is currently in place.

Anyway thats currently what I’m up to so check back to see how things develop on the work front. In the meantime feel free to check out a few mods for the FusionBB community on their site and my main site

Have fun and be good 😉

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
Leave a Comment more...

End of an Era

by on Jun.17, 2007, under Personal

Well its now an end of an era, I have now finished University.

The past four years have given me some awesome experiences to remember such as the night we came back from the union and spent the remainder of the night sat in a stairwell chatting about random things (yes a stairwell lol). There have also been some bad experiences such as the shooting, I know it didn’t directly affect me but I know a couple of guys who were working that night and they were a little shook up for a while. It just goes to show that when everyone sticks together anything can be overcome.

Anyway its fathers day so I just wanted to put up a public thank you to my dad for his support over the past four years. Without him I probably wouldn’t have made it.

So Thanks Dad :)
VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
Leave a Comment more...

Asus Eee PC 701 – Must for any Geek on the move

by on Jun.09, 2007, under technology

Hehehe this looks amazing and will appeal to anyone who like to use a laptop whilst on the move.

Specification at the moment is as follows:

  • 7in display
  • laptop-like QWERTY keyboard
  • Intel’s Ultra Mobile Platform chip technology
  • 512MB of memory
  • 4, 8 or 16GB of Flash storage
  • 802.11b/g Wi-Fi
  • 100Mbps Ethernet
  • 0.3-megapixel camera, stereo speakers, microphone, VGA output
  • 22.5 x 16.5 x 2.1-3.5cm

It is expected to go for around £100 or $200 but once demand increases I can see this price increasing.Basically its just a machine for accessing the net whilst your on the move, not going to be powerful enough to run most 3d games, but that price who really cares.

The full story can be seen at Engadget – Chinese or an english version can be found at reghardware
Cheers to DotWaffle who found this in the first place and showed me it 😉

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

LaserWar & America’s Army

by on May.29, 2007, under Gaming

LaserWar is a cross between LaserQuest and PaintBall, it takes place outside (like paintball) and uses weapons which utilise laser (not actual lasers) technology. Last weekend I went with a few mates from LSUCS.
It turned out to be an awesome morning, we initially booked it for the day, however the place we went to, http://www.warfighters.eu, were due to get some new weapons in the day before. This meant they had been able to take more bookings for the same day.
The plan was to have two teams, us and someone else, and we would play against each other. The problem was the weapons never arrived therfore there were not enough weapons to go around. So we ended up playing in the morning and the other group played after us (about 2ish). We did however get refunded for the trouble.

Anyway once we got kited up, we set off into the field and fought amongst ourselves for about 4 hours. Totally awesome experience and fully recommend it above paintball. So much more tactical than paintball but does require a little bit more walking to get between battlegrounds. Fully recommended!!!

Anyway following this trip to LaserWar, I decided to have a look and see how far America’s Army (the game) had progressed. WOW its come far since I last played it (couple of years back). There are loads of new maps, and the graphics for each map are immense. The great thing about it though has to be that the gameplay side of the game has not been affected by all the changes. Its still seems as good as I remember if not better.

The game can be downloaded here or here and is available for Windows, MAC and Linux. However the MAC ad Linux clients are now longer being developed by the same people who develop the Windows version but it will be continued as a community project (feel free to correct me on this if I am wrong).
For those running Vista, punkbuster requires you to run the game “as an administrator” (untill they come up with a better solution). The easiest way to do this for those who don’t know is to right-click on the shortcut and goto properties, then click on compatability and check the “Run this program as an administrator” box, this will then run the game as an admin everytime. Hopefully they will come up with a solution soon.

BTW for those who havn’t noticed I decided to change the look and feel of this section to my site, feel free to drop me a comment about wether you prefer it or prefer the other theme.

VN:F [1.9.22_1171]
Rating: 4.5/5 (2 votes cast)
Leave a Comment more...

Impressivness of Vista Utils

by on May.25, 2007, under Vista

The time came to reinstall Vista this afternoon, and not for the usual reasons. It was reinstalled to update the license to a legal version of Vista Business :)

Have to admit I was quite impressed with it, I decided to play around with the backup / Easy Transfer utilities that Vista now offers. Here is what happened:
The Easy Transfer utility worked like a charm. Installed Vista, inserted the disk created during the Easy Transfer setup on the old install where I told it to copy all my email settings etc and when I ran it in the new install it just copied them over.
Started up the mail client and hey presto all my accounts are there (had to enter all the passwords again), all my emails and all the rules which I had previously spent hours setting up. Nice job Microsoft 😉

Thought I would also have a look at the backup feature but that doesn’t seem to like backups created under other installations for some reason. Keeps claiming that I need to create a backup before I can restore a backup … “I have created one” … oh well never mind might create one and see if I can then use the older backup.

Just found out that the Easy Transfer utility even copied over putty and a couple of other utils (with their configs).
Will do a guide on how I did this at some point (after revision for final year exams are over lol).

Decided to stick with Winamp for my music player and went to look for a new skin for it. I actually found an awesome skin which fits in perfectly with my desktop setup. It evens has a feature which folds it away in to the right hand side of the desktop. This mixed with the transparency -> opaque on hover settings (found under alpha blending skin options) means I can still do everything I want, without having to have Winamp on top of all my windows.

The skin can be found in the main winamp skins collection and below are a couple of screenshots showing the skin visible on the desktop, 10% transparency and folded up 😉
Visible Winamp Skin

Winamp Skin with 10% transparency

Minimised view of the winamp skin

Click the thumbnails for a larger view :)

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
Leave a Comment more...

Family Guy – Streetfighter

by on May.18, 2007, under random

Just got sent this link to a random but hilarious video on Youtube.

Enjoy and wait till the end, its hilarious.

[youtube Zu8hTdDqioo]

Click here if the video doesn’t appear

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
Leave a Comment more...

High Score on Desktop Tower Defense

by on Apr.23, 2007, under random

Highscore.png

This was the highscore I achieved on my second attempt.

The objective of the game is to prevent createures getting from one side of the board to the other. This is done by strategically placing weapon platforms all over the field in an arrangement such that nothing gets through.

Enjoy!!!

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes 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!