]> git.stg.codes - stg.git/commitdiff
Code cleanup.
authorMaxim Mamontov <faust.madf@gmail.com>
Tue, 27 May 2014 13:30:41 +0000 (16:30 +0300)
committerMaxim Mamontov <faust.madf@gmail.com>
Tue, 27 May 2014 13:30:41 +0000 (16:30 +0300)
projects/sgconf/Makefile
projects/sgconf/common_sg.cpp [deleted file]
projects/sgconf/common_sg.h [deleted file]
projects/sgconf/main.cpp
projects/sgconf/request.h [deleted file]
projects/sgconf/users.cpp
stglibs/srvconf.lib/include/stg/servconf_types.h
stglibs/srvconf.lib/parsers/get_user.cpp

index c5f3e4bf0309dc39b4e34924dd5fa6931f09cc3e..e2fb8c1bf9b8857cc06902108541154c70589476 100644 (file)
@@ -7,7 +7,6 @@ include ../../Makefile.conf
 PROG = sgconf
 
 SRCS = ./main.cpp \
 PROG = sgconf
 
 SRCS = ./main.cpp \
-       ./common_sg.cpp \
        ./options.cpp \
        ./actions.cpp \
        ./admins.cpp \
        ./options.cpp \
        ./actions.cpp \
        ./admins.cpp \
