MineCraft RCON via PHP

Today I went looking for examples of how to talk to a minecraft server via RCON. There is not a lot out there, and that surprised me.  I did eventually find a PHP script that worked, but it required the modification of an existing class.  I don’t like modifying someone else’s source class files to make a program work, that is why PHP has the ability to extend the class.   What follows is a simple program, that extendis the verion 1.0  rcon.class.php from http://fremnet.net/article/199/source-rcon-class and connects to a minecraft 1.2.3 server and executes the console command “say”, the result is returned in a string.   I hope this example helps others out. See the example after the break.
Continue reading


Nested ReWrite Maps

Today, in helping out a co-worker I came up with a pretty cool ModRewrite rule set. The rule is to be used to migrate users web pages to a new server with new user names. The rewrite will map the old user names to the new user name automatically, allowing existing sets of web pages to easily transition to the new user name without any old links breaking. This was accomplished using two RewriteMaps. The first map is used to convert any case of the old user name to lowercase. This is handled using the int:tolower function.
RewriteMap upper2lower int:tolower

The second RewriteMap is used to perform the actual user lookup. This is accomplished by creating a map file that contains a space separated pair of the form: lowercase_old_user_name new_user_name

oldusernameone Z00000001
oldusernametwo Z00000002

The map file is then put into play by using the line:

RewriteMap usermap txt:/etc/apache2/userlist.txt

There were two prospects to the overall rewrite that posed a bit of a challenge to me. The first challenge was to prevent the rewrite from occurring when the URL request contained the new format of user name. This was ultimately accomplished using the RewriteCond statement.

RewriteCond %{THE_REQUEST} !/~[Zz][0-9]{8}

The new user names takes the format of a single, specific, alpha character followed by 8 numeric digits. This made for an easy regular expression to match on, and using the ! character negates the normal “does match” condition of the regular expression into a “does not match” condition.

After that was solved the next problem to solve turned out to be the most difficult of all. I could not find any instructions on the net about how to properly nest two RewriteMap maps inside of each other. My first solution was slightly creative, in that I used two chained ReWrite rules. The first rule assigned the lower cased user name to an apache environment variable, then the second rule used that variable as the input to the second map. While this solution did work, it seemed really convoluted, and I knew there had to be a simpler way to do it. After walking away from the rule for a little bit, I came back to it and hit upon the correct method to nest the two maps.


Translated into English this essentially reads as, take the first match and pass it to the upper2lower RewriteMap, and take the results of that RewriteMap and pass it into the usermap RewriteMap. Or more simply, make the user name from the URL lower case, and then lookup the lower case value in the file userlist.txt.

Next up, I just had to iron out the regular expression needed to match and replace the old user name and still retain the remaining parts of the URL, while preventing user names that do not match in our lookup to still trigger a standard 404 error.


Pretty straight forward over all. In English it essentially reads:
Match the beginning of the line with /~. Take the next one or more (+) A-Z, a-z, or 0-9 characters and place them into variable $1. Place any characters following an optional / into $2. There is a flaw in this, but it should not be an issue in our implementation. If you can identify it, or better yet fix it, please post your solution in the comments. 🙂

One additional touch, that I felt was important to add was the R=301 flag. This causes apache to generate an HTTP 301 permanent redirect header. This should help Google and the like properly index the new URLs. The final rewrite code block follows.

RewriteEngine On
RewriteMap upper2lower int:tolower
RewriteMap usermap txt:/etc/apache2/userlist.txt
RewriteCond %{THE_REQUEST} !/~[Zz][0-9]{8}
RewriteRule ^/~([A-Za-z0-9]+)/?(.*) http://www.example.com/~ ${usermap:${upper2lower:$1}}/$2 [L,R=301]

I’d love to hear comments, or improvements on the rule set.

Installing VMware Player 2.5.1 in Ubuntu 8 via rpm

