|
||||
1 : #!/bin/wel¢Ò 2 : ¢Ò 3 : /* file: upnotice¢Ò 4 : ¢Ò 5 : notice.wel V1.1.2 º¯È¯ ÇÁ·Î±×·¥(author: ¼±¤Çö)¢Ò 6 : Copyright (c) 2001/04/05 by Wesoft¢Ò 7 : All Rights Reserved.¢Ò 8 : */¢Ò 9 : ¢Ò 10 : print("<<< Convert notice.wel V1.1.2 to WelBoard V2.0.4 >>>\n\n");¢Ò 11 : if(argc!=3)¢Ò 12 : {¢Ò 13 : print("Usage: upnotice dbname notice_data_directory\n");¢Ò 14 : return;¢Ò 15 : }¢Ò 16 : ¢Ò 17 : db= argv[1];¢Ò 18 : notice_datadir= argv[2];¢Ò 19 : break_on= -1;¢Ò 20 : if(include("include/board.inc")!=OK) return;¢Ò 21 : message_form= "";¢Ò 22 : ¢Ò 23 : function cancel_message(string msg)¢Ò 24 : {¢Ò 25 : if(msg!="") print("\n ERROR: ", msg, "\n\n");¢Ò 26 : print(" upnotice is cancelled.\n\n");¢Ò 27 : return;¢Ò 28 : }¢Ò 29 : ¢Ò 30 : function get_noticename(string notice_data_dir)¢Ò 31 : {¢Ò 32 : while( (pos= strfind(notice_data_dir, "/")) > 0)¢Ò 33 : {¢Ò 34 : notice_data_dir= mid(notice_data_dir, pos+1);¢Ò 35 : }¢Ò 36 : return( notice_data_dir );¢Ò 37 : }¢Ò 38 : ¢Ò 39 : rt= mysql_connection("");¢Ò 40 : if(rt==MYSQL_ERR)¢Ò 41 : {¢Ò 42 : if(mysql==MYSQL_ERR) msg= "MySQL connection error!";¢Ò 43 : else msg= "MySQL select db error! (DB=" ~ mydb ~ ")";¢Ò 44 : cancel_message(msg);¢Ò 45 : return disconnect();¢Ò 46 : }¢Ò 47 : ¢Ò 48 : recnt= get_recount(mytable,"");¢Ò 49 : if(recnt<0)¢Ò 50 : {¢Ò 51 : cancel_message("MySQL database=" ~ mydb ~ " , table="¢Ò 52 : ~ mytable ~ " : Table error!");¢Ò 53 : return disconnect();¢Ò 54 : }¢Ò 55 : if(right(notice_datadir,1)=="/")¢Ò 56 : {¢Ò 57 : notice_datadir= left(notice_datadir, len(notice_datadir)-1);¢Ò 58 : }¢Ò 59 : notice_dbname= get_noticename(notice_datadir);¢Ò 60 : notice_datadir ~= "/";¢Ò 61 : notice_conf= notice_datadir ~ notice_dbname ~ ".conf";¢Ò 62 : notice_lastnum= notice_datadir ~ notice_dbname ~ ".num";¢Ò 63 : if(!fexist(notice_conf))¢Ò 64 : {¢Ò 65 : cancel_message("notice.wel V1.1.2: Configuration file not found error!\n"¢Ò 66 : ~ " File: " ~ notice_conf);¢Ò 67 : return disconnect();¢Ò 68 : }¢Ò 69 : if(!fexist(notice_lastnum))¢Ò 70 : {¢Ò 71 : cancel_message("notice.wel V1.1.2: LastNumber file not found error!\n"¢Ò 72 : ~ " File: " ~ notice_lastnum);¢Ò 73 : return disconnect();¢Ò 74 : }¢Ò 75 : ¢Ò 76 : include(notice_conf, -1);¢Ò 77 : fp= fopen(notice_lastnum, "r");¢Ò 78 : if(fp==FILE_OPEN_ERR)¢Ò 79 : {¢Ò 80 : cancel_message("notice.wel V1.1.2: LastNumber file open error!\n"¢Ò 81 : ~ " File: " ~ notice_lastnum);¢Ò 82 : return disconnect();¢Ò 83 : }¢Ò 84 : lastnum= finput(fp);¢Ò 85 : fclose(fp);¢Ò 86 : ¢Ò 87 : print(" 1. Target notice: ", notice_datadir, "\n");¢Ò 88 : print(" 2. Notice name: ", title, "\n");¢Ò 89 : print(" 3. Maximum number: ", lastnum, "\n\n");¢Ò 90 : sel= choice(" Do you want to continue?(Y/n) ", "Yy\nNn");¢Ò 91 : if(sel==3) print("Y");¢Ò 92 : print("\n\n");¢Ò 93 : if(sel>3) { cancel_message(""); return disconnect(); }¢Ò 94 : ¢Ò 95 : function int convert(string datafile, string memofile)¢Ò 96 : {¢Ò 97 : if(!fexist(datafile)) return(-1);¢Ò 98 : include(datafile, -1);¢Ò 99 : content= strform("{&fdump(memofile)}");¢Ò 100 : ¢Ò 101 : subject= strchange(left(lrtrim(DT_SUBJECT),60,1), fch, rch);¢Ò 102 : content= strchange(content, fch, rch);¢Ò 103 : linecnt= strcount(content, "\n");¢Ò 104 : if(right(content,1)!="\n") ++linecnt;¢Ò 105 : wdtime= left(DT_DATE,10) ~ " " ~ left(time(1),5);¢Ò 106 : grpno= selno= get_maximum(mytable, "selno", "") + 1;¢Ò 107 : ¢Ò 108 : qstr= "insert into " ~ mytable¢Ò 109 : ~ " (selno,grpno,answer,subject,content,readcnt,downcnt,linecnt,"¢Ò 110 : ~ "wdtime,wip,whost,wname) values ("¢Ò 111 : ~ strform("{$selno},{$grpno},'','{$subject}','{$content}',0,0,",¢Ò 112 : "{$linecnt},'{$wdtime}','127.0.0.1','localhost','°ü¸®ÀÚ')");¢Ò 113 : ¢Ò 114 : if(mysql_query(mysql, qstr)==MYSQL_ERR) return(0);¢Ò 115 : return(1);¢Ò 116 : }¢Ò 117 : ¢Ò 118 : num= 1;¢Ò 119 : totcnt= errcnt= 0;¢Ò 120 : while(num<=lastnum)¢Ò 121 : {¢Ò 122 : data_file= notice_datadir ~ num ~ ".dat";¢Ò 123 : memo_file= notice_datadir ~ num ~ ".txt";¢Ò 124 : rt= convert(data_file, memo_file);¢Ò 125 : if(rt!=-1)¢Ò 126 : {¢Ò 127 : totcnt++;¢Ò 128 : if(rt==0)¢Ò 129 : {¢Ò 130 : errcnt++;¢Ò 131 : print(" *** converting error: ", data_file, "\n");¢Ò 132 : }¢Ò 133 : }¢Ò 134 : num++;¢Ò 135 : }¢Ò 136 : print("\n >> Total record: ", totcnt);¢Ò 137 : if(errcnt>0) printf(" , Error: ", errcnt);¢Ò 138 : print(" , Converted record: ", totcnt-errcnt, "\n");¢Ò 139 : return disconnect();¢Ò |
||||
|