263{
264 String strID;
265 String strPasswd;
266
267 String strSubject;
268 String strBody;
269 String strVisitor;
270 String strEmail;
271 String strRHost = ctx.remoteAddr();
272
273 ListedStringToStringArrayMap::Iterator it;
274
275 it = params.find(L"id");
276 if ((it != params.end()) && (!(*it).value.isEmpty()))
277 strID = (*it).value[0];
278
279 it = params.find(L"passwd");
280 if ((it != params.end()) && (!(*it).value.isEmpty()))
281 strPasswd = (*it).value[0];
282
283 it = params.find(L"subject");
284 if ((it != params.end()) && (!(*it).value.isEmpty()))
285 strSubject = (*it).value[0];
286
287 it = params.find(L"body");
288 if ((it != params.end()) && (!(*it).value.isEmpty()))
289 strBody = (*it).value[0];
290
291 it = params.find(L"visitor");
292 if ((it != params.end()) && (!(*it).value.isEmpty()))
293 strVisitor = (*it).value[0];
294
295 it = params.find(L"email");
296 if ((it != params.end()) && (!(*it).value.isEmpty()))
297 strEmail = (*it).value[0];
298
299 if (strSubject.isEmpty()
300 || strBody.isEmpty()
301 || strVisitor.isEmpty()
302 || strEmail.isEmpty())
303 {
304 out << L"<br><br><p><strong>모두 입력해 주세요!!</strong></p>";
305 return;
306 }
307
308 String strSQL = L""
309 "INSERT INTO "
310 " ES_VISITOR_BOOK(SUBJECT, BODY, REGIST, VISITOR,"
311 " EMAIL, RHOST, PASSWD) "
312 " VALUES(:SUBJECT, :BODY, CURRENT_TIMESTAMP, :VISITOR,"
313 " :EMAIL, :RHOST, :PASSWD)";
314
315 SQLQuery q(pSQLConn);
316 if (!strID.isEmpty()) {
317 q.execute(L"SELECT PASSWD FROM ES_VISITOR_BOOK WHERE ID = " + strID);
318 q.fetch();
319 if (!q.eof()) {
320 if (q.fields()[0].isNull()
321 || q.fields()[0].asString() == strPasswd) {
322 strSQL = L""
323 "UPDATE ES_VISITOR_BOOK "
324 " SET SUBJECT = :SUBJECT, BODY = :BODY, VISITOR = :VISITOR, "
325 " EMAIL = :EMAIL, RHOST = :RHOST, PASSWD = :PASSWD "
326 " WHERE ID = " + strID;
327 }
328 else {
330 return;
331 }
332 }
333 }
334
335 q.prepare(strSQL);
336 SQLParams& sqlParams = q.params();
337 sqlParams.
byName(L
"SUBJECT").setValue(strSubject);
338 sqlParams.
byName(L
"BODY").setValue(strBody);
339 sqlParams.
byName(L
"VISITOR").setValue(strVisitor);
340 sqlParams.
byName(L
"EMAIL").setValue(strEmail);
341 sqlParams.
byName(L
"RHOST").setValue(strRHost);
342 sqlParams.
byName(L
"PASSWD").setValue(strPasswd);
343
344 q.execute();
345
347}
SQLParam & byName(const wchar_t *_name) _CONST __DCL_THROWS1(InvalidIndexException *)