strcpy(sfp,"/tmp");
strcat(sfp,"/sess_");
strcat(sfp,session_id);
remove(sfp);
}
void clean_session_file()
{
DIR *pdir;
struct dirent *ent;
char *path;
char *filename;
char filepath[64];
int fd;
char str_time[11];
time_t now;
path = "/tmp";
pdir = opendir(path);
if(pdir != NULL)
{
while( ent =readdir(pdir) )
{
filename = ent->d_name;
if( strncmp(filename,"sess_",5)==0 )
{
strcpy(filepath,path);
strcat(filepath,"/");
strcat(filepath,filename);
fd = open(filepath,O_RDONLY);
read(fd,str_time,10);
time(&now);
if( now - atoi(str_time) > atoi(parse_config_file("session_live_time")) )
{
remove(filepath);
}
close(fd);
}
}
}
closedir(pdir);
}
void print_session_error(char *n)
{
printf("Content-type:text/html\n\n");
printf("<html><head>";
print_title("请重新登陆!");
printf("</head>\n");
printf("<body>\n");
printf("对不起,请重新登陆。<p>\n");
printf("你长时间没有操作,登陆已经超时。或者是系统发生了错误。<p>\n");
printf("如果是后者,请与管理人员联系。\n");
printf("<!--%s-->",n);
printf("</body>");
printf("</html>\n");
}