Jump to content

Problem with FileReadLine


Kitsune
 Share

Recommended Posts

The past couple days I've been working on a Bot-Seeker script to help identify bot accounts on a forum based upon their profiles and I pretty much have it coded out but when it runs it gets trapped in a loop at around line 18 due to an error with FileReadLine, could anyone shed some light on what may be causing the problem?

#include <INet.au3>
Global $stop = 500
Global $botshandle = 0
Global $highhandle = 0
Global $genhandle = 0
Global $Block
Global $Occupation
Global $Interests
Global $line = ""
$botshandle = FileOpen(@ScriptDir & "\TrueBots.txt",1)
If $botshandle = -1 Then MsgBox(0,"Debug","Error at line 10")
$highhandle = FileOpen(@ScriptDir & "\MaybeBots.txt",1)
If $highhandle = -1 Then MsgBox(0,"Debug","Error at line 12")
;====================
$genhandle = FileOpen(@ScriptDir & "\Ocupation.txt",0)
If $genhandle = -1 Then MsgBox(0,"Debug","Error at line 15")
Global $string = ""
While 1
    $line = FileReadLine($genhandle)
    If @error Then MsgBox(0,"Debug","Error at line 19")
    If @error = -1 Then
        ExitLoop
    Else
        $string = $string & $line
    EndIf
Wend
FileClose($genhandle)
$Occupation = StringSplit($string,"<>",1)
;====================
$genhandle = FileOpen(@ScriptDir & "\Interests.txt",0)
If $genhandle = -1 Then MsgBox(0,"Debug","Error at line 30")
Global $string = ""
While 1
    $line = FileReadLine($genhandle)
    If @error Then MsgBox(0,"Debug","Error at line 33")
    If @error = -1 Then
        ExitLoop
    Else
        $string = $string & $line
    EndIf
Wend
FileClose($genhandle)
$Interests = StringSplit($string,"<>",1)
;====================
$genhandle = FileOpen(@ScriptDir & "\BlockDomains.txt",0)
If $genhandle = -1 Then MsgBox(0,"Debug","Error at line 44")
Global $string = ""
While 1
    $line = FileReadLine($genhandle)
    If @error Then MsgBox(0,"Debug","Error at line 48")
    If @error = -1 Then
        ExitLoop
    Else
        $string = $string & $line
    EndIf
Wend
FileClose($genhandle)
$Block = StringSplit($string,"<>",1)
;====================
SearchList()
FileClose($botshandle)
FileClose($highhandle)
Exit


Func SearchList()
    Local $listhandle
    Local $level = 0
    While StringInStr( _InetGetSource("http://2kinds.com/forum/memberlist.php?mode=joindate&order=ASC&start=" & String($level)),"profile.php?mode=viewprofile&amp;u=")
        $listhandle = FileOpen(@ScriptDir & "\Buffer2.txt",2)
        FileWrite($listhandle, _INetGetSource("http://2kinds.com/forum/memberlist.php?mode=joindate&order=ASC&start=" & String($level)))
        If @error Then MsgBox(0,"Debug","Error at line 62")
        FileClose($listhandle)
        $listhandle = FileOpen(@ScriptDir & "\Buffer2.txt",0)
        $string = FileReadLine($listhandle,260)
        While 1
            Do
                $string = FileReadLine($listhandle)
                If @error = -1 Then
                    ExitLoop(2)
                EndIf
            Until StringInStr($string,"profile.php?mode=viewprofile&amp;u=")
            $sarray = StringSplit($string,"profile.php?mode=viewprofile&amp;u=",1)
            $string = $sarray[2]
            $sarray = StringSplit($string,'" ',1)
            $user = $sarray[1]
            CheckMember($user)
        Wend
        FileClose($listhandle)
        $level+=50
        If $level > $stop Then ExitLoop
    Wend
EndFunc


Func CheckMember($member)
    $genhandle = FileOpen(@ScriptDir & "\Buffer.txt",2)
    FileWrite($genhandle, _INetGetSource("http://2kinds.com/forum/profile.php?mode=viewprofile&u=" & $member))
    FileClose($genhandle)
    $genhandle = FileOpen(@ScriptDir & "\Buffer.txt",0)
    Local $buffer
    $buffer = FileRead($genhandle)
    Local $page
    Local $name
    Local $email
    Local $hasemail = False
    Local $icq
    Local $hasicq = False
    Local $msn
    Local $posts
    Local $occupation
    Local $ofail = False
    Local $interests
    Local $ifail = False
    Local $location
    ;===============
    If StringInStr($buffer,"mailto:") Then
        $hasemail = True
    EndIf
    If StringInStr($buffer,"http://wwp.icq.com/scripts/search.dll?to=") Then
        $hasicq = True
    EndIf
    FileReadLine($genhandle,260)
    Do
        $cstring = FileReadLine($genhandle)
