diff options
author | onefang | 2020-04-19 17:59:47 +1000 |
---|---|---|
committer | onefang | 2020-04-19 17:59:47 +1000 |
commit | 9ef4e683cf97aa43d81f00d6d5b7fbe8da25db00 (patch) | |
tree | 607b703b661a84ba4e205654413cf763b4ba7c69 /src/sledjchisl/sledjchisl.c | |
parent | Actually validate their age. (diff) | |
download | opensim-SC-9ef4e683cf97aa43d81f00d6d5b7fbe8da25db00.zip opensim-SC-9ef4e683cf97aa43d81f00d6d5b7fbe8da25db00.tar.gz opensim-SC-9ef4e683cf97aa43d81f00d6d5b7fbe8da25db00.tar.bz2 opensim-SC-9ef4e683cf97aa43d81f00d6d5b7fbe8da25db00.tar.xz |
Add a simple voucher field.
Diffstat (limited to '')
-rw-r--r-- | src/sledjchisl/sledjchisl.c | 37 |
1 files changed, 36 insertions, 1 deletions
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) | |||
3329 | char *file = xmprintf("%s/users/%s.lua", scData, Rd->shs.UUID); | 3329 | char *file = xmprintf("%s/users/%s.lua", scData, Rd->shs.UUID); |
3330 | char *link = (NULL == Rd->lnk) ? "" : Rd->lnk->hashish; | 3330 | char *link = (NULL == Rd->lnk) ? "" : Rd->lnk->hashish; |
3331 | char *about = encodeSlash(getStrH(Rd->stuff, "aboutMe")); | 3331 | char *about = encodeSlash(getStrH(Rd->stuff, "aboutMe")); |
3332 | char *voucher = encodeSlash(getStrH(Rd->stuff, "voucher")); | ||
3332 | char *tnm = xmprintf( "user = \n" | 3333 | char *tnm = xmprintf( "user = \n" |
3333 | "{\n" | 3334 | "{\n" |
3334 | " ['name']='%s',\n" | 3335 | " ['name']='%s',\n" |
@@ -3347,6 +3348,7 @@ static void accountWrite(reqData *Rd) | |||
3347 | " ['adult']='%s',\n" | 3348 | " ['adult']='%s',\n" |
3348 | " ['aboutMe']='%s',\n" | 3349 | " ['aboutMe']='%s',\n" |
3349 | " ['vouched']='%s',\n" | 3350 | " ['vouched']='%s',\n" |
3351 | " ['voucher']='%s',\n" | ||
3350 | " ['linky-hashish']='%s',\n" | 3352 | " ['linky-hashish']='%s',\n" |
3351 | "}\n" | 3353 | "}\n" |
3352 | "return user\n", | 3354 | "return user\n", |
@@ -3365,6 +3367,7 @@ static void accountWrite(reqData *Rd) | |||
3365 | getStrH(Rd->stuff, "adult"), | 3367 | getStrH(Rd->stuff, "adult"), |
3366 | about, | 3368 | about, |
3367 | "off", | 3369 | "off", |
3370 | voucher, | ||
3368 | link | 3371 | link |
3369 | ); | 3372 | ); |
3370 | 3373 | ||
@@ -3394,6 +3397,7 @@ static void accountWrite(reqData *Rd) | |||
3394 | } | 3397 | } |
3395 | xclose(fd); | 3398 | xclose(fd); |
3396 | free(tnm); | 3399 | free(tnm); |
3400 | free(voucher); | ||
3397 | free(about); | 3401 | free(about); |
3398 | free(file); | 3402 | free(file); |
3399 | } | 3403 | } |
@@ -4155,6 +4159,31 @@ static void ToSWeb(reqData *Rd, inputForm *oF, inputValue *oV) | |||
4155 | Rd->reply->addstrf(Rd->reply, "<h2>Terms of Service</h2><pre>%s</pre>\n", getStrH(Rd->configs, "ToS")); | 4159 | Rd->reply->addstrf(Rd->reply, "<h2>Terms of Service</h2><pre>%s</pre>\n", getStrH(Rd->configs, "ToS")); |
4156 | } | 4160 | } |
4157 | 4161 | ||
4162 | static int voucherValidate(reqData *Rd, inputForm *oF, inputValue *oV) | ||
4163 | { | ||
4164 | int ret = 0; | ||
4165 | char *voucher = (char *) oV->value; | ||
4166 | |||
4167 | if ((NULL == voucher) || ('\0' == voucher[0])) | ||
4168 | { | ||
4169 | bitch(Rd, "Please fill in the 'Voucher' section.", "None supplied."); | ||
4170 | ret++; | ||
4171 | } | ||
4172 | |||
4173 | if ((0 == ret) && (NULL != voucher)) | ||
4174 | { | ||
4175 | char *t = qurl_encode(voucher, strlen(voucher)); | ||
4176 | Rd->stuff->putstr(Rd->stuff, "voucher", t); | ||
4177 | free(t); | ||
4178 | } | ||
4179 | |||
4180 | return ret; | ||
4181 | } | ||
4182 | static void voucherWeb(reqData *Rd, inputForm *oF, inputValue *oV) | ||
4183 | { | ||
4184 | HTMLtext(Rd->reply, "text", oV->field->title, oV->field->name, oV->value, oV->field->viewLength, oV->field->maxLength, oV->field->flags & FLD_REQUIRED); | ||
4185 | } | ||
4186 | |||
4158 | static int aboutMeValidate(reqData *Rd, inputForm *oF, inputValue *oV) | 4187 | static int aboutMeValidate(reqData *Rd, inputForm *oF, inputValue *oV) |
4159 | { | 4188 | { |
4160 | int ret = 0; | 4189 | int ret = 0; |
@@ -4271,13 +4300,14 @@ static void accountViewWeb(reqData *Rd, inputForm *oF, inputValue *oV) | |||
4271 | 4300 | ||
4272 | accountWebHeaders(Rd, oF, getStrH(Rd->stuff, "name")); | 4301 | accountWebHeaders(Rd, oF, getStrH(Rd->stuff, "name")); |
4273 | accountWebFields(Rd, oF, oV); | 4302 | accountWebFields(Rd, oF, oV); |
4274 | // TODO - still need to encode < > as < u> for email and about. | 4303 | // TODO - still need to encode < > as < u> for email, voucher, and about. |
4275 | // TODO - dammit, qurl_decode returns the string length, and decodes the string in place. | 4304 | // TODO - dammit, qurl_decode returns the string length, and decodes the string in place. |
4276 | Rd->reply->addstrf(Rd->reply, "<p><font size='5'><span style='font-size: x-large'><b>Title / level :</b></span></font> %s / %d</p>", getLevel(Rd), Rd->shs.level); | 4305 | Rd->reply->addstrf(Rd->reply, "<p><font size='5'><span style='font-size: x-large'><b>Title / level :</b></span></font> %s / %d</p>", getLevel(Rd), Rd->shs.level); |
4277 | Rd->reply->addstrf(Rd->reply, "<p><font size='5'><span style='font-size: x-large'><b>Date of birth :</b></span></font> %s</p>", getStrH(Rd->database, "Lua.DoB")); | 4306 | Rd->reply->addstrf(Rd->reply, "<p><font size='5'><span style='font-size: x-large'><b>Date of birth :</b></span></font> %s</p>", getStrH(Rd->database, "Lua.DoB")); |
4278 | Rd->reply->addstrf(Rd->reply, "<p><font size='5'><span style='font-size: x-large'><b>Created :</b></span></font> %s</p>", ctime(&crtd)); | 4307 | Rd->reply->addstrf(Rd->reply, "<p><font size='5'><span style='font-size: x-large'><b>Created :</b></span></font> %s</p>", ctime(&crtd)); |
4279 | Rd->reply->addstrf(Rd->reply, "<p><font size='5'><span style='font-size: x-large'><b>Email :</b></span></font> %s</p>", displayPrep(getStrH(Rd->stuff, "email"))); | 4308 | Rd->reply->addstrf(Rd->reply, "<p><font size='5'><span style='font-size: x-large'><b>Email :</b></span></font> %s</p>", displayPrep(getStrH(Rd->stuff, "email"))); |
4280 | Rd->reply->addstrf(Rd->reply, "<p><font size='5'><span style='font-size: x-large'><b>UUID :</b></span></font> %s</p>", Rd->shs.UUID); | 4309 | Rd->reply->addstrf(Rd->reply, "<p><font size='5'><span style='font-size: x-large'><b>UUID :</b></span></font> %s</p>", Rd->shs.UUID); |
4310 | Rd->reply->addstrf(Rd->reply, "<p><font size='5'><span style='font-size: x-large'><b>Voucher :</b></span></font> %s</p>", displayPrep(getStrH(Rd->database, "Lua.voucher"))); | ||
4281 | // Rd->reply->addstrf(Rd->reply, "<p><font size='5'><span style='font-size: x-large'><b>About :</b></span></font> </p>" | 4311 | // Rd->reply->addstrf(Rd->reply, "<p><font size='5'><span style='font-size: x-large'><b>About :</b></span></font> </p>" |
4282 | // "<textarea readonly >%s</textarea>", qurl_decode(getStrH(Rd->database, "Lua.aboutMe"))); | 4312 | // "<textarea readonly >%s</textarea>", qurl_decode(getStrH(Rd->database, "Lua.aboutMe"))); |
4283 | HTMLtextArea(Rd->reply, "aboutMe", "About", 7, 50, 4, 16384, "", "off", "true", "soft", displayPrep(getStrH(Rd->database, "Lua.aboutMe")), FALSE, TRUE); | 4313 | 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); | |||
4422 | Rd->database->putstr(Rd->database, "Lua.adult", getStrH(tnm, "adult")); | 4452 | Rd->database->putstr(Rd->database, "Lua.adult", getStrH(tnm, "adult")); |
4423 | Rd->database->putstr(Rd->database, "Lua.aboutMe", getStrH(tnm, "aboutMe")); | 4453 | Rd->database->putstr(Rd->database, "Lua.aboutMe", getStrH(tnm, "aboutMe")); |
4424 | Rd->database->putstr(Rd->database, "Lua.vouched", getStrH(tnm, "vouched")); | 4454 | Rd->database->putstr(Rd->database, "Lua.vouched", getStrH(tnm, "vouched")); |
4455 | Rd->database->putstr(Rd->database, "Lua.voucher", getStrH(tnm, "voucher")); | ||
4425 | } | 4456 | } |
4426 | else if (rows) | 4457 | else if (rows) |
4427 | { | 4458 | { |
@@ -4616,6 +4647,7 @@ static int accountValidate(reqData *Rd, inputForm *iF, inputValue *iV) | |||
4616 | Rd->stuff->putstr(Rd->stuff, "adult", getStrH(Rd->database, "Lua.adult")); | 4647 | Rd->stuff->putstr(Rd->stuff, "adult", getStrH(Rd->database, "Lua.adult")); |
4617 | Rd->stuff->putstr(Rd->stuff, "aboutMe", getStrH(Rd->database, "Lua.aboutMe")); | 4648 | Rd->stuff->putstr(Rd->stuff, "aboutMe", getStrH(Rd->database, "Lua.aboutMe")); |
4618 | Rd->stuff->putstr(Rd->stuff, "vouched", getStrH(Rd->database, "Lua.vouched")); | 4649 | Rd->stuff->putstr(Rd->stuff, "vouched", getStrH(Rd->database, "Lua.vouched")); |
4650 | Rd->stuff->putstr(Rd->stuff, "voucher", getStrH(Rd->database, "Lua.voucher")); | ||
4619 | Rd->shs.level = -100; | 4651 | Rd->shs.level = -100; |
4620 | accountWrite(Rd); | 4652 | accountWrite(Rd); |
4621 | wipe = TRUE; | 4653 | wipe = TRUE; |
@@ -5036,6 +5068,9 @@ void account_html(char *file, reqData *Rd, HTMLfile *thisFile) | |||
5036 | addDoBFields(iF); | 5068 | addDoBFields(iF); |
5037 | addLegalFields(iF); | 5069 | addLegalFields(iF); |
5038 | fld = addInputField(iF, LUA_TSTRING, "ToS", "Terms of Service", "", NULL, ToSWeb); | 5070 | fld = addInputField(iF, LUA_TSTRING, "ToS", "Terms of Service", "", NULL, ToSWeb); |
5071 | fld = addInputField(iF, LUA_TSTRING, "voucher", "The grid name of someone that will vouch for you", | ||
5072 | "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); | ||
5073 | inputFieldExtra(fld, FLD_EDITABLE, 42, 63); | ||
5039 | fld = addInputField(iF, LUA_TSTRING, "aboutMe", "About me", NULL, aboutMeValidate, aboutMeWeb); | 5074 | fld = addInputField(iF, LUA_TSTRING, "aboutMe", "About me", NULL, aboutMeValidate, aboutMeWeb); |
5040 | inputFieldExtra(fld, FLD_EDITABLE, 50, 16384); | 5075 | inputFieldExtra(fld, FLD_EDITABLE, 50, 16384); |
5041 | addSubmit(iF, "confirm", "confirm", NULL, accountAdd, "accountView"); | 5076 | addSubmit(iF, "confirm", "confirm", NULL, accountAdd, "accountView"); |