Jump to content

AU3Chat Server/Client


erifash
 Share

Recommended Posts

  • Replies 69
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

please do its an amazinhg thing that me and my m8s use... but we have to start up new account when we logout cus of the eoor with the exit button... it dont log you out...

i removed most of the bugs and the xskin:

Edit: now anyone can be admin, the server owner just need to set admin to 1 inside database.ini and fixed more bugs

Chat.zip Update

Edited by Alek

[font="Impact"]Never fear, I is here.[/font]

Link to comment
Share on other sites

  • 2 weeks later...

yoooooooooooooooooooooooooooooo

so cool !!!!

:):P:):)

Can I make a sugestion ?

- the Admin should be able to see the PM (or to make an option )

sooo cool anyway many thanks !

Link to comment
Share on other sites

  • Developers

I get this error message when I try to log in as administrator. Everything works fine. I am using the original version, the first download link posted on page 1.

Posted Image

Like I said, everything works just fine except for this.

Its as the error states ... BinaryString() is an invalid function.

It did exist in some Beta versions but was removed/replaced ...

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I get this error message when I try to log in as administrator. Everything works fine. I am using the original version, the first download link posted on page 1.

Take the one in Page 4 it works well !!!

Cramaboule :)

Link to comment
Share on other sites

I tried that one, it's all messed up. The server version won't work unless the IP is set to 0.0.0.0 and the client version doesn't work at all it tells me wrong username and password when its the first time I have entered it.

Are there some missing configuration instructions or something?

The SuperFlyChetGuy
Link to comment
Share on other sites

Are there some missing configuration instructions or something?

Yeees,

The @IPaddress2 needs to be changed either by @Ipaddress1 or by the address of your server,

the ini file might make some problem as well so,I changed the begining as this:

IniWrite(@ScriptDir & "\Database.ini", "Serverconfig", "Ip", @IPAddress1)
IniWrite(@ScriptDir & "\Database.ini", "Serverconfig", "port", "31758")
if not FileExists(@ScriptDir & "\Database.ini") Then
    IniWrite(@ScriptDir & "\Database.ini","Admin","Password","Admin")
    IniWrite(@ScriptDir & "\Database.ini","Admin","Online","0")
    IniWrite(@ScriptDir & "\Database.ini","Admin","Ban","0")
EndIfoÝ÷ Øíç%éíjëh×6IniWrite("Config.ini","Config","Ip",---IP OF THE SERVER---)
IniWrite("Config.ini","Config","Port","31758")
if not FileExists("Config.ini") Then 
    IniWrite("Config.ini","Save","Username","")
    IniWrite("Config.ini","Save","Password","")
EndIf

then every time it write the IP address,... but Who cares ???

Cramaboule :)

Link to comment
Share on other sites

What about logout? When i try to reconnect it says user is currently connected so I have to manually adjust the server ini file back to "0" before I can get back on. Any changes there?

stop 1rst the client than the serever !
Link to comment
Share on other sites

ok, now its almost perfect :P

Whats new:

-You no longer have to restart the client if enter wrong password or the username you try reg is already in use

-change the userlist to Guictrlcreatelist, insted of guictrlcreatelistview, i think it looks better

-the server now creates a log

-->What the server logs

-->When people enter and if the person that enter is admin or not

--> what people say and pm eachother

--> when a Admin kicks or bans another person

-->what admin banned/kicked what user, looks something like this <"name of Admin" Banned/kicked "Name of User">

Server:

[autoit]Opt("TrayMenuMode", 1)

$traystop = TrayCreateItem("Stop server")

FileDelete("Log.txt")

Global Const $IP = @IPAddress2

Global Const $PORT = IniRead(@ScriptDir & "\database.ini","ServerConfig","Port","31758")

if not FileExists(@ScriptDir & "\Database.ini") Then

IniWriteSection(@ScriptDir & "\Database.ini","ServerConfig","Port=" & $PORT)

