--- innwebd/base.cpp 2004/12/01 08:31:52 1.11 +++ innwebd/base.cpp 2008/04/11 17:14:49 1.15 @@ -1,14 +1,10 @@ /*******************************************************/ /* */ /* LeafOK Innbbsd */ -/* Copyright (C) LeafOK.com, 2003-2004 */ /* */ -/* Programmed by Leaf */ -/* E-mail:leaflet@leafok.com QQ:6049044 */ +/* Copyright (C) LeafOK.com, 2003-2008 */ /* */ -/* http://bbs.leafok.com */ -/* http://bbs.leafok.net */ -/* http://bbs.fenglin.info */ +/* http://www.leafok.com */ /* */ /*******************************************************/ @@ -46,7 +42,9 @@ int base::s_exec(const char* in_str, CSt } catch(CException* e) { - syslog << logfile::log_head << "Error in s_exec()" << endl; + char strErrMsg[1024]; + e->GetErrorMessage(strErrMsg,1024); + syslog << logfile::log_head << "Error in s_exec() [" << strErrMsg << "]" << endl; e->Delete(); return -1; } @@ -59,10 +57,14 @@ int base::db_open(const char* conn_str) try { this->Db.Open("",0,0,conn_str,0); + this->Db.ExecuteSQL("SET CHARACTER SET gb2312"); + this->Db.ExecuteSQL("SET NAMES 'gb2312'"); } catch(CException* e) { - syslog << logfile::log_head << "Open database failed in db_open()" << endl; + char strErrMsg[1024]; + e->GetErrorMessage(strErrMsg,1024); + syslog << logfile::log_head << "Open database failed in db_open() [" << strErrMsg << "]" << endl; e->Delete(); return -1; } @@ -78,7 +80,9 @@ int base::db_close(void) } catch(CException* e) { - syslog << logfile::log_head << "Close database failed in db_close()" << endl; + char strErrMsg[1024]; + e->GetErrorMessage(strErrMsg,1024); + syslog << logfile::log_head << "Close database failed in db_close() [" << strErrMsg << "]" << endl; e->Delete(); return -1; } @@ -233,7 +237,7 @@ int base::bbs_post(const CString& head, } } if (nickname.GetLength() > 20) - nickname = nickname.Left(20); + nickname = nickname.Left(19) + " "; //Reference /bbs/add_sub.php @@ -351,7 +355,9 @@ long base::last_insert_id(void) } catch(CException* e) { - syslog << logfile::log_head << "Error in last_insert_id()" << endl; + char strErrMsg[1024]; + e->GetErrorMessage(strErrMsg,1024); + syslog << logfile::log_head << "Error in last_insert_id() [" << strErrMsg << "]" << endl; e->Delete(); return 0; } @@ -425,7 +431,9 @@ int base::s_send(const char* in_str, boo } catch(CException* e) { - syslog << logfile::log_head << "Error in s_send()" << endl; + char strErrMsg[1024]; + e->GetErrorMessage(strErrMsg,1024); + syslog << logfile::log_head << "Error in s_send() [" << strErrMsg << "]" << endl; e->Delete(); return -1; } @@ -462,7 +470,9 @@ int base::s_receive(CString& out_str, ch } catch(CException* e) { - syslog << logfile::log_head << "Error in s_receive()" << endl; + char strErrMsg[1024]; + e->GetErrorMessage(strErrMsg,1024); + syslog << logfile::log_head << "Error in s_receive() [" << strErrMsg << "]" << endl; e->Delete(); return -1; } @@ -477,7 +487,7 @@ int base::begin(void) unsigned int time_wait = 0; if (!this->IsShutdown()) - return 1; + return 0; if (hThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)base::Thread,(LPVOID)this,0,&ulThreadId)) { @@ -494,7 +504,7 @@ int base::begin(void) { Sleep(100); time_wait += 100; - if (time_wait > 10000) //Wait 10 seconds + if (time_wait > 30000) //Wait 30 seconds { syslog << logfile::log_head << "Module timeout in begin()" << endl; this->end(); @@ -516,7 +526,7 @@ DWORD base::Thread(LPVOID pParam) p->ulMainThreadId = GetCurrentThreadId(); - if (p->GetParentThread()->GetThreadPool()->AddThread(GetCurrentThreadId(), CLOCKS_PER_SEC * 30) != 0) + if (p->GetParentThread()->GetThreadPool()->AddThread(GetCurrentThreadId(), CLOCKS_PER_SEC * 60) != 0) { syslog << logfile::log_head << "Register thread ... Failed" << endl; }