;       If @error = -1 Then
;           ExitLoop(2)
;       EndIf
    Until StringInStr($cstring,"Viewing profile :: ")
    $xarray = StringSplit($cstring,"Viewing profile :: ",1)
    $cstring = $xarray[2]
    $xarray = StringSplit($cstring,'</th>',1)
    $name = $xarray[1]
;========================
    Do
        $cstring = FileReadLine($genhandle)
;       If @error = -1 Then
;           ExitLoop(2)
;       EndIf
    Until StringInStr($cstring,"Total posts:")
    $cstring = FileReadLine($genhandle)
    $xarray = StringSplit($cstring,'<span class="gen">',1)
    $cstring = $xarray[2]
    $xarray = StringSplit($cstring,'</span>',1)
    $posts = $xarray[1]
;=======================
    $cstring = FileReadLine($genhandle)
    $cstring = FileReadLine($genhandle)
    $cstring = FileReadLine($genhandle)
    $cstring = FileReadLine($genhandle)
    $xarray = StringSplit($cstring,'<span class="gen">',1)
    $cstring = $xarray[2]
    $xarray = StringSplit($cstring,'</span>',1)
    $location = $xarray[1]
;======================
    $cstring = FileReadLine($genhandle)
    $cstring = FileReadLine($genhandle)
    $cstring = FileReadLine($genhandle)
    $cstring = FileReadLine($genhandle)
    $cstring = FileReadLine($genhandle)
    $cstring = FileReadLine($genhandle)
    $cstring = FileReadLine($genhandle)
    $cstring = FileReadLine($genhandle)
    $xarray = StringSplit($cstring,'<span class="gen">',1)
    $cstring = $xarray[2]
    $xarray = StringSplit($cstring,'</span>',1)
    $occupation = $xarray[1]
;====================
    $cstring = FileReadLine($genhandle)
    $cstring = FileReadLine($genhandle)
    $cstring = FileReadLine($genhandle)
    $cstring = FileReadLine($genhandle)
    $xarray = StringSplit($cstring,'<span class="gen">',1)
    $cstring = $xarray[2]
    $xarray = StringSplit($cstring,'</span>',1)
    $interests = $xarray[1]
;======================
If $hasemail Then
    Do
        $cstring = FileReadLine($genhandle)
;       If @error = -1 Then
;           ExitLoop(2)
;       EndIf
    Until StringInStr($cstring,"mailto:")
    $xarray = StringSplit($cstring,'mailto:',1)
    $cstring = $xarray[2]
    $xarray = StringSplit($cstring,'"',1)
    $email = $xarray[1]
EndIf
;========================
    Do
        $cstring = FileReadLine($genhandle)
;       If @error = -1 Then
;           ExitLoop(2)
;       EndIf
    Until StringInStr($cstring,"MSN Messenger")
    $cstring = FileReadLine($genhandle)
    $xarray = StringSplit($cstring,'<span class="gen">',1)
    $cstring = $xarray[2]
    $xarray = StringSplit($cstring,'</span>',1)
    $msn = $xarray[1]
;========================
If $hasicq Then
    Do
        $cstring = FileReadLine($genhandle)
;       If @error = -1 Then
;           ExitLoop(2)
;       EndIf
    Until StringInStr($cstring,"http://wwp.icq.com/scripts/search.dll?to=")
    $xarray = StringSplit($cstring,'http://wwp.icq.com/scripts/search.dll?to=',1)
    $cstring = $xarray[2]
    $xarray = StringSplit($cstring,'"><',1)
    $icq = $xarray[1]
EndIf
;========================
FileClose($genhandle)
;============================================================================================================================================================
;BOT DETECTION LOGIC=========================================================================================================================================
;============================================================================================================================================================
    If $hasicq Then
        If StringInStr(_INetGetSource("http://wwp.icq.com/scripts/search.dll?to=" & $icq),"error page") Then
            If Int($posts) Then
                FileWriteLine($highhandle,$name)
                Return
            Else
                FileWriteLine($botshandle,$name)
                Return
            EndIf
        EndIf
    EndIf
    For $x = 1 to $Block[0]
        If StringInStr($email,$Block[$x]) Then
            FileWriteLine($botshandle,$name)
            Return
        EndIf
    Next
    If StringInStr($email,"www.") Or StringInStr($email,"http") Then
        FileWriteLine($botshandle,$name)
        Return
    EndIf
    For $x = 1 to $Occupation[0]
        If Not StringCompare($email,$Occupation[$x]) Then
            $ofail = True
            ExitLoop
        EndIf
    Next
    For $x = 1 to $Interests[0]
        If Not StringCompare($email,$Interests[$x]) Then
            $ifail = True
            ExitLoop
        EndIf
    Next
    If $hasicq And ($ofail Or $ifail) And Int($posts) Then
        FileWriteLine($highhandle,$name)
        Return
    ElseIf ($hasicq And $ofail And Not Int($posts)) OR ($hasicq And $ifail And Not Int($posts)) Or ($ofail And $ifail) Then
        FileWriteLine($botshandle,$name)
        Return
    EndIF
EndFunc
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...