added support for UTF-8
now the UTF-8 is a default charset git-svn-id: svn://ttmath.org/publicrep/winix/trunk@677 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
33
db/db.cpp
33
db/db.cpp
@@ -15,7 +15,7 @@
|
||||
|
||||
|
||||
|
||||
bool Db::CheckUser(const std::string & login, const std::string & password, long & user_id)
|
||||
bool Db::CheckUser(const std::wstring & login, const std::wstring & password, long & user_id)
|
||||
{
|
||||
PGresult * r = 0;
|
||||
bool user_ok = false;
|
||||
@@ -60,7 +60,7 @@ return user_ok;
|
||||
|
||||
|
||||
|
||||
Error Db::AddUser(User & user, const std::string & password)
|
||||
Error Db::AddUser(User & user, const std::wstring & password)
|
||||
{
|
||||
PGresult * r = 0;
|
||||
Error status = WINIX_ERR_OK;
|
||||
@@ -107,7 +107,8 @@ bool is_that_url;
|
||||
PGresult * r = 0;
|
||||
int index = 1;
|
||||
const int max_index = 99;
|
||||
char appendix[20];
|
||||
wchar_t appendix[20];
|
||||
size_t appendix_len = sizeof(appendix) / sizeof(wchar_t);
|
||||
appendix[0] = 0;
|
||||
|
||||
try
|
||||
@@ -131,7 +132,7 @@ appendix[0] = 0;
|
||||
|
||||
if( Rows(r) != 0 )
|
||||
{
|
||||
sprintf(appendix, "_(%d)", ++index);
|
||||
swprintf(appendix, appendix_len, L"_(%d)", ++index);
|
||||
is_that_url = true;
|
||||
}
|
||||
else
|
||||
@@ -213,8 +214,8 @@ void Db::CheckAllUrlSubject()
|
||||
|
||||
for(int i = 0 ; i<rows ; ++i)
|
||||
{
|
||||
item.id = atol( AssertValue(r, i, cid) );
|
||||
item.subject = AssertValue(r, i, csubject);
|
||||
item.id = AssertValueLong(r, i, cid);
|
||||
item.subject = AssertValueWide(r, i, csubject);
|
||||
|
||||
CheckAllUrlSubjectModifyItem(item);
|
||||
}
|
||||
@@ -573,7 +574,7 @@ return result;
|
||||
}
|
||||
|
||||
|
||||
Error Db::EditTemplateItemById(long id, const std::string & new_html_template)
|
||||
Error Db::EditTemplateItemById(long id, const std::wstring & new_html_template)
|
||||
{
|
||||
PGresult * r = 0;
|
||||
Error result = WINIX_ERR_OK;
|
||||
@@ -810,7 +811,7 @@ void Db::GetItem(std::vector<Item> & item_tab, long id)
|
||||
|
||||
|
||||
// !! nowy interfejs
|
||||
Error Db::GetItem(long parent_id, const std::string & url, Item & item)
|
||||
Error Db::GetItem(long parent_id, const std::wstring & url, Item & item)
|
||||
{
|
||||
PGresult * r = 0;
|
||||
Error result = WINIX_ERR_OK;
|
||||
@@ -883,7 +884,7 @@ return result;
|
||||
|
||||
|
||||
|
||||
long Db::GetItemId(long parent_id, const std::string & url, Item::Type type)
|
||||
long Db::GetItemId(long parent_id, const std::wstring & url, Item::Type type)
|
||||
{
|
||||
PGresult * r = 0;
|
||||
long result = -1;
|
||||
@@ -916,13 +917,13 @@ return result;
|
||||
|
||||
|
||||
|
||||
long Db::GetFileId(long parent_id, const std::string & url)
|
||||
long Db::GetFileId(long parent_id, const std::wstring & url)
|
||||
{
|
||||
return GetItemId(parent_id, url, Item::file);
|
||||
}
|
||||
|
||||
|
||||
long Db::GetDirId(long parent_id, const std::string & url)
|
||||
long Db::GetDirId(long parent_id, const std::wstring & url)
|
||||
{
|
||||
return GetItemId(parent_id, url, Item::dir);
|
||||
}
|
||||
@@ -1321,9 +1322,9 @@ void Db::GetUsers(UGContainer<User> & user_tab)
|
||||
|
||||
if( u.id != last_id )
|
||||
{
|
||||
u.name = AssertValue(r, i, cname);
|
||||
u.super_user = static_cast<bool>( atoi( AssertValue(r, i, csuper_user) ) );
|
||||
u.email = AssertValue(r, i, cemail);
|
||||
u.name = AssertValueWide(r, i, cname);
|
||||
u.super_user = static_cast<bool>(AssertValueInt(r, i, csuper_user));
|
||||
u.email = AssertValueWide(r, i, cemail);
|
||||
u.cms_notify = AssertValueInt(r, i, ccms_notify);
|
||||
u.thread_notify = AssertValueInt(r, i, cthread_notify);
|
||||
|
||||
@@ -1384,7 +1385,7 @@ void Db::GetGroups(UGContainer<Group> & group_tab)
|
||||
|
||||
if( g.id != last_id )
|
||||
{
|
||||
g.name = AssertValue(r, i, cname);
|
||||
g.name = AssertValueWide(r, i, cname);
|
||||
log << log3 << "Db: get group, id:" << g.id << ", group:" << g.name << logend;
|
||||
|
||||
iter = group_tab.PushBack( g );
|
||||
@@ -1510,7 +1511,7 @@ Error Db::GetThreads(long parent_id, std::vector<Thread> & thread_tab)
|
||||
thread.last_item.id = AssertValueLong(r, i, clast_item);
|
||||
thread.last_item.date_modification = AssertValueTm(r, i, cdate_modification);
|
||||
thread.last_item.user_id = AssertValueLong(r, i, cuser_id);
|
||||
thread.last_item.guest_name = AssertValue(r, i, cguest_name);
|
||||
thread.last_item.guest_name = AssertValueWide(r, i, cguest_name);
|
||||
|
||||
thread_tab.push_back(thread);
|
||||
}
|
||||
|
Reference in New Issue
Block a user