From 9ef4e683cf97aa43d81f00d6d5b7fbe8da25db00 Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 19 Apr 2020 17:59:47 +1000 Subject: Add a simple voucher field. --- src/sledjchisl/sledjchisl.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'src/sledjchisl/sledjchisl.c') diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c index 069f5de..771cf87 100644 --- a/src/sledjchisl/sledjchisl.c +++ b/src/sledjchisl/sledjchisl.c @@ -3329,6 +3329,7 @@ static void accountWrite(reqData *Rd) char *file = xmprintf("%s/users/%s.lua", scData, Rd->shs.UUID); char *link = (NULL == Rd->lnk) ? "" : Rd->lnk->hashish; char *about = encodeSlash(getStrH(Rd->stuff, "aboutMe")); + char *voucher = encodeSlash(getStrH(Rd->stuff, "voucher")); char *tnm = xmprintf( "user = \n" "{\n" " ['name']='%s',\n" @@ -3347,6 +3348,7 @@ static void accountWrite(reqData *Rd) " ['adult']='%s',\n" " ['aboutMe']='%s',\n" " ['vouched']='%s',\n" + " ['voucher']='%s',\n" " ['linky-hashish']='%s',\n" "}\n" "return user\n", @@ -3365,6 +3367,7 @@ static void accountWrite(reqData *Rd) getStrH(Rd->stuff, "adult"), about, "off", + voucher, link ); @@ -3394,6 +3397,7 @@ static void accountWrite(reqData *Rd) } xclose(fd); free(tnm); + free(voucher); free(about); free(file); } @@ -4155,6 +4159,31 @@ static void ToSWeb(reqData *Rd, inputForm *oF, inputValue *oV) Rd->reply->addstrf(Rd->reply, "

Terms of Service

%s
\n", getStrH(Rd->configs, "ToS")); } +static int voucherValidate(reqData *Rd, inputForm *oF, inputValue *oV) +{ + int ret = 0; + char *voucher = (char *) oV->value; + + if ((NULL == voucher) || ('\0' == voucher[0])) + { + bitch(Rd, "Please fill in the 'Voucher' section.", "None supplied."); + ret++; + } + + if ((0 == ret) && (NULL != voucher)) + { + char *t = qurl_encode(voucher, strlen(voucher)); + Rd->stuff->putstr(Rd->stuff, "voucher", t); + free(t); + } + + return ret; +} +static void voucherWeb(reqData *Rd, inputForm *oF, inputValue *oV) +{ + HTMLtext(Rd->reply, "text", oV->field->title, oV->field->name, oV->value, oV->field->viewLength, oV->field->maxLength, oV->field->flags & FLD_REQUIRED); +} + static int aboutMeValidate(reqData *Rd, inputForm *oF, inputValue *oV) { int ret = 0; @@ -4271,13 +4300,14 @@ static void accountViewWeb(reqData *Rd, inputForm *oF, inputValue *oV) accountWebHeaders(Rd, oF, getStrH(Rd->stuff, "name")); accountWebFields(Rd, oF, oV); -// TODO - still need to encode < > as < u> for email and about. +// TODO - still need to encode < > as < u> for email, voucher, and about. // TODO - dammit, qurl_decode returns the string length, and decodes the string in place. Rd->reply->addstrf(Rd->reply, "

Title / level : %s / %d

", getLevel(Rd), Rd->shs.level); Rd->reply->addstrf(Rd->reply, "

Date of birth : %s

", getStrH(Rd->database, "Lua.DoB")); Rd->reply->addstrf(Rd->reply, "

Created : %s

", ctime(&crtd)); Rd->reply->addstrf(Rd->reply, "

Email : %s

", displayPrep(getStrH(Rd->stuff, "email"))); Rd->reply->addstrf(Rd->reply, "

UUID : %s

", Rd->shs.UUID); + Rd->reply->addstrf(Rd->reply, "

Voucher : %s

", displayPrep(getStrH(Rd->database, "Lua.voucher"))); // Rd->reply->addstrf(Rd->reply, "

About :

" // "", qurl_decode(getStrH(Rd->database, "Lua.aboutMe"))); HTMLtextArea(Rd->reply, "aboutMe", "About", 7, 50, 4, 16384, "", "off", "true", "soft", displayPrep(getStrH(Rd->database, "Lua.aboutMe")), FALSE, TRUE); @@ -4422,6 +4452,7 @@ d("accountRead() UUID %s, name %s %s", uuid, first, last); Rd->database->putstr(Rd->database, "Lua.adult", getStrH(tnm, "adult")); Rd->database->putstr(Rd->database, "Lua.aboutMe", getStrH(tnm, "aboutMe")); Rd->database->putstr(Rd->database, "Lua.vouched", getStrH(tnm, "vouched")); + Rd->database->putstr(Rd->database, "Lua.voucher", getStrH(tnm, "voucher")); } else if (rows) { @@ -4616,6 +4647,7 @@ static int accountValidate(reqData *Rd, inputForm *iF, inputValue *iV) Rd->stuff->putstr(Rd->stuff, "adult", getStrH(Rd->database, "Lua.adult")); Rd->stuff->putstr(Rd->stuff, "aboutMe", getStrH(Rd->database, "Lua.aboutMe")); Rd->stuff->putstr(Rd->stuff, "vouched", getStrH(Rd->database, "Lua.vouched")); + Rd->stuff->putstr(Rd->stuff, "voucher", getStrH(Rd->database, "Lua.voucher")); Rd->shs.level = -100; accountWrite(Rd); wipe = TRUE; @@ -5036,6 +5068,9 @@ void account_html(char *file, reqData *Rd, HTMLfile *thisFile) addDoBFields(iF); addLegalFields(iF); fld = addInputField(iF, LUA_TSTRING, "ToS", "Terms of Service", "", NULL, ToSWeb); + fld = addInputField(iF, LUA_TSTRING, "voucher", "The grid name of someone that will vouch for you", + "We use a vouching system here, an existing member must know you well enough to tell us you'll be good for our grid.", voucherValidate, voucherWeb); + inputFieldExtra(fld, FLD_EDITABLE, 42, 63); fld = addInputField(iF, LUA_TSTRING, "aboutMe", "About me", NULL, aboutMeValidate, aboutMeWeb); inputFieldExtra(fld, FLD_EDITABLE, 50, 16384); addSubmit(iF, "confirm", "confirm", NULL, accountAdd, "accountView"); -- cgit v1.1