logo

ShrimpWorks

// why am I so n00b?

(Wanted to reply to this NewsForge article, since some other seemingly know-it-all n00bs were ranting in the comments about Smarty being a waste of time, however their comments system won’t let me post [most likely a problem on SAIX’s side])


After having used Smarty for around 2 years now, I don’t think I could ever go back to writing PHP applications without it.

It’s brilliant to be able to spend some time working out your code, logic, etc all nicely in a PHP script, assigning the variables and values you want to present on the final page, then go and throw together a plain HTML page with some smarty tags to display that information.

Bug in your HTML? No need to dig through PHP scripts bloated with loads of HTML searching for problems, just whip out the template and correct it easily. Same goes for debugging the PHP code, it’s not all mixed in with the HTML so it’s millions of time easier to debug.

Overall, there’s no faster, cleaner way of writing PHP applications.

w00t

Finally, got my internet connection back. Turns most of the houses in the townhouse complex we moved into don’t actually have phone lines installed. It’s taken more than 2 weeks of begging and whining at the complex managers to get something done. They finally arrived yesterday (Thursday) with a Telkom tech guy and installed it in around 10 minutes.

Today a not-too-bright Telkom dude pitched up and installed the ADSL. Apparently we should be glad it works at all, since we’re far from the exchange. I guess all that matters is that it actually works in the end :).

The drive up was pretty uneventful, even though it did take 12 hours, around 3-4 more than it should have. I blame retarded truck drivers for that. I must say the scenery around the Eastern Cape is a lot nicer than the barren wastelands between there and Johannesburg. I’ll miss it. The weather here is so dry and hot :(, I’ll miss the humidity too.

Aside from the lack of a phone line (although fixed now), the new place is pretty nice, secure and stuff, 2Kms from work, nice views (guess I’ll post some nice pics I took the other day soon). You’re not allowed to hammer anything into the walls or anything here, or drill any holes, etc, etc, so I’m looking into getting as many PCs on 108mbps wireless LAN. Dodging masses of network cables around the passages between rooms isn’t too hot :).

Work’s just work, but it’s nice not having to fix people’s emails and printers every five minutes, I’m just left alone to write code and stuff. I’m strangely looking forward to work every day much more than I used to in East London, although I’m basically doing the same job (except the lame fixing stuff). Maybe it’s the free and easy access to the coffee machine. Unfortunately the interweb has been owned by a rather nasty proxy/firewall setup that seems to block completely random stuff, even development resources like parts of SourceForge (like most search results) and large parts of the online PHP manual. UnrealZA also works fine, until you try to view a thread… Pretty strange :/.

Guess I should stop babbling and go catch up on some Battlefield 2 :D.

I just came across a post on Voodoo Extreme about the fact that IGN are offering fansite hosting. The commentary along with the post really made me think about the state of fansites in recent years.

They really *have* pretty much completely died off. The closest you’ll get to a fan site these days is something like the SGS or Prophecy forums. I see the Prophecy homepage is even a store-front now, with the forum coming across as an afterthought. Perhaps a little closer to the original fansite idea, you get places like BeyondUnreal and GameSpy’s various Planet* sites. However, these sites have taken themselves from traditional fansites, to giant networks, many of which focusing on some business model or another, rather than the game that got them going in the first place.

On the other hand, a site like UnrealZA is perhaps one of the few remaining dedicated fan sites around. Although, most members on the forums hardly play the game any more :), the idea behind the site and it’s operation has remained pretty much the same since Buccaneer founded it way back in 1998 (granted, a lot of sections and things have been ‘streamlined’ or removed completely due to lack of interest from maintainers and readers alike).

Sadly though, I have also noticed fewer and fewer visitors, and new community members, on the site. Perhaps this is why the bigger sites have reformed themselves from mere fansites like UZA, to the giant networks they are today. I’d really like to try some new stuff with UZA, which I believe could be rather successful (thinking the ’network’ approach of some sites), however on the other hand, I’m worried about losing UZA’s ‘identity’ and ’legacy’ which has been one of the cooler things about being involved with UZA. It really is a pretty unique place on the local gaming scene, I think.

But we’ll see what develops over the coming months.

Yay, on Friday, I decided to take the plunge, and install Debian on my laptop. I’ve always wanted to try working in a Linux desktop environment, considering I do practically no Delphi development any more, everything’s either PHP or Python. Since Debian has plenty of support for both of these, it seemed quite ideal.

I’m not dumping the existing Windows install though, so I had to partition my drive. Now, partitioning drives is about the most nerve-racking thing I’ve ever done, no matter what software I’m using, no matter how little data I stand to lose, I’m always scared as hell something will go wrong. Doubly so on this laptop since I use it constantly for work, and it’s the default installation HP put on, which I’m not really eager to bugger up. Luckily, that all went smoothly though :D.

When it came to installing Debian though, I had a problem with the netinst installer I was using, in that a package or two would not install due to missing some authentication files or something. So, since that installer didn’t work, it was suggested that I try an older Sarge installer and upgrade to the Unstable branch from there.

