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:
@@ -61,7 +61,7 @@ void System::Init()
|
||||
|
||||
// !! mozna zrobic jakas obsluge kiedy nie mozemy sie redirectnac, np gdy wystapil blad
|
||||
// !! moze zwracac jakas wartosc?
|
||||
void System::RedirectTo(const Item & item, const char * postfix)
|
||||
void System::RedirectTo(const Item & item, const wchar_t * postfix)
|
||||
{
|
||||
request->redirect_to = config->base_url;
|
||||
|
||||
@@ -86,9 +86,8 @@ void System::RedirectTo(const Item & item, const char * postfix)
|
||||
|
||||
|
||||
|
||||
void System::RedirectTo(long item_id, const char * postfix)
|
||||
void System::RedirectTo(long item_id, const wchar_t * postfix)
|
||||
{
|
||||
std::string path;
|
||||
Item * pdir;
|
||||
|
||||
request->redirect_to = config->base_url;
|
||||
@@ -339,7 +338,7 @@ size_t i = 0;
|
||||
|
||||
bool System::CanUseHtml(long user_id)
|
||||
{
|
||||
return IsMemberOfGroup(user_id, "allow_html");
|
||||
return IsMemberOfGroup(user_id, L"allow_html");
|
||||
}
|
||||
|
||||
|
||||
@@ -352,12 +351,12 @@ bool System::CanUseBBCode(long user_id)
|
||||
|
||||
bool System::CanUseRaw(long user_id)
|
||||
{
|
||||
return IsMemberOfGroup(user_id, "allow_raw");
|
||||
return IsMemberOfGroup(user_id, L"allow_raw");
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool System::IsMemberOfGroup(long user_id, const char * group_name)
|
||||
bool System::IsMemberOfGroup(long user_id, const wchar_t * group_name)
|
||||
{
|
||||
User * puser = users.GetUser(user_id);
|
||||
|
||||
@@ -365,7 +364,7 @@ bool System::IsMemberOfGroup(long user_id, const char * group_name)
|
||||
return false;
|
||||
|
||||
if( puser->super_user )
|
||||
return true;
|
||||
return true; // !! ?? zakladamy ze administrator jest czlonkiem wszystkich grup? dlaczego?
|
||||
|
||||
long group = groups.GetGroupId(group_name);
|
||||
|
||||
@@ -373,10 +372,7 @@ bool System::IsMemberOfGroup(long user_id, const char * group_name)
|
||||
// there is no such a group
|
||||
return false;
|
||||
|
||||
if( puser->IsMemberOf(group) )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return puser->IsMemberOf(group);
|
||||
}
|
||||
|
||||
|
||||
@@ -384,7 +380,7 @@ return false;
|
||||
|
||||
|
||||
|
||||
bool System::MakePathSimpleFs(std::string & path, long dir_id, bool create_dir)
|
||||
bool System::MakePathSimpleFs(std::wstring & path, long dir_id, bool create_dir)
|
||||
{
|
||||
if( config->auth_simplefs_dir.empty() )
|
||||
{
|
||||
@@ -407,16 +403,18 @@ return true;
|
||||
|
||||
|
||||
// the path depends on id
|
||||
bool System::MakePathHashFs(std::string & path, long id, bool create_dir)
|
||||
bool System::MakePathHashFs(std::wstring & path, long id, bool create_dir)
|
||||
{
|
||||
char buffer[50];
|
||||
char * hash = buffer;
|
||||
wchar_t buffer[50];
|
||||
wchar_t * hash = buffer;
|
||||
size_t buffer_len = sizeof(buffer)/sizeof(wchar_t);
|
||||
|
||||
// get 'id' as hexadecimal
|
||||
buffer[0] = '0';
|
||||
sprintf(buffer+1, "%lx", (unsigned long)id);
|
||||
swprintf(buffer+1, buffer_len, L"%lx", (unsigned long)id);
|
||||
|
||||
path = config->auth_hashfs_dir;
|
||||
|
||||
if( path.empty() )
|
||||
{
|
||||
log << log1 << "System: auth_hashfs_dir is not set in the config file" << logend;
|
||||
@@ -426,7 +424,7 @@ char * hash = buffer;
|
||||
path += '/';
|
||||
|
||||
// make sure that the length is even
|
||||
if( (strlen(hash) & 1) != 0 )
|
||||
if( (wcslen(hash) & 1) != 0 )
|
||||
hash = buffer + 1; // the first character was zero
|
||||
|
||||
// creating dirs without the last part
|
||||
@@ -447,14 +445,14 @@ char * hash = buffer;
|
||||
|
||||
// one character more to make sure the path is unique
|
||||
// (we can have a directory without the character)
|
||||
path += "_";
|
||||
path += '_';
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// making a complete path to a static file
|
||||
bool System::MakePath(const Item & item, std::string & path, bool create_dir)
|
||||
bool System::MakePath(const Item & item, std::wstring & path, bool create_dir)
|
||||
{
|
||||
bool res;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user