Tiberath

Joined: Oct 12, 03

Home page

HTML, CSS, PHP, SQL and DM Programmer.

My Projects

BYOND Stuff:

Isorath:
Programming Progress
Art Progress
Development Forum


Websites:
Tiberath.com
(Redesigned and new content added daily!)

Tibbius.com


Hobby Writing:


(Updated Daily)

Tip Jar

My Amazon.com Wish List



Past Donations 2009
Popisfizzy - 30.00(USD)
Mikau - 2.52 (USD)
Jeff8500 - 5.00 (USD)
T3h B4tman - 7.95 (USD)
KitKatze - 32.00 (USD)
Gotrax - 10.00 (USD)
Dark Campainger
  • The Orange Box.
  • Left 4 Dead.

Fanciful - 5.00 (USD)
Calus CoRPS - 20.00 (AUD)

Past Donations 2008
Thief Jack - 5.00(AUD)
Popisfizzy - 11.00(USD)
Mobius Evalon - 5.00(USD)
Shira-kun - 20.00(USD)
Haywire - 4.50 (AUD)
DarkCampainger - 42.00 (USD)
Schnitzelnagler - 45.00 (AUD)


Past Donations 2007
JackGuy - 27.00 (AUD)
GhostAnime - 50.00 (AUD)
AlexisOnFire - 12.00 (AUD)
Evi of au - 25.00 (USD)
Tom - 5.00 (USD)

Advertisin'

SliceHost - The best for BYOND Hosting.
No Clean Feed - Stop Internet Censorship in Australia


My libraries

My demos

 

 

Working around .htaccess, compelte control of the URL.

So for the past little while I was looking for a way to do clean URLs (url.com/articles/something) without resorting to .htaccess redirects for the pages.

I found my every attempt in doing it using .htaccess to result in limited usability often breaking with unexpected input. Experiments on tiberath.com resulted in massive headaches until I eventually gave up on it.

So I gots to thinking of how to do it another way. With a little conferring with Mobius, we decided that PHP is a fairly strong language, and we should have no troubles parsing the URL with it.

Unfortunately for us, this sacrifices a little bit of speed (negligible amounts really, but efficiency nuts will yell at us. Eh, they know exactly where they can go. Given today's computers, the milliseconds it takes to run the following functions aren't worth sacrificing the new freedom I gave myself) but makes up everything in usability.

So I got to work, and with a little regex help from Mobius, came up with a solution I was happy with. Of course, anyone who isn't me will probably find the scripts useless, as I format my URL's far different than most people would normally do.

For the most part, you'll find most URLs formatted something not unlike .com?action=account&page=register where I'm more inclined to run through the alphabet: .com?a=account&b=register only varying from this method with important things like an id number: .com?a=members&b=profile&id=20

With this in mind, I wrote the following PHP script.
function fix_uri($uri, $nockey = false) {
    $new_uri = array();
    $i = 97;
    foreach($uri as $key) {
        if(substr_count($key, "=")) {
            $key = explode("=", $key);
            $new_uri[ckey($key[0])] = $nockey ? $key[1] : ckey($key[1]);
        } else if($key) {
            $new_uri[chr($i)] = $nockey ? $key : ckey($key);
            $i++;
        }
    }
    return $new_uri;
}
    
function ckey($t) { 
    return strtolower(preg_replace('/[^a-zA-Z0-9@]/','',$t)); 
}


A quick Google search for the .htaccess code I needed resorted in this .htaccess script:
RewriteEngine on

#Auto-redirect all pages to index.php
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]


Effectively, all URL's are redirected to index.php. With exception to files and sub-folders. Which was a major bonus I never actually took into consideration when designing this script (and something that had pained me terrible when attempting it with .htaccess redirects).

Throwing this script in my header.php (hearder.php is called before any output to the website is done, and generally only outputs stuff that are on all pages at the very bottom of the file):
$uri = fix_uri(preg_split('![/|?|&|;|$]!', urldecode($_SERVER['REQUEST_URI'])));
$uri_a = fix_uri(preg_split('![/|?|&|;|$]!', urldecode($_SERVER['REQUEST_URI'])), true);


I'm given a clean URL and a complete URL. The resulting executions give me all kinds of crazy URLs to work with, effectively, something like this: http://www.isorath.com/OMG/this/is/A/valid/ url?that=SeEms&to=enJOY?working=properly!!/using/ all&kinds=of?weird=methos;that;I;seem=to/enjoy doing - ONLINE EXAMPLE NO LONGER AVAILABLE.

