changed: in Request:

removed start_tm
         added start_date (PT::Date)
changed: in Session:
         removed: tm_time
         added: start_date (PT::Date)
         renamed: time -> start_time
         the same is for last_time
         now we have (last_time and last_date)



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@838 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
Tomasz Sowa 2012-05-24 21:09:37 +00:00
parent db9d381a43
commit 5b845f1d03
11 changed files with 153 additions and 104 deletions

View File

@ -481,27 +481,29 @@ run.o: htmlfilter.h ../templates/htmltextstream.h ../core/textstream.h misc.h
run.o: ../../pikotools/date/date.h session.h user.h plugindata.h rebus.h
run.o: mount.h ../templates/locale.h
session.o: session.h item.h ../../pikotools/space/space.h error.h user.h
session.o: plugindata.h rebus.h textstream.h misc.h requesttypes.h
session.o: plugindata.h rebus.h textstream.h ../../pikotools/date/date.h
session.o: misc.h requesttypes.h
sessioncontainer.o: sessioncontainer.h session.h item.h
sessioncontainer.o: ../../pikotools/space/space.h error.h user.h plugindata.h
sessioncontainer.o: rebus.h textstream.h cur.h request.h requesttypes.h
sessioncontainer.o: config.h ../../pikotools/space/spaceparser.h
sessioncontainer.o: rebus.h textstream.h ../../pikotools/date/date.h cur.h
sessioncontainer.o: request.h requesttypes.h config.h
sessioncontainer.o: ../../pikotools/space/spaceparser.h
sessioncontainer.o: ../../pikotools/space/space.h htmlfilter.h
sessioncontainer.o: ../templates/htmltextstream.h ../core/textstream.h misc.h
sessioncontainer.o: ../../pikotools/date/date.h mount.h log.h
sessioncontainer.o: logmanipulators.h slog.h ../templates/locale.h
sessioncontainer.o: mount.h log.h logmanipulators.h slog.h
sessioncontainer.o: ../templates/locale.h
sessionmanager.o: sessionmanager.h sessioncontainer.h session.h item.h
sessionmanager.o: ../../pikotools/space/space.h error.h user.h plugindata.h
sessionmanager.o: rebus.h textstream.h cur.h request.h requesttypes.h
sessionmanager.o: config.h ../../pikotools/space/spaceparser.h
sessionmanager.o: rebus.h textstream.h ../../pikotools/date/date.h cur.h
sessionmanager.o: request.h requesttypes.h config.h
sessionmanager.o: ../../pikotools/space/spaceparser.h
sessionmanager.o: ../../pikotools/space/space.h htmlfilter.h
sessionmanager.o: ../templates/htmltextstream.h ../core/textstream.h misc.h
sessionmanager.o: ../../pikotools/date/date.h mount.h lastcontainer.h
sessionmanager.o: system.h job.h basethread.h synchro.h dirs.h dircontainer.h
sessionmanager.o: ../db/db.h ../db/dbbase.h ../db/dbconn.h
sessionmanager.o: ../db/dbtextstream.h ../core/error.h ../db/dbitemquery.h
sessionmanager.o: ../core/item.h ../db/dbitemcolumns.h ../core/user.h
sessionmanager.o: ../core/group.h ../core/dircontainer.h
sessionmanager.o: mount.h lastcontainer.h system.h job.h basethread.h
sessionmanager.o: synchro.h dirs.h dircontainer.h ../db/db.h ../db/dbbase.h
sessionmanager.o: ../db/dbconn.h ../db/dbtextstream.h ../core/error.h
sessionmanager.o: ../db/dbitemquery.h ../core/item.h ../db/dbitemcolumns.h
sessionmanager.o: ../core/user.h ../core/group.h ../core/dircontainer.h
sessionmanager.o: ../core/ugcontainer.h log.h logmanipulators.h slog.h
sessionmanager.o: ../templates/locale.h ../notify/notify.h
sessionmanager.o: ../notify/notifypool.h ../templates/patterns.h
@ -541,12 +543,13 @@ sessionmanager.o: ../templates/changepatterns.h ../templates/htmltextstream.h
sessionmanager.o: ../core/sessionmanager.h
sessionparser.o: sessionparser.h session.h item.h
sessionparser.o: ../../pikotools/space/space.h error.h user.h plugindata.h
sessionparser.o: rebus.h textstream.h sessioncontainer.h cur.h request.h
sessionparser.o: requesttypes.h config.h ../../pikotools/space/spaceparser.h
sessionparser.o: rebus.h textstream.h ../../pikotools/date/date.h
sessionparser.o: sessioncontainer.h cur.h request.h requesttypes.h config.h
sessionparser.o: ../../pikotools/space/spaceparser.h
sessionparser.o: ../../pikotools/space/space.h htmlfilter.h
sessionparser.o: ../templates/htmltextstream.h ../core/textstream.h misc.h
sessionparser.o: ../../pikotools/date/date.h mount.h users.h log.h
sessionparser.o: logmanipulators.h slog.h ../templates/locale.h
sessionparser.o: mount.h users.h log.h logmanipulators.h slog.h
sessionparser.o: ../templates/locale.h
slog.o: slog.h cur.h request.h requesttypes.h item.h
slog.o: ../../pikotools/space/space.h error.h config.h
slog.o: ../../pikotools/space/spaceparser.h ../../pikotools/space/space.h
@ -609,17 +612,17 @@ threadmanager.o: ../../pikotools/date/date.h session.h user.h plugindata.h
threadmanager.o: rebus.h mount.h ../templates/locale.h
users.o: users.h sessionmanager.h sessioncontainer.h session.h item.h
users.o: ../../pikotools/space/space.h error.h user.h plugindata.h rebus.h
users.o: textstream.h cur.h request.h requesttypes.h config.h
users.o: ../../pikotools/space/spaceparser.h ../../pikotools/space/space.h
users.o: htmlfilter.h ../templates/htmltextstream.h ../core/textstream.h
users.o: misc.h ../../pikotools/date/date.h mount.h lastcontainer.h system.h
users.o: job.h basethread.h synchro.h dirs.h dircontainer.h ../db/db.h
users.o: ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h ../core/error.h
users.o: ../db/dbitemquery.h ../core/item.h ../db/dbitemcolumns.h
users.o: ../core/user.h ../core/group.h ../core/dircontainer.h
users.o: ../core/ugcontainer.h log.h logmanipulators.h slog.h
users.o: ../templates/locale.h ../notify/notify.h ../notify/notifypool.h
users.o: ../templates/patterns.h ../templates/locale.h
users.o: textstream.h ../../pikotools/date/date.h cur.h request.h
users.o: requesttypes.h config.h ../../pikotools/space/spaceparser.h
users.o: ../../pikotools/space/space.h htmlfilter.h
users.o: ../templates/htmltextstream.h ../core/textstream.h misc.h mount.h
users.o: lastcontainer.h system.h job.h basethread.h synchro.h dirs.h
users.o: dircontainer.h ../db/db.h ../db/dbbase.h ../db/dbconn.h
users.o: ../db/dbtextstream.h ../core/error.h ../db/dbitemquery.h
users.o: ../core/item.h ../db/dbitemcolumns.h ../core/user.h ../core/group.h
users.o: ../core/dircontainer.h ../core/ugcontainer.h log.h logmanipulators.h
users.o: slog.h ../templates/locale.h ../notify/notify.h
users.o: ../notify/notifypool.h ../templates/patterns.h ../templates/locale.h
users.o: ../templates/localefilter.h ../../ezc/src/ezc.h
users.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h
users.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h

