Page 1 sur 1

Traduction en pure code parametres CGI

Publié : dim. 13/mars/2011 20:03
par Kwai chang caine
Bonjour à tous

Excusez moi de vous deranger dans une rubrique ou j'ai rien à y foutre :oops:

Mais le gentil FREEPUREBASIC m'a donné un code en ASM qui permet de récupérer les paramètres d'un appel CGI
http://www.purebasic.fr/english/viewtop ... 78#p348778
J'ai trouvé ça génial
Il m'a donné aussi le ZIP tout prêt, alors je suppose que ce code est le source de l'EXE

Code : Tout sélectionner

format pe console
include 'win32ax.inc'

.data

_message        db 'Content-Type: text/html',10,'Ciao Chane!',13,10
_message.len    = $ - _message

.code

begin:
        push    eax
        invoke  GetStdHandle,STD_OUTPUT_HANDLE
        mov     ecx,esp
        invoke  WriteFile,eax,_message,_message.len,ecx,0
        pop     eax
        invoke  ExitProcess,0

.end begin
Je voudrais savoir si ce code peut se traduire en PB ????
Et aussi si j'ai bien compris ou bien me suis je encore roulé dans la fange :oops:

Merci et bonne journée

Re: Traduction en pure code parametres CGI

Publié : dim. 13/mars/2011 20:55
par djes

Code : Tout sélectionner

OpenConsole()
WriteConsoleData(?MESSAGE, ?MESSAGE_FIN - ?MESSAGE)
End
DataSection
MESSAGE:
Data.b "Content-Type: text/html",10,"Ciao Chane!",13,10
MESSAGE_FIN:

Re: Traduction en pure code parametres CGI

Publié : dim. 13/mars/2011 21:04
par Kwai chang caine
DJES....t'es beau, t'es bon, t'es gentil....
T'es marié ??? j'ai le droit à la bigamie ???? :lol:

Mille merci sincerement 8)

Alors si je comprend bien, en fait je ne comprend pas...comme dab :oops:
C'est pour ça que je voulais une traduction PB, parce que l'ASM, je comprend pas une ligne malgré que je trouve ça splendide 8O
Ou il est le texte que je passe en paramètre après le ?

Ce code a donc rien a voir avec l'exe que FREEPUREBASIC m'a fait essayé ?? :roll:
Nadine boudin ce WEB, j'ai pas commencé que je le déteste deja...on dirait du microsoft :lol:

Re: Traduction en pure code parametres CGI

Publié : dim. 13/mars/2011 21:04
par Warkering
Petite question comme ça, il est normal de fermer son label ainsi? Je veux dire, c'est une spécificité de Fasm? Car je n'ai jamais vu cela en Nasm.

Re: Traduction en pure code parametres CGI

Publié : dim. 13/mars/2011 21:25
par djes
Warkering a écrit :Petite question comme ça, il est normal de fermer son label ainsi? Je veux dire, c'est une spécificité de Fasm? Car je n'ai jamais vu cela en Nasm.
Quel label?

Re: Traduction en pure code parametres CGI

Publié : dim. 13/mars/2011 21:32
par Warkering
Le «begin». Il le termine avec un «.end begin». :?:

Re: Traduction en pure code parametres CGI

Publié : lun. 14/mars/2011 9:12
par djes
Bah! Je pense que le .end est un mot clé (comme .code ou .data qui définissent des sections) ; ce qu'il y a après ne doit pas être pris en compte par le parser, donc tu mets ce que tu veux. Je dis ça sans avoir vérifié, hein. Déjà quand tu vois des 'invoke', tu peux être sûr qu'il y a des macros et tout un tas de bidules pour faciliter le code, et qu'il ne faut pas en faire un fromage.

Re: Traduction en pure code parametres CGI

