BBS水木清华站∶精华区

发信人: xcec (money), 信区: Linux 
标  题: guestbook-->guanli.cpp 
发信站: BBS 水木清华站 (Mon Jan 17 13:12:21 2000) WWW-POST 
 
#include <iostream.h> 
#include <stdlib.h> 
#include <ctype.h> 
#include <string.h> 
#include "datafile.h" 
#include "cgi.h" 
 
#define PASSWORD "xxxxxx" 
 
void printerror(void); 
 
int main() 

    CGI cgi; 
 
    if (cgi.argnum < 1) { 
printerror(); 
        return 1; 
    } 
 
    if ( strcmp(cgi.namevalue[0].value, PASSWORD) ) { 
printerror(); 
return 1; 
    } 
 
    char *p = cgi.namevalue[1].value; 
    while ( *p && isdigit(*p) ) 
p++; 
    if ( *p ) { 
printerror(); 
return 1; 
    } 
 
    DATAFILE datafile; 
    datafile.del_record( atoi(cgi.namevalue[1].value) ); 
 
    cout<<"Content-Type: text/html\n\n"; 
    cout<<"<html>"<<endl; 
    cout<<"<head>"<<endl; 
    cout<<"<title></title>"<<endl; 
    cout<<"<meta http-equiv=refresh content=\"0;url=guestbook.cgi\">"<<endl; 
    cout<<"</head>"<<endl; 
    cout<<"<body>"<<endl; 
    cout<<"<p>"<<endl; 
    cout<<"<p><a href=\"guestbook.cgi\"></a>"<<endl; 
    cout<<"</body></html>"<<endl; 
    return 0; 

 
void printerror(void) 

    cout<<"Content-Type: text/html\n\n"; 
    cout<<"<html>"<<endl; 
    cout<<"<head>"<<endl; 
    cout<<"<title></title>"<<endl; 
    cout<<"</head>"<<endl; 
    cout<<"<body>"<<endl; 
    cout<<"<p>, "<<endl; 
    cout<<"<p><a href=\"guanli.html\"></a>"<<endl; 
    cout<<"</body></html>"<<endl; 

 
-- 
※ 来源:·BBS 水木清华站 smth.org·[FROM: 162.105.33.162]  

BBS水木清华站∶精华区