Dec 28

Here's a quick function I wrote to generate IP address ranges using recursion.

function iprange($oct, $prefix=""){
	for($i=1;$i<256;$i++){
		if($oct == 1) print("$prefix.$i\\n");
		else iprange($oct - 1, "$prefix.$i");
	}
}

Just call it with the number of octets you want to generate and the beginning of the IP range.

Example:

iprange(2, "127.0");

Output:

127.0.1.1
127.0.1.2
127.0.1.3
127.0.1.4
127.0.1.5

127.0.255.254
127.0.255.255

Enjoy :)

Dec 25

Whatever your religious affiliation, may you have a merry Christmas, Kwanzaa, Hanukkah, whatever from everyone (me, myself and I) at 13337.org.

:)

Dec 20

Google CodeSearch is an awesome tool that has the ability to explain how functions work, how other programmers handled difficult problems.. Or just provide you material to laugh at. Codeulate has a great list of comment swearing. I gotta say, I'm guilty of this too, but at least my anger isn't usually revealed to the world!

Dec 19

A while back when I was first learning AJAX, I decided I wanted to write an interactive PHP/JavaScript shell for executing commands, etc. All the other ones I found either didn't handle directories well, were way too bulky or were backdoored. So, I now present to you JAXED Shell. I haven't extensively tested it, but it should work in the majority of situations.

Enjoy :)
Commands:

home - return to shell's home directory
clear - clear history box
up/down arrow - go through previous commands
right arrow - file name completion

Read the rest of this entry »

Dec 17

Wrote this for one of my projects - hopefully it helps you out a little bit. POST data needs to be formatted variable1=value&variable2=value2 and urlencoded.

function CURL($url, $postdat=""){
	$ch = curl_init($url);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
	curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
	if($postdat){
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $postdat);
	}
	while(!$dat) $dat = curl_exec($ch);
	curl_close($ch);
	return $dat;
}

Examples:

$dat = CURL("http://google.com");
$dat = CURL("http://site.com/post.php", "search=bunnies");

Sorry I haven't had much content lately: finals this week :-\

« Previous Entries