added: winix function: rmuser
changed: UGContainer<> now uses std::list as a storage (previously it was using std::vector with pointers) removed: now we don't have the operator[] for UGContainer<> git-svn-id: svn://ttmath.org/publicrep/winix/trunk@816 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -30,16 +30,17 @@ app.o: ../functions/ln.h ../functions/ls.h ../functions/man.h
|
||||
app.o: ../functions/meta.h ../functions/mkdir.h ../functions/mv.h
|
||||
app.o: ../functions/nicedit.h ../functions/node.h ../functions/passwd.h
|
||||
app.o: ../functions/priv.h ../functions/pw.h ../functions/reload.h
|
||||
app.o: ../functions/rm.h ../functions/sort.h ../functions/specialdefault.h
|
||||
app.o: ../functions/stat.h ../functions/subject.h ../functions/template.h
|
||||
app.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
|
||||
app.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
|
||||
app.o: ../core/htmlfilter.h ../templates/templates.h
|
||||
app.o: ../templates/patterncacher.h ../templates/indexpatterns.h
|
||||
app.o: ../templates/patterns.h ../templates/changepatterns.h
|
||||
app.o: ../templates/htmltextstream.h ../core/sessionmanager.h compress.h
|
||||
app.o: postparser.h httpsimpleparser.h cookieparser.h postmultiparser.h
|
||||
app.o: acceptencodingparser.h acceptbaseparser.h plugin.h pluginmsg.h
|
||||
app.o: ../functions/rm.h ../functions/rmuser.h ../functions/sort.h
|
||||
app.o: ../functions/specialdefault.h ../functions/stat.h
|
||||
app.o: ../functions/subject.h ../functions/template.h ../functions/tinymce.h
|
||||
app.o: ../functions/uname.h ../functions/upload.h ../functions/uptime.h
|
||||
app.o: ../functions/who.h ../functions/vim.h ../core/htmlfilter.h
|
||||
app.o: ../templates/templates.h ../templates/patterncacher.h
|
||||
app.o: ../templates/indexpatterns.h ../templates/patterns.h
|
||||
app.o: ../templates/changepatterns.h ../templates/htmltextstream.h
|
||||
app.o: ../core/sessionmanager.h compress.h postparser.h httpsimpleparser.h
|
||||
app.o: cookieparser.h postmultiparser.h acceptencodingparser.h
|
||||
app.o: acceptbaseparser.h plugin.h pluginmsg.h
|
||||
basethread.o: basethread.h
|
||||
bbcodeparser.o: bbcodeparser.h htmlfilter.h
|
||||
compress.o: compress.h log.h textstream.h logmanipulators.h slog.h cur.h
|
||||
@@ -77,8 +78,9 @@ config.o: ../functions/ln.h ../functions/ls.h ../functions/man.h
|
||||
config.o: ../functions/meta.h ../functions/mkdir.h ../functions/mv.h
|
||||
config.o: ../functions/nicedit.h ../functions/node.h ../functions/passwd.h
|
||||
config.o: ../functions/priv.h ../functions/pw.h ../functions/reload.h
|
||||
config.o: ../functions/rm.h ../functions/sort.h ../functions/specialdefault.h
|
||||
config.o: ../functions/stat.h ../functions/subject.h ../functions/template.h
|
||||
config.o: ../functions/rm.h ../functions/rmuser.h ../functions/sort.h
|
||||
config.o: ../functions/specialdefault.h ../functions/stat.h
|
||||
config.o: ../functions/subject.h ../functions/template.h
|
||||
config.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
|
||||
config.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
|
||||
config.o: ../core/htmlfilter.h ../templates/templates.h
|
||||
@@ -148,9 +150,9 @@ image.o: ../functions/logout.h ../functions/ln.h ../functions/ls.h
|
||||
image.o: ../functions/man.h ../functions/meta.h ../functions/mkdir.h
|
||||
image.o: ../functions/mv.h ../functions/nicedit.h ../functions/node.h
|
||||
image.o: ../functions/passwd.h ../functions/priv.h ../functions/pw.h
|
||||
image.o: ../functions/reload.h ../functions/rm.h ../functions/sort.h
|
||||
image.o: ../functions/specialdefault.h ../functions/stat.h
|
||||
image.o: ../functions/subject.h ../functions/template.h
|
||||
image.o: ../functions/reload.h ../functions/rm.h ../functions/rmuser.h
|
||||
image.o: ../functions/sort.h ../functions/specialdefault.h
|
||||
image.o: ../functions/stat.h ../functions/subject.h ../functions/template.h
|
||||
image.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
|
||||
image.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
|
||||
image.o: ../core/htmlfilter.h ../templates/templates.h
|
||||
@@ -236,9 +238,9 @@ mounts.o: ../functions/logout.h ../functions/ln.h ../functions/ls.h
|
||||
mounts.o: ../functions/man.h ../functions/meta.h ../functions/mkdir.h
|
||||
mounts.o: ../functions/mv.h ../functions/nicedit.h ../functions/node.h
|
||||
mounts.o: ../functions/passwd.h ../functions/priv.h ../functions/pw.h
|
||||
mounts.o: ../functions/reload.h ../functions/rm.h ../functions/sort.h
|
||||
mounts.o: ../functions/specialdefault.h ../functions/stat.h
|
||||
mounts.o: ../functions/subject.h ../functions/template.h
|
||||
mounts.o: ../functions/reload.h ../functions/rm.h ../functions/rmuser.h
|
||||
mounts.o: ../functions/sort.h ../functions/specialdefault.h
|
||||
mounts.o: ../functions/stat.h ../functions/subject.h ../functions/template.h
|
||||
mounts.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
|
||||
mounts.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
|
||||
mounts.o: ../core/htmlfilter.h ../templates/templates.h
|
||||
@@ -274,9 +276,9 @@ plugin.o: ../functions/logout.h ../functions/ln.h ../functions/ls.h
|
||||
plugin.o: ../functions/man.h ../functions/meta.h ../functions/mkdir.h
|
||||
plugin.o: ../functions/mv.h ../functions/nicedit.h ../functions/node.h
|
||||
plugin.o: ../functions/passwd.h ../functions/priv.h ../functions/pw.h
|
||||
plugin.o: ../functions/reload.h ../functions/rm.h ../functions/sort.h
|
||||
plugin.o: ../functions/specialdefault.h ../functions/stat.h
|
||||
plugin.o: ../functions/subject.h ../functions/template.h
|
||||
plugin.o: ../functions/reload.h ../functions/rm.h ../functions/rmuser.h
|
||||
plugin.o: ../functions/sort.h ../functions/specialdefault.h
|
||||
plugin.o: ../functions/stat.h ../functions/subject.h ../functions/template.h
|
||||
plugin.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
|
||||
plugin.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
|
||||
plugin.o: ../core/htmlfilter.h ../templates/templates.h
|
||||
@@ -315,15 +317,16 @@ plugindata.o: ../functions/ls.h ../functions/man.h ../functions/meta.h
|
||||
plugindata.o: ../functions/mkdir.h ../functions/mv.h ../functions/nicedit.h
|
||||
plugindata.o: ../functions/node.h ../functions/passwd.h ../functions/priv.h
|
||||
plugindata.o: ../functions/pw.h ../functions/reload.h ../functions/rm.h
|
||||
plugindata.o: ../functions/sort.h ../functions/specialdefault.h
|
||||
plugindata.o: ../functions/stat.h ../functions/subject.h
|
||||
plugindata.o: ../functions/template.h ../functions/tinymce.h
|
||||
plugindata.o: ../functions/uname.h ../functions/upload.h
|
||||
plugindata.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
|
||||
plugindata.o: ../core/htmlfilter.h ../templates/templates.h
|
||||
plugindata.o: ../templates/patterncacher.h ../templates/indexpatterns.h
|
||||
plugindata.o: ../templates/patterns.h ../templates/changepatterns.h
|
||||
plugindata.o: ../templates/htmltextstream.h ../core/sessionmanager.h
|
||||
plugindata.o: ../functions/rmuser.h ../functions/sort.h
|
||||
plugindata.o: ../functions/specialdefault.h ../functions/stat.h
|
||||
plugindata.o: ../functions/subject.h ../functions/template.h
|
||||
plugindata.o: ../functions/tinymce.h ../functions/uname.h
|
||||
plugindata.o: ../functions/upload.h ../functions/uptime.h ../functions/who.h
|
||||
plugindata.o: ../functions/vim.h ../core/htmlfilter.h
|
||||
plugindata.o: ../templates/templates.h ../templates/patterncacher.h
|
||||
plugindata.o: ../templates/indexpatterns.h ../templates/patterns.h
|
||||
plugindata.o: ../templates/changepatterns.h ../templates/htmltextstream.h
|
||||
plugindata.o: ../core/sessionmanager.h
|
||||
postmultiparser.o: postmultiparser.h error.h requesttypes.h config.h
|
||||
postmultiparser.o: htmlfilter.h misc.h item.h log.h textstream.h
|
||||
postmultiparser.o: logmanipulators.h slog.h cur.h request.h
|
||||
@@ -364,7 +367,7 @@ request.o: ../functions/ln.h ../functions/ls.h ../functions/man.h
|
||||
request.o: ../functions/meta.h ../functions/mkdir.h ../functions/mv.h
|
||||
request.o: ../functions/nicedit.h ../functions/node.h ../functions/passwd.h
|
||||
request.o: ../functions/priv.h ../functions/pw.h ../functions/reload.h
|
||||
request.o: ../functions/rm.h ../functions/sort.h
|
||||
request.o: ../functions/rm.h ../functions/rmuser.h ../functions/sort.h
|
||||
request.o: ../functions/specialdefault.h ../functions/stat.h
|
||||
request.o: ../functions/subject.h ../functions/template.h
|
||||
request.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
|
||||
@@ -421,7 +424,7 @@ sessionmanager.o: ../functions/man.h ../functions/meta.h ../functions/mkdir.h
|
||||
sessionmanager.o: ../functions/mv.h ../functions/nicedit.h
|
||||
sessionmanager.o: ../functions/node.h ../functions/passwd.h
|
||||
sessionmanager.o: ../functions/priv.h ../functions/pw.h ../functions/reload.h
|
||||
sessionmanager.o: ../functions/rm.h ../functions/sort.h
|
||||
sessionmanager.o: ../functions/rm.h ../functions/rmuser.h ../functions/sort.h
|
||||
sessionmanager.o: ../functions/specialdefault.h ../functions/stat.h
|
||||
sessionmanager.o: ../functions/subject.h ../functions/template.h
|
||||
sessionmanager.o: ../functions/tinymce.h ../functions/uname.h
|
||||
@@ -475,8 +478,9 @@ system.o: ../functions/ln.h ../functions/ls.h ../functions/man.h
|
||||
system.o: ../functions/meta.h ../functions/mkdir.h ../functions/mv.h
|
||||
system.o: ../functions/nicedit.h ../functions/node.h ../functions/passwd.h
|
||||
system.o: ../functions/priv.h ../functions/pw.h ../functions/reload.h
|
||||
system.o: ../functions/rm.h ../functions/sort.h ../functions/specialdefault.h
|
||||
system.o: ../functions/stat.h ../functions/subject.h ../functions/template.h
|
||||
system.o: ../functions/rm.h ../functions/rmuser.h ../functions/sort.h
|
||||
system.o: ../functions/specialdefault.h ../functions/stat.h
|
||||
system.o: ../functions/subject.h ../functions/template.h
|
||||
system.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
|
||||
system.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
|
||||
system.o: plugin.h pluginmsg.h sessionmanager.h sessioncontainer.h
|
||||
@@ -487,4 +491,41 @@ threadmanager.o: item.h error.h config.h htmlfilter.h
|
||||
threadmanager.o: ../templates/htmltextstream.h ../core/textstream.h misc.h
|
||||
threadmanager.o: session.h user.h plugindata.h rebus.h mount.h
|
||||
threadmanager.o: ../templates/locale.h
|
||||
users.o: users.h
|
||||
users.o: users.h sessionmanager.h sessioncontainer.h session.h item.h error.h
|
||||
users.o: user.h plugindata.h rebus.h textstream.h cur.h request.h
|
||||
users.o: requesttypes.h config.h htmlfilter.h ../templates/htmltextstream.h
|
||||
users.o: ../core/textstream.h misc.h mount.h lastcontainer.h system.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
|
||||
users.o: ../../ezc/src/stringconv.h ../notify/notifythread.h
|
||||
users.o: ../core/basethread.h synchro.h ../notify/templatesnotify.h
|
||||
users.o: ../core/config.h ../core/users.h ugcontainer.h mounts.h
|
||||
users.o: mountparser.h crypt.h run.h groups.h group.h loadavg.h image.h
|
||||
users.o: basethread.h threadmanager.h plugin.h pluginmsg.h
|
||||
users.o: ../functions/functions.h ../functions/functionbase.h
|
||||
users.o: ../core/request.h ../core/system.h ../core/synchro.h
|
||||
users.o: ../functions/functionparser.h ../core/cur.h ../functions/adduser.h
|
||||
users.o: ../functions/cat.h ../functions/chmod.h ../functions/privchanger.h
|
||||
users.o: ../functions/chown.h ../functions/ckeditor.h ../functions/cp.h
|
||||
users.o: ../functions/default.h ../functions/download.h ../functions/emacs.h
|
||||
users.o: ../functions/env.h ../functions/last.h ../functions/login.h
|
||||
users.o: ../functions/logout.h ../functions/ln.h ../functions/ls.h
|
||||
users.o: ../functions/man.h ../functions/meta.h ../functions/mkdir.h
|
||||
users.o: ../functions/mv.h ../functions/nicedit.h ../functions/node.h
|
||||
users.o: ../functions/passwd.h ../functions/priv.h ../functions/pw.h
|
||||
users.o: ../functions/reload.h ../functions/rm.h ../functions/rmuser.h
|
||||
users.o: ../functions/sort.h ../functions/specialdefault.h
|
||||
users.o: ../functions/stat.h ../functions/subject.h ../functions/template.h
|
||||
users.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
|
||||
users.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
|
||||
users.o: ../core/htmlfilter.h ../templates/templates.h
|
||||
users.o: ../templates/patterncacher.h ../templates/indexpatterns.h
|
||||
users.o: ../templates/patterns.h ../templates/changepatterns.h
|
||||
users.o: ../templates/htmltextstream.h ../core/sessionmanager.h
|
||||
|
@@ -61,6 +61,7 @@ App::App()
|
||||
system.SetDb(&db);
|
||||
system.SetSynchro(&synchro);
|
||||
system.SetFunctions(&functions);
|
||||
system.SetSessionManager(&session_manager);
|
||||
|
||||
templates.SetConfig(&config);
|
||||
templates.SetCur(&cur);
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -39,7 +39,7 @@ Group * Groups::GetGroup(long group_id)
|
||||
if( i == table.End() )
|
||||
return 0;
|
||||
|
||||
return &(**i);
|
||||
return &(*i);
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ Group * Groups::GetGroup(const std::wstring & name)
|
||||
if( i == table.End() )
|
||||
return 0;
|
||||
|
||||
return &(**i);
|
||||
return &(*i);
|
||||
}
|
||||
|
||||
|
||||
@@ -86,9 +86,9 @@ Groups::SizeType Groups::Size()
|
||||
}
|
||||
|
||||
|
||||
Group & Groups::operator[](Groups::SizeType pos)
|
||||
bool Groups::Remove(long group_id)
|
||||
{
|
||||
return table[pos];
|
||||
return table.Remove(group_id);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
Iterator Begin();
|
||||
Iterator End();
|
||||
SizeType Size();
|
||||
Group & operator[](SizeType pos);
|
||||
bool Remove(long group_id);
|
||||
|
||||
};
|
||||
|
||||
|
@@ -165,21 +165,9 @@
|
||||
// from the session file
|
||||
#define WINIX_USER_LOGGED 30600
|
||||
|
||||
// preparing a current user to logout
|
||||
// send from 'logout' winix function
|
||||
// !! IMPROVE ME this message can be sent when winix is making the shutdown
|
||||
// (for sessions which are not mark as 'remember me')
|
||||
// and when the SessionManager deletes a session (from the special thread)
|
||||
#define WINIX_PREPARE_USER_LOGGED_OUT 30610
|
||||
|
||||
// a user has been logged out
|
||||
// send from 'logout' winix function
|
||||
// in l1 you have the old user_id
|
||||
// !! IMPROVE ME this message can be sent when winix is making the shutdown
|
||||
// (for sessions which are not mark as 'remember me')
|
||||
// and when the SessionManager deletes a session (from the special thread)
|
||||
#define WINIX_USER_LOGGED_OUT 30620
|
||||
|
||||
// a user is going to logout
|
||||
// in p1 you have a pointer to User struct
|
||||
#define WINIX_PREPARE_USER_TO_LOGOUT 30610
|
||||
|
||||
// here you add your own html templates
|
||||
// call TemplatesFunctions::patterns.Add(L"file_name.html")
|
||||
@@ -191,6 +179,16 @@
|
||||
// in other cases after 'reload' function the indexes would be wrong
|
||||
#define WINIX_ADD_TEMPLATE 31000
|
||||
|
||||
// a user will be removed
|
||||
// in p1 you have a pointer to the User struct
|
||||
// directly after this message a WINIX_USER_REMOVED will be sent
|
||||
#define WINIX_PREPARE_TO_REMOVE_USER 31010
|
||||
|
||||
// a user has been removed
|
||||
// in l1 you have the old user_id
|
||||
#define WINIX_USER_REMOVED 31020
|
||||
|
||||
|
||||
|
||||
|
||||
// values from 4000 - 4099 reserved for 'thread' plugin
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -44,6 +44,7 @@ void Session::Clear()
|
||||
remember_me = false;
|
||||
new_session = true;
|
||||
spam_score = 0;
|
||||
remove_me = false;
|
||||
plugin_data.Resize(0);
|
||||
}
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2011, Tomasz Sowa
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -61,6 +61,9 @@ struct Session
|
||||
|
||||
int spam_score;
|
||||
|
||||
// if true then this session will be removed by SessionManager
|
||||
// without checking the time expiration
|
||||
bool remove_me;
|
||||
|
||||
PluginData plugin_data;
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -153,7 +153,7 @@ bool SessionManager::SetSessionFromCookie(const std::string & cookie)
|
||||
long id = Tol(cookie.c_str());
|
||||
SessionContainer::Iterator s = session_tab.FindById(id);
|
||||
|
||||
if( s == session_tab.End() )
|
||||
if( s == session_tab.End() || s->remove_me )
|
||||
return false;
|
||||
|
||||
// that session is in the table
|
||||
@@ -220,6 +220,18 @@ SessionContainer::Iterator SessionManager::SessionEnd()
|
||||
|
||||
void SessionManager::DeleteSessions()
|
||||
{
|
||||
SessionContainer::Iterator i;
|
||||
|
||||
for(i=session_tab.Begin() ; i!=session_tab.End() ; ++i)
|
||||
{
|
||||
if( i->puser && !i->remember_me )
|
||||
{
|
||||
cur->session = &(*i); // for correctly setting a session data in plugins
|
||||
plugin.Call(WINIX_PREPARE_USER_TO_LOGOUT, i->puser);
|
||||
last_container->UserLogout(i->puser->id, i->id);
|
||||
}
|
||||
}
|
||||
|
||||
session_tab.Clear();
|
||||
}
|
||||
|
||||
@@ -300,7 +312,7 @@ void SessionManager::SaveSessions()
|
||||
|
||||
for( ; i!=session_tab.End() ; ++i )
|
||||
{
|
||||
if( i->id != 0 && i->puser )
|
||||
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;
|
||||
@@ -330,6 +342,30 @@ Session * SessionManager::GetCurSession()
|
||||
}
|
||||
|
||||
|
||||
// returns how many sessions was marked to remove
|
||||
size_t SessionManager::MarkAllSessionsToRemove(long user_id)
|
||||
{
|
||||
size_t how_many = 0;
|
||||
SessionContainer::Iterator i;
|
||||
Session * old_session = cur->session;
|
||||
|
||||
for(i=session_tab.Begin() ; i!=session_tab.End() ; ++i)
|
||||
{
|
||||
if( i->puser && i->puser->id == user_id )
|
||||
{
|
||||
cur->session = &(*i); // for correctly setting a session data in plugins
|
||||
plugin.Call(WINIX_PREPARE_USER_TO_LOGOUT, i->puser);
|
||||
last_container->UserLogout(i->puser->id, i->id);
|
||||
i->remove_me = true;
|
||||
i->puser = 0;
|
||||
how_many += 1;
|
||||
}
|
||||
}
|
||||
|
||||
cur->session = old_session;
|
||||
|
||||
return how_many;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -382,7 +418,7 @@ const int deleted_max_at_once = 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( IsSessionOutdated(*i->second) )
|
||||
if( i->second->remove_me || IsSessionOutdated(*i->second) )
|
||||
{
|
||||
DeleteSession(i++);
|
||||
++deleted;
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -50,6 +50,7 @@ public:
|
||||
SessionContainer::Iterator SessionEnd();
|
||||
|
||||
size_t Size();
|
||||
size_t MarkAllSessionsToRemove(long user_id);
|
||||
|
||||
private:
|
||||
|
||||
|
@@ -45,6 +45,10 @@ void System::SetFunctions(Functions * pfunctions)
|
||||
functions = pfunctions;
|
||||
}
|
||||
|
||||
void System::SetSessionManager(SessionManager * sm)
|
||||
{
|
||||
session_manager = sm;
|
||||
}
|
||||
|
||||
|
||||
void System::Init()
|
||||
@@ -65,6 +69,7 @@ void System::Init()
|
||||
mounts.ReadMounts();
|
||||
|
||||
users.SetCur(cur);
|
||||
users.SetSessionManager(session_manager);
|
||||
users.ReadUsers(db);
|
||||
users.SetTimeZoneOffset(config->time_zone_offset);
|
||||
groups.ReadGroups(db); // !! chwilowe przekazanie argumentu, db bedzie zmienione
|
||||
|
@@ -28,6 +28,7 @@
|
||||
|
||||
|
||||
class Functions;
|
||||
class SessionManager;
|
||||
|
||||
|
||||
// file system
|
||||
@@ -73,6 +74,7 @@ public:
|
||||
void SetDb(Db * pdb);
|
||||
void SetSynchro(Synchro * psynchro);
|
||||
void SetFunctions(Functions * pfunctions);
|
||||
void SetSessionManager(SessionManager * sm);
|
||||
void Init();
|
||||
|
||||
void AddParams(const ParamTab & param_tab, std::wstring & str, bool clear_str = true);
|
||||
@@ -158,6 +160,7 @@ private:
|
||||
Config * config;
|
||||
Synchro * synchro;
|
||||
Functions * functions;
|
||||
SessionManager * session_manager;
|
||||
|
||||
Item item_temp;
|
||||
std::wstring link_to_temp, name_temp;
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -10,11 +10,8 @@
|
||||
#ifndef headerfile_winix_core_ugcontainer
|
||||
#define headerfile_winix_core_ugcontainer
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "log.h"
|
||||
|
||||
|
||||
@@ -24,21 +21,17 @@ class UGContainer
|
||||
{
|
||||
public:
|
||||
|
||||
UGContainer();
|
||||
~UGContainer();
|
||||
|
||||
// we have to use a pointer (Type*) here
|
||||
// because we are remembering some pointers to the items elsewhere
|
||||
// so the pointers should not be invalidated
|
||||
typedef typename std::vector<Type*> Table;
|
||||
typedef typename Table::iterator Iterator;
|
||||
typedef typename Table::size_type SizeType;
|
||||
typedef typename std::list<Type> Table;
|
||||
typedef typename Table::iterator Iterator;
|
||||
typedef typename Table::size_type SizeType;
|
||||
|
||||
typedef typename std::map<long, SizeType> TableId;
|
||||
typedef typename std::map<std::wstring, SizeType> TableName;
|
||||
typedef typename std::map<long, Iterator> TableId;
|
||||
typedef typename std::map<std::wstring, Iterator> TableName;
|
||||
|
||||
|
||||
UGContainer();
|
||||
|
||||
Iterator Begin();
|
||||
Iterator End();
|
||||
SizeType Size();
|
||||
@@ -52,17 +45,25 @@ public:
|
||||
Iterator FindId(long id);
|
||||
Iterator FindName(const std::wstring & name);
|
||||
|
||||
Type & operator[](SizeType pos);
|
||||
bool Remove(long id);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
void AddIndexes(SizeType pos);
|
||||
// don't copy these objects
|
||||
UGContainer(const UGContainer<Type> &);
|
||||
UGContainer<Type> & operator=(const UGContainer<Type> &);
|
||||
|
||||
void AddIndexes(Iterator iter);
|
||||
void RebuildIndexes();
|
||||
|
||||
// main table
|
||||
Table table;
|
||||
|
||||
// table.size() has O(n) complexity
|
||||
size_t table_size;
|
||||
|
||||
// indexes
|
||||
TableId table_id;
|
||||
TableName table_name;
|
||||
@@ -80,6 +81,23 @@ UGContainer<Type>::~UGContainer()
|
||||
template<class Type>
|
||||
UGContainer<Type>::UGContainer()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
||||
// is private
|
||||
template<class Type>
|
||||
UGContainer<Type>::UGContainer(const UGContainer<Type> &)
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
// is private
|
||||
template<class Type>
|
||||
UGContainer<Type> & UGContainer<Type>::operator=(const UGContainer<Type> &)
|
||||
{
|
||||
Clear();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +120,7 @@ typename UGContainer<Type>::Iterator UGContainer<Type>::End()
|
||||
template<class Type>
|
||||
typename UGContainer<Type>::SizeType UGContainer<Type>::Size()
|
||||
{
|
||||
return table.size();
|
||||
return table_size;
|
||||
}
|
||||
|
||||
|
||||
@@ -121,12 +139,13 @@ typename UGContainer<Type>::Iterator UGContainer<Type>::PushBack(const Type & ty
|
||||
if( Is(type.id) || Is(type.name) )
|
||||
return End();
|
||||
|
||||
table.push_back(new Type(type));
|
||||
log << log2 << "UGCont: added, id: " << type.id << ", name: " << type.name << logend;
|
||||
|
||||
AddIndexes( table.size() - 1 );
|
||||
table.push_back(type);
|
||||
table_size += 1;
|
||||
Iterator i = --table.end();
|
||||
log << log3 << "UGCont: added, id: " << type.id << ", name: " << type.name << logend;
|
||||
AddIndexes(i);
|
||||
|
||||
return --table.end();
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
@@ -134,9 +153,7 @@ return --table.end();
|
||||
template<class Type>
|
||||
void UGContainer<Type>::Clear()
|
||||
{
|
||||
for(size_t i=0 ; i<table.size() ; ++i)
|
||||
delete table[i];
|
||||
|
||||
table_size = 0;
|
||||
table.clear();
|
||||
table_id.clear();
|
||||
table_name.clear();
|
||||
@@ -177,7 +194,7 @@ typename UGContainer<Type>::Iterator UGContainer<Type>::FindId(long id)
|
||||
if( i == table_id.end() )
|
||||
return table.end();
|
||||
|
||||
return table.begin() + i->second;
|
||||
return i->second;
|
||||
}
|
||||
|
||||
|
||||
@@ -190,18 +207,18 @@ typename UGContainer<Type>::Iterator UGContainer<Type>::FindName(const std::wstr
|
||||
if( i == table_name.end() )
|
||||
return table.end();
|
||||
|
||||
return table.begin() + i->second;
|
||||
return i->second;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class Type>
|
||||
void UGContainer<Type>::AddIndexes(UGContainer<Type>::SizeType pos)
|
||||
void UGContainer<Type>::AddIndexes(UGContainer<Type>::Iterator iter)
|
||||
{
|
||||
table_id.insert( std::make_pair(table[pos]->id, pos) );
|
||||
table_name.insert( std::make_pair(table[pos]->name, pos) );
|
||||
table_id.insert( std::make_pair(iter->id, iter) );
|
||||
table_name.insert( std::make_pair(iter->name, iter) );
|
||||
|
||||
log << log4 << "UGCont: added indexes to: id: " << table[pos]->id << ", name: " << table[pos]->name << logend;
|
||||
log << log4 << "UGCont: added indexes to: id: " << iter->id << ", name: " << iter->name << logend;
|
||||
}
|
||||
|
||||
|
||||
@@ -209,30 +226,51 @@ void UGContainer<Type>::AddIndexes(UGContainer<Type>::SizeType pos)
|
||||
template<class Type>
|
||||
void UGContainer<Type>::RebuildIndexes()
|
||||
{
|
||||
Iterator i;
|
||||
|
||||
log << log4 << "UGCont: rebuilding indexes" << logend;
|
||||
|
||||
table_id.clear();
|
||||
table_name.clear();
|
||||
|
||||
SizeType i, len = table.size();
|
||||
|
||||
|
||||
for(i=0 ; i!=len ; ++i)
|
||||
AddIndexes( i );
|
||||
|
||||
for(i=table.begin() ; i!=table.end() ; ++i)
|
||||
AddIndexes(i);
|
||||
|
||||
log << log4 << "UGCont: indexes rebuilt, table.size: " << table.size() << ", table_id.size: "
|
||||
log << log4 << "UGCont: indexes rebuilt, table.size: " << table_size << ", table_id.size: "
|
||||
<< table_id.size() << ", table_name.size: " << table_name.size() << logend;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type & UGContainer<Type>::operator[](UGContainer<Type>::SizeType pos)
|
||||
{
|
||||
if( pos >= table.size() )
|
||||
throw std::out_of_range("UGContainer: operator[]: index is out of range");
|
||||
|
||||
return *table[pos];
|
||||
|
||||
template<class Type>
|
||||
bool UGContainer<Type>::Remove(long id)
|
||||
{
|
||||
typename TableId::iterator i = table_id.find(id);
|
||||
typename TableName::iterator n;
|
||||
bool result = false;
|
||||
|
||||
if( i != table_id.end() )
|
||||
{
|
||||
for(n=table_name.begin() ; n != table_name.end() ; ++n)
|
||||
{
|
||||
if( n->second == i->second )
|
||||
{
|
||||
table_name.erase(n);
|
||||
log << log4 << "UGCont: removed index_id to: id: " << i->second->id << ", name: " << i->second->name << logend;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
log << log4 << "UGCont: removed index_name to: id: " << i->second->id << ", name: " << i->second->name << logend;
|
||||
log << log3 << "UGCont: removed: id: " << i->second->id << ", name: " << i->second->name << logend;
|
||||
table.erase(i->second);
|
||||
table_id.erase(i);
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -2,13 +2,15 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include "users.h"
|
||||
#include "sessionmanager.h"
|
||||
#include "plugin.h"
|
||||
|
||||
|
||||
|
||||
@@ -25,6 +27,12 @@ void Users::SetCur(Cur * pcur)
|
||||
}
|
||||
|
||||
|
||||
void Users::SetSessionManager(SessionManager * sm)
|
||||
{
|
||||
session_manager = sm;
|
||||
}
|
||||
|
||||
|
||||
void Users::Clear()
|
||||
{
|
||||
table.Clear();
|
||||
@@ -45,7 +53,7 @@ void Users::SetTimeZoneOffset(int offset)
|
||||
|
||||
for(i=table.Begin() ; i!=table.End() ; ++i)
|
||||
{
|
||||
(*i)->time_zone_offset = offset;
|
||||
i->time_zone_offset = offset;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +79,7 @@ User * Users::GetUser(long user_id)
|
||||
if( i == table.End() )
|
||||
return 0;
|
||||
|
||||
return &(**i);
|
||||
return &(*i);
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +90,7 @@ User * Users::GetUser(const std::wstring & name)
|
||||
if( i == table.End() )
|
||||
return 0;
|
||||
|
||||
return &(**i);
|
||||
return &(*i);
|
||||
}
|
||||
|
||||
|
||||
@@ -119,13 +127,28 @@ Users::SizeType Users::Size()
|
||||
}
|
||||
|
||||
|
||||
|
||||
User & Users::operator[](Users::SizeType pos)
|
||||
bool Users::Remove(long user_id)
|
||||
{
|
||||
return table[pos];
|
||||
bool result = false;
|
||||
User * puser = GetUser(user_id);
|
||||
|
||||
if( puser )
|
||||
{
|
||||
LogoutUser(user_id);
|
||||
plugin.Call(WINIX_PREPARE_TO_REMOVE_USER, puser);
|
||||
result = table.Remove(user_id);
|
||||
|
||||
if( result )
|
||||
plugin.Call(WINIX_USER_REMOVED, user_id);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// !! IMPROVE ME
|
||||
// this method is too long
|
||||
bool Users::LoginUser(long user_id, bool remember_me, bool use_ses_log)
|
||||
{
|
||||
if( !cur->session )
|
||||
@@ -191,6 +214,27 @@ return true;
|
||||
}
|
||||
|
||||
|
||||
size_t Users::LogoutUser(long user_id)
|
||||
{
|
||||
size_t how_many = 0;
|
||||
User * puser = GetUser(user_id);
|
||||
|
||||
if( puser )
|
||||
{
|
||||
log << log2 << "Users: logging out user " << puser->name << ", id: "
|
||||
<< puser->id << " from all sessions" << logend;
|
||||
|
||||
// WINIX_PREPARE_USER_TO_LOGOUT will be sent by MarkAllSessionsToRemove()
|
||||
how_many = session_manager->MarkAllSessionsToRemove(user_id);
|
||||
how_many_logged -= how_many;
|
||||
|
||||
if( how_many )
|
||||
log << log3 << "Users: " << how_many << " user(s) were logged out" << logend;
|
||||
}
|
||||
|
||||
return how_many;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Users::LogoutCurrentUser()
|
||||
@@ -201,13 +245,14 @@ void Users::LogoutCurrentUser()
|
||||
log << log2 << "Users: user " << cur->session->puser->name << ", id: "
|
||||
<< cur->session->puser->id << " logged out" << logend;
|
||||
|
||||
plugin.Call(WINIX_PREPARE_USER_TO_LOGOUT, cur->session->puser);
|
||||
last.UserLogout(cur->session->puser->id, cur->session->id);
|
||||
|
||||
if( how_many_logged > 0 ) // for safety
|
||||
how_many_logged -= 1;
|
||||
|
||||
cur->session->puser = 0;
|
||||
cur->session->remember_me = 0;
|
||||
cur->session->remember_me = false;
|
||||
}
|
||||
|
||||
|
||||
|
13
core/users.h
13
core/users.h
@@ -2,7 +2,7 @@
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008-2010, Tomasz Sowa
|
||||
* Copyright (c) 2008-2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
@@ -17,6 +17,8 @@
|
||||
#include "cur.h"
|
||||
#include "db/db.h"
|
||||
|
||||
class SessionManager;
|
||||
|
||||
|
||||
class Users
|
||||
{
|
||||
@@ -24,6 +26,7 @@ typedef UGContainer<User> Table;
|
||||
Table table;
|
||||
|
||||
Cur * cur;
|
||||
SessionManager * session_manager;
|
||||
long how_many_logged;
|
||||
|
||||
public:
|
||||
@@ -36,6 +39,7 @@ public:
|
||||
Users();
|
||||
|
||||
void SetCur(Cur * pcur);
|
||||
void SetSessionManager(SessionManager * sm);
|
||||
|
||||
void Clear();
|
||||
void ReadUsers(Db * db);
|
||||
@@ -48,10 +52,11 @@ public:
|
||||
Iterator Begin();
|
||||
Iterator End();
|
||||
SizeType Size();
|
||||
User & operator[](SizeType pos);
|
||||
bool Remove(long user_id);
|
||||
|
||||
bool LoginUser(long user_id, bool remember_me, bool use_ses_log = false);
|
||||
void LogoutCurrentUser();
|
||||
bool LoginUser(long user_id, bool remember_me, bool use_ses_log = false);
|
||||
size_t LogoutUser(long user_id);
|
||||
void LogoutCurrentUser();
|
||||
|
||||
void IncrementLoggedUsers();
|
||||
long HowManyLogged();
|
||||
|
Reference in New Issue
Block a user