diff --git a/projects/sgconf/common_sg.cpp b/projects/sgconf/common_sg.cpp
deleted file mode 100644 (file)
index e407a71..0000000
+++ /dev/null
@@ -1,536 +0,0 @@
-/*
- *    This program is free software; you can redistribute it and/or modify
- *    it under the terms of the GNU General Public License as published by
- *    the Free Software Foundation; either version 2 of the License, or
- *    (at your option) any later version.
- *
- *    This program is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *    GNU General Public License for more details.
- *
- *    You should have received a copy of the GNU General Public License
- *    along with this program; if not, write to the Free Software
- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/*
- *    Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
- */
-
- /*
- $Author: faust $
- $Revision: 1.12 $
- $Date: 2009/06/08 10:02:28 $
- */
-
-
-#include "sg_error_codes.h"
-#include "common_sg.h"
-#include "version_sg.h"
-
-#include "stg/common.h"
-
-#include <iostream>
-#include <vector>
-
-#include <cstdio>
-#include <cstring>
-#include <cstdlib>
-#include <cerrno>
-#include <clocale>
-
-#include <langinfo.h>
-#include <iconv.h>
-
-using namespace STG;
-
-const int usageConf = 0;
-const int usageInfo = 1;
-
-const int TO_KOI8 = 0;
-const int FROM_KOI8 = 1;
-//-----------------------------------------------------------------------------
-struct ResultData
-{
-    bool result;
-    std::string reason;
-};
-//-----------------------------------------------------------------------------
-struct GetUserData
-{
-    GetUserData(REQUEST & req, bool res) : request(req), result(res) {}
-    REQUEST & request;
-    bool result;
-    std::string reason;
-};
-//---------------------------------------------------------------------------
-struct HelpParams
-{
-    std::string setActionName;
-    std::string getActionName;
-    std::string valueName;
-    std::string valueParam;
-};
-//---------------------------------------------------------------------------
-void Usage(int usageType)
-{
-printf("Sgconf version: %s\n\n", VERSION_SG);
-
-char action[4];
-if (usageType == usageConf)
-    strcpy(action, "set");
-else
-    strcpy(action, "get");
-
-printf("To add or to set cash use:\n");
-printf("sgconf set -s <server> -p <port> -a <admin> -w <admin_pass> -u <user> -c <add_cash[:log message]>\n");
-printf("sgconf set -s <server> -p <port> -a <admin> -w <admin_pass> -u <user> -v <set_cash[:log message]>\n");
-printf("To get cash use:\n");
-printf("sgconf get -s <server> -p <port> -a <admin> -w <admin_pass> -u <user> -c\n\n");
-
-HelpParams hp[] =
-{
-    {"set tariff",              "get tariff",           "-t",   "<tariff:now|delayed>"},
-    {"set credit",              "get credit",           "-r",   "<credit>"},
-    {"set credit expire",       "get credit expire",    "-E",   "<credit_expire_date>"},
-    {"set password",            "get password",         "-o",   "<new_password>"},
-    {"set prepaid traffic",     "get prepaid traffic",  "-e",   "<prepaid>"},
-    {"set IP-addresses",        "get IP-addresses",     "-I",   "<*|ip_addr[,ip_addr...]>"},
-    {"set name",                "get name",             "-A",   "<name>"},
-    {"set note",                "get note",             "-N",   "<note>"},
-    {"set street address",      "get street address",   "-D",   "<address>"},
-    {"set email",               "get email",            "-L",   "<email>"},
-    {"set phone",               "get phone",            "-P",   "<phone>"},
-    {"set group",               "get group",            "-G",   "<group>"},
-    {"set/unset down",          "get down",             "-d",   "<0/1>"},
-    {"set/unset \'passive\'",   "get \'passive\'",      "-i",   "<0/1>"},
-    {"set/unset \'disableDetailStat\'",   "get \'disableDetailStat\'",      "--disable-stat",   "<0/1>"},
-    {"set/unset \'alwaysOnline\'",   "get \'alwaysOnline\'",      "--always-online",   "<0/1>"},
-};
-
-for (unsigned i = 0; i < sizeof(hp) / sizeof(HelpParams); i++)
-    {
-    printf("To %s use:\n", hp[i].setActionName.c_str());
-    printf("sgconf set -s <server> -p <port> -a <admin> -w <admin_pass> -u <user> %s %s\n",
-           hp[i].valueName.c_str(), hp[i].valueParam.c_str());
-    printf("To %s use:\n", hp[i].getActionName.c_str());
-    printf("sgconf get -s <server> -p <port> -a <admin> -w <admin_pass> -u <user> %s\n\n",
-           hp[i].valueName.c_str());
-    }
-
-printf("To set user\'s upload traffic value use:\n");
-printf("sgconf set -s <server> -p <port> -a <admin> -w <admin_pass> -u <user> --u0 <traff> [--u1<traff> ...]\n");
-printf("To get user\'s upload traffic value use:\n");
-printf("sgconf get -s <server> -p <port> -a <admin> -w <admin_pass> -u <user> --u0 [--u1 ...]\n\n");
-
-printf("To set user\'s download traffic value use:\n");
-printf("sgconf set -s <server> -p <port> -a <admin> -w <admin_pass> -u <user> --d0 <traff> [--d1<traff> ...]\n");
-printf("To get user\'s download traffic value use:\n");
-printf("sgconf get -s <server> -p <port> -a <admin> -w <admin_pass> -u <user> --d0 [--d1 ...]\n\n");
-
-printf("To set userdata<0...9> use:\n");
-printf("sgconf set -s <server> -p <port> -a <admin> -w <admin_pass> -u <user> --ud0 <userdata> [--ud1<userdata> ...]\n");
-printf("To get userdata<0...9> use:\n");
-printf("sgconf get -s <server> -p <port> -a <admin> -w <admin_pass> -u <user> --ud0 [--ud1 ...]\n\n");
-
-printf("To get user's authorizers list use:\n");
-printf("sgconf get -s <server> -p <port> -a <admin> -w <admin_pass> -u <user> --authorized-by\n\n");
-
-printf("To send message use:\n");
-printf("sgconf set -s <server> -p <port> -a <admin> -w <admin_pass> -u <user> -m <message>\n\n");
-
-printf("To create user use:\n");
-printf("sgconf set -s <server> -p <port> -a <admin> -w <admin_pass> -u <user> -n\n\n");
-
-printf("To delete user use:\n");
-printf("sgconf set -s <server> -p <port> -a <admin> -w <admin_pass> -u <user> -l\n\n");
-}
-//---------------------------------------------------------------------------
-void UsageConf()
-{
-Usage(usageConf);
-}
-//---------------------------------------------------------------------------
-void UsageInfo()
-{
-Usage(usageInfo);
-}
-//---------------------------------------------------------------------------
-int CheckLogin(const char * login)
-{
-for (int i = 0; i < (int)strlen(login); i++)
-    {
-    if (!(( login[i] >= 'a' && login[i] <= 'z')
-        || (login[i] >= 'A' && login[i] <= 'Z')
-        || (login[i] >= '0' && login[i] <= '9')
-        ||  login[i] == '.'
-        ||  login[i] == '_'
-        ||  login[i] == '-'))
-        {
-        return 1;
-        }
-    }
-return 0;
-}
-//-----------------------------------------------------------------------------
-short int ParseServerPort(const char * p)
-{
-int port;
-if (str2x(p, port) != 0)
-    {
-    printf("Incorrect server port %s\n", p);
-    exit(NETWORK_ERR_CODE);
-    }
-return (short)port;
-}
-//-----------------------------------------------------------------------------
-char * ParseAdminLogin(char * adm)
-{
-if (CheckLogin(adm))
-    {
-    printf("Incorrect admin login %s\n", adm);
-    exit(PARAMETER_PARSING_ERR_CODE);
-    }
-return adm;
-}
-//-----------------------------------------------------------------------------
-char * ParsePassword(char * pass)
-{
-if (strlen(pass) >= ADM_PASSWD_LEN)
-    {
-    printf("Password too big %s\n", pass);
-    exit(PARAMETER_PARSING_ERR_CODE);
-    }
-
-return pass;
-}
-//-----------------------------------------------------------------------------
-char * ParseUser(char * usr)
-{
-if (CheckLogin(usr))
-    {
-    printf("Incorrect user login %s\n", usr);
-    exit(PARAMETER_PARSING_ERR_CODE);
-    }
-return usr;
-}
-//-----------------------------------------------------------------------------
-void ConvertKOI8(const std::string & src, std::string * dst, int encType)
-{
-iconv_t cd;
-char * ob = new char[src.size() * 2 + 1];
-char * ib = new char[src.size() + 1];
-
-strcpy(ib, src.c_str());
-
-char * outbuf = ob;
-char * inbuf = ib;
-
-setlocale(LC_ALL, "");
-
-char charsetF[100];
-char charsetT[100];
-
-if (encType == TO_KOI8)
-    {
-    strcpy(charsetF, nl_langinfo(CODESET));
-    strcpy(charsetT, "koi8-ru");
-    }
-else
-    {
-    strcpy(charsetT, nl_langinfo(CODESET));
-    strcpy(charsetF, "koi8-ru");
-    }
-
-size_t nconv = 1;
-
-size_t insize = strlen(ib);
-size_t outsize = insize * 2 + 1;
-
-insize = src.size();
-
-cd = iconv_open(charsetT, charsetF);
-if (cd == (iconv_t) -1)
-    {
-    if (errno != EINVAL)
-        printf("error iconv_open\n");
-    else
-        {
-        printf("Warning: iconv from %s to %s failed\n", charsetF, charsetT);
-        *dst = src;
-        return;
-        }
-
-    exit(ICONV_ERR_CODE);
-    }
-
-#if defined(FREE_BSD) || defined(FREE_BSD5)
-nconv = iconv(cd, (const char **)&inbuf, &insize, &outbuf, &outsize);
-#else
-nconv = iconv(cd, &inbuf, &insize, &outbuf, &outsize);
-#endif
-//printf("charsetT=%s charsetF=%s\n", charsetT, charsetF);
-//printf("ib=%s ob=%s\n", ib, ob);
-//printf("nconv=%d outsize=%d\n", nconv, outsize);
-if (nconv == (size_t) -1)
-    {
-    if (errno != EINVAL)
-        {
-        printf("iconv error\n");
-        exit(ICONV_ERR_CODE);
-        }
-    }
-
-*outbuf = L'\0';
-
-iconv_close(cd);
-*dst = ob;
-
-delete[] ob;
-delete[] ib;
-}
-//-----------------------------------------------------------------------------
-void ConvertFromKOI8(const std::string & src, std::string * dst)
-{
-ConvertKOI8(src, dst, FROM_KOI8);
-}
-//-----------------------------------------------------------------------------
-void ResultCallback(bool result, const std::string & reason, void * d)
-{
-ResultData * data = static_cast<ResultData *>(d);
-data->result = result;
-data->reason = reason;
-}
-//-----------------------------------------------------------------------------
-void RecvAuthByData(bool result, const std::string & reason,
-                    const AUTH_BY::INFO & list, void * d)
-{
-ResultData * data = static_cast<ResultData *>(d);
-data->result = result;
-data->reason = reason;
-
-if (!result)
-    return;
-
-for (std::vector<std::string>::const_iterator it = list.begin(); it != list.end(); ++it)
-    std::cout << *it << "\n";
-
-std::cout << std::endl;
-}
-//-----------------------------------------------------------------------------
-struct StringReqParams
-{
-    std::string name;
-    RESETABLE<std::string> reqParam;
-    const std::string * value;
-};
-//-----------------------------------------------------------------------------
-void GetUserCallback(bool result, const std::string& reason, const GET_USER::INFO & info, void * d)
-{
-GetUserData * data = static_cast<GetUserData *>(d);
-data->result = false;
-data->reason = reason;
-
-if (!result)
-    return;
-
-if (info.login == "")
-    {
-    data->result = false;
-    data->reason = "Invalid login.";
-    return;
-    }
-
-if (!data->request.cash.empty())
-    cout << "cash = " << info.cash << endl;
-
-if (!data->request.credit.empty())
-    cout << "credit = " << info.credit << endl;
-
-if (!data->request.creditExpire.empty())
-    {
-    char buf[32];
-    struct tm brokenTime;
-    time_t tt = info.creditExpire;
-
-    brokenTime.tm_wday = 0;
-    brokenTime.tm_yday = 0;
-    brokenTime.tm_isdst = 0;
-    brokenTime.tm_hour = 0;
-    brokenTime.tm_min = 0;
-    brokenTime.tm_sec = 0;
-
-    gmtime_r(&tt, &brokenTime);
-
-    strftime(buf, 32, "%Y-%m-%d", &brokenTime);
-
-    cout << "creditExpire = " << buf << endl;
-    }
-
-if (!data->request.down.empty())
-    cout << "down = " << info.down << endl;
-
-if (!data->request.passive.empty())
-    cout << "passive = " << info.passive << endl;
-
-if (!data->request.disableDetailStat.empty())
-    cout << "disableDetailStat = " << info.disableDetailStat << endl;
-
-if (!data->request.alwaysOnline.empty())
-    cout << "alwaysOnline = " << info.alwaysOnline << endl;
-
-if (!data->request.prepaidTraff.empty())
-    cout << "prepaidTraff = " << info.prepaidTraff << endl;
-
-for (int i = 0; i < DIR_NUM; i++)
-    {
-    if (!data->request.sessionUpload[i].empty())
-        cout << "session upload for dir " << i << " = " << info.stat.su[i] << endl;
-    if (!data->request.sessionDownload[i].empty())
-        cout << "session download for dir " << i << "=" << info.stat.sd[i] << endl;
-    }
-
-for (int i = 0; i < DIR_NUM; i++)
-    {
-    if (!data->request.monthUpload[i].empty())
-        cout << "month upload for dir " << i << " = " << info.stat.mu[i] << endl;
-    if (!data->request.monthDownload[i].empty())
-        cout << "month download for dir " << i << " = " << info.stat.md[i] << endl;
-    }
-
-for (int i = 0; i < USERDATA_NUM; i++)
-    {
-    if (!data->request.userData[i].empty())
-        {
-        std::string str;
-        ConvertFromKOI8(info.userData[i], &str);
-        cout << "user data " << i << " = " << str << endl;
-        }
-    }
-
-StringReqParams strReqParams[] =
-{
-    {"note",     data->request.note,        &info.note},
-    {"name",     data->request.name,        &info.name},
-    {"address",  data->request.address,     &info.address},
-    {"email",    data->request.email,       &info.email},
-    {"phone",    data->request.phone,       &info.phone},
-    {"group",    data->request.group,       &info.group},
-    {"tariff",   data->request.tariff,      &info.tariff},
-    {"password", data->request.usrPasswd,   &info.password},
-    {"ip",       data->request.ips,         &info.ips} // IP-address of user
-};
-for (unsigned i = 0; i < sizeof(strReqParams) / sizeof(StringReqParams); i++)
-    {
-    if (!strReqParams[i].reqParam.empty())
-        {
-        string str;
-        ConvertFromKOI8(*strReqParams[i].value, &str);
-        cout << strReqParams[i].name << " = " << str << endl;
-        }
-    }
-data->result = true;
-}
-//-----------------------------------------------------------------------------
-bool ProcessSetUser(const std::string & server,
-                    int port,
-                    const std::string & login,
-                    const std::string & password,
-                    const std::string & user,
-                    const USER_CONF_RES & conf,
-                    const USER_STAT_RES & stat)
-{
-SERVCONF sc(server, port, login, password);
-
-ResultData data;
-int res = sc.ChgUser(user, conf, stat, ResultCallback, &data);
-
-if (res == st_ok && data.result)
-    {
-    printf("Ok\n");
-    return false;
-    }
-
-printf("Error\n");
-if (res != st_ok)
-    printf("%s\n", sc.GetStrError().c_str());
-else
-    printf("%s\n", data.reason.c_str());
-return true;
-}
-//-----------------------------------------------------------------------------
-bool ProcessSendMessage(const std::string & server, uint16_t port,
-                        const std::string & login, const std::string & password,
-                        const std::string & user, const std::string & text)
-{
-SERVCONF sc(server, port, login, password);
-
-ResultData data;
-int res = sc.SendMessage(user, text, ResultCallback, &data);
-
-if (res == st_ok && data.result)
-    {
-    printf("Ok\n");
-    return true;
-    }
-
-printf("Error\n");
-if (res != st_ok)
-    printf("%s\n", sc.GetStrError().c_str());
-else
-    printf("%s\n", data.reason.c_str());
-return false;
-}
-//-----------------------------------------------------------------------------
-bool ProcessGetUser(const std::string &server,
-                    int port,
-                    const std::string &admLogin,
-                    const std::string &admPasswd,
-                    const std::string &login,
-                    REQUEST & request)
-{
-SERVCONF sc(server, port, admLogin, admPasswd);
-
-GetUserData data(request, false);
-bool res = (sc.GetUser(login.c_str(), GetUserCallback, &data) == st_ok);
-
-if (res && data.result)
-    {
-    printf("Ok\n");
-    return true;
-    }
-
-printf("Error\n");
-if (!res)
-    printf("%s\n", sc.GetStrError().c_str());
-else
-    printf("%s\n", data.reason.c_str());
-return false;
-}
-//-----------------------------------------------------------------------------
-bool ProcessAuthBy(const std::string &server,
-                   int port,
-                   const std::string &admLogin,
-                   const std::string &admPasswd,
-                   const std::string &login)
-{
-SERVCONF sc(server, port, admLogin, admPasswd);
-
-ResultData data;
-bool res = (sc.AuthBy(login.c_str(), RecvAuthByData, &data) == st_ok);
-
-if (res && data.result)
-    {
-    printf("Ok\n");
-    return true;
-    }
-
-printf("Error\n");
-if (!res)
-    printf("%s\n", sc.GetStrError().c_str());
-else
-    printf("%s\n", data.reason.c_str());
-return false;
-}
-//-----------------------------------------------------------------------------
diff --git a/projects/sgconf/common_sg.h b/projects/sgconf/common_sg.h
deleted file mode 100644 (file)
index 323a8cf..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- *    This program is free software; you can redistribute it and/or modify
- *    it under the terms of the GNU General Public License as published by
- *    the Free Software Foundation; either version 2 of the License, or
- *    (at your option) any later version.
- *
- *    This program is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *    GNU General Public License for more details.
- *
- *    You should have received a copy of the GNU General Public License
- *    along with this program; if not, write to the Free Software
- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/*
- *    Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
- */
-
- /*
- $Author: faust $
- $Revision: 1.5 $
- $Date: 2009/06/08 10:02:28 $
- */
-
-
-#ifndef COMMON_SG_H
-#define COMMON_SG_H
-
-#include "stg/servconf.h"
-#include "stg/servconf_types.h"
-#include "request.h"
-
-#include <string>
-
-struct USER_CONF_RES;
-struct USER_STAT_RES;
-
-void UsageConf();
-void UsageInfo();
-
-char * ParseUser(char * usr);
-char * ParsePassword(char * pass);
-char * ParseAdminLogin(char * adm);
-short int ParseServerPort(const char * p);
-void ParseAnyString(const char * c, string * msg, const char * enc = "cp1251");
-int CheckLogin(const char * login);
-void ConvertFromKOI8(const std::string & src, std::string * dst);
-void ConvertToKOI8(const std::string & src, std::string * dst);
-
-bool ProcessGetUser(const std::string & server,
-                    int port,
-                    const std::string & admLogin,
-                    const std::string & admPasswd,
-                    const std::string & login,
-                    REQUEST & request);
-
-bool ProcessAuthBy(const std::string & server,
-                   int port,
-                   const std::string & admLogin,
-                   const std::string & admPasswd,
-                   const std::string & login);
-
-bool ProcessSetUser(const std::string & server,
-                    int port,
-                    const std::string & admLogin,
-                    const std::string & admPasswd,
-                    const std::string & user,
-                    const USER_CONF_RES & conf,
-                    const USER_STAT_RES & stat);
-
-bool ProcessSendMessage(const std::string & server, uint16_t port,
-                        const std::string & login, const std::string & password,
-                        const std::string & user, const std::string & text);
-
-#endif
index e10d21f0b7ec41c41ff8756ca71923b0ed11c5b6..135cd3c02656f826a8122ae69566ed1dd805da48 100644 (file)
  *    Author : Maxim Mamontov <faust@stargazer.dp.ua>
  */
 
  *    Author : Maxim Mamontov <faust@stargazer.dp.ua>
  */
 