IniWrite(@ScriptDir & "\Database.ini","Admin","Password","Admin")

IniWrite(@ScriptDir & "\Database.ini","Admin","Online","0")

IniWrite(@ScriptDir & "\Database.ini","Admin","Ban","0")

IniWrite(@ScriptDir & "\Database.ini","Admin","Admin","1")

EndIf

Global $listen

Global $list[101][2] ; [ index ][ socket, username ]

_Log("Strating up Server")

TCPStartup()

$listen = TCPListen($IP, $PORT, 17)

If $listen = -1 Then

_Log("Unable to connect")

mError("Unable to connect.", 1)

EndIf

TrayTip("AU3Chat", "Server is connected on:" & @CRLF & $IP & ":" & $PORT, 15, 1)

_ReduceMemory()

While 1

$msg = TrayGetMsg()

If $msg = $traystop Then Exit

_CheckConn()

Sleep(0)

$sock = TCPAccept($listen)

If $sock = -1 Then ContinueLoop

_AddConn($sock)

_ReduceMemory()

WEnd

Func _AddConn($iSocket)

Local $recv = _SockRecv($iSocket), $temp

Local $erorr = 0

If @error Then

_DelConn($iSocket)

Else

$temp = StringSplit($recv, Chr(2))

Switch $temp[1]

Case "Reguser"

_Reguser($temp[2],$temp[3],$iSocket)

Case "login"

$User = $temp[2]

$Password = $temp[3]

_Login($User,$Password,$iSocket)

EndSwitch

EndIf

Return 0

EndFunc ;==>_AddConn

Func _DelConn($iSocket)

For $i = 0 To 100

If $list[$i][0] = $iSocket Then

TCPCloseSocket($iSocket)

$list[$i][0] = 0

$list[$i][1] = ""

Return 1

EndIf

Next

Return 0

EndFunc ;==>_DelConn

Func _CheckConn()

Local $recv = ""

For $i = 0 To 100

If $list[$i][0] Then

$recv = TCPRecv($list[$i][0], 2048)

If @error Then

TCPCloseSocket($list[$i][0])

_SendAll(Chr(1) & "deluser" & Chr(2) & $list[$i][1])

$list[$i][0] = 0

$list[$i][1] = ""

Else

If $recv <> "" Then

$temp = StringSplit($recv, Chr(2))

Switch $temp[1]

Case "bye"

TCPCloseSocket($list[$i][0])

IniWrite("Database.ini", $list[$i][1], "Online", "0")

_SendAll(Chr(1) & "deluser" & Chr(2) & $list[$i][1])

_Log("<" & $list[$i][1] & "> Left the chat rom")

$list[$i][0] = 0

$list[$i][1] = ""

Case "kick"

_Kick($temp[2])

_Log("<" & $temp[2] & "> Kicked Bye" & $list[$i][1] )

Case "ban"

_ban($temp[2])

_Log("<" & $temp[2] & "> Banned Bye " & $list[$i][1])

Case "PM"

_PM($temp[2], $temp[3], $list[$i][1])

_Log("<PM From " & $list[$i][1] & " To " & $temp[2] & "> " & $temp[3])

Case "msg"

_SendAll($temp[2], $list[$i][1])

_Log("<" & $list[$i][1] & "> " & $temp[2])

Endswitch

EndIf

EndIf

EndIf

Next

EndFunc ;==>_CheckConn

Func _SendAll($str, $from = "", $except = 0)

For $i = 0 To 100

If $list[$i][0] And $list[$i][0] <> $except Then

If $from And StringLeft($str, 1) <> Chr(1) Then

TCPSend($list[$i][0], "<" & $from & ">: " & $str)

Else

TCPSend($list[$i][0], $str)

EndIf

EndIf

Next

EndFunc ;==>_SendAll

Func _Kick($user)

if not _isadmin($user) Then

For $i = 0 To 99

If $list[$i][1] = $user Then

TCPSend($list[$i][0], Chr(1) & "kick")