View File

@ -85,7 +85,6 @@ void Request::Clear()
using_ssl = false;
start_time = 0;
memset(&start_tm, 0, sizeof(start_tm));
start_date.Clear();
subdomain.clear();
@ -99,7 +98,6 @@ void Request::RequestStarts()
// so starting is much faster
start_time = std::time(0);
start_tm = Time(start_time);
start_date = start_time;
}

View File

@ -128,14 +128,10 @@ struct Request
// this is a pointer either to the item (if exists) or to the last directory
Item * last_item;
// depracated
// request start time
// Time() methods are very slow so it is better to directly use those two values
// they are set when a request starts
time_t start_time;
tm start_tm;
// now we start using PT::Date class
PT::Date start_date;
// a subdomain

View File

@ -15,7 +15,6 @@
Session::Session()
{
SetTimeToNow();
Clear();
plugin_data.SetSession(this);
}
@ -45,20 +44,21 @@ return *this;
void Session::SetTimeToNow()
void Session::SetTimesTo(time_t time)
{
time = std::time(0);
tm_time = Time(time);
start_time = time;
start_date = time;
last_time = time;
tm_last_time = tm_time;
last_time = start_time;
last_date = start_date;
// the first request can be a POST (it doesn't matter)
last_time_get = time;
last_time_get = start_time;
}
// this doesn't clear times
// clear_plugin_data is used when clearing the temporary session
void Session::Clear(bool clear_plugin_data)
{
id = 0;
@ -70,6 +70,16 @@ void Session::Clear(bool clear_plugin_data)
spam_score = 0;
remove_me = false;
start_time = 0;
last_time = 0;
last_time_get = 0;
start_date.Clear();
last_date.Clear();
tz_add = 0;
log_buffer.Clear();
last_css.clear();
if( clear_plugin_data )
plugin_data.Resize(0);
}

