Sign in to follow this  
Followers 0
arcker

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

4 posts in this topic

#1 ·  Posted (edited)

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



#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

#3 ·  Posted (edited)

#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

#4 ·  Posted (edited)

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  
Followers 0

  • Similar Content

    • FrancescoDiMuro
      By FrancescoDiMuro
      Good evening everyone
      Before all, I want to say that I'm doing this script to see how _IE* functions work, and see if my studs can hack a quiz I'm working on.
      I want to clarify that I'm not automating any game, bypassing any CAPTCHAs, or anything that could damage anyone.
      I was trying to autofill a form, based on which question is displayed.
      The question is always stored in here:
      <header> <h1><span class="questionid">1. </span>Here goes the question</h1> </header> And answers are stored in here:
      <ul class="answers"> <li><label><span><input id="answer_0" name="answer[]" type="radio" value="0">Answer 1</span></label></li> <li><label><span><input id="answer_1" name="answer[]" type="radio" value="1">Answer 2</span></label></li> <li><label><span><input id="answer_2" name="answer[]" type="radio" value="2">Anwser 3</span></label></li> <li><label><span><input id="answer_3" name="answer[]" type="radio" value="3">Answer 4</span></label></li> </ul></fieldset></form></div> And, there are 15 questions like this.
      How can automatically fill my form?
      Thanks in advance
      Francesco
    • houser747
      By houser747
      I have previously used _IEFormElementGetObjByName and _IEFormElementSetValue to enter text into a search box on a form and then submit the form.
      I am now trying to enter text into a search box which is not part of a form. 
      Here is the HTML from the website that i'm trying to enter the data on and then submit the search.
      <div class="row">
          <div class="form-group col-xs-12">
              <span id="FullWidthWithSubmenuContent_FullWidthContent_MainContent_AircraftRegistry_lblSearchText" for="input-search">Registreringsbeteckning</span>
              <div class="input-group col-xs-12">
                  <span id="FullWidthWithSubmenuContent_FullWidthContent_MainContent_AircraftRegistry_preSearchText" class="input-group-addon">SE -</span>
                  <input name="ctl00$FullWidthWithSubmenuContent$FullWidthContent$MainContent$AircraftRegistry$txtSearchText" type="text" value="DTH" id="FullWidthWithSubmenuContent_FullWidthContent_MainContent_AircraftRegistry_txtSearchText" class="form-control" />
              </div>
          </div>
      </div>
      <div class="row">
          <div class="form-group col-xs-12">
              <label class="sr-only" for="">Sök</label>
              <input type="submit" name="ctl00$FullWidthWithSubmenuContent$FullWidthContent$MainContent$AircraftRegistry$btnSearch" value="Sök" id="FullWidthWithSubmenuContent_FullWidthContent_MainContent_AircraftRegistry_btnSearch" class="btn btn-primary ladda-button" data-style="expand-right" />
          </div>
      </div>
      Many thanks in advance
      cheers
      Roger
    • SkysLastChance
      By SkysLastChance
      #include <IE.au3> #include <MsgBoxConstants.au3> Local $oIE = _IECreate("website") Local $oForms = _IEFormGetCollection($oIE) For $oForm In $oForms MsgBox($MB_SYSTEMMODAL, "Form Info", $oForm.name) _IEImgClick($oForm.name, "Reserved.ReportViewerWebControl.axd?OpType=Resource&amp;Version=12.0.5522.0&amp;Name=Microsoft.ReportingServices.Rendering.HtmlRenderer.RendererResources.TogglePlus.gif", "src") Next I am having trouble clicking an image. Here is what I have tried. 

    • Jefrey
      By Jefrey
      I've made this HTTP lib to simplify HTTP requests, mainly when dealing about POST data or file uploads.
      Three functions are available:
      string _HTTP_Get ( string $sURL ) string _HTTP_Post ( string $sURL , string $sPostData ) string _HTTP_Upload ( string $sURL , string $sFilePath , string $sFileField , string $sPostData = '' , string $sFilename = Default) Additionaly, two helper functions are also available:
      URLEncode($sStr) URLDecode($sStr) Full documentation: https://github.com/jesobreira/HTTP.au3/blob/master/README.md
      Fork me on Github: https://github.com/jesobreira/HTTP.au3
      Download lib + docs: https://github.com/jesobreira/HTTP.au3/archive/master.zip
    • mjolnirmarkiv
      By mjolnirmarkiv
      Hi!
      Does anyone have any idea why Test() returns 0, while Test2() returns 1?
      #include <IE.au3> MsgBox(0, "", Test() & " " & Test2()) Func Test() Local $oHTML = ObjCreate("HTMLFILE") $oHTML.body.innerHTML = FileRead("Test.html") Return IsObj($oHTML.getElementsByClassName("example")) EndFunc Func Test2() Local $oIE = _IEAttach("", "instance", 1) Return IsObj($oIE.document.getElementsByClassName("example")) EndFunc Sample Test.html I open in IE before testing:
      <!DOCTYPE html> <html> <body> <p class="example"></p> <div class="example"></div> </body> </html> I'm receiving html text in a response to http request, I need to parse it fast and easy, getElementsByClassName would have been ideal. I'm using 3.3.12.0 version.