大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 技术开发 -> CGI专区 -> CGI教程(8)记录用户记录脚本之二

CGI教程(8)记录用户记录脚本之二

时间: 2021-07-31 作者:daque

记委派户记载剧本//以次是mas_res步调#include "t99_type.h"#include #include #include #include #include #include #include #include "parse.h"#include "parse.cpp"#include "mas_cvo.cpp"void write_log_entry( char[], char[] );void cgi_var_output();char* getenv_n( char [] );void gif_output( char [] );int main(){char *query_str = getenv("query_string");parse list( query_str == 0 ? (char*)"file=mas&page=test&" : query_str );if ( list.get_item( "file" ) != null ){write_log_entry( list.get_item_n( "file", 1, true ),list.get_item_n( "page" ) );}if ( list.get_item( "img" ) != null ){gif_output( list.get_item_n("img", 1, true) );} else {html("content-type: text/html"); html("");cgi_var_output(); // debug option}return 0;} void write_log_entry( char file[], char page[] ){//cout << "file = [" << file << "] page = [" << page << "]" << "\n";//cout.flush();ofstream inf( file, ios::app );//inf.open( file, ios::out );if ( !inf.fail() ){time_t t;time( &t);char *str = ctime( &t ); str[24] = '\0';inf << setiosflags( ios::left );inf << setw(24) << str << " " <<setw(10) << (page!=null? page : (char*)"unknown" ) << " " <<setw(18) << getenv_n("remote_addr") << " " <<setw(20) << getenv_n("remote_host") << "\n";// setw(20) << getenv_n("remote_user") << "\n";}}void gif_output( char gif[] ){char square [] = {'g', 'i', 'f', '8', '9', 'a', 0002, 0000, 0002, 0000, 0263, 0000, 0000, 0000, 0000, 0000,0277, 0000, 0000, 0000, 0277, 0000, 0277, 0277,0000, 0000, 0000, 0277, 0277, 0000, 0277, 0000,0277, 0277, 0300, 0300, 0300, 0200, 0200, 0200,0377, 0000, 0000, 0000, 0377, 0000, 0377, 0377,0000, 0000, 0000, 0377, 0377, 0000, 0377, 0000,0377, 0377, 0377, 0377, 0377, 0054, 0000, 0000,0000, 0000, 0002, 0000, 0002, 0000, 0100, 0004,0003, 0020, 0200, 0010, 0000, 0073 };html("content-type: image/gif"); html("");if ( gif[0] != '\0' ) // 输入gif文献{ifstream in( gif );if ( !in.fail() ) { char c;in.read( &c, 1 );while ( !in.eof() ){cout.write( &c, 1 );in.read( &c, 1 );}return; // 中断}}cout.write( square, (int) sizeof( square ) );}  固然,网页的欣赏器必需是扶助欣赏图片以及承载图片的。几个不许承载图片的来由是:  欣赏器不扶助图片欣赏;  用户仍旧废除对欣赏图片的选项,由于要加块贯穿搜集效劳器的速率;  效劳器件接受到归来图片的乞求。

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.