2008-12-10 05:42:49 +01:00
|
|
|
/*
|
2010-02-28 01:08:10 +01:00
|
|
|
* This file is a part of Winix
|
2014-10-04 20:04:03 +02:00
|
|
|
* and is distributed under the 2-Clause BSD licence.
|
|
|
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2021-02-24 01:19:47 +01:00
|
|
|
* Copyright (c) 2008-2021, Tomasz Sowa
|
2008-12-10 05:42:49 +01:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
2014-10-04 20:04:03 +02:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
2008-12-10 05:42:49 +01:00
|
|
|
*/
|
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
#ifndef headerfile_winix_core_session
|
|
|
|
#define headerfile_winix_core_session
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2011-06-24 22:53:21 +02:00
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
2008-12-10 05:42:49 +01:00
|
|
|
#include <ctime>
|
2018-07-02 13:16:36 +02:00
|
|
|
#include <map>
|
2009-04-21 22:50:55 +02:00
|
|
|
#include "error.h"
|
2021-04-30 01:34:48 +02:00
|
|
|
#include "models/user.h"
|
2010-05-04 23:58:22 +02:00
|
|
|
#include "plugindata.h"
|
2010-08-10 18:12:50 +02:00
|
|
|
#include "rebus.h"
|
2011-06-19 22:59:58 +02:00
|
|
|
#include "textstream.h"
|
2012-05-24 23:09:37 +02:00
|
|
|
#include "date/date.h"
|
2012-10-27 09:44:26 +02:00
|
|
|
#include "ipban.h"
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
|
2014-02-12 17:30:49 +01:00
|
|
|
namespace Winix
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2012-03-17 06:11:23 +01:00
|
|
|
|
2021-06-18 19:18:13 +02:00
|
|
|
class Session
|
2008-12-10 05:42:49 +01:00
|
|
|
{
|
2021-06-18 19:18:13 +02:00
|
|
|
public:
|
2018-07-02 13:16:36 +02:00
|
|
|
|
2012-03-17 06:11:23 +01:00
|
|
|
Session();
|
|
|
|
Session(const Session & ses);
|
|
|
|
Session & operator=(const Session & ses);
|
|
|
|
|
2012-05-24 23:09:37 +02:00
|
|
|
void SetTimesTo(time_t time);
|
2012-03-17 06:11:23 +01:00
|
|
|
void Clear(bool clear_plugin_data = true);
|
2013-12-04 02:21:57 +01:00
|
|
|
void ClearAfterRequest();
|
2012-03-17 06:11:23 +01:00
|
|
|
|
|
|
|
|
2010-12-07 18:41:28 +01:00
|
|
|
// 0 - means that there is a temporary session
|
2008-12-30 02:05:03 +01:00
|
|
|
long id;
|
2008-12-21 22:17:09 +01:00
|
|
|
|
2014-11-22 16:30:56 +01:00
|
|
|
// a session index
|
|
|
|
// incremented each time a request to this session is made
|
|
|
|
unsigned int id_index;
|
|
|
|
|
|
|
|
// the last time when id_index was incremented
|
|
|
|
time_t id_index_changed;
|
|
|
|
|
2009-11-21 00:09:52 +01:00
|
|
|
// true if the session was created now
|
|
|
|
bool new_session;
|
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
// when this session was created
|
2009-01-31 07:53:36 +01:00
|
|
|
// (the same values)
|
2012-05-24 23:09:37 +02:00
|
|
|
time_t start_time;
|
2021-05-20 20:59:12 +02:00
|
|
|
pt::Date start_date;
|
2009-01-31 07:53:36 +01:00
|
|
|
|
|
|
|
// when this session was last used
|
|
|
|
// (the same values)
|
2012-05-24 23:09:37 +02:00
|
|
|
time_t last_time;
|
2021-05-20 20:59:12 +02:00
|
|
|
pt::Date last_date;
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2009-12-09 01:42:40 +01:00
|
|
|
// when there was a last get request
|
2012-10-27 09:44:26 +02:00
|
|
|
// (used to calculate spam or invalid login attempts etc.)
|
2009-12-09 01:42:40 +01:00
|
|
|
time_t last_time_get;
|
2009-01-31 07:53:36 +01:00
|
|
|
|
2012-05-24 23:09:37 +02:00
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
// 0 - means that nobody is logged
|
2008-12-21 22:17:09 +01:00
|
|
|
User * puser;
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2009-11-21 00:09:52 +01:00
|
|
|
// if false the session will end when the user browser is shutdown
|
|
|
|
bool remember_me;
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2012-03-09 03:36:25 +01:00
|
|
|
// if true then this session will be removed by SessionManager
|
|
|
|
// without checking the time expiration
|
|
|
|
bool remove_me;
|
2010-05-04 23:58:22 +02:00
|
|
|
|
|
|
|
PluginData plugin_data;
|
|
|
|
|
2010-12-07 18:41:28 +01:00
|
|
|
|
2011-06-19 22:59:58 +02:00
|
|
|
// buffer for the session log
|
|
|
|
TextStream<std::wstring> log_buffer;
|
2010-12-07 18:41:28 +01:00
|
|
|
|
2012-10-17 08:00:00 +02:00
|
|
|
// !! IMPROVE ME it is still needed?
|
|
|
|
// css cannot be taken directly from the mountpoint?
|
2011-06-24 22:53:21 +02:00
|
|
|
// table with css files
|
|
|
|
// used by some javascript wysiwyg editors (ckeditor, tinymce)
|
|
|
|
std::vector<std::wstring> last_css;
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2012-10-27 09:44:26 +02:00
|
|
|
// pointer to IPBan struct if exists for this IP
|
|
|
|
// many sessions can pointer to the same IPBan struct
|
|
|
|
// (it can be null)
|
|
|
|
IPBan * ip_ban;
|
|
|
|
|
2018-07-02 13:16:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// rebus - set by rebus_question(Info & i) from templates
|
|
|
|
Rebus::Item * rebus_item;
|
|
|
|
bool rebus_checked;
|
|
|
|
int spam_score;
|
|
|
|
std::map<long, long> antispan;
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-12 17:30:49 +01:00
|
|
|
} // namespace Winix
|
|
|
|
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|