Jump to content

Dellairion

Active Members
  • Posts

    101
  • Joined

  • Last visited

Dellairion's Achievements

Adventurer

Adventurer (3/7)

0

Reputation

  1. Thanks for the reply. I really thought the whole thing was pausing. Grtz, Dellairion
  2. Hello, I'm trying to update my tcp/udp packet forwarder (this time with a user friendly gui). Is it possible to force the script to keep running while the window is getting moved? I don't want the whole process to pause while the user is just moving the gui. I thought that i have seen a solution somewhere on this forum to this, i'm just unable to find it... Thnx, Dellairion
  3. *Updated first post. The app is still very basic but it should work now.
  4. Well the problem is that i have never used IIS 5 and i dont have xp but vista installed on my pc. My IIS is running on a seprate computer with windows server 2003 on it. Also what i did with IIS 6.0 that runs on my server was pure setting some options and testing because i have never used IIS myself before. But i'll see what i can do.
  5. This is my solution to fix the post that isn't working. Maybe a little bit amateuristic but it works. First of all: Open the 'AuCGI.au3' Look for the line with this code: $source = " ?><?au3 #include <Web.au3>"&@CRLF&"Global $AuCGI_version = '"&$version&"'"&" ?>"&$source&"<?au3 "oÝ÷ Ø(Z¢¶ÚºÚ"µÍÌÍÜÛÝÙHH ][ÝÈÉÝÉÏØ]LÈ ÌÍÔÔÕÑUHH ÌÎNÉ][ÝÉ[ÐÛÛÛÛTXY I[É][ÝÉÌÎNÉ][ÝÉ[ÐÔ[É][ÝÈÚ[ÛYH ÕÙX]LÉÝÉ][ÝÉ[ÐÔ[É][ÝÑÛØ[ ÌÍÐ]PÑÒWÝÚ[ÛH ÌÎNÉ][ÝÉ[ÉÌÍÝÚ[Û[É][ÝÉÌÎNÈÉÝÉ][ÝÉ[ÉÌÍÜÛÝÙI[É][ÝÉÏØ]LÈ ][ÝoÝ÷ Ú,³ è"¶aȧ*kzúh²Ûh~,wö,·B¢jbè­6(¥é÷õgjí÷ô(ZºÚ"µÍÛØ[ ÌÍ×ÔÔÕÜ]ÈHÛÛÛÛTXY ÌÍÔÜÝÛÛ[[Ý Now you should be able to get 'post' by '_Post("nameofvartoget")'. Btw, is it just me or is the having problems with viewing and posting on the forums. Everything is slow and sometimes the server returns an internal error. Grz, Dellairion
  6. Hello, Sorry for the late reply i lost it out of sight. Thanks complexjunk for reminding me. This is what i did to get AuCGI to work on IIS 6.0 (should work also on other versions i think). (If you haven't IIS installed yet on your server you can go for details here for IIS 6.0 and here for IIS 7.0.) First of all place your AUCGI somewhere for example 'C:\AuCGI\'. When u have installed IIS, goto 'Control Panel -> Administrative Tools -> Manage Your Server' if it isn't open yet (a window should open with the name Manage Your Server). Then click on 'Manage this application server' which can be found under 'Application Server'. A new window will popup, if you have installed IIS corectly a subdir named 'Internet Information Services (ISS) Manager' will be shown, double click on it, another subdir will be shown click that one open also. (With other words just goto your IIS configuration panel.) Step 1: Now to start right click on '<servername> (local computer)' and then click on 'Properties'. A new windows will popup. Click on 'MIME Types... -> New...'. In the field 'Extension' should come the extension u are going to use for AutoIt web files (example: '.ahp', '.aux' and more). In the field 'MIME type' should be 'text/html' (both without the quotes). Then click 'OK' 3 times (to close all the child windows). Step 2: Now you're back in the 'Application Server' window right click on the subdir 'Web Sites' and then properties. Goto the tab named 'Home Directory' and click on the button 'Configuration...'. Under the tab 'Mappings' in the new window that just popped up, click on the button 'Add...'. In the field 'Executable' should be the path to your AuCGI.exe for example 'C:\AuCGI\AuCGI.exe'. After the path should "%s" be added so the result should be this: C:\AuCGI\AuCGI.exe "%s" In the extension field should be the same extension as used in step 1 ('.ahp', '.aux' or other). In 'Verbs' the option 'All verbs' should be selected and also 'Script engine' should be selected. Now click 'OK' until you are back into the 'Web Sites Properties' window. To add the 'index.<your_extension>' so IIS opens it as standard goto the tab 'Documents'. Click on the 'Add...' button and fill in 'index.<your_extension>' (example: 'index.ahp' or 'index.aux') Click 'OK' until are child windows are closed again. Step 3: Goto the subdir named 'Web Service Extensions' in the 'Application Server' window. Click on the button/link named 'Add a new Web service extension...'. In the field 'Extension name' you can put whatever name you want. Click on the 'Add...' button at the right from the 'Required files' field. In the field 'Path to file' should be exact the same as in step 2 (example: C:\AuCGI\AuCGI.exe "%s"). Click 'Ok'. Now the file is added in 'Required files' click on it and then click on the button 'Allow'. Click 'OK'. You now have added the AuCGI Extension to IIS. I hope you understand this and correct me if i'm wrong or if unclear . Grz, Dellairion
  7. Hi i tryed to create a login form but i'm still unable to get the login data by POST. <?au3 echo(EnvGet("REQUEST_METHOD")&" - "&$_POST_raw&" - "&$PostContentLength) ?> Returns: POST - - 39 I'm using the newest version of Web.au3 include. Note: this piece of code is just a part out of my webpage. nvm i changed it a bit so it works now.
  8. hmms k... ill turn it off Btw, i'm trying to add AuCGI atm So far so good...
  9. Source code updated...
  10. Thnx for reply I will take a look at it gzip = data compression It send the page in hex to the client. Note: Content-Encoding should be gzip when doing that so the client knows what type of compression is used. EDIT: Your script seems to give some errors... C:\Users\Terminator\Desktop\AutoIt 07-08\AutoWEB\webserver.au3(326,32) : ERROR: _ArraySort() called with wrong number of args. _ArraySort($MIMETypes,0,0,0,2,0) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ D:\Program Files\AutoIt3\Include\Array.au3(884,89) : REF: definition of _ArraySort(). Func _ArraySort(ByRef $avArray, $iDescending = 0, $iStart = 0, $iEnd = 0, $iSubItem = 0) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ I'm using AutoIt v3.2.12.1
  11. Hi there, What i'm trying to do is to create a web server (something like apache). Source code has been updated images work now. And now it also supports AuCGI (just tested the basics). Hmms, can someone tell me how cookies and etags work? I'm a noob at those things... Download: http_server0.0.0.8.zip Dellairion
  12. I tryed to create my own web server. so far so so good. (This is still in beta stages, dont expect too much of this) ; AutoK Web Server ; Made by Kris ; Last release @ 16 juli 2008 ; Version 0.0.0.4 ; ; ======= AU3 CONFIG ======= ;#NoTrayIcon #RequireAdmin #include <Array.au3> #Include <Date.au3> ; ======= MAIN VARS ======== $Title = "AutoK Web Server" $Version = "0.0.0.4" $Version_HTTP = "1.1" $Configfile = @ScriptDir&"\config.ini" $Server_IP = IniRead($Configfile, "server", "ip", @IPAddress1) $Server_Port = IniRead($Configfile, "server", "port", 80) $Server_Filetype = IniRead($Configfile, "server", "filetype", ".htm,.html,.aux") $Server_Index = IniRead($Configfile, "server", "index", "index.htm,index.html,index.aux") $Server_Httpdir = IniRead($Configfile, "server", "httpdir", @ScriptDir&"\httpdocs") $Messages_Level = IniRead($Configfile, "messages", "level", 2) ; 1=critical,2+=non-critical,3+=debug,4+=fulldebug $Log_Level = IniRead($Configfile, "log", "level", 5) ; 1=critical,2+=non-critical,3+=connections,4+=pages,5+=debug $Log_Logdir = IniRead($Configfile, "log", "logdir", @ScriptDir&"\logs") $Log_Timestamps = IniRead($Configfile, "log", "timestamps", 1) $Time_GMT = IniRead($Configfile, "time", "gmt", "+1") $Module_List = IniReadSection($Configfile, "module") Global $Client_List[1], $Client_Current = 1 ; ====== CHECK VARS ======= If Not _IsIP($Server_IP) Then $Server_IP = TCPNameToIP($Server_IP) If Not _IsIP($Server_IP) Then If $Messages_Level > 0 Then _Message("Invallid ip specified "&$Server_IP&":"&$Server_Port&"."&@CRLF&"Error code: 0x0100") If $Log_Level > 0 Then _Log("Invallid ip specified "&$Server_IP&":"&$Server_Port&". Error code: 0x0100") Exit EndIf EndIf If Not _IsPort($Server_Port) Then If $Messages_Level > 0 Then _Message("Invallid ip specified "&$Server_IP&":"&$Server_Port&"."&@CRLF&"Error code: 0x0101") If $Log_Level > 0 Then _Log("Invallid ip specified "&$Server_IP&":"&$Server_Port&". Error code: 0x0101") Exit EndIf $Server_Httpdir = _PathFix($Server_Httpdir) $Log_Logdir = _PathFix($Log_Logdir) If $Server_Index = "" Then If $Messages_Level > 1 Then _Message("Warning, no indexes specified.") If $Log_Level > 1 Then _Log("Warning, no indexes specified.") EndIf If $Server_Filetype = "" Then If $Messages_Level > 0 Then _Message("No filetypes specified."&@CRLF&"Error code: 0x0102") If $Log_Level > 0 Then _Log("No filetypes specified. Error code: 0x0102") Exit EndIf If Not IsArray($Module_List) Then Global $Module_List[2][2] Else For $i = 1 To UBound($Module_List)-1 If $Module_List[$i][1] <> "" Then $Module_List[$i][1] = _PathFix($Module_List[$i][1]) Next EndIf ; ====== TCP SERVICE ====== Opt("TCPTimeout", 100) TCPStartup() $Server_Connection = TCPListen($Server_IP, $Server_Port) If @error Then If $Messages_Level > 0 Then _Message("Could not start the server at "&$Server_IP&":"&$Server_Port&"."&@CRLF&"Error code: 0x0103") If $Log_Level > 0 Then _Log("Could not start the server at "&$Server_IP&":"&$Server_Port&". Error code: 0x0103") Exit Else If $Messages_Level > 2 Then _Message("Server started at "&$Server_IP&":"&$Server_Port&".") If $Log_Level > 0 Then _Log("Server started at "&$Server_IP&":"&$Server_Port&".") EndIf ; ======= MAIN LOOP ======= While 1 $Client_New = TCPAccept($Server_Connection) If $Client_New > 0 And $Client_New <> "0" Then _ArrayAdd($Client_List, $Client_New) If $Messages_Level > 3 Then _Message("Client "&SocketToIP($Client_New)&" connected.") If $Log_Level > 2 Then _Log("Client "&SocketToIP($Client_New)&" connected.") EndIf If $Client_Current > UBound($Client_List)-1 Then $Client_Current = 1 EndIf If UBound($Client_List) > 1 Then $Client_Data = TCPRecv($Client_List[$Client_Current], 2048) If @Error Then _ClientDisconnect($Client_Current) ElseIf $Client_Data <> "" Then If $Log_Level > 4 Then _Log("Recieved data from "&SocketToIP($Client_List[$Client_Current])&": "&$Client_Data) _Answer($Client_Current, $Client_Data) EndIf EndIf $Client_Current += 1 WEnd ; ====== FUNCTIONS ======= Func _IsIP($IP) $IP_Test = StringSplit($IP, ".") If $IP_Test[0] = 4 And $IP <> "0.0.0.0" Then If $IP_Test[1] < 256 And $IP_Test[2] < 256 And $IP_Test[3] < 256 And $IP_Test[4] < 256 Then Return 1 EndIf EndFunc Func _IsPort($Port) If $Port > 0 And $Port < 65535 Then Return 1 EndFunc Func _Message($Message) MsgBox(0, $Title&" - Message", $Message) EndFunc Func _Log($Message) $Timestamp = "" If $Log_Timestamps = 1 Then $Timestamp = @YEAR&"-"&@MON&"-"&@MDAY&" "&@HOUR&":"&@MIN&":"&@SEC&" > " If $Log_Level > 4 Then ConsoleWrite($Timestamp&$Message&@CRLF) FileWrite($Log_Logdir&"\"&"Log_"&@YEAR&"-"&@MON&"-"&@MDAY&".log", $Timestamp&$Message&@CRLF) If @error Then If $Messages_Level > 1 Then _Message("Unable to create a log file at "&$Log_Logdir&"."&@CRLF&"Log is now disabled."&@CRLF&"Error code: 0x0200") $Log_Level = 0 EndIf EndIf EndFunc Func _PathFix($Path) $Path = StringReplace($Path, "/", "\") If StringRight($Path, 1) = "\" Then $Path = StringTrimRight($Path, 1) If StringLeft($Path, 1) = "\" Or StringLeft($Path, 1) = ".\" Then $Path = @ScriptDir&"\"&StringTrimLeft($Path, StringInStr($Path, "\")) EndIf Return $Path EndFunc Func _DateCurrent() $WDay = @WDAY If $WDay = 1 Then $Date = "Sun" If $WDay = 2 Then $Date = "Mon" If $WDay = 3 Then $Date = "Tue" If $WDay = 4 Then $Date = "Wed" If $WDay = 5 Then $Date = "Thu" If $WDay = 6 Then $Date = "Fri" If $WDay = 7 Then $Date = "Sat" If $Time_GMT = 0 Then $Time_GMT = "" $Date &= ", "&@MDAY&" "&_DateToMonth(@MON)&" "&@YEAR&" "&@HOUR&":"&@MIN&":"&@SEC&" GMT"&$Time_GMT Return $Date EndFunc Func _FileLastmodified($Filepath) $Date = FileGetTime($Filepath) If Not @error Then Return $Date[0]&"-"&$Date[1]&"-"&$Date[2]&" "&$Date[3]&":"&$Date[4]&":"&$Date[5] EndFunc Func _Answer($Client, $Client_Data) $HeaderMain = StringSplit(_HeaderGet($Client_Data, ""), " ") If $HeaderMain[0] > 1 Then $Filepath = _FileGet($HeaderMain[2]) Else $Filepath = _FileGet("/") EndIf If @error = 1 Then $Server_Data = _PageStatusSet("", 404) If $Log_Level > 4 Then _Log("Sending response to "&SocketToIP($Client_List[$Client])&": "&$Server_Data) TCPSend($Client_List[$Client], $Server_Data) _ClientDisconnect($Client) Return ElseIf @error = 2 Then $Server_Data = _PageStatusSet("", 202) If $Log_Level > 4 Then _Log("Sending response to "&SocketToIP($Client_List[$Client])&": "&$Server_Data) ; Download TCPSend($Client_List[$Client], $Server_Data) _ClientDisconnect($Client) Return EndIf $Source = _SourceGet(_PageStatusSet("", 200), $Filepath) If $Log_Level > 4 Then _Log("Sending response to "&SocketToIP($Client_List[$Client])&": "&$Source) TCPSend($Client_List[$Client], $Source) _ClientDisconnect($Client) EndFunc Func _SourceGet($Data, $Filepath) If $Module_List[1][1] = "" Then $Source = FileRead($Filepath) $Source_Length = StringLen(Binary($Source)) $FileLastmodified = _FileLastmodified($Filepath) $Data = _HeaderSet($Data, "Last-Modified", $FileLastmodified) $Data = _HeaderSet($Data, "Content-Length", $Source_Length) $Data = _HeaderSet($Data, "Etag", StringReplace(StringReplace(StringStripWS($FileLastmodified, 8), "-", ""), ":", "")&$Source_Length) $Data = _HeaderSet($Data, "Source", $Source) Else ; EndIf Return $Data EndFunc Func _FileGet($Filepath) ; Error:1=not_found,2=exists_but_not_valid $Indexes = _IndexGet() $Filetypes = _FiletypeGet() If $Filepath = "" Then $Filepath = "/" EndIf $Filepath = $Server_Httpdir&$Filepath If $Indexes[1] <> "" And StringRight($Filepath, 1) = "/" Then For $i = 1 To $Indexes[0] If FileExists($Filepath&"\"&$Indexes[$i]) Then Return $Filepath&"\"&$Indexes[$i] Next ElseIf StringRight($Filepath, 1) <> "/" Then If FileExists($Filepath) Then For $i = 1 To $Filetypes[0] If StringRight($Filepath, StringLen($Filetypes[$i])) = $Filetypes[$i] Then Return $Filepath EndIf Next SetError(2) Return EndIf EndIf SetError(1) EndFunc Func _ClientDisconnect($Client) $Client_ID = SocketToIP($Client_List[$Client]) If StringLen($Client_ID) < 7 Then $Client_ID = "unknown" If $Messages_Level > 3 Then _Message("Client "&$Client_ID&" disconnected.") If $Log_Level > 2 Then _Log("Client "&$Client_ID&" disconnected.") TCPCloseSocket($Client_List[$Client]) _ArrayDelete($Client_List, $Client) EndFunc Func _HeaderGet($Data, $Header) If $Header = "" Then Return StringLeft($Data, StringInStr($Data, @CRLF, 1)-1) If $Header <> "" Then If $Header = "Source" Then Return StringTrimLeft($Data, StringInStr($Data, @CRLF&@CRLF, 1)) Else $Data2 = StringRegExp($Data, $Header&": (.*)"&@CRLF, 1) If Not @error Then Return $Data2[1] EndIf EndIf EndIf SetError(1) Return "" EndFunc Func _HeaderSet($Data, $Header, $Value, $Overwrite = 1) If $Data = "" And $Header = "" Then Return $Value&@CRLF If $Data <> "" And $Header = "" Then $Line1 = StringLeft($Data, StringInStr($Data, @CRLF)-1) If StringInStr($Line1, ":") Then Return $Value&@CRLF&$Data Else If $Overwrite Then Return $Value&StringTrimLeft($Data, StringInStr($Data, @CRLF)-1) Return $Data EndIf EndIf If $Data = "" And $Header <> "" Then Return $Header&": "&$Value&@CRLF $Data2 = StringSplit($Data, @CRLF&@CRLF, 1) If $Header = "Source" Then If $Overwrite Then Return $Data2[1]&@CRLF&@CRLF&$Value If $Data2[0] < 2 Then Return $Data2[1]&@CRLF&@CRLF&$Value Return $Data ElseIf $Header <> "" Then If StringInStr($Data2[1], $Header) Then If $Overwrite Then $Data2[1] = StringRegExpReplace($Data2[1], $Header&": (.*)"&@CRLF, $Header&": "&$Value&@CRLF) If $Data2[0] > 1 Then Return $Data2[1]&@CRLF&@CRLF&$Data2[2] Return $Data2[1] EndIf Return $Data Else $Data2[1] &= $Header&": "&$Value&@CRLF If $Data2[0] > 1 Then Return $Data2[1]&@CRLF&@CRLF&$Data2[2] Return $Data2[1] EndIf EndIf EndFunc Func _IndexGet() $Indexes = StringSplit(StringStripWS($Server_Index, 8), ",") Return $Indexes EndFunc Func _FiletypeGet() $Filetypes = StringSplit(StringStripWS($Server_Filetype, 8), ",") Return $Filetypes EndFunc Func _PageStatusSet($Data, $Code) Switch $Code Case 200 $Data = _HeaderSet($Data, "", "HTTP/"&$Version_HTTP&" "&$Code&" OK") Case 202 $Data = _HeaderSet($Data, "", "HTTP/"&$Version_HTTP&" "&$Code&" ACCEPTED") Case 404 $Data = _HeaderSet($Data, "", "HTTP/"&$Version_HTTP&" "&$Code&" NOTFOUND") ; EndSwitch $Data = _HeaderSet($Data, "Date", _DateCurrent(), 0) $Data = _HeaderSet($Data, "Server", $Title&"/"&$Version&" (Win32)", 0) $Data = _HeaderSet($Data, "Accept-Ranges", "bytes", 0) $Data = _HeaderSet($Data, "Connection", "close", 0) $Data = _HeaderSet($Data, "Content-Type", "text/html; charset=UTF-8", 0) ;$Data = _HeaderSet($Data, "Content-Encoding", "gzip") Return $Data 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*",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 Grtz, Dellairon
  13. Cool muttley I'm going to test this out right now. Btw, thank you for the fast replies. Dellairion
  14. Nice muttley. I like this alot exept that i got stuck in a latarn in the "Pk3Test.au3" test when pressing "j". And i also have no sound. I can see that this uses .bsp files that are inside the pk3 file? Can this support bsp files from half-life? Anyway this looks promising! Dellairion
  15. It's been a while i checked this topic, just one question: Did someone get the _post working or is there any work around out yet? It would make this script even more usefull if i could use it to create a site with login system. Thnx, Dellairion
×
×
  • Create New...