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;¢Ò
|