Bool_t gApacheExec=kTRUE; Bool_t gApacheRedirectStdout=kTRUE; Bool_t gApacheDebug=kTRUE; char* gApacheExecFunc="HelloWorld()"; #include #include void ALLVars() { TApache ap; ap.SetCookie("cookie_test",Form("%d",gSystem->Getenv("DATE_LOCAL"))); // cookie must be set before any output // ap.SetNoCache(); //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* //*-* //*-* This macro demonstrates: //*-* - how to embed HTML code into C++ //*-* - how to get a value of CGI variable //*-* //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* // start of embedded HTML code /* How to get CGI variables
*/ // ap.SendHttpTrace(); /*
*/ // end of embedded HTML code { TList* li = ap.GetVars("CGI"); TIter next(li); TObject* obj; const char* varname; const char* value; int i = 0; ap.Printf(""); ap.Printf(""); while((obj=next())) { i++; varname = obj->GetName(); value = gSystem->Getenv(varname); if(!value || !strlen(value)) value = " "; ap.Printf("",!(i%2) ? "cornsilk" : "white", varname); ap.Printf("",value); } } { TList* li = ap.GetVars("GET"); TIter next(li); TObject* obj; const char* varname; const char* value; int i = 0; ap.Printf(""); ap.Printf(""); while((obj=next())) { i++; varname = obj->GetName(); value = gSystem->Getenv(varname); if(!value || !strlen(value)) value = " "; ap.Printf("",!(i%2) ? "cornsilk" : "white", varname); ap.Printf("",value); } } { TList* li = ap.GetVars("POST"); TIter next(li); TObject* obj; const char* varname; const char* value; int i = 0; ap.Printf(""); ap.Printf(""); while((obj=next())) { i++; varname = obj->GetName(); value = gSystem->Getenv(varname); if(!value || !strlen(value)) value = " "; ap.Printf("",!(i%2) ? "cornsilk" : "white", varname); ap.Printf("",value); } } { TList* li = ap.GetVars("COOKIE"); TIter next(li); TObject* obj; const char* varname; const char* value; int i = 0; ap.Printf(""); ap.Printf(""); while((obj=next())) { i++; varname = obj->GetName(); value = gSystem->Getenv(varname); if(!value || !strlen(value)) value = " "; ap.Printf("",!(i%2) ? "cornsilk" : "white", varname); ap.Printf("",value); } } { TList* li = ap.GetVars("FILE"); TIter next(li); TObject* obj; const char* varname; const char* value; int i = 0; ap.Printf(""); ap.Printf(""); while((obj=next())) { i++; varname = obj->GetName(); value = gSystem->Getenv(varname); if(!value || !strlen(value)) value = " "; ap.Printf("",!(i%2) ? "cornsilk" : "white", varname); ap.Printf("",value); TApacheUploadedFile *tauf = dynamic_cast(obj); fseek(tauf->GetFP(), 0, SEEK_END); ap.Printf("tauf size: %ld\n", ftell(tauf->GetFP())); } } ap.Flush(); // start of embedded HTML code /*
CGI variables
CGI Vars
NAMEVALUE
%s%s
GET Vars
NAMEVALUE
%s%s
POST Vars
NAMEVALUE
%s%s
Cookie Vars
NAMEVALUE
%s%s
FILE Vars
NAMEVALUE
%s%s

To embed HTML into C++ code use / *<html> </html>* / tags


To get CGI variable use gSystem->Getenv(varname);


*/ // end of embedded HTML code }