forked from github/server
- Simpler Adresscheck (ungültige emails)
- Lua: - faction.info (banner)
This commit is contained in:
parent
e657058251
commit
8ab908dde9
|
@ -66,7 +66,7 @@ createmonsters(void)
|
|||
/* alles ist auf null gesetzt, ausser dem folgenden. achtung - partei
|
||||
* no 0 muss keine orders einreichen! */
|
||||
|
||||
set_string(&f->email, "keine");
|
||||
set_string(&f->email, "monsters@eressea.de");
|
||||
set_string(&f->name, "Monster");
|
||||
f->alive = 1;
|
||||
f->options = (char) pow(2, O_REPORT);
|
||||
|
|
|
@ -2053,12 +2053,16 @@ email_cmd(unit * u, struct order * ord)
|
|||
|
||||
if (!s[0]) {
|
||||
cmistake(u, ord, 85, MSG_EVENT);
|
||||
} else if (strstr(s, "internet:") || strchr(s, ' ')) {
|
||||
cmistake(u, ord, 117, MSG_EVENT);
|
||||
} else {
|
||||
set_string(&u->faction->email, s);
|
||||
ADDMSG(&u->faction->msgs, msg_message("changemail", "value",
|
||||
gc_add(strdup(u->faction->email))));
|
||||
faction * f = u->faction;
|
||||
if (set_email(&f->email, s)!=0) {
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -23,8 +23,9 @@
|
|||
#include "group.h"
|
||||
|
||||
/* util includes */
|
||||
#include <base36.h>
|
||||
#include <event.h>
|
||||
#include <util/base36.h>
|
||||
#include <util/event.h>
|
||||
#include <util/goodies.h>
|
||||
|
||||
#include <attributes/otherfaction.h>
|
||||
|
||||
|
@ -93,11 +94,13 @@ addfaction(const char *email, const char * password,
|
|||
int subscription)
|
||||
{
|
||||
int i;
|
||||
faction *f;
|
||||
assert(frace != new_race[RC_ORC]);
|
||||
f = calloc(sizeof(faction), 1);
|
||||
faction * 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) {
|
||||
set_string(&f->passw, password);
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
#include <attrib.h>
|
||||
#include <base36.h>
|
||||
#include <event.h>
|
||||
#include <util/goodies.h>
|
||||
#include <resolve.h>
|
||||
#include <sql.h>
|
||||
#include <rand.h>
|
||||
|
@ -1491,6 +1492,8 @@ readfaction(FILE * F)
|
|||
int planes;
|
||||
int i = rid(F);
|
||||
faction * f = findfaction(i);
|
||||
char * email;
|
||||
|
||||
if (f==NULL) {
|
||||
f = (faction *) calloc(1, sizeof(faction));
|
||||
f->no = i;
|
||||
|
@ -1519,7 +1522,11 @@ readfaction(FILE * F)
|
|||
if (!quiet) printf(" - Lese Partei %s (%s)\n", f->name, factionid(f));
|
||||
|
||||
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);
|
||||
if (global.data_version >= OVERRIDE_VERSION) {
|
||||
rds(F, &f->override);
|
||||
|
|
|
@ -348,7 +348,9 @@ guardian_faction(plane * pl, int id)
|
|||
f->banner = strdup("Sie dienen dem großen Wyrm");
|
||||
f->passw = 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->race = new_race[RC_ILLUSION];
|
||||
f->age = turn;
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include <util/attrib.h>
|
||||
#include <util/base36.h>
|
||||
#include <util/event.h>
|
||||
#include <util/goodies.h>
|
||||
#include <util/umlaut.h>
|
||||
|
||||
/* 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->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->race = new_race[RC_TEMPLATE];
|
||||
f->age = 0;
|
||||
|
@ -729,7 +732,9 @@ gm_addfaction(const char * email, plane * p, region * r)
|
|||
add_key(&f->attribs, atoi36("quest"));
|
||||
f->banner = strdup("Questenpartei");
|
||||
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->race = new_race[RC_TEMPLATE];
|
||||
f->age = 0;
|
||||
|
|
|
@ -134,3 +134,33 @@ locale_check(void)
|
|||
if (errorlevel) return false;
|
||||
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;
|
||||
}
|
|
@ -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 boolean locale_check(void);
|
||||
extern char *fstrncat(char * buffer, const char * str, unsigned int size);
|
||||
|
||||
extern int set_email(char** pemail, const char *newmail);
|
||||
/* fast strncat */
|
||||
/* grammar constants: */
|
||||
#define GR_PLURAL 0x01
|
||||
|
|
|
@ -159,6 +159,7 @@ bind_faction(lua_State * L)
|
|||
.def("set_variable", &faction_set_variable)
|
||||
.def("get_variable", &faction_get_variable)
|
||||
.def("delete_variable", &faction_delete_variable)
|
||||
.def_readonly("info", &faction::banner)
|
||||
.def_readonly("name", &faction::name)
|
||||
.def_readonly("password", &faction::passw)
|
||||
.def_readonly("email", &faction::email)
|
||||
|
|
|
@ -257,7 +257,9 @@ readshortpwds()
|
|||
f = findfaction(atoi36(faction));
|
||||
if (f!=NULL) {
|
||||
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->used = false;
|
||||
pwd->next = f->shortpwds;
|
||||
|
|
|
@ -252,7 +252,9 @@ readshortpwds()
|
|||
f = findfaction(atoi36(faction));
|
||||
if (f!=NULL) {
|
||||
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->used = false;
|
||||
pwd->next = f->shortpwds;
|
||||
|
|
|
@ -256,7 +256,9 @@ read_newfactions(const char * filename)
|
|||
}
|
||||
if (nf) continue;
|
||||
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->race = rc_find(race);
|
||||
nf->subscription = subscription;
|
||||
|
|
|
@ -1531,7 +1531,7 @@ makemonsters(void)
|
|||
f->next=factions;
|
||||
f->race=new_race[RC_TEMPLATE];
|
||||
f->alive=1;
|
||||
f->email=strdup("");
|
||||
set_email(&f->email, "");
|
||||
f->lastorders=0;
|
||||
f->locale=default_locale;
|
||||
|
||||
|
|
Loading…
Reference in New Issue