Results 1 to 13 of 13

Thread: php and C++

  1. #1

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919

    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?

  2. #2

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    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?

  3. #3
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    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.

  4. #4

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    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?

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    And the header file...
    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

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  8. #8

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    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?

  9. #9
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  10. #10

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    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?

  11. #11

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    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?

  12. #12
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  13. #13

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    ohhh ok

    thanks
    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
  •  



Click Here to Expand Forum to Full Width