-#include "request.h"
-#include "common_sg.h"
-#include "sg_error_codes.h"
-
 #include "xml.h"
 #include "admins.h"
 #include "tariffs.h"
 #include "xml.h"
 #include "admins.h"
 #include "tariffs.h"
@@ -31,6 +27,7 @@
 #include "actions.h"
 #include "config.h"
 
 #include "actions.h"
 #include "config.h"
 
+#include "stg/servconf.h"
 #include "stg/user_conf.h"
 #include "stg/user_stat.h"
 #include "stg/common.h"
 #include "stg/user_conf.h"
 #include "stg/user_stat.h"
 #include "stg/common.h"
diff --git a/projects/sgconf/request.h b/projects/sgconf/request.h
deleted file mode 100644 (file)
index bca3c14..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- *    This program is free software; you can redistribute it and/or modify
- *    it under the terms of the GNU General Public License as published by
- *    the Free Software Foundation; either version 2 of the License, or
- *    (at your option) any later version.
- *
- *    This program is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *    GNU General Public License for more details.
- *
- *    You should have received a copy of the GNU General Public License
- *    along with this program; if not, write to the Free Software
- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/*
- *    Date: 27.10.2002
- */
-
-/*
- *    Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
- */
-
- /*
- $Author: faust $
- $Revision: 1.14 $
- $Date: 2009/06/08 10:02:28 $
- */
-
-#ifndef request_h
-#define request_h
-
-#include <string>
-
-#include "stg/resetable.h"
-#include "stg/const.h"
-#include "stg/os_int.h"
-
-#define TARIFF_NOW  (0)
-#define TARIFF_DEL  (1)
-#define TARIFF_REC  (2)
-
-using namespace std;
-//-----------------------------------------------------------------------------
-struct REQUEST
-{
-
-REQUEST()
-    : chgTariff(false),
-      createUser(false),
-      deleteUser(false),
-      authBy(false)
-{
-    for (int i = 0; i < DIR_NUM; i++)
-        {
-        sessionUpload[i].reset();
-        sessionDownload[i].reset();
-        monthUpload[i].reset();
-        monthDownload[i].reset();
-        }
-
-    for (int i = 0; i < USERDATA_NUM; i++)
-        userData[i].reset();
-}
-
-RESETABLE<string>   server;
-RESETABLE<short>    port;
-RESETABLE<string>   admLogin;
-RESETABLE<string>   admPasswd;
-RESETABLE<string>   login;
-
-RESETABLE<string>   tariff;
-int                 chgTariff;
-
-RESETABLE<double>   cash;
-RESETABLE<double>   setCash;
-string              message;
-bool                createUser;
-bool                deleteUser;
-bool                authBy;
-
-RESETABLE<string>   usrMsg;
-RESETABLE<double>   credit;
-RESETABLE<time_t>   creditExpire;
-RESETABLE<string>   usrPasswd;
-RESETABLE<bool>     down;
-RESETABLE<bool>     passive;
-RESETABLE<bool>     disableDetailStat;
-RESETABLE<bool>     alwaysOnline;
-RESETABLE<double>   prepaidTraff;
-
-RESETABLE<int64_t>  sessionUpload[DIR_NUM];
-RESETABLE<int64_t>  sessionDownload[DIR_NUM];
-
-RESETABLE<int64_t>  monthUpload[DIR_NUM];
-RESETABLE<int64_t>  monthDownload[DIR_NUM];
-
-RESETABLE<string>   userData[USERDATA_NUM];
-
-RESETABLE<string>   note;
-RESETABLE<string>   name;
-RESETABLE<string>   address;
-RESETABLE<string>   email;
-RESETABLE<string>   phone;
-RESETABLE<string>   group;
-RESETABLE<string>   ips; // IP-address of user
-};
-//-----------------------------------------------------------------------------
-
-#endif
-
-
index cdbfbbb5acd838b281bf52852ee8a194ad69ee38..0fb68544e1584961a5aad457729481e91eaf51fe 100644 (file)
@@ -27,7 +27,7 @@ std::cout << Indent(level, true) << "login: " << info.login << "\n"
           << Indent(level)       << "credit expire: " << TimeToString(info.creditExpire) << "\n"
           << Indent(level)       << "last cash add: " << info.lastCash << "\n"
           << Indent(level)       << "prepaid traffic: " << info.prepaidTraff << "\n"
           << Indent(level)       << "credit expire: " << TimeToString(info.creditExpire) << "\n"
           << Indent(level)       << "last cash add: " << info.lastCash << "\n"
           << Indent(level)       << "prepaid traffic: " << info.prepaidTraff << "\n"
