记录用户记录脚本
//以下是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 ) );
}
当然,网页的浏览器必须是支持浏览图片以及装载图片的。几个不能装载图片的理由是:
浏览器不支持图片浏览;
用户已经取消对浏览图片的选项,因为要加块连接网络服务器的速度;
服务器件接收到返回图片的请求。
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器