users(u),
property(s->GetScriptsDir()),
WriteServLog(GetStgLogger()),
+ lastScanMessages(0),
login(),
id(0),
__connected(0),
connected(__connected),
+ enabledDirs(),
userIDGenerator(),
__currIP(0),
currIP(__currIP),
store(st),
tariffs(t),
tariff(NULL),
+ traffStat(),
+ traffStatSaved(),
+ settings(s),
+ authorizedBy(),
+ messages(),
+ deleted(false),
+ lastWriteStat(0),
+ lastWriteDetailedStat(0),
cash(property.cash),
up(property.up),
down(property.down),
userdata7(property.userdata7),
userdata8(property.userdata8),
userdata9(property.userdata9),
+ sessionUpload(),
+ sessionDownload(),
passiveNotifier(this),
tariffNotifier(this),
cashNotifier(this),
- ipNotifier(this)
+ ipNotifier(this),
+ mutex(),
+ errorStr()
{
-settings = s;
-
password = "*_EMPTY_PASSWORD_*";
tariffName = NO_TARIFF_NAME;
-connected = 0;
ips = StrToIPS("*");
-deleted = false;
lastWriteStat = stgTime + random() % settings->GetStatWritePeriod();
lastWriteDetailedStat = stgTime;
property.tariffName.AddBeforeNotifier(&tariffNotifier);
property.passive.AddBeforeNotifier(&passiveNotifier);
+property.disabled.AddAfterNotifier(&disabledNotifier);
property.cash.AddBeforeNotifier(&cashNotifier);
ips.AddAfterNotifier(&ipNotifier);
-lastScanMessages = 0;
-
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
}
#else
USER_IMPL::USER_IMPL(const SETTINGS_IMPL * s,
- const STORE * st,
- const TARIFFS * t,
- const ADMIN * a,
- const USERS * u)
+ const STORE * st,
+ const TARIFFS * t,
+ const ADMIN * a,
+ const USERS * u)
: USER(),
users(u),
property(s->GetScriptsDir()),
WriteServLog(GetStgLogger()),
+ lastScanMessages(0),
login(),
id(0),
__connected(0),
connected(__connected),
+ enabledDirs(),
userIDGenerator(),
__currIP(0),
currIP(__currIP),
store(st),
tariffs(t),
tariff(NULL),
+ traffStat(),
+ traffStatSaved(),
+ settings(s),
+ authorizedBy(),
+ messages(),
+ deleted(false),
+ lastWriteStat(0),
+ lastWriteDetailedStat(0),
cash(property.cash),
up(property.up),
down(property.down),
userdata7(property.userdata7),
userdata8(property.userdata8),
userdata9(property.userdata9),
+ sessionUpload(),
+ sessionDownload(),
passiveNotifier(this),
+ disabledNotifier(this),
tariffNotifier(this),
cashNotifier(this),
- ipNotifier(this)
+ ipNotifier(this),
+ mutex(),
+ errorStr()
{
-settings = s;
-
password = "*_EMPTY_PASSWORD_*";
tariffName = NO_TARIFF_NAME;
-connected = 0;
ips = StrToIPS("*");
-deleted = false;
lastWriteStat = stgTime + random() % settings->GetStatWritePeriod();
lastWriteDetailedStat = stgTime;
property.tariffName.AddBeforeNotifier(&tariffNotifier);
property.passive.AddBeforeNotifier(&passiveNotifier);
+property.disabled.AddAfterNotifier(&disabledNotifier);
property.cash.AddBeforeNotifier(&cashNotifier);
ips.AddAfterNotifier(&ipNotifier);
-lastScanMessages = 0;
-
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
users(u.users),
property(u.settings->GetScriptsDir()),
WriteServLog(GetStgLogger()),
+ lastScanMessages(0),
login(u.login),
id(u.id),
- __connected(u.__connected),
+ __connected(0),
connected(__connected),
+ enabledDirs(),
+ userIDGenerator(u.userIDGenerator),
__currIP(u.__currIP),
currIP(__currIP),
lastIPForDisconnect(0),
store(u.store),
tariffs(u.tariffs),
tariff(u.tariff),
+ traffStat(u.traffStat),
+ traffStatSaved(u.traffStatSaved),
+ settings(u.settings),
+ authorizedBy(),
+ messages(u.messages),
+ deleted(u.deleted),
+ lastWriteStat(u.lastWriteStat),
+ lastWriteDetailedStat(u.lastWriteDetailedStat),
cash(property.cash),
up(property.up),
down(property.down),
userdata7(property.userdata7),
userdata8(property.userdata8),
userdata9(property.userdata9),
+ sessionUpload(),
+ sessionDownload(),
passiveNotifier(this),
+ disabledNotifier(this),
tariffNotifier(this),
cashNotifier(this),
- ipNotifier(this)
+ ipNotifier(this),
+ mutex(),
+ errorStr()
{
if (&u == this)
return;
-connected = 0;
-
-deleted = u.deleted;
-
-lastWriteStat = u.lastWriteStat;
-lastWriteDetailedStat = u.lastWriteDetailedStat;
-
-settings = u.settings;
-
property.tariffName.AddBeforeNotifier(&tariffNotifier);
property.passive.AddBeforeNotifier(&passiveNotifier);
+property.disabled.AddAfterNotifier(&disabledNotifier);
property.cash.AddBeforeNotifier(&cashNotifier);
ips.AddAfterNotifier(&ipNotifier);
-lastScanMessages = 0;
-
property.SetProperties(u.property);
pthread_mutexattr_t attr;
//-----------------------------------------------------------------------------
USER_IMPL::~USER_IMPL()
{
-property.passive.DelBeforeNotifier(&passiveNotifier);
property.tariffName.DelBeforeNotifier(&tariffNotifier);
+property.passive.DelBeforeNotifier(&passiveNotifier);
+property.disabled.DelAfterNotifier(&disabledNotifier);
+property.cash.DelBeforeNotifier(&cashNotifier);
pthread_mutex_destroy(&mutex);
}
//-----------------------------------------------------------------------------
enabledDirs[i] = dirs & (1 << i);
}
-if (authorizedBy.size())
+if (!authorizedBy.empty())
{
if (currIP != ip)
{
property.cash.Set(c - fee, sysAdmin, login, store, "Subscriber fee charge");
break;
case 1:
- if (c > 0)
+ if (c + credit >= 0)
property.cash.Set(c - fee, sysAdmin, login, store, "Subscriber fee charge");
break;
case 2:
- if (c > fee)
+ if (c + credit >= fee)
+ property.cash.Set(c - fee, sysAdmin, login, store, "Subscriber fee charge");
+ break;
+ case 3:
+ if (c >= 0)
property.cash.Set(c - fee, sysAdmin, login, store, "Subscriber fee charge");
break;
}
}
double c = cash;
-printfd(__FILE__, "login: %8s Fee=%f PassiveTimePart=%f fee=%f\n",
+printfd(__FILE__, "login: %8s Cash=%f Credit=%f Fee=%f PassiveTimePart=%f fee=%f\n",
login.c_str(),
+ cash.ConstData(),
+ credit.ConstData(),
tariff->GetFee(),
passiveTimePart,
fee);
SetPrepaidTraff();
break;
case 1:
- if (c > 0)
+ if (c + credit >= 0)
{
property.cash.Set(c - fee, sysAdmin, login, store, "Subscriber fee charge");
SetPrepaidTraff();
}
break;
case 2:
- if (c > fee)
+ if (c + credit >= fee)
+ {
+ property.cash.Set(c - fee, sysAdmin, login, store, "Subscriber fee charge");
+ SetPrepaidTraff();
+ }
+ break;
+ case 3:
+ if (c >= 0)
{
property.cash.Set(c - fee, sysAdmin, login, store, "Subscriber fee charge");
SetPrepaidTraff();
"Freeze");
}
//-----------------------------------------------------------------------------
+void CHG_DISABLED_NOTIFIER::Notify(const int & oldValue, const int & newValue)
+{
+if (oldValue && !newValue && user->GetConnected())
+ {
+ user->Disconnect(false, "disabled");
+ }
+else if (!oldValue && newValue && user->IsInetable())
+ {
+ user->Connect(false);
+ }
+
+}
+//-----------------------------------------------------------------------------
void CHG_TARIFF_NOTIFIER::Notify(const string &, const string & newTariff)
{
if (user->settings->GetReconnectOnTariffChange() && user->connected)