TCPCloseSocket($list[$i][0])

$list[$i][0] = 0

IniWrite("Database.ini", $list[$i][1], "Online", "0")

_SendAll(Chr(1) & "deluser" & Chr(2) & $list[$i][1])

$list[$i][1] = ""

Return 1

EndIf

Next

Return 0

EndIf

EndFunc ;==>_Kick

Func _ban($user)

if not _isadmin($user) Then

For $i = 0 To 99

If $list[$i][1] = $user Then

TCPSend($list[$i][0], Chr(1) & "ban")

TCPCloseSocket($list[$i][0])

$list[$i][0] = 0

IniWrite("Database.ini", $list[$i][1], "Ban", "1")

IniWrite("Database.ini", $list[$i][1], "Online", "0")

_SendAll(Chr(1) & "deluser" & Chr(2) & $list[$i][1])

$list[$i][1] = ""

Return 1

EndIf

Next

Return 0

EndIf

EndFunc ;==>_ban

Func _PM($user, $str, $from)

if $from <> $user Then

For $i = 0 To 100

$Admin = IniRead("Database.ini",$list[$i][1],"Admin","0")

If $list[$i][1] = $user Then

TCPSend($list[$i][0], "<PM:" & $from & ">: " & $str)

elseif _isadmin($list[$i][1]) and not _isadmin($from) Then

TCPSend($list[$i][0], "Admin Message: "& @CRLF & "<PM: From " & $from & " To " & $user & ">: " & $str)

EndIf

Next

Return 0

EndIf

EndFunc ;==>_PM

Func _SendUsers($iSocket)

For $i = 0 To 100

If $list[$i][0] Then TCPSend($iSocket, Chr(1) & "adduser" & Chr(2) & $list[$i][1])

Next

EndFunc ;==>_SendUsers

Func _SockRecv($iSocket, $iBytes = 2048)

Local $sData = ""

While $sData = ""

$sData = TCPRecv($iSocket, $iBytes)

If @error Then Return SetError(1, 0, 0)

WEnd

Return $sData

EndFunc ;==>_SockRecv

Func _ReduceMemory()

DllCall("psapi.dll", "int", "EmptyWorkingSet", "long", -1)

EndFunc ;==>_ReduceMemory

Func mError($sText, $iFatal = 0, $sTitle = "Error", $iOpt = 0)

Local $ret = MsgBox(48 + 4096 + 262144 + $iOpt, $sTitle, $sText)

If $iFatal Then Exit

Return $ret

EndFunc ;==>mError

Func OnAutoitStart()

$var = IniReadSectionNames("Database.ini")

If @error Then

MsgBox(4096, "", "Error occurred, probably no INI file.")

Else

For $i = 2 To $var[0]

IniWrite("Database.ini", $var[$i], "Online", "0")

Next

EndIf

EndFunc

Func _isadmin($user)

if IniRead(@ScriptDir & "\database.ini",$user,"Admin","0") = 1 Then

Return True

Else

Return False

EndIf

EndFunc

Func _SocketToIP($SHOCKET)

Local $sockaddr = DllStructCreate("short;ushort;uint;char[8]")

Local $aRet = DllCall("Ws2_32.dll", "int", "getpeername", "int", $SHOCKET, _

"ptr", DllStructGetPtr($sockaddr), "int_ptr", DllStructGetSize($sockaddr))

If Not @error And $aRet[0] = 0 Then