I have been running VMware player 2.0.4 since August to launch a windows XP Virtual Machine.  I don’t really use the VM all that often, but when I am doing web development, I need to be able to test in IE, and thats the only way I can do it w/o rebooting to Vista *shudder*.     Towards the end of September it started telling me there was an upgrade available.  I went to the VMware website only to discover they had stopped providing the .tar.gz version of VMware player.  My only options were .bundle or .rpm.    Not really feeling like I wanted to be all that adventurous I ignored the upgrade requests.    Finally after installing the latest kernel patches last night I decided to go ahead and upgrade VMware Player as well since I would have to re-compile the kernel modules again anyway for the new linux kernel.  Having never tried to install and RPM on Ubuntu I was at a loss.

Continue reading

Foxmarks in the Library

Recently I was asked by one of our librarians to come up with a way to easily add bookmarks to our Internet workstations.   A little background on this situation follows.  Our Internet workstations are all Linux based, with a custom version of FireFox.  This custom version of FireFox has a lot of things disabled to keep the browser in a stable stat.   I have removed the ability to modify the bookmarks on the workstation in any way. The event code for drag and drop, the menu items, you name it, its gone.   This has made it impossible for the librarians to manage the bookmarks on the workstations themselves.   Any bookmark changes have required me to connect to the machines via SSH and manually update the bookmarks.html file.    This method was just not convenient, and did not allow for easy updates by any means.

Earlier this week, thanks to the offloading of some tasks to our new employee, I was able to put some thought into this problem.   I needed a solution that was easy to maintain, simple for the librarians to use, and most of all, easy to implement.   That last criteria ruled out creating something from scratch, which I really didn’t want to do anyway.   Earlier in the week a co-worker had mentioned how he had just setup foxmarks on his machine and how it was going to sync his bookmarks both at home and work.   It hit me then, why not take a look at foxmarks.  I downloaded and installed it in my browser, and it did exactly as it was designed to.    I realized then that it was a purely native chrome based app.   This fact about its design made it a perfect candidate for what I needed.

I set to creating a generic account for the library, a simple task thanks to the easy to use interface.  Once that was done, I installed foxmarks into the browser on one of the Internet stations.  Due to the customizations, this was not as easy as it normally would be. ( I have all installation menus, and handlers disabled.  Ooops…) I finally worked out a way to install the extension, and once I did I set it to use the newly created account, and checked the box to save the sync password.   Foxmarks  performed its initial sync, and I was able to confirm the success by browsing the foxmarks website.   I then closed the browser, clicked yes on the dialog to clear all stored personal information and felt confident I had a good start.   I re launched the browser, hit sync, and foxmarks asked me for the password for the sync account.  What? I was certain I checked to save the password.  I checked it again, and restated the browser, again clearing the personal information.  Sure enough, foxmarks asked for the sync password again.   It then occured to me that clearing the personal information was probably clearing the foxmarks password.   That would be a problem for sure.  Confident that the password hurdle could be overcome, I set about to modifying the chrome files, and was able to hid the configuration menu items, and remove the keystroke sequence for accessing the configuration menu.

    <menupopup id="menu_ToolsPopup">
        <menu id="foxmarks-menuitem" label="Foxmarks" class="menu-iconic"
            insertafter="devToolsSeparator" hidden="true">

