Jump to content
Sign in to follow this  
arcker

Au3 FastCGI - AuCGI, but faster. ( Generate WebPages behind any WebServer )

Recommended Posts

arcker

Au3_FastCGI

Arck System.

Version 0.1 Beta

alpha version ( proof of concept ).

Version 0.1 Beta *

What is it ?

Au3 FastCGI is a CGI handler that will run constantly to get request from webservers

The process will send back html code to the webserver.

It’s the same as php or other language that acts as cgi.

FastCGI is powerful since CGI spawn a process on each request. FastCGI works with TCP connection, so it’s always started to handle request.

Some reads : http://www.fastcgi.com/drupal/

Features :

This udf enables FastCGI to be used with autoit.

FastCGI is used by a lot of webservers ( mainly to use php ) to call functions written in other languages. Its main purpose is too use sockets on existants processes instead of stdios to send/receive result and spawn process.

With is, you can spawn your fastcgi “listener” then let it run. A service is in preparation to do so.

You can use any webserver that support FastCGI. Lighttp, apache, and more, make a total third part architecture. The webserver with your firewall can run in linux and Au3_fastcgi_Server can run on a dedicated server.

Multiple instances can run, so many processes can run, to avoid contention and make a bigger webserver.

This UDF uses

  • TCP_Event by kip to boost performances. ( avoid loop )
  • Bininbinary by ward to fastcheck only needed informations. ( avoid uses of multiple structure, can gain 1-2 ms ) ( will be in proper version ) ( not used in FastCGI_Lite )
For now, this udf lets you make webservers in autoit with easy integration. By detaching webserver and fastcgi, you can easily update your webserver.

I’ve attached a script that you rerun your script in scite to test. Simply right-click on autoit icon when running, then click restart, and it will close and tells cite to reload it. Be careful, scite will run active tab.

To use it, you have to think this way :

The main process will handle all of your process code. You have to let the engine function, then add your functions to test it.

When you call http://localhost/test.au3, the script will call “test” function.

If the function doesn’t exists, a custom 404 error is thrown. For now, you can’t set subpages ( like /somepages/test/index.au3 ) only “root” can be called.

The Fast CGI Lite script is my paperboard. You can execute it and test some pages, but it will changed often in the future. Please test your script in an external file.

HOW TO RUN

  • First of all, start the ServerControl.exe, then click start, and reduces it if everything ok. If another process is listening to port 80, close it, or change port in ligttpd config files.
  • Open Au3_FastCGI_Lite.au3 in Scite and run it
  • Open your favorite webbrower and type http://localhost/index.au3

    • You should see a 404 custom page
  • Now go to http://localhost/_all.au3

TO DO LIST

  • Add SubPages Support
  • Add GZip support ( should be on lighttp size, don’t know)
  • Add ability to send/receive files and process them
  • Add Multiple process example
  • Add Session ID or something like that
  • Benchmark TCP Event <> TCP Loop

LIMITATIONS

  • Your code must contain engine code.
  • All of your pages must be functions ( for now, I plan to make something different with an array soon )
  • All au3 code must be added in. You can btw use external files to make more. AutoIt can’t compile code on the fly (as php does ), so your “listener” must be fully stopped and restarted to test changes.
  • Doesn’t support session id ( for now )

DOWNLOAD

http://www.2shared.com/file/UmS1x9Hv/FastCGI.html

Edited by arcker

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]

Share this post


Link to post
Share on other sites
davidkim

#include "F:AuCGIhtdocsindex.au3"

#include "F:AuCGIhtdocsRequest_data.au3"

#include "F:AuCGIhtdocsGet_results.au3"

#include "F:AuCGIhtdocsindex_test.au3"

4 file where?


I interest am many quite in AutoitScript.From that is [http://cafe.naver.com/autoitscript[/color]] Korea of cafe(blog) to be operating, [size="2"][color="#ff00ff"]English cannot well[/size].Many help it requests.To read, it stands it thanks.

Share this post


Link to post
Share on other sites
arcker

#include "F:AuCGIhtdocsindex.au3"

#include "F:AuCGIhtdocsRequest_data.au3"

#include "F:AuCGIhtdocsGet_results.au3"

#include "F:AuCGIhtdocsindex_test.au3"

4 file where?

Don't use au3_fastcgi_server, prefer use au3_fastcgi_lite.au3

you can remove those, they are other test pages ;)

will post update asap.

Edited by arcker

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]

Share this post


Link to post
Share on other sites
davidkim

How to use $_FILES Global Var?

i'm use code...

<?php
 $error = "";
 $msg = "";
 $fileElementName = 'fileToUpload';
 if(!empty($_FILES[$fileElementName]['error']))
 {
  switch($_FILES[$fileElementName]['error'])
  {

   case '1':
    $error = 'The uploaded file exceeds the upload_max_filesize directive in php.ini';
    break;
   case '2':
    $error = 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form';
    break;
   case '3':
    $error = 'The uploaded file was only partially uploaded';
    break;
   case '4':
    $error = 'No file was uploaded.';
    break;

   case '6':
    $error = 'Missing a temporary folder';
    break;
   case '7':
    $error = 'Failed to write file to disk';
    break;
   case '8':
    $error = 'File upload stopped by extension';
    break;
   case '999':
   default:
    $error = 'No error code avaiable';
  }
 }elseif(empty($_FILES['fileToUpload']['tmp_name']) || $_FILES['fileToUpload']['tmp_name'] == 'none')
 {
  $error = 'No file was uploaded..';
 }else
 {
   $msg .= " File Name: " . $_FILES['fileToUpload']['name'] . ", ";
   $msg .= " File Size: " . @filesize($_FILES['fileToUpload']['tmp_name']);
   //for security reason, we force to remove all uploaded file
   @unlink($_FILES['fileToUpload']);  
 }  
 echo "{";
 echo    "error: '" . $error . "',n";
 echo    "msg: '" . $msg . "'n";
 echo "}";
