78 lines
1.2 KiB
C++
Executable File
78 lines
1.2 KiB
C++
Executable File
/*
|
|
* This file is a part of CMSLU -- Content Management System like Unix
|
|
* and is not publicly distributed
|
|
*
|
|
* Copyright (c) 2009, Tomasz Sowa
|
|
* All rights reserved.
|
|
*
|
|
*/
|
|
|
|
#ifndef headerfilecmslucorelastcontainer
|
|
#define headerfilecmslucorelastcontainer
|
|
|
|
#include <string>
|
|
#include <list>
|
|
#include <cstring>
|
|
#include <ctime>
|
|
|
|
|
|
|
|
// how many items we store in the 'last' function
|
|
#define LAST_TABLE_SIZE 100
|
|
|
|
|
|
|
|
struct LastItem
|
|
{
|
|
long user_id;
|
|
|
|
// additional we store the whole string-name
|
|
// (you can delete a user from the database but we can still print the name)
|
|
std::string name;
|
|
|
|
// ip address
|
|
unsigned int ip;
|
|
|
|
// session id (used when logging out)
|
|
long session_id;
|
|
|
|
// start logging and end logging
|
|
tm start;
|
|
tm end;
|
|
|
|
|
|
LastItem();
|
|
bool IsLoggedOut();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class LastContainer
|
|
{
|
|
public:
|
|
|
|
typedef std::list<LastItem> LastTab;
|
|
typedef LastTab::iterator Iterator;
|
|
|
|
|
|
public:
|
|
|
|
Iterator Begin();
|
|
Iterator End();
|
|
void UserLogin(long user_id, const std::string & name, unsigned int ip, long session_id);
|
|
void UserLogout(long user_id, long session_id);
|
|
|
|
|
|
private:
|
|
|
|
LastTab last_tab;
|
|
Iterator FindNotLoggedOut(long user_id, long session_id);
|
|
|
|
};
|
|
|
|
|
|
#endif
|