As expected, that installation went without issue. Unfortunately I just had to try my best to keep the machine cool while waiting for the installation to complete and the ACPI applications to kick in so the fans would do their thing. Thanks Korpse for warning me about that in advance ;).

So anyway, after the base installation was done, it was trivial (as I have come to expect from Debian,) to get Gnome, X.org and GDM installed and running. Apache, PHP and the rest were even easier. I was very pleased to see that the Firebird SQL server (open source’d Interbase fork thingey) was available in Debian right away, so I plonked that in as well. All that was left was to install Subversion, and check out my work stuff. Once done, I was 100% ready for work :D.

There are a few things not working yet - I haven’t had much luck with the wireless LAN. Gnome’s wireless LAN configuration applet thing is missing WPA-PSK authentication options (which I’ve configured my wireless AP to use), it only supports WEP. I also can’t seem to get the WPA tools (wap_supplicant) to work correctly. Based on the output I’m getting though, it *looks* like it’s connecting to the access point - it manages to find the AP’s MAC address and everything just fine, and it reports the authentication was successful, but beyond that, I can’t actually ping anything, and all traffic still seems to be trying to go through eth0 (wired LAN) rather than eth1 (wireless). Guess I need to learn a bit more about Linux networking… heh.

Another thing that’s not quite working is Bluetooth. Again, it *seems* to be working, the hardware is detected, and is working fine. My phone can pair with the laptop fine, using the PIN I’ve defined, but I can’t seem to transfer files or anything in either direction. I’ll admit that I haven’t played with this much yet, but I’m not really sure where to go next. I haven’t even tried looking into infra-red yet :).

And yes, I do use all these things, that’s why I spent so much on this laptop :P.

I also haven’t installed the ATI drivers yet, it looks like it’s going to be a bit of a mission on it’s own though.

Along the way I’ve also discovered some interesting new applications I haven’t seen or heard of before. gDesklets seem like a nice way to waste some CPU time and memory if you like to keep your desktop busy. Beep Media Player seems like a very nice alternative to XMMS, seems a lot more stable, and the general feel integrates better with Gnome. RapidSVN looks like it’s trying to be a nice enough SVN front-end, however I find the good old command-line a lot more friendly and efficient (and it crashes less). Sylpheed is a rather nice little mail client, and works well as an alternative to Thunderbird - assuming you’re unhappy with Thunderbird though. ibWebAdmin is a neat web-based tool for managing your Interbase databases, not as feature-packed or good looking as phpMyAdmin, but it does what it needs to do pretty well.

All that’s left now is to give it a shot at work tomorrow, and see how it all goes :).

I’ve had a couple of questions regarding my Battlefield 2 Stats in Python post, and how it may be possible to do the same in PHP, so I thought I’d add an update for that.

Simple PHP code for Battlefield 2 Stats retrieval:

    ini_set("user_agent","GameSpyHTTP/1.0");

    $info = "per*,cmb*,twsc,cpcp,cacp,dfcp,kila,heal,rviv,rsup,rpar,tgte,dkas,dsab,cdsc,rank,cmsc,kick,kill,deth,suic,ospm,klpm,klpr,dtpr,bksk,wdsk,bbrs,tcdr,ban,dtpm,lbtl,osaa,vrk,tsql,tsqm,tlwf,mvks,vmks,mvn*,vmr*,fkit,fmap,fveh,fwea,wtm-,wkl-,wdt-,wac-,wkd-,vtm-,vkl-,vdt-,vkd-,vkr-,atm-,awn-,alo-,abr-,ktm-,kkl-,kdt-,kkd-";

    $pid = '43595724';
    $data = file("http://bf2web.gamespy.com/ASP/getplayerinfo.aspx?pid=".$pid."&info=".$info);

    $stats = array_combine(explode("\t", $data[3]), explode("\t", $data[4]));

    printf("%s has %s kills and %s deaths and a score of %s", $stats['nick'], $stats['kill'], $stats['deth'], $stats['scor']);

Note that if you’re not using PHP5, you’ll need to add the following drop-in replacement for the “array_combine” function:

    function array_combine($keys, $vals) {
        $i = 0;
        foreach ($keys as $key) {
            $newarray[trim($key)] = trim($vals[$i++]);
        }
        return $newarray;
    }

It’s also important to note that while at the time of writing this, this method of retrieving stats works, EA, DICE and GameSpy are supposedly working on a new XML-based stats system for BF2.

Updated: Since this was written, some things changed with the stats system, and the GameSpy application requires you to pass a bunch of columns you want info for. This can help customise the data you get back, so you only request what you need. I’ve included all the columns in the $info variable, which you can customise. Make sure it contains only valid columns, or you won’t get any data back at all.

For info on what to do with the stats, and what all the columns etc. mean, check out the BF2 Technical Wiki.

So Korpse pointed out a rather interesting website the other night - Pandora.

