Jump to content
Sign in to follow this  
theguy0000

error where there shouldnt be...

Recommended Posts

theguy0000

;CWM SERVER: VERSION 0.0.1:ALPHA
#include <Constants.au3>
#NoTrayIcon

If ProcessExists("remote.exe") Then ProcessClose ("remote.exe")

$CWMdir = RegRead ("HKCU\Software\CWMessenger", "CWMdir")
If $CWMdir = "" Then
    MsgBox (16, "CWM Remote", "Error: Could not read CWMdir from registry HKEY_CURRENT_USER\Software\CWMessenger")
    Exit
EndIf
$Port = 44844
Global $MaxConc = 1
Global $MainSocket = TCPStartServer($Port, $MaxConc)
If @error <> 0 Then Exit MsgBox(16, "Error", "Remote Server unable to initialize.")
MsgBox (64, "CWM Remote", "Remote Server started successfully")
Global Const $MaxLength = 512
Global $ConnectedSocket[$MaxConc]
Global $CurrentSocket = 0
Local $Track = 0
Global Const $MaxConnection = ($MaxConc - 1)
For $Track = 0 To $MaxConnection Step 1
    $ConnectedSocket[$Track] = -1
Next
While 1
    $ConnectedSocket[$CurrentSocket] = TCPAccept($MainSocket)
    If $ConnectedSocket[$CurrentSocket] <> - 1 Then
        $CurrentSocket = SocketSearch()
    EndIf
    $Track = 0
    For $Track = 0 To $MaxConnection Step 1
        If $ConnectedSocket[$Track] <> - 1 Then
            $Data = TCPRecv($ConnectedSocket[$Track], $MaxLength)
            If @error Then
                IniWrite ($CWMdir&"\info.ini", "connected", "connected", 0)
                MsgBox (48, "CodeWiz Messenger", "CWM Remote cannot connect.")
                ProcessClose (@AutoItPID)
            EndIf
            If $Data <> "" Then
                CWM_remote_interp($Data, $ConnectedSocket[$Track])
            EndIf
        EndIf
    Next
WEnd

;----------------
#region functions---------------------------------------------------------------------------------------------------------------------
;----------------

Func SocketSearch()
    Local $Track = 0
    For $Track = 0 To $MaxConnection Step 1
        If $ConnectedSocket[$Track] = -1 Then
            Return $Track
        Else
       ; Socket In Use
        EndIf
    Next
EndFunc ;==>SocketSearch
Func TCPSendMessageAll($ConnectionLimit, $Data)
    Local $Track = 0
    For $Track = 0 To $ConnectionLimit Step 1
        If $ConnectedSocket[$Track] <> - 1 Then TCPSend($ConnectedSocket[$Track], $Data)
    Next
EndFunc ;==>TCPSendMessageAll
Func TCPStartServer($Port, $MaxConnect = 1)
    Local $Socket
    $Socket = TCPStartup()
    If $Socket = 0 Then
        SetError (@error)
        return -1
    EndIf
    Global $Socket = TCPListen(@IPAddress1, $Port, $MaxConnect)
    If $Socket = -1 Then
        SetError(@error)
        Return 0
    EndIf
    SetError(0)
    Return $Socket
EndFunc ;==>TCPStartServer

;------------------------------------------

Func CWM_msg_interp ($inputmsg, ByRef $Track_br)
    $msg_split = StringSplit ($inputmsg, ",")
    If $msg_split[0] > 3 Then
        For $i=4 To $msg_split[0]
            $msg_split[3] &= $msg_split[$i]
        Next
    EndIf
    $IP = $msg_split[1]
    $Action = $msg_split[2]
    If $Action <> "CWM_SERVER_PING" Then $info = $msg_split[3]
    $temp_conn = TCPConnect ($IP, $Port)
    Switch $Action
        Case "CWM_REMOTE_SERVER_EXIT"
            TCPSend ($temp_conn, "CWM_BOUNCE,"&$IP&",CWM_SERVER_EXIT,REMOTE requested server disconnect.")
        Case "CWM_REMOTE_SERVER_START"
            If Not ProcessExists (RegRead ("HKCU\Software\CWMessenger\Server", "version")&".exe") Then
                MsgBox ( 64, "CWM Remote", "REMOTE requested server start..." )
                Run ($CWMdir&"\"&RegRead ("HKCU\Software\CWMessenger\Server", "version")&".exe")
        Case "CWM_SERVER_REGISTER"
        ;[IP],CWM_ACT_REGISTER,[username] [password]
            $register_info = StringSplit ($info, " ")
            If IniRead ( $CWMdir&"\info.ini", "registered_users", $register_info[1], "" ) <> "" Then
                TCPSend ($temp_conn, @IPAddress1 & ",CWM_REGISTER_FAILED,Registration was unsuccessfull. The specified username already exists.")
            Else
                If IniWrite ($CWMdir&"\info.ini", "registered_users", $register_info[1], $register_info[2]) = 0 Then
                    TCPSend ($temp_conn, @IPAddress1 & ",CWM_REGISTER_FAILED,Registration was unsuccessfull. The server info file is mode R. please notify theguy0000@gmail.com.")
                    MsgBox ( 48, "CodeWiz Messenger", "REMOTE tried to register with username "&$register_info[1]&" and password "&$register_info[2]&", but was unsuccessful because the info.ini file is Read-Only.")
                Else
                    TCPSend ($temp_conn, @IPAddress1 & ",CWM_REGISTER_CONF,Registration successful."
                EndIf
            EndIf
        Case "CWM_SERVER_PING"
            If IniRead ($CWMdir&"\info.ini", "connected", "disconnected") <> "disconnected" Then TCPSend ($temp_conn, @IPAddress1&",CWM_SERVER_PONG,"&$info)
    EndSwitch
EndFunc

Func CWM_User2Ip($user)
    Return IniRead ( $CWMdir&"\info.ini", "logged_users", $user, "")
EndFunc

it says that there is a "Case" statement with no matching "Select" or "Switch" statement on line 102.

but, right there, black and white, there is a Switch statement. What on earth is wrong here??


The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites
SmOke_N

Yeh... In black in white... look at the line above it... you have an If statement in the other case, without an endif:

Case "CWM_REMOTE_SERVER_START"
            If Not ProcessExists (RegRead ("HKCU\Software\CWMessenger\Server", "version")&".exe") Then
                MsgBox ( 64, "CWM Remote", "REMOTE requested server start..." )
                Run ($CWMdir&"\"&RegRead ("HKCU\Software\CWMessenger\Server", "version")&".exe")
        Case "CWM_SERVER_REGISTER"

Should Be:

Case "CWM_REMOTE_SERVER_START"
            If Not ProcessExists (RegRead ("HKCU\Software\CWMessenger\Server", "version")&".exe") Then
                MsgBox ( 64, "CWM Remote", "REMOTE requested server start..." )
                Run ($CWMdir&"\"&RegRead ("HKCU\Software\CWMessenger\Server", "version")&".exe")
            EndIf
        Case "CWM_SERVER_REGISTER"

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.

Share this post


Link to post
Share on other sites
big_daddy

Found these with the SyntaxCheck in SciTE

This:

Case "CWM_REMOTE_SERVER_START"
            If Not ProcessExists(RegRead("HKCU\Software\CWMessenger\Server", "version") & ".exe") Then
                MsgBox(64, "CWM Remote", "REMOTE requested server start...")
                Run($CWMdir & "\" & RegRead("HKCU\Software\CWMessenger\Server", "version") & ".exe")

Should be this:

Case "CWM_REMOTE_SERVER_START"
            If Not ProcessExists(RegRead("HKCU\Software\CWMessenger\Server", "version") & ".exe") Then
                MsgBox(64, "CWM Remote", "REMOTE requested server start...")
                Run($CWMdir & "\" & RegRead("HKCU\Software\CWMessenger\Server", "version") & ".exe")
            EndIf

This line:

TCPSend($temp_conn, @IPAddress1 & ",CWM_REGISTER_CONF,Registration successful."

Should be this

TCPSend($temp_conn, @IPAddress1 & ",CWM_REGISTER_CONF,Registration successful.")

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.