/[LeafOK_CVS]/pvpgn-1.7.4/src/bnetd/userverify.c
ViewVC logotype

Annotation of /pvpgn-1.7.4/src/bnetd/userverify.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Thu Jun 22 16:42:42 2006 UTC (19 years, 9 months ago) by sysadm
Branch: MAIN
CVS Tags: pvpgn_1-7-4-0_MIL, HEAD
Changes since 1.1: +6 -9 lines
Content type: text/x-csrc
Account verification

1 sysadm 1.1 #define ACCOUNT_INTERNAL_ACCESS
2     #include "common/setup_before.h"
3     #include <stdio.h>
4     #ifdef HAVE_STDDEF_H
5     # include <stddef.h>
6     #else
7     # ifndef NULL
8     # define NULL ((void *)0)
9     # endif
10     #endif
11     #ifdef STDC_HEADERS
12     # include <stdlib.h>
13     #endif
14     #ifdef HAVE_STRING_H
15     # include <string.h>
16     #else
17     # ifdef HAVE_STRINGS_H
18     # include <strings.h>
19     # endif
20     #endif
21     #include "compat/strchr.h"
22     #include "compat/strdup.h"
23     #include "compat/strcasecmp.h"
24     #include "compat/strncasecmp.h"
25     #include <ctype.h>
26     #ifdef HAVE_LIMITS_H
27     # include <limits.h>
28     #endif
29     #include "compat/char_bit.h"
30     #ifdef TIME_WITH_SYS_TIME
31     # include <sys/time.h>
32     # include <time.h>
33     #else
34     # ifdef HAVE_SYS_TIME_H
35     # include <sys/time.h>
36     # else
37     # include <time.h>
38     # endif
39     #endif
40     #include <errno.h>
41     #include "compat/strerror.h"
42     #ifdef HAVE_SYS_TYPES_H
43     # include <sys/types.h>
44     #endif
45     #include "compat/pdir.h"
46     #include "common/list.h"
47     #include "common/elist.h"
48     #include "common/eventlog.h"
49     #include "prefs.h"
50     #include "common/util.h"
51     #include "common/field_sizes.h"
52     #include "common/bnethash.h"
53     #include "common/introtate.h"
54     #include "account.h"
55     #include "account_wrap.h"
56     #include "common/hashtable.h"
57     #include "storage.h"
58     #include "connection.h"
59     #include "watch.h"
60     #include "friends.h"
61     #include "team.h"
62     #include "common/tag.h"
63     #include "ladder.h"
64     #include "clan.h"
65     #include "server.h"
66     #include "common/flags.h"
67     #include "common/xalloc.h"
68     #ifdef HAVE_ASSERT_H
69     # include <assert.h>
70     #endif
71     #include "common/setup_after.h"
72     #include "userverify.h"
73    
74     extern int require_verify(t_account * account)
75     {
76     FILE *fp;
77     char filename[256];
78    
79     strcpy(filename, prefs_get_verify_dir());
80     strcat(filename, "/");
81     strcat(filename, account->name);
82    
83     if ((fp=fopen(filename, "w")) == NULL) {
84     eventlog(eventlog_level_error, __FUNCTION__, "Can't write verify file %s", filename);
85     return -2;
86     }
87    
88     fprintf(fp, "REQUEST\n%s\n", account_get_email(account));
89    
90     fclose(fp);
91    
92     return 0;
93     }
94    
95     extern int is_verified(const char * username)
96     {
97     FILE *fp;
98     char filename[256];
99     char status[50];
100     int ret = 0;
101    
102     strcpy(filename, prefs_get_verify_dir());
103     strcat(filename, "/");
104     strcat(filename, username);
105    
106     if ((fp=fopen(filename, "r")) == NULL) {
107     // eventlog(eventlog_level_error, __FUNCTION__, "Can't read verify file %s", filename);
108     return 2; //TODO: remove this line
109     // return 0;
110     }
111    
112     if (fscanf(fp, "%s", status) != 1)
113     {
114     strcpy(status, "ERROR");
115     eventlog(eventlog_level_error, __FUNCTION__, "Format error in verify file %s", filename);
116     }
117     fclose(fp);
118    
119     if (strcmp(status, "OK") == 0)
120     ret = 1;
121     else
122     ret = 0;
123    
124     return ret;
125     }
126    
127     extern int reset_user_email(t_account * account)
128     {
129     FILE *fp;
130     char filename[256];
131     char status[50];
132     char email[256];
133    
134     strcpy(filename, prefs_get_verify_dir());
135     strcat(filename, "/");
136     strcat(filename, account->name);
137 sysadm 1.2 strcat(filename, ".eml");
138 sysadm 1.1
139     if ((fp=fopen(filename, "r")) == NULL)
140     return -1;
141     if (fscanf(fp, "%s", email) != 1) {
142     eventlog(eventlog_level_error, __FUNCTION__, "Format error in verify file %s", filename);
143     fclose(fp);
144     return 2;
145     }
146     fclose(fp);
147    
148     if (account_set_email(account, email) < 0) {
149     eventlog(eventlog_level_error, __FUNCTION__, "Failed to change account \"%s\" email to \"%s\"", account_get_name(account), email);
150     return -2;
151     }
152 sysadm 1.2
153     /*
154 sysadm 1.1 if (require_verify(account)) {
155     return -3;
156     }
157 sysadm 1.2 */
158    
159     remove(filename);
160 sysadm 1.1
161     return 0;
162     }

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1