Basically, it’s a rather nice little service which allows you to discover new music, artists, etc, by telling it which music you like already. Based on a song, or artist name you provide, it goes off and finds music matching an assortment of criteria matching the provided song/artist. It then proceeds to play a endless playlist. It’s all streaming, but it’s extremely good quality for streamed content, and practically never stutters, even when downloading or uploading other stuff (0n 512k ADSL anyway).

During your listening, if it plays something you don’t particularly like, you can tell it so, and it’ll further fine tune the playlist, the same applies to something you do like.

I do have a few things I’d like to see added or changed though. The ability to play your well refined playlist in the player of your choice

  • could play pretty much like a normal streaming playlist. Show a timer/track progress bar thing, it’s just nice to know :). Ability to go back and play previously listened to tracks. Perhaps two additional rating categories - it’d be nice to rate vocals and music separately.

Anyway, my 10 free trial hours are up, and I can’t seem to cheat by deleting cookies or something. My MasterCard should be arriving this week some time, and I’m seriously considering that $36 for an annual subscription…

Someone posted an image of somewhere they’re staying in “Qatar Doha” (no, I don’t know exactly where that is ;)) on the SGS Forums, mentioning how similar it looks to the Battlefield 2 map, Strike at Karkand.

I thought it might be cool to try to make the image look a bit more like the map, adjusting the colour balance, adding the orangey dusty air effect, etc. Further on, someone posted an image with some player characters and a jet overlayed, I though it was a pretty cool idea, so I whipped out Photoshop, my previously modified image, the official BF2 site (for screenshots of vehicles and characters), and got to work.

The end result is pretty cool I think :D. Click for full versions (original on the left, mine on the right):

Lost in time

Update; toned down the colours a bit, didn’t realise the monitor I did this on originally was so off :P.

A few weeks ago, the Serious Sam 2 demo was release, and my clan, the Avatars, and I were dying to try out the co-op, since we had played the previous game though together (although some shocking networking code made it near impossible), and were rather looking forward to SS2.

Unfortunately however, the demo’s internet play functionality was rather broken. After some digging on various forums looking for a solution, someone found a rather useful little utility - Hamachi.

Hamachi is basically a very simple VPN system, which behaves pretty much like an instant messaging client. When you install it, you’re run through a very informative little tutorial to get you started. During the process, you’re assigned an IP in the 5.5.x.x range - though I’m not entirely sure where the range starts or ends, we all got IPs like that - and a new Hamachi network connection is created under Windows. You may then join or create as many private or public networks as you like.

Members on the network can ping each other on their “Hamachi IPs”, they can browse shares, and copy files backwards and forwards (shares even end up showing up in your “My Network Places” eventually), send messages back and forth, etc. And of course in our case, it registers in games as a LAN connection, so you can easily play any multiplayer game with LAN support, without the need for the person hosting the game to mess with their firewalls, routers, port forwarding, etc.

There is a Linux binary available, however I couldn’t get this to work on my Debian Sid server, there were various tunneling problems, which are a bit beyond my networking skills to resolve.

In general though, the possibilities are pretty endless. Anything you can do an a LAN, you can securely and easily do with Hamachi, on a network spanning the world if you really wanted.

“Oops, I just printed my bank statement to Joe in Australia’s printer!”

Ever since installing BattleField 2, I’ve had a problem with taking screenshots. Basically, the game completely freezes up when I press whatever key is assigned to screen captures, and I need to reset my computer completely. Also, I seemed unable to use Fraps to make screen captures since the game seemed to be blocking all requests to whichever keys I assigned to Fraps’ capturing options.

I decided to rather just create my own utility. A simple application that hooks into the “Print Screen” key’s press, so when you press Print Screen, this app takes the image out of the clipboard, and will write it to a folder as a JPEG image. You can customise both the output location and the JPEG compression quality. The images are named after the current date and time.

It doesn’t work only for games, ANY time you press Print Screen, a screenshot will be saved. I think that could actually be pretty useful.

Yes, there are a million screen grabbers for Windows out there, but writing something yourself is both educational, and you know exactly what it’s doing. Also, I now have a single screenshot button for games, and everything else as well :D.

Note this may not work for all games, as some games tend to dump quite a mess to the clipboard when attempting a Print Screen.

This post also serves as a test for the attachment plugin for WordPress I recently installed ;).

Yes, so everyone’s obsessed with checking their BF2 stats these days ;).

Anyway, I wanted to give my Supybot IRC bot (“Nooblet” on Shadowfire) the ability to check my own and other people’s stats whenever they felt like it. I came up with something like this:

import urllib2
from string import split
from time import time

# the columns you want to request data for. comma-separated string.
info = 'per*,cmb*,twsc,cpcp,cacp,dfcp,kila,heal,rviv,rsup,rpar,tgte,dkas,dsab,cdsc,rank,cmsc,kick,kill,deth,suic,ospm,klpm,klpr,dtpr,bksk,wdsk,bbrs,tcdr,ban,dtpm,lbtl,osaa,vrk,tsql,tsqm,tlwf,mvks,vmks,mvn*,vmr*,fkit,fmap,fveh,fwea,wtm-,wkl-,wdt-,wac-,wkd-,vtm-,vkl-,vdt-,vkd-,vkr-,atm-,awn-,alo-,abr-,ktm-,kkl-,kdt-,kkd-'