View File

@ -19,6 +19,7 @@
#include "plugindata.h"
#include "rebus.h"
#include "textstream.h"
#include "date/date.h"
@ -28,7 +29,7 @@ struct Session
Session(const Session & ses);
Session & operator=(const Session & ses);
void SetTimeToNow();
void SetTimesTo(time_t time);
void Clear(bool clear_plugin_data = true);
@ -40,18 +41,27 @@ struct Session
// when this session was created
// (the same values)
time_t time;
tm tm_time;
time_t start_time;
PT::Date start_date;
// when this session was last used
// (the same values)
time_t last_time;
tm tm_last_time;
PT::Date last_date;
// when there was a last get request
// (used to calculate spam)
time_t last_time_get;
// how many seconds should be added/substructed from the universal time
// to create the local time for this session/user
// it has combined time zone offset and daylight saving time
// so when reading a value from a user (e.g. in html form) you should
// substract tz_add and when printing you should add it
time_t tz_add;
// 0 - means that nobody is logged
User * puser;

View File

@ -128,7 +128,7 @@ SessionContainer::Iterator i = session_tab.End();
{
session = &(*i);
session->new_session = true;
session->SetTimeToNow();
session->SetTimesTo(cur->request->start_time);
log << log2 << "SM: created a new session: " << session->id << logend;
}
@ -138,7 +138,7 @@ SessionContainer::Iterator i = session_tab.End();
// we do not set a session cookie
session = &temporary_session;
session->Clear(false);
session->SetTimeToNow();
session->SetTimesTo(cur->request->start_time);
session->new_session = false; // temporary session was initialized at the beginning
log << log1 << "SM: cannot create a session id (temporary used: with id 0)" << logend;
}
@ -158,11 +158,11 @@ bool SessionManager::SetSessionFromCookie(const std::string & cookie)
// that session is in the table
session = &(*s);
session->new_session = false;
session->last_time = std::time(0);
session->tm_last_time = Time(session->last_time);
session->last_time = cur->request->start_time;
session->last_date = cur->request->start_time;
if( cur->request->method == Request::get )
session->last_time_get = session->last_time;
session->last_time_get = cur->request->start_time;
log << log2 << "SM: session: " << session->id;
@ -362,7 +362,7 @@ void SessionManager::SaveSessions()
if( i->id != 0 && i->puser && !i->remove_me )
{
file << i->id << ' ' << i->puser->id << ' ' << i->remember_me << ' ';
file << (long)i->time << ' ' << (long)i->last_time << std::endl;
file << (long)i->start_time << ' ' << (long)i->last_time << std::endl;
++len;
}

View File

