My Blog
Well I am now finally all moved into college. It's the same place the iPhone unlocker is going to. There haven't been as many updates recently just because I've been slightly busy. The good news is that league planning and development has been green-lighted.
But Where's Clans??? They're on their way. Just need testing and tweaking and what-not. Unfortunately I am not paid to twiddle my thumbs. Although I am paid to tap on the keyboard.
Anyhow, I leave you with one last nice little snippet of code. Have you ever wanted to generate links (a tags) in user input? Ever just give up when you realize that there might be HTML input in there as well, and your simple attempt fails when someone does something like: <a href="http://www.google.com">http://www.google.com</a> and your link generator ends up creating: <a href="<a href="http://www.google.com">http://www.google.com</a>"><a href="http://www.google.com">http://www.google.com</a></a>. Well, fear not, with a bit of advanced regular expressions, I came up with this solution:
function Linkify($input) {
return preg_replace('/ (http:\/\/|[^\/]www\.)([a-z0-9]+[a-z0-9\._%,#&-;?\/:]+)(?!<)/i', '<a href="http://\\2" rel="nofollow" target="_blank">\\1\\2</a>', ' ' . $input);
}
Anyhow enjoy!
A problem on most sites that allow user-submitted HTML is verifying that the HTML is valid (won't break the page, mess up the formatting, etc). Unfortunately there isn't a lot of help on the Internet from what I've seen short of just suggesting locking down almost all HTML tags. On blogs, this isn't such a great idea because people like to express themselves and stay away from just the content.
Well, here's a specific problem I have seen little about: closing mismatched and unclosed tags. For example, if you leave in one <div> or </div> you could totally wrek a page's layout. Another problem is removing nasty attributes on a tag, like onClick or onHover where potential XSS exploits could surface.
So without further discussion, here's a nice function in PHP I have been working on that can clean the structure of an XHTML input and clear illegal tag attributes:
function clean_tag_structure($input, $badAttributes = '') {
$i = 0;
$tagStack = $matches = array();
preg_match_all("/(.*?)<([^\s>]+)(.*?)>([^<]*)/", $input, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
for($t = 0; $t < count($matches); $t++) {
$output .= $match[1][0];
$match = $matches[$t];
$tag = strtolower(trim($match[2][0]));
if($tag{0} == '/') {
$tag = substr($tag, 1);
if($i != 0) {
$output .= "</{$tagStack[$i]}>";
$i--;
}
} else if($tag{strlen($tag)-1} != '/') {
$tagStack[++$i] = $tag;
if($badAttributes != '') {
$match[3][0] = preg_replace("/($badAttributes)=\"[^\"]*\"/", '', $match[3][0]);
$match[3][0] = preg_replace("/($badAttributes)='[^']*'/", '', $match[3][0]);
}
$output .= "<{$tag} {$match[3][0]}>";
} else {
$output .= $tag;
}
$output .= $match[4][0];
}
for($j = 1; $j <= $i; $j++)
$output .= "</{$tagStack[$j]}>";
return $output;
}
Here's a sample of it at work:
$input = "</b>This <em><strong>TEST</strong></em> </div> <b> is <em onHover=\"deleteIT()\"> a </b></em> test! <div align=\"left\" onClick='deleteHardDrive();'> <div align='left'> </b>";
<div align="\"left\"" onClick='deleteHardDrive();'><div align="left">echo "Before: $input \n";
echo "After: " . clean_tag_structure($input, "onclick|onhover");</div></div>
Output:
Before: </b>This <em><strong>TEST</strong></em> </div> <b> is <em onHover="deleteIT()"> a </b></em> test! <div align="left" onClick='deleteHardDrive();'> <div align='left'> </b>
After: This <em ><strong >TEST</strong></em> <b > is <em > a </em></b> test! <div align="left" > <div align='left'> </div></div>
Cool!
Starting now, when you upload a demo on the report hacker page, you can monitor the progress of the file upload with a nice progress bar and a percentage readout while you wait. It should also notify you immediately if the upload has failed (too large, or some other reason).
Oh, and clans are about 95% complete.
I think it's about time we go into some of the more interesting tools clans will have at their disposal: one of them is clan matches.
The general idea we wanted to get with clan matches is that it would be the central base to see if the clan has upcoming matches, if they have enough players, and some information about past matches. We also wanted members to be able to publicize the event and add some extra content to it, like screenshots or demos.
Who's Playing, and what's the IP?
A common question in my old clan. We plan on addressing this issue by making it possible for a clan member to create a match with all of the important information: league, map, time, server, etc. The creator will have the option to notify certain people (or all) and an email will be sent asking them to RSVP. Clan members can login, go to the match info page, and check if they are going to attend, maybe attend, or not attend. They also can post comments in a discussion thread for the match. You could talk about possible strategies, the starting five, and so on. We also take privacy into consideration, so only a small amount of information will be available to guests until the match is reported, and then the discussion thread is still hidden to only clan members.
"Oh no we've been disputed!" "Did you see John's Ace?"
Need or want someone's demo? Within the match info page, members will be able to add screenshots or their demos, or whatever they want to the match. They can also choose whether or not to make the file public or visible to members only. The file will be listed on the match info page for easy downloading and viewing.
The goal is to provide a one-stop shop for clans, so they can use SpawnPoint not only to show off their cool clan, but to keep track of it as well.
If you look at my blog (which is State of the SpawnPoint Art by the way), you'll notice I have a few screenshots at the bottom of my post. Starting now, all users can attach screenshots to their posts or to their blog. A keen observer will also note that under "My Pages" on the right, all users now have a page called "Screenshots." This page is dedicated to all of the screenshot uploads made by the user.
Wait, I thought I was supposed to be working on clans? Well, the screenshots feature was requested for clans (specifically clan matches), but we also decided to throw them on to blogs as well -- call it a leftover from the clans development (which is going well).
Notice my cool artwork below - made all by myself back when I fiddled with Photoshop!
Alright, here's the update on what is done, what needs to be done, and what I'm thinking about...
What's Done?
- Clan creation
- Clan domains (yourclan.spawnpoint.com)
- Roster page
- Clan management panel setup
- Manage ranks
- Manage rosters
- Invite
- Join clan/Accept invite
What's next?
- Validate permissions when promoting/demoting -- Going to be weird with the draggable list items and the rank drop boxes.
- General page permissions for the clan panel
- Edit clan info
- Edit about page
- News display
- About page display
What's still on my mind?
Matches. Matches. Matches. I'm trying to make the system flexible enough to allow any type of match to be reported. However I also want to make it generic enough so it can be extended for the league code. Going to be interesting; I still haven't thought of the best way, but time will tell.
Another important issue will be file uploads. I'd like to have them be able to be tagged to a match, with different types (demos, screenshots, etc.). That one requires less thought than the matches one.
Things are moving at a nice pace though -- A little slower than I wanted but reasonable.

It's funnier when you actually do it
Things are moving along well; more updates soon.
I see some of you are interested in the league play - all still in planning. By matches, I mean the ability to report a scrim or maybe a match in another league so you can keep track of everything/show off.
Some of you may be wondering what's happening with clans. After all, it has been some time since we added the teaser page for "Clans" and "Ladders." Although they are not ready for release yet, I thought I'd take a few minutes out of my celebrity-like life of developing to talk about some of the cool features you can look forward to.
Clan?
Clans are basically a way for people to unite and play games together. I think a lot of people use the word "team" now, but I think you'll find that our Clans are the same thing. The plan is to allow clan members to post news, upload files (demos), report their matches to keep a record, manage their roster, and eventually play in Spawnpoint sponsored matches (on ladders).
I want a Clan!
Anyone can create a clan. The process will be pretty simple. You enter your desired clan name, your tag, and some other information about your clan (IRC channel, website, etc.) You will also be asked for a "friendly name" or domain name. Similar to how you access your blog (like wayetender.spawnpoint.com), you access your clan page by going to [friendlyname].spawnpoint.com. Because of the possible collisions, Clans cannot have friendly names that match a username, nor can new users have a username that matches a pre-existing clan friendly name.
I have a Clan, Now What?
Once you create your clan, you'll find some interesting options: manage ranks, add officer, report match, post news, upload file, and perhaps more. Immediately upon creation of a clan, two unique Ranks are made: member and leader. What is a Rank? A Rank is a way of designating the clan's hierarchy. You can manage all the Ranks and change who is allowed to do what to the clan. The default group, member, has no privileges and the leader group has all the privileges. Of course you can always change all of the ranks to suit your clans hierarchy. A nice UI touch will be the ranks can be adjusted with a nice sortable list, so you can change permissions with a simple drag-and-drop.
Growing My Army
When you first create your clan, you will be asked how you want your users to join. The possible options are invitation, and using a join password. You are allowed to enable or disable a join password whenever you want. It may be useful when you first create your clan to just use a join password. However, the choice is up to you. When you want to invite a user, you can just simply enter their email address or username. If they don't belong to Spawnpoint, an email will be sent showing how they can register and then join the clan.
How Do I Know When Something Happens?
Well, we do know people like to stay connected, and this issue is a large concern for all of Spawnpoint. A nice feature that we are working on is a unified notification system. Anything from a profile update, someone making a comment on your blog, or someone leaving your clan can all be adjusted in the new notification system. Also, how you receive updates can be changed; anywhere from being emailed immediately, to looking at a feed that shows all relevant information that you would find interesting. Perhaps in the future it will send you a text message? I think I'm thinking too much...
There are many things you can do in a clan, but not enough to make it cumbersome. It is a nice way to show off your clan with statistics on your matches, manage your roster so you can send messages to everyone easily, and eventually have some fun playing matches on the Spawnpoint ladders.
More updates soon, but I must get back to work!
Like my new banner image?
You can have one too. Click Manage Your Blog, and under options, select "Banner Image."
Be warned it removes the title and tag line.