Of course, a URL would never get that big and ridiculous, but you get the idea behind it. Using my own style of formatting URLs (which is in fact, quite handy for say, me, because I don't actually have to change anything in pre-existing websites (minus tiberath.com, that I did differently)), I'm able to provide incredibly clean URLs at the same time as giving myself absolutely no headaches. And if I was to say update the page and give it another division in the URL, I'd have to change absolutely nothing.

The complete index.php you saw on the link above is simply this:
<?
    function fix_uri($uri, $nockey = false) {
        $new_uri = array();
        $i = 97;
        foreach($uri as $key) {
            if(substr_count($key, "=")) {
                $key = explode("=", $key);
                $new_uri[ckey($key[0])] = $nockey ? $key[1] : ckey($key[1]);
            } else if($key) {
                $new_uri[chr($i)] = $nockey ? $key : ckey($key);
                $i++;
            }
        }
        return $new_uri;
    }
    
    function ckey($t) { 
        return strtolower(preg_replace('/[^a-zA-Z0-9@]/','',$t)); 
    }
    
    $uri = fix_uri(preg_split('![/|?|&|;|$]!', urldecode($_SERVER['REQUEST_URI'])));
    $uri_a = fix_uri(preg_split('![/|?|&|;|$]!', urldecode($_SERVER['REQUEST_URI'])), true);
        
    echo("The complete URL is: " . $_SERVER['REQUEST_URI'] . "<br /><br />The clean URL is: <pre>" . print_r($uri, true) . "</pre><br /><br />The direct URL is: <pre>" . print_r($uri_a, true) . "</pre>");
?>


I'm contented with this. The major setback to it I can foresee but haven't yet tested, is it might mess with Search Engine Optimisation (as technically, all pages will report as index.php). Again, I'm not particularly phased. According to my Google Analytics page, the URLs are reporting correctly, so it's possible Search Engine Optimisation will be saved (or improved if you didn't have any kind of clean URL before hand).

That's all there is to it really. Anyone who uses PHP and hates the thought of .htaccess is free to use it and do as they see fit.

[Update]
The results of the now offline example URL.
The complete URL is: /omg/this/is/a/valid/url?that=seems&to=enjoy?working=properly/using/all&kinds=of?weird=methos;that;I;seem=to/enjoy

The clean URL is:

Array
(
    [a] => omg
    [b] => this
    [c] => is
    [d] => a
    [e] => valid
    [f] => url
    [that] => seems
    [to] => enjoy
    [working] => properly
    [g] => using
    [h] => all
    [kinds] => of
    [weird] => methos
    [i] => that
    [j] => i
    [seem] => to
    [k] => enjoy
)



The direct URL is:

Array
(
    [a] => omg
    [b] => this
    [c] => is
    [d] => a
    [e] => valid
    [f] => url
    [that] => seems
    [to] => enjoy
    [working] => properly
    [g] => using
    [h] => all
    [kinds] => of
    [weird] => methos
    [i] => that
    [j] => I
    [seem] => to
    [k] => enjoy
)

Posted by Tiberath on Saturday, November 07, 2009 07:21AM - 8 comments / Members say: yea +0, nay -0
(Edited on Sunday, November 08, 2009 11:55AM)

« Drink Pepsi, annihilate thousands! · You know what I want? »

Login to post a comment.

#8 Tiberath:  

Airjoe wrote:
> I still don't understand why you're not using mod_rewrite over PHP.

That was explained in the first or second paragraph. The process of using mod_rewrite was painful and far more limited than what I'm doing now.

Sunday, November 08, 2009 10:46AM

#7 Airjoe:  

I still don't understand why you're not using mod_rewrite over PHP.

Sunday, November 08, 2009 10:45AM

#6 Tiberath:  

Kuraudo wrote:
> > Throwing this script in my header.php (hearder.php
>
> You also made a typo on "header.php"!

Verm covered that one.

> As for the script, it sounds neat. I take it that actually creating sub-directories was not something you wanted to do? For "url.com/articles/something" you could just create an "articles" directory and in it put a "something" one, stick an index.php in "[www_root]/articles/something/" and be well off enough.

That's pure insanity that. You'll find very little (if any) websites will resort to making subdirectories for things like this, especially when scripts like the above and other redirect methods are already available.

Take BYOND for example.
/members
/developer
/help
/hub
/games

And then they have 'subdirectories' of their own:
/members/tiberath
/developer/tiberath
/help/forum
/hub/tiberath.interfacecontrol
/games/tiberath.isorath

There's no way a folder for each of those exists. That's definitely URL trickery.

Saturday, November 07, 2009 04:30PM

#5 Kuraudo:  

> Throwing this script in my header.php (hearder.php

You also made a typo on "header.php"!

As for the script, it sounds neat. I take it that actually creating sub-directories was not something you wanted to do? For "url.com/articles/something" you could just create an "articles" directory and in it put a "something" one, stick an index.php in "[www_root]/articles/something/" and be well off enough.

Saturday, November 07, 2009 10:34AM

#4 Tiberath:  

I also said "terrible" instead of "terribly".

And I can appreciate corrections that aren't made just to catch me out. Haywire has this thing about him that he absolutely must call every mistake I make AND do it in a pretentious manor,

(I used a comma instead of a period!)

Saturday, November 07, 2009 08:18AM

#3 Vermolius:  

I was going to leave a serious comment, but I'm not, just to irritate you. Instead, I'd like to inform you that you spelled header.php wrong.

Saturday, November 07, 2009 08:17AM

#2 Tiberath:  

Oh wow, a typo in the heading. Fascinating. Completely disregarding the entire post mind you, but hey, who cares about the post content?

I'm not going to fix it, just to irritate you.

Saturday, November 07, 2009 07:51AM

#1 Haywire:  

Title: complete*

Saturday, November 07, 2009 07:42AM

 

 

Contact

Email: tiberath@tibbius.com
MSN: ambient546@hotmail.com

Shoutbox

Login to post a comment.

#21 Tiberath:  

View the source:
<!--
Menu code not produced by me!
Pilfered from http://www.byond.com -> Free online gaming! Go there, NOW.
-->
<div id='menu'>

AND

This

Saturday, November 14, 2009 08:08PM

#20 Kuraudo:  

So...I notice a slight similarity to Tiberath.com's menu bar and BYOND's... ;)

Saturday, November 14, 2009 07:57PM

#19 Tiberath:  

Asakuraboy wrote:
> Tibs, i cot a few questions about Slice hosting... Such as, how many low-level worlds could a 256 slice manage?

It all depends on the game. Icon Ultima is a very resource heavy world, as a result of that, we have a Cron Job to delete the BYOND cache on the server every six hours (20GB of free space would be used up in a day or two otherwise). Bandwidth wise, my slice nearly uses the entire 200GB of transfer available.

However, even with IU, we were still able to host My Life as a Spy, Chatters and on occasion Solar Conquest at the same time.

A 256 slice, provided you're not running websites like I am, could probably manage several small casual games along side one or two RPGs.

And if you find yourself unable to host what you want, you can also upgrade your slice with only a few hours downtime.

Sunday, November 08, 2009 10:49AM

#18 Asakuraboy:  

Tibs, i cot a few questions about Slice hosting... Such as, how many low-level worlds could a 256 slice manage?

Sunday, November 08, 2009 08:50AM

#17 Tiberath:  

Kuraudo wrote:
> I'd start by combining client.IsByondMember() and an if() test.

Well, you'd start wrong. I'd write a datum to control the benefits given for members (and subscribers).


Saturday, October 31, 2009 10:53AM

#16 Kuraudo:  

Sayaotonashis wrote:
> If you could maybe help me make a IsByondMember()
> that works and gives byond members verbs or other things as rewards?

I'd start by combining client.IsByondMember() and an if() test.

Saturday, October 31, 2009 01:41AM

#15 Sayaotonashis:  

Hello Tiberath and thanks for pointing out..oh.I was going to ask,If you could maybe help me make a IsByondMember()
that works and gives byond members verbs or other things as rewards?

Thursday, October 29, 2009 12:50PM

#14 PsychopathicYugiohFreak:  

Tiberath wrote:
> Very sorry! I recieved both your emails, but personal times for me at the moment are quite tough and I haven't had a lot of time or desire to do much BYOND related. Your game is a fit for BYOND RPG and it's looking pretty good. Needs a bit of polish here and there but is otherwise doing well. Keep me posted on any major developments with it. Cheers.
---
Thanks for the response! Very sorry to hear about your dilemma.. Hopefully all goes well. We'll keep you posted on development!

Monday, August 17, 2009 11:07PM

#13 Tiberath:  

PsychopathicYugiohFreak wrote:
> I'm a bit confused as to what I'm supposed to do next. If you have the time, I'd appreciate a nudge in the right direction. Thanks!

Very sorry! I recieved both your emails, but personal times for me at the moment are quite tough and I haven't had a lot of time or desire to do much BYOND related. Your game is a fit for BYOND RPG and it's looking pretty good. Needs a bit of polish here and there but is otherwise doing well. Keep me posted on any major developments with it. Cheers.

Monday, August 17, 2009 05:46AM

#12 PsychopathicYugiohFreak:  

Hey there, Tiberath. I've been trying to contact you regarding Mobius (BYOND RPG submission) via email and I haven't received a response since you asked for details. Was I supposed to make a submission on the BYOND RPG forum?

I'm a bit confused as to what I'm supposed to do next. If you have the time, I'd appreciate a nudge in the right direction. Thanks!

Saturday, August 15, 2009 03:44AM

#11 Tiberath:  

Ripiz wrote:
> Hello Tiberath. I've been suggested to contact you. I tried BYOND pager however it didn't work :)
> Could you please contact me through MSN either EMail? (ripiz14@hotmail.com)
>
> Thank you

That depends on what you're after. Presently I'm running multiple computers and generally have my pager running on the computer I'm not stationed at.

Feel free to drop me a line at tiberath@tibbius.com or for MSN ambient546@hotmail.com on what you wish to ask me.

Sunday, July 19, 2009 10:25AM

#10 Ripiz:  

Hello Tiberath. I've been suggested to contact you. I tried BYOND pager however it didn't work :)
Could you please contact me through MSN either EMail? (ripiz14@hotmail.com)

Thank you

Sunday, July 19, 2009 10:15AM

#9 Tiberath:  

Gokukg wrote:
> hey i realy need help r u byond staff or anythink u seem quite improtan anyway i carnt get my password back somebody hacked me changed pass when i send retrieval email to my email i never recieve it thus i carnt get back on to main ALT contact me at Con_kibbler@hotmaial.co.uk or leave comment on my byondpage thankyou

No I'm not BYOND Staff, just a volunteer. Matters of account retrieval should be handed directly to BYOND staff via the Support Form. In future, any problems you have should be posted in BYOND Help.

Monday, July 13, 2009 11:14PM

#8 Gokukg:  

im on friends alt my key is Con13

Monday, July 13, 2009 10:46AM

#7 Gokukg:  

hey i realy need help r u byond staff or anythink u seem quite improtan anyway i carnt get my password back somebody hacked me changed pass when i send retrieval email to my email i never recieve it thus i carnt get back on to main ALT contact me at Con_kibbler@hotmaial.co.uk or leave comment on my byondpage thankyou

Monday, July 13, 2009 10:46AM

#6 Espadamaster:  

Ok On Icon Ultima i had just come out of afk and someone banned me plz unbann me

sincerely,
Espadamaster

Saturday, July 11, 2009 02:01PM

#5 Tiberath:  

Zxcvdnm wrote:
> Hope all is well brother. Art is slow lately, sorry about that. I've come out of a social dry spell recently so I'm busy most days and when I'm not busy I'm tired and don't feel like doing much of anything. I'll force myself to work on it soon, maybe after my Warhammer trial runs out. Peace.

Don't stress too much. I have pesky real world obligations to fulfil as my father wants me to dig up the drive way so he can lay cement. Chipping through gravel and clay with a large and heavy metal pole isn't easy.

Sunday, March 29, 2009 06:03PM
(Edited on Sunday, April 26, 2009 09:30AM)

#4 Zxcvdnm:  

Hope all is well brother. Art is slow lately, sorry about that. I've come out of a social dry spell recently so I'm busy most days and when I'm not busy I'm tired and don't feel like doing much of anything. I'll force myself to work on it soon, maybe after my Warhammer trial runs out. Peace.

Sunday, March 29, 2009 01:45PM

#3 Tiberath:  

DarkCampainger wrote:
> zomg, where did your awesome green CSS go?

Fixing it up to be more compatible. I wrote it a few months after the original BYOND Member was released and haven't updated it since.

Sunday, March 29, 2009 04:34AM

#2 Kisioj:  

I hack you too Tiberath!

Sunday, March 29, 2009 04:20AM

Protestin'

No Clean Feed - Stop Internet Censorship in Australia

Poll

Would you rather "full screen" or a set-in-stone interface?

  • "Full Screen" 67% (59)
  • Set-in-stone 32% (28)

Login to vote.

Blog Calendar

November 2009
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30          
 
«Oct  

My hosted files

(7.5 KB)
(677 bytes)
(21.6 KB)
(14.2 KB)
(1.6 MB)
(10.8 KB)