# this is my BF2 ID. You can also query the stats server with "nick" rather than "pid", but I've had problems with some characters
pid = '43595724'

opener = urllib2.build_opener()
opener.addheaders = [('User-agent', 'GameSpyHTTP/1.0')]  # otherwise GameSpy's servers will block your request
webData = opener.open('http://bf2web.gamespy.com/ASP/getplayerinfo.aspx?pid=%s&info=%s&nocache=%s'%(pid,info,round(time()))).read()

statsData = split(webData, "\n")

cols = split(statsData[3], "\t")
data = split(statsData[4], "\t")

stats = dict(zip(cols, data))

# you now have a nice dictionary with a few hundred bits of stats data.
print "%s has %s kills and %s deaths and a score of %s" % (stats['nick'],stats['kill'],stats['deth'],stats['scor'])

Thanks to korpse and mithrandi for showing me the “zip” function. It takes the list from the first parameter, and uses those values as keys in a dictionary, the values from the second parameter are then used as values in that dictionary. I was using map(None, keyList, valueList), but zip seems cleaner.

Anyway, if you’re looking for more info on stats querying, try the BF2 Technical Info wiki, or check out SaladFork’s Guide to Creating a BF2 Stat Signature - although it’s in PHP, he does give a nice list of column names and their meanings, you can also grab lists of ranks, weapons, vehicles, etc.

Update: Also see: Battlefield Stats in PHP

Updated: Since this was written, some things changed with the stats system, and the GameSpy application requires you to pass a bunch of columns you want info for. This can help customise the data you get back, so you only request what you need. I’ve included all the columns in the info variable, which you can customise. Make sure it contains only valid columns, or you won’t get any data back at all.

As above, for info on what all the columns etc. mean, check out the BF2 Technical Wiki.

I decided it might be a good idea, from a debugging and administrative point of view, to save the reports people were viewing in my application at work. Since users are distributed all over the country, and I have to communicate with them over the phone with on-the-spot problems, it’s hard and very time consuming to get them to tell me all the parameters etc they’re using to generate a report which they are having problems with (mostly, the data looks like something they weren’t expecting).

Anyway, I thought saving the exact report they are viewing is much easier for me to simply call up while someone’s on the phone, than doing the whole ‘which options did you use?’ thing.

Option one was saving each report to a PDF file on the server, but, that’s pretty inflexible, and also, people can view more than just PDF files with my reporting options (emails can be send direct, zip files can be downloaded, and data can be downloaded in csv format), so that wouldn’t always work out.

So I looked into serializing the actual report object used to generate any of the above report types, since that object contains absolutely all data, totals, titles, info, etc.. Unfortunately, PHP’s built-in serialize() and unserialize() functions don’t work too well with complex data structures (arrays within classes, multi-dimensional arrays, etc, etc), and I couldn’t really work around all that without writing a few GBs of code onto my report class.

SO, I turned to XML. As it turns out, the PEAR ‘suite’ of scripts contains a rather useful XML serialization class -XML_Serializer, which can turn any data structure into an XML string, and for reading those strings back to usable PHP variables and objects.

It’s really quite simple:

$object = new SomeClass();
$object->var1 = "Hello World";
$object->etc();

$serializer = &new XML_Serializer(array("indent" => "  ", "typeHints" => true));
$serializer->serialize($object);
$xml = $serializer->getSerializedData();

$xml now contains the full definition of $object in XML. You can write $xml to a file, save it in a database, whatever you like.

You can then come back later, and load the file/database record/etc into a string, and deserialize it…

$unserializer = &new XML_Unserializer();
$unserializer->unserialize($xml);
$object2 = $unserializer->getUnserializedData();

echo $object2->var1;
$object2->etc();

Quite fun actually :D. You can obviously do a lot of error checking, and other things, but that’s just the basics.

I sat down this afternoon and had a bit of a play with Gran Turismo 4’s Photo Tour option within GT mode. I must admit I’m rather impressed, and although it’s seemingly boring, it turned out to be a rather entertaining exersize.

It basically presents you with a couple of venues from around the world

  • Venice, Tokyo, New York, the Grand Canyon, etc, which are pretty much static scenes, with pre-defined car and camera ‘zones’ within which you may arrange things to you liking. You control the vehicle location, rotation and wheel rotation, and camera location, height, tilt, zoom, focus, etc. After you’ve got your scene arranged just right, you can fiddle with things like colour balance, saturation, etc to get the scene just right.

You then get to take your photo in a lovely high resolution, and save it to a USB flash disk! WOW! Someone finally found something useful to do with the PlayStation 2’s USB ports, aside from whacky controller contraptions. Anyway, once saved, you pop off to your nearest PC and offload your pics (which are saved in JPG format).

