<commit_before>/* Copyright (c) 2010-2012, <NAME>
 * All rights reserved.
 *
 * This software may be used and distributed according to the terms of
 * the New BSD License, which is incorporated herein by reference.
 */

#include <QHostInfo>
#include <QCryptographicHash>
#include <QThread>
#include <TWebApplication>
#include <TSessionStore>
#include "tsystemglobal.h"
#include "tsessionmanager.h"
#include "tsessionstorefactory.h"

#define STORE_TYPE          "Session.StoreType"
#define GC_PROBABILITY      "Session.GcProbability"
#define GC_MAX_LIFE_TIME    "Session.GcMaxLifeTime"
#define SESSION_LIFETIME    "Session.LifeTime"


static QByteArray randomString()
{
    QByteArray data;
    data.reserve(128);

    QDateTime now = QDateTime::currentDateTime();
    data.append(QByteArray::number(now.toTime_t()));
    data.append(QByteArray::number(now.time().msec()));
    data.append(QHostInfo::localHostName());
    data.append(QByteArray::number(QCoreApplication::applicationPid()));
    data.append(QByteArray::number((qulonglong)QThread::currentThread()));
    data.append(QByteArray::number((qulonglong)qApp));
    data.append(QByteArray::number(Tf::randXor128()));
    return QCryptographicHash::hash(data, QCryptographicHash::Sha1).toHex();
}


TSessionManager::TSessionManager()
{ }


TSessionManager::~TSessionManager()
{ }


TSession TSessionManager::findSession(const QByteArray &id)
{
    T_TRACEFUNC("");

    QDateTime now = QDateTime::currentDateTime();
    QDateTime validCreated = (sessionLifeTime() > 0) ? now.addSecs(-sessionLifeTime()) : now.addYears(-20);<commit_msg>modified to use currentMSecsSinceEpoch() in randomString() function.<commit_after>/* Copyright (c) 2010-2012, <NAME>
 * All rights reserved.
 *
 * This software may be used and distributed according to the terms of
 * the New BSD License, which is incorporated herein by reference.
 */

#include <QHostInfo>
#include <QCryptographicHash>
#include <QThread>
#include <TWebApplication>
#include <TSessionStore>
#include "tsystemglobal.h"
#include "tsessionmanager.h"
#include "tsessionstorefactory.h"

#define STORE_TYPE          "Session.StoreType"
#define GC_PROBABILITY      "Session.GcProbability"
#define GC_MAX_LIFE_TIME    "Session.GcMaxLifeTime"
#define SESSION_LIFETIME    "Session.LifeTime"


static QByteArray randomString()
{
    QByteArray data;
    data.reserve(128);

#if QT_VERSION >= 0x040700
    data.append(QByteArray::number(QDateTime::currentMSecsSinceEpoch()));
#else
    QDateTime now = QDateTime::currentDateTime();
    data.append(QByteArray::number(now.toTime_t()));
    data.append(QByteArray::number(now.time().msec()));
#endif
    data.append(QHostInfo::localHostName());
    data.append(QByteArray::number(QCoreApplication::applicationPid()));
    data.append(QByteArray::number((qulonglong)QThread::currentThread()));
    data.append(QByteArray::number((qulonglong)qApp));
    data.append(QByteArray::number(Tf::randXor128()));
    return QCryptographicHash::hash(data, QCryptographicHash::Sha1).toHex();
}


TSessionManager::TSessionManager()
{ }


TSessionManager::~TSessionManager()
{ }


TSession TSessionManager::findSession(const QByteArray &id)
{
    T_TRACEFUNC("");

    QDateTime now = QDateTime::currentDateTime();
    QDateTime validCreated = (sessionLifeTime() > 0) ? now.addSecs(-sessionLifeTime()) : now.addYears(-20);
{'fraction_non_alphanumeric': 0.13710879284649777, 'fraction_numerical': 0.012816691505216096, 'mean_word_length': 5.962655601659751, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6852449', 'n_tokens_mistral': 1114, 'n_tokens_neox': 1060, 'n_words': 197}