-          << Indent(level)       << "disabled: " << (info.down ? "t" : "f") << "\n"
+          << Indent(level)       << "disabled: " << (info.disabled ? "t" : "f") << "\n"
           << Indent(level)       << "passive: " << (info.passive ? "t" : "f") << "\n"
           << Indent(level)       << "disabled detail stat: " << (info.disableDetailStat ? "t" : "f") << "\n"
           << Indent(level)       << "connected: " << (info.connected ? "t" : "f") << "\n"
           << Indent(level)       << "passive: " << (info.passive ? "t" : "f") << "\n"
           << Indent(level)       << "disabled detail stat: " << (info.disableDetailStat ? "t" : "f") << "\n"
           << Indent(level)       << "connected: " << (info.connected ? "t" : "f") << "\n"
index 3fd1c7c57a26d771ae8ab1c47560db83f16982a5..2217250666ad07cbb109e47610110ff4f5a8112e 100644 (file)
@@ -141,8 +141,9 @@ struct INFO
     double      credit;
     time_t      creditExpire;
     double      lastCash;
     double      credit;
     time_t      creditExpire;
     double      lastCash;
+    time_t      lastTimeCash;
     double      prepaidTraff;
     double      prepaidTraff;
-    int         down;
+    int         disabled;
     int         passive;
     int         disableDetailStat;
     int         connected;
     int         passive;
     int         disableDetailStat;
     int         connected;
