1 : /* file: common.inc¶
2 : ¶
3 : 환경 및 공통 정의 (author: 서광현)¶
4 : ¶
5 : Copyright (c) 2001/02/22 by Wesoft¶
6 : All Rights Reserved.¶
7 : */¶
8 : ¶
9 : // your system configuration¶
10 : ¶
11 : myhost= "{$myhost}"; // MySQL host¶
12 : mydb= "{$mydb}"; // MySQL database name¶
13 : myuser= "{$myuser}"; // MySQL user id¶
14 : enpass= "{$enpass}"; // MySQL password¶
15 : zipcode_url= "{$zipcode_url}"; // 우편번호 검색 프로그램 URL¶
16 : COOKIE_EXPIRE= {$cookie_expire}; // 쿠키만기 시간 {$cookie_expire}분¶
17 : decode_variable= "{$decoder}"; // password decoding variable¶
18 : register_flag= {$register}; // (0:신청불능, 1:신청확인, 2:자동등록)¶
19 : cookie_garbage= {$cookie_garbage}; // 쿠키의 쓰레기값 위치¶
20 : admin_email= "{$admemail}"; // 관리자 email 주소¶
21 : view_memo= 1; // 로그인화면에 메모 출력(1:출력, 0:감춤)¶
22 : memo_limit= 30; // 메모 유지 한계일(memo_limit 이전은 삭제됨)¶
23 : mpagerec= 5; // 메모의 페이지당 레코드 수¶
24 : background= "bgcolor='#ffffff'"; // body background¶
25 : titlecolor= "#ffffff"; // title font color¶
26 : titlebgcolor= "#25648F"; // title back ground color¶
27 : bar_boardcolor= "#e0b0b0"; // 주소록의 상하 색상¶
28 : bar_trashcolor= "#e0b0d0"; // 삭제자료의 상하 색상¶
29 : bar_admincolor= "#f09090"; // 관리자 목록 상하 색상¶
30 : list_headcolor= "#6090b8"; // 목록 제목 색상¶
31 : list_trashcolor= "#b86090"; // 삭제자료의 제목 색상¶
32 : ¶
33 : preTBname= "z"; // 주소록 테이블 명칭의 접두사(preTBname~주소록ID)¶
34 : myustable= "user"; // user table name¶
35 : memotable= "umemo"; // memo table name¶
36 : ¶
37 : // end system configuration¶
38 : ¶
39 : mypass= decode(enpass, "", decode_variable);¶
40 : OK= 1;¶
41 : FAIL= 0;¶
42 : fch= "\\|\"|'"; // 찾을 문자¶
43 : rch= "/|`|`"; // 바꿔지는 문자¶
44 : message_form= "form/message.fom";¶
45 : message_title= "개인 주소록 프로그램 오류 메시지";¶
46 : MSG0= "<b>ERROR: </b>";¶
47 : PROGRAM_NAME= "addrbook.wel";¶
48 : PROGRAM_VERSION= "V1.4";¶
49 : cpright= "<font color=#5c5c5c face=Verdana size=1>"¶
50 : ~ "<b>Wesoft Corp.</b> ⓒ 2001 All rights reserved.</font>";¶
51 : ¶
52 : week_str= array("일","월","화","수","목","금","토");¶
53 : ¶
54 : function string insert_week(string dtime)¶
55 : {¶
56 : int pos, yy, mm, dd;¶
57 : string date, time;¶
58 : ¶
59 : pos= strfind(dtime, " ");¶
60 : if(pos>1)¶
61 : {¶
62 : date= left(dtime, pos-1);¶
63 : time= mid(dtime, pos+1);¶
64 : yy= val(left(date, 4));¶
65 : mm= val(mid(date, 6, 2));¶
66 : dd= val(mid(date, 9, 2));¶
67 : dtime= date ~ "(" ~ week_str[iweek(yy,mm,dd)] ~ ") " ~ time;¶
68 : }¶
69 : return(dtime);¶
70 : }¶
71 : ¶
72 : DEFINE_BUTTON=¶
73 : {[ <input type="button" value="{$btname}" id=ib onClick="{$action}"{$style}]}¶
74 : ¶
75 : DEFINE_BUTTON2=¶
76 : {[¶
77 : onmouseover="this.style.color='#f00000'"¶
78 : onmouseout= "this.style.color='#000000'">]}¶
79 : /*¶
80 : mode==0 : 출력없이 문자열을 리턴함¶
81 : mode==1 : 버튼을 출력함¶
82 : mode>1 : 버튼을 출력한 후 개행을 함¶
83 : style의 첫글자가 "!" : off된 모양¶
84 : */¶
85 : ¶
86 : function free button(int mode, string action, string btname, string style)¶
87 : {¶
88 : string bt, bt_str;¶
89 : ¶
90 : bt= DEFINE_BUTTON;¶
91 : if(left(style,1)!="!") bt~= DEFINE_BUTTON2;¶
92 : else style= mid(style,2), bt~= ">";¶
93 : if(style!="") style= " style=\"" ~ style ~ "\"";¶
94 : bt_str= strform(bt);¶
95 : if(mode==0) return(bt_str);¶
96 : print(bt_str);¶
97 : if(mode>1) print();¶
98 : return;¶
99 : }¶
100 : ¶
101 : HELP_ADMIN= " 관리자에게 문의하세요!<br><br>"¶
102 : ~ button(0, "goadmail()","(?) 관리자에게 문의하기","width:150");¶
103 : ¶
104 : LOGIN_BUTTON= "<br><br>"¶
105 : ~ button(0,"location.replace('login.wel')","로그인하기","");¶
106 : BACK_BUTTON= "<br><br>" ~ button(0, "history.back()", "뒤로가기","width:60");¶
107 : ¶
108 : free mysql; // mysql pointer¶
109 : int ctype_printed= 0; // content type 출력 flag¶
110 : int mysql_connected= 0; // mysql 연결 flag¶
111 : vlock mysql_connected; // 읽기 전용 설정¶
112 : vlock ctype_printed; // 읽기 전용 설정¶
113 : ¶
114 : function print_type(string cookie)¶
115 : {¶
116 : if(ctype_printed==0)¶
117 : {¶
118 : print("Content-type: text/html\n", cookie, "\n");¶
119 : global ctype_printed;¶
120 : vunlock ctype_printed;¶
121 : ctype_printed= 1;¶
122 : vlock ctype_printed;¶
123 : }¶
124 : return;¶
125 : }¶
126 : ¶
127 : function int mysql_connection()¶
128 : {¶
129 : mysql= mysql_connect(myhost, myuser, mypass); // MySQL 서버 연결¶
130 : if(mysql==MYSQL_ERR)¶
131 : {¶
132 : MSG1= "MySQL 서버 연결 오류";¶
133 : MSG2= "MySQL 서버가 작동하지 않거나 MySQL 사용자 ID 또는"¶
134 : ~ " 암호가 잘못되었습니다." ~ HELP_ADMIN;¶
135 : print_type("");¶
136 : formdump(message_form);¶
137 : return(MYSQL_ERR);¶
138 : }¶
139 : if(mysql_select_db(mysql, mydb)==MYSQL_ERR)¶
140 : {¶
141 : MSG1= "MySQL 데이터베이스 선택 오류";¶
142 : MSG2= mydb ~ " 데이터베이스가 없거나 내부 오류입니다." ~ HELP_ADMIN;¶
143 : print_type("");¶
144 : formdump(message_form);¶
145 : mysql_close(mysql);¶
146 : return(MYSQL_ERR);¶
147 : }¶
148 : global mysql_connected;¶
149 : vunlock mysql_connected;¶
150 : mysql_connected= 1;¶
151 : vlock mysql_connected;¶
152 : return(OK);¶
153 : }¶
154 : ¶
155 : function disconnect()¶
156 : {¶
157 : if(mysql_connected==1)¶
158 : {¶
159 : mysql_close(mysql);¶
160 : global mysql_connected;¶
161 : vunlock mysql_connected;¶
162 : mysql_connected= 0;¶
163 : vlock mysql_connected;¶
164 : }¶
165 : return;¶
166 : }¶
167 : ¶
168 : function err_form(string formname)¶
169 : {¶
170 : MSG1= formname ~ " 폼 개방 오류";¶
171 : MSG2= formname ~ " 파일을 개방할 수 없습니다." ~ HELP_ADMIN;¶
172 : print_type("");¶
173 : formdump(message_form);¶
174 : return disconnect();¶
175 : }¶
176 : ¶
177 : function err_query()¶
178 : {¶
179 : MSG1= "MySQL query 오류";¶
180 : MSG2= "MySQL query error!<br><font color=#f00000>QUERY:</font> "¶
181 : ~ qstr ~ "<br>" ~ HELP_ADMIN;¶
182 : print_type("");¶
183 : formdump(message_form);¶
184 : return disconnect();¶
185 : }¶
186 : ¶
187 : function err_store_result()¶
188 : {¶
189 : MSG1= "MySQL store result 오류";¶
190 : MSG2= "메모리가 부족하거나 MySQL에 문제가 발생했습니다." ~ HELP_ADMIN;¶
191 : print_type("");¶
192 : formdump(message_form);¶
193 : return disconnect();¶
194 : }¶
195 : ¶
196 : function err_fetch_row()¶
197 : {¶
198 : MSG1= "MySQL fetch row 오류";¶
199 : MSG2= "메모리가 부족하거나 MySQL에 문제가 발생했습니다." ~ HELP_ADMIN;¶
200 : print_type("");¶
201 : formdump(message_form);¶
202 : return disconnect();¶
203 : }¶
204 : ¶
205 : function long get_recount(free mysql, string table, string cond)¶
206 : {¶
207 : string qstr;¶
208 : free r, myresult;¶
209 : ¶
210 : qstr= "select count(*) from " ~ table;¶
211 : if(cond!="") qstr~= " where " ~ cond;¶
212 : if(mysql_query(mysql, qstr)==MYSQL_ERR) return(-1);¶
213 : myresult= mysql_store_result(mysql);¶
214 : if(myresult==MYSQL_ERR) return(-2);¶
215 : r= mysql_fetch_row(myresult);¶
216 : mysql_free_result(myresult);¶
217 : return(r[0]);¶
218 : }¶
219 : ¶
220 : function send_cookie(string id, string pass)¶
221 : {¶
222 : int r;¶
223 : ¶
224 : usinfo= "ckid=" ~ id ~ "&ckpass=" ~ pass¶
225 : ~ "&ckdate=" ~ date(0) ~ "&cktime=" ~ time(0);¶
226 : ¶
227 : usinfo= encode(usinfo, encodekey(), "", decode_variable);¶
228 : if(usinfo!="")¶
229 : {¶
230 : randomize();¶
231 : r= rand(3);¶
232 : if(r==0) r= rand(10) + '0';¶
233 : else if(r==1) r= rand(26) + 'A';¶
234 : else r= rand(26) + 'a';¶
235 : ch= chr(r);¶
236 : usinfo= left(usinfo, cookie_garbage)~ch~mid(usinfo, cookie_garbage+1);¶
237 : }¶
238 : set_cookie= "Set-Cookie: usinfo=" ~ usinfo ~ ";\n";¶
239 : // ~ "; expires=" ~ time(-7,COOKIE_EXPIRE*60) ~ "\n";¶
240 : ¶
241 : print_type(set_cookie);¶
242 : }¶
243 : ¶
244 : function replace_location(string url)¶
245 : {¶
246 : print("<script>location.replace('", url, "');</script>");¶
247 : return;¶
248 : }¶
249 : return;¶
|