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