/* *MakeUserPageList Version 1.0(2003-12-10) by PF-X.NET */ #include #include #include #include typedef struct _EDITINDATA { char username[50]; char password[20]; char name[80]; char mailaddr[50]; char dskquota[5]; char last_login_day[5]; char last_login_date[15]; char login_count[15]; char ok_date[10]; char paramX[20]; } EDITINDATA, *PEDITINDATA; //返ってくるもの→項目数 int get_data(PEDITINDATA pEditInData); int get_title(char *filename, char *title); int get_html(char *hostname, char *userstr, char *username); int main(){ PEDITINDATA pEditInData; pEditInData = (PEDITINDATA)malloc(sizeof(EDITINDATA)*10000); char r_title[129]; int kazu = get_data(pEditInData); FILE *op; op = fopen("./userlist.html","w"); fprintf(op,"%s%s%s%s", "ユーザーページ一覧\n", "

TOPへ

ユーザーページ一覧


\nユーザーページの一覧です。", "
それぞれのindex.htmlからタイトルを抽出したものとURLのリストです。登録順にて表示されています。尚未ログインユーザーは表示されません。
", "\n"); int count=0; int i,r; for(i=0; i\n", pEditInData[i].username,pEditInData[i].username,r_title,pEditInData[i].ok_date); count ++; } if(r == 2){ //ファイルはあるが取得失敗 fprintf(op,"\n", pEditInData[i].username,pEditInData[i].username,pEditInData[i].ok_date); } if(r == 3){ //途中でエラー fprintf(op,"\n", pEditInData[i].username,pEditInData[i].username,pEditInData[i].ok_date); } } } } remove("./404page.html"); remove("./403page.html"); } fprintf(op,"
ユーザー名タイトル登録日
%s%s%s
%s取得失敗(ファイルは存在)%s
%s不明なエラー%s
_▲_

\n"); fprintf(op,"
取得成功数:%d 総ユーザー数:%d

Generated by MakeUserList Version1.0 (pf-x.net 2003)\n",count,kazu); fprintf(op,"\n"); fclose(op); free(pEditInData); remove("./index.html"); } int get_title(char *filename, char *title){ FILE *fp; fp = fopen("./index.html","r"); if(fp==NULL){ return 3; } fclose(fp); FILE *nkf; system("nkf -e ./index.html > nkf-index.html"); fp = fopen("./nkf-index.html","r"); if(fp==NULL){ remove("./nkf-index.html"); return 3; } char buffer[2048]; fread(buffer,1,sizeof(buffer),fp); fclose(fp); char *start; char *end; start = strstr(buffer,""); if(start == NULL){ start = strstr(buffer,"<TITLE>"); } if(start == NULL){ return 2; } end = strstr(buffer,""); if(end == NULL){ end = strstr(buffer,""); } if(end == NULL){ return 2; } char *work; work = start; work += 7;//余計な分進める int r = 0; while(work != end){ if(r >= 128){ title[129] = '\0'; break; } if(!(title[r] =='<' && title[r] == '>')){ title[r] = *work; } else { title[r] = ' '; } work++; r++; } title[r] = '\0'; return 0; } int get_data(PEDITINDATA pEditInData){ FILE *maindata; maindata = fopen("../datafile/accountdata.cgi","r"); lockf( fileno(maindata), F_LOCK, 0 ); char main_data_buf[10000][300]; int mLoop=0; char readbuf[300]; while((fgets( readbuf, sizeof(readbuf), maindata )) != NULL ){ strcpy(main_data_buf[mLoop],readbuf); mLoop++; } fclose(maindata); int i; for(i=0; i