- Simpler Adresscheck (ungültige emails)

- Lua:
  - faction.info (banner)
This commit is contained in:
Enno Rehling 2004-08-22 09:33:15 +00:00
parent e657058251
commit 8ab908dde9
13 changed files with 80 additions and 20 deletions

View File

@ -66,7 +66,7 @@ createmonsters(void)
/* alles ist auf null gesetzt, ausser dem folgenden. achtung - partei /* alles ist auf null gesetzt, ausser dem folgenden. achtung - partei
* no 0 muss keine orders einreichen! */ * no 0 muss keine orders einreichen! */
set_string(&f->email, "keine"); set_string(&f->email, "monsters@eressea.de");
set_string(&f->name, "Monster"); set_string(&f->name, "Monster");
f->alive = 1; f->alive = 1;
f->options = (char) pow(2, O_REPORT); f->options = (char) pow(2, O_REPORT);

View File

@ -2053,12 +2053,16 @@ email_cmd(unit * u, struct order * ord)
if (!s[0]) { if (!s[0]) {
cmistake(u, ord, 85, MSG_EVENT); cmistake(u, ord, 85, MSG_EVENT);
} else if (strstr(s, "internet:") || strchr(s, ' ')) {
cmistake(u, ord, 117, MSG_EVENT);
} else { } else {
set_string(&u->faction->email, s); faction * f = u->faction;
ADDMSG(&u->faction->msgs, msg_message("changemail", "value", if (set_email(&f->email, s)!=0) {
gc_add(strdup(u->faction->email)))); log_error(("Invalid email address: %s\n", s));
ADDMSG(&f->msgs, msg_message("changemail_invalid", "value",
gc_add(strdup(s))));
} else {
ADDMSG(&f->msgs, msg_message("changemail", "value",
gc_add(strdup(f->email))));
}
} }
return 0; return 0;
} }

View File