?>

 

how convert FASTCGI code??

Edited by davidkim

I interest am many quite in AutoitScript.From that is [http://cafe.naver.com/autoitscript[/color]] Korea of cafe(blog) to be operating, [size="2"][color="#ff00ff"]English cannot well[/size].Many help it requests.To read, it stands it thanks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • ur
      By ur
      Is there any UDF to remove all anchor tags <a> with a particular class (and also its sub elements completely) in a html document.
      Here the classes are browse and breadcrumbs
      Like in the below image.


       
      I am not able to find that option in IE.au3
       
      Please suggest.
    • milkmoron
      By milkmoron
      I am trying to automate something in a web browser but i need some help with finding the html code to a web applet. How do I access the code.
    • Seminko
      By Seminko
      Is there a way to grab non-hardcoded but rather javascript generated data from a webpage?
      Tried a get request as well as _IEBodyReadHTML but both seem to grab the code without the javascript generated data.
      $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", "link", False) $oHTTP.Send() $oReceived = $oHTTP.ResponseText $oStatusCode = $oHTTP.Status Global $DataArray[10][5] If $oStatusCode <> 200 Then Exit MsgBox(1, "Error", "Status Code <> 200") EndIf FileWrite(@ScriptDir & "\output.txt", $oReceived) ; //////// #include <IE.au3> Local $FullLink = "link" Local $oIE = _IECreate($FullLink, 0, 0) _IELoadWait($oIE) Local $sText = _IEBodyReadHTML($oIE) FileWrite(@ScriptDir & "\output.txt", $sText)  
    • SkysLastChance
      By SkysLastChance
       
      WinActivate("MEDITECH - Internet Explorer") Sleep (500) $oIE = _IEAttach("MEDITECH") $oDiv1 = _IEGetObjById($oIE, "sysmenu-searchbarbutton") _IEAction($oDiv1, "click") I am just trying to click the little magnifying glass, next to the gear button with no luck. I was hoping someone might have an idea why this is not working?
       

    • Burgs
      By Burgs
      Hello,
        I have a website with a Google Map I setup using the Google Map API.  It works and displays just fine.  However to make it useful to me I need to be able to dynamically change the map to display different areas by sending new Latitude and Longitude coordinates.  I am having difficulty making this happen.  Here is my code thus far:
      #include <IE.au3> $oIE3 = _IECreate("http://my_sample_website.html") ;just an example, not an actual site... _IELoadWait($oIE3) $s_word = "lat:" $oInputs = _IETagNameAllGetCollection($oIE3) if @error <> 0 Then MsgBox($MB_SYSTEMMODAL, "ERROR", "Error is: " & @error) EndIf ;@error For $oInput In $oInputs if Number($iPos) == -1 Then $iPos = StringInStr($oInput.innerHTML, String($s_word)) if (Number($iPos) > 0) AND (@error == 0) Then ConsoleWrite("I FOUND IT...! " & String($s_word) & @CRLF) $sHTML = _IEBodyReadHTML($oIE3) $_lat_look = 0 $_lng_look = 0 $_end_look = 0 ;default $_lat_look = StringInStr(String($sHTML), "lat:") if Number($_lat_look) <> 0 Then $_lng_look = StringInStr(String($sHTML), "lng:") if Number($_lng_look) <> 0 Then $_end_look = StringInStr(String($sHTML), "}") if Number($_end_look) <> 0 Then ConsoleWrite("HTML BODY: " & $sHTML & @CRLF) $_old_lat = String(StringMid(String($sHTML), $_lat_look, ($_lng_look - $_lat_look))) $_old_lng = String(StringMid(String($sHTML), $_lng_look, ($_end_look - $_lng_look))) ConsoleWrite("$_old_lat: " & $_old_lat & @CRLF) ConsoleWrite("$_old_lng: " & $_old_lng & @CRLF) $_new_lat = "lat: " & String("-34.397") & ", " $_new_lng = "lng: " & String("150.644") & "}; " ConsoleWrite("...new lat is: " & String($_new_lat) & " new lng is: " & String($_new_lng) & @CRLF) $_LOOK = StringReplace($_old_lat, 1, String($_new_lat)) $_LOOK2 = StringReplace($_old_lng, 1, String($_new_lng)) ConsoleWrite("$_LOOK: " & $_LOOK & "$_LOOK2: " & $_LOOK2 & @CRLF) EndIf ;'$_end_look' NOT "0"... $iPos = -1 EndIf ;'String($s_word)' was found in the collection '$oInputs' EndIf ;'$iPos' is "-1" Next  
        I am having trouble trying to replace the line in the HTML ($sHTML variable in my example) that contains the "lat:" and "lng:" information.  I figure if I can replace that line everything else remains the same, and in theory, the map should cycle to display a map with the new latitude and longitude coordinates...I hope. 
        I have attempted to write the $sHTML to a text document and then use '_IEBodyWriteHTML' to read it back into the webpage HTML however that is not working.  There must be an easier method to accomplish this...what am I missing here...?  Any thoughts greatly appreciated.  Regards.       
×