|
-
Dec 25th, 2001, 09:21 PM
#1
Thread Starter
Fanatic Member
php and C++
with my version of OmniHTTPd, in the cgi-bin, theres a couple of programs, which in the readme, says they're written in C++.
the program generates an image of the counter, with the current number of hits. i attached the readme, incase you dont know what i mean
how do you write CGI-Executables in C++?
the person said he has the full-source on his page, but the page was down.
also, my other question
http://www.vbforums.com/showthread.p...hreadid=129496
thanks
-nabeel
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Dec 25th, 2001, 09:24 PM
#2
Thread Starter
Fanatic Member
just adding the attachment
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Dec 26th, 2001, 08:03 AM
#3
Black Cat
Just write "Content-type: text/html\n\n" to STANDARD OUTPUT and then your HTML data.
Code:
#include <stdio.h>
#include <stdlib.h>
main() {
char *chRM;
char *chQS;
chRM = getenv("HTTP_USER_AGENT");
//check for NULL or we'll get at error with printf
if (chRM == NULL) {
chRM = "NONE";
}
chQS = getenv("QUERY_STRING");
if (chQS == NULL) {
chQS = "NONE";
}
printf("Content-type: text/html\n\n");
printf("<html>\n");
printf("<head><title>CGI Test</title></head>\n");
printf("<body>\n");
printf("<p>Hello World!\n");
printf("<br><b>HTTP_USER_AGENT:</b> ");
printf(chRM);
printf("<br><b>QUERY_STRING:</b> ");
printf(chQS);
printf("</p>\n");
printf("</body>\n");
printf("</html>\n");
return 0;
}
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
-
Dec 26th, 2001, 11:09 AM
#4
Thread Starter
Fanatic Member
ah cool
thanks man
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Dec 26th, 2001, 06:27 PM
#5
Monday Morning Lunatic
This is quite old so it's not the greatest code around - I can see some obvious optimisations it can have (not to mention some things which are evil enough to demand a rewrite), but I don't really need it anymore so I'm sure you can manage it nicely 
So Ked, no jumping down my throat about any of it, k?
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Dec 26th, 2001, 06:29 PM
#6
Monday Morning Lunatic
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Dec 26th, 2001, 06:38 PM
#7
transcendental analytic
spreading evil code around again parksie? where's the headerfile`?
*prepares to write a load of comments* j/k
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Dec 26th, 2001, 07:52 PM
#8
Thread Starter
Fanatic Member
yah, u forgot the header file
so, i just add it to my project and since its a class, i just declare and use it?
cool-o.
optimizations: err i have no clue. but that's ok im horrible at C++
how would i process a parameter that is passed? lets say
cgiexetext.exe?URL=http://www.hotmail.com
just check for it through the void main(int argc, char *argv[]) way? like retrive it then parse it?
thx guys
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Dec 27th, 2001, 05:30 AM
#9
Monday Morning Lunatic
Sorry I couldn't get onto VBW last night very well, and I thought it had attached it but obviously not (you might notice that this was one of my last posts yesterday).
Anyway, I didn't forget - see my post above 
Code:
CLibCGI CGI;
string keyword;
CGI.Setup();
keyword = CGI.GetValueFromName("keyword");

I admit, something like this would have been better:
Code:
CLibCGI CGI;
keyword = CGI["keyword"];
But remember, I wrote this in Feb 2000 so it's getting VERY old now
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Dec 27th, 2001, 11:10 AM
#10
Thread Starter
Fanatic Member
heh. cool thanks. so i would do
Code:
CLibCGI CGI;
string URL;
CGI.Setup();
URL = CGI.GetValueFromName("URL");
and then from there i can do what i want/need?
thanks for the help!
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Dec 27th, 2001, 11:41 AM
#11
Thread Starter
Fanatic Member
ok i tried it like you said, and it gives an error, and it wants to send an error report to microsoft. (running win xp)
but, when i take out the CGILib stuff, it works fine, it outputs.
Code:
//#include "libcgi.cpp"
#include "libcgi.h"
void main(int argc, char *argv[]){
CLibCGI cgi;
string URL;
cgi.Setup();
printf("Content-type: text/html\n\n");
printf("<html><head><title>Forwarding...</title></head>\n\n");
URL = cgi.GetValueFromName("site");
if(URL.length == 0){
printf("<body>");
printf("No URL was specified<br>\n\n");
printf("</body></html>");
}
else{
printf("<script>window.location = %c%s%c;</script>\n\n",39,URL,39);
printf("</body></html>");
}
}
thanks
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Dec 28th, 2001, 08:25 AM
#12
Monday Morning Lunatic
Don't include the .cpp file - you compile that separately and link it in.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Dec 28th, 2001, 11:51 AM
#13
Thread Starter
Fanatic Member
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|