A few of my results (I only have cheap cars in my garage at the moment);

Images lost in time

titleMy Cat

date 26 Aug 2005

Because “Weblogs are things with cat pictures in them.”

Lost in time

So ja, it’s been reported that the games SWAT 4 (via the latest patch) and the latest Splinter Cell games both have ’live’ advertising, which download as you play and display stuff, basically no better than banners, on posters, vending machines, billboards, etc. within the games.

Both of these games seem to have been ’enhanced’ by what seems to be a recently launched ‘service’, Massive Incorporated, specifically set up to place advertising within games.

Personally, I have a few problems with this. Firstly, I’ve already payed around R400 for my game. Now as I see it, things like advertising are usuallly used to subsidise either free services (eg: banner ads on many websites), or relatively cheap services (eg: ads on TV and radio). Now why the hell do publishers feel the need to milk even MORE money beyond the R400 a copy they are selling?

Secondly, there is NO opt-out. If you want to play the R400 game you just bought, you have to agree with the fact that you will be downloading these ads and wasting bandwidth on every map/level change, that they will be defacing your game, and you will be sending the advertisers ‘usage statistics’ - how long you looked at each ad, what angle you looked at it from, how far away you were from it, etc. As I read elsewhere (forgotten the URL at the moment), it’s pretty scary that this is the ‘first generation’ of this technology - I can only imagine the kinds of things they’ll track about your playing habbits in the future.

And finally, it’s just plain intrusive. I like seeing often humerous made-up posters where they’re needed - which is normally seldom in most games. I don’t want to see darn Coke ads in my games. Also, I’m sure publishers and advertisers will start pushing developers to include even more and more advertising billboards/posters/vending machines/etc in their levels, until one day you’re sneaking/running/driving/strolling/handing/rolling around some kind of psycho colourful flashing whacked hall of nothing but lame-ass banners and shit. Piss off with that stuff, please.

Aaaanyway, you may have guessed this idea doesn’t appeal to me at all. Unfortunately once the trend is started and the standards are set by a few games, things will only go downhill.

What’s also scary is that both SWAT and Splinter Cell are Unreal engine games :(. At the moment though, neither Epic or Midway have signed on with Massive Inc. it seems.

I only noticed this rather recently.. But you can set up Firefox’s ‘Homepage’ option to open multiple tabs when you open the browser.

Just enter the URLs you want to open by default, separated by the pipe (’|’) character. The same effect can be achieved by opening all the tabs you want, then use the ‘Use Current Page(s)’ button.

So you can now open Google and 200 random websites you probably won’t even look at anyway! Personally, it irritated the hell out of me, but maybe someone would find it useful…

Thanks to a link mithrandi posted in IRC, I’ve discovered this rather useful tool.

Gregarius is a web-based RSS/RDF/ATOM feed aggregator (oops, I didn’t copy/paste that from their homepage :P) which you can install on your own server, and manage as you like.

Setup was a breeze, I just checked out the latest version from their Subversion repo, copied the files over to /var/www, and created a MySQL database. First visit to your Gregarius URL prompts for database access settings, and creates the tables and everything for you.

It has an extremely clean interface, I suspect in fact that it’s highly influenced by WordPress (their “devlog” using WordPress further convinces me), but that’s beside the point. It’s extremely easy to manage categories, add feeds (it automatically fetches a “favicon.ico” file if one’s available as well), etc. I got my whole installation and 10 feeds all setup within around 10 minutes.

It presents the feed items nicely enough, sorted by date, with links to the full versions, as well as descriptions/summaries. It also keeps track of items you’ve left unread, making it easy to come back to them later. Another helpful feature is the ability to search within the feeds it’s downloaded and stored, allowing you to pull up any item at any time, I’ve already found this quite useful.

All-in-all, a pretty great little package. It sure beats Thunderbird’s RSS reader hands down. If you subscribe to any feeds, have the ability to host it (just PHP and MySQL required), and 10 minutes to set it up, throw away your existing RSS readers and get your own Gregarius aggregator up and running :).

Ok, so this is such an insanely simple thing to do. I once tried looking for a PHP class or package which could write Excel .xls files from data in an array. Well, I found a really ugly class which simply saved a .csv file as .xls. Anyway, I ended up writing my own 4-line function for that:

function arrayToCSV($data) {
    $csv = implode(',', array_keys($data[0])) . '\r\n';
    for ($i = 0; $i < count($data); $i++) {
        $csv .= implode(',', $data[$i]) . '\r\n';
    }
    return $csv;
}

You’ll have to do your own validation for empty arrays and things elsewhere. It returns a string with each record from the array on it’s own line, separated by commas. $data is expected in a format something like this:

$data[] = array('name' => 'Bob', 'age' => 12);
$data[] = array('name' => 'Jack', 'age' => 15);

Which looks something like this: print_r($data):

Array
(
    [0] => Array
        (
            [name] => Bob
            [age] => 12
        )
    [1] => Array
        (
            [name] => Jack
            [age] => 15
        )
)