@@ -157,6 +158,8 @@ struct INFO
     std::string address;
     std::string phone;
     STAT        stat;
     std::string address;
     std::string phone;
     STAT        stat;
+    time_t      pingTime;
+    time_t      lastActivityTime;
     ARRAY<std::string, USERDATA_NUM> userData;
 };
 
     ARRAY<std::string, USERDATA_NUM> userData;
 };
 
index cd19d1f6444242b3e5bdef4cc57627c33205af6d..391519733cc55d3f2a73def9469a3aa5dfdf9a15 100644 (file)
@@ -72,11 +72,12 @@ GET_USER::PARSER::PARSER(CALLBACK f, void * d)
     AddParser(propertyParsers, "credit", info.credit);
     AddParser(propertyParsers, "creditExpire", info.creditExpire);
     AddParser(propertyParsers, "lastCash", info.lastCash);
     AddParser(propertyParsers, "credit", info.credit);
     AddParser(propertyParsers, "creditExpire", info.creditExpire);
     AddParser(propertyParsers, "lastCash", info.lastCash);
-    AddParser(propertyParsers, "prepaidTraff", info.prepaidTraff);
-    AddParser(propertyParsers, "down", info.down);
+    AddParser(propertyParsers, "lastTimeCash", info.lastCash);
+    AddParser(propertyParsers, "freeMb", info.prepaidTraff);
+    AddParser(propertyParsers, "down", info.disabled);
     AddParser(propertyParsers, "passive", info.passive);
     AddParser(propertyParsers, "disableDetailStat", info.disableDetailStat);
     AddParser(propertyParsers, "passive", info.passive);
     AddParser(propertyParsers, "disableDetailStat", info.disableDetailStat);
