1
0
Fork 0
mirror of git://git.psyced.org/git/psyced synced 2024-08-15 03:25:10 +00:00

Merge remote-tracking branch 'fly/master'

This commit is contained in:
psyc://loupsycedyglgamf.onion/~lynX 1984-04-04 00:44:04 +00:00
commit 927074c26a
3 changed files with 76 additions and 3 deletions

66
place/rating.c Normal file
View file

@ -0,0 +1,66 @@
#include <net.h>
#include <text.h>
#include <ht/http.h>
#define NAME "rating"
#define PRIVATE
#define SECURE
#include <place.gen>
#define RATING_TITLE "This is a demonstration of psyced's rating tool"
#define RATING_ITEMS 3
#define RATING_ITEM_HEIGHT 100
#define DEFAULT_RATING_AMOUNT 5
#define RATING_UNIFORM_PREFIX "https://www.psyced.org/rating/"
// hack, should be using w() instead
#define htfs(BLA) write("<body bgcolor='black' text='white'><center>"+ BLA +"</center");
mapping rating = ([ ]);
htget(prot, query, headers, qs, data, noprocess) {
htnotify(query, headers, "_rating_test",
"[_nick_place] by [_web_on] from [_web_from] using '[_parameters]'.", 0, qs);
sTextPath(query["layout"], query["lang"], "html");
string j = query["juror"];
unless (j) {
hterror(prot, R_PAYMENTREQ, "Hello!? Who are you?");
return 1;
}
mapping previous = rating[lower_case(j)];
htok(prot);
if (query["c001"]) {
if (previous) {
htfs("Replaced old evaluation by new one. Thank you, "+j);
} else {
htfs("Evaluation stored. Thank you, "+j);
}
rating[lower_case(j)] = query;
log_file("RATING", "\n%O from %O using %O got %O\n",
ME, query_ip_name(), headers["user-agent"], query);
return 1;
}
w("_PAGES_start_group_rating", 0,
([ "_title_page" : htquote(RATING_TITLE),
// "_parameters" : query["parameters"] || qs,
"_uniform_logo" : HT_LOGO,
"_nick_juror" : j || query_ip_number(),
"_amount_height_item" : RATING_ITEM_HEIGHT,
"_nick_place" : MYNICK ]) );
// printf("%O vs %O\n", query, headers);
for (int i=1; i <= RATING_ITEMS; i++) {
string ii=sprintf("%03d", i);
w("_HTML_item_rating", 0, ([
"_index_item" : ii,
"_uniform_item" : RATING_UNIFORM_PREFIX +ii,
"_amount_rating_item" : previous? previous["r"+ii]: DEFAULT_RATING_AMOUNT,
"_comment_item" : previous? previous["c"+ii] || "": "",
"_nick_place" : MYNICK ]) );
}
w("_PAGES_end_group_rating", 0, ([
"_comment_notes" : previous? previous["notes"] || "": "",
"_nick_place" : MYNICK ]) );
return 1;
}

View file

@ -18,6 +18,9 @@
#include <status.h>
#include <uniform.h>
#ifndef DEFAULT_HT_LOGO
# define DEFAULT_HT_LOGO "/img/psyc.gif"
#endif
#ifndef HT_LOGO
# define HT_LOGO DEFAULT_HT_LOGO
#endif
@ -624,6 +627,7 @@ htget(prot, query, headers, qs) {
// maybe this all belongs into archetype.gen.. chesmo!
htget(prot, query, headers, qs, data, noprocess) {
PT(("%O place.gen::htget\n", ME))
if (probably_private(this_interactive()) <= PRIVACY_SURVEILLED) {
hterror(prot, R_PAYMENTREQ, "To protect against abuse in this nasty world this function needs 'https' instead of 'http'.");
htnotify(query, headers, "_challenge_disabled_encryption",
@ -651,12 +655,14 @@ htget(prot, query, headers, qs, data, noprocess) {
htnotify(query, headers, "_challenge_accomplished_web",
"Challenge accomplished in [_nick_place] by [_web_on] coming from [_web_from].");
# ifdef CHALLENGE_REDIRECT
sTextPath(query["layout"], query["lang"], "html");
# ifdef CHALLENGE_REDIRECT_TITLE
# ifdef CHALLENGE_QUESTION
htok3(prot, 0, "Set-Cookie: psycplace=\"challenge=done\"; Path="+ item +"; Secure; Max-Age=9\n");
# else
htok();
# endif
// you can output a player iframe instead of a redirect...
w("_PAGES_frame_redirect", 0,
([ "_uniform_page" : CHALLENGE_REDIRECT,
"_title_page" : CHALLENGE_REDIRECT_TITLE,
@ -667,7 +673,6 @@ htget(prot, query, headers, qs, data, noprocess) {
# endif
# else
# ifdef HTGET
// you may want to output a player iframe instead of a redirect...
return HTGET;
# else
return ::htget(prot, query, headers, qs, data, noprocess);
@ -723,7 +728,7 @@ htget(prot, query, headers, qs, data, noprocess) {
// url that allows other people to bypass the challenge.
htok3(prot, 0, "Set-Cookie: psycplace=\"challenge=given\"; Path="+ item +"; Secure; Max-Age=999\n");
# ifndef CHALLENGE_REDIRECT_TITLE
# define CHALLENGE_REDIRECT_TITLE "Challenge for " MYNICK
# define CHALLENGE_REDIRECT_TITLE "Challenge for "+ MYNICK
# endif
w("_PAGES_group_challenge", 0,
([ "_challenge" : htquote(CHALLENGE_QUESTION),

View file

@ -474,7 +474,7 @@ _request_set_topic(source, mc, data, vars, b) {
#if HAS_PORT(HTTP_PORT, HTTP_PATH) || HAS_PORT(HTTPS_PORT, HTTP_PATH)
// for GDPR compliance server owners are expected not to log these messages
htnotify(query, headers, mc, fmt, acct) {
htnotify(query, headers, mc, fmt, acct, qs) {
if (query["from"] == "") query["from"] = 0;
if (query["location"] == "") query["location"] = 0;
@ -490,6 +490,8 @@ htnotify(query, headers, mc, fmt, acct) {
query_ip_name(this_interactive()) ||
headers["user-agent"] || "http",
"_host_name" : query_ip_name(this_interactive()) || "",
// so far used by 'rating' only
"_parameters" : query["parameters"] || qs,
"_nick_place" : MYNICK || "This place",
]) );
}