If you’re using ADODB, you can use this little function to convert the recordset to a suitable array (there are some built-in functions to convert recordsets to arrays, but they all end up giving you pretty useless data).

function rsToArray($rs) {
    $arr = array();
    while (!$rs->EOF) {
        $arr[] = $rs->GetRowAssoc(False);
        $rs->MoveNext();
    }
    return $arr;
}

I must say, I’m rather disappointed with my “SmoothWall experience” so far. I’ve been tasked with setting up a SmoothWall firewall/proxy machine at work, and from what I’ve read, it’s like the best thing since sliced bread.

Unfortunately I cannot agree.

The installation tends to go fine, it partitions the hard disk by itself, installs fairly fast, then steps through a simple setup ‘wizard’. Here we are prompted if we want to enable or disable ADSL. Now, I want SmoothWall to connect via our ADSL line. BUT, it seems the developer’s idea of “ADSL” is in fact “USB ADSL Modem”.

Anyway, after figuring that one out, and after much shuffling of subnets and IPs between the router, SmoothWall, and my PC, I finally get it to use the router as a gateway. I try visiting some sites - DNS lookups fail. I take a look in all the log options on SmoothWall, and find the firewall is blocking DNS traffic, and is trying to route everything through the same (“Green”) NIC, rather than the second (“Red”) one.

Sooo, turns out I can fix this by running the “setup” tool again, and ‘pretending’ to change the IPs, so it resets everything (re-writes the firewall rules maybe?). Cool, everything’s working again. Not quite.

Seems after that, the proxy magically stops working altogether, so from the web interface, I just disable it, and re-enable it. Cool, everything’s working now. Riiiiight.

A few hours later, suddenly the internet is dead. Hmm, seems the firewall is blocking all traffic again and routing though the same NIC. Sooo, I repeat the whole IP change/reset, proxy reset, etc, and everything’s cool.

A few hours later I find myself repeating the whole procedure again.

This is seriously lame, having to practically reboot the entire machine every few hours. So I think maybe I’ll try to set up a PPPoE connection. So I go and configure the router correctly, test ‘dialing up’ with my machine in XP, all’s cool. Now to set up SmoothWall. Running the setup tool again lets me set the “Red” interface to “PPPoE”, and that seems done. Now where do I put my username and password to dial up?

Apparently the “ppp settings” page of the web GUI is where it’s done. Now excuse my ignorance, but this looks like a modem dial-up page, asking for phone numbers, which COM port my modem is on, etc, etc. A bit of searching around the rather un-helpful support forums, reveals that this is indeed where you need to configure PPPoE usernames and passwords. Just leave all settings alone except for login details.

I give it a shot, tell it to connect, nothing happens. Check the logs, and not surprisingly, it’s trying to connect via ttyS0 (COM1).

Now, apparently there’s supposed to be an option to select the correct interface in the drop-list where you select which port your modem is on, on the “PPP Settings” page, but for some magical reason this does not exist for me.

Unfortunately their forums are also not very helpful it seems, and even after composing a very descriptive help request, I get a rather sarcastic “RTFM” response for a subject not covered in the manual.

Basically the manuals are not up to scratch, the support forums are full of leetbois, the options in both the setup tool and web UI are obscure, and the whole thing is bloody useless, needing a darn reboot every few hours. WTF.

I’d love to send the whole thing to hell, but unfortunately I have to get it to work. *sigh*

titleNew phone

date 8 Jul 2005

So I got myself a shiny new samsung D500 phone!

Since WP supports posting by email and this phone can send them, I thought I would mess around a bit with the concept.

Here’s a rather bad photo taken out my office window…

Lost in time

Since I’m bored at the moment, I might as well post some code :D

PHP has 2 nice functions, explode() which breaks a string into an array using a separator, and implode() which takes an array and glues it back into a single string using a separator. I use it regularly, so eventually ended up needing one for Delphi too.

I cannot take full credit for the Explode function however, I found it somewhere and can’t for the life of me remember where that might be. It is somewhat modified from the original though…

Also note that these work with TStrings, rather than arrays.

function Explode(const str: string; const separator: string): TStrings;
var
  n: integer;
  p, q, s: PChar;
  item: string;