@ -92,10 +92,11 @@ void SessionParser::MakeSession(long id, long user_id, SessionContainer & contai
i->puser = puser;
i->new_session = true;
i->remember_me = ReadLong();
i->time = ReadLong();
i->start_time = ReadLong();
i->last_time = ReadLong();
i->tm_time = Time(i->time);
i->tm_last_time = Time(i->last_time);
i->start_date = i->start_time;
i->last_date = i->last_time;
// !! IMPROVE ME we do not save last_time_get
users->IncrementLoggedUsers();
log << log2 << "SP: read session id: " << id << " for user: " << puser->name << logend;

View File

@ -13,6 +13,7 @@
#include <string>
#include <vector>
#include "space/space.h"
#include "date/date.h"
#define WINIX_ACCOUNT_MAX_LOGIN_SIZE 250
@ -93,6 +94,21 @@ struct User
// time zone
// values here are the same as those in env space
// we provide they here to speed up the process of calculating times
// time zone offset
time_t tz_offset;
// true if the time zone has daylight saving time
bool tz_has_dst;
// time zone daylight saving time (used if tz_has_dst is true)
// the 'year' field is ignored
PT::Date tz_dst_start, tz_dst_end;
User()
{
@ -112,6 +128,10 @@ struct User
env.Clear();
aenv.Clear();
status = WINIX_ACCOUNT_BLOCKED;
tz_offset = 0;
tz_has_dst = false;
tz_dst_start.Clear();
tz_dst_end.Clear();
}
@ -126,6 +146,16 @@ struct User
return false;
}
// lepsza nazwe dac
void SetTz()
{
tz_offset = env.Long(L"tz_offset");
}
};

View File

@ -30,7 +30,8 @@ exportinfo.o: ../../core/job.h ../../core/basethread.h ../../core/synchro.h
exportinfo.o: ../../../pikotools/space/space.h ../../core/dirs.h
exportinfo.o: ../../core/item.h ../../core/dircontainer.h ../../db/db.h
exportinfo.o: ../../db/dbbase.h ../../db/dbitemquery.h ../../core/item.h
exportinfo.o: ../../db/dbitemcolumns.h ../../core/user.h ../../core/group.h
exportinfo.o: ../../db/dbitemcolumns.h ../../core/user.h
exportinfo.o: ../../../pikotools/date/date.h ../../core/group.h
exportinfo.o: ../../core/dircontainer.h ../../core/ugcontainer.h
exportinfo.o: ../../core/log.h ../../core/textstream.h
exportinfo.o: ../../core/logmanipulators.h ../../core/slog.h ../../core/cur.h
@ -39,18 +40,17 @@ exportinfo.o: ../../core/error.h ../../core/config.h
exportinfo.o: ../../../pikotools/space/spaceparser.h
exportinfo.o: ../../../pikotools/space/space.h ../../core/htmlfilter.h
exportinfo.o: ../../templates/htmltextstream.h ../../core/textstream.h
exportinfo.o: ../../core/misc.h ../../../pikotools/date/date.h
exportinfo.o: ../../core/session.h ../../core/user.h ../../core/plugindata.h
exportinfo.o: ../../core/rebus.h ../../core/mount.h ../../templates/locale.h
exportinfo.o: ../../notify/notify.h ../../notify/notifypool.h
exportinfo.o: ../../templates/patterns.h ../../templates/locale.h
exportinfo.o: ../../templates/localefilter.h ../../../ezc/src/ezc.h
exportinfo.o: ../../../ezc/src/generator.h ../../../ezc/src/pattern.h
exportinfo.o: ../../../ezc/src/functions.h ../../../ezc/src/funinfo.h
exportinfo.o: ../../../ezc/src/stringconv.h ../../../pikotools/utf8/utf8.h
exportinfo.o: ../../notify/notifythread.h ../../core/basethread.h
exportinfo.o: ../../notify/templatesnotify.h ../../core/config.h
exportinfo.o: ../../core/users.h ../../core/ugcontainer.h
exportinfo.o: ../../core/misc.h ../../core/session.h ../../core/user.h
exportinfo.o: ../../core/plugindata.h ../../core/rebus.h ../../core/mount.h
exportinfo.o: ../../templates/locale.h ../../notify/notify.h
exportinfo.o: ../../notify/notifypool.h ../../templates/patterns.h
exportinfo.o: ../../templates/locale.h ../../templates/localefilter.h
exportinfo.o: ../../../ezc/src/ezc.h ../../../ezc/src/generator.h
exportinfo.o: ../../../ezc/src/pattern.h ../../../ezc/src/functions.h
exportinfo.o: ../../../ezc/src/funinfo.h ../../../ezc/src/stringconv.h
exportinfo.o: ../../../pikotools/utf8/utf8.h ../../notify/notifythread.h
exportinfo.o: ../../core/basethread.h ../../notify/templatesnotify.h
exportinfo.o: ../../core/config.h ../../core/users.h ../../core/ugcontainer.h
exportinfo.o: ../../core/lastcontainer.h ../../core/mounts.h
exportinfo.o: ../../core/mountparser.h ../../core/crypt.h ../../core/run.h
exportinfo.o: ../../core/users.h ../../core/groups.h ../../core/group.h

