# Default: 1
DayFee = 1
+# When set to 'no' Stargazer will continue reading database after error and show all of them.
+# Parameter: optional
+# Values: yes, no
+# Default: yes
+# StopOnError = yes
+
# Fee charged at the last (yes) or first (no) day of tariffication period.
# Defines how the fee will be charged in the transition to the new tariff.
# User has tariff A with fee 100. Changing it to tariff B with fee 200
# Default: no
# ReconnectOnTariffChange = no
+ # Definest set of parameters passed to OnConnect and OnDisconnect scripts
+ # This set is added to the end of the default param list, which are, respectively:
+ # login, ip, cash, id, dirs
+ # Valid parameter names: "cash", "upload", "download", "lastCashAdd", "passiveTime",
+ # "lastCashAddTime", "freeMb", "lastActivityTime", "password", "passive", "disabled",
+ # "disabledDetailStat", "alwaysOnline", "tariffName", "nextTariff", "address",
+ # "note", "group", "email", "phone", "realName", "credit", "creditExpire", "ips",
+ # "userdata0" ... "userdata9".
+ # Parameter: optional
+ # Values: parameter names, case insensitive
+ # Default:
+ # ScriptParams =
+
+ # Enable or disable writing session log
+ # Parameter: optional
+ # Values: yes, no
+ # Default: no (session log is enabled)
+ # DisableSessionLog = no
+
+ # Filter for logging parameter changes
+ # Defines which parameters will be logged to parameter log in database. Allows
+ # to specify multiuple parameter names or asterisk (*), which means "log all params".
+ # Valid parameter names: "cash", "upload", "download", "lastCashAdd", "passiveTime",
+ # "lastCashAddTime", "freeMb", "lastActivityTime", "password", "passive", "disabled",
+ # "disabledDetailStat", "alwaysOnline", "tariffName", "nextTariff", "address",
+ # "note", "group", "email", "phone", "realName", "credit", "creditExpire", "ips",
+ # "userdata0" ... "userdata9".
+ # Parameter: optional
+ # Values: parameter names, case insensitive, or "*"
+ # Default: *
+ # FilterParamsLog = *
+
################################################################################
# Store module
# Configure the module that works with the database server
# Default: 1
DayFee = 1
+# When set to 'no' Stargazer will continue reading database after error and show all of them.
+# Parameter: optional
+# Values: yes, no
+# Default: yes
+# StopOnError = yes
+
# Fee charged at the last (yes) or first (no) day of tariffication period.
# Defines how the fee will be charged in the transition to the new tariff.
# User has tariff A with fee 100. Changing it to tariff B with fee 200
# Default: no
# ReconnectOnTariffChange = no
+ # Definest set of parameters passed to OnConnect and OnDisconnect scripts
+ # This set is added to the end of the default param list, which are, respectively:
+ # login, ip, cash, id, dirs
+ # Valid parameter names: "cash", "upload", "download", "lastCashAdd", "passiveTime",
+ # "lastCashAddTime", "freeMb", "lastActivityTime", "password", "passive", "disabled",
+ # "disabledDetailStat", "alwaysOnline", "tariffName", "nextTariff", "address",
+ # "note", "group", "email", "phone", "realName", "credit", "creditExpire", "ips",
+ # "userdata0" ... "userdata9".
+ # Parameter: optional
+ # Values: parameter names, case insensitive
+ # Default:
+ # ScriptParams =
+
+ # Enable or disable writing session log
+ # Parameter: optional
+ # Values: yes, no
+ # Default: no (session log is enabled)
+ # DisableSessionLog = no
+
+ # Filter for logging parameter changes
+ # Defines which parameters will be logged to parameter log in database. Allows
+ # to specify multiuple parameter names or asterisk (*), which means "log all params".
+ # Valid parameter names: "cash", "upload", "download", "lastCashAdd", "passiveTime",
+ # "lastCashAddTime", "freeMb", "lastActivityTime", "password", "passive", "disabled",
+ # "disabledDetailStat", "alwaysOnline", "tariffName", "nextTariff", "address",
+ # "note", "group", "email", "phone", "realName", "credit", "creditExpire", "ips",
+ # "userdata0" ... "userdata9".
+ # Parameter: optional
+ # Values: parameter names, case insensitive, or "*"
+ # Default: *
+ # FilterParamsLog = *
+
################################################################################
# Store module
# Configure the module that works with the database server
spreadFee(false),
freeMbAllowInet(false),
dayFeeIsLastDay(false),
+ stopOnError(true),
writeFreeMbTraffCost(false),
showFeeInCash(true),
messageTimeout(0),
feeChargeType(0),
reconnectOnTariffChange(false),
+ disableSessionLog(false),
logger(GetStgLogger())
{
+ filterParamsLog.push_back("*");
}
//-----------------------------------------------------------------------------
SETTINGS_IMPL::SETTINGS_IMPL(const SETTINGS_IMPL & rval)
- : SETTINGS(),
- strError(),
- modulesPath(rval.modulesPath),
+ : modulesPath(rval.modulesPath),
dirName(rval.dirName),
confDir(rval.confDir),
scriptsDir(rval.scriptsDir),
spreadFee(rval.spreadFee),
freeMbAllowInet(rval.freeMbAllowInet),
dayFeeIsLastDay(rval.dayFeeIsLastDay),
+ stopOnError(rval.stopOnError),
writeFreeMbTraffCost(rval.writeFreeMbTraffCost),
showFeeInCash(rval.showFeeInCash),
messageTimeout(rval.messageTimeout),
feeChargeType(rval.feeChargeType),
reconnectOnTariffChange(rval.reconnectOnTariffChange),
+ disableSessionLog(rval.disableSessionLog),
+ filterParamsLog(rval.filterParamsLog),
modulesSettings(rval.modulesSettings),
storeModuleSettings(rval.storeModuleSettings),
logger(GetStgLogger())
spreadFee = rhs.spreadFee;
freeMbAllowInet = rhs.freeMbAllowInet;
dayFeeIsLastDay = rhs.dayFeeIsLastDay;
+ stopOnError = rhs.stopOnError;
writeFreeMbTraffCost = rhs.writeFreeMbTraffCost;
showFeeInCash = rhs.showFeeInCash;
messageTimeout = rhs.messageTimeout;
feeChargeType = rhs.feeChargeType;
reconnectOnTariffChange = rhs.reconnectOnTariffChange;
+ disableSessionLog = rhs.disableSessionLog;
+ filterParamsLog = rhs.filterParamsLog;
modulesSettings = rhs.modulesSettings;
storeModuleSettings = rhs.storeModuleSettings;
}
}
+ if (strcasecmp(node->getName(), "StopOnError") == 0)
+ {
+ if (ParseYesNo(node->getValue(0), &stopOnError) != 0)
+ {
+ strError = "Incorrect StopOnError value: \'" + std::string(node->getValue(0)) + "\'";
+ return -1;
+ }
+ }
+
if (strcasecmp(node->getName(), "WriteFreeMbTraffCost") == 0)
{
if (ParseYesNo(node->getValue(0), &writeFreeMbTraffCost) != 0)
}
}
+ if (strcasecmp(node->getName(), "DisableSessionLog") == 0)
+ {
+ if (ParseYesNo(node->getValue(0), &disableSessionLog) != 0)
+ {
+ strError = "Incorrect DisableSessionLog value: \'" + std::string(node->getValue(0)) + "\'";
+ return -1;
+ }
+ }
+
+ if (strcasecmp(node->getName(), "FilterParamsLog") == 0)
+ {
+ filterParamsLog.clear();
+ for (int i = 0; node->getValue(i) != NULL; ++i)
+ filterParamsLog.push_back(node->getValue(i));
+ }
+
if (strcasecmp(node->getName(), "DirNames") == 0)
{
const DOTCONFDocumentNode * child = node->getChildNode();
if (strcasecmp(node->getName(), "ScriptParams") == 0)
{
for (int i = 0; node->getValue(i) != NULL; ++i)
- {
scriptParams.push_back(node->getValue(i));
- }
}
node = node->getNextNode();
}
bool GetSpreadFee() const { return spreadFee; }
bool GetFreeMbAllowInet() const { return freeMbAllowInet; }
bool GetDayFeeIsLastDay() const { return dayFeeIsLastDay; }
+ bool GetStopOnError() const { return stopOnError; }
bool GetWriteFreeMbTraffCost() const
{ return writeFreeMbTraffCost; }
bool GetShowFeeInCash() const { return showFeeInCash; }
unsigned GetMessageTimeout() const { return messageTimeout * 3600 * 24; }
unsigned GetFeeChargeType() const { return feeChargeType; }
bool GetReconnectOnTariffChange() const { return reconnectOnTariffChange; }
+ bool GetDisableSessionLog() const { return disableSessionLog; }
+ const std::vector<std::string> & GetFilterParamsLog() const { return filterParamsLog; }
const std::string & GetModulesPath() const { return modulesPath; }
const MODULE_SETTINGS & GetStoreModuleSettings() const
bool spreadFee;
bool freeMbAllowInet;
bool dayFeeIsLastDay;
+ bool stopOnError;
bool writeFreeMbTraffCost;
bool showFeeInCash;
unsigned messageTimeout;
unsigned feeChargeType;
bool reconnectOnTariffChange;
+ bool disableSessionLog;
+ std::vector<std::string> filterParamsLog;
std::vector<MODULE_SETTINGS> modulesSettings;
MODULE_SETTINGS storeModuleSettings;
const USERS * u,
const SERVICES & svcs)
: users(u),
- property(s->GetScriptsDir()),
+ property(*s),
WriteServLog(GetStgLogger()),
lastScanMessages(0),
id(0),
const USERS * u,
const SERVICES & svcs)
: users(u),
- property(s->GetScriptsDir()),
+ property(*s),
WriteServLog(GetStgLogger()),
lastScanMessages(0),
id(0),
USER_IMPL::USER_IMPL(const USER_IMPL & u)
: USER(),
users(u.users),
- property(u.settings->GetScriptsDir()),
+ property(*u.settings),
WriteServLog(GetStgLogger()),
lastScanMessages(0),
login(u.login),
connected = true;
}
- if (store->WriteUserConnect(login, currIP))
+ if (!settings->GetDisableSessionLog() && store->WriteUserConnect(login, currIP))
{
WriteServLog("Cannot write connect for user %s.", login.c_str());
WriteServLog("%s", store->GetStrError().c_str());
if (!lastDisconnectReason.empty())
reasonMessage += ": " + lastDisconnectReason;
- if (store->WriteUserDisconnect(login, up, down, sessionUpload, sessionDownload,
- cash, freeMb, reasonMessage))
+ if (!settings->GetDisableSessionLog() && store->WriteUserDisconnect(login, up, down, sessionUpload, sessionDownload,
+ cash, freeMb, reasonMessage))
{
WriteServLog("Cannot write disconnect for user %s.", login.c_str());
WriteServLog("%s", store->GetStrError().c_str());
ResetPassiveTime();
}
//-----------------------------------------------------------------------------
+void USER_IMPL::ProcessServices()
+{
+struct tm tms;
+time_t t = stgTime;
+localtime_r(&t, &tms);
+
+double passiveTimePart = 1.0;
+if (!settings->GetFullFee())
+ {
+ passiveTimePart = GetPassiveTimePart();
+ }
+else
+ {
+ if (passive.ConstData())
+ {
+ printfd(__FILE__, "Don't charge fee `cause we are passive\n");
+ return;
+ }
+ }
+
+for (size_t i = 0; i < property.Conf().services.size(); ++i)
+ {
+ SERVICE_CONF conf;
+ if (m_services.Find(property.Conf().services[i], &conf))
+ continue;
+ if (conf.payDay == tms.tm_mday ||
+ (conf.payDay == 0 && tms.tm_mday == DaysInCurrentMonth()))
+ {
+ double c = cash;
+ double fee = conf.cost * passiveTimePart;
+ printfd(__FILE__, "Service fee. login: %8s Cash=%f Credit=%f Fee=%f PassiveTimePart=%f fee=%f\n",
+ login.c_str(),
+ cash.ConstData(),
+ credit.ConstData(),
+ tariff->GetFee(),
+ passiveTimePart,
+ fee);
+ switch (settings->GetFeeChargeType())
+ {
+ case 0:
+ property.cash.Set(c - fee, sysAdmin, login, store, "Subscriber fee charge");
+ SetPrepaidTraff();
+ break;
+ case 1:
+ if (c + credit >= 0)
+ {
+ property.cash.Set(c - fee, sysAdmin, login, store, "Subscriber fee charge");
+ SetPrepaidTraff();
+ }
+ break;
+ case 2:
+ 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();
+ }
+ break;
+ }
+ }
+ }
+}
+//-----------------------------------------------------------------------------
void USER_IMPL::SetPrepaidTraff()
{
if (tariff != NULL)