begin
  Result := TStringList.Create;
  try
    p := PChar(str);
    s := PChar(separator);
    n := Length(separator);
    repeat
      q := StrPos(p, s);
      if q = nil then q := StrScan(p, #0);
      SetString(item, p, q - p);
      Result.Add(item);
      p := q + n;
    until q^ = #0;
  except
    item := '';
    Result.Free;
    raise;
  end;
end;
function Implode(const Strings: TStrings; const separator: string): String;
var
  i: Integer;
begin
  Result := Strings[0];
  for i := 1 to Strings.Count - 1 do
    Result := Result + separator + Strings[i];
end;

titleEmail testing

date 26 Jun 2005

Wordpress lets you write email messages to a specific email address and
it’ll periodically check for new messages, and post them to the blog!

Cool beans!

titleBattlefield 2

date 15 Jun 2005

MMMMMMMMM

This game (demo at the moment) is really sucking up all my evenings :D. The gameplay is absolutely brilliant. The whole Squad story is just ownage when playing with a decent bunch of players. Just a pity squads can only be 6 people big.

I can actually fly planes too. Managed to shoot down a helicopter and a plane last night (though the plane kill took about 5 minutes of frantic flying from my victim). Though there’s always someone else behind me waiting for me to fly straight for a half second too long :(.

If you like team games, with a rather unrealistic, yet somehow realistic feel, get this when it comes out on the 28th (South African release apparently).

Ok so this is a little trick I picked up a few years ago when I developed the first version of ECheck and I started learning the POP3 protocol. It’s come in very handy when I’m away from my email client and don’t want to receive email anywhere and fragment my mailbox by spreading it across a few machines.

Firstly, this’ll work on both Linux and Windows systems, with no extra software needed (assuming most Linux distros come with a Telnet client by default).

It’s a pretty useful thing everyone with an email account should know ;-).

Firstly, open a command prompt, and execute the following:

$ telnet <your.mail.server> 110

would obviously be replaced by the address (IP or hostname) of your POP3 server.

If you connect, you should be presented with a welcome message and a “+OK” message. You then enter the following commands to log in, replacing the contents of the "" with your details:

user <your@username>   pass <password>

After which, you should be greeted by another “+OK” assuming you managed to log in. If you make a typo, just send the line with the type

  • you usually cannot backspace and correct mistakes. Issue the correct command again.

Now that you’re in, let’s see your messages. To see how many messages and how big each of your messages is, send the following:

list

Once again a “+OK” line should be shown, followed by a very simple list of message IDs and file sizes (in bytes). Let’s preview a message, shall we?

top <id> <lines>

The headers for message , followed by up to number of lines from the message will be spammed to your console. You can find both the “Subject:” and “From:” header lines to decipher who the message is from and what it’s about. Of course you can also read the body…

Hmm? This message is junk mail or spam? Want to delete it before it hits your inbox?

dele <id>

… will delete the message with ID . It’s important to note that the message IDs are maintained - so if you delete message 1, message 2 will not fall into 1’s place. It’ll remain 2 for the remainder of the session.

If you’ve deleted the wrong message, all it not lost. You can ‘reset’ the mailbox status to how it was when you first connected:

rset

And once you’re done mucking around, disconnect nicely:

quit

It’s also worth noting that the commands are all case-insensitive, though I’m sure the ‘correct’ way of doing it would be to use all caps for commands, the server doesn’t seem to mind either way.

Have fun…

I haven’t really seen a lot of news about the OpenOffice.org 2 Beta release. It seems to me like a pretty important thing :P.

Anyway I popped by the OO site recently and grabbed the beta (which is actually version 1.9.79). Anyway, first thing to note is the loading time has unfortunately not really changed much since the 1.1 range. Next thing you’ll notice is the look. It looks a few million times better than previous versions, and actually looks like a native Windows application now. The toolbar icons all look much clearer - I never really liked the previous version’s icons much at all, they were all very unclear as to what they did.

Next up, Calc now supports 64000 rows!! This was my biggest gripe with previous versions - they were limited to 32000 before, which pissed me off no end when trying to work with large chunks of data. For me, this is the biggest improvement I could have hoped for :). I also found defining custom number and date formats somewhat easier than before.

I can’t say I’ve used Writer all that much, so I can’t comment too much on that, but I did note that the Print Preview has been properly overhauled. The Print Preview seemed to have been an issue when trying to convert people :).

I can’t say I care much for the new Open Document Formats, since most of my work requires me to use Excel and Word files, so I just write to those formats whenever I save. Lets see if MS will start to support the format in Office now that it’s been recognised and approved as a standard.

Overall, I guess the real version 2 can only get better :).

I’ve been adding some nifty things to my PHP project at work (cellphone starter pack invoicing, usage tracking [big bro is watching you earn him money every time you use your pre-paid airtime :P], etc). It’s got a lot of pretty nice features. Using client-side JavaScript, it actually pretty much behaves as a normal desktop application, only it lags like hell when you visit other pages (slow web server :P).

