-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathluser.cpp
More file actions
125 lines (106 loc) · 3.66 KB
/
luser.cpp
File metadata and controls
125 lines (106 loc) · 3.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// LoraBBS Version 2.99 Free Edition
// Copyright (C) 1987-98 Marco Maccaferri
//
// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "_ldefs.h"
#include "lora_api.h"
VOID PurgeUsers (USHORT Days, USHORT Level)
{
USHORT i;
CHAR Temp[64];
ULONG Today;
struct tm *ltm;
class TUser *User;
printf (" * Purging Users\n");
Today = time (NULL);
if ((User = new TUser ("users")) != NULL) {
if (User->First () == TRUE)
do {
if (Level == 0 || User->Level < Level) {
i = (USHORT)((Today - User->LastCall) / 86400L);
if (i >= Days) {
ltm = localtime ((time_t *)&User->LastCall);
strcpy (Temp, asctime (ltm));
Temp[strlen (Temp) - 1] = '\0';
printf (" +-- %-30.30s Last: %s (%u days)\n", User->Name, Temp, i);
User->Delete ();
}
}
} while (User->Next () == TRUE);
delete User;
}
}
VOID PackUsers ()
{
class TUser *User;
printf (" * Pack (Compressing) Users\n");
if ((User = new TUser ("users")) != NULL) {
User->Pack ();
delete User;
}
}
int main (int argc, char *argv[])
{
int i;
USHORT Pack, Purge, Level;
Pack = FALSE;
Purge = Level = 0;
printf ("\nLUSER; %s v%s - User maintenance utility\n", NAME, VERSION);
printf (" Copyright (c) 1991-96 by Marco Maccaferri. All Rights Reserved.\n\n");
/*
if (ValidateKey ("bbs", NULL, NULL) == KEY_UNREGISTERED) {
printf ("* * * WARNING: No license key found * * *\n");
if ((i = CheckExpiration ()) == 0) {
printf ("* * * This evaluation copy has expired * * *\n\a\n");
exit (0);
}
else
printf ("* * * You have %2d days left for evaluation * * * \n\a\n", i);
}
*/
if (argc <= 1) {
printf (" * Command-line parameters:\n\n");
printf (" -P Pack (compress) user file\n");
printf (" -D[n] Delete users who haven't called in [n] days\n");
printf (" -M[s] Only purge users with security level less than [s]\n");
printf ("\n * Please refer to the documentation for a more complete command summary\n\n");
}
else {
for (i = 1; i < argc; i++) {
if (argv[i][0] == '-' || argv[i][0] == '/') {
switch (toupper (argv[i][1])) {
case 'D':
Purge = (USHORT)atoi (&argv[i][2]);
break;
case 'M':
Level = (USHORT)atoi (&argv[i][2]);
break;
case 'P':
Pack = TRUE;
break;
}
}
}
if (Purge != 0)
PurgeUsers (Purge, Level);
if (Pack == TRUE)
PackUsers ();
if (Purge != 0 || Pack == TRUE)
printf (" * Done\n\n");
else
printf (" * Nothing to do\n\n");
}
return 0;
}