@ -23,8 +23,9 @@
#include "group.h" #include "group.h"
/* util includes */ /* util includes */
#include <base36.h> #include <util/base36.h>
#include <event.h> #include <util/event.h>
#include <util/goodies.h>
#include <attributes/otherfaction.h> #include <attributes/otherfaction.h>
@ -93,11 +94,13 @@ addfaction(const char *email, const char * password,
int subscription) int subscription)
{ {
int i; int i;
faction *f; faction * f = calloc(sizeof(faction), 1);
assert(frace != new_race[RC_ORC]);
f = calloc(sizeof(faction), 1);
set_string(&f->email, email); assert(frace != new_race[RC_ORC]);
if (set_email(&f->email, email)!=0) {
log_error(("Invalid email address: %s\n", email));
}
if (password) { if (password) {
set_string(&f->passw, password); set_string(&f->passw, password);

View File

@ -58,6 +58,7 @@
#include <attrib.h> #include <attrib.h>
#include <base36.h> #include <base36.h>
#include <event.h> #include <event.h>
#include <util/goodies.h>
#include <resolve.h> #include <resolve.h>
#include <sql.h> #include <sql.h>
#include <rand.h> #include <rand.h>
@ -1491,6 +1492,8 @@ readfaction(FILE * F)
int planes; int planes;
int i = rid(F); int i = rid(F);
faction * f = findfaction(i); faction * f = findfaction(i);
char * email;
if (f==NULL) { if (f==NULL) {
f = (faction *) calloc(1, sizeof(faction)); f = (faction *) calloc(1, sizeof(faction));
f->no = i; f->no = i;
@ -1519,7 +1522,11 @@ readfaction(FILE * F)
if (!quiet) printf(" - Lese Partei %s (%s)\n", f->name, factionid(f)); if (!quiet) printf(" - Lese Partei %s (%s)\n", f->name, factionid(f));
rds(F, &f->banner); rds(F, &f->banner);
rds(F, &f->email); rds(F, &email);
if (set_email(&f->email, email)!=0) {
log_error(("Invalid email address: %s\n", email));
set_email(&f->email, "");
}
rds(F, &f->passw); rds(F, &f->passw);
if (global.data_version >= OVERRIDE_VERSION) { if (global.data_version >= OVERRIDE_VERSION) {
rds(F, &f->override); rds(F, &f->override);

View File

@ -348,7 +348,9 @@ guardian_faction(plane * pl, int id)
f->banner = strdup("Sie dienen dem großen Wyrm"); f->banner = strdup("Sie dienen dem großen Wyrm");
f->passw = strdup(itoa36(rand())); f->passw = strdup(itoa36(rand()));
f->override = strdup(itoa36(rand())); f->override = strdup(itoa36(rand()));
f->email = strdup("igjarjuk@eressea-pbem.de"); if (set_email(&f->email, "igjarjuk@eressea.de")!=0) {
log_error(("Invalid email address: %s\n", email));
}
f->name = strdup("Igjarjuks Kundschafter"); f->name = strdup("Igjarjuks Kundschafter");
f->race = new_race[RC_ILLUSION]; f->race = new_race[RC_ILLUSION];
f->age = turn; f->age = turn;

View File

@ -37,6 +37,7 @@
#include <util/attrib.h> #include <util/attrib.h>
#include <util/base36.h> #include <util/base36.h>
#include <util/event.h> #include <util/event.h>
#include <util/goodies.h>
#include <util/umlaut.h> #include <util/umlaut.h>
/* libc includes */ /* libc includes */
@ -628,7 +629,9 @@ gm_addquest(const char * email, const char * name, int radius, unsigned int flag
f->passw = strdup(itoa36(rand())); f->passw = strdup(itoa36(rand()));
f->override = strdup(itoa36(rand())); f->override = strdup(itoa36(rand()));
f->override = strdup(itoa36(rand())); f->override = strdup(itoa36(rand()));
f->email = strdup(email); if (set_email(&f->email, email)!=0) {
log_error(("Invalid email address: %s\n", email));
}
f->name = strdup("Questenpartei"); f->name = strdup("Questenpartei");
f->race = new_race[RC_TEMPLATE]; f->race = new_race[RC_TEMPLATE];
f->age = 0; f->age = 0;
@ -729,7 +732,9 @@ gm_addfaction(const char * email, plane * p, region * r)
add_key(&f->attribs, atoi36("quest")); add_key(&f->attribs, atoi36("quest"));
f->banner = strdup("Questenpartei"); f->banner = strdup("Questenpartei");
f->passw = strdup(itoa36(rand())); f->passw = strdup(itoa36(rand()));
f->email = strdup(email); if (set_email(&f->email, email)!=0) {
log_error(("Invalid email address: %s\n", email));
}
f->name = strdup("Questenpartei"); f->name = strdup("Questenpartei");
f->race = new_race[RC_TEMPLATE]; f->race = new_race[RC_TEMPLATE];
f->age = 0; f->age = 0;

View File

@ -134,3 +134,33 @@ locale_check(void)
if (errorlevel) return false; if (errorlevel) return false;
return true; return true;
} }
int
set_email(char** pemail, const char *newmail)
{
int at = 0;
const char * s;
if (newmail && *newmail) {
for (s=newmail;*s;++s) {
switch(*s) {
case ':':
case '"':
case ' ':
return -1;
case '@':
if (at) return -1;
at = 1;
default:
break;
}
}
if (!at) return -1;
}
if (*pemail) free(*pemail);
*pemail = 0;
if (newmail) {
*pemail = strdup(newmail);
}
return 0;
}

View File

@ -26,6 +26,8 @@ extern unsigned int hashstring(const char* s);
extern const char *escape_string(const char * str, char * buffer, unsigned int len); extern const char *escape_string(const char * str, char * buffer, unsigned int len);
extern boolean locale_check(void); extern boolean locale_check(void);
extern char *fstrncat(char * buffer, const char * str, unsigned int size); extern char *fstrncat(char * buffer, const char * str, unsigned int size);
extern int set_email(char** pemail, const char *newmail);
/* fast strncat */ /* fast strncat */
/* grammar constants: */ /* grammar constants: */
#define GR_PLURAL 0x01 #define GR_PLURAL 0x01

View File

@ -159,6 +159,7 @@ bind_faction(lua_State * L)
.def("set_variable", &faction_set_variable) .def("set_variable", &faction_set_variable)
.def("get_variable", &faction_get_variable) .def("get_variable", &faction_get_variable)
.def("delete_variable", &faction_delete_variable) .def("delete_variable", &faction_delete_variable)
.def_readonly("info", &faction::banner)
.def_readonly("name", &faction::name) .def_readonly("name", &faction::name)
.def_readonly("password", &faction::passw) .def_readonly("password", &faction::passw)
.def_readonly("email", &faction::email) .def_readonly("email", &faction::email)

View File

@ -257,7 +257,9 @@ readshortpwds()
f = findfaction(atoi36(faction)); f = findfaction(atoi36(faction));
if (f!=NULL) { if (f!=NULL) {
shortpwd * pwd = (shortpwd*)malloc(sizeof(shortpwd)); shortpwd * pwd = (shortpwd*)malloc(sizeof(shortpwd));
pwd->email = strdup(email); if (set_email(&pwd->email, email)!=0) {
log_error(("Invalid email address: %s\n", email));
}
pwd->pwd = strdup(passwd); pwd->pwd = strdup(passwd);
pwd->used = false; pwd->used = false;
pwd->next = f->shortpwds; pwd->next = f->shortpwds;

View File

@ -252,7 +252,9 @@ readshortpwds()
f = findfaction(atoi36(faction)); f = findfaction(atoi36(faction));
if (f!=NULL) { if (f!=NULL) {
shortpwd * pwd = (shortpwd*)malloc(sizeof(shortpwd)); shortpwd * pwd = (shortpwd*)malloc(sizeof(shortpwd));
pwd->email = strdup(email); if (set_email(&pwd->email, email)!=0) {
log_error(("Invalid email address: %s\n", email));
}
pwd->pwd = strdup(passwd); pwd->pwd = strdup(passwd);
pwd->used = false; pwd->used = false;
pwd->next = f->shortpwds; pwd->next = f->shortpwds;

View File

@ -256,7 +256,9 @@ read_newfactions(const char * filename)
} }
if (nf) continue; if (nf) continue;
nf = calloc(sizeof(newfaction), 1); nf = calloc(sizeof(newfaction), 1);
nf->email = strdup(email); if (set_email(&nf->email, email)!=0) {
log_error(("Invalid email address: %s\n", email));
}
nf->password = strdup(password); nf->password = strdup(password);
nf->race = rc_find(race); nf->race = rc_find(race);
nf->subscription = subscription; nf->subscription = subscription;

View File

@ -1531,7 +1531,7 @@ makemonsters(void)
f->next=factions; f->next=factions;
f->race=new_race[RC_TEMPLATE]; f->race=new_race[RC_TEMPLATE];
f->alive=1; f->alive=1;
f->email=strdup(""); set_email(&f->email, "");
f->lastorders=0; f->lastorders=0;
f->locale=default_locale; f->locale=default_locale;