Files
winix/core/session.cpp
Tomasz Sowa 717eb526fb * added: class HTMLFilter
files: htmlfilter.h htmlfilter.cpp
         this is an html filter used to make the html output looking better
         this is a very lightweight filter
         (without using any dynamic memory - some memory is allocated only at the beginning - in ctors)
         this filter has O(n) complexity over the whole html string
* added: antyspamming method
         if the POST request is sent too fast after the GET
         it is treated as a spam
         only for no logged users and only in 'emacs' and 'createthread' functions
       


git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@534 e52654a7-88a9-db11-a3e9-0013d4bc506e
2009-12-09 00:42:40 +00:00

114 lines
1.4 KiB
C++
Executable File

/*
* This file is a part of CMSLU -- Content Management System like Unix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa
* All rights reserved.
*
*/
#include "session.h"
Session::Session()
{
Clear();
time = std::time(0);
tm_time = *std::localtime(&time);
last_time = time;
tm_last_time = tm_time;
// the first request can be a POST (it doesn't matter)
last_time_get = time;
}
void Session::Clear()
{
id = 0;
time = 0;
puser = 0;
done = Done::none;
done_status = Error::ok;
item.Clear();
done_timer = 0;
rebus_item = 0;
rebus_checked = false;
remember_me = false;
new_session = true;
spam_score = 0;
dir_old.clear();
}
bool Session::operator==(const Session & s) const
{
return id == s.id;
}
bool Session::operator<(const Session & s) const
{
return id < s.id;
}
/*
bool Session::DecTimer(int & timer)
{
if( timer == 0 )
return false;
--timer;
if( timer == 0 )
return true; // we must clear our variables
return false;
}
void Session::CheckTimers()
{
if( DecTimer(done_timer) )
{
done = Done::none;
done_status = Error::ok;
}
}
*/
void Session::DecTimer(int & timer)
{
if( timer == 0 )
return;
--timer;
}
void Session::CheckTimers()
{
DecTimer(done_timer);
if( done_timer == 0 )
{
done = Done::none;
done_status = Error::ok;
}
}
void Session::IncrementTimersIfExist()
{
if( done_timer != 0 )
++done_timer;
}