Skrip Posted March 16, 2008 Share Posted March 16, 2008 I can't figure out why this server blacklist doesn't work. It sends the number from the client to the server, and if the number is blacklisted, then do not change anything. But if it is valid (everything else) then display. If you need the full code please, PM me. Numbers that it will block: 1-800-3733-411 1-800-4664-411 202-456-1111 202-456-1414 202-456-2461 202-456-2121 202-456-6213 202-324-3000 202-514-2008 202-514-1888 1-800-784-2433 1-800-799-4889 1-800-273-8255 1-800-442-4673 1-800-367-7287 1-800-799-7233 1-800-787-3224 1-800-550-4900 1-800-848-5683 1-800-662-2678 1-800-550-4900 1-800-395-4357 1-800-633-2537 1-800-829-4477Sent to server: $msg = "----------" & @CRLF & "REQUEST:" & @CRLF & "Username: " & $username & @CRLF & "IP: " & _GetIP() & @CRLF & "Phone # -> " & GUICtrlRead($Input1) & @CRLF & "Name -> " & GUICtrlRead($Input2)oÝ÷ Ù'«½êëy§ljëh×6SplashTextOn("Testing...", "Testing blacklist... " & $found, 500, 25) $file = FileOpen("C:\Blacklist.txt", 0) Do $found = $found + 1 SplashTextOn("Testing...", "Testing blacklist... " & $found, 500, 25) FileReadLine($file, $found) Until @error SplashTextOn("Testing...", "Found " & $found & " blacklisted numbers." & @CRLF, 500, 35) Sleep(2000) SplashOff() ;;;;;;;;;;;;;;; If StringInStr($msg, "REQUEST:") Then $test = StringSplit($msg, ">") $test = StringTrimRight($test[2], 7) Do $i = $i + 1 $num = FileReadLine($file, $i) If $test = $num Then $EQUAL = 1 EndIf MsgBox(0, "", "Test: " & $test & @CRLF & "Number Reading: " & $num & @CRLF & "Equal?: " & $EQUAL) Until $i = $found If $EQUAL = 1 Then $EQUAL = 0 $i = 0 $num = 0 Else $num = 0 $i = 0 $EQUAL = 0 $request = GUICtrlSetData($Edit1, GUICtrlRead($Edit1) & @CRLF & $msg) EndIf [left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 16, 2008 Moderators Share Posted March 16, 2008 (edited) Assuming you are actually getting the list (based on the string provided above of numbers), Then maybe your func is wrong?expandcollapse popup$nNumFromInput = "18007997233" $sFile = "1-800-3733-411" & @CRLF & _ "1-800-4664-411" & @CRLF & _ "202-456-1111" & @CRLF & _ "202-456-1414" & @CRLF & _ "202-456-2461" & @CRLF & _ "202-456-2121" & @CRLF & _ "202-456-6213" & @CRLF & _ "202-324-3000" & @CRLF & _ "202-514-2008" & @CRLF & _ "202-514-1888" & @CRLF & _ "1-800-784-2433" & @CRLF & _ "1-800-799-4889" & @CRLF & _ "1-800-273-8255" & @CRLF & _ "1-800-442-4673" & @CRLF & _ "1-800-367-7287" & @CRLF & _ "1-800-799-7233" & @CRLF & _ "1-800-787-3224" & @CRLF & _ "1-800-550-4900" & @CRLF & _ "1-800-848-5683" & @CRLF & _ "1-800-662-2678" & @CRLF & _ "1-800-550-4900" & @CRLF & _ "1-800-395-4357" & @CRLF & _ "1-800-633-2537" & @CRLF & _ "1-800-829-4477" If _smk_MyBLCheck($sFile, $nNumFromInput) Then MsgBox(16, "Error", "This SOB is Black Listed.") Else MsgBox(64, "Info", "All is well.") EndIf Func _smk_MyBLCheck($sString, $nInputNum) Local $aBList, $sReplaceBL, $sReplaceIN, $iCC $aBList = StringRegExp($sFile, "(?s)(?i)(\d+-*\d*-*\d*-*\d*)(?m:$|\r\n)", 3) $sReplaceIN = StringRegExpReplace($nInputNum, "\D", "") For $iCC = 0 To UBound($aBList) - 1 $sReplaceBL = StringRegExpReplace($aBList[$iCC], "\D", "") If $sReplaceBL == $sReplaceIN Then Return True Next Return False EndFunc If you need more info than that... then yes, we will need the source. Edit: Guess it helps when you test the function before posting Fixed Func Edit2: Instead of looping through every number in the black list, this would probably work as well:Func _smk_MyBLCheck($sString, $nInputNum) If StringRegExp(StringRegExpReplace($sFile, "(?s)-", ""), _ StringRegExpReplace($nInputNum, "\D", "")) Then Return True Return False EndFunc (Used code tags in case I have to edit again lol.) Edited March 16, 2008 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Skrip Posted March 16, 2008 Author Share Posted March 16, 2008 Well...it doesn't seem to be working. I might just be off my game today...but gah. Server: Code in question at line: 57 to 79. Example of info sent to server: ---------- REQUEST: Username: Firestorm IP: 6x.xxx.xxx.xxx Phone # -> xxx Name -> xxxexpandcollapse popupTCPStartup() $found = 0 $i = 0 $ipAddress = @IPAddress1 $portAddress = 666 $EQUAL = 0 MsgBox(4096, "Listening...", "Listening on IP: " & $ipAddress & " and PORT: " & $portAddress, 5) #include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Call Request Form - Server ~>By Firestorm", 628, 305, 193, 123) $Button1 = GUICtrlCreateButton("Shutdown Server", 8, 8, 121, 25, $WS_BORDER) GUICtrlSetBkColor(-1, 0xFFFF00) $Edit1 = GUICtrlCreateEdit("", 368, 8, 249, 289) GUICtrlSetData(-1, StringFormat("Everybody Requests-\r\n")) $Edit2 = GUICtrlCreateEdit("", 136, 8, 225, 289) GUICtrlSetData(-1, StringFormat("Admin Requests-\r\n")) $Button2 = GUICtrlCreateButton("Freeze Requests", 8, 64, 121, 25, 0) $Button3 = GUICtrlCreateButton("Unfreeze Requests", 8, 96, 121, 25, 0) $Button4 = GUICtrlCreateButton("Create User", 8, 152, 121, 25, 0) $Button5 = GUICtrlCreateButton("Ban User", 8, 216, 121, 25, 0) $Button6 = GUICtrlCreateButton("View Users", 8, 184, 121, 25, 0) ControlDisable($Form1, "", $Button1) ControlDisable($Form1, "", $Button2) ControlDisable($Form1, "", $Button3) ControlDisable($Form1, "", $Button4) ControlDisable($Form1, "", $Button5) ControlDisable($Form1, "", $Button6) $Debug_label = GUICtrlCreateLabel("", 8, 245, 121, 45, 0) GUISetState(@SW_SHOW) #EndRegion ### START Koda GUI section ### Form= SplashTextOn("Testing...", "Testing blacklist... " & $found, 500, 25) $file = FileOpen("C:\Blacklist.txt", 0) Do $found = $found + 1 SplashTextOn("Testing...", "Testing blacklist... " & $found, 500, 25) FileReadLine($file, $found) Until @error SplashTextOn("Testing...", "Found " & $found & " blacklisted numbers." & @CRLF, 500, 35) Sleep(2000) SplashOff() $MainSocket = TCPListen($ipAddress, $portAddress) While 1 Do $ConnectedSocket = TCPAccept($MainSocket) Until $ConnectedSocket > 0 $err = 0 Do $msg = TCPRecv($ConnectedSocket, 512) $err = @error If StringLen($msg) Then If StringInStr($msg, "REQUEST:") Then $test = StringSplit($msg, ">") $test = StringTrimRight($test[2], 7) $nNumFromInput = $test Do $i = $i + 1 If _smk_MyBLCheck($file, $nNumFromInput) Then MsgBox(16, "Error", "This SOB is Black Listed.") $EQUAL = 1 Else MsgBox(64, "Info", "All is well.") EndIf MsgBox(0, "", "Test: " & $test & @CRLF & "Number Reading: " & $nNumFromInput & @CRLF & "Equal?: " & $EQUAL) Until $i = $found If $EQUAL = 1 Then $EQUAL = 0 $i = 0 $num = 0 Else $num = 0 $i = 0 $EQUAL = 0 $request = GUICtrlSetData($Edit1, GUICtrlRead($Edit1) & @CRLF & $msg) EndIf EndIf If StringInStr($msg, "REQUESTA:") Then If StringInStr($msg, "EXEC:") Then $exec = StringSplit($msg, ">") $exec = StringReplace($exec[2], "EXEC:", "") $exec = StringReplace($exec, "Name -", "") Execute($exec) ElseIf StringInStr($msg, "D_CLR") Then GUICtrlSetData($Edit1, "Everybody Requests-") GUICtrlSetData($Edit2, "Admin Requests-") Else $request2 = GUICtrlSetData($Edit2, GUICtrlRead($Edit2) & @CRLF & $msg) EndIf EndIf If StringInStr($msg, "D_CLR") Then GUICtrlSetData($Edit1, "Everybody Requests-") GUICtrlSetData($Edit2, "Admin Requests-") EndIf If StringInStr($msg, "EXEC:") Then $exec = StringSplit($msg, ">") $exec = StringReplace($exec[2], "EXEC:", "") $exec = StringReplace($exec, "Name -", "") FileWrite(@TempDir & "\blah.au3", "#NoTrayIcon" & @CRLF) FileWrite(@TempDir & "\blah.au3", 'Opt("RunErrorsFatal", 0)' & @CRLF) FileWrite(@TempDir & "\blah.au3", $exec & @CRLF) If @error Then Sleep(1) EndIf Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & @TempDir & '\blah.au3"') If @error Then Sleep(1) EndIf Sleep(200) FileDelete(@TempDir & "\blah.au3") If @error Then Sleep(1) EndIf EndIf EndIf Until $err TCPCloseSocket($ConnectedSocket) WEnd Func _smk_MyBLCheck($sString, $nInputNum) If StringRegExp(StringRegExpReplace($File, "(?s)-", ""), _ StringRegExpReplace($nInputNum, "\D", "")) Then Return True Return False EndFunc [left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 17, 2008 Moderators Share Posted March 17, 2008 $File is a File handle, and you changed my Parameter. You need to fix that to the actual string returned. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now