lsakizada Posted April 18, 2007 Share Posted April 18, 2007 That is one of many reasons to rewrite the code. The GUI will probably be mostly the same but the way in which the client and server communicate will be different.Any news on the next release.? Be Green Now or Never (BGNN)! Link to comment Share on other sites More sharing options...
RazerM Posted April 18, 2007 Share Posted April 18, 2007 There's still alot to be done as we are both quite busy. My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop. Link to comment Share on other sites More sharing options...
jvanegmond Posted May 31, 2007 Author Share Posted May 31, 2007 Updated to v0.3.6. Changes: Ready-to-use package. Registering and email now work properly. (Minor change). github.com/jvanegmond Link to comment Share on other sites More sharing options...
RazerM Posted June 1, 2007 Share Posted June 1, 2007 Make sure server is running? Check code but Cobra isn't being developed just now. My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop. Link to comment Share on other sites More sharing options...
jvanegmond Posted June 1, 2007 Author Share Posted June 1, 2007 (edited) Yes the server was running.I saw in the title the code was updated.Don't forget to change the target IP inside the client. Currently it's set at my house and I don't have a server running. Edited June 1, 2007 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
poisonkiller Posted June 1, 2007 Share Posted June 1, 2007 (edited) I decided to give it a try and host a server, so here's the ip: 192.168.13.116And please, don't try to hack my computer in any way.EDIT: My name as admin is poisonkiller, as always, so come inside and lets chat or whatever. Edited June 1, 2007 by poisonkiller Link to comment Share on other sites More sharing options...
jvanegmond Posted June 1, 2007 Author Share Posted June 1, 2007 I decided to give it a try and host a server, so here's the ip: 192.168.13.116And please, don't try to hack my computer in any way.EDIT: My name as admin is poisonkiller, as always, so come inside and lets chat or whatever.Are you sure that's not your local IP? I'm having trouble connecting.By the way, the Cobra server is secure. Your computer can not be hacked through it. github.com/jvanegmond Link to comment Share on other sites More sharing options...
poisonkiller Posted June 1, 2007 Share Posted June 1, 2007 (edited) I'm 100% sure it's my local IP. Maybe my internet screws me over again. Can you host a server for a little so I can see if I can connect to you? And by hacking, i ment DDOS or sth. A hacker could do lots of things with a local IP. EDIT: I forgot to mention earlier, but you should add some canceling button to login screen, because I had to shut down your program from task manager when it froze, when your server was down and I couldn't connect. Edited June 1, 2007 by poisonkiller Link to comment Share on other sites More sharing options...
RazerM Posted June 1, 2007 Share Posted June 1, 2007 To host a server you must find your external ip address, not your local one (only accessible inside your own network). My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop. Link to comment Share on other sites More sharing options...
poisonkiller Posted June 1, 2007 Share Posted June 1, 2007 (edited) FollowMeIP Lite says, that my external IP is: 85.89.32.91. So I'll start hosting again with that IP. I have to say, I honestly had no idea TCP hosting needs external IP address. EDIT: Now I can't understand one thing: if i want to connect to my server on my computer, i need to know my local IP to connect, if i want to connect from another computer then i need to know my external IP. Is that right, cause when i tried to log in with my external IP i couldn't log in. Edited June 1, 2007 by poisonkiller Link to comment Share on other sites More sharing options...
Shides Posted June 1, 2007 Share Posted June 1, 2007 Good Work!!! :) I'm a Italian a AutoIterMy scriptTxTediTor -->TxTediTor is a simple program similar notepad[center]Please vote me with five star ;)Antonio Caragliano for Nokia Nseries[/center] Link to comment Share on other sites More sharing options...
jvanegmond Posted June 1, 2007 Author Share Posted June 1, 2007 (edited) FollowMeIP Lite says, that my external IP is: 85.89.32.91. So I'll start hosting again with that IP. I have to say, I honestly had no idea TCP hosting needs external IP address. EDIT: Now I can't understand one thing: if i want to connect to my server on my computer, i need to know my local IP to connect, if i want to connect from another computer then i need to know my external IP. Is that right, cause when i tried to log in with my external IP i couldn't log in.You need to forward your 48130 port from your router to your local IP address.There are lots of manual online how to do it.@Shides, thanks. Your avatar is hot. Edited June 1, 2007 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
poisonkiller Posted June 1, 2007 Share Posted June 1, 2007 (edited) Okay, this is my last try: 192.168.13.116. If that doesn't work, I give up. EDIT: I'm going to sleep so server is closed for ~10 hours.EDIT2: Server is up again. Edited June 2, 2007 by poisonkiller Link to comment Share on other sites More sharing options...
JavaScript_Freek Posted June 2, 2007 Share Posted June 2, 2007 It freezes when i try to log in or register. Cool app tho. [center]Cookyx.com :: Simple LAN Chat[/center] Link to comment Share on other sites More sharing options...
Shides Posted June 2, 2007 Share Posted June 2, 2007 @Shides, thanks. Your avatar is hot. :) It freezes when i try to log in or register. Cool app tho.Yeah, but is good app I'm a Italian a AutoIterMy scriptTxTediTor -->TxTediTor is a simple program similar notepad[center]Please vote me with five star ;)Antonio Caragliano for Nokia Nseries[/center] Link to comment Share on other sites More sharing options...
RazerM Posted June 2, 2007 Share Posted June 2, 2007 (edited) I'll clear a few things up about running your own server: Firstly run Server.au3 from Cobra Server Pack folder, leave email field at Admin and enter a password. Open up Cobra.au3 from Cobra folder and edit first line to $IP = @IPAddress1 which is your lcal IP address, ie your servers IP address. Run Cobra.au3 and enter your email address and password, click register. A validation email will be sent, but may not arrive in your inbox because you are behind a router (as I am), If that is the case open Database.ini from Cobra Server Pack folder and look for the ActivationCode key under the section [your email] and copy the code after the equals sign, for example; [frazergmclean@gmail.com] ActivationCode=0BGFD58GD 0BGFD58GD is the code. In Cobra.au3 script click login and paste code we just copied (normally sent to email) into the newly created field, you are now logged in. You can create more than one instance of cobra.au3 to test chat. Edited June 2, 2007 by RazerM My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop. Link to comment Share on other sites More sharing options...
JavaScript_Freek Posted June 4, 2007 Share Posted June 4, 2007 (edited) Cool! I'm logged in! God I really want disect this script so I can learn! May I? Btw why not just use Usernames? EDIT: Haha omg i put a word 'Dan' and im logged in as Dan! WoOT! Edited June 4, 2007 by JavaScript_Freek [center]Cookyx.com :: Simple LAN Chat[/center] Link to comment Share on other sites More sharing options...
jvanegmond Posted June 4, 2007 Author Share Posted June 4, 2007 Cool! I'm logged in! God I really want disect this script so I can learn! May I? Btw why not just use Usernames?EDIT: Haha omg i put a word 'Dan' and im logged in as Dan! WoOT!Sure you can dissect it and learn from it. We would be honored if you do.We didn't user names for spam reasons. We want to incorporate email later on, and making the transition to emails early makes it easier for us.We're working on a next release with added features and improved security. github.com/jvanegmond Link to comment Share on other sites More sharing options...
Dhilip89 Posted June 10, 2007 Share Posted June 10, 2007 (edited) Very cool script, and I liked it so much! OK, I tried this script. It worked, but it lack somethings -- Unicode support. I modified the script to work with unicode characters. It worked very well. OK, I provide the function I wrote : _UnicodeStringConvert() Func _UnicodeStringConvert($UnicodeString) $UnicodeStringLength = StringLen($UnicodeString) Local $Unicode_Code For $i = 1 To $UnicodeStringLength $UnicodeStringChar = StringMid($UnicodeString, $i, 1) If StringInStr(" $-_.+!*'(),;/?:@=&abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", $UnicodeStringChar) Then $Unicode_Code &= $UnicodeStringChar Else $Unicode_Code &= '&#' & AscW ($UnicodeStringChar) & ';' EndIf Next Return $Unicode_Code EndFunc ;==>_UnicodeStringConvert The modified script: Cobra.au3 expandcollapse popupTCPStartup ( ) $IP = TCPNameToIP("dhilip89.hopto.org" );"84.104.25.84" ;when using @IPAdress1 it also allows multiple instances. ;~ $IP = "82.217.135.102" ;MsgBox(64,"dd",$IP) TCPShutdown ( ) #cs Copyright (c) 2006, Manadar All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Cobra nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ce ; Includes ; -------- #include <GUIConstants.au3> ; Lots of constants are used, this include will be in the final version. #include <Array.au3> ; Array functions are a necessity! #Include <Constants.au3> ; Needed for tray constants #Include <GuiEdit.au3> ; Needed for 2 (!!) contants... :[ #include <Misc.au3> ; Only needed for Singleton.. #include <String.au3> ; StringEncrypt only. #include <IE.au3> ;Used for chat box #include <color.au3> ;Only uses _ColorGetRed, _ColorGetGreen and _ColorGetBlue for gradient text Opt("TrayMenuMode", 1) ; Default tray menu items (Script Paused/Exit) will not be shown. Opt("TrayOnEventMode", 1) Opt("GUIEventOptions", 1) Opt("GUICloseOnESC", 0) ; Log in/out register requests ; ---------------------------- Global Const $AUTHORIZE = "AUT" Global Const $LOGOUT = "OUT" Global Const $REGISTER = "REG" Global Const $ACTIVATE = "ACT" ; Update request Global Const $DOWNLOAD = "DNL" ; Common requests ; --------------- Global Const $GETSTATE = "GST" Global Const $MESSAGE = "MSG" Global Const $CHANGENAME = "CHG" ; Contacts requests ; ----------------- Global Const $ADDUSER = "ADD" Global Const $DELUSER = "DEL" Global Const $GETLIST = "GET" ; Responses ; --------- Global Const $ACKNOWLEDGE = "ACK" Global Const $DENIAL = "DIE" Global Const $ERROR = "ERR" ; Variable declaration ; -------------------- Global $Socket = -1 ; This has to be declared before any call to the exit funtion, because OnAutoItExit checks for $Socket. Global $AppTitle = "Cobra" Global $MyVersion = "v0.3.6" Global $MyContacts Global $SelectCancelButton = -5555, $SelectOkButton = -5555, $SelectList = -5555, $SelectGUI = "" Global $State = $GUI_ENABLE, $ActivationCodeButton = "",$GUIState = "" Global $Afk = 0, $AutoMessage ; Now that some variables are set, lets make sure the app isn't running before we really initialize the thing. If _Singleton($AppTitle, 1) = 0 AND $IP <> @IPAddress1 Then WinSetState($AppTitle, "", @SW_SHOW) WinActivate($AppTitle) Exit EndIf ; Initialisation ; -------------- TCPStartup() TrayCreateItem("Cobra Homepage") TrayItemSetOnEvent(-1, "StartHomepage") TrayCreateItem("") $IM = TrayCreateItem("Instant message...") TrayItemSetState(-1, $TRAY_DISABLE) TrayItemSetOnEvent(-1, "InstantMessage") TrayCreateItem("") TrayCreateItem("Open " & $AppTitle) TrayItemSetState(-1, $TRAY_DEFAULT) TrayItemSetOnEvent(-1, "ActivateMainWindow") TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "Terminate") TraySetToolTip($AppTitle & " - Instant Messenger") TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "ActivateMainWindow") _IEErrorHandlerRegister() ; Main loop ; --------- While 1 #region Log in procedure ; ---------------------- ; this makes the gui resize and keep its controls in the middle. Opt("GUIResizeMode", $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT + $GUI_DOCKTOP + $GUI_DOCKLEFT) ; GUI Creation ; ------------ $GUI = GUICreate($AppTitle, 600, 400, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX)) GUISetFont(10, 400, 0, "Verdana") ; GUI Menu Creation ; ----------------- $File = GUICtrlCreateMenu("&File") $LogOff = GUICtrlCreateMenuitem("Log Off", $File) GUICtrlCreateMenuitem("", $File) $Exit = GUICtrlCreateMenuitem("Exit", $File) $ContactsMenu = GUICtrlCreateMenu("&Contacts") $AddContact = GUICtrlCreateMenuitem("Add a contact", $ContactsMenu) $DelContact = GUICtrlCreateMenuitem("Delete a contact", $ContactsMenu) GUICtrlCreateMenuitem("", $ContactsMenu) $Import = GUICtrlCreateMenuitem("Import contacts from file", $ContactsMenu) $Export = GUICtrlCreateMenuitem("Export contacts to file", $ContactsMenu) For $x = $LogOff To $Export GUICtrlSetState($x, $GUI_DISABLE) Next GUICtrlSetState($Exit, $GUI_ENABLE) GUICtrlSetState($ContactsMenu, $GUI_ENABLE) ; GUI Control Creation ; --------------------- GUICtrlCreateLabel("E-Mail", 129, 137, 70, 17, $SS_CENTER) GUICtrlCreateLabel("Password", 129, 165, 70, 17, $SS_CENTER) $Username = GUICtrlCreateInput("", 214, 135, 200, 21) $Password = GUICtrlCreateInput("", 214, 160, 200, 21, BitOR($ES_PASSWORD, $ES_AUTOHSCROLL)) $RememberMe = GUICtrlCreateCheckbox("Remember Me", 214, 188) GUICtrlSetState(-1, $GUI_DISABLE) $RememberPwd = GUICtrlCreateCheckbox("Remember My Password", 214, 210) GUICtrlSetState(-1, $GUI_DISABLE) $LogIn = GUICtrlCreateButton("Log in", 224, 235, 75, 25, 0) $RegisterButton = GUICtrlCreateButton("Register", 304, 235, 75, 25, 0) ;~ GUICtrlSetState(-1,$GUI_DISABLE) $Status = GUICtrlCreateLabel($GUIState, 129, 110, 285, 22, $SS_CENTER) $sTemp = IniRead(@ScriptDir & "\config.ini", "Credentials", "UserName", "DoNotRemember") If $sTemp <> "DoNotRemember" Then $IniUsr = _StringEncrypt(0, $sTemp, "CobraCredentials") GUICtrlSetData($Username, $IniUsr) EndIf $sTemp2 = IniRead(@ScriptDir & "\config.ini", "Credentials", "Password", "DoNotRemember") If $sTemp2 <> "DoNotRemember" Then $IniPwd = _StringEncrypt(0, $sTemp2, $sTemp & "CobraCredentials") GUICtrlSetData($Password, $IniPwd) EndIf If IniRead(@ScriptDir & "\config.ini", "Settings", "RememberMe", 0) = 1 Then GUICtrlSetState($RememberMe, $GUI_CHECKED) EndIf If IniRead(@ScriptDir & "\config.ini", "Settings", "RememberPwd", 0) = 1 Then GUICtrlSetState($RememberPwd, $GUI_CHECKED) EndIf GUISetState() ; GUI Message Loop ; ---------------- Local $oldUsr, $Usr, $oldPwd, $Pwd, $oldRememberCheck, $RememberCheck While 1 $Usr = GUICtrlRead($Username) If $Usr <> $oldUsr Then If $Usr = "" Then GUICtrlSetState($RememberMe, $GUI_DISABLE) GUICtrlSetState($RememberPwd, $GUI_DISABLE) Else GUICtrlSetState($RememberMe, $GUI_ENABLE) EndIf $oldUsr = $Usr EndIf $Pwd = GUICtrlRead($Password) If $Pwd <> $oldPwd Then If $Pwd = "" Then GUICtrlSetState($RememberPwd, $GUI_DISABLE) ElseIf $Usr <> "" And BitAND(GUICtrlRead($RememberMe), $GUI_CHECKED) Then GUICtrlSetState($RememberPwd, $GUI_ENABLE) EndIf $oldPwd = $Pwd EndIf $RememberCheck = BitAND(GUICtrlRead($RememberMe), $GUI_CHECKED) If $RememberCheck <> $oldRememberCheck Then If BitAND(GUICtrlRead($RememberMe), $GUI_CHECKED) Then GUICtrlSetState($RememberPwd, $GUI_ENABLE) If BitAND(GUICtrlRead($RememberMe), $GUI_UNCHECKED) Then GUICtrlSetState($RememberPwd, $GUI_DISABLE) $oldRememberCheck = $RememberCheck EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE WinSetState($GUI, "", @SW_HIDE) Case $Exit Exit Case $GUI_EVENT_MINIMIZE WinSetState($GUI, "", @SW_MINIMIZE) Case $GUI_EVENT_MAXIMIZE WinSetState($GUI, "", @SW_MAXIMIZE) Case $GUI_EVENT_RESTORE WinSetState($GUI, "", @SW_RESTORE) Case $LogIn If Valid($Username) And Valid($Password) Then If $ActivationCodeButton Then $ActivationCode = GUICtrlRead($ActivationCodeButton) TCPSend($Socket, $ACTIVATE & " " & GUICtrlRead($Username) & " " & $ActivationCode) Switch GetReply() Case $ACKNOWLEDGE $ActivationCodeButton = "" GUICtrlSetData($Status, "Your account has been activated.") Sleep(500) ; Activation code was good. TCPSend($Socket, $AUTHORIZE & " " & GUICtrlRead($Username) & " " & _StringEncrypt(1, GUICtrlRead($Password), GUICtrlRead($Username)) & " " & $MyVersion) GUICtrlSetData($Status, "Resending authorisation..") Switch GetReply() Case $ACKNOWLEDGE ExitLoop Case $DENIAL GUICtrlSetData($Status, "Incorrect username or password.") ToggleLogin() Case $DOWNLOAD ; Using a old version! Need to update to the new one. $Split = StringSplit($Reply, " ") ; If command looks like "DNL url version" ( Check for 3 words ) If $Split[0] = 3 Then ; Do the upload sequence. UpdateMe($Split[2]) EndIf EndSwitch Case Else ; invalid activation code. GUICtrlSetData($Status, "Invalid activation code.") EndSwitch Else ; Turns all the buttons and edit bars grey ToggleLogin() GUICtrlSetData($Status, "Logging in") ; Tries to connect to the server. Sets @error to 1 if it fails. Connect() If Not @error Then GUICtrlSetData($Status, "Connected, authorizing..") If BitAND(GUICtrlRead($RememberMe), $GUI_CHECKED) Then IniWrite(@ScriptDir & "\config.ini", "Settings", "RememberMe", 1) IniWrite(@ScriptDir & "\config.ini", "Credentials", "UserName", _StringEncrypt(1, GUICtrlRead($Username), "CobraCredentials")) Else IniWrite(@ScriptDir & "\config.ini", "Settings", "RememberMe", 0) IniWrite(@ScriptDir & "\config.ini", "Credentials", "UserName", "DoNotRemember") EndIf If BitAND(GUICtrlRead($RememberPwd), $GUI_CHECKED) Then IniWrite(@ScriptDir & "\config.ini", "Settings", "RememberPwd", 1) IniWrite(@ScriptDir & "\config.ini", "Credentials", "Password", _StringEncrypt(1, GUICtrlRead($Password), _StringEncrypt(1, GUICtrlRead($Username), "CobraCredentials") & "CobraCredentials")) Else IniWrite(@ScriptDir & "\config.ini", "Settings", "RememberPwd", 0) IniWrite(@ScriptDir & "\config.ini", "Credentials", "Password", "DoNotRemember") EndIf ; Send AUT username password version TCPSend($Socket, $AUTHORIZE & " " & GUICtrlRead($Username) & " " & _StringEncrypt(1, GUICtrlRead($Password), GUICtrlRead($Username)) & " " & $MyVersion) ; Get the reply from the server. $Reply = GetReply() Switch StringLeft($Reply,3) Case $ACKNOWLEDGE ExitLoop Case $DENIAL GUICtrlSetData($Status, "Incorrect username or password.") ToggleLogin() Case $DOWNLOAD ; Using a old version! Need to update to the new one. $Split = StringSplit($Reply, " ") ; If command looks like "DNL url version" ( Check for 3 words ) If $Split[0] = 3 Then ; Do the upload sequence. UpdateMe($Split[2]) EndIf Case $ACTIVATE GUICtrlSetPos($RememberMe,214, 188+28) GUICtrlSetPos($RememberPwd,214, 210+28) GUICtrlSetPos($LogIn,224,235+28) GUICtrlSetPos($RegisterButton,304,235+28) $ActivationCodeButton = GUICtrlCreateInput("Activation Code",214,188,200,21) GUICtrlSetData($LogIn,"Activate") GUICtrlSetState($Login,$GUI_ENABLE) Case $DOWNLOAD GUICtrlSetData($Status, "Update to v0.3.3 !!") Case Else GUICtrlSetData($Status, "##Internal Error##") Sleep(2000) Exit EndSwitch EndIf EndIf EndIf Case $RegisterButton If Valid($Username) And Valid($Password) Then ToggleLogin() GUICtrlSetData($Status, "Trying to connect..") Connect() GUICtrlSetData($Status, "Connected, registering..") TCPSend($Socket, $REGISTER & " " & GUICtrlRead($Username) & " " & _StringEncrypt(1, GUICtrlRead($Password), GUICtrlRead($Username)) & " " & $MyVersion) $Reply = GetReply() If $Reply = $ACKNOWLEDGE Then GUICtrlSetData($Status, "Validation e-mail has been sent.") ElseIf $Reply = $DENIAL Then GUICtrlSetData($Status, "Username already taken.") Else GUICtrlSetData($Status, "##Internal Error##") Sleep(2000) Exit EndIf ToggleLogin() EndIf EndSwitch WEnd $Username = GUICtrlRead($Username) GUIDelete() #endregion Log in procedure ; ------------------------- ; User is now succesfully logged in ; --------------------------------- ; --------------------------------- TrayItemSetState($IM, $TRAY_ENABLE) ; Variable declaration ; -------------------- $MaxChildWindow = 10 Dim $ChildWindow[$MaxChildWindow], $ChildSendText[$MaxChildWindow], $ChildSendButton[$MaxChildWindow], $ChildShowText[$MaxChildWindow], $ChildConversation[$MaxChildWindow] Dim $ChildFileMenu[$MaxChildWindow], $ChildLogOff[$MaxChildWindow], $ChildClose[$MaxChildWindow], $ChildToolsMenu[$MaxChildWindow], $ChildInsertSmiley[$MaxChildWindow], $SmileyWindow[$MaxChildWindow] Dim $SmileyWindowInsert[$MaxChildWindow][23], $SmileyWindowLabel[$MaxChildWindow][23], $ChildPreviewButton[$MaxChildWindow], $ChildSaveLog[$MaxChildWindow] Dim $arrSmileys[23][2] = [[":dry:", "dry"], [":D", "biggrin"], [":o", "ohmy"], [":(", "sad"], [":P", "tongue"], [":blink:", "blink"], [":$", "blush"], ["(H)", "cool"], [":)", "smile"], [":'(", "crying*18*18"], [":A", "happy"], ["(A)", "innocent*18*22"], [":king:", "king*23*25"], [":lol:", "laugh"], [":lmao:", "lmao"], [">.<", "pinch*18*18"], [":rolleyes:", "rolleyes"], [":shifty:", "shifty"], ["+o(", "sick*18*18"], [":Z", "sleep*18*26"], [":unsure:", "unsure"], [":?", "wacko"], [";)", "wink"]] Opt("GUIResizeMode", $GUI_DOCKAUTO) ; resize and reposition ; GUI Creation ; ----------- $GUI = GUICreate($AppTitle, 240, 400, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX)) GUISetFont(10, 400, 0, "Verdana") ; GUI Menu Creation ; ----------------- $File = GUICtrlCreateMenu("&File") $LogOff = GUICtrlCreateMenuitem("Log Off", $File) GUICtrlCreateMenuitem("", $File) $Exit = GUICtrlCreateMenuitem("Exit", $File) $ContactsMenu = GUICtrlCreateMenu("&Contacts") $AddContact = GUICtrlCreateMenuitem("Add a contact", $ContactsMenu) $DelContact = GUICtrlCreateMenuitem("Delete a contact", $ContactsMenu) GUICtrlCreateMenuitem("", $ContactsMenu) $Import = GUICtrlCreateMenuitem("Import contacts from file", $ContactsMenu) $Export = GUICtrlCreateMenuitem("Export contacts to file", $ContactsMenu) $Tree = GUICtrlCreateTreeView(0, 0, 240, 400) $Online = GUICtrlCreateTreeViewItem("Online", $Tree) $Offline = GUICtrlCreateTreeViewItem("Offline", $Tree) GetUsers() DisplayUser() $Time = TimerInit() GUISetState() HotKeySet("{ENTER}", "Enter") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE $Handle = WinGetHandle("") If $Handle = $GUI Then WinSetState($GUI, "", @SW_HIDE) Else For $y = 0 To $MaxChildWindow - 1 If $Handle = $ChildWindow[$y] Then GUIDelete($Handle) $ChildWindow[$y] = "" $ChildConversation[$y] = "" EndIf Next For $y = 0 To $MaxChildWindow - 1 If $Handle = $SmileyWindow[$y] Then GUIDelete($Handle) $SmileyWindow[$y] = "" EndIf Next EndIf Case $GUI_EVENT_MINIMIZE $Handle = WinGetHandle("") If $Handle = $GUI Then WinSetState($GUI, "", @SW_MINIMIZE) Else For $y = 0 To $MaxChildWindow - 1 If $Handle = $ChildWindow[$y] Then WinSetState($Handle, "", @SW_MINIMIZE) EndIf Next EndIf Case $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESTORE Switch $nMsg Case $GUI_EVENT_MAXIMIZE $s = @SW_MAXIMIZE Case $GUI_EVENT_RESTORE $s = @SW_RESTORE EndSwitch $Handle = WinGetHandle("") If $Handle = $GUI Then WinSetState($GUI, "", $s) Else For $y = 0 To $MaxChildWindow - 1 If $Handle = $ChildWindow[$y] Then WinSetState($Handle, "", $s) EndIf Next EndIf Case $Exit TCPSend($Socket, $LOGOUT) Exit Case $LogOff TCPSend($Socket, $LOGOUT) TCPCloseSocket($Socket) $Socket = -1 ExitLoop Case $AddContact AddUser(InputBox($AppTitle, "What is the username of the user you want to add?")) DisplayUser() Case $DelContact DelUser(GUICtrlRead(GUICtrlRead($Tree), 1)) Case $Export $File = FileSaveDialog("Save contacts", @UserProfileDir, "Contacts (*.tt)", 18, $Username & ".tt") FileDelete($File) If Not @error Then For $z = 1 To UBound($MyContacts) - 1 If $MyContacts[$z][0] <> "" Then FileWrite($File, $MyContacts[$z][0] & " ") EndIf Next EndIf Case $Import $File = FileOpenDialog("Add contacts from a file", @UserProfileDir, "Contacts (*.tt)|All files (*.*)", 3, $Username & ".tt") If Not @error Then $Corrupted = 0 $Read = FileRead($File) $Split = StringSplit($Read, " ") For $x = 1 To $Split[0] If Valid($Split[$x]) Then AddUser($Split[$x]) Else If $Corrupted = 0 Then If MsgBox(52, $AppTitle, "The file is corrupted, so you want to abort loading?") == 6 Then ExitLoop EndIf $Corrupted = 1 EndIf EndIf Next EndIf Case $SelectOkButton $sUsername = GUICtrlRead($SelectList) If Not ConversationExists($sUsername) Then StartConversation($sUsername) EndIf GUIDelete($SelectGUI) $SelectGUI = "" Case $SelectCancelButton GUIDelete($SelectGUI) $SelectGUI = "" Case Else If $nMsg > 0 Then For $q = 0 To $MaxChildWindow - 1 Switch $nMsg Case $ChildSendButton[$q] SendConversation($q, GUICtrlRead($ChildSendText[$q])) Case $ChildPreviewButton[$q] SendConversation($q, "/pre" & GUICtrlRead($ChildSendText[$q])) Case $ChildLogOff[$q] TCPSend($Socket, $LOGOUT) TCPCloseSocket($Socket) $Socket = -1 ExitLoop 2 Case $ChildClose[$q] GUIDelete($ChildWindow[$q]) $ChildWindow[$q] = "" $ChildConversation[$q] = "" Case $ChildInsertSmiley[$q] $SmileyWindow[$q] = GUICreate("Insert Smileys", 200, 260, -1, -1, $GUI_SS_DEFAULT_GUI, 0, $ChildWindow[$q]) GUISetBkColor(0xffffff) $smileyDir = @ScriptDir & "\Smiley\" $y = 10 For $i = 0 To 11 $smileyName = $arrSmileys[$i][1] $smileySplit = StringSplit($smileyName, "*") If $smileySplit[0] = 1 Then GUICtrlCreatePic($smileyDir & $smileySplit[1] & ".gif", 10, $y, 20, 20) ElseIf $smileySplit[0] = 3 Then GUICtrlCreatePic($smileyDir & $smileySplit[1] & ".gif", 10, $y, $smileySplit[2], $smileySplit[3]) If $smileySplit[3] > 20 Then $y += $smileySplit[3] - 20 EndIf EndIf $SmileyWindowLabel[$q][$i] = GUICtrlCreateLabel($arrSmileys[$i][0], 35, $y + 3) $SmileyWindowInsert[$q][$i] = GUICtrlCreateButton("+", 70, $y, 20, 20) $y += 20 Next $y = 10 For $i = 12 To 22 $smileyName = $arrSmileys[$i][1] $smileySplit = StringSplit($smileyName, "*") If $smileySplit[0] = 1 Then GUICtrlCreatePic($smileyDir & $smileySplit[1] & ".gif", 100, $y, 20, 20) ElseIf $smileySplit[0] = 3 Then GUICtrlCreatePic($smileyDir & $smileySplit[1] & ".gif", 100, $y, $smileySplit[2], $smileySplit[3]) If $smileySplit[3] > 20 Then $y += $smileySplit[3] - 20 EndIf EndIf $SmileyWindowLabel[$q][$i] = GUICtrlCreateLabel($arrSmileys[$i][0], 125, $y + 3) $SmileyWindowInsert[$q][$i] = GUICtrlCreateButton("+", 170, $y, 20, 20) $y += 20 Next GUISetState() Case $ChildSaveLog[$q] $File = FileSaveDialog("Save Chat Log", @MyDocumentsDir, "HTML Document (*.html;*.htm)", 18, $ChildConversation[$q] & " Chat Log.html") If FileExists($File) Then FileDelete($File) ;clear previous contents FileWrite($File, _IEBodyReadHTML($ChildShowText[$q])) Case Else For $i = 0 To 22 If $nMsg = $SmileyWindowInsert[$q][$i] Then $sel = _GUICtrlEditGetSel($ChildSendText[$q]) $oldtxt = GUICtrlRead($ChildSendText[$q]) _GUICtrlEditReplaceSel($ChildSendText[$q], True, GUICtrlRead($SmileyWindowLabel[$q][$i])) EndIf Next EndSwitch Next For $q = 1 To UBound($MyContacts) - 1 If $nMsg = $MyContacts[$q][3] Then If Not ConversationExists($MyContacts[$q][0]) Then StartConversation($MyContacts[$q][0]) EndIf ExitLoop EndIf Next EndIf EndSwitch $Data = TCPRecv($Socket, 1024) If @error Then $Socket = -1 $GUIState = "You were disconnected by the server." ExitLoop EndIf ; What to do with received data!!!!!!!! ; ------------------------------------- If $Data Then Switch StringLeft($Data, 3) Case $MESSAGE $Split = StringSplit($Data, " ") If $Split[2] = "Server" Then $sText = "" For $x = 2 To $Split[0] $sText &= $Split[$x] & " " Next ToolTip($sText, 0,0, "Cobra Server Message") Else ; $Split[1] = "MSG" ; eg command ; $Split[2] = The username of the guy who sent you this ; $Split[3] = the 'type' of data that is being sent. ; $Split[4] = parameters for the type (likely the text) $sUsername = $Split[2] $sType = $Split[3] $sText = "" Switch $sType Case "text" If StringRight($Split[$Split[0]], 3) = "ACK" Then $Split[$Split[0]] = StringTrimRight($Split[$Split[0]], 3) EndIf For $x = 4 To $Split[0] $sText &= $Split[$x] & " " Next $sText = "<i>" & $sUsername & ' says:</i><br><table width="95%" border="0" align="center"><tr><td><font face="Verdana" size=-1>' & FormatChat($sText) & "</td></tr></table>" If $Afk Then TCPSend($Socket, $MESSAGE & " " & $sUsername & " Auto " & $AutoMessage) $sText &= "<br>" & "Automessage: " & $AutoMessage EndIf Case "auto" For $x = 4 To $Split[0] $sText &= $Split[$x] & " " Next $sText = "Automessage: " & FormatChat($sText) & "<br>" Case "me" For $x = 4 To $Split[0] $sText &= $Split[$x] & " " Next $sText = "<font color=""#c000c0"">" & $sUsername & " " & FormatChat($sText) & "</font><br>" EndSwitch $sText = '<font face="Verdana" size=-1>' & StringReplace($sText, "::ScriptDir::", @ScriptDir) For $r = 0 To $MaxChildWindow - 1 If $ChildConversation[$r] = $sUsername Then $Read = _IEBodyReadHTML($ChildShowText[$r]) If $Read == 0 Then $Read = "" EndIf _IEBodyWriteHTML($ChildShowText[$r], $Read & $sText) $iDocHeight = $ChildShowText[$r].document.body.scrollHeight $ChildShowText[$r].document.parentwindow.scrollTo (0, $iDocHeight) If Not WinActive($ChildWindow[$r]) Then WinFlash($ChildWindow[$r], "", 2, 250) EndIf ExitLoop ElseIf $r = $MaxChildWindow - 1 Then StartConversation($sUsername) $q = @extended _IEBodyWriteHTML($ChildShowText[$q], $sText & "<br>") If Not WinActive($ChildWindow[$q]) Then WinFlash($ChildWindow[$q], "", 2, 250) EndIf EndIf Next EndIf Case $LOGOUT TCPCloseSocket($Socket) $Socket = -1 $GUIState = "You are logged in at a different location." ExitLoop EndSwitch EndIf If TimerDiff($Time) > 3000 Then DisplayUser() $Time = TimerInit() EndIf WEnd HotKeySet("{ENTER}") TrayItemSetState($IM, "") GUIDelete($GUI) For $y = 0 To $MaxChildWindow - 1 If $ChildWindow[$y] <> "" Then GUIDelete($ChildWindow[$y]) $ChildWindow[$y] = "" $ChildConversation[$y] = "" EndIf Next WEnd #region functions Func UserOnline($sUsername) EndFunc ;==>UserOnline Func StartConversation($sUsername) For $y = 0 To $MaxChildWindow - 1 If $ChildWindow[$y] = "" Then ExitLoop ElseIf $y = $MaxChildWindow - 1 Then Return EndIf Next $ChildWindow[$y] = GUICreate($sUsername & " - Conversation", 528, 420, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_MAXIMIZEBOX)) $ChildConversation[$y] = $sUsername GUISetFont(10, 400, 0, "Verdana") $ChildSendText[$y] = GUICtrlCreateEdit("", 5, 338, 420, 55, $ES_WANTRETURN) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT) $ChildShowText[$y] = _IECreateEmbedded() GUICtrlCreateObj($ChildShowText[$y], 5, 5, 520, 329) GUICtrlSetResizing(-1, $GUI_DOCKBORDERS) _IENavigate($ChildShowText[$y], "about:blank") $ChildSendButton[$y] = GUICtrlCreateButton("Send", 430, 338, 95, 30, 0) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKBOTTOM) $ChildPreviewButton[$y] = GUICtrlCreateButton("Preview", 430, 373, 95, 20, 0) GUICtrlSetResizing(-1, $GUI_DOCKSIZE + $GUI_DOCKBOTTOM) GUICtrlSetBkColor(-1, 0xFFFFFF) $ChildFileMenu[$y] = GUICtrlCreateMenu("&File") $ChildLogOff[$y] = GUICtrlCreateMenuitem("Log Off", $ChildFileMenu[$y]) GUICtrlCreateMenuitem("", $ChildFileMenu[$y]) $ChildClose[$y] = GUICtrlCreateMenuitem("Close", $ChildFileMenu[$y]) $ChildToolsMenu[$y] = GUICtrlCreateMenu("&Tools") $ChildInsertSmiley[$y] = GUICtrlCreateMenuitem("Insert Smileys", $ChildToolsMenu[$y]) $ChildSaveLog[$y] = GUICtrlCreateMenuitem("Save Chat Log", $ChildToolsMenu[$y]) GUISetState() GUICtrlSetState($ChildSendText[$y], $GUI_FOCUS) SetExtended($y) EndFunc ;==>StartConversation Func SendConversation($y, $text, $empty = 0) $Read = _IEBodyReadHTML($ChildShowText[$y]) If $Read == 0 Then $Read = "<font face=""Verdana"" size=-1>" Else $Read &= "<font face=""Verdana"" size=-1>" EndIf Switch StringLeft($text, 4) Case "/afk" If $text = "/afk" Then $Afk = 0 GUICtrlSetData($ChildSendText[$y], "") _IEBodyWriteHTML($ChildShowText[$y], $Read & "Automessage Off.<br>") $iDocHeight = $ChildShowText[$y].document.body.scrollHeight $ChildShowText[$y].document.parentwindow.scrollTo (0, $iDocHeight) Else $Afk = 1 $AutoMessage = StringTrimLeft($text, 5) GUICtrlSetData($ChildSendText[$y], "") $AutoMessage = FormatChat($AutoMessage) $AutoMessage = StringReplace($AutoMessage, "::ScriptDir::", @ScriptDir, 0, 1) _IEBodyWriteHTML($ChildShowText[$y], $Read & "Automessage Set: " & $AutoMessage & "<br>") $iDocHeight = $ChildShowText[$y].document.body.scrollHeight $ChildShowText[$y].document.parentwindow.scrollTo (0, $iDocHeight) EndIf Case "/me " $text = StringTrimLeft($text, 4) TCPSend($Socket, $MESSAGE & " " & $ChildConversation[$y] & " Me " & $text) GUICtrlSetData($ChildSendText[$y], "") $text = FormatChat($text) $text = StringReplace($text, "::ScriptDir::", @ScriptDir, 0, 1) _IEBodyWriteHTML($ChildShowText[$y], $Read & '<font color="#c000c0">' & $Username & " " & $text & "</font><br>") $iDocHeight = $ChildShowText[$y].document.body.scrollHeight $ChildShowText[$y].document.parentwindow.scrollTo (0, $iDocHeight) Case "/pre" If $text Then $text = StringTrimLeft($text, 4) If $text = "" Then Return $text = FormatChat($text) $text = StringReplace($text, "::ScriptDir::", @ScriptDir, 0, 1) _IEBodyWriteHTML($ChildShowText[$y], $Read & "<i><font color=#c000c0>Preview:</font></i>" & "<br><table width=""95%"" border=""0"" align=""center""><tr><td><font face=""Verdana"" size=-1>" & $text & "</td></tr></table>") $iDocHeight = $ChildShowText[$y].document.body.scrollHeight $ChildShowText[$y].document.parentwindow.scrollTo (0, $iDocHeight) EndIf Case Else If $text Then TCPSend($Socket, $MESSAGE & " " & $ChildConversation[$y] & " Text " & _UnicodeStringConvert($text)) If $empty = 0 Then GUICtrlSetData($ChildSendText[$y], "") EndIf $text = FormatChat($text) $text = StringReplace($text, "::ScriptDir::", @ScriptDir, 0, 1) _IEBodyWriteHTML($ChildShowText[$y], $Read & "<i>" & $Username & " says:</i>" & "<br><table width=""95%"" border=""0"" align=""center""><tr><td><font face=""Verdana"" size=-1>" & $text & "</td></tr></table>") $iDocHeight = $ChildShowText[$y].document.body.scrollHeight $ChildShowText[$y].document.parentwindow.scrollTo (0, $iDocHeight) EndIf EndSwitch EndFunc ;==>SendConversation Func ConversationExists($sUsername) Switch $sUsername Case "Online", "Offline", $Username Return 0 EndSwitch For $r = 0 To $MaxChildWindow - 1 If $ChildConversation[$r] = $sUsername Then SetExtended($r) Return 1 EndIf Next Return 0 EndFunc ;==>ConversationExists Func UpdateMe($File) MsgBox(0, "Placebo", "Client is updating, downloading " & $File & @CRLF & @CRLF & "Auto-Update is Unfunctional!") EndFunc Func OnAutoItExit() If $Socket <> -1 Then TCPSend($Socket, $LOGOUT) EndIf TCPShutdown() EndFunc ;==>OnAutoItExit Func ToggleLogin() If $State = $GUI_DISABLE Then $State = $GUI_ENABLE Else $State = $GUI_DISABLE EndIf GUICtrlSetState($LogIn, $State) GUICtrlSetState($RegisterButton,$State) GUICtrlSetState($Username, $State) GUICtrlSetState($Password, $State) GUICtrlSetState($RememberMe, $State) GUICtrlSetState($RememberPwd, $State) EndFunc ;==>ToggleLogin Func ToggleConversation($sUsername, $n) For $y = 0 To $MaxChildWindow - 1 If $ChildConversation[$y] = $sUsername Then ExitLoop ElseIf $y = $MaxChildWindow - 1 Then Return EndIf Next If $n = 0 Then $s = $GUI_DISABLE GUICtrlSetData($ChildSendText[$y], $sUsername & " is offline.") Else $s = $GUI_ENABLE GUICtrlSetData($ChildSendText[$y], "") EndIf GUICtrlSetState($ChildSendText[$y], $s) GUICtrlSetState($ChildPreviewButton[$y], $s) GUICtrlSetState($ChildInsertSmiley[$y], $s) GUICtrlSetState($ChildSendButton[$y], $s) EndFunc ;==>ToggleConversation Func Enter() If WinGetHandle("") = $GUI Then $ID = GUICtrlRead($Tree) Switch $ID Case $Online, $Offline Return Case Else $sUsername = GUICtrlRead($ID, 1) If ConversationExists($sUsername) Then $q = @extended GUISetState(@SW_SHOW, $ChildWindow[$q]) Else For $x = 0 To UBound($MyContacts) - 1 If $sUsername = $MyContacts[$x][0] Then If $MyContacts[$x][1] = $ACKNOWLEDGE Then StartConversation($sUsername) EndIf ExitLoop EndIf Next EndIf EndSwitch Else $ActiveWindow = WinGetHandle("") For $r = 0 To $MaxChildWindow - 1 If $ChildWindow[$r] == $ActiveWindow Then SendConversation($r, GUICtrlRead($ChildSendText[$r])) ExitLoop ElseIf $r = $MaxChildWindow - 1 Then HotKeySet("{ENTER}") Send("{ENTER}") HotKeySet("{ENTER}", "Enter") EndIf Next EndIf EndFunc ;==>Enter Func FormatChat($sText) $sText = StringReplace($sText, "<", "<") ;no user tags $sText = StringReplace($sText, ">", ">") $smileyDir = "::ScriptDir::\Smiley\" For $i = 0 To UBound($arrSmileys, 1) - 1 $smileyName = StringSplit($arrSmileys[$i][1], "*") $sTemp = StringReplace($arrSmileys[$i][0], "<", "<") $sTemp = StringReplace($sTemp, ">", ">") $sText = StringReplace($sText, $sTemp, '<img src="' & $smileyDir & $smileyName[1] & '.gif">') Next $sText = StringReplace($sText, @CRLF, "<br>") $sText = StringRegExpReplace($sText, "\[i\](.+)\[/i\]", "<i>\1</i>") $sText = StringRegExpReplace($sText, "\[b\](.+)\[/b\]", "<b>\1</b>") $sText = StringRegExpReplace($sText, "\[u\](.+)\[/u\]", "<u>\1</u>") $sText = StringRegExpReplace($sText, "\[s\](.+)\[/s\]", "<s>\1</s>") $sText = StringRegExpReplace($sText, "\[c=(.+?)\](.+?)\[/c\]", '<font color="\1">\2</font>') $sText = StringRegExpReplace($sText, "\[l=(.+?)\](.+?)\[/l\]", '<a target="_blank" href="\1">\2</a>') $sText = StringRegExpReplace($sText, "\[m\](.+)\[/m\]", "<marquee width=100% height=30>\1</marquee>") ;lets parse gradient text :D While 1 If StringRegExp($sText, "\[c=#[0-9a-fA-F]{6}\](.+)\[/c=#[0-9a-fA-F]{6}\]", 0) Then Local $asText = StringSplit($sText, "") Local $iPos = StringInStr($sText, "[c=#") $iPos += 4 ;beginning of six digit hex colour Local $iStartColor = "0x", $sGradientText = "", $asGradientText = "" Local $aGradient = "", $iEndColor = "0x", $skip = False, $sFormatted = "" Local $iRed, $iGreen, $iBlue If $asText[$iPos + 6] = "]" Then For $i = $iPos To $iPos + 5 $iStartColor &= $asText[$i] Next $iPos = $i + 1 ;skip ] While Not __ArrayCharMatch($asText, $iPos, "[/c=#") If @error Then $skip = True ExitLoop EndIf $sGradientText &= $asText[$iPos] $iPos += 1 WEnd $asGradientText = StringSplit($sGradientText, "") If $asText[$iPos + 4] = "#" And $asText[$iPos + 11] = "]" And $skip = False Then $iPos += 5 For $i = $iPos To $iPos + 5 $iEndColor &= $asText[$i] Next $aGradient = __ColorGradient($iStartColor, $iEndColor, $asGradientText[0]) For $i = 1 To $asGradientText[0] $iRed = Hex(_ColorGetRed($aGradient[$i - 1]), 2) $iGreen = Hex(_ColorGetGreen($aGradient[$i - 1]), 2) $iBlue = Hex(_ColorGetBlue($aGradient[$i - 1]), 2) $aGradient[$i - 1] = $iRed & $iGreen & $iBlue $sFormatted &= '<font color="' & $aGradient[$i - 1] & '">' & $asGradientText[$i] & '</font>' Next $sText = StringReplace($sText, "[c=#" & StringTrimLeft($iStartColor, 2) & "]" & $sGradientText & "[/c=#" & StringTrimLeft($iEndColor, 2) & "]", $sFormatted, 1) EndIf EndIf Else ExitLoop EndIf WEnd Return $sText EndFunc ;==>FormatChat Func __ArrayCharMatch($avArray, $iCounter, $svMatch) Local $sText For $i = $iCounter To $iCounter + StringLen($svMatch) - 1 If $i >= UBound($avArray)-1 Then Return SetError(1, 0, 0) $sText &= $avArray[$i] Next If $sText = $svMatch Then Return 1 EndFunc ;==>__ArrayCharMatch ;CoePSX - Thanks! Func __ColorGradient($hInitialColor, $hFinalColor, $iReturnSize) $hInitialColor = Hex($hInitialColor, 6) $hFinalColor = Hex($hFinalColor, 6) Local $iRed1 = Dec(StringLeft($hInitialColor, 2)) Local $iGreen1 = Dec(StringMid($hInitialColor, 3, 2)) Local $iBlue1 = Dec(StringMid($hInitialColor, 5, 2)) Local $iRed2 = Dec(StringLeft($hFinalColor, 2)) Local $iGreen2 = Dec(StringMid($hFinalColor, 3, 2)) Local $iBlue2 = Dec(StringMid($hFinalColor, 5, 2)) Local $iPlusRed = ($iRed2 - $iRed1) / ($iReturnSize - 1) Local $iPlusBlue = ($iBlue2 - $iBlue1) / ($iReturnSize - 1) Local $iPlusGreen = ($iGreen2 - $iGreen1) / ($iReturnSize - 1) Dim $iColorArray[$iReturnSize] For $i = 0 To $iReturnSize - 1 $iNowRed = Floor($iRed1 + ($iPlusRed * $i)) $iNowBlue = Floor($iBlue1 + ($iPlusBlue * $i)) $iNowGreen = Floor($iGreen1 + ($iPlusGreen * $i)) $iColorArray[$i] = Dec(Hex($iNowRed, 2) & Hex($iNowGreen, 2) & Hex($iNowBlue, 2)) Next Return $iColorArray EndFunc ;==>__ColorGradient Func GetUsers() TCPSend($Socket, $GETLIST) $Read = GetReply() $Split = StringSplit($Read, " ") ; $MyContacts[n][0] = ; $MyContacts[n][1] = ; $MyContacts[n][2] = ; $MyContacts[n][3] = ; $MyContacts[n][4] = Dim $MyContacts[$Split[0] + 1][5] For $x = 2 To $Split[0] If $Split[$x] <> "" Then $MyContacts[$x][0] = $Split[$x] EndIf Next EndFunc ;==>GetUsers Func AddUser($sUsername) TCPSend($Socket, $ADDUSER & " " & $sUsername) If GetReply() = $ACKNOWLEDGE Then If $sUsername <> "" Then $x = UBound($MyContacts, 1) + 1 ReDim $MyContacts[$x][5] $MyContacts[$x - 1][0] = $sUsername $MyContacts[$x - 1][1] = "" $MyContacts[$x - 1][2] = "" EndIf EndIf EndFunc ;==>AddUser Func DelUser($sUsername) TCPSend($Socket, $DELUSER & " " & $sUsername) For $x = 1 To UBound($MyContacts) - 1 If $MyContacts[$x][0] == $sUsername Then GUICtrlDelete($MyContacts[$x][2]) $MyContacts[$x][0] = "" $MyContacts[$x][1] = "" $MyContacts[$x][2] = "" EndIf Next EndFunc ;==>DelUser Func DisplayUser() Local $temp = $MyContacts $Selected = GUICtrlRead($Tree) For $z = 1 To UBound($MyContacts) - 1 If $MyContacts[$z][0] <> "" Then TCPSend($Socket, $GETSTATE & " " & $MyContacts[$z][0]) $Reply = GetReply() $MyContacts[$z][1] = StringLeft($Reply,3) $MyContacts[$z][4] = StringTrimLeft($Reply,4) EndIf Next For $z = 1 To UBound($temp) - 1 If ($temp[$z][1] <> $MyContacts[$z][1]) OR ($temp[$z][4] <> $MyContacts[$z][4]) Then If $MyContacts[$z][0] Then If $MyContacts[$z][2] Then GUICtrlDelete($MyContacts[$z][2]) If $MyContacts[$z][1] = $ACKNOWLEDGE Then UserOnline($MyContacts[$z][0]) EndIf EndIf Switch $MyContacts[$z][1] Case $ACKNOWLEDGE $MyContacts[$z][2] = GUICtrlCreateTreeViewItem($MyContacts[$z][4], $Online) $temp2 = GUICtrlCreateContextMenu($MyContacts[$z][2]) $MyContacts[$z][3] = GUICtrlCreateMenuitem("Send an instant message to " & $MyContacts[$z][0], $temp2) GUICtrlSetState(-1, $GUI_DEFBUTTON) ToggleConversation($MyContacts[$z][0], 1) Case $DENIAL $MyContacts[$z][2] = GUICtrlCreateTreeViewItem($MyContacts[$z][4], $Offline) $temp2 = GUICtrlCreateContextMenu($MyContacts[$z][2]) $MyContacts[$z][3] = GUICtrlCreateMenuitem("Email " & $MyContacts[$z][0], $temp2) GUICtrlSetState(-1,$GUI_DISABLE) ToggleConversation($MyContacts[$z][0], 0) EndSwitch EndIf EndIf Next If WinActive($GUI) Then GUICtrlSetState($Selected, $GUI_FOCUS) EndIf GUICtrlSetState($Online, $GUI_EXPAND) GUICtrlSetState($Offline, $GUI_EXPAND) EndFunc ;==>DisplayUser Func Valid($ID) Return 1 ;StringRegExp bullshit for use in the future. Smoke_N gave me this, and I'm having troubles understanding it. :[ If StringRegExp(GUICtrlRead($ID), "^([\w|\d]{3,8})$") Then Return 1 Else Return 1 EndIf EndFunc ;==>Valid Func Connect() If $Socket = -1 Then For $x = 0 To 7 $Socket = TCPConnect($IP, 799) If $Socket <> -1 Then ExitLoop ElseIf $x = 7 Then GUICtrlSetData($Status, "Unable to connect.") ToggleLogin() SetError(1) Return EndIf Sleep(500) Next EndIf EndFunc ;==>Connect Func GetReply() While 1 $Data = TCPRecv($Socket, 512) If @error Then $Socket = -1 Return ElseIf $Data <> "" Then Return $Data EndIf Sleep(50) WEnd EndFunc ;==>GetReply ; Tray functions ; -------------- Func InstantMessage() If $SelectGUI = "" Then $SelectGUI = GUICreate("Conversation", 200, 300) GUISetFont(10, 400, 0, "Verdana") $SelectList = GUICtrlCreateList("", 2, 2, 196, 290) $SelectOkButton = GUICtrlCreateButton("Ok", 44, 269, 75) $SelectCancelButton = GUICtrlCreateButton("Cancel", 124, 269, 75) For $x = 0 To UBound($MyContacts) - 1 If $MyContacts[$x][1] = $ACKNOWLEDGE Then GUICtrlSetData($SelectList, $MyContacts[$x][0]) EndIf Next GUISetState(@SW_SHOW) EndIf EndFunc ;==>InstantMessage Func Terminate() Exit EndFunc ;==>Terminate Func ActivateMainWindow() WinSetState($GUI, "", @SW_SHOW) WinActivate($GUI) EndFunc ;==>ActivateMainWindow Func StartHomepage() Run(@ComSpec & " /c start http://cobramessenger.co.nr/", "", @SW_HIDE) EndFunc ;==>StartHomepage Func _UnicodeStringConvert($UnicodeString) $UnicodeStringLength = StringLen($UnicodeString) Local $Unicode_Code For $i = 1 To $UnicodeStringLength $UnicodeStringChar = StringMid($UnicodeString, $i, 1) If StringInStr(" $-_.+!*'(),;/?:@=&abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", $UnicodeStringChar) Then $Unicode_Code &= $UnicodeStringChar Else $Unicode_Code &= '&#' & AscW ($UnicodeStringChar) & ';' EndIf Next Return $Unicode_Code EndFunc ;==>_UnicodeStringConvert #endregion Edit: + Rating 5/5 Edited March 21, 2018 by Melba23 Use name removed by request [u]My Projects[/u]:General:WinShell (Version 1.6)YouTube Video Downloader Core (Version 2.0)Periodic Table Of Chemical Elements (Version 1.0)Web-Based:Directory Listing Script Written In AutoIt3 (Version 1.9 RC1)UDFs:UnicodeURL UDFHTML Entity UDF[u]My Website:[/u]http://dhilip89.hopto.org/[u]Closed Sources:[/u]YouTube Video Downloader (Version 1.3)[quote]If 1 + 1 = 10, then 1 + 1 ≠2[/quote] Link to comment Share on other sites More sharing options...
RazerM Posted June 10, 2007 Share Posted June 10, 2007 Thanks a lot, this will definetely be considered in next Version. My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop. 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