aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/sledjchisl
diff options
context:
space:
mode:
authoronefang2020-04-22 05:51:40 +1000
committeronefang2020-04-22 05:51:40 +1000
commitd80fe50ade9d74b83310b926d0d98037ecdac1d8 (patch)
tree65d9947aa268206941eca25744e06cd760cda3c3 /src/sledjchisl
parentTypo-- (diff)
downloadopensim-SC_OLD-d80fe50ade9d74b83310b926d0d98037ecdac1d8.zip
opensim-SC_OLD-d80fe50ade9d74b83310b926d0d98037ecdac1d8.tar.gz
opensim-SC_OLD-d80fe50ade9d74b83310b926d0d98037ecdac1d8.tar.bz2
opensim-SC_OLD-d80fe50ade9d74b83310b926d0d98037ecdac1d8.tar.xz
Various fixes and additions I'm too tired to untangle now. lol
Method to include a query in the GET redirection. More testing instructions. More stuff v shs sanity. Various functions changed from figuring out their arguments to just pass them in. Changed some function names. Added "You are person X" linky at top of logged in pages. Allow gods to edit the level of others. No doubt various small things I forgot. lol
Diffstat (limited to '')
-rw-r--r--src/sledjchisl/sledjchisl.c372
1 files changed, 249 insertions, 123 deletions
diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c
index f6f8f9d..8fb505b 100644
--- a/src/sledjchisl/sledjchisl.c
+++ b/src/sledjchisl/sledjchisl.c
@@ -380,7 +380,7 @@ struct _reqData
380{ 380{
381 lua_State *L; 381 lua_State *L;
382 qhashtbl_t *configs, *queries, *body, *cookies, *headers, *valid, *stuff, *database, *Rcookies, *Rheaders; 382 qhashtbl_t *configs, *queries, *body, *cookies, *headers, *valid, *stuff, *database, *Rcookies, *Rheaders;
383 char *Scheme, *Host, *Method, *Script, *RUri, *doit, *form, *output; 383 char *Scheme, *Host, *Method, *Script, *RUri, *doit, *form, *output, *outQuery;
384 sesh shs, *lnk; 384 sesh shs, *lnk;
385 MYSQL *db; 385 MYSQL *db;
386 gridStats *stats; 386 gridStats *stats;
@@ -2539,6 +2539,8 @@ static void HTMLfooter(qgrow_t *reply)
2539 " So feel free to create as many test accounts as you need to test things.</p>\n" 2539 " So feel free to create as many test accounts as you need to test things.</p>\n"
2540 " <p>We follow the usual web site registration process, which sends a validation email, with a link to click. &nbsp; " 2540 " <p>We follow the usual web site registration process, which sends a validation email, with a link to click. &nbsp; "
2541 " However, during this test mode, no emails will be sent, instead a link will be displayed near the top of the page when a user is logged in.</p>\n" 2541 " However, during this test mode, no emails will be sent, instead a link will be displayed near the top of the page when a user is logged in.</p>\n"
2542 " <p>After creating an account, log on as your grid god account, click the 'validated members' button, click on the new member, set their level to 'approved', "
2543 " then click on the 'save' button. &nbsp; In theory that will create their in world account, in practice I still haven't written that bit.</p>"
2542 " <p>Missing bits that are still being written - sending the emails, creating real grid accounts, editing accounts, listing accounts, deleting accounts.</p>\n" 2544 " <p>Missing bits that are still being written - sending the emails, creating real grid accounts, editing accounts, listing accounts, deleting accounts.</p>\n"
2543 " </div>\n"); 2545 " </div>\n");
2544// reply->addstr(reply, " <div class='centre'>\n </div>\n"); 2546// reply->addstr(reply, " <div class='centre'>\n </div>\n");
@@ -2774,7 +2776,7 @@ HTMLfile *checkHTMLcache(char *file)
2774. tell them they have validated 2776. tell them they have validated
2775 create their OpenSim account UserAccounts.UserTitle and auth tables, not GridUser table 2777 create their OpenSim account UserAccounts.UserTitle and auth tables, not GridUser table
2776 create their GridUser record. 2778 create their GridUser record.
2777 update their UserAccounts.Userlevel and UserAccounts.UserTitle 2779. update their UserAccounts.Userlevel and UserAccounts.UserTitle
2778. send them to the login page. 2780. send them to the login page.
2779. regenerate the usual token 2781. regenerate the usual token
2780? let user stay logged on? 2782? let user stay logged on?
@@ -3191,7 +3193,7 @@ static void setToken_n_munchie(reqData *Rd, boolean linky)
3191 shs->salt, 3193 shs->salt,
3192 shs->seshID 3194 shs->seshID
3193 ); 3195 );
3194 char *tnm1 = xmprintf(" ['name']='%s',\n", shs->name); 3196 char *tnm1 = xmprintf(" ['name']='%s',\n ['level']='%d',\n", shs->name, (int) shs->level);
3195 char *tnm2 = xmprintf(" ['UUID']='%s',\n", shs->UUID); 3197 char *tnm2 = xmprintf(" ['UUID']='%s',\n", shs->UUID);
3196 char *tnm3 = xmprintf(" ['passHash']='%s',\n", getStrH(Rd->stuff, "passHash")); 3198 char *tnm3 = xmprintf(" ['passHash']='%s',\n", getStrH(Rd->stuff, "passHash"));
3197 char *tnm4 = xmprintf(" ['passSalt']='%s',\n", getStrH(Rd->stuff, "passSalt")); 3199 char *tnm4 = xmprintf(" ['passSalt']='%s',\n", getStrH(Rd->stuff, "passSalt"));
@@ -3304,9 +3306,9 @@ static void generateAccountUUID(reqData *Rd)
3304 Rd->database->putstr(Rd->database, "UserAccounts.Userlevel", "-200"); 3306 Rd->database->putstr(Rd->database, "UserAccounts.Userlevel", "-200");
3305} 3307}
3306 3308
3307char *getLevel(reqData *Rd) 3309char *getLevel(short level)
3308{ 3310{
3309 char *ret = "", *lvl = xmprintf("%d", Rd->shs.level); 3311 char *ret = "", *lvl = xmprintf("%d", level);
3310 ret = accountLevels->getstr(accountLevels, lvl, false); 3312 ret = accountLevels->getstr(accountLevels, lvl, false);
3311 if (NULL == ret) 3313 if (NULL == ret)
3312 { 3314 {
@@ -3316,7 +3318,7 @@ char *getLevel(reqData *Rd)
3316 accountLevels->lock(accountLevels); 3318 accountLevels->lock(accountLevels);
3317 while(accountLevels->getnext(accountLevels, &obj, NULL, false) == true) 3319 while(accountLevels->getnext(accountLevels, &obj, NULL, false) == true)
3318 { 3320 {
3319 if (atoi(obj.name) <= Rd->shs.level) 3321 if (atoi(obj.name) <= level)
3320 ret = (char *) obj.data; 3322 ret = (char *) obj.data;
3321 } 3323 }
3322 } 3324 }
@@ -3326,7 +3328,9 @@ char *getLevel(reqData *Rd)
3326 3328
3327static void accountWrite(reqData *Rd) 3329static void accountWrite(reqData *Rd)
3328{ 3330{
3329 char *file = xmprintf("%s/users/%s.lua", scData, Rd->shs.UUID); 3331 char *uuid = getStrH(Rd->database, "UserAccounts.PrincipalID");
3332 char *file = xmprintf("%s/users/%s.lua", scData, uuid);
3333 char *level = getStrH(Rd->database, "UserAccounts.UserLevel");
3330 char *link = (NULL == Rd->lnk) ? "" : Rd->lnk->hashish; 3334 char *link = (NULL == Rd->lnk) ? "" : Rd->lnk->hashish;
3331 char *about = encodeSlash(getStrH(Rd->stuff, "aboutMe")); 3335 char *about = encodeSlash(getStrH(Rd->stuff, "aboutMe"));
3332 char *voucher = encodeSlash(getStrH(Rd->stuff, "voucher")); 3336 char *voucher = encodeSlash(getStrH(Rd->stuff, "voucher"));
@@ -3337,7 +3341,7 @@ static void accountWrite(reqData *Rd)
3337 " ['created']='%ld',\n" 3341 " ['created']='%ld',\n"
3338 " ['email']='%s',\n" 3342 " ['email']='%s',\n"
3339 " ['title']='%s',\n" 3343 " ['title']='%s',\n"
3340 " ['level']='%d',\n" 3344 " ['level']='%s',\n"
3341 " ['flags']='%d',\n" 3345 " ['flags']='%d',\n"
3342 " ['active']='%d',\n" 3346 " ['active']='%d',\n"
3343 " ['passwordHash']='%s',\n" 3347 " ['passwordHash']='%s',\n"
@@ -3355,13 +3359,13 @@ static void accountWrite(reqData *Rd)
3355 getStrH(Rd->stuff, "name"), 3359 getStrH(Rd->stuff, "name"),
3356 (strcmp("", getStrH(Rd->stuff, "created")) != 0) ? atol(getStrH(Rd->stuff, "created")) : (long) Rd->shs.timeStamp[1].tv_sec, 3360 (strcmp("", getStrH(Rd->stuff, "created")) != 0) ? atol(getStrH(Rd->stuff, "created")) : (long) Rd->shs.timeStamp[1].tv_sec,
3357 getStrH(Rd->stuff, "email"), 3361 getStrH(Rd->stuff, "email"),
3358 getLevel(Rd), 3362 getLevel(atoi(level)),
3359 Rd->shs.level, 3363 level,
3360 64, 3364 64,
3361 0, 3365 0,
3362 getStrH(Rd->stuff, "passwordHash"), 3366 getStrH(Rd->stuff, "passwordHash"),
3363 getStrH(Rd->stuff, "passwordSalt"), 3367 getStrH(Rd->stuff, "passwordSalt"),
3364 Rd->shs.UUID, 3368 uuid,
3365 getStrH(Rd->stuff, "DoB"), 3369 getStrH(Rd->stuff, "DoB"),
3366 getStrH(Rd->stuff, "agree"), 3370 getStrH(Rd->stuff, "agree"),
3367 getStrH(Rd->stuff, "adult"), 3371 getStrH(Rd->stuff, "adult"),
@@ -3714,6 +3718,10 @@ W("Validated session linky.");
3714 } 3718 }
3715 else 3719 else
3716 { 3720 {
3721 char *level = tnm->getstr(tnm, "level", false);
3722
3723 if (NULL == level)
3724 level = "-256";
3717 qstrcpy(shs->sesh, sizeof(shs->sesh), seshion); 3725 qstrcpy(shs->sesh, sizeof(shs->sesh), seshion);
3718 qstrcpy(shs->toke_n_munchie, sizeof(shs->toke_n_munchie), toke_n_munchie); 3726 qstrcpy(shs->toke_n_munchie, sizeof(shs->toke_n_munchie), toke_n_munchie);
3719 qstrcpy(shs->hashish, sizeof(shs->hashish), hashish); 3727 qstrcpy(shs->hashish, sizeof(shs->hashish), hashish);
@@ -3723,6 +3731,8 @@ W("Validated session linky.");
3723// TODO - free this somewhere. 3731// TODO - free this somewhere.
3724// shs->name = tnm->getstr(tnm, "name", true); 3732// shs->name = tnm->getstr(tnm, "name", true);
3725// shs->UUID = tnm->getstr(tnm, "UUID", true); 3733// shs->UUID = tnm->getstr(tnm, "UUID", true);
3734 shs->level = atoi(level);
3735// TODO - get level from somewhere and stuff it in shs.
3726 shs->timeStamp[0].tv_nsec = UTIME_OMIT; 3736 shs->timeStamp[0].tv_nsec = UTIME_OMIT;
3727 shs->timeStamp[0].tv_sec = UTIME_OMIT; 3737 shs->timeStamp[0].tv_sec = UTIME_OMIT;
3728 memcpy(&shs->timeStamp[1], &st.st_mtim, sizeof(struct timespec)); 3738 memcpy(&shs->timeStamp[1], &st.st_mtim, sizeof(struct timespec));
@@ -3747,8 +3757,9 @@ t("SessionValidate() Lua read %s = %s", n, (char *) obj.data);
3747 } 3757 }
3748 } 3758 }
3749 tnm->unlock(tnm); 3759 tnm->unlock(tnm);
3760
3750// TODO - check this. 3761// TODO - check this.
3751 Rd->database->putstr(Rd->database, "UserAccounts.PrincipalID", tnm->getstr(tnm, "UUID", false)); 3762// Rd->database->putstr(Rd->database, "UserAccounts.PrincipalID", tnm->getstr(tnm, "UUID", false));
3752 } 3763 }
3753 } 3764 }
3754 free(munchie); 3765 free(munchie);
@@ -3877,10 +3888,12 @@ static int nameValidate(reqData *Rd, inputForm *iF, inputValue *iV)
3877 3888
3878 if (0 == ret) 3889 if (0 == ret)
3879 { 3890 {
3880 Rd->stuff->putstr(Rd->stuff, "firstName", name); 3891 Rd->stuff->putstr(Rd->stuff, "firstName", name);
3881 Rd->stuff->putstr(Rd->stuff, "lastName", s); 3892 Rd->stuff->putstr(Rd->stuff, "lastName", s);
3882 Rd->stuff->putstrf(Rd->stuff, "name", "%s %s", name, s); 3893 Rd->stuff->putstrf(Rd->stuff, "name", "%s %s", name, s);
3883 Rd->shs.name = Rd->stuff->getstr(Rd->stuff, "name", true); 3894// TODO - fix this, so we don't show "You are user" when we are not, but everything else still works.
3895// if ('\0' != getStrH(Rd->queries, "user")[0])
3896 Rd->shs.name = Rd->stuff->getstr(Rd->stuff, "name", true);
3884 } 3897 }
3885 } 3898 }
3886 } 3899 }
@@ -4223,18 +4236,23 @@ static void aboutMeWeb(reqData *Rd, inputForm *oF, inputValue *oV)
4223 HTMLtextArea(Rd->reply, oV->field->name, oV->field->title, 7, oV->field->viewLength, 4, oV->field->maxLength, "Describe yourself here.", "off", "true", "soft", oV->value, FALSE, FALSE); 4236 HTMLtextArea(Rd->reply, oV->field->name, oV->field->title, 7, oV->field->viewLength, 4, oV->field->maxLength, "Describe yourself here.", "off", "true", "soft", oV->value, FALSE, FALSE);
4224} 4237}
4225 4238
4226static void accountWebHeaders(reqData *Rd, inputForm *oF, char *name) 4239static void accountWebHeaders(reqData *Rd, inputForm *oF) //, char *name)
4227{ 4240{
4228 char *linky = checkLinky(Rd); 4241 char *linky = checkLinky(Rd);
4229 4242
4230 HTMLheader(Rd->reply, "<!--#echo var=\"grid\" --> account manager"); 4243 HTMLheader(Rd->reply, "<!--#echo var=\"grid\" --> account manager");
4231 Rd->reply->addstrf(Rd->reply, "<h1><!--#echo var=\"grid\" --> account manager</h1>\n"); 4244 Rd->reply->addstrf(Rd->reply, "<h1><!--#echo var=\"grid\" --> account manager</h1>\n");
4232 if (NULL != name) 4245 if (NULL != Rd->shs.name)
4233 { 4246 {
4234 Rd->reply->addstrf(Rd->reply, "<h2><!--#echo var=\"grid\" --> account for %s</h2>\n", name); 4247 char *nm = qstrreplace("tr", xstrdup(Rd->shs.name), " ", "+");
4248
4249 Rd->reply->addstrf(Rd->reply, "<h3>You are <a href='https://%s%s?user=%s'>%s</a></h3>\n", Rd->Host, Rd->RUri, nm, Rd->shs.name);
4235 Rd->reply->addstr(Rd->reply, linky); 4250 Rd->reply->addstr(Rd->reply, linky);
4251 free(nm);
4236 } 4252 }
4237 free(linky); 4253 free(linky);
4254// if (NULL != name)
4255// Rd->reply->addstrf(Rd->reply, "<h2><!--#echo var=\"grid\" --> account for %s</h2>\n", name);
4238 if (0 != Rd->errors->size(Rd->messages)) 4256 if (0 != Rd->errors->size(Rd->messages))
4239 HTMLlist(Rd->reply, "messages -", Rd->messages); 4257 HTMLlist(Rd->reply, "messages -", Rd->messages);
4240 if (NULL != oF->help) 4258 if (NULL != oF->help)
@@ -4284,9 +4302,9 @@ static void accountWebFooter(reqData *Rd, inputForm *oF)
4284 4302
4285static void accountAddWeb(reqData *Rd, inputForm *oF, inputValue *oV) 4303static void accountAddWeb(reqData *Rd, inputForm *oF, inputValue *oV)
4286{ 4304{
4287 char *name = getStrH(Rd->stuff, "name"); 4305// char *name = getStrH(Rd->database, "Lua.name");
4288 4306
4289 accountWebHeaders(Rd, oF, name); 4307 accountWebHeaders(Rd, oF);
4290 accountWebFields(Rd, oF, oV); 4308 accountWebFields(Rd, oF, oV);
4291 accountWebSubs(Rd, oF); 4309 accountWebSubs(Rd, oF);
4292 accountWebFooter(Rd, oF); 4310 accountWebFooter(Rd, oF);
@@ -4294,10 +4312,9 @@ static void accountAddWeb(reqData *Rd, inputForm *oF, inputValue *oV)
4294 4312
4295static void accountLoginWeb(reqData *Rd, inputForm *oF, inputValue *oV) 4313static void accountLoginWeb(reqData *Rd, inputForm *oF, inputValue *oV)
4296{ 4314{
4297 char *name = getStrH(Rd->stuff, "name"); 4315 Rd->shs.name = NULL;
4298
4299 Rd->shs.UUID = NULL; 4316 Rd->shs.UUID = NULL;
4300 accountWebHeaders(Rd, oF, NULL); 4317 accountWebHeaders(Rd, oF);
4301 accountWebFields(Rd, oF, oV); 4318 accountWebFields(Rd, oF, oV);
4302 accountWebSubs(Rd, oF); 4319 accountWebSubs(Rd, oF);
4303 accountWebFooter(Rd, oF); 4320 accountWebFooter(Rd, oF);
@@ -4305,21 +4322,23 @@ static void accountLoginWeb(reqData *Rd, inputForm *oF, inputValue *oV)
4305 4322
4306static void accountViewWeb(reqData *Rd, inputForm *oF, inputValue *oV) 4323static void accountViewWeb(reqData *Rd, inputForm *oF, inputValue *oV)
4307{ 4324{
4308 char *name = getStrH(Rd->stuff, "name"), 4325 char *name = getStrH(Rd->database, "Lua.name"),
4309 *email = displayPrep(getStrH(Rd->stuff, "email")), 4326 *level = getStrH(Rd->database, "UserAccounts.UserLevel"),
4327 *email = displayPrep(getStrH(Rd->database, "UserAccounts.Email")),
4310 *voucher = displayPrep(getStrH(Rd->database, "Lua.voucher")), 4328 *voucher = displayPrep(getStrH(Rd->database, "Lua.voucher")),
4311 *about = displayPrep(getStrH(Rd->database, "Lua.aboutMe")); 4329 *about = displayPrep(getStrH(Rd->database, "Lua.aboutMe"));
4312 time_t crtd = atol(getStrH(Rd->database, "UserAccounts.Created")); 4330 time_t crtd = atol(getStrH(Rd->database, "UserAccounts.Created"));
4313 4331
4314 accountWebHeaders(Rd, oF, name); 4332 accountWebHeaders(Rd, oF);
4315 accountWebFields(Rd, oF, oV); 4333 accountWebFields(Rd, oF, oV);
4316// TODO - still need to encode < > as &lt; u&gt; for email, voucher, and about. 4334// TODO - still need to encode < > as &lt; u&gt; for email, voucher, and about.
4317// TODO - dammit, qurl_decode returns the string length, and decodes the string in place. 4335// TODO - dammit, qurl_decode returns the string length, and decodes the string in place.
4318 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); 4336 Rd->reply->addstrf(Rd->reply, "<p><font size='5'><span style='font-size: x-large'><b>Name :</b></span></font> %s</p>", name);
4337 Rd->reply->addstrf(Rd->reply, "<p><font size='5'><span style='font-size: x-large'><b>Title / level :</b></span></font> %s / %s</p>", getLevel(atoi(level)), level);
4319 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")); 4338 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"));
4320 Rd->reply->addstrf(Rd->reply, "<p><font size='5'><span style='font-size: x-large'><b>Created :</b></span></font> %s</p>", ctime(&crtd)); 4339 Rd->reply->addstrf(Rd->reply, "<p><font size='5'><span style='font-size: x-large'><b>Created :</b></span></font> %s</p>", ctime(&crtd));
4321 Rd->reply->addstrf(Rd->reply, "<p><font size='5'><span style='font-size: x-large'><b>Email :</b></span></font> %s</p>", email); 4340 Rd->reply->addstrf(Rd->reply, "<p><font size='5'><span style='font-size: x-large'><b>Email :</b></span></font> %s</p>", email);
4322 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); 4341 Rd->reply->addstrf(Rd->reply, "<p><font size='5'><span style='font-size: x-large'><b>UUID :</b></span></font> %s</p>", getStrH(Rd->database, "UserAccounts.PrincipalID"));
4323 Rd->reply->addstrf(Rd->reply, "<p><font size='5'><span style='font-size: x-large'><b>Voucher :</b></span></font> %s</p>", voucher); 4342 Rd->reply->addstrf(Rd->reply, "<p><font size='5'><span style='font-size: x-large'><b>Voucher :</b></span></font> %s</p>", voucher);
4324// Rd->reply->addstrf(Rd->reply, "<p><font size='5'><span style='font-size: x-large'><b>About :</b></span></font> </p>" 4343// Rd->reply->addstrf(Rd->reply, "<p><font size='5'><span style='font-size: x-large'><b>About :</b></span></font> </p>"
4325// "<textarea readonly >%s</textarea>", qurl_decode(getStrH(Rd->database, "Lua.aboutMe"))); 4344// "<textarea readonly >%s</textarea>", qurl_decode(getStrH(Rd->database, "Lua.aboutMe")));
@@ -4332,43 +4351,65 @@ static void accountViewWeb(reqData *Rd, inputForm *oF, inputValue *oV)
4332 4351
4333static void accountEditWeb(reqData *Rd, inputForm *oF, inputValue *oV) 4352static void accountEditWeb(reqData *Rd, inputForm *oF, inputValue *oV)
4334{ 4353{
4335 char *name = getStrH(Rd->stuff, "name"); 4354 char *name = getStrH(Rd->database, "Lua.name"),
4355 *level = getStrH(Rd->database, "UserAccounts.UserLevel"),
4356 *email = displayPrep(getStrH(Rd->database, "UserAccounts.Email")),
4357 *voucher = displayPrep(getStrH(Rd->database, "Lua.voucher")),
4358 *about = displayPrep(getStrH(Rd->database, "Lua.aboutMe")),
4359 *lvl = getLevel(atoi(level));
4336 4360
4337 accountWebHeaders(Rd, oF, name); 4361 accountWebHeaders(Rd, oF);
4338 accountWebFields(Rd, oF, oV); 4362 accountWebFields(Rd, oF, oV);
4339 HTMLtext(Rd->reply, "password", "Old password", "password", "", 16, 0, FALSE); 4363// HTMLtext(Rd->reply, "password", "Old password", "password", "", 16, 0, FALSE);
4340 Rd->reply->addstr(Rd->reply, "<p>Warning, the limit on password length is set by your viewer, some can't handle longer than 16 characters.</p>\n"); 4364// Rd->reply->addstr(Rd->reply, "<p>Warning, the limit on password length is set by your viewer, some can't handle longer than 16 characters.</p>\n");
4341//// HTMLtext(Rd->reply, "title", "text", "title", getStrH(Rh->stuff, "title"), 16, 64, TRUE); 4365//// HTMLtext(Rd->reply, "title", "text", "title", getStrH(Rh->stuff, "title"), 16, 64, TRUE);
4342 4366
4343 qlisttbl_obj_t obj; 4367 HTMLhidden(Rd->reply, "user", name);
4344 char *lvl = getLevel(Rd); 4368 Rd->reply->addstrf(Rd->reply, "<p><font size='5'><span style='font-size: x-large'><b>Name :</b></span></font> %s</p>", name);
4369 Rd->reply->addstrf(Rd->reply, "<p><font size='5'><span style='font-size: x-large'><b>Email :</b></span></font> %s</p>", email);
4370 Rd->reply->addstrf(Rd->reply, "<p><font size='5'><span style='font-size: x-large'><b>Voucher :</b></span></font> %s</p>", voucher);
4345 4371
4346 HTMLselect(Rd->reply, "level", "level"); 4372 if (200 <= Rd->shs.level)
4347 memset((void*)&obj, 0, sizeof(obj)); // must be cleared before call
4348 accountLevels->lock(accountLevels);
4349 while(accountLevels->getnext(accountLevels, &obj, NULL, false) == true)
4350 { 4373 {
4351 boolean is = false; 4374 qlisttbl_obj_t obj;
4352 4375
4353 if (strcmp(lvl, (char *) obj.data) == 0) 4376 HTMLselect(Rd->reply, "level", "level");
4354 is = true; 4377 memset((void*)&obj, 0, sizeof(obj)); // must be cleared before call
4355 HTMLoption(Rd->reply, (char *) obj.data, is); 4378 accountLevels->lock(accountLevels);
4379 while(accountLevels->getnext(accountLevels, &obj, NULL, false) == true)
4380 {
4381 boolean is = false;
4382
4383 if (strcmp(lvl, (char *) obj.data) == 0)
4384 is = true;
4385 HTMLoption(Rd->reply, (char *) obj.data, is);
4386 }
4387 accountLevels->unlock(accountLevels);
4388 HTMLselectEnd(Rd->reply);
4389
4390 Rd->reply->addstrf(Rd->reply, "<p><dl>");
4391 Rd->reply->addstrf(Rd->reply, "<dt>disabled</dt><dd>Account cannot log in anywhere.</dd>");
4392 Rd->reply->addstrf(Rd->reply, "<dt>newbie</dt><dd>Newly created account, not yet validated.</dd>");
4393 Rd->reply->addstrf(Rd->reply, "<dt>validated</dt><dd>Newly created account, they have clicked on the validation link in their validation email.</dd>");
4394 Rd->reply->addstrf(Rd->reply, "<dt>vouched for</dt><dd>Someone has vouched for this person.</dd>");
4395 Rd->reply->addstrf(Rd->reply, "<dt>approved</dt><dd>This person is approved, and can log into the world.</dd>");
4396 Rd->reply->addstrf(Rd->reply, "<dt>god</dt><dd>This is a god admin person.</dd>");
4397 Rd->reply->addstrf(Rd->reply, "</dl></p>");
4356 } 4398 }
4357 accountLevels->unlock(accountLevels); 4399 else
4358 HTMLselectEnd(Rd->reply); 4400 Rd->reply->addstrf(Rd->reply, "<p><font size='5'><span style='font-size: x-large'><b>Title / level :</b></span></font> %s / %s</p>", lvl, level);
4359 4401
4360 accountWebSubs(Rd, oF); 4402 accountWebSubs(Rd, oF);
4361 accountWebFooter(Rd, oF); 4403 accountWebFooter(Rd, oF);
4362} 4404}
4363 4405
4364 4406
4365static int accountRead(reqData *Rd, inputForm *iF, inputValue *iV) 4407static int accountRead(reqData *Rd, char *uuid, char *firstName, char *lastName)
4366{ 4408{
4367 int ret = 0, rt = -1; 4409 int ret = 0, rt = -1;
4368 struct stat st; 4410 struct stat st;
4369 struct timespec now; 4411 struct timespec now;
4370 qhashtbl_t *tnm = qhashtbl(0, 0); 4412 qhashtbl_t *tnm = qhashtbl(0, 0);
4371 char *uuid, *first, *last;
4372 uuid_t binuuid; 4413 uuid_t binuuid;
4373 rowData *rows = NULL; 4414 rowData *rows = NULL;
4374 4415
@@ -4413,7 +4454,33 @@ static int accountRead(reqData *Rd, inputForm *iF, inputValue *iV)
4413 dbRequests->addfirst(dbRequests, auth, sizeof(*auth)); 4454 dbRequests->addfirst(dbRequests, auth, sizeof(*auth));
4414 } 4455 }
4415 4456
4416 uuid = Rd->shs.UUID; first = getStrH(Rd->stuff, "firstName"); last = getStrH(Rd->stuff, "lastName"); 4457// uuid = Rd->shs.UUID; first = getStrH(Rd->stuff, "firstName"); last = getStrH(Rd->stuff, "lastName");
4458
4459 // Special for showing another users details.
4460 if ('\0' != getStrH(Rd->queries, "user")[0])
4461 uuid = "";
4462
4463 char *first = xstrdup(""), *last = xstrdup("");
4464
4465 if (NULL != firstName)
4466 {
4467 first = xstrdup(firstName);
4468 if (NULL == lastName)
4469 {
4470 char *t = strchr(first, ' ');
4471
4472d("accountRead() single name |%s| |%s|", first, last);
4473 if (NULL == t)
4474 t = strchr(first, '+');
4475 if (NULL != t)
4476 {
4477 *t++ = '\0';
4478 last = xstrdup(t);
4479 }
4480 }
4481 else
4482 last = xstrdup(lastName);
4483 }
4417d("accountRead() UUID %s, name %s %s", uuid, first, last); 4484d("accountRead() UUID %s, name %s %s", uuid, first, last);
4418 uuid_clear(binuuid); 4485 uuid_clear(binuuid);
4419 if ((NULL != uuid) && ('\0' != uuid[0])) 4486 if ((NULL != uuid) && ('\0' != uuid[0]))
@@ -4471,10 +4538,16 @@ d("accountRead() UUID %s, name %s %s", uuid, first, last);
4471 } 4538 }
4472 else if (rows) 4539 else if (rows)
4473 { 4540 {
4541
4474 ret += rows->rows->size(rows->rows); 4542 ret += rows->rows->size(rows->rows);
4475 if (1 == ret) 4543 if (1 == ret)
4476 { 4544 {
4477 dbPull(Rd, "UserAccounts", rows); 4545 dbPull(Rd, "UserAccounts", rows);
4546
4547 char *name = xmprintf("%s %s", getStrH(Rd->database, "UserAccounts.FirstName"), getStrH(Rd->database, "UserAccounts.LastName"));
4548
4549 Rd->database->putstr(Rd->database, "Lua.name", name);
4550 free(name);
4478 dbDoSomething(auth, FALSE, getStrH(Rd->database, "UserAccounts.PrincipalID")); 4551 dbDoSomething(auth, FALSE, getStrH(Rd->database, "UserAccounts.PrincipalID"));
4479 rows = auth->rows; 4552 rows = auth->rows;
4480 if (rows) 4553 if (rows)
@@ -4492,19 +4565,28 @@ d("accountRead() UUID %s, name %s %s", uuid, first, last);
4492 if (1 == ret) 4565 if (1 == ret)
4493 { 4566 {
4494// TODO - this has to change when we are editing other peoples accounts. 4567// TODO - this has to change when we are editing other peoples accounts.
4495 Rd->shs.UUID = Rd->database->getstr(Rd->database, "UserAccounts.PrincipalID", true); 4568 if ('\0' == getStrH(Rd->queries, "user")[0])
4496 Rd->stuff->putstr(Rd->stuff, "email", getStrH(Rd->database, "UserAccounts.Email")); 4569 {
4497 Rd->shs.level = atoi(getStrH(Rd->database, "UserAccounts.UserLevel")); 4570// Rd->shs.level = atoi(getStrH(Rd->database, "UserAccounts.UserLevel"));
4571// TODO - might have to combine first and last here.
4572// Rd->shs.name = Rd->database->getstr(Rd->database, "Lua.name", true);
4573// Rd->shs.UUID = Rd->database->getstr(Rd->database, "UserAccounts.PrincipalID", true);
4574//d("accountRead() setting session uuid %s level %d name %s ", Rd->shs.UUID, (int) Rd->shs.level, Rd->shs.name);
4575 }
4576// Rd->stuff->putstr(Rd->stuff, "email", getStrH(Rd->database, "UserAccounts.Email"));
4498 } 4577 }
4499 4578
4579 free(last);
4580 free(first);
4500 tnm->free(tnm); 4581 tnm->free(tnm);
4501 return ret; 4582 return ret;
4502} 4583}
4503 4584
4504static int accountDel(reqData *Rd, inputForm *iF, inputValue *iV) 4585static int accountDelSub(reqData *Rd, inputForm *iF, inputValue *iV)
4505{ 4586{
4506 int ret = 0; 4587 int ret = 0;
4507 int c = accountRead(Rd, iF, iV); 4588 char *uuid = Rd->shs.UUID, *first = getStrH(Rd->stuff, "firstName"), *last = getStrH(Rd->stuff, "lastName");
4589 int c = accountRead(Rd, uuid, first, last);
4508 4590
4509 if (1 != c) 4591 if (1 != c)
4510 { 4592 {
@@ -4519,10 +4601,12 @@ static int accountDel(reqData *Rd, inputForm *iF, inputValue *iV)
4519 } 4601 }
4520 return ret; 4602 return ret;
4521} 4603}
4522static int accountCreate(reqData *Rd, inputForm *iF, inputValue *iV) 4604
4605static int accountCreateSub(reqData *Rd, inputForm *iF, inputValue *iV)
4523{ 4606{
4524 int ret = 0; 4607 int ret = 0;
4525 int c = accountRead(Rd, iF, iV); 4608 char *uuid = Rd->shs.UUID, *first = getStrH(Rd->stuff, "firstName"), *last = getStrH(Rd->stuff, "lastName");
4609 int c = accountRead(Rd, uuid, first, last);
4526 boolean wipe = FALSE; 4610 boolean wipe = FALSE;
4527 4611
4528 if (strcmp("POST", Rd->Method) == 0) 4612 if (strcmp("POST", Rd->Method) == 0)
@@ -4558,10 +4642,12 @@ static int accountCreate(reqData *Rd, inputForm *iF, inputValue *iV)
4558 newSesh(Rd, FALSE); 4642 newSesh(Rd, FALSE);
4559 return ret; 4643 return ret;
4560} 4644}
4561static int accountAdd(reqData *Rd, inputForm *iF, inputValue *iV) 4645
4646static int accountAddSub(reqData *Rd, inputForm *iF, inputValue *iV)
4562{ 4647{
4563 int ret = 0; 4648 int ret = 0;
4564 int c = accountRead(Rd, iF, iV); 4649 char *uuid = Rd->shs.UUID, *first = getStrH(Rd->stuff, "firstName"), *last = getStrH(Rd->stuff, "lastName");
4650 int c = accountRead(Rd, uuid, first, last);
4565 boolean wipe = FALSE; 4651 boolean wipe = FALSE;
4566 4652
4567 if (0 != c) 4653 if (0 != c)
@@ -4587,11 +4673,12 @@ static int accountAdd(reqData *Rd, inputForm *iF, inputValue *iV)
4587 Rd->stuff->putstr(Rd->stuff, "passwordHash", getStrH(Rd->stuff, "passHash")); 4673 Rd->stuff->putstr(Rd->stuff, "passwordHash", getStrH(Rd->stuff, "passHash"));
4588 Rd->stuff->putstr(Rd->stuff, "passwordSalt", getStrH(Rd->stuff, "passSalt")); 4674 Rd->stuff->putstr(Rd->stuff, "passwordSalt", getStrH(Rd->stuff, "passSalt"));
4589 Rd->shs.level = -200; 4675 Rd->shs.level = -200;
4676 Rd->database->putstr(Rd->database, "UserAccounts.UserLevel", "-200");
4590 freeSesh(Rd, FALSE, wipe); 4677 freeSesh(Rd, FALSE, wipe);
4591 newSesh(Rd, TRUE); 4678 newSesh(Rd, TRUE);
4592 accountWrite(Rd); 4679 accountWrite(Rd);
4593// log them in 4680// log them in
4594 I("Logged on %s %s Level %d %s", Rd->shs.UUID, getStrH(Rd->stuff, "name"), Rd->shs.level, getLevel(Rd)); 4681 I("Logged on %s %s Level %d %s", Rd->shs.UUID, getStrH(Rd->stuff, "name"), Rd->shs.level, getLevel(Rd->shs.level));
4595 Rd->output = "accountView"; 4682 Rd->output = "accountView";
4596 Rd->form = "accountView"; 4683 Rd->form = "accountView";
4597 Rd->doit = "login"; 4684 Rd->doit = "login";
@@ -4603,10 +4690,11 @@ static int accountAdd(reqData *Rd, inputForm *iF, inputValue *iV)
4603 return ret; 4690 return ret;
4604} 4691}
4605 4692
4606static int accountSave(reqData *Rd, inputForm *iF, inputValue *iV) 4693static int accountSaveSub(reqData *Rd, inputForm *iF, inputValue *iV)
4607{ 4694{
4608 int ret = 0; 4695 int ret = 0;
4609 int c = accountRead(Rd, iF, iV); 4696 char *uuid = Rd->shs.UUID, *first = getStrH(Rd->body, "user"), *last = NULL;
4697 int c = accountRead(Rd, NULL, first, last);
4610 boolean wipe = FALSE; 4698 boolean wipe = FALSE;
4611 4699
4612 if (1 != c) 4700 if (1 != c)
@@ -4616,31 +4704,45 @@ static int accountSave(reqData *Rd, inputForm *iF, inputValue *iV)
4616 } 4704 }
4617 else if ((0 == ret) && (strcmp("POST", Rd->Method) == 0)) 4705 else if ((0 == ret) && (strcmp("POST", Rd->Method) == 0))
4618 { 4706 {
4619 char *h = checkSLOSpassword(Rd, getStrH(Rd->stuff, "passSalt"), getStrH(Rd->body, "password"), getStrH(Rd->stuff, "passHash"), "Passwords are not the same."); 4707 Rd->stuff->putstr(Rd->stuff, "email", getStrH(Rd->database, "UserAccounts.Email"));
4620 if (NULL == h) 4708 Rd->stuff->putstr(Rd->stuff, "created", getStrH(Rd->database, "UserAccounts.Created"));
4621 { 4709 Rd->stuff->putstr(Rd->stuff, "flags", getStrH(Rd->database, "UserAccounts.UserFlags"));
4622 ret++; 4710 Rd->stuff->putstr(Rd->stuff, "active", getStrH(Rd->database, "UserAccounts.active"));
4623 wipe = TRUE; 4711 Rd->stuff->putstr(Rd->stuff, "passwordSalt", getStrH(Rd->database, "auth.passwordSalt"));
4624 Rd->shs.UUID = NULL; 4712 Rd->stuff->putstr(Rd->stuff, "passwordHash", getStrH(Rd->database, "auth.passwordHash"));
4625 Rd->output = "accountLogin"; 4713 Rd->stuff->putstr(Rd->stuff, "name", getStrH(Rd->database, "Lua.name"));
4626 } 4714 Rd->stuff->putstr(Rd->stuff, "DoB", getStrH(Rd->database, "Lua.DoB"));
4627 else 4715 Rd->stuff->putstr(Rd->stuff, "agree", getStrH(Rd->database, "Lua.agree"));
4716 Rd->stuff->putstr(Rd->stuff, "adult", getStrH(Rd->database, "Lua.adult"));
4717 Rd->stuff->putstr(Rd->stuff, "aboutMe", getStrH(Rd->database, "Lua.aboutMe"));
4718 Rd->stuff->putstr(Rd->stuff, "vouched", getStrH(Rd->database, "Lua.vouched"));
4719 Rd->stuff->putstr(Rd->stuff, "voucher", getStrH(Rd->database, "Lua.voucher"));
4720
4721 char *lvl = getStrH(Rd->body, "level");
4722 qlisttbl_obj_t obj;
4723
4724 memset((void*)&obj, 0, sizeof(obj)); // must be cleared before call
4725 accountLevels->lock(accountLevels);
4726 while(accountLevels->getnext(accountLevels, &obj, NULL, false) == true)
4628 { 4727 {
4629 free(h); 4728 if (strcmp(lvl, (char *) obj.data) == 0)
4630 Rd->stuff->putstr(Rd->stuff, "passwordHash", getStrH(Rd->stuff, "passHash")); 4729 Rd->database->putstr(Rd->database, "UserAccounts.UserLevel", obj.name);
4631 Rd->stuff->putstr(Rd->stuff, "passwordSalt", getStrH(Rd->stuff, "passSalt"));
4632 accountWrite(Rd);
4633 } 4730 }
4731 accountLevels->unlock(accountLevels);
4732 accountWrite(Rd);
4733 free(Rd->outQuery);
4734 Rd->outQuery = xmprintf("?user=%s+%s", getStrH(Rd->database, "UserAccounts.FirstName"), getStrH(Rd->database, "UserAccounts.LastName"));
4634 } 4735 }
4635 freeSesh(Rd, FALSE, wipe); 4736// freeSesh(Rd, FALSE, wipe);
4636 newSesh(Rd, FALSE); 4737// newSesh(Rd, FALSE);
4637 return ret; 4738 return ret;
4638} 4739}
4639 4740
4640static int accountValidate(reqData *Rd, inputForm *iF, inputValue *iV) 4741static int accountValidateSub(reqData *Rd, inputForm *iF, inputValue *iV)
4641{ 4742{
4642 int ret = 0; 4743 int ret = 0;
4643 int c = accountRead(Rd, iF, iV); 4744 char *uuid = Rd->shs.UUID, *first = getStrH(Rd->stuff, "firstName"), *last = getStrH(Rd->stuff, "lastName");
4745 int c = accountRead(Rd, uuid, first, last);
4644 boolean wipe = FALSE; 4746 boolean wipe = FALSE;
4645 4747
4646 if (1 != c) 4748 if (1 != c)
@@ -4664,6 +4766,7 @@ static int accountValidate(reqData *Rd, inputForm *iF, inputValue *iV)
4664 Rd->stuff->putstr(Rd->stuff, "vouched", getStrH(Rd->database, "Lua.vouched")); 4766 Rd->stuff->putstr(Rd->stuff, "vouched", getStrH(Rd->database, "Lua.vouched"));
4665 Rd->stuff->putstr(Rd->stuff, "voucher", getStrH(Rd->database, "Lua.voucher")); 4767 Rd->stuff->putstr(Rd->stuff, "voucher", getStrH(Rd->database, "Lua.voucher"));
4666 Rd->shs.level = -100; 4768 Rd->shs.level = -100;
4769 Rd->database->putstr(Rd->database, "UserAccounts.UserLevel", "-100");
4667 accountWrite(Rd); 4770 accountWrite(Rd);
4668 wipe = TRUE; 4771 wipe = TRUE;
4669 } 4772 }
@@ -4672,15 +4775,15 @@ static int accountValidate(reqData *Rd, inputForm *iF, inputValue *iV)
4672 return ret; 4775 return ret;
4673} 4776}
4674 4777
4675 4778static int accountViewSub(reqData *Rd, inputForm *iF, inputValue *iV)
4676static int accountView(reqData *Rd, inputForm *iF, inputValue *iV)
4677{ 4779{
4678// TODO - this has to change when we are editing other peoples accounts. 4780// TODO - this has to change when we are editing other peoples accounts.
4679 int ret = 0; 4781 int ret = 0;
4680 int c = accountRead(Rd, iF, iV); 4782 char *uuid = Rd->shs.UUID, *first = getStrH(Rd->stuff, "firstName"), *last = getStrH(Rd->stuff, "lastName");
4783 int c = accountRead(Rd, uuid, first, last);
4681 boolean wipe = FALSE; 4784 boolean wipe = FALSE;
4682 4785
4683d("Sub accountView %s %s %s", getStrH(Rd->database, "UserAccounts.PrincipalID"), getStrH(Rd->database, "UserAccounts.FirstName"), getStrH(Rd->database, "UserAccounts.LastName")); 4786d("Sub accountViewSub() %s %s %s", uuid, first, last);
4684 if (1 != c) 4787 if (1 != c)
4685 { 4788 {
4686 bitch(Rd, "Cannot view account.", "Account doesn't exist."); 4789 bitch(Rd, "Cannot view account.", "Account doesn't exist.");
@@ -4693,7 +4796,7 @@ d("Sub accountView %s %s %s", getStrH(Rd->database, "UserAccounts.PrincipalID")
4693 { 4796 {
4694 // Check password on POST if the session user is the same as the shown user, coz this is the page shown on login. 4797 // Check password on POST if the session user is the same as the shown user, coz this is the page shown on login.
4695 // Also only check on login. 4798 // Also only check on login.
4696 if ((strcmp("POST", Rd->Method) == 0) && (strcmp(Rd->shs.UUID, getStrH(Rd->database, "UserAccounts.PrincipalID")) == 0) 4799 if ((strcmp("POST", Rd->Method) == 0) //&& (strcmp(Rd->shs.UUID, getStrH(Rd->database, "UserAccounts.PrincipalID")) == 0)
4697 && (strcmp("login", Rd->doit) == 0) && (strcmp("accountLogin", Rd->form) == 0)) 4800 && (strcmp("login", Rd->doit) == 0) && (strcmp("accountLogin", Rd->form) == 0))
4698 { 4801 {
4699 char *h = checkSLOSpassword(Rd, getStrH(Rd->database, "auth.passwordSalt"), getStrH(Rd->body, "password"), getStrH(Rd->database, "auth.passwordHash"), "Login failed."); 4802 char *h = checkSLOSpassword(Rd, getStrH(Rd->database, "auth.passwordSalt"), getStrH(Rd->body, "password"), getStrH(Rd->database, "auth.passwordHash"), "Login failed.");
@@ -4706,8 +4809,11 @@ d("Sub accountView %s %s %s", getStrH(Rd->database, "UserAccounts.PrincipalID")
4706 } 4809 }
4707 else 4810 else
4708 { 4811 {
4812 Rd->shs.level = atoi(getStrH(Rd->database, "UserAccounts.UserLevel"));
4813 Rd->shs.name = getStrH(Rd->database, "Lua.name");
4814 Rd->shs.UUID = getStrH(Rd->database, "UserAccounts.PrincipalID");
4709 free(h); 4815 free(h);
4710 I("Logged on %s %s Level %d %s", Rd->shs.UUID, getStrH(Rd->stuff, "name"), Rd->shs.level, getLevel(Rd)); 4816 I("Logged on %s %s Level %d %s", Rd->shs.UUID, Rd->shs.name, Rd->shs.level, getLevel(Rd->shs.level));
4711 } 4817 }
4712 } 4818 }
4713 } 4819 }
@@ -4716,12 +4822,13 @@ d("Sub accountView %s %s %s", getStrH(Rd->database, "UserAccounts.PrincipalID")
4716 4822
4717 return ret; 4823 return ret;
4718} 4824}
4719static int accountEdit(reqData *Rd, inputForm *iF, inputValue *iV) 4825static int accountEditSub(reqData *Rd, inputForm *iF, inputValue *iV)
4720{ 4826{
4721 int ret = 0; 4827 int ret = 0;
4722 int c = accountRead(Rd, iF, iV); 4828 char *uuid = Rd->shs.UUID, *first = getStrH(Rd->stuff, "firstName"), *last = getStrH(Rd->stuff, "lastName");
4829 int c = accountRead(Rd, uuid, first, last);
4723 4830
4724d("Sub accountView %s %s %s", getStrH(Rd->database, "UserAccounts.PrincipalID"), getStrH(Rd->database, "UserAccounts.FirstName"), getStrH(Rd->database, "UserAccounts.LastName")); 4831d("Sub accountEditSub %s %s %s", uuid, first, last);
4725 if (1 != c) 4832 if (1 != c)
4726 { 4833 {
4727 bitch(Rd, "Cannot edit account.", "Account doesn't exist."); 4834 bitch(Rd, "Cannot edit account.", "Account doesn't exist.");
@@ -4734,16 +4841,19 @@ d("Sub accountView %s %s %s", getStrH(Rd->database, "UserAccounts.PrincipalID")
4734 } 4841 }
4735 return ret; 4842 return ret;
4736} 4843}
4737static int accountExplore(reqData *Rd, inputForm *iF, inputValue *iV) 4844
4845static int accountExploreSub(reqData *Rd, inputForm *iF, inputValue *iV)
4738{ 4846{
4739 int ret = 0; 4847 int ret = 0;
4740// get a list of user records 4848// get a list of user records
4741 return ret; 4849 return ret;
4742} 4850}
4743static int accountOut(reqData *Rd, inputForm *iF, inputValue *iV) 4851
4852static int accountOutSub(reqData *Rd, inputForm *iF, inputValue *iV)
4744{ 4853{
4745 int ret = 0; 4854 int ret = 0;
4746 int c = accountRead(Rd, iF, iV); 4855 char *uuid = Rd->shs.UUID, *first = getStrH(Rd->stuff, "firstName"), *last = getStrH(Rd->stuff, "lastName");
4856 int c = accountRead(Rd, uuid, first, last);
4747 4857
4748 if (1 != c) 4858 if (1 != c)
4749 { 4859 {
@@ -4782,7 +4892,7 @@ static int accountFilterValidated(struct dirtree *node)
4782 char *where = xmprintf("%s/users/%s", scData, node->name); 4892 char *where = xmprintf("%s/users/%s", scData, node->name);
4783 int rt = LuaToHash(rdl->Rd, where, "user", tnm, 0, &st, &now, "user"); 4893 int rt = LuaToHash(rdl->Rd, where, "user", tnm, 0, &st, &now, "user");
4784 4894
4785//t("accountFilterValidatedVoucher %s (%s) -> %s -> %s", name, getStrH(tnm, "level"), getStrH(tnm, "name"), getStrH(tnm, "voucher")); 4895t("accountFilterValidatedVoucher %s (%s) -> %s -> %s", name, getStrH(tnm, "level"), getStrH(tnm, "name"), getStrH(tnm, "voucher"));
4786 if ((0 == rt) && (strcmp("-100", getStrH(tnm, "level")) == 0)) 4896 if ((0 == rt) && (strcmp("-100", getStrH(tnm, "level")) == 0))
4787 rdl->list->put(rdl->list, getStrH(tnm, "name"), tnm, sizeof(*tnm)); 4897 rdl->list->put(rdl->list, getStrH(tnm, "name"), tnm, sizeof(*tnm));
4788 else 4898 else
@@ -4808,10 +4918,10 @@ qlisttbl_t *getAccounts(reqData *Rd)
4808static void accountExploreValidatedVouchersWeb(reqData *Rd, inputForm *oF, inputValue *oV) 4918static void accountExploreValidatedVouchersWeb(reqData *Rd, inputForm *oF, inputValue *oV)
4809{ 4919{
4810 qlisttbl_t *list =getAccounts(Rd); 4920 qlisttbl_t *list =getAccounts(Rd);
4811 char *name = getStrH(Rd->stuff, "name"); 4921// char *name = getStrH(Rd->stuff, "name");
4812 4922
4813 Rd->shs.UUID = NULL; 4923 Rd->shs.UUID = NULL;
4814 accountWebHeaders(Rd, oF, name); 4924 accountWebHeaders(Rd, oF);
4815 accountWebFields(Rd, oF, oV); 4925 accountWebFields(Rd, oF, oV);
4816 4926
4817 count = list->size(list); 4927 count = list->size(list);
@@ -4829,9 +4939,9 @@ static void accountExploreValidatedVouchersWeb(reqData *Rd, inputForm *oF, input
4829 while(list->getnext(list, &obj, NULL, false) == true) 4939 while(list->getnext(list, &obj, NULL, false) == true)
4830 { 4940 {
4831 qhashtbl_t *tnm = (qhashtbl_t *) obj.data; 4941 qhashtbl_t *tnm = (qhashtbl_t *) obj.data;
4832 char *nm = qstrreplace("tr", xstrdup(obj.name), " ", "_"); 4942 char *nm = qstrreplace("tr", xstrdup(obj.name), " ", "+");
4833 4943
4834 Rd->reply->addstrf(Rd->reply, "<tr><td><a href='https://%s%s/users/%s'>%s</a></td>", Rd->Host, Rd->RUri, nm, obj.name); 4944 Rd->reply->addstrf(Rd->reply, "<tr><td><a href='https://%s%s?user=%s'>%s</a></td>", Rd->Host, Rd->RUri, nm, obj.name);
4835 Rd->reply->addstrf(Rd->reply, "<td>%s</td><td>%s</td><td>%s</td></tr>", getStrH(tnm, "voucher"), getStrH(tnm, "level"), getStrH(tnm, "title")); 4945 Rd->reply->addstrf(Rd->reply, "<td>%s</td><td>%s</td><td>%s</td></tr>", getStrH(tnm, "voucher"), getStrH(tnm, "level"), getStrH(tnm, "title"));
4836 free(nm); 4946 free(nm);
4837 tnm->clear(tnm); 4947 tnm->clear(tnm);
@@ -4846,7 +4956,7 @@ static void accountExploreValidatedVouchersWeb(reqData *Rd, inputForm *oF, input
4846 accountWebSubs(Rd, oF); 4956 accountWebSubs(Rd, oF);
4847 accountWebFooter(Rd, oF); 4957 accountWebFooter(Rd, oF);
4848} 4958}
4849static int accountExploreValidatedVoucher(reqData *Rd, inputForm *iF, inputValue *iV) 4959static int accountExploreValidatedVoucherSub(reqData *Rd, inputForm *iF, inputValue *iV)
4850{ 4960{
4851 int ret = 0; 4961 int ret = 0;
4852 return ret; 4962 return ret;
@@ -5180,8 +5290,8 @@ void account_html(char *file, reqData *Rd, HTMLfile *thisFile)
5180 inputFieldExtra(fld, FLD_EDITABLE, 42, 63); 5290 inputFieldExtra(fld, FLD_EDITABLE, 42, 63);
5181 fld = addInputField(iF, LUA_TSTRING, "aboutMe", "About me", NULL, aboutMeValidate, aboutMeWeb); 5291 fld = addInputField(iF, LUA_TSTRING, "aboutMe", "About me", NULL, aboutMeValidate, aboutMeWeb);
5182 inputFieldExtra(fld, FLD_EDITABLE, 50, 16384); 5292 inputFieldExtra(fld, FLD_EDITABLE, 50, 16384);
5183 addSubmit(iF, "confirm", "confirm", NULL, accountAdd, "accountView"); 5293 addSubmit(iF, "confirm", "confirm", NULL, accountAddSub, "accountView");
5184 addSubmit(iF, "cancel", "cancel", NULL, accountOut, "accountLogin"); 5294 addSubmit(iF, "cancel", "cancel", NULL, accountOutSub, "accountLogin");
5185 5295
5186 5296
5187 iF = newInputForm("accountView", "account view", NULL, accountViewWeb, accountLoginWeb); 5297 iF = newInputForm("accountView", "account view", NULL, accountViewWeb, accountLoginWeb);
@@ -5190,35 +5300,39 @@ void account_html(char *file, reqData *Rd, HTMLfile *thisFile)
5190// inputFieldExtra(fld, FLD_HIDDEN, 0, 0); 5300// inputFieldExtra(fld, FLD_HIDDEN, 0, 0);
5191 fld = addInputField(iF, LUA_TSTRING, "name", "name", NULL, nameValidate, nameWeb); 5301 fld = addInputField(iF, LUA_TSTRING, "name", "name", NULL, nameValidate, nameWeb);
5192 inputFieldExtra(fld, FLD_HIDDEN, 42, 63); 5302 inputFieldExtra(fld, FLD_HIDDEN, 42, 63);
5193 addSubmit(iF, "login", "", NULL, accountView, "accountView"); // Coz we sometimes want to trigger this from code. 5303 fld = addInputField(iF, LUA_TSTRING, "user", "user", NULL, nameValidate, nameWeb);
5194 addSubmit(iF, "validate", "", NULL, accountValidate, "accountLogin"); // Coz we sometimes want to trigger this from code. 5304 inputFieldExtra(fld, FLD_HIDDEN, 42, 63);
5195// addSubmit(iF, "edit", "edit", NULL, accountEdit, "accountEdit"); 5305 addSubmit(iF, "login", "", NULL, accountViewSub, "accountView"); // Coz we sometimes want to trigger this from code.
5196 addSubmit(iF, "validated_members", "validated members", NULL, accountExploreValidatedVoucher, "accountValidated"); 5306 addSubmit(iF, "validate", "", NULL, accountValidateSub, "accountLogin"); // Coz we sometimes want to trigger this from code.
5197 addSubmit(iF, "logout", "logout", NULL, accountOut, "accountLogin"); 5307 addSubmit(iF, "edit", "", NULL, accountEditSub, "accountEdit"); // Coz we sometimes want to trigger this from code.
5308 addSubmit(iF, "validated_members", "validated members", NULL, accountExploreValidatedVoucherSub, "accountValidated");
5309 addSubmit(iF, "logout", "logout", NULL, accountOutSub, "accountLogin");
5198 5310
5199 5311
5200 iF = newInputForm("accountValidated", "account validated list", NULL, accountExploreValidatedVouchersWeb, accountLoginWeb); 5312 iF = newInputForm("accountValidated", "account validated list", NULL, accountExploreValidatedVouchersWeb, accountLoginWeb);
5201 addSession(iF); 5313 addSession(iF);
5202 fld = addInputField(iF, LUA_TSTRING, "name", "name", NULL, nameValidate, nameWeb); 5314 fld = addInputField(iF, LUA_TSTRING, "name", "name", NULL, nameValidate, nameWeb);
5203 inputFieldExtra(fld, FLD_HIDDEN, 42, 63); 5315 inputFieldExtra(fld, FLD_HIDDEN, 42, 63);
5204 addSubmit(iF, "login", "", NULL, accountView, "accountView"); // Coz we sometimes want to trigger this from code. 5316 addSubmit(iF, "login", "", NULL, accountViewSub, "accountView"); // Coz we sometimes want to trigger this from code.
5205 addSubmit(iF, "back", "back", NULL, accountView, "accountView"); 5317 addSubmit(iF, "back", "back", NULL, accountViewSub, "accountView");
5206 5318
5207 5319
5208 iF = newInputForm("accountEdit", "account edit", NULL, accountEditWeb, accountLoginWeb); 5320 iF = newInputForm("accountEdit", "account edit", NULL, accountEditWeb, accountLoginWeb);
5209 addSession(iF); 5321 addSession(iF);
5210// fld = addInputField(iF, LUA_TSTRING, "UUID", "UUID", NULL, UUIDValidate, UUIDWeb); 5322// fld = addInputField(iF, LUA_TSTRING, "UUID", "UUID", NULL, UUIDValidate, UUIDWeb);
5211// inputFieldExtra(fld, FLD_HIDDEN, 0, 0); 5323// inputFieldExtra(fld, FLD_HIDDEN, 0, 0);
5212 fld = addInputField(iF, LUA_TSTRING, "name", "name", NULL, nameValidate, nameWeb); 5324// fld = addInputField(iF, LUA_TSTRING, "name", "name", NULL, nameValidate, nameWeb);
5213 inputFieldExtra(fld, FLD_HIDDEN, 42, 63); 5325// inputFieldExtra(fld, FLD_HIDDEN, 42, 63);
5214 fld = addInputField(iF, LUA_TEMAIL, "email", "email", "", emailValidate, emailWeb); 5326// fld = addInputField(iF, LUA_TSTRING, "user", "user", NULL, nameValidate, nameWeb);
5215 inputFieldExtra(fld, FLD_NONE, 42, 254); 5327// inputFieldExtra(fld, FLD_HIDDEN, 42, 63);
5216 addSubmit(iF, "login", "", NULL, accountView, "accountView"); // Coz we sometimes want to trigger this from code. 5328// fld = addInputField(iF, LUA_TEMAIL, "email", "email", "", emailValidate, emailWeb);
5217 addSubmit(iF, "save", "save", NULL, accountSave, "accountSave"); 5329// inputFieldExtra(fld, FLD_NONE, 42, 254);
5218 addSubmit(iF, "cancel", "cancel", NULL, accountOut, "accountView"); 5330 addSubmit(iF, "login", "", NULL, accountViewSub, "accountView"); // Coz we sometimes want to trigger this from code.
5219// addSubmit(iF, "members", "members", NULL, accountExplore, "accountExplore"); 5331 addSubmit(iF, "save", "save", NULL, accountSaveSub, "accountView");
5220 addSubmit(iF, "logout", "logout", NULL, accountOut, "accountLogin"); 5332 addSubmit(iF, "back", "back", NULL, accountViewSub, "accountView");
5221// addSubmit(iF, "delete", "delete", NULL, accountDel, "accountDel"); 5333// addSubmit(iF, "members", "members", NULL, accountExploreSub, "accountExplore");
5334 addSubmit(iF, "logout", "logout", NULL, accountOutSub, "accountLogin");
5335// addSubmit(iF, "delete", "delete", NULL, accountDelSub, "accountDel");
5222 5336
5223 5337
5224 iF = newInputForm("accountLogin", "account login", "Please login, or create your new account.", accountLoginWeb, accountLoginWeb); 5338 iF = newInputForm("accountLogin", "account login", "Please login, or create your new account.", accountLoginWeb, accountLoginWeb);
@@ -5228,10 +5342,10 @@ void account_html(char *file, reqData *Rd, HTMLfile *thisFile)
5228 fld = addInputField(iF, LUA_TPASSWORD, "password", "password", 5342 fld = addInputField(iF, LUA_TPASSWORD, "password", "password",
5229 "Warning, the limit on password length is set by your viewer, some can't handle longer than 16 characters.", passwordValidate, passwordWeb); 5343 "Warning, the limit on password length is set by your viewer, some can't handle longer than 16 characters.", passwordValidate, passwordWeb);
5230 inputFieldExtra(fld, FLD_EDITABLE | FLD_REQUIRED, 16, 0); 5344 inputFieldExtra(fld, FLD_EDITABLE | FLD_REQUIRED, 16, 0);
5231 addSubmit(iF, "logout", "", NULL, accountOut, "accountLogin"); // Coz we sometimes want to trigger this from code. 5345 addSubmit(iF, "logout", "", NULL, accountOutSub, "accountLogin"); // Coz we sometimes want to trigger this from code.
5232 addSubmit(iF, "validate", "", NULL, accountValidate, "accountLogin"); // Coz we sometimes want to trigger this from code. 5346 addSubmit(iF, "validate", "", NULL, accountValidateSub, "accountLogin"); // Coz we sometimes want to trigger this from code.
5233 addSubmit(iF, "login", "login", NULL, accountView, "accountView"); 5347 addSubmit(iF, "login", "login", NULL, accountViewSub, "accountView");
5234 addSubmit(iF, "create", "create account", NULL, accountCreate, "accountAdd"); 5348 addSubmit(iF, "create", "create account", NULL, accountCreateSub, "accountAdd");
5235 } 5349 }
5236 5350
5237 // Figure out what we are doing. 5351 // Figure out what we are doing.
@@ -5267,6 +5381,15 @@ void account_html(char *file, reqData *Rd, HTMLfile *thisFile)
5267 sub = iF->subs->get(iF->subs, doit, NULL, false); 5381 sub = iF->subs->get(iF->subs, doit, NULL, false);
5268 } 5382 }
5269 5383
5384 // Special for showing another users details.
5385 if ('\0' != getStrH(Rd->queries, "user")[0])
5386 {
5387 doit = "edit";
5388 form = "accountView";
5389 iF = accountPages->get(accountPages, form, NULL, false);
5390 sub = iF->subs->get(iF->subs, doit, NULL, false);
5391 }
5392
5270 Rd->doit = doit; 5393 Rd->doit = doit;
5271 Rd->form = form; 5394 Rd->form = form;
5272 Rd->output = sub->outputForm; 5395 Rd->output = sub->outputForm;
@@ -5378,13 +5501,13 @@ void account_html(char *file, reqData *Rd, HTMLfile *thisFile)
5378 if ('\0' != Rd->doit[0]) 5501 if ('\0' != Rd->doit[0])
5379 setCookie(Rd, "doit", Rd->doit); 5502 setCookie(Rd, "doit", Rd->doit);
5380 Rd->Rheaders->putstr (Rd->Rheaders, "Status", "303 See Other"); 5503 Rd->Rheaders->putstr (Rd->Rheaders, "Status", "303 See Other");
5381 Rd->Rheaders->putstrf(Rd->Rheaders, "Location", "https://%s%s", Rd->Host, Rd->RUri); 5504 Rd->Rheaders->putstrf(Rd->Rheaders, "Location", "https://%s%s%s", Rd->Host, Rd->RUri, Rd->outQuery);
5382 Rd->reply->addstrf(Rd->reply, "<html><title>Post POST redirect</title><head>" 5505 Rd->reply->addstrf(Rd->reply, "<html><title>Post POST redirect</title><head>"
5383 "<meta http-equiv='refresh' content='0; URL=https://%s%s' />" 5506 "<meta http-equiv='refresh' content='0; URL=https://%s%s%s' />"
5384 "</head><body>You should get redirected to <a href='https://%s%s'>https://%s%s</a></body></html>", 5507 "</head><body>You should get redirected to <a href='https://%s%s%s'>https://%s%s%s</a></body></html>",
5385 Rd->Host, Rd->RUri, Rd->Host, Rd->RUri, Rd->Host, Rd->RUri 5508 Rd->Host, Rd->RUri, Rd->outQuery, Rd->Host, Rd->RUri, Rd->outQuery, Rd->Host, Rd->RUri, Rd->outQuery
5386 ); 5509 );
5387 I("Redirecting dynamic page %s -> https://%s%s (%s)", file, Rd->Host, Rd->RUri, Rd->form); 5510 I("Redirecting dynamic page %s -> https://%s%s%s (%s)", file, Rd->Host, Rd->RUri, Rd->outQuery, Rd->form);
5388 } 5511 }
5389 } 5512 }
5390 } 5513 }
@@ -5403,6 +5526,8 @@ void account_html(char *file, reqData *Rd, HTMLfile *thisFile)
5403 free(iV); 5526 free(iV);
5404 } 5527 }
5405 5528
5529 free(Rd->outQuery);
5530
5406 C("Ending dynamic page %s %s", Rd->RUri, form); 5531 C("Ending dynamic page %s %s", Rd->RUri, form);
5407} 5532}
5408 5533
@@ -5878,6 +6003,7 @@ jit library is loaded or the JIT compiler will not be activated.
5878 Rd->errors = qlist(0); 6003 Rd->errors = qlist(0);
5879 Rd->messages = qlist(0); 6004 Rd->messages = qlist(0);
5880 Rd->reply = qgrow(QGROW_THREADSAFE); 6005 Rd->reply = qgrow(QGROW_THREADSAFE);
6006 Rd->outQuery = xstrdup("");
5881 qhashtbl_obj_t hobj; 6007 qhashtbl_obj_t hobj;
5882 qlist_obj_t lobj; 6008 qlist_obj_t lobj;
5883 6009