View File

@ -316,7 +316,8 @@ templates.o: ../../core/item.h ../../core/system.h ../../core/job.h
templates.o: ../../core/basethread.h ../../core/synchro.h ../../core/dirs.h
templates.o: ../../core/dircontainer.h ../../db/db.h ../../db/dbbase.h
templates.o: ../../db/dbitemquery.h ../../db/dbitemcolumns.h
templates.o: ../../core/user.h ../../core/group.h ../../core/dircontainer.h
templates.o: ../../core/user.h ../../../pikotools/date/date.h
templates.o: ../../core/group.h ../../core/dircontainer.h
templates.o: ../../core/ugcontainer.h ../../core/log.h
templates.o: ../../core/textstream.h ../../core/logmanipulators.h
templates.o: ../../core/slog.h ../../core/cur.h ../../core/request.h
@ -324,14 +325,14 @@ templates.o: ../../core/requesttypes.h ../../core/error.h ../../core/config.h
templates.o: ../../../pikotools/space/spaceparser.h
templates.o: ../../../pikotools/space/space.h ../../core/htmlfilter.h
templates.o: ../../templates/htmltextstream.h ../../core/textstream.h
templates.o: ../../core/misc.h ../../../pikotools/date/date.h
templates.o: ../../core/session.h ../../core/user.h ../../core/plugindata.h
templates.o: ../../core/rebus.h ../../core/mount.h ../../templates/locale.h
templates.o: ../../notify/notify.h ../../notify/notifypool.h
templates.o: ../../templates/patterns.h ../../templates/locale.h
templates.o: ../../templates/localefilter.h ../../notify/notifythread.h
templates.o: ../../core/basethread.h ../../notify/templatesnotify.h
templates.o: ../../core/config.h ../../core/users.h ../../core/ugcontainer.h
templates.o: ../../core/misc.h ../../core/session.h ../../core/user.h
templates.o: ../../core/plugindata.h ../../core/rebus.h ../../core/mount.h
templates.o: ../../templates/locale.h ../../notify/notify.h
templates.o: ../../notify/notifypool.h ../../templates/patterns.h
templates.o: ../../templates/locale.h ../../templates/localefilter.h
templates.o: ../../notify/notifythread.h ../../core/basethread.h
templates.o: ../../notify/templatesnotify.h ../../core/config.h
templates.o: ../../core/users.h ../../core/ugcontainer.h
templates.o: ../../core/lastcontainer.h ../../core/mounts.h
templates.o: ../../core/mountparser.h ../../core/crypt.h ../../core/run.h
templates.o: ../../core/users.h ../../core/groups.h ../../core/group.h
@ -375,7 +376,8 @@ ticketinfo.o: ../../core/job.h ../../core/basethread.h ../../core/synchro.h
ticketinfo.o: ../../../pikotools/space/space.h ../../core/dirs.h
ticketinfo.o: ../../core/item.h ../../core/dircontainer.h ../../db/db.h
ticketinfo.o: ../../db/dbbase.h ../../db/dbitemquery.h
ticketinfo.o: ../../db/dbitemcolumns.h ../../core/user.h ../../core/group.h
ticketinfo.o: ../../db/dbitemcolumns.h ../../core/user.h
ticketinfo.o: ../../../pikotools/date/date.h ../../core/group.h
ticketinfo.o: ../../core/dircontainer.h ../../core/ugcontainer.h
ticketinfo.o: ../../core/log.h ../../core/textstream.h
ticketinfo.o: ../../core/logmanipulators.h ../../core/slog.h ../../core/cur.h
@ -384,18 +386,17 @@ ticketinfo.o: ../../core/error.h ../../core/config.h
ticketinfo.o: ../../../pikotools/space/spaceparser.h
ticketinfo.o: ../../../pikotools/space/space.h ../../core/htmlfilter.h
ticketinfo.o: ../../templates/htmltextstream.h ../../core/textstream.h
ticketinfo.o: ../../core/misc.h ../../../pikotools/date/date.h
ticketinfo.o: ../../core/session.h ../../core/user.h ../../core/plugindata.h
ticketinfo.o: ../../core/rebus.h ../../core/mount.h ../../templates/locale.h
ticketinfo.o: ../../notify/notify.h ../../notify/notifypool.h
ticketinfo.o: ../../templates/patterns.h ../../templates/locale.h
ticketinfo.o: ../../templates/localefilter.h ../../../ezc/src/ezc.h
ticketinfo.o: ../../../ezc/src/generator.h ../../../ezc/src/pattern.h
ticketinfo.o: ../../../ezc/src/functions.h ../../../ezc/src/funinfo.h
ticketinfo.o: ../../../ezc/src/stringconv.h ../../../pikotools/utf8/utf8.h
ticketinfo.o: ../../notify/notifythread.h ../../core/basethread.h
ticketinfo.o: ../../notify/templatesnotify.h ../../core/config.h
ticketinfo.o: ../../core/users.h ../../core/ugcontainer.h
ticketinfo.o: ../../core/misc.h ../../core/session.h ../../core/user.h
ticketinfo.o: ../../core/plugindata.h ../../core/rebus.h ../../core/mount.h
ticketinfo.o: ../../templates/locale.h ../../notify/notify.h
ticketinfo.o: ../../notify/notifypool.h ../../templates/patterns.h
ticketinfo.o: ../../templates/locale.h ../../templates/localefilter.h
ticketinfo.o: ../../../ezc/src/ezc.h ../../../ezc/src/generator.h
ticketinfo.o: ../../../ezc/src/pattern.h ../../../ezc/src/functions.h
ticketinfo.o: ../../../ezc/src/funinfo.h ../../../ezc/src/stringconv.h
ticketinfo.o: ../../../pikotools/utf8/utf8.h ../../notify/notifythread.h
ticketinfo.o: ../../core/basethread.h ../../notify/templatesnotify.h
ticketinfo.o: ../../core/config.h ../../core/users.h ../../core/ugcontainer.h
ticketinfo.o: ../../core/lastcontainer.h ../../core/mounts.h
ticketinfo.o: ../../core/mountparser.h ../../core/crypt.h ../../core/run.h
ticketinfo.o: ../../core/users.h ../../core/groups.h ../../core/group.h

View File

@ -77,11 +77,11 @@ void who_tab_time(Info & i)
return;
i.out << DateToStr( 0,
who_iterator->tm_time.tm_mon + 1,
who_iterator->tm_time.tm_mday,
who_iterator->tm_time.tm_hour,
who_iterator->tm_time.tm_min,
who_iterator->tm_time.tm_sec );
who_iterator->start_date.month,
who_iterator->start_date.day,
who_iterator->start_date.hour,
who_iterator->start_date.min,
who_iterator->start_date.sec );
}
@ -91,11 +91,11 @@ void who_tab_last_time(Info & i)
return;
i.out << DateToStr( 0,
who_iterator->tm_last_time.tm_mon + 1,
who_iterator->tm_last_time.tm_mday,
who_iterator->tm_last_time.tm_hour,
who_iterator->tm_last_time.tm_min,
who_iterator->tm_last_time.tm_sec );
who_iterator->last_date.month,
who_iterator->last_date.day,
who_iterator->last_date.hour,
who_iterator->last_date.min,
who_iterator->last_date.sec );
}