Publié : lun. 14/mars/2011 21:24
par Droopy
Tu peux récupérer cela via les variables d'environnement : cf fonction de Purebasic 'GetEnvironmentVariable('

Code : Tout sélectionner

Structure CommonGatewayInterface
  AuthType.s
  ContentLength.i
  ContentType.s
  DocumentRoot.s
  GatewayInterface.s
  PathInfo.s
  PathTranslated.s
  QueryString.s
  RemoteAddr.s
  RemoteHost.s
  RemoteIdent.s
  RemotePort.s
  RemoteUser.s
  RequestURI.s
  RequestMethod.s
  ScriptName.s
  ScriptFilename.s
  ServerAdmin.s
  ServerName.s
  ServerPort.s
  ServerProtocol.s
  ServerSignature.s
  ServerSoftware.s
  HTTPAccept.s
  HTTPAcceptEncoding.s
  HTTPAcceptLanguage.s
  HTTPCookie.s
  HTTPForwarded.s
  HTTPHost.s
  HTTPPragma.s
  HTTPReferer.s
  HTTPUserAgent.s
  
  PostData.s
EndStructure

Global cgi.CommonGatewayInterface

Procedure GetCGIVariables() 
  
  ;/ AUTH_TYPE - Describes the authentication method used by the web browser If any authentication method was used. This is Not set unless the script is Protected.
  cgi\AuthType = GetEnvironmentVariable("AUTH_TYPE")
  
  ;/ CONTENT_LENGTH - This is used For scripts that are receiving form Data using the POST method. This variable tells the byte length of the CGI input Data stream. This is required To Read the Data from the standard input With the POST method.
  cgi\ContentLength = Val(GetEnvironmentVariable("CONTENT_LENGTH"))
  
  ;/ CONTENT_TYPE - Tells the media type of Data being received from the user. this is used For scripts called using the POST method.
  cgi\ContentType = GetEnvironmentVariable("CONTENT_TYPE")
  
  ;/ DOCUMENT_ROOT - The root path To the home HTML page For the server. Example: /home/httpd/html
  cgi\DocumentRoot = GetEnvironmentVariable("DOCUMENT_ROOT")
  
  ;/ GATEWAY_INTERFACE - The version of the common gateway Interface (CGI) specification being used To exchange the Data between the client And server. this is normally CGI/1.1 For the current revision level of 1.1. Example:   CGI/1.1
  cgi\GatewayInterface = GetEnvironmentVariable("GATEWAY_INTERFACE")
  
  ;/ PATH_INFO - Extra path information added To the End of the URL that accessed the server side script program.
  cgi\PathInfo = GetEnvironmentVariable("PATH_INFO")
  
  ;/ PATH_TRANSLATED - A translated version of the PATH_INFO variable translated by the webserver from virtual To physical path information.
  cgi\PathTranslated = GetEnvironmentVariable("PATH_TRANSLATED")
  
  ;/ QUERY_STRING - This string contains any information at the End of the server side script path that followed a question mark. Used To Return Data If the GET method was used by a form. There are length restrictions To the QUERY_STRING. Example of how To set it in HTML:
  ; <A HREF="/cgi-bin/hits.pl?mainpage></A>
  ; The information after the ? is the QUERY_STRING which is "mainpage" in this Case. How it looks on the server side mainpage
  cgi\QueryString = GetEnvironmentVariable("QUERY_STRING")
  
  ;/ REMOTE_ADDR - The IP address of the client computer. Example: 132.15.28.124
  cgi\RemoteAddr = GetEnvironmentVariable("REMOTE_ADDR")
  
  ;/ REMOTE_HOST - The fully qualified domain name of the client machine making the HTTP request. It may Not be possible To determine this name since many client computers names are Not recorded in the DNS system. Example: comp11.mycompanyproxy.com
  cgi\RemoteHost = GetEnvironmentVariable("REMOTE_HOST")
  
  ;/ REMOTE_IDENT - The ability To use this variable is limited To servers that support RFC 931. This variable may contain the client machine's username, but it is intended to be used for logging purposes only, when it is available.
  cgi\RemoteIdent = GetEnvironmentVariable("REMOTE_IDENT")
  
  ;/ REMOTE_PORT - The clients requesting port. An example: 3465
  cgi\RemotePort = GetEnvironmentVariable("REMOTE_PORT")
  
  ;/ REMOTE_USER - If the CGI script was Protected And the user had To be logged in To get access To the script, this value will contain the user's log in name
  cgi\RemoteUser = GetEnvironmentVariable("REMOTE_USER")
  
  ;/ REQUEST_URI - The path To the requested file by the client. An example: /cgi-bin/join.pl?button=on
  cgi\RequestURI = GetEnvironmentVariable("REQUEST_URI")
  
  ;/ REQUEST_METHOD - This describes the request method used by the browser which is normally GET, POST, Or HEAD.
  cgi\RequestMethod = GetEnvironmentVariable("REQUEST_METHOD")
  
  ;/ SCRIPT_NAME - The virtual path of the CGI script being executed. Example: /cgi-bin/join.pl
  cgi\ScriptName = GetEnvironmentVariable("SCRIPT_NAME")
  
  ;/ SCRIPT_FILENAME - Example: /home/httpd/cgi-bin/join.pl
  cgi\ScriptFilename = GetEnvironmentVariable("SCRIPT_FILENAME")
  
  ;/ SERVER_ADMIN - The e-mail address of the server administrator. Example: webadmin@myhost.mycompany.org
  cgi\ServerAdmin = GetEnvironmentVariable("SERVER_ADMIN")
  
  ;/ SERVER_NAME - The server hostname, IP address Or DNS alias name shown As a self referencing URL. This does Not include the protocol identifier such As "HTTP:", the machine name, Or port number. Example: myhost
  cgi\ServerName = GetEnvironmentVariable("SERVER_NAME")
  
  ;/ SERVER_PORT - The port number the HTTP requests And responses are being sent on. Example: 80
  cgi\ServerPort = GetEnvironmentVariable("SERVER_PORT")
  
  ;/ SERVER_PROTOCOL - This value is normally HTTP which describes the protocol being used between the client And server computers. Example: HTTP/1.1
  cgi\ServerProtocol = GetEnvironmentVariable("SERVER_PROTOCOL")
  
  ;/ SERVER_SIGNATURE - Server information specifying the name And version of the web server And the port being serviced. Example: Apache/1.3.12 Server at mdct-dev3 Port 80
  cgi\ServerSignature = GetEnvironmentVariable("SERVER_SIGNATURE")
  
  ;/ SERVER_SOFTWARE - The name And version of the web server. Example: Apache/1.3.12 (Unix) (Red Hat/Linux) PHP/3.0.15 mod_perl/1.21
  cgi\ServerSoftware = GetEnvironmentVariable("SERVER_SOFTWARE")
  
  ;/ HTTP_ACCEPT - The media types of Data that the client browser can accept. these Data types are separated by commas. An example:
  ; image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/msword, application/vnd.ms-powerpoint, */*
  cgi\HTTPAccept = GetEnvironmentVariable("HTTP_ACCEPT")
  
  ;/ HTTP_ACCEPT_ENCODING An example: gzip, deflate
  cgi\HTTPAcceptEncoding = GetEnvironmentVariable("HTTP_ACCEPT_ENCODING")
  
  ;/ HTTP_ACCEPT_LANGUAGE - The language the client browser accepts. Example: en-us
  cgi\HTTPAcceptLanguage = GetEnvironmentVariable("HTTP_ACCEPT_LANGUAGE")
  
  ;/ HTTP_COOKIE - Used As an environment variable that contains cookies associated With the server domain from the browser.
  cgi\HTTPCookie = GetEnvironmentVariable("HTTP_COOKIE")
  
  ;/ HTTP_FORWARDED An example: by http://proxy-nt1.yourcompany.org:8080 (Netscape-Proxy/3.5)
  cgi\HTTPForwarded = GetEnvironmentVariable("HTTP_FORWARDED")
  
  ;/ HTTP_HOST An example: yourwebhost.yourcompany.org
  cgi\HTTPHost = GetEnvironmentVariable("HTTP_HOST")
  
  ;/ HTTP_PRAGMA - An example: No-Cache
  cgi\HTTPPragma = GetEnvironmentVariable("HTTP_PRAGMA")
  
  ;/ HTTP_REFERER - The page address where the HTTP request originated. An example: http://ctdp.tripod.com/independent/web/cgi/cgimanual/index.html
  cgi\HTTPReferer = GetEnvironmentVariable("HTTP_REFERER")
  
  ;/ HTTP_USER_AGENT - The name of the client web browser being used To make the request. Example: Mozilla/4.0 (compatible; MSIE 4.01; Windows 95)
  cgi\HTTPUserAgent = GetEnvironmentVariable("HTTP_USER_AGENT")
  
EndProcedure 
 
  
  



Re: Traduction en pure code parametres CGI

Publié : lun. 14/mars/2011 21:58
par Kwai chang caine
J'suis drolement content de te parler, ça me rappelle mon arrivée ici :D

Bon je vais essayer, c'est pas gagné, j'ai vu que toi t'avais tout compris, moi j'avance petit à petit, mais la route est encore longue. :?
Le problème c'est qu'avec l'anglais en plus quand c'est un sujet ou tu viens pour la première fois d'y mettre le nez ...c'est pas facile.
Mais je doit reconnaitre que AND51 et FREEPUREBASIC pour le coté US ont été des anges

Heureusement aussi que DJES ce fait un c.. comme ça pour que je comprenne, avec toi en plus...si j'y arrive pas ..ça va devenir indécent :oops:

Quatre bons programmeurs pour une burne .....tiens...on dirait un nom de western :mrgreen: :lol:

Merci mille fois DROOPY 8)