#1 - amp88
Check If License Names Are Valid - Best Practice
Hi, folks. What I'm trying to do is to check if a number of license names are valid and I'm wonder what the best way to achieve this is.

The way I'm currently thinking of doing it is to check the output of the pst query (to get online stats for the racer). Then depending on the output (if the username isn't valid "pst: no valid username" will be returned, if the username is valid then a list of online stats will be returned) I know whether each license name is valid or not.

However, this way there is a lot of unnecessary data being returned (I don't need to know the stats for a racer if they are valid) and I need to check the validity of each username separately. Is there a better way to achieve what I want to do?

Thanks for any input.
I'm wondering about this, too, I was going to use it on my LFS Favhosts website.
atm there is no straight forward "username exists" query available. I suppose i could add that to the next version of pubstat though. I've a couple other requests too so it's worth updating that again.
But atm i'm a bit busy (as you'll know amp ). I will look at it when i can though. Maybe for now just use the PST method?
Would be great to have either "Does not exist" (-1) or the licence stage as response, 0 for Demo, 1 for S1, 2 for S2, etc.
#5 - amp88
Thanks for the quick replies guys

Yep, I'll just use the PST method for the moment.
Quote from morpha :Would be great to have either "Does not exist" (-1) or the licence stage as response, 0 for Demo, 1 for S1, 2 for S2, etc.

Though it might make sense to implement that as bitflag instead, just in case for any hypothetical license model changes in the future where an S2-content license doesn't require an S1-content license anymore, for example.

So make it:
-1 doesn't exist
0 no license / demo
1 S1 license
2 S2 license
4 S3 license

A typical S2 user today would then report as 3 (S1 + S2 license).


Then again... just how likely is that to happen? So maybe not
S2 comes with S1. So i dont get it ?
Yeah, that seems to be a running theme.
Quote from AndroidXP :[...]
just in case for any hypothetical license model changes in the future where an S2-content license doesn't require an S1-content license anymore
[...]

Isn't it possible to just check their username, go to the forums, and see what Version they have? Sorry I'm not a Code writer, so I have no idea if what I said even makes sense.
Quote from Hawk233 :Isn't it possible to just check their username, go to the forums, and see what Version they have? Sorry I'm not a Code writer, so I have no idea if what I said even makes sense.

It's possible to do it that way but it's not very efficient. To do that the user (you or I) would have to spend time doing searches for usernames then interpreting the results and somehow marking that username as valid or invalid. It's a time consuming process and because it's done by a human it's open to mistakes.

The point of this sub-forum is that Victor has provided a system whereby members of the public can submit queries to LFS World directly and receive results based on the query. That way all the user has to do is to start an application and it will work away in the background, doing the (essentially easy and repetitive) task for them, leaving them free to do something more important (like gaming or whatever ).

If you're interested in getting stats for whatever purpose take a look here for more information.
Also, as far as I am aware, the forum accounts aren't created until you first log in here, so you can be licensed without the forums showing you as such.

This is evidenced by the forum reporting 38450 members including demo racers, but the amount of total licensed racers alone is > 60000 from the last reported numbers.
#12 - ekze
Quote from AndroidXP :Though it might make sense to implement that
So make it:
-1 doesn't exist
0 no license / demo
1 S1 license
2 S2 license
4 S3 license

A typical S2 user today would then report as 3 (S1 + S2 license).

I agree!
This would be great!
Here's a thought:
Write a program to log every users username. Make it so that it runs automatically. Then write a new program that uses the the LFS World member search function. Use the scale that someone suggested. You can then use that to weed out the invalid usernames. After you weed out the ,erm, weeds, you can then worry about the others. Write a program that will search for things in groups and ID found terms. Such as: "Search for <"Username, S1", "Username, S2", "Username, Demo">" and assign a value to each item. For instance, If the <Username, S1> is found, have it print "true S1." And if <Username, S2> is found, print "true S2." and if <Username, Demo> is found, print "true Demo." If no terms are satisfied, then print "No Such User."

Anyways I hope that made sense, I have just been introduced into programming so some of my ideas may be flawed.
Let's look at what it would take to get every user on this forum:

30 Results Per Page, 38455 Total users (At this Time), producing 1282 pages.
So, we would then only read the data from the username column of the member list as it has the users name, license level, and userid (in the href). But we still have to parse each of the 1282 pages. That means querying the server 1282 times to find out all of the current users at this time.) The last page's HTML is 45,109 Bytes. So, 45,109 * 1282 = 57,829,738 Bytes = ~55.2 MB. It took around 2 seconds to download the page with wget, so ... 2 * 1282 = 42 Minutes and ~ 45 Seconds to download all of the users, but keep in mind, that's only all of the users from when you got each page! With new members joining at a rate of 1 member every 2 minutes, your data base is already out of date when your done. I would feel bad for the LFS Forum's Server scraping all of that information. The idea is going to slam the server from when you start it until the rest of time just to keep the information up to date.

Roadrash17, I've been programming for much longer then I would like to admit. Think again, you have some good ideas and I hate to discourage people. Just think of another way to handle it. Hint: The best approach is an LFS World Query, Lobby for it.
Thanks for the encouragement...I have just started programming and have no trouble admitting the fact that I'm a noob at it, as of now. :]

FGED GREDG RDFGDR GSFDG