Apache AuthMySQL
I had the pleasure of trying to figure out how to use AuthMySQL the other day, as I wanted to password protect my folders (in a simple fashion, since the content wasn’t essential) but wanted to avoid the whole flat-file .htpasswd system.
Lots of searching on Google helped, but it was funny that I found I didn’t have the Mod_Auth_MySQL module in XAMPP. It turns out the later releases of XAMPP removed the module for some reason. (There was a reason for it, but I wasn’t really interested in it, since I just wanted it working on my local machine!).
Getting the XAMPP Module
Getting it was actually pretty simple. You just need to find and download the 1.6.2 version of XAMPP. Make sure you download the correct version based on your operating system (since grabbing the Windows file wouldn’t work on Linux etc…).
It sounds insane downloading the entire thing for just one file, but unfortunately that’s really all you can do (unless you manage to find it elsewhere).
Once you have the mod_auth_mysql.so file, put it in your xampp/apache/modules folder, and then edit the xampp/apache/httpd.conf file.
Down around the file (was line 132 for me) is a line that looks like:
;LoadModule mysql_auth_module modules/mod_auth_mysql.so
The semi-colon at the front is basically a “comment”, disabling the module. Remove it, and then save the file. Restart apache (in Windows you can use the XAMPP manager).
Creating the Database Table
This is MySQL authentication, so we need to create the table. The table is pretty simple, at the most it needs 3 fields, a username, a password and a group.
Here’s a quick create script, but you can obviously make (or use) your own. I would suggest you don’t use plain passwords, rather if you use the MySQL md5 function, apache can work with that.
CREATE TABLE IF NOT EXISTS `auth_user` (
`id` int(3) NOT NULL AUTO_INCREMENT,
`username` varchar(25) NOT NULL,
`password` varchar(32) NOT NULL,
`usergroup` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`)
);
Then add a user to the database.
INSERT INTO `auth_user` (`username`, `password`, `usergroup`) VALUE ('username', 'password', 'groupname');
The group field should just be a group name, a simple string. We’re being simple here, but things can get more complicated if you want (such as multiple groups).
Setting Up
You can set up the authentication in your .htaccess file, like anything else.
Edit your file and add the following:
# MySQL Auth
AuthMySQLHost {your database host}
AuthMySQLUser {database username}
AuthMySQLPassword {database password}
AuthMySQLDB {database name}
AuthMySQLUserTable {user table}
AuthMySQLNameField {username field name}
AuthMySQLPasswordField {password field name}
AuthMySQLGroupField {group field name}
AuthMySQLNoPasswd on
AuthMySQLPwEncryption md5
AuthMySQLEnable on
# Standard auth stuff
AuthType Basic
AuthName "{Public name}"
Anything in {brackets} were added by me, and should be replaced (with no brackets).
Finally, on the folders you want to protect, just add the regular directives.
# If you want to allow any valid-user
Require valid-user
# If you want to allow only a specific group(s)
Require group groupname secondgroupname
That’s really it.
(Greasemonkey) Gaia Avatar Undo
I had another case of “distracted Greasemonkey writer”, where I’m on a web page and wondering why this certain something really doesn’t work that well.
Anyway, it resulted in me writing a new script, which I call the Avatar Undo. Like my last one, this is for GaiaOnline.com, and basically it adds a simple “undo” button to the avatar page. It records what items you put on, and in what order. Then when you click undo, it will go back and reverse those changes.
It is obviously not perfect, since it cannot compensate for server-side changes (like other items being removed due to layering clashes), however it is pretty good for the simple stuff.
This is something we all should hope Gaia adds, sometime in the future.
It can be found on my Gaia-based website, as well as on Userscripts.org.
Remember, this is a greasemonkey script, so if you don’t have it, go get it!
IDs starting with Numbers
We all know the ID and NAME conventions on HTML tags. The ID must start with a letter, and then afterwards can be any number, letter, hyphen, underscore or colon. So creating an ID of 56green would not work, as it begins with the number 5. Where as S6green would be perfectly valid.
Recently I wrote a greasemonkey script, and I found (to my horror) the website had used alphanumeric strings as their IDs. That was fine, but the catch was they didn’t check to see if each string followed the standards, meaning half started with a number.
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens (“-”), underscores (“_”), colons (“:”), and periods (“.”).
It didn’t bother them, as the elements were not directly referred to. However it was a pain for me and my script, and so I had to find a way to call the element.
In my example, the name of the element will be 25tuna.
$('#25tuna').hide();
// In this case, nothing would happen. The element would not hide,
// even if it was still on the page.
$('#25tuna').length
// Would = 0, even though we can see the element sitting on the page.
Instead, I ended up having to use a workaround for the issue.
$('div[id="25tuna"]').length; // now will equal 1
$('div[id="25tuna"]').hide(); // should now work
So while you can’t refer to the element using the regular notation, you can use it through attribute notation (since ID is another attribute on an HTML element).
This is not ideal, and does introduce its own performance issues. If it’s a case where you are able to alter the HTML element on the page directly (being your own website), do that and make the ID/NAME attributes conform. It will save effort and frustration.
However if you are writing a greasemonkey script (in jQuery like I did) then you may find this is your only option.
(Greasemonkey) Gaia – Search Avatar Page v2
This is a Greasemonkey script written for GaiaOnline.com.
This script basically comes around from me completely getting lost inside my own dress up page on Gaia. What it does is basically give you a place to type an item name, and then it will highlight said item in your dress up page.
I get lost in my avatar page, and items can be staring me in the face without me seeing them. So this does help a cluttered person like me.
Due to the way Gaia loads your inventory, it will only search the loaded tabs. Meaning if you want to find an item in any tab, you’ll have to click each and let it load first. This is done mainly because I wanted to make this simple, and to avoid any calls to Gaia. This script only parses the source, it doesn’t make extra loads on the page.
phpbb3 + Flyspray Part 2
In my previous post I mentioned how I wanted to bridge phpbb3 and Flyspray. Well, I’ve done that, but due to the way Flyspray works, it was basically a complete pain.
I love Flyspray, I really do, but I think it is time I moved on to a new bug tracking system. Unfortunately though I don’t know of that many (if you do, definitely please contact me through the comments!). I’ve tried Trac, but on the host I use it is an absolute nightmare to get installed. What I’d really like is a simple PHP-based system like Flyspray, but one that does get updated regularly.
The trouble I had with Flyspray is I basically had to hack it to get it working with my forum. In the end I get phpbb to do the authentication (on each page load), and if the Flyspray user doesn’t exist it manually creates it.
It definitely isn’t the ideal solution, the DokuWiki bridge that someone else (awesome person) wrote works perfectly, but that comes down to DokuWiki being easier to modify with plugins.
So yes, if you are interested in bridging Flyspray and phpBB3, it is possible. However it basically is bypassing all of Flyspray’s authentication and saying “This is the ID of the logged in user”. You also have to rename their Database and User classes, since they clash with phpBB.
All in all, if you’re looking for a bug tracking system that can easily bridge with a forum, look for something else.

