The online racing simulator
Quote from dawesdust_12 :which is valid, as any case variant of a username will permit you to login to LFS (and report to the server as your case variant). Eg. dustin dawes is the same user as Dustin Dawes, however LFS will show is as "dustin dawes" (even though on LFSW it's Dustin Dawes).

yes, but when i type !cruise fine 100 t3charmy it does not work

just says " Was Fined $100."

and it does not fine me ... seems like it is returning a empty $data variable
No. What I'm saying is username should be case insensitive as LFS will let you login with any mixture of case and report that to the server.

Clearly a simple strtolower($username) where the usernames get pulled by PRISM, and then when using getClientByUname() it auto lcases the input to create an equal comparison. Or does some form of case-insensitive checking (== rather than === somewhere)

That makes sense?
Quote from dawesdust_12 :No. What I'm saying is username should be case insensitive as LFS will let you login with any mixture of case and report that to the server.

Clearly a simple strtolower($username) where the usernames get pulled by PRISM, and then when using getClientByUname() it auto lcases the input to create an equal comparison. Or does some form of case-insensitive checking (== rather than === somewhere)

That makes sense?

ahh that makes more sense now :P sorry for the confusion
Is the LFS Username case insensitive, are player names? Victor, can you clear this one up? If so, I'll strtolower() when searching by username (UName) and player name (PName).
strcasecmp() is faster than strtolower()ing 2 strings.
Alternatively you could could keep a lower or upper case version of the PName and UName for comparison so you'd only have to strtolower() or strtoupper() one string to perform a comparison, which would be a wee bit faster than strcasecmp().
Upper case would be slightly slower in most cases as more of the string would have to be changed.
Yes you must treat lfs usernames as case insensitive. Like dustin said LFS uses whatever casing you enter in your username, so you cannot rely on usernames always having the same case.
Note that you may have to take special care of certain characters that may not go to lower or upper automatically. I've just tested this again to make sure, but for example converting "Leguán" to upper converts to "LEGUáN" in php (and actually c as well), so in order to get good conversion you must do something like this :


<?php 
function str_to_upper ($str){
    return 
strtr (
        
$str,
        
"abcdefghijklmnopqrstuvwxyz".
        
"\x9A\x9C\x9E".
        
"\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7".
        
"\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF".
        
"\xF0\xF1\xF2\xF3\xF4\xF5\xF6".
        
"\xF8\xF9\xFA\xFB\xFC\xFD\xFE".
        
"\xFF",
        
"ABCDEFGHIJKLMNOPQRSTUVWXYZ".
        
"\x8A\x8C\x8E".
        
"\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7".
        
"\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF".
        
"\xD0\xD1\xD2\xD3\xD4\xD5\xD6".
        
"\xD8\xD9\xDA\xDB\xDC\xDD\xDE".
        
"\x9F"
    
);
}
?>

(I'm doing strtouppers for comparisons instead of strtolower)
Quote from morpha :strcasecmp() is faster than strtolower()ing 2 strings.
Alternatively you could could keep a lower or upper case version of the PName and UName for comparison so you'd only have to strtolower() or strtoupper() one string to perform a comparison, which would be a wee bit faster than strcasecmp().
Upper case would be slightly slower in most cases as more of the string would have to be changed.

Thanks for the info on strcasecmp, I think that makes the most amount of sense. I don't think I'll make a copy of a string to upper / lower version of every ones name because it would still require that the compare string will be converted and so the performance is pretty much lost. Unless you wish to benchmark these numbers.

Quote from Victor :Yes you must treat lfs usernames as case insensitive.

Quote from Victor :Note that you may have to take special care of certain characters that may not go to lower or upper automatically.

Ok, I'll do that from now on, good to know there can never be a Dygear & dygear. I'll take care of the conversion of those characters.
Quote from Dygear :Thanks for the info on strcasecmp, I think that makes the most amount of sense. I don't think I'll make a copy of a string to upper / lower version of every ones name because it would still require that the compare string will be converted and so the performance is pretty much lost. Unless you wish to benchmark these numbers.

I did and as I said, converting one string and comparing it with one you know is lower case is faster than strcasecmp(). The issue Victor raised renders strcasecmp() useless though, because it will not recognise "Leguán" as "LEGUÁN".

Victor, comparing lower case strings is usually faster because most names and normal text contain predominantly lower case characters. Comparing the simple string 'A normal string' with itself yields the following results:

On my slowest machine (P2 300MHz) over 10000 iterations:
upper: 1.017s
lower: 0.381s

On my desktop (Q9450 3.6GHz) over 1000000 iterations:
upper: 2.015s
lower: 2.008s

Admittedly the difference is marginal on the modern machine

Anyway, if you know a string you intend to compare is going to be mostly lower case, you should use tolower(), respectively if it's going to be mostly upper case, toupper().
I intend on fixing the case insensitive nature of the UName and PName in the next version of PRISM. But I would not expect this for another month as I am doing ambulance rotations for the rest of the month. (Class is almost over, thank god, then it's back to my life of programming PRISM and working normal (overnight) hours again!)
mb_strtolower, no? :o It worked for the "LEGUÁN" thing...
Quote from boothy :mb_strtolower, no? :o It worked for the "LEGUÁN" thing...

I'm just worried about codepage conflicts.
(And if I don't have to have people include the mb extension, that would be cool too.)
mb_strtolower is 10(!) times slower than strtolower, that's definitely a no-go.
7 by my calculations Sorry for the hijacking, but then what is the best solution to ensure consistent (lower) case across variables which include utf-8 characters?
For UTF-8, mb_strtolower is, but LFS doesn't use UTF-8
Hmm, maybe that's why LFS messages like "15 D.Grdi^Eæ^L took over from 15 S.Milašinovi^Eæ" haven't been converting correctly using http://www.lfsforum.net/showthread.php?t=36628 - I've been getting stuff from a database using utf-8 (just tried it without the db, setting the file encoding to ANSI worked...)
Quote from morpha :For UTF-8, mb_strtolower is, but LFS doesn't use UTF-8

But when it comes to displaying the formats on the same page, there is pretty much no way to go BUT to convert from codepage to UTF-8 as it's the only universal standard. It does make the most amount of sense. This does lead me into how I'm going to handle LFS strings. I have a pretty good parser in LFSWorldSDK 2.0, but I've not released it yet. I think I might port it over here, or just tackle the whole thing again to make sure I did it right.
It would be fantastic if LFS would just report it as they registered with, not how they unlocked their account.
i made a new web control panel for Prism... I will be releasing it in the coming weeks!

Edit: the login system doesn't work??? and is there a way to check permission flags?

Preview: http://just4fun.servegame.com:8888

also is there an official logo?
Quote from T3charmy :i made a new web control panel for Prism... I will be releasing it in the coming weeks!

Cool, glad there is still interest as I have 30 days until I am done with my rotations then I can go back to a normal life.

Quote from T3charmy :Edit: the login system doesn't work??? and is there a way to check permission flags?

I really don't remember off hand, I think that it does, as for the permissions flags, you should be able to get to them via the main $PRISM object and then a sub class. Don't forget to make sure that they have permissions to run commands on THAT server, because it is possible to setup commands on a per client, per server basis.

Quote from T3charmy :Preview: http://just4fun.servegame.com:8888

That looks SWEET! Nice job!

Quote from T3charmy :also is there an official logo?

Nope, not yet. Just the beta one that Vic made a while back. I've asked people to make on, but it always falls through.
Quote from Dygear :I really don't remember off hand, I think that it does

i have tried and it does not seem to work...
Quote from Dygear :That looks SWEET! Nice job!

Thanks
i am gonna try and get a good amount of the site done this weekend...
[size]Possible i could become an official Prism dev?[/size]
Quote from T3charmy :i am gonna try and get a good amount of the site done this weekend...
Possible i could become an official Prism dev?

When you done, feel free to submit a patch on github.
i still cant seem to get the login system to work, i cant really move forward with out it...

i think i may rewrite it from scratch being it does not seem to work right...
Quote from T3charmy :i still cant seem to get the login system to work, i cant really move forward with out it...

i think i may rewrite it from scratch being it does not seem to work right...

As I type this message right now, I am setting in the passenger seat of an ambulance, as I'm going to be for the next 19 days. If you can wait that long I'll take a look at the system myself and see what's what.
Quote from T3charmy :i still cant seem to get the login system to work, i cant really move forward with out it...

i think i may rewrite it from scratch being it does not seem to work right...

I've just tried it with the original web php files that are still in the actual prism release and it worked there for me. Both HTTP Auth and regular login via the webpage itself.

So maybe you can explain a bit more about what you're trying and what exactly doesn't work? Which type of login are you trying? (ok the webpage type duh Maybe post some code?

FGED GREDG RDFGDR GSFDG