30 October 2017, 08:37 | #1561 |
old bearded fool
Join Date: Jan 2010
Location: Bangkok
Age: 56
Posts: 779
|
Turran,
I threw together a Python script 'eab_post_count.py' to get post count of a given EAB forum user. This is kind of hairy in the sense that it depends on counting html tags and such on a dynamic webpage, pretty far from ideal, but it works (at the moment). Code:
#!/usr/bin/env python import sys, re, urllib2 version="1.0" if len(sys.argv) < 2: print(sys.argv[0] + ' v' + version +' by modrobert in 2017') print('Function: Returns the number of posts for a given EAB forum user.') print('Syntax: eab_user_count.py <username> [-i]') print('Options: -i ignore case sensivity in user name') print('Result: 0 = user found, 1 = user not found, 2 = invalid option.') sys.exit(1) else: username = sys.argv[1] usernameurl = re.sub('[ ]', '%20', username) eaburl = "http://eab.abime.net/memberlist.php?do=getall&pp=1&ausername=" + usernameurl def parseurl(url): if not url: print("Empty URL!") return headers = { 'User-Agent' : 'Mozilla/5.0' } request = urllib2.Request(url, None, headers) response = urllib2.urlopen(request) content = response.read() return content def pagesearch(content, trigger, start, end): sane = 0 needlestack = [] while sane == 0: curpos = content.find(trigger) if curpos >= 0: testlen = len(content) content = content[curpos:testlen] curpos = content.find('"') testlen = len(content) content = content[curpos+1:testlen] curpos = content.find(end) needle = content[0:curpos] result = content[len(start):curpos] if needle.startswith(start): needlestack.append(result) else: sane = 1 return needlestack def unescape(s): s = s.replace("<", "<") s = s.replace(">", ">") # this has to be last: s = s.replace("&", "&") return s eabcontent = parseurl(eaburl) countlist = pagesearch(eabcontent, 'td class', 'alt2">', '</td>') userlist = pagesearch(eabcontent, 'member.php?', '>', '</a>') try: if sys.argv[2] == '-i': if unescape(str.lower(''.join(userlist))) != str.lower(username): print("User not found: " + username) sys.exit(1) else: print("Invalid option. ") sys.exit(2) except Exception: if unescape(str(''.join(userlist))) != username: print("User not found: " + username) sys.exit(1) for item in countlist: stripitem = re.sub('[,]', '', item) try: print(int(stripitem)) sys.exit(0) except Exception: continue Last edited by modrobert; 30 October 2017 at 14:30. Reason: Fixed bug, apparently a user with > 1000 posts get a ',' in their counter. Added handling of space in user name. Fixed "more than one hit" bug (thanks Turran). |
30 October 2017, 08:49 | #1562 | |
Moderator
Join Date: May 2012
Location: Stockholm / Sweden
Age: 49
Posts: 1,575
|
Quote:
Thats why I wanted to move the register account page here, behind a "member only" page. Kinda like The Zone in a way. Then we ensure that the username registered on the FTP is the same as the forum username. |
|
30 October 2017, 09:36 | #1563 | |
old bearded fool
Join Date: Jan 2010
Location: Bangkok
Age: 56
Posts: 779
|
Quote:
PS: Found a bug in the script, edited previous post. Apparently a user with > 1000 posts get a ',' in their counter. |
|
30 October 2017, 10:10 | #1564 | |
Moderator
Join Date: May 2012
Location: Stockholm / Sweden
Age: 49
Posts: 1,575
|
Quote:
For example, if I registered an EAB user called "Turbo", I can not check its post count or even existence from your script since we get a lot of users with "Turbo" in their name.. This can of course be extended in the script to check all hits found, if one is an exact match, but perhaps more work than its worth right now. Last edited by Turran; 30 October 2017 at 10:16. |
|
30 October 2017, 10:19 | #1565 | |
old bearded fool
Join Date: Jan 2010
Location: Bangkok
Age: 56
Posts: 779
|
Quote:
The exit codes of my Python script are: 0 = user found, 1 = user not found, 2 = more than one user found. So, for example, if you want to use this from a Bourne shell script. Code:
#!/bin/sh USER="Turran" OUTPUT=`eab_post_count.py "$USER"` RTN=$? if test $RTN -eq 0 ; then # user found, do your stuff here echo "Post count: $OUTPUT" fi PS: Updated the Python script post with another bug fix, the forum allows spaces in user names, handling that now. Last edited by modrobert; 30 October 2017 at 11:54. Reason: Improved the shell example. |
|
30 October 2017, 11:59 | #1566 |
Moderator
Join Date: May 2012
Location: Stockholm / Sweden
Age: 49
Posts: 1,575
|
So try getting the postcount for "Turbo". You cant since the result is only "More then one user found".
We need to go through the results if its more then one, and only when it finds an exact match, report the postcount. If no exact match is found then return "user not found". Otherwise, the user "Turbo" can never register an EAB FTP account since we can not check the postcount =) |
30 October 2017, 12:01 | #1567 | |
old bearded fool
Join Date: Jan 2010
Location: Bangkok
Age: 56
Posts: 779
|
Quote:
EDIT: OK, here's another example, checking of exit code is "not equal" to zero. Code:
#!/bin/sh USER="Turran" OUTPUT=`eab_post_count.py "$USER"` RTN=$? if test $RTN -ne 0 ; then # user name not found or incomplete (more than one) echo "User not found" exit 1 fi # we have a valid user name # do your stuff here echo "Post count: $OUTPUT" Last edited by modrobert; 30 October 2017 at 12:22. Reason: Added another shell script example. |
|
30 October 2017, 12:22 | #1568 |
Moderator
Join Date: May 2012
Location: Stockholm / Sweden
Age: 49
Posts: 1,575
|
I dont think we understand each other. If the user "Turbo" tries to add an EAB FTP account, he is going to be denied because eab_post_count.py is going to report
print("* Found more than one user: " + username), when he indeed has a valid EAB Forums account. This is because there are three other usernames also containing "Turbo" (RobTurbo, Turbo2Xs & TurboCrash). We have no way to get the postcount from the user "Turbo" using the existing script, therefor he can not create an FTP account, even though he is a valid user (Well, he does not exist right now. Its just an example). So my suggestion would here, here. Instead of the sys.exit(2): print("* Found more than one user: " + username) sys.exit(2) go through all the results we got back, check if the username is an exact match to any of the result. If it is, grab the post count and return that. If no user in all the results are a match, return print("* User not found: " + username) sys.exit(1) But then again, do not spend time on this because its easy to exploit anyway by just browsing the eab member list and creating an FTP user with the same name as an existing member. |
30 October 2017, 12:29 | #1569 | ||
old bearded fool
Join Date: Jan 2010
Location: Bangkok
Age: 56
Posts: 779
|
Quote:
Quote:
Perhaps you posted your reply while I was editing my previous post to add another example? Last edited by modrobert; 30 October 2017 at 12:51. |
||
30 October 2017, 12:52 | #1570 | ||
Moderator
Join Date: May 2012
Location: Stockholm / Sweden
Age: 49
Posts: 1,575
|
Quote:
python eabpostcount.py Turbo * Found more than one user: Turbo That user does not exist as its just an example. Lets give a real life example: Quote:
If he tries to create an FTP account: # python eabpostcount.py AGN * Found more than one user: AGN Why? There are other users that has the lettering agn in their name. All of them are valid http://eab.abime.net/memberlist.php?...&ausername=AGN That is because memberlist.php uses "like" instead of "=". Its not an exact match were getting but simply a "contains" search. Last edited by Turran; 30 October 2017 at 12:58. |
||
30 October 2017, 12:55 | #1571 | |
old bearded fool
Join Date: Jan 2010
Location: Bangkok
Age: 56
Posts: 779
|
Quote:
Code:
#!/bin/sh USER="Turran" OUTPUT=`eab_post_count.py "$USER"` RTN=$? if test $RTN -ne 0 ; then # user name not found or incomplete (more than one) echo "User not found" exit 1 fi # we have a valid user name # do your stuff here echo "Post count: $OUTPUT" EDIT: I see what you mean now, finally, sorry for the misunderstanding. I will fix it. Last edited by modrobert; 30 October 2017 at 13:03. |
|
30 October 2017, 13:12 | #1572 |
Moderator
Join Date: May 2012
Location: Stockholm / Sweden
Age: 49
Posts: 1,575
|
Sweet =)
Is it possible to grab the "Last visit" as well as postcount? Then we check that as well. If the user has not been active/logged on to EAB for a while, we can deny the creation as well. Then we might block (some of) the users just grabbing someone elses EAB Forums username to create an FTP account with.. |
30 October 2017, 13:13 | #1573 |
Registered User
Join Date: Jul 2013
Location: Helsinki / Finland
Age: 42
Posts: 90
|
Damn, this was painful to read Hope you guys get them codes working
|
30 October 2017, 13:39 | #1574 |
Moderator
Join Date: May 2012
Location: Stockholm / Sweden
Age: 49
Posts: 1,575
|
Perhaps we should move to PM =)
|
30 October 2017, 13:45 | #1575 |
old bearded fool
Join Date: Jan 2010
Location: Bangkok
Age: 56
Posts: 779
|
No thanks, considering some of the crap posted in this thread so far, a bit of code can't hurt. Almost done.
Last edited by modrobert; 30 October 2017 at 16:14. |
30 October 2017, 14:40 | #1576 |
old bearded fool
Join Date: Jan 2010
Location: Bangkok
Age: 56
Posts: 779
|
OK, edited my previous "release post" with new eab_post_count.py v1.0.
Changelog: * Fixed bug with "more than one user", now compares given user name with output from EAB forum (thanks Turran). * Added -i option to ignore case in user name, this has to be the last option on command line, default (no option) is now case-sensitive user name. * User names with '<', '>' and '&' characters are now handled correctly by converting html escape codes. * Result/exit codes are now as follows: 0 = user found, 1 = user not found, 2 = invalid option. I skip the "Last Visit" option for now, vBulletin have these "Today", "Yesterday", "A week ago" and then "DD Month YYYY" strings, not something you can directly do math operations on, need a big table. Last edited by modrobert; 30 October 2017 at 15:10. |
30 October 2017, 17:32 | #1577 |
Moderator
Join Date: May 2012
Location: Stockholm / Sweden
Age: 49
Posts: 1,575
|
Thanks. Testing.
|
30 October 2017, 18:09 | #1578 |
Moderator
Join Date: May 2012
Location: Stockholm / Sweden
Age: 49
Posts: 1,575
|
OK done. Thanks modrobert, it works fine. https://grandis.nu:444/eabadduser/ updated =)
|
30 October 2017, 18:13 | #1579 |
Registered User
Join Date: Aug 2006
Location: Scunthorpe/United Kingdom
Posts: 2,087
|
Worked perfectly, many thanks
|
30 October 2017, 18:20 | #1580 |
Moderator
Join Date: May 2012
Location: Stockholm / Sweden
Age: 49
Posts: 1,575
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
While EAB file server is down... | Retroplay | project.Amiga File Server | 24 | 18 March 2020 11:34 |
SWOS '96-'97 (EAB File Server) | Specksynder | support.Games | 8 | 27 September 2014 14:08 |
Secondary file server | DannyBoy | project.Amiga File Server | 12 | 12 August 2013 11:33 |
Is EAB file server deleted ? | Ribdevil | project.Amiga File Server | 13 | 03 February 2012 19:28 |
'Syncing' with the file server | exoticaga | project.Amiga File Server | 5 | 20 August 2010 00:36 |
|
|