After the UI modifications were complete I  again launched the browser, and checked over the browser to make sure nothing was visible that could allow malicious patrons to manipulate the setup.    Everything I could think of was tested and it passed with flying colors.  I then added a bookmark via the website, and triggered the sync process.   After entering the password, foxmarks synced and the new item appeared.  Again, I still had to fix the password problem.   I  closed the browser again, this time un-checking the options to clear the password store.  After re-launching foxmarks synced perfectly, remembering its password.  This then confirmed for me that foxmarks was indeed using the firefox password store.  It makes perfect sense that it would, but of course in this situation, it’s very inconvenient.    I again dove into the code that comprises foxmarks.  I found, in the foxmarks-settings.js file two functions that handled the username and password.    As I suspected they ultimately called “return” with the value for the username and password.   A simple one line change to each of these functions resulted in a hard coded username and password that would stay put after a clearing of the password store.  By placing a return() just inside the function declaration we essentially bypass the default actions of  the functions.

 get username() {
	return "our_foxmarks_user_account";
        return this.getCharPref("username", "");

 get passwordNoPrompt() {
        return "our_foxmarks_account_password";
        if (!this.rememberPassword && this.sessionPassword) {

After saving the modified file, I started up firefox and hit the sync keystroke, presto, no request for password or user name, and the browser synced.  I restarted again, making sure to clear the password cache, and again foxmarks worked perfectly.   At this point I deployed the modified version of foxmarks to all of our workstations, and sat back and watched the fun.   Within a short period of time, every workstation had correctly synced its bookmarks and all was well.

Finally I  sat down with the librarians and explained how to work with foxmarks’ website interface.  By the end of the first evening after foxmarks was installed we had a healthy collection of frequently used websites all bookmarked, and categorized.   The sync process has been working well and we have had no real problems.  (there was one point where I had accidentally left one of the browsers restored to its default state and some things were modified, but I caught it quickly and fixed the problem.

This alone would have been a fantastic solution, but not being one to rest on my laurels, today I used foxmarks ability to create RSS feeds from links in folders, and used that data to allow the library to randomly select a link and twitter it.  Yup, more fun with twitter.

L.E.D. Fun

What do you get when you combine 24 awg stranded 2 conductor wire with a resistor, and a high intensity L.E.D.?

You get a really awesome spotlight so small that it can be easily hidden in even the smallest tree beach and yet illuminate a scene plenty bright enought.

Tonight, I wired 5 of these. 2 blue, 2green, and 1 red. Tomorrow I hope to make the housing for them.


Well, today has been a car day.   After getting the insurance thing straightened out, I stopped to fill up with gas.   While doing so, I placed my keys on the trunk of the car.  The temperature was of course quite cold… After filling up I got back in the car and stuck my key in the ignition.  When I did the plastic shroud that forms the hole for the keyring shattered.  It has been in bad shape for quite some time, so I wasn’t terribly surprised.

After work, I stopped at Wal-Mart to get a key made.   The woman at the desk looked at the key, and said “Oh, we can’t do that, it has a chip.”  I responded, “No, it doesn’t. It’s from 1995, they didn’t chip the keys then.”  “Uh huh… sure…  Let me show you, I’ll put it in our detector.”  I just smiled and nodded.  She stuck the key into their detector, and it didn’t light up.  She removed it and tried it again.  “Huh, I guess you are in luck, there doesn’t seem to be a chip.”  “Oh, Huh… Who knew…”  So then she struggled a bit with the machine trying to figure out what blank to use.  Once she got the key made, I paid for it, and took it to my car.  It opened the door just fine.  I stuck it in the ignition, and it wouldn’t turn. So, back I went, she made another key and this one suffered the same problem.   I kept it after I noticed what I assumed was the problem.  Their machine left a  square edge at the hilt of the key, when the original key had that spot at a 30 degree angle.

I then stopped at ACE Hardware thinking they might be better at it.  The man took a look at the key, asked me  “What year” “1995” “Make and Model?” “Ford Tarus” He then pulled out a book, and looked up the key and selected the right blank in seconds.  (A far difference form the Wal-Mart idiot method of sticking the key in a bunch of holes to find the proper fit)  He made the key, and I paid for it.  I took it to my car, and found that it opened the door just fine also.   I stuck it in the ignition and it wouldn’t turn.   At that moment of despair a little voice in my head said “hey, flip it over”. Not one to ignore the little voices in my head when they get loud, I did and the key turned just fine.

I drove home using the new key, confident that I could easily fix the other side of the key so it would work correctly.    When I got home the little voice chimed in again with, “hey try flipping over the Wal-Mart key too”.  I did, and that one also worked when inserted one way, but not the other.    I went inside and took a good look at the keys, in both cases there was the square improperly cut spot at the hilt of the key on one side.     I got out the Dremel, and ground down the square point, and brushed the rough sharp points off, I then went out to the car, and the keys both worked.


So, it would seem that Ford’s key design is really just two keys stuck together in one, and there is only one set of tumblers in the ignition afterall.
The only point in the key looking the way it does is so that it will work either way you put it in.  Who knew… (yeah, all you car people out there knew already didn’t you?)

iPod Scare

The past two days I have been re-installing everything on my work computer. It’s been hell. Thirty some apps to manually install, on top of the plethera of other work apps that are deployed by the network on first run. Today I plugged in my ipod and was appalled to see the message “iTunes has detected an iPod in recovery mode”. I panicked. Thankfully I refused to believe this was the case, as I had just used the iPod hours before and it was working fine. I did some searching on the net, and found Apple suggests that when this happens you should let it completely wipe your iPod. My response… NO… They then tell you if after wiping your iPod, you still get the message, try changing the drive letter assignment in windows. DUH! OF COURSE! I went into disk manager changed the drive letter assignment, detached and re-attached the iPod, and viola, all is well.

Why wouldn’t they list the least destructive fix 1st?

No HTTPS in IE, Active X untrusted, Windows Patches untrusted

This weekend I was asked to look at a computer that had been giving its owner a lot of trouble.  They could not visit any HTTPS sites in IE, or AOL.  The computer also could not install any patches / updates, it would complain about the patches not being able to be confirmed as coming from a trusted source.

The first problem, getting the HTTPS protocol to work was easy enough.  That one I just had to re-register the urlmon.dll

That was accomplished with:     regsvr32 urlmon.dll 

That returned the abiltiy to browse https sites. It did not, however restore any abiltiy to install active X controlls, or install and of the downloaded windows updates.  I did some more browsing, and came across a list of other DLL’s to re-register.

regsvr32 softpub.dll
regsvr32 wintrust.dll
regsvr32 initpki.dll
regsvr32 dssenh.dll
regsvr32 rsaenh.dll
regsvr32 gpkcsp.dll
regsvr32 sccbase.dll
regsvr32 slbcsp.dll
regsvr32 cryptdlg.dll

After these we re-registered  (initpki.dll  takes forever) I tried again and everything began to work as designed.    I was able to install ALL system updates and patches.  I was able to access ActiveX controls, and website viewed as they were designed to be.

All better

I’m so pleased to announce that I have, with some help from the guy I goto when things look bleak, completely recovered my home automation / file server.

Everything is back to normal, and actually a couple of things are working better.

Thank you Zack!

How did I fix it?

booted to the SLES 9.1 boot CD, ran the recovery mode. From the console there I was able to mount the partition on the system to a temp location. Then I ran “mkinitrd /mnt/oldroot”. mkinitrd ran through the kernel on the mounted partition, and built a new initrd and dumpted it to the ramdisk /boot. I copied it form there to the boot partition on the HDD and rebooted.

Poof! up came my system. Well sorta… The ethernet interface didn’t load, but that was because I had to change out the MB which changed the mac address. A quick rename of the config file and a network services restart gave me back my ethernet connection. I rebooted once more and everything came up fine. I still ahd to do some fidgiting with the X10 controller but got that going too.

It’s not just a paperclip…

I really love paperclips.

Ok, stop looking at the screen so funny.  I almost never use a paperclip for holding paper together.  I just love the convienece of paperclips when I need small pieces of stiff wire.  Yesterday, quite by accident, I got pulled in to consult on a damaged color laserjet 4650.   The paper pickup assmbly had been damaged by improper removal of a paper jam.  During that jam removal part of the printer that holds a paper guide door (comes into play when duplexing) was broken off.  After some time Ron and I found all three pieces of the guide while Calette was looking up the replacement part on HP’s website.

While looking the broken part over I decided I could probably fix it with a little ingenuity.  I came back to my desk grabbed my locktite superglue like compound, and returned to the broken printer.  Once there I “cut” a paperclip into small pieces the right size to act as support “splints” and glued them on the sides of the broken assembly. Just to make sure the rough areas where the breaks occured didnt cause anything to bind, I then coated the inside with a piece of book tape. (really heavy duity, scotch tape) We then left the glue to dry overnight. Around 11 today  I reassembled the printer. (The repaired part slid right into place perfectly. I was worried that it might break again while trying to get it into place.)  Then after a little mishap with popping a door spring loose that then required the printer to be dismantled even more than the 1st time, I re-assembled the printer again. Once the diagnostics, and calibration finished, I ran the paper path tests and held my breath.   “Ok everyone, cross your fingers”.  You know, it’s really funny to watch an office full of people simultaniously cross their fingers…
The printer quietly printed the 1st side, and without missing a beat, printed the second side of the page as well.

So, as I said in the beginning, I love paperclips.