Anyway, I can’t claim I’ve written all the snazzy features myself unfortunately. Due to time and pressure I’ve been relying on good old Open Source to help me out. There’s actually a helluva lot of stuff out there to make things easier for just about anything you need to do…

  • ADOdb - http://adodb.sourceforge.net/

    Obviously the first thing to get going on any database-aware application, is to actually interact with the database. PHP has an Interbase module, with a whole bunch of Interbase functions. These all work fine, and there’s really no problem with them. ADOdb however makes working with SQL databases so much easier. No need to remember PHP’s randomly named module functions, and it gives you access to a huge assortment of database drivers (of corse all dependent on normal PHP modules). It’s even available for Python now!

  • Smarty - http://smarty.php.net/

    Next you’d presumably like a fancy presentation for your application. You have three options here - painfully output every single line of HTML manually through your code, create yourself a template engine/language, or use Smarty. Smarty is a Template Engine, which lets you define “.tpl” files which are bascally just HTML files with a couple of variable placeholders and smarty function calls. But it’s not just the simplicity of creating a Smarty instance, assigning variables to it, and then just calling display(), it’s the functions you can put into your template files. Looping through customer listings, building tables or drop lists, check lists, etc, etc, etc. One of the most useful things I’ve found is the ability to define your own smarty functions, allowing you to add custom functionality to your templates and the output they generate.

  • PHP pdf / PDFClass - http://ros.co.nz/pdf/

    One of the requirements of this project was that reports had to be generated in user and printer friendly PDF format. At first I looked into the option of having Smarty generate tabular reports, and get an HTML to PDF processor (there are several PHP options available) to turn my HTML into the PDFs required. Unfortunately, for the most part, these converters are heavily buggy, and didn’t give me very much control at all over the output (ok, I had full control over the output, but things like page headers and footers, page numbering, etc, etc are required for nice reports). Anyway, so I set about using PHP’s PDF functions. Unfortunately, that turned out rather risky across different versions of PHP, and was generally a pain to work with. Enter this package. It doesn’t require any of PHP’s PDF modules, so it’s free from cross-version and cross-platform bugs and stuff. It also has a bunch of nice functions for headers, footers, tables, etc. It also provides the option to save the output to disk, output direct to browser, or plop the output into memory where I can play with it. I’ve built a very nice reporting class around this package.

  • Code 3 of 9 Barcode Generator - http://www.sid6581.net/cs/php-scripts/barcode/

    Another requirement of the system is the ability to group multiple items into a single item. From the code side of things, it’s fairly simple, but to users, trying to manage these million boxes of starter packs and remembering or creating their own codes for these boxes would obviously be rather difficult. Anyway, I though it’d be nice to offer a barcode people can print and stick to the boxes. Enter this little script. Couldn’t be easier to use, and with the help of a little Javascript, users can even scale the barcodes up and down (by dynamically reloading the image, not just changing the dimensions and possibly corrupting it) before printing.

  • PHPMailer - http://phpmailer.sourceforge.net/

    I’m using this for sending my PDF reports via email. It allows you to easily attach files, or file content (so I don’t need to save the PDF’s to temp files before attaching, just attach the output directly from script). Also supports SMTP, so no need to rely on PHP’s mail configuration.

I’m also using a nifty little ZIP lib that allows me to zip my in-memory PDF reports, and send them direct to the browser for downloadable reports (since a normal PDF will open in the browser). Unfortunately there’s no readme or author URL in the source :)

I did get it from PHPClasses.org though, which has quickly become by first stop for anything I need in a hurry that I couldn’t be bothered, or don’t have time to write myself. Nice rating system and “top 10"s filter out the good stuff instantly, making finding stuff really simple. I highly recommend it to any PHP developers.

titleNew Toy

date 13 May 2005

So I went and bought myself a brand spanking new laptop last week :D.

It’s an HP Compaq NC8230 featuring the works - Intel Centrino CPU, ATI X600 ‘mini’ PCI-Express with it’s own 64MB RAM (don’t you just hate ‘shared video RAM?’), 15.4" widescreen display (with ambient light sensor to adjust brightness dynamically! Ooooooh, aaaah), only a 40GB HDD still, wifi, bluetooth, smart card reader stuffies, Win XP Pro SP2, etc etc etc.

All very nice :)

I went and got myself a virus on the day I unpacked it though… So much for the pre-installed Norton AntiVirus. Dumped Norton and tried out the home edition of avast! Anti Virus, which saved me rather smartly. Seems much nicer than the good old AVG system.

Anyway, it’s not as pretty as my old one (nx9010), but after a week using it at work, it actually feels more comfortable despite it’s more rigid, rectangular appearance.

Overall I’m very impressed :-).

Well because I’m apparently not doing any work here… I’m being trekked off to JHB yet again. No idea when I’m even getting back. Lovely 3 days notice I’m given too.

Seems whenever things in my life start settling down and I actually start getting things done, this shit pops up…

Hrm, I just remembered I was supposed to do some work for an old client this weekend too… LOLOLOL…… :-(

Dunno if anyone would have noticed but the site was blinking on and off last week, with dynamic DNS issues.

I’ve been using an application which runs as a service on my Windows machine, but it seems to often give up if it can’t get a new IP or the update fails, and sometimes it just doesn’t bother even trying :-).

Anyway I slapped up a quick Python script to be run from a cron job at 5 minute intervals to check a website which provides my IP (like http://checkip.dyndns.org), grab the first IP it finds, and updates my ZoneEdit account with the new IP.

Seems to have been running reliably the past few days now.

I’ve dumped it on the Files page if anyone would like to give it a go. It’s set up for ZoneEdit, but I’m sure it’s easy to adapt to other services as well.