#include <Array.au3>
;=========================>
$sIndex = Fileread(@scriptdir & "\index.html")
$sPass = "wohoo"
TCPStartup()
$MainSocket = TCPListen(@IPAddress1, 80)
If @error Then MsgBox(16, "ERROR", "Fehler beim Horchen")
While 1
Do 
	$socket = TCPAccept($MainSocket)
	Sleep(20)
until $socket <> -1
ConsoleWrite("Verbunden..." & @crlf)
$sRecv = ""
Do 
	$sRecv &= TCPRecv($socket, 1)
until Stringinstr($sRecv, @crlf & @crlf)
Consolewrite($sRecv & @crlf)
If Stringinstr($sRecv, "GET / ") Then 
	HTTPSend($socket, $sIndex)
elseif StringinStr($sRecv, "GET /MsgBox.html?") Then 
	$aResults = StringRegExp($sRecv, "pass=(.+?)&flag=(\d+?)&title=(.+?)&text=(.+?) ", 3) ;extrahiere alle wichtigen Daten REIHENFOLGE WICHTIG
	If Ubound($aResults) < 4 Then ;falls es zu wenig Parameter gibt...
		HTTPSend($socket, "Zu wenig Parameter (alle inputs ausf&uuml;llen)")
	Elseif Ubound($aResults) = 4 Then
		If $aResults[0] = $sPass Then 
			Run("MsgBoxProg.exe "&$aResults[1]&" "&$aResults[2]&" "&$aResults[3])
			HTTPSend($socket, "MsgBox wurde angezeigt")
		EndIf
	Else
		HTTPSendNotFound($socket, "Seite wurde nicht gefunden")
	EndIf
Else
	HTTPSendNotFound($socket, "Seite wurde nicht gefunden")
EndIf
TCPCloseSocket($socket)
$socket = -1
wend
TCPShutdown()

Func HTTPSend($socket, $sData)
$sHeader = 	"HTTP/1.1 200 OK" & @crlf & _
	"Server: Autoit" & @crlf & _
	"Cache-Control: max-age=0, public" & @crlf & _
	"Connection: close" & @crlf & _
	"Content-Length: " & Stringlen($sData) & @crlf & _
	"Content-Type: text/html; charset=UTF-8" & @crlf & @crlf 
	return TCPSend($socket, $sHeader & $sData)
EndFunc

Func HTTPSendNotFound($socket, $sMessage)
$sHeader = 	"HTTP/1.1 404 Not Found" & @crlf & _
	"Server: Autoit" & @crlf & _
	"Cache-Control: max-age=0, public" & @crlf & _
	"Connection: close" & @crlf & _
	"Content-Length: " & Stringlen($sMessage) & @crlf & _
	"Content-Type: text/html; charset=UTF-8" & @crlf & @crlf 
	return TCPSend($socket, $sHeader & $sMessage)
EndFunc