-    AddParser(propertyParsers, "connected", info.connected);
+    AddParser(propertyParsers, "status", info.connected);
     AddParser(propertyParsers, "aonline", info.alwaysOnline);
     AddParser(propertyParsers, "currIP", info.ip, GetIPValue);
     AddParser(propertyParsers, "ip", info.ips);
     AddParser(propertyParsers, "aonline", info.alwaysOnline);
     AddParser(propertyParsers, "currIP", info.ip, GetIPValue);
     AddParser(propertyParsers, "ip", info.ips);
@@ -88,6 +89,8 @@ GET_USER::PARSER::PARSER(CALLBACK f, void * d)
     AddParser(propertyParsers, "address", info.address, GetEncodedValue);
     AddParser(propertyParsers, "phone", info.phone, GetEncodedValue);
     AddParser(propertyParsers, "traff", info.stat);
     AddParser(propertyParsers, "address", info.address, GetEncodedValue);
     AddParser(propertyParsers, "phone", info.phone, GetEncodedValue);
     AddParser(propertyParsers, "traff", info.stat);
+    AddParser(propertyParsers, "pingTime", info.pingTime);
+    AddParser(propertyParsers, "lastActivityTime", info.lastActivityTime);
 
     for (size_t i = 0; i < USERDATA_NUM; ++i)
         AddParser(propertyParsers, "userData" + unsigned2str(i), info.userData[i], GetEncodedValue);
 
     for (size_t i = 0; i < USERDATA_NUM; ++i)
         AddParser(propertyParsers, "userData" + unsigned2str(i), info.userData[i], GetEncodedValue);