Saturday, July 10, 2010

Special Force PH Clan Management Tool Part 3: Search Codename Feature


Technologies used:

Through the entire series of tools, I will be using C# and .Net framework 3.5. The tools will mostly be achieved by using ReGex and the WebBrowser control. As the tool progresses, databases and more advanced technologies will also be utilized.

Search Codename feature

For our first feature, we will grant a clan master an ability to search for codenames. To do this, the clan master must first login on the clan home page. This will be done by navigating the only webBrowser control of the application to http://sfclan.ph.gameclub.com/ . Before I go on further, I wish to guide players to avoid log-in scams.

// Starting at this point, I'll be using shortcuts A LOT. These will need to be edited in the future.

>>>> Checking the Authenticity of Special Force PH Log-in to avoid scams:

In Google Chrome, hover cursor over LOGIN button, on the bottom the browser, you can see the javascript function that the button is associated to.

In this case, we are looking for the loginSubmit() function. Right Click on the LOGIN button then click on Inspect Element to view the associated HTML source.


If we look for the loginSubmit() function associated with the LOGIN button, we find this code:

Now we need to see what's in the loginSubmit function to verify if this webpage is authentic. To see the entire HTML code of the page, find the View Source button in Chrome's file menu.


Chrome will open a new tab that will contain the source. Press CTRL+F to bring up the search box and type loginSubmit to find the function. Luckily, the first result is the one we're looking for.


This is the entire loginSubmit() function. It checks if the UserID and Pass textboxes have values in them. If not, it warns the users. If they both have values, the UserID and Pass are submitted to "http://ph.gameclub.com/member/login_ok.asp" which is a gameclub server so we're assured that we're logging in on an authentic page.

WARNING IMPORTANT! 
NEVER login to a third party program or unofficial program even you have verified that the website  UNLESS, repeat, UNLESS you are absolutely sure you trust who the program came from only should you log-in in the .You should not even log-in if that program is currently open if you do not trust the author of the program because key loggers are very easy to incorporate in such software.

Alternate LOGIN for my program
My program uses the IE6+ (I think???) browser library, if you don't want to login directly to my program because of the risks, you can use Internet Explorer (the one that comes with windows) to log-in to "http://sfclan.ph.gameclub.com/" . Leave Internet Explorer open, then you can open my program and it will automatically detect that you have already logged in through Internet Explorer and will not ask you to log-in.


ReGex and HTML.
To identify patterns such as those for codenames, I will be using .Net's RegEx library.


Checking if the account is logged in
An account is logged in if the a there is a Clan name on the ID card when you navigate to "http://sfclan.ph.gameclub.com/.



To make a ReGex matching pattern that will determine the clan name and the position, I need to see the HTML code. In Firefox, this can easily be done by highlighting the clan name and position then right click on the highlight then select View Selection source.


Below is the HTML code of the Clan name and position:

and the corresponding ReGex code to find the Clan name and position is:


CASES:
$2 == Master : Enable all features
$2 != Master : Enable Members List only.
No Match == Player has no clan : Disable all features.

Browsing through the Member's List and Manage Members pages
To be able to search through each page of the Member's List and Manage Member's pages, we need to know what are the formats of the URLs.


The URL format for the Member's List (Non-Master accounts) is:
http://sfclan.ph.gameclub.com/myclan/member_list.asp?guildid=LeGiOnAiReS&gp=&gotopage=4

*Replace LeGiOnAiReS with the matched clan name.
*replace 4 after "&gotopage=" to go to the desired page number.


The URL format for the Manage Members page (Master Account) is:
http://sfclan.ph.gameclub.com/myclan/management/manage_member.asp?guildid=LeGiOnAiReS&gp=&gotopage=4


*Replace LeGiOnAiReS with the matched clan name.
*Replace 4 after "&gotopage=" to go to the desired page number.

HTML for each member row in the Manage Members Page

RegEx for each member row in the Manage Members Page


Match collection:

$1 = Officer || Member
$2 = Account Number
$3 = Rank
$4 = Codename
$5 = Join Date

Member List HTML


Member List RegEx 


$1 = Clan Master || Officer || Member || Pending
$2 = Rank
$3 = Codename
$4 = Join Date


Interface:

Search logic
[check if logged in]
page buffer to determine that there is no change of codename order.