$aRet = DllCall("Ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($sockaddr, 3))

If Not @error Then $aRet = $aRet[0]

Else

$aRet = 0

EndIf

$sockaddr = 0

Return $aRet

EndFunc ;==>_SocketToIP

Func _Login($S_Username,$S_Password,$iSocket)

if $S_Password == IniRead("Database.ini", $S_Username, "Password", "") Then

If IniRead("Database.ini", $S_Username, "Online", "0") = 0 Then

If IniRead("Database.ini", $S_Username, "Ban", "0") = 0 Then

For $i = 0 To 100

If Not $list[$i][0] Then

$list[$i][0] = $iSocket

$list[$i][1] = $S_Username

$Admin = IniRead("Database.ini",$S_Username,"Admin","0")

if $Admin = 1 then

TCPSend($iSocket, Chr(1) & "adminaccepted")

_Log("User: " & $S_Username & " Connected. Is Admin")

Else

TCPSend($iSocket, Chr(1) & "accepted")

_Log("User: " & $S_Username & " Connected.")

EndIf

IniWrite("Database.ini", $S_Username, "Online", "1")

IniWrite("Database.ini", $S_Username, "Ip", _SocketToIP($iSocket))

_SendUsers($iSocket)

_SendAll(Chr(1) & "adduser" & Chr(2) & $S_Username, "", $iSocket)

Return 1

EndIf

Next

Else

TCPSend($iSocket, Chr(1) & "banerror")

EndIf

Else

TCPSend($iSocket, Chr(1) & "rejected")

EndIf

Else

TCPSend($iSocket, Chr(1) & "passerror")

EndIf

EndFunc

Func _Reguser($S_Username,$S_Password,$iSocket)

$var = IniRead("Database.ini", $S_Username, "Password", "NoError")

If $var = "NoError" Then

IniDelete("Database", "Reguser")

FileWrite("Database.ini", @CRLF & @CRLF)

IniWrite("Database.ini", $S_Username, "Password", $S_Password)

IniWrite("Database.ini", $S_Username, "Online", "0")

IniWrite("Database.ini", $S_Username, "Ban", "0")

IniWrite("Database.ini", $S_Username, "Admin", "0")

TCPSend($iSocket, Chr(1) & "regdone")

_Log("User: " & $S_Username & " Created")

Else

TCPSend($iSocket, Chr(1) & "regerror")

_Kick($S_Username)

EndIf

EndFunc

Func _Log($s_Log, $s_LogFile="Log.txt")

FileWrite($s_LogFile,$s_Log & @CRLF)

EndFunc

Func OnAutoItExit()

$var = IniReadSectionNames("Database.ini")

If @error Then

MsgBox(4096, "", "Error occurred, probably no INI file.")

Else

For $i = 2 To $var[0]

IniWrite("Database.ini", $var[$i], "Online", "0")

Next

EndIf

_SendAll(Chr(1) & "exit")

TCPShutdown()

Exit

EndFunc ;==>OnAutoItExit

[font="Impact"]Never fear, I is here.[/font]

Link to comment
Share on other sites

  • 4 months later...

Hey

If anyone's still looking at this i fixed some of the bugs and gave to admin a few more options.

- The DBViewer.au3 in one of the zip files i merged with the client for the admin.

- Added an option for the admin to remove the create user

- Added encryption for the password

- In the database viewer i added kick, ban, make admin, remove admin and delete user.

- Added tray tips on the server program.

I'm now looking into a change password button

Also there's still a problem with the logout.

If you download the zipped files the admin username and password is admin

AU3Chat.zip

Edited by Gmail
Link to comment
Share on other sites

Hey

If anyone's still looking at this i fixed some of the bugs and gave to admin a few more options.

- The DBViewer.au3 in one of the zip files i merged with the client for the admin.

- Added an option for the admin to remove the create user

- Added encryption for the password

- In the database viewer i added kick, ban, make admin, remove admin and delete user.

- Added tray tips on the server program.

I'm now looking into a change password button

Also there's still a problem with the logout.

If you download the zipped files the admin username and password is admin

AU3Chat.zip

i whould sugest you have a look here:

http://www.autoitscript.com/forum/index.php?showtopic=52121

its a newer version of the script, it has bin totaly rewriten, this one i posted here has bin overscripted with many bugs and security problems :)

[font="Impact"]Never fear, I is here.[/font]

Link to comment
Share on other sites

  • 4 months later...

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...