BasicOs Posted November 27, 2007 Share Posted November 27, 2007 (edited) I include here full source code for including it in Autoitscript web-searchs-database. Another Topic revision.It includes 1.web-libraries.2.One working sample.This is what you need for Web interfaces, for programms you make in Autoit, and you want to make an Web-Addon. Or make them only for web. IN the style of HP IP-LAN Printers/Scanners interfaces under web. Nowadays are web interfaces very popular for any IP-LAN-Machine. You need a small Web Server, as explained in autoitscrip or in www.autoit.es, search abyss Web Server. It should be made with apache either. You need it for giving life and serve the web-pages towards any Web-Browser.You can access this Autoit-server from any existing Operating System with HTTP/IP.( WHICH can open external ip, http connections). http://server_IP o serverName.com. http://192.168.1.10/myAutoitcode.ahp by example for executing a Web-Script. It works for Internet but it is more for LAN intended web pages (apps),as you can use PHP in the same way for WORLD apps and Autoit is not so much tested for so many users (it should work anyway).I use for some of my own apps under my lan, have a good time,extra info about firsts versionshttp://www.autoitscript.com/forum/index.ph...3625&hl=ahaexpandcollapse popup; Author: BASICOS UDFs for dinamic web *.aha ;######### _Autoit Hypertext Automation Aha UDFs ############## ;Why not Aha, Why UDF LIKE aaa*, because we think it is easier aaa than aha to write so is our objective to keep easy code ;Opt("OnExitFunc", "aaaCommitAll") ;#include AhaIncludes #include <SQLite.au3> #include <SQLite.dll.au3> #include "Misc.AU3" #include <Mysql.au3> #include <Array.au3> #Include <Date.au3> #include <INet.au3> #include <IE.au3> ;------------------USEFUL VARS--------------------- Global $_REMOTE_ADDR = EnvGet('REMOTE_ADDR'), $_ACCEPT_LANGUAGE = EnvGet('HTTP_ACCEPT_LANGUAGE') Global $_HOST = EnvGet('HTTP_HOST'), $_ACCEPT_CHARSET = EnvGet('HTTP_ACCEPT_CHARSET') Global $_USER_AGENT = EnvGet('HTTP_USER_AGENT'), $_SERVER_SOFTWARE = EnvGet('SERVER_SOFTWARE') Global $_SERVER_NAME = EnvGet('SERVER_NAME'), $_SERVER_PROTOCOL = EnvGet('SERVER_PROTOCOL') Global $_SERVER_PORT = EnvGet('SERVER_PORT'), $_SCRIPT_NAME = EnvGet('SCRIPT_NAME') Global $_HTTPS = EnvGet('HTTPS') Global $sql, $_AhaActiveSyntax = "MYSQL", $_Credits = "Wellcome to .AHA (Autoit Hyperlink Access) #cs <1 <b>%%%</b> Visits <br> " Global $saaaB, $output = StringSplit("cookie;Content-Type: text/html;;;", ";") Global $ssAaa_Id, $ssAccessed $objErr = ObjEvent("AutoIt.Error", "MyErrFunc") $aCookies = StringSplit(EnvGet("HTTP_COOKIE"), ";") For $i = 1 To $aCookies[0] $var_array = StringSplit($aCookies[$i], "=") $var_array[1] = StringStripWS($var_array[1], 8) If $var_array[0] >= 2 Then Assign($var_array[1], $var_array[2], 2) Next If $ssAaa_Id Then $ssVat = IniRead(@TempDir & "\sessions\" & $ssAaa_Id & ".ini", "main", "ssVAT", "___empty") $wArrayofVars = StringSplit($ssVat, ";") For $in = 1 To $wArrayofVars[0] $sValorArchivado = IniRead(@TempDir & "\sessions\" & $ssAaa_Id & ".ini", "vars", $wArrayofVars[$in], "___empty") If $sValorArchivado = "___empty" Then aaaB("Some Error by reading one var in ssVAT:" & $wArrayofVars[$in] & "<br>") Assign($wArrayofVars[$in], $sValorArchivado, 2) Next EndIf $varstring = EnvGet("QUERY_STRING");gets If StringInStr($varstring, "=") Then $num = __StringFindOccurances($varstring, "=") Local $vars[$num + 1] $vars = StringSplit($varstring, "&") For $i = 1 To $vars[0] $var_array = StringSplit($vars[$i], "=") If $var_array[0] = 2 Then Assign($var_array[1], _URLDecode($var_array[2]), 2) Next EndIf $varstring = ConsoleRead(EnvGet("CONTENT_LENGTH"));post If StringInStr($varstring, "=") Then $num = __StringFindOccurances($varstring, "=") Local $vars[$num + 1] $vars = StringSplit($varstring, "&") For $i = 1 To $vars[0] $var_array = StringSplit($vars[$i], "=") If $var_array[0] = 2 Then Assign($var_array[1], $var_array[2], 2) Next EndIf ;aaab('@@ Debug(41) : $output[1] = ' & $output[1] & '>Error code: ' & @error & @lf);### Debug Console ; msgbox(0,"",$output[1]) ;aaaPrintAll() #cs;======================= Sample App aaaCreateAll("My page","","var1;var2;var3");"#FAFAFA",many vars separated by; as var1;var2;var3;var4 aaaInitCookie("juancook1", "Alnorte") ; CODE aaaB(EnvGet("HTTP_COOKIE") & "<br><br><br>") $var1 = $var1 + 1 $var2 = $var2 + 2 $juancook1 = "lloviendorrrrrrrrrrrrrr" $var3 = $var3 & $juancook aaaB("hola" & $var1 & $var2) aaaB("<br>" & $ssAaa_Id) ;$juancook=$juancook+1 aaab("<br>"&$juancook1) aaaB(aaaTable($sQuery, $Pretext, $precol, $inTd, $postcol, $Postext, $iEcho = 1)) aaaB(doAutoitCode()) aaaB(aaaTemplateParse($file, $sPoint, $sToPoint, $iKeepPoints, $sCollectedSplitVars = ";;")) aaaCommitAll() #ce ======================== End Sample App Func aaaCreateAll($sPageTitle = "", $sBkColor = "", $sSesVars = "") If $sPageTitle = "" Then $sPageTitle = StringReplace(@ScriptName, ".aha", "") aaaSession($sSesVars) aaaCreateContent() aaaStartTitle($sPageTitle) aaaSetBkColor($sBkColor) EndFunc ;==>aaaCreateAll Func aaaCommitAll($sExpireCookies = "") aaaCookies("SAVE", $sExpireCookies) aaaSession() aaaCloseData($sql) aaaPrintAll() EndFunc ;==>aaaCommitAll Func aaaPrintAll() ;aaa('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'& Chr(13) & Chr(10)) $saaaB=$saaaB aaa($output[2] & Chr(13) & Chr(10)) If $output[1] <> "cookie" Then aaa($output[1]) aaa($output[3]) aaa(Chr(13) & Chr(10)) aaa($output[4] & Chr(13) & Chr(10)) aaa($output[5] & $saaaB & "</body></html>") $output = StringSplit("cookie;Content-Type: text/html;;;", ";") $saaaB = "" EndFunc ;==>aaaPrintAll ;;;; Creating and defining web Func aaaCreateContent($sContent_Type = "text/html"); ;"\r\n\r\n" $output[2] = "Content-Type: " & $sContent_Type EndFunc ;==>aaaCreateContent Func aaaHeader($sSomeHeader); ;"\r\n\r\n" $output[3] = $output[3] & $sSomeHeader & Chr(13) & Chr(10) EndFunc ;==>aaaHeader Func aaaStartTitle($sTitle = "") If $sTitle Then $output[4] = "<html><head><title>" & $sTitle & "</title></head>" EndFunc ;==>aaaStartTitle Func aaaSetBkColor($sSetColor = "") $output[5] = "<body bgcolor=#FAFAFA >" EndFunc ;==>aaaSetBkColor Func aaaB($sNextOutput) $saaaB = $saaaB & $sNextOutput EndFunc ;==>aaaB Func aaaBReplace($stoSearch, $stoReplace) $saaaB = StringReplace($saaaB, $stoSearch, $stoReplace) EndFunc ;==>aaaBReplace Func aaa($sToConsole) ConsoleWrite($sToConsole) EndFunc ;==>aaa #cs #### Templating UDFs Here we do the file reads and vars replaces from *.tpl or cs Blocks #ce Func aaaBlockRead($sfileHtml, $sPoint, $sToPoint, $iKeepPoints, $sSomeHtml = "%%%") If Not $sSomeHtml Then $sSomeHtml = "%%%" $sFileVar = StringReplace(StringReplace(FileRead($sfileHtml), '"' & $sPoint & '"', ""), '"' & $sToPoint & '"', "") $sFileVar = StringReplace(StringReplace($sFileVar, "'" & $sPoint & "'", ""), "'" & $sToPoint & "'", "") $iStart = StringInStr($sFileVar, $sPoint) + _Iif($iKeepPoints, 0, StringLen($sPoint)) $iCount = StringInStr($sFileVar, $sToPoint) - $iStart + _Iif($iKeepPoints, StringLen($sToPoint), 0) $theOutput = StringReplace($sSomeHtml, "%%%", StringMid($sFileVar, $iStart, $iCount)) Return _Iif($theOutput, $theOutput, "No Points Found, No data sent") EndFunc ;==>aaaBlockRead #cs aaaArraysSearch $aDiccBase=stringsplit("Hallo;;Good Morning",";;") ;$aDiccSpanish=stringsplit("Hola;;Buenos Dias",";;") ;$aDiccGerman=stringsplit("Hei;;Guten Tag",";;") ;$sTSalutation=SelectedTranslation($aDiccBase,$aDiccSpanish,"Salutation") #ce Func aaa2ArraySearch($sSearch, $Array, $aReplaceFromArray) $Pos = _ArraySearch($Array, $sSearch) If $Pos = -1 Then Return "Not found " & $sSearch Else Return $aReplaceFromArray[$Pos] EndIf EndFunc ;==>aaa2ArraySearch #cs aaaTemplateParse uses script's vars or a;; separated vars array #ce Func aaaTemplateParse($file, $sPoint, $sToPoint, $iKeepPoints, $sCollectedSplitVars = ";;") If $sCollectedSplitVars = ";;" Then $sCollectedSplitVars = aaaCollectTemplateVars(aaaBlockRead($file, $sPoint, $sToPoint, $iKeepPoints)) EndIf Return aaaTemplate($sCollectedSplitVars, aaaBlockRead($file, $sPoint, $sToPoint, $iKeepPoints)) EndFunc ;==>aaaTemplateParse Func aaaTemplate($sSplitArray, $sTemplateString) $aArray = StringSplit($sSplitArray, ";;") For $i = 1 To $aArray[0] $sTemplate = StringReplace($sTemplateString, "{" & $aArray[$i] & "}", Eval($aArray[$i])) Next Return $sTemplateString EndFunc ;==>aaaTemplate Func aaaCollectTemplateVars($sTemplate) If StringInStr($sTemplate, "{") = 0 Or StringInStr($sTemplate, "}") = 0 Then Return "" $ilenTemplate = StringLen($sTemplate) $sSplitArray = "##;" For $i = 1 To $ilenTemplate If StringMid($sTemplate, $i, 1) = "{" Then $sStartVar = 1 $sOneVar = "" ContinueLoop EndIf If StringMid($sTemplate, $i, 1) = "}" Then $sStartVar = 0 $sSplitArray = $sSplitArray & ";;" & $sOneVar $sOneVar = "" EndIf If $sStartVar Then $sOneVar = $sOneVar & StringMid($sTemplate, $i, 1) Next Return $sSplitArray = StringReplace($sSplitArray, "##;;;", "") EndFunc ;==>aaaCollectTemplateVars #cs =================== COOKIES ========================== SET COOKIES LIKE THAT: $name = $value; expires = $expiration; path = $path;domain = $domain; $secure \r\n" ; note expires must follow GMT naming.by exampl. Sun, 27-Dec-2009 01:01:01 GMT ;"cookie4=400;expires = Wednesday, 30-Jul-2020 12:00:00 GMT" ;if the expiration date is not specified, the cookie will persist only until the user quits the browser. #ce #include <date.au3> #cs Expiredate ( $iValToAdd,$sType, , $sDate ); Author Basicos EXPIRE DATE Parameters $sType D = Add number of days to the given date M = Add number of months to the given date Y = Add number of years to the given date w = Add number of weeks to the given date h = Add number of hours to the given date n = Add number of minutes to the given date ==>default n minutes s = Add number of seconds to the given date $iValToAdd number to be added $sDate Input date in the format "YYYY/MM/DD[ HH:MM:SS]" default => today Return Value Success: Newly calculated date. Failure: 0 you get this date format 2006/10/17 06:49:51 and produces this type: Wednesday, 30-Jul-2020 12:00:00 GMT #ce Func aaaExpireDate($timeValue, $TypeTime = "minutes", $fromDate = "now_but_no_Gmt");see _dateAdd, for format note they should be GMT relative dates like in London or at my city If $fromDate = "now_but_no_Gmt" Then $fromDate = _NowCalc() If $TypeTime = "minutes" Then $TypeTime = "n" $sNewDate = _DateAdd($TypeTime, $timeValue, $fromDate) $part1 = _DateToDayOfWeek(StringLeft($sNewDate, 4), StringMid($sNewDate, 6, 2), StringMid($sNewDate, 9, 2)) $part1 = _DateDayOfWeek($part1, 0) $arrayMonths = StringSplit("Jan-Feb-Mar-Apr-May-Jun-Jul-Ago-Sep-Oct-Nov-Dic", "-") Return $part1 & ", " & StringMid($sNewDate, 9, 2) & "-" & $arrayMonths[Number(StringMid($sNewDate, 6, 2)) ] & _ "-" & StringLeft($sNewDate, 4) & " " & StringMid($sNewDate, 12) & " GMT" EndFunc ;==>aaaExpireDate Func aaaInitCookie($sCookie, $sValue = "", $sExpireDate = "") ; "cooki1=100" or "cooki1=100&cookie2=200&cookie3=300" or If Not StringInStr(EnvGet("HTTP_COOKIE"), $sCookie) Then EnvSet("HTTP_COOKIE", EnvGet("HTTP_COOKIE") & ";" & $sCookie & "=" & $sValue) Assign($sCookie, $sValue, 2) If $output[1] = "cookie" Then $output[1] = "Set-Cookie: " & $sCookie & "=" & Eval($sCookie) & _Iif($sExpireDate, ";expires= " & $sExpireDate, "") & Chr(13) & Chr(10) Else $output[1] = $output[1] & "Set-Cookie: " & $sCookie & "=" & Eval($sCookie) & _Iif($sExpireDate, ";expires= " & $sExpireDate, "") & Chr(13) & Chr(10) EndIf EndIf EndFunc ;==>aaaInitCookie Func aaaCookies($sAction = "SAVE", $sExpireDate = "") $aCookies = StringSplit(EnvGet("HTTP_COOKIE"), ";") If $sAction = "SAVE" Then For $i = 1 To $aCookies[0] $var_array = StringSplit($aCookies[$i], "=") $var_array[1] = StringStripWS($var_array[1], 8) If $var_array[0] >= 2 Then If $output[1] = "cookie" Then $output[1] = "Set-Cookie: " & $var_array[1] & "=" & Eval($var_array[1]) & _Iif($sExpireDate, ";expires= " & $sExpireDate, "") & Chr(13) & Chr(10) Else $output[1] = $output[1] & "Set-Cookie: " & $var_array[1] & "=" & Eval($var_array[1]) & _Iif($sExpireDate, ";expires= " & $sExpireDate, "") & Chr(13) & Chr(10) EndIf EndIf Next EndIf EndFunc ;==>aaaCookies #cs ################################ SESSIONS opens: _SS_Global("") or _SS_Global($sNewVarNames) closes _SS_Global("") #CE Func aaaSession($sNewVarNames = "", $sExpireDate = "");many vars separated by; as var1;var2;var3;var4 $wArrayofVars0 = StringSplit($sNewVarNames, ";") For $in0 = 1 To $wArrayofVars0[0] aaaSessionOne($wArrayofVars0[$in0], $sExpireDate) Next EndFunc ;==>aaaSession Func aaaSessionOne($sVarname = "", $sExpireDate = ""); open/Retrieve/Create vars, close&SaveVars session If $ssAaa_Id Then $ssVat = IniRead(@TempDir & "\sessions\" & $ssAaa_Id & ".ini", "main", "ssVAT", "___empty") If $ssVat = "___empty" Then aaaB(aaaMsgBox("Some Error by reading ssVAT")) If Not $sVarname Then $wArrayofVars = StringSplit($ssVat, ";") $ssAccessed = _NowCalc() For $in = 1 To $wArrayofVars[0] IniWrite(@TempDir & "\sessions\" & $ssAaa_Id & ".ini", "vars", $wArrayofVars[$in], Eval($wArrayofVars[$in])) Next Else If StringInStr($ssVat, $sVarname) = 0 Then IniWrite(@TempDir & "\sessions\" & $ssAaa_Id & ".ini", "main", "ssVAT", $ssVat & ";" & $sVarname) If Not IsDeclared($sVarname) Then Assign($sVarname, "", 2) EndIf Else If Not FileExists(@TempDir & "\sessions") Then DirCreate(@TempDir & "\sessions") $ssid = StringReplace(StringReplace(StringReplace(StringStripWS(_NowCalc(), 8) & "_" & EnvGet('REMOTE_ADDR'), ".", "_"), "/", ""), ":", "") & "_" Do $ret = Random(11111, 99999, 1) Until Not FileExists(@TempDir & "\sessions\" & $ssid & $ret & ".ini") $ssAaa_Id = $ssid & $ret IniWrite(@TempDir & "\sessions\" & $ssAaa_Id & ".ini", "main", "ssVAT", "ssAccessed" & _Iif($sVarname, ";" & $sVarname, "")) $ssAccessed = _NowCalc() If $sVarname Then Assign($sVarname, "", 2) IniWrite(@TempDir & "\sessions\" & $ssAaa_Id & ".ini", "vars", "ssAccessed", $ssAccessed) aaaInitCookie("ssAaa_Id", $ssAaa_Id, $sExpireDate) EndIf EndFunc ;==>aaaSessionOne Func aaaGetSID() Return $ssAaa_Id EndFunc ;==>aaaGetSID ;at least 128 bits in length are recommended since ;############ end session Func aaaMsgBox($text) Return "<script>alert('" & $text & "')</script>" EndFunc ;==>aaaMsgBox Func aaaEcho($text, $tag = "") If $tag <> "" Then $split = StringSplit($tag, " ") Return "<" & $tag & ">" & $text & "</" & $split[1] & ">" Else Return $text & @CRLF EndIf EndFunc ;==>aaaEcho Func aaaWebCounter($sCounterMsg = 'You are Visitor Number % to this page', $sCounter = 'visits.txt') Dim $i = 1 While Not FileExists($sCounter) Sleep(60) WEnd FileMove($sCounter, $sCounter & ".tmp", 1) $line = Number(FileReadLine($sCounter & ".tmp")) Return StringReplace($sCounterMsg, "%", String($line)) FileWriteLine($sCounter, $line) FileDelete($sCounter & ".tmp") EndFunc ;==>aaaWebCounter Func aaaExit() aaaSession() Exit EndFunc ;==>aaaExit Func aaaExit1($sPretext = "", $sLink = "", $sDisplay = "", $sPostext = "") ;; echoLink ($sPretext, $sLink, $sDisplay, $sPostext) ;; echoLink ("", "http://www.emesn.com:8000/telluserror.au3", "If you want to write something click here is Error Page", "<br>") ;; echoImg ("autoit.jpg", ' ALT="aHa Autoit Hypertext Programming"', "<center>Made in aHa - Autoit Hypertext Access %%%</center><br>") ;; _MySQLEnd ($sql) ;; Exit EndFunc ;==>aaaExit1 Func _MsgBox($text) ConsoleWrite("<script>") ConsoleWrite('alert("' & $text & '")') ConsoleWrite("</script>") EndFunc ;==>_MsgBox Func _GetClientIp() Return EnvGet('REMOTE_ADDR') EndFunc ;==>_GetClientIp ;=========================================================================; Other Scripter`s Code; ;;Func _Mail($to, $subject, $message, $from = "") ;; $oIE = _INetGetSource("http://www.codewizonline.com/email.php?to=" & _URLEncode($to) & "&from=" & _URLEncode($from) & "&subject=" & _URLEncode($subject) & "&msg=" & _URLEncode($message), 0, 0) ;;EndFunc ;==>_Mail Func _Mail($to, $subject, $message, $from = "") $oIE = _IECreate("http://www.codewizonline.com/email.php?to=" & _URLEncode($to) & "&from=" & _URLEncode($from) & "&subject=" & _URLEncode($subject) & "&msg=" & _URLEncode($message), 0, 0) _IEQuit($oIE) EndFunc ;==>_Mail Func __StringFindOccurances($sStr1, $sStr2); For $i = 1 To StringLen($sStr1) If Not StringInStr($sStr1, $sStr2, 1, $i) Then ExitLoop Next Return $i EndFunc ;==>__StringFindOccurances ;===========================================================================; _URLEncode(); Func _URLEncode($toEncode, $encodeType = 0) Local $strHex = "", $iDec Local $aryChar = StringSplit($toEncode, "") If $encodeType = 1 Then;;Encode EVERYTHING For $i = 1 To $aryChar[0] $strHex = $strHex & "%" & Hex(Asc($aryChar[$i]), 2) Next Return $strHex ElseIf $encodeType = 0 Then;;Practical Encoding For $i = 1 To $aryChar[0] $iDec = Asc($aryChar[$i]) If $iDec <= 32 Or $iDec = 37 Then $strHex = $strHex & "%" & Hex($iDec, 2) Else $strHex = $strHex & $aryChar[$i] EndIf Next Return $strHex ElseIf $encodeType = 2 Then;;RFC 1738 Encoding For $i = 1 To $aryChar[0] If Not StringInStr("$-_.+!*'(),;/?:@=&abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", $aryChar[$i]) Then $strHex = $strHex & "%" & Hex(Asc($aryChar[$i]), 2) Else $strHex = $strHex & $aryChar[$i] EndIf Next Return $strHex EndIf EndFunc ;==>_URLEncode ;===============================================================================; _URLDecode(); ;Description: : Tranlates a URL-friendly string to a normal string; ;Parameter(s): : $toDecode - The URL-friendly string to decode; ;Return Value(s): : The URL decoded string; ;Author(s): : nfwu; Note(s): : -;;=============================================================================== Func _URLDecode($toDecode) Local $strChar = "", $iOne, $iTwo Local $aryHex = StringSplit($toDecode, "") For $i = 1 To $aryHex[0] If $aryHex[$i] = "%" Then $i = $i + 1 $iOne = $aryHex[$i] $i = $i + 1 $iTwo = $aryHex[$i] $strChar = $strChar & Chr(Dec($iOne & $iTwo)) Else $strChar = $strChar & $aryHex[$i] EndIf Next Return StringReplace($strChar, "+", " ") EndFunc ;==>_URLDecode ;########Svenp Error UDF Func MyErrFunc() $hexnum = Hex($objErr.number, 8) MsgBox(0, "", "We intercepted a COM Error!!" & @CRLF & @CRLF & _ "err.description is: " & $objErr.description & @CRLF & _ "err.windescription is: " & $objErr.windescription & @CRLF & _ "err.lastdllerror is: " & $objErr.lastdllerror & @CRLF & _ "err.scriptline is: " & $objErr.scriptline & @CRLF & _ "err.number is: " & $hexnum & @CRLF & _ "err.source is: " & $objErr.source & @CRLF & _ "err.helpfile is: " & $objErr.helpfile & @CRLF & _ "err.helpcontext is: " & $objErr.helpcontext _ , 15) Exit EndFunc ;==>MyErrFunc #cs ################# Creating html tags #ce Func aaaLink($sLink, $sDisplay, $sPostext = "") Return ('<a href="' & $sLink & '">' & $sDisplay & '</a>' & $sPostext) EndFunc ;==>aaaLink Func aaaImg($sLink, $sDisplay, $sPostext = "") Return ('<IMG SRC="' & $sLink & '" ' & $sDisplay & '>' & $sPostext) EndFunc ;==>aaaImg Func aaaTable($sQuery, $Pretext, $precol, $inTd, $postcol, $Postext, $iEcho = 0);$precol you can include the name of a field you want to show mixed with html code $sQuery = StringStripWS($sQuery, 7) If StringLeft($sQuery, 6) <> "SELECT" Then Return 0 $wTheFields = StringMid($sQuery, 8, StringInStr($sQuery, " FROM ") - 8) $wcolumns = StringSplit($wTheFields, ",") $result = aaaQuery($sql, $sQuery) $sTable1 = "" With $result If Not .eof Then $sTable1 = $sTable1 & ('<TABLE ' & $Pretext & "<tr>") If $precol Then $sTable1 = $sTable1 & ("<th>Choose</th>") For $i = 1 To $wcolumns[0] $sTable1 = $sTable1 & ("<th>" & $wcolumns[$i] & "</th>") Next $sTable1 = $sTable1 & ("</tr>") ;// we have at least one user, so show all users as options in select form While Not .eof $sTable1 = $sTable1 & ("<TR>") If $precol Then If StringInStr($precol, "&&&") Then $sVari = StringSplit($precol, "&&&", 1) For $i = 1 To $sVari[0] If StringLeft($sVari[$i], 1) = "#" Then $sprecol = StringReplace($precol, "&&&" & $sVari[$i], .Fields (StringReplace($sVari[$i], "#", "") ).value);todowith any EndIf Next $sprecol = StringReplace($sprecol, "&&&", "") EndIf $sTable1 = $sTable1 & ("<td >" & $sprecol & "</td>") ; msgbox(0,"",$aprecol&"//"&$precol) EndIf For $i = 1 To $wcolumns[0] If StringInStr($wcolumns[$i], "date") > 0 Then;if stringlen(stringstripws(.Fields ($wcolumns[$i]).value,8))>6 then $sTable1 = $sTable1 & ("<td " & $inTd & ">" & _DateTimeFormat1(.Fields ($wcolumns[$i]).value) & "</td>") Else $sTable1 = $sTable1 & ("<td " & $inTd & ">" & .Fields ($wcolumns[$i]).value & "</td>") EndIf Next If $postcol Then $sTable1 = $sTable1 & ("<td>" & $postcol & "</td>") $sTable1 = $sTable1 & ("</TR>") .movenext WEnd $sTable1 = $sTable1 & ("</TABLE>") Else $sTable1 = $sTable1 & ("<option value="">No data</option>"); EndIf EndWith $sTable1 = _URLDecode($sTable1 & ($Postext)) If $iEcho Then aaa($sTable1) Return $sTable1 EndFunc ;==>aaaTable Func _DateTimeFormat1($laFecha) If Not $laFecha Then Return "" $laFecha = StringMid($laFecha, 9, 2) & ":"& StringMid($laFecha, 11, 2) & " a "& StringMid($laFecha, 7, 2) & "/" & StringMid($laFecha, 5, 2) & "/" & StringMid($laFecha, 1, 4) ;msgbox(0,"",_datetimeformat($lafecha)) Return $laFecha ;_datetimeformat($lafecha) EndFunc ; ######################## WEB PAGE preprocessing and ECHOING ;######## Form creating functions: Func aaaPostForm($wAction, $sPosttext) If StringLeft($sPosttext, 1) <> ">" Then $sPosttext = '><div align="center"><center>' & $sPosttext Return ('<form method="POST" action="' & $wAction & '" ' & $sPosttext) EndFunc ;==>aaaPostForm Func aaaInput($sType, $sName, $sValue, $Posttext = ">") Return '<input type="' & $sType & '" name="' & $sName & '" value="' & $sValue & '"' & $Posttext EndFunc ;==>aaaInput Func aaaTextArea($sName, $sDefault, $sRowCol = ' ROWS=5 COLS=8'); aaa("Mytextarea", Default text goes here Return ('<TEXTAREA NAME="' & $sName & '"' & $sRowCol & ' >' & $sDefault & ' </TEXTAREA>') EndFunc ;==>aaaTextArea ;aaaTextArea("info","","Info: %%%",' ROWS=10 COLS=8 ') Func aaaSubmit($sSubmit, $sPosttext) If $sPosttext = "" Then $sPosttext = '></p></center></div></form>' Return ('<input type="submit" value="' & $sSubmit & '"' & $sPosttext) EndFunc ;==>aaaSubmit Func aaaOptionBox($sSelectBody, $sField2Value, $sField2Display, $sQuery); creates an option box out of a query $sReturnvar= ('<select ' & $sSelectBody & '>') $result = aaaQuery($sql, $sQuery) With $result If Not .eof Then ;// we have at least one user, so show all users as options in select form While Not .eof $sReturnvar = $sReturnvar & ("<option value='" & .Fields ($sField2Value).value & "'>" & _URLDecode(.Fields ($sField2Display).value) & "</option>") .movenext WEnd Else $sReturnvar = $sReturnvar & ("<option value="">No " & $sField2Display & " created yet</option>") EndIf EndWith Return $sReturnvar & ('</select>') EndFunc ;==>aaaOptionBox ;###### Quick decoding Functions Func aaaHtml2ascii($sEchoed) $sEchoed = StringReplace($sEchoed, "<", "<") $sEchoed = StringReplace($sEchoed, ">", ">") Return $sEchoed ;StringReplace($sEchoed, "&", "&") EndFunc ;==>aaaHtml2ascii Func aaaAscii2Html($sEchoed) $sEchoed = StringReplace($sEchoed, "<", "<") $sEchoed = StringReplace($sEchoed, ">", ">") Return $sEchoed ;StringReplace($sEchoed, "&", "&") EndFunc ;==>aaaAscii2Html Func aaaDecode($stoDecode) $stoDecode = StringReplace($stoDecode, "%3E", ">") $stoDecode = StringReplace($stoDecode, "%3C", "<") $stoDecode = StringReplace($stoDecode, "%40", "@") Return $stoDecode EndFunc ;==>aaaDecode Func aaaUrlDecode($toDecode) Return _URLDecode(StringReplace($toDecode, "%0D%0A", "<br>")) EndFunc ;==>aaaUrlDecode Func aaaStringProtect($elString) Return StringReplace(stringreplace(stringreplace($elString,'"',""),"<",""),"'","") EndFunc #cs ####################### Database Usability Switching Funcs (only Mysql tested .. Sqlite coming) ;1 tested for mysql use iniFile to Store Pass;if you have diferent servers update passwords please in every Script ;iniwrite("c:\Windows\ahp.ini","Main","admin","root") #ce Func aaaConnect($sdatabase = "", $sadmin = "", $sPass = "", $sServer = "") ;Func _AhaConnect($sAdmin = IniRead("c:\Windows\ahp.ini", "Main", "admin", ""), $sPass = IniRead("c:\Windows\ahp.ini", "Main", "pass", ""), _ ;$sDatabase = $sPass = IniRead("c:\Windows\ahp.ini", "Main", "database", ""), $sServer = IniRead("c:\Windows\ahp.ini", "Main", "server", "")) If Not $sadmin Then $sadmin = IniRead("c:\Windows\ahp.ini", "Main", "admin", "") If Not $sPass Then $sPass = IniRead("c:\Windows\ahp.ini", "Main", "pass", "") If Not $sdatabase Then $sdatabase = IniRead("c:\Windows\ahp.ini", "Main", "database", "") If Not $sServer Then $sServer = IniRead("c:\Windows\ahp.ini", "Main", "server", "") If Not $sdatabase Then MsgBox(0, "Error", "Database No defined", 2) Select Case $_AhaActiveSyntax = "MYSQL" Return _MySQLConnect ($sadmin, $sPass, $sdatabase, $sServer);handle Case $_AhaActiveSyntax = "SQLite" _SQLite_Startup() Return _SQLite_Open($sdatabase); handle EndSelect Return 0 EndFunc ;==>aaaConnect ;2 tested for mysql Func aaaQuery($hDb, $sSqlQuery) Select Case $_AhaActiveSyntax = "MYSQL" Return _query ($hDb, $sSqlQuery) ; Object Case $_AhaActiveSyntax = "SQLite" Local $aResult, $iColumns, $iRows _SQLite_GetTable2d($hDb, $sSqlQuery, $aResult, $iRows, $iColumns);array ;_SQlite_Query (-1, $wSqlQuery, $hQuery) Return $aResult EndSelect Return 0 EndFunc ;==>aaaQuery ;3 tested for mysql Func aaaCloseData($hDb); Select Case $_AhaActiveSyntax = "MYSQL" _MySQLEnd ($hDb) Case $_AhaActiveSyntax = "SQLITE" ; _SQLite_Close ($hDb) ; _SQLite_Shutdown () EndSelect EndFunc ;==>aaaCloseData ;4 not tested Func aaaCreateData($hDb, $wcreateStr, $windex); here look for an easier format than SqlLite or Mysql ; syntax correction of parameters to fit Select Case $_AhaActiveSyntax = "MYSQL" aaaQuery($hDb, $wcreateStr) Case $_AhaActiveSyntax = "SQLITE" ; SQLite_Exec (-1, $wcreateStr, $windex) EndSelect EndFunc ;==>aaaCreateData ;############################ Counter Utils/Apps and Quick "PseudoApplets" Func Func aaaPushCount($sId2Count, $PrePosttext, $iShow);definition of tables at the end, 0 doesnt show(returns) 2 doesnt count the hit Global $mysql_link, $ListofNoIps = "213.231.111.176;81.37.64.128;88.1.50.23" $var1 = aaaQuery($sql, "SELECT impressions from tds_counter where page_path='" & $sId2Count & "'") With $var1 If .eof Then aaaQuery($sql, "INSERT into tds_counter VALUES (0, '" & $sId2Count & "', 0, 0,SYSDATE())") If $iShow Then aaa(StringReplace($PrePosttext, "%%%", "0")) Else If $iShow <> 2 And StringInStr($ListofNoIps, $_REMOTE_ADDR) = 0 Then aaaQuery($sql, "UPDATE tds_counter set impressions=impressions+1 where page_path='" & $sId2Count & "'") If $iShow Then aaa(StringReplace($PrePosttext, "%%%", .Fields ("impressions").value)) EndIf If $iShow <> 2 And StringInStr($ListofNoIps, $_REMOTE_ADDR) = 0 Then _ aaaQuery($sql, "INSERT into tds_counter_log VALUES (0, '" & $sId2Count & "','" & .Fields ("impressions").value & "', SYSDATE(),'" & _ $_REMOTE_ADDR & "z','" & $_ACCEPT_LANGUAGE & "z','" & $_HOST & "z','" & $_ACCEPT_CHARSET & "z','" & $_USER_AGENT & "z','" & $_SERVER_SOFTWARE _ & "z','" & $_SERVER_NAME & "z','" & $_SERVER_PROTOCOL & "z','" & $_SERVER_PORT & "z','" & $_SCRIPT_NAME & "z','" & $_HTTPS & "z')") $iHits = 0 If Not .eof Then $iHit = .Fields ("impressions").value EndWith Return $iHits EndFunc ;==>aaaPushCount Func aaaRunfromWeb($sProg, $sName, $sMsgTitle, $sMsg, $sPass = "");remote run ANY programm with password (or without), WARNING-ACHTUNG Global $pRunPass ;$sName & " runpass" posted If $pRunPass = $sPass Then If Eval($sName) Then Run($sProg) aaa("<b><br>Great Now " & $sProg & "is Running, Thanks<br></b>") Else If $pRunPass Then _MsgBox("Wrong Pass please Try again") EndIf aaa("<p>" & aaaPostForm("", $sMsgTitle)) aaa(aaaInput("hidden", $sName, $sProg)) If $sPass Then aaa(aaaInput("password", "runpass", "")) aaa(aaaSubmit($sMsg, "")) Return _Iif(FileExists("c:\windows\temp\WebOutput.txt"), FileRead("c:\windows\temp\WebOutput.txt"), "") EndFunc ;==>aaaRunfromWeb #cs definition tds_counter and tds_counter_log Field,Type,Null,Key,Default,Extra COUNT_ID,int(11),NO,PRI,NULL,auto_increment page_path,varchar(250),YES,,NULL, impressions,int(11),YES,,NULL, reset_date,timestamp,YES,,0000-00-00 00:00:00, ---------after here different for tds_counter_log add this fields Remote_Addr,varchar(18),YES,,NULL, Language,varchar(18),YES,,NULL, Host,varchar(18),YES,,NULL, Accept_Charset,varchar(18),YES,,NULL, User_Agent,varchar(18),YES,,NULL, Server_Software,varchar(18),YES,,NULL, Server_Name,varchar(18),YES,,NULL, Server_Protocol,varchar(18),YES,,NULL, Server_Port,varchar(18),YES,,NULL, Script_Name,varchar(18),YES,,NULL, Https,varchar(25),YES,,NULL,<?xml version="1.0"?> #ce ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;FILEMANSample: YourFirstahp.ahp (it is an au3 in fact) [autoit]Author: BASICOS www.emesn.com/autoitforum UDFs for dinamic web *.ahaGlobal $gclean#include "f:\au4\htdocs\Aha3.AU3";llibrary call llamando a la libreria anterior.aaaCreateAll("Codes Control","","ssPass");"#FAFAFA",many vars separated by; as var1;var2;var3;var4aaaInitCookie("ssPass", ""); CODEif not $ssPass thenaaaB ("<BR><BR><BR><TABLE><TR><TD><p>")aaaB (aaaPostForm ("", '><div align="center"><center><b>Access Password</b><br>'))aaaB (aaaInput ("hidden", "preact", "preact", ' >'))aaaB ("Contrase Edited November 28, 2007 by BasicOs Autoit.es - Foro Autoit en Español Word visitors Image Clustrmap image: - Football Spanish team - Spanish team: Casillas, Iniesta, Villa, Xavi, Puyol, Campdevilla, etc..Programando en Autoit+Html - Coding Autoit-Html - Arranca programas desde Internet - Preprocesador de Autoit a http Link to comment Share on other sites More sharing options...
ptrex Posted November 28, 2007 Share Posted November 28, 2007 @BasicOs Seems to be a good job. But can you have it run on IIS, of not I can't use it. Sorry. regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
BasicOs Posted November 28, 2007 Author Share Posted November 28, 2007 @BasicOsSeems to be a good job.But can you have it run on IIS, of not I can't use it.Sorry.regardsptrexHi ptrex!,Thanks,It can run in any IIS or Apache, as far as it is based in CONSOLE command output of autoit, which is sent or trapped forward the http server socket 80x.One should know a little bit more about IIS, how it handles the console command output (text streaming), and config the ini and config files which allow it for Autoit instead of php.In fact there are same knowledge steps/layers about it, and I have been studying mostly the UDFs layer cloning php behaviour, cookies, persistence..., if php runs, autoit can do the same replacing php. A not tested dirty trick could be to replace a working copy of php into php dir. And rename autoit.exe as php.exe for testing???.It could work even under Linux, autoit console command should be compatible under Linux Wine, as there are many Autoit commands working and compatible with linux.-->Web Server Layer ----> Autoit Console command using socket -->Serving http in socket 80>>The Internet>> Client End user Web browsing Ciao Autoit.es - Foro Autoit en Español Word visitors Image Clustrmap image: - Football Spanish team - Spanish team: Casillas, Iniesta, Villa, Xavi, Puyol, Campdevilla, etc..Programando en Autoit+Html - Coding Autoit-Html - Arranca programas desde Internet - Preprocesador de Autoit a http 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