added: item content type: raw

git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@549 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2010-01-11 14:47:52 +00:00
parent 59943c87cd
commit 3c95b84633
28 changed files with 319 additions and 178 deletions

View File

@@ -388,7 +388,7 @@ void Request::SendSessionCookie()
return;
}
time_t t = time(0) + data.session_remember_max_iddle;
time_t t = time(0) + data.session_remember_max_idle;
tm * expires = localtime(&t);
if( !expires )
@@ -456,12 +456,14 @@ void Request::AddDebugInfo()
}
void Request::SendPage(bool compressing)
void Request::SendPage(bool compressing, const std::string & source_ref)
{
const std::string & source_ref = page.str();
const std::string * source = &source_ref;
if( data.html_filter )
bool raw = request.is_item && request.item.content_type == Item::ct_raw && request.status == Error::ok &&
request.pfunction && (request.pfunction->code == FUN_CAT || request.pfunction->code == FUN_RUN);
if( data.html_filter && !raw )
{
html_filter.TrimWhite(true);
html_filter.BreakLongLines(true);
@@ -480,13 +482,15 @@ void Request::SendPage(bool compressing)
void Request::SendAll()
{
bool compressing = data.compression && !browser_msie && !browser_konqueror && accept_encoding_parser.AcceptDeflate();
Header header = h_200;
const std::string & source_ref = page.str();
bool compressing = data.compression && !browser_msie && !browser_konqueror &&
accept_encoding_parser.AcceptDeflate() && source_ref.size() >= 512;
Header header = h_200;
if( status == Error::db_no_item || status == Error::no_function || status == Error::unknown_param )
if( status == Error::no_item || status == Error::no_function || status == Error::unknown_param )
header = h_404;
if( status == Error::permision_denied || status == Error::cant_change_user || status == Error::cant_change_group )
if( status == Error::permission_denied || status == Error::cant_change_user || status == Error::cant_change_group )
header = h_403;
SendSessionCookie();
@@ -504,7 +508,7 @@ Header header = h_200;
AddDebugInfo();
// sending content
SendPage(compressing);
SendPage(compressing, source_ref);
}
@@ -792,29 +796,23 @@ return true;
bool Request::CanUseHtml(long user_id)
{
User * puser = data.users.GetUser(user_id);
if( !puser )
return false;
if( puser->super_user )
// super user can use html
return true;
long group = data.groups.GetGroupId("allow_html");
if( group == -1 )
// there is no such a group
return false;
if( puser->IsMemberOf(group) )
return true;
return false;
return CanUse(user_id, "allow_html");
}
bool Request::CanUseBBCode(long user_id)
{
return CanUse(user_id, "allow_bbcode");
}
bool Request::CanUseRaw(long user_id)
{
return CanUse(user_id, "allow_raw");
}
bool Request::CanUse(long user_id, const char * group_name)
{
User * puser = data.users.GetUser(user_id);
@@ -822,10 +820,9 @@ bool Request::CanUseBBCode(long user_id)
return false;
if( puser->super_user )
// super user can use bbcode
return true;
long group = data.groups.GetGroupId("allow_bbcode");
long group = data.groups.GetGroupId(group_name);
if( group == -1 )
// there is no such a group
@@ -838,6 +835,9 @@ return false;
}
bool Request::MakeDirsOnFS(std::string & path)
{
size_t i;