mirror of
git://git.psyced.org/git/psyced
synced 2024-08-15 03:25:10 +00:00
things that happened in 2008
This commit is contained in:
parent
8f98522570
commit
94530cc322
136 changed files with 3222 additions and 2873 deletions
|
@ -1,47 +1,54 @@
|
|||
#include <ht/http.h>
|
||||
#include <net.h>
|
||||
#include <text.h>
|
||||
#include <ht/http.h>
|
||||
|
||||
protected mapping sessions = ([ ]);
|
||||
|
||||
string make_session(string nick, int expiry, string jack) {
|
||||
string sid;
|
||||
string sid;
|
||||
#ifndef TELEPHONY_EXPIRY
|
||||
# define TELEPHONY_EXPIRY expiry - time()
|
||||
#endif
|
||||
while (sessions[sid = RANDHEXSTRING]);
|
||||
sessions[sid] = ({ nick, expiry, jack });
|
||||
call_out( (: return m_delete(sessions, sid); :), TELEPHONY_EXPIRY);
|
||||
return sid;
|
||||
while (sessions[sid = RANDHEXSTRING]);
|
||||
sessions[sid] = ({ nick, expiry, jack });
|
||||
call_out( (: return m_delete(sessions, sid); :), TELEPHONY_EXPIRY);
|
||||
return sid;
|
||||
}
|
||||
|
||||
mixed answer(string sid, int yesno, int thatsme, string variant) {
|
||||
if (!(sid && sessions[sid])) {
|
||||
return -1; // no session found
|
||||
}
|
||||
if (sessions[sid][1] < time()) {
|
||||
return -2; // session expired
|
||||
}
|
||||
string ni = sessions[sid][0];
|
||||
unless (thatsme) {
|
||||
string mc;
|
||||
object uo = find_person(ni);
|
||||
|
||||
if (!uo) return -3;
|
||||
mc = yesno? "_notice_answer_call": "_notice_reject_call";
|
||||
if (variant) mc += variant;
|
||||
|
||||
if (!sendmsg(uo, mc, 0, ([
|
||||
"_time_expire" : to_string(sessions[sid][1]),
|
||||
"_check_call" : sessions[sid][2],
|
||||
"_token_call" : sid,
|
||||
]))) return -4; // sendmsg failed;
|
||||
}
|
||||
return ni;
|
||||
}
|
||||
|
||||
htget(prot, query, headers, qs) {
|
||||
#ifdef TELEPHONY_SERVER
|
||||
string sid = query["sid"];
|
||||
if (!(sid && sessions[sid])) {
|
||||
// no session found
|
||||
return;
|
||||
}
|
||||
if (sessions[sid][1] < time()) {
|
||||
// session expired
|
||||
return;
|
||||
}
|
||||
|
||||
string ni = sessions[sid][0];
|
||||
string t = query["thats"];
|
||||
mixed ni = answer(sid, !query["reject"], t, "_click");
|
||||
|
||||
unless (t) {
|
||||
object uo = find_person(ni);
|
||||
if (!uo || !sendmsg(uo, "_notice_answer_talk_click",
|
||||
"Your phone call request has been clicked upon.", ([
|
||||
"_time_expire" : to_string(sessions[sid][1]),
|
||||
"_check_call" : sessions[sid][2],
|
||||
"_session" : sid,
|
||||
]))) {
|
||||
hterror(prot, R_GATEWTIMEOUT,
|
||||
"User cannot be reached.");
|
||||
return 1;
|
||||
}
|
||||
if (intp(ni)) {
|
||||
hterror(prot, R_GATEWTIMEOUT, "User cannot be reached.");
|
||||
return 1;
|
||||
}
|
||||
htok3(prot, 0, "Expires: 0\n");
|
||||
localize(query["lang"], "html");
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
// $Id: configure.c,v 1.58 2007/06/17 21:07:54 lynx Exp $ // vim:syntax=lpc
|
||||
// $Id: configure.c,v 1.59 2008/04/22 22:43:56 lynx Exp $ // vim:syntax=lpc
|
||||
//
|
||||
// web configurator interface. does a lot of cool things for you,
|
||||
// and it should always learn to do some more. if you don't need or
|
||||
// like it, simply don't load it (from init.ls, or by fetching the url).
|
||||
//
|
||||
#include <ht/http.h>
|
||||
#include <net.h>
|
||||
#include <driver.h>
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
// this code contributed from symlynX webchat. currently not in use.
|
||||
|
||||
#include <ht/http.h>
|
||||
#include <net.h>
|
||||
#include <text.h>
|
||||
#include <person.h>
|
||||
#include <ht/http.h>
|
||||
#include <url.h>
|
||||
|
||||
#define NO_INHERIT
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <ht/http.h>
|
||||
#include <net.h>
|
||||
#include <text.h>
|
||||
#include <person.h>
|
||||
|
@ -16,11 +17,13 @@ htget(prot, query, headers, qs) {
|
|||
} else if ((t = query["cmd"]) && strlen(t)) {
|
||||
user->parsecmd(t); // htcmd?
|
||||
t = "_echo_execute_web";
|
||||
} else if (t = user->htDescription(prot, query, headers, qs, "")) {
|
||||
} else if (t = user->htDescription(0, query, headers, qs, "")) {
|
||||
P4(("result: %O\n", t))
|
||||
// this is the thing!!
|
||||
write(t);
|
||||
return 1;
|
||||
}
|
||||
// show error message
|
||||
localize(query["lang"], "html");
|
||||
w("_HTML_head");
|
||||
w(t || "_failure_unavailable_description");
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// $Id: fetch.c,v 1.39 2008/04/09 08:29:37 lynx Exp $ // vim:syntax=lpc
|
||||
// $Id: fetch.c,v 1.42 2008/12/10 22:53:33 lynx Exp $ // vim:syntax=lpc
|
||||
//
|
||||
// generic HTTP GET client, mostly used for RSS -
|
||||
// but we could fetch any page or data with it, really
|
||||
// tobij even made the object have the URL as its object name. fancy! ;)
|
||||
//
|
||||
#include <net.h>
|
||||
#include <ht/http.h>
|
||||
#include <net.h>
|
||||
#include <url.h>
|
||||
#include <services.h>
|
||||
|
||||
|
@ -104,6 +104,13 @@ varargs int real_logon(int arg) {
|
|||
}
|
||||
|
||||
varargs int logon(int arg, int sub) {
|
||||
// net/connect disables telnet for all robots and circuits
|
||||
#if 0 //__EFUN_DEFINED__(enable_telnet)
|
||||
// when fetching the spiegel rss feed, telnet_neg() occasionally
|
||||
// crashes. fixing that would be cool, but why have the telnet
|
||||
// machine enabled at all?
|
||||
enable_telnet(0);
|
||||
#endif
|
||||
// when called from xmlrpc.c we can't do TLS anyway
|
||||
if (sub) return ::logon(arg);
|
||||
if (ssl) tls_init_connection(ME, #'real_logon);
|
||||
|
@ -118,7 +125,11 @@ int parse_status(string all) {
|
|||
sscanf(all, "%s%t%s", prot, state);
|
||||
sscanf(state, "%d%t%s", http_status, http_message);
|
||||
P3(("%O got %O %O from %O\n", ME, http_status, http_message, host));
|
||||
// P2(("http_status %O == %O?\n", http_status, R_OK))
|
||||
if (http_status != R_OK) {
|
||||
monitor_report("_failure_unsupported_code_HTTP",
|
||||
S("http/fetch'ing %O returned %O %O", url || ME,
|
||||
http_status, http_message));
|
||||
}
|
||||
next_input_to(#'parse_header);
|
||||
return 1;
|
||||
}
|
||||
|
@ -168,9 +179,7 @@ disconnected(remainder) {
|
|||
}
|
||||
break;
|
||||
default:
|
||||
monitor_report("_error_unknown_method_HTTP",
|
||||
S("http/fetch'ing %O returned %O %O", url || ME,
|
||||
http_status, http_message));
|
||||
// doesn't seem to get here when HTTP returns 301 or 302. strange.
|
||||
// fall thru
|
||||
case R_NOTMODIFIED:
|
||||
qDel(ME);
|
||||
|
|
|
@ -1,24 +1,35 @@
|
|||
// vim:noexpandtab:syntax=lpc
|
||||
// $Id: header.i,v 1.5 2007/10/08 11:00:31 lynx Exp $
|
||||
// $Id: header.i,v 1.10 2008/08/05 12:21:33 lynx Exp $
|
||||
|
||||
#include <ht/http.h>
|
||||
|
||||
volatile int headerDone = 0;
|
||||
|
||||
http_ok(string prot, string type, string extra) {
|
||||
string h;
|
||||
string out;
|
||||
|
||||
// yes, this is compatible to pre-HTTP/1.0 browsers. sick, i know.
|
||||
if (!prot || headerDone++) return;
|
||||
|
||||
h = type || extra ? htheaders(type, extra) +"\n"
|
||||
out = type || extra ? htheaders(type, extra) +"\n"
|
||||
: "Content-type: " DEFAULT_CONTENT_TYPE "\n\n";
|
||||
emit(HTTP_SVERS " 200 Sure\n"+ h);
|
||||
emit(out = HTTP_SVERS " 200 Sure\n"+ out);
|
||||
P3((out))
|
||||
}
|
||||
|
||||
varargs http_error(string prot, int code, string comment, string html) {
|
||||
string out;
|
||||
|
||||
// apparently there isn't a single app that calls this with "html"
|
||||
P2(("hterror(%O,%O,%O,%O) in %O\n", prot,code,comment,html, ME))
|
||||
#if defined(GAMMA) && defined(T)
|
||||
// use the textdb if available
|
||||
out = psyctext( T("_PAGES_error",
|
||||
"<html><title id='code'>[_code]</title>\n"
|
||||
"<body><h1 id='comment'>[_comment]</h1></body></html>\n"),
|
||||
([ "_comment": comment, "_code": code ]) );
|
||||
#else
|
||||
// use some hardcoded defaults
|
||||
out = "<body text=white bgcolor=black link=green vlink=green>\n";
|
||||
if (html) out = sprintf("<title>%s</title>\n%s%s", comment, out, html);
|
||||
else out = sprintf("\
|
||||
|
@ -32,11 +43,12 @@ varargs http_error(string prot, int code, string comment, string html) {
|
|||
);
|
||||
// <a href=\"mailto:%s?subject=%s\">%s</a>\n
|
||||
//, WEBMASTER_EMAIL, comment, WEBMASTER_EMAIL
|
||||
|
||||
#endif
|
||||
// yes, this is compatible to pre-HTTP/1.0 browsers. sick, i know.
|
||||
if (!headerDone++ && prot) {
|
||||
// I used to output the comment, but Id have to cut out the
|
||||
// newline from the db
|
||||
emit(sprintf(HTTP_SVERS " 200 Actually %03d but MSIE steals my error page\n%s\n%s", code, htheaders(), out));
|
||||
emit(out = sprintf(HTTP_SVERS " 200 Actually %03d but MSIE steals my error page\n%s\n%s", code, htheaders(), out));
|
||||
P3((out))
|
||||
} else emit(out);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// vim:noexpandtab:syntax=lpc
|
||||
// $Id: library.i,v 1.38 2008/04/08 23:12:16 lynx Exp $
|
||||
// $Id: library.i,v 1.40 2008/04/27 08:20:47 lynx Exp $
|
||||
//
|
||||
// HTTP function library -lynx
|
||||
//
|
||||
|
@ -85,20 +85,21 @@ void htrequireauth(string prot, string type, string realm) {
|
|||
}
|
||||
}
|
||||
|
||||
varargs string htredirect(string prot, string target, string comment, int permanent) {
|
||||
varargs string htredirect(string prot, string target, string comment, int permanent, string extra) {
|
||||
if (!comment) comment = "Check this out";
|
||||
if (!target) target = "/";
|
||||
if (!extra) extra = "";
|
||||
|
||||
if (prot) {
|
||||
printf("%s %d %s\n%s", HTTP_SVERS,
|
||||
permanent ? R_MOVED : R_FOUND, comment, htheaders());
|
||||
}
|
||||
printf("\
|
||||
Location: %s\n\
|
||||
Location: %s\n%s\
|
||||
\n\
|
||||
<a href=\"%s\">%s</a>.\n\
|
||||
",
|
||||
target, target, comment);
|
||||
target, extra, target, comment);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <ht/http.h>
|
||||
#include <net.h>
|
||||
#include <text.h>
|
||||
#include <person.h>
|
||||
|
@ -15,7 +16,13 @@ htget(prot, query, headers, qs) {
|
|||
} else {
|
||||
PT(("replacing cookie %O\n", headers["cookie"]))
|
||||
htok3(prot, 0, "Set-Cookie: psyced=\""+ qs +"\";\n");
|
||||
#ifdef GAMMA
|
||||
// login was supposed to something more than just /surf
|
||||
// but until this is the case, why lose time?
|
||||
return NET_PATH "http/examine"->htget(0, query, headers, qs);
|
||||
#else
|
||||
t = "_PAGES_login";
|
||||
#endif
|
||||
}
|
||||
htok3(prot, 0, "Expires: 0\n");
|
||||
localize(query["lang"], "html");
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
// this code contributed from symlynX webchat. currently not in use.
|
||||
|
||||
#include <ht/http.h>
|
||||
#include <net.h>
|
||||
#include <text.h>
|
||||
#include <ht/html.h>
|
||||
#include <ht/http.h>
|
||||
#include <person.h>
|
||||
|
||||
volatile string nick;
|
||||
|
@ -18,22 +17,20 @@ htget(prot, query, headers, qs) {
|
|||
localize(query["lang"], "ht");
|
||||
|
||||
htok(prot);
|
||||
write (hthead("modifying "+nick+"'s settings") + htfs_on "<th>");
|
||||
write (hthead("modifying "+nick+"'s settings"));
|
||||
unless (nick) {
|
||||
write( T("_PAGES_register_nickless", "Who are you?")
|
||||
+ htfs_off);
|
||||
write( T("_PAGES_register_nickless", "Who are you?") );
|
||||
return 1;
|
||||
}
|
||||
unless (user = find_person(nick)) {
|
||||
write( T("_PAGES_register_offline",
|
||||
"You're not in the chat?<br>Please enter it.")
|
||||
+ T("_HTML_back", "") + htfs_off );
|
||||
+ T("_HTML_back", "") );
|
||||
return 1;
|
||||
}
|
||||
unless (user -> validToken(query["token"])) {
|
||||
write( T("_error_invalid_authentication_token",
|
||||
"Invalid token. Please log in anew.")
|
||||
+ htfs_off);
|
||||
"Invalid token. Please log in anew."));
|
||||
return 1;
|
||||
}
|
||||
okay = 1;
|
||||
|
@ -103,9 +100,9 @@ htget(prot, query, headers, qs) {
|
|||
#endif
|
||||
write( T("_PAGES_edit_stored",
|
||||
"Settings successfully stored.")
|
||||
+ T("_HTML_back", "") + htfs_off );
|
||||
+ T("_HTML_back", "") );
|
||||
} else
|
||||
write( T("_HTML_back", "") + htfs_off );
|
||||
write( T("_HTML_back", "") );
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,212 +1,213 @@
|
|||
// $Id: profile.c,v 1.2 2007/04/11 13:48:57 lynx Exp $ vim:syntax=lpc
|
||||
//
|
||||
// <kuchn> profile.c, a web based user settings/profile changer,
|
||||
// called from net/http/server.
|
||||
//
|
||||
// TODO: please make use of the new convert_profile(vars, 0, "set") and
|
||||
// convert_profile(settings, "set", 0) to convert a mapping of settings
|
||||
// into a mapping of PSYC variables and back. this should make a lot of
|
||||
// code in here unnecessary. avoiding replication is g00000d.
|
||||
//
|
||||
// i'm unhappy with the way of authing.. first i thought this could be
|
||||
// inherited somehow to be a part of the user object, but thats schmarn.
|
||||
// but i think psyc auth would be a nice way here..
|
||||
// using checkPassword() the way you do is fine! we are not planning
|
||||
// to use a web-based editor for remote PSYC items.. and the
|
||||
// asynchronicity of it isn't something HTTP can easily handle.
|
||||
// HTTP isn't as cool as PSYC you know? hahahahahahahahahahah
|
||||
|
||||
// as long as this is in development it could cause security breaches
|
||||
// in production servers. so please only use this on experimental servers.
|
||||
#ifdef EXPERIMENTAL
|
||||
|
||||
#include <net.h>
|
||||
#include <text.h>
|
||||
#include <person.h>
|
||||
|
||||
object user;
|
||||
|
||||
create() {
|
||||
sTextPath(0, 0, "html");
|
||||
}
|
||||
|
||||
htget(prot, query, headers, qs) {
|
||||
htok3(prot, "text/html", "Cache-Control: no-cache\n");
|
||||
w("_PAGES_user_header");
|
||||
|
||||
auth(prot, query, headers, qs);
|
||||
}
|
||||
|
||||
checkAuth(val, prot, query, headers, qs, user) {
|
||||
if(! val)
|
||||
{
|
||||
w("_PAGES_user_login_failed");
|
||||
return;
|
||||
}
|
||||
|
||||
w("_PAGES_user_header");
|
||||
|
||||
switch(query["action"]) {
|
||||
case "settings":
|
||||
if(query["set"] == "1")
|
||||
settings(prot, query, headers, qs, user);
|
||||
else
|
||||
w("_PAGES_user_settings_body", ([
|
||||
"_username" : query["username"],
|
||||
"_password" : query["password"],
|
||||
|
||||
"_speakaction" : user->v("speakaction") ? user->v("speakaction") : "",
|
||||
"_commandcharacter" : user->v("commandcharacter") ? user->v("commandcharacter") : ""
|
||||
]) );
|
||||
break;
|
||||
case "profile":
|
||||
if(query["set"] == "1")
|
||||
profile(prot, query, headers, qs, user);
|
||||
else
|
||||
w("_PAGES_user_profile_body", ([
|
||||
"_username" : query["username"],
|
||||
"_password" : query["password"],
|
||||
|
||||
"_me" : user->v("me") ? user->v("me") : "",
|
||||
"_publicpage" : user->v("publicpage") ? user->v("publicpage") : "",
|
||||
"_publictext" : user->v("publictext") ? user->v("publictext") : "",
|
||||
"_publicname" : user->v("publicname") ? user->v("publicname") : "",
|
||||
"_animalfave" : user->v("animalfave") ? user->v("animalfave") : "",
|
||||
"_popstarfave" : user->v("popstarfave") ? user->v("popstarfave") : "",
|
||||
"_musicfave" : user->v("musicfave") ? user->v("musicfave") : "",
|
||||
"_privatetext" : user->v("privatetext") ? user->v("privatetext") : "",
|
||||
"_likestext" : user->v("likestext") ? user->v("likestext") : "",
|
||||
"_dislikestext" : user->v("dislikestext") ? user->v("dislikestext") : "",
|
||||
"_privatepage" : user->v("privatepage") ? user->v("privatepage") : "",
|
||||
"_email" : user->v("email") ? user->v("email") : "",
|
||||
"_color" : user->v("color") ? user->v("color") : "",
|
||||
"_language" : user->v("language") ? user->v("language") : "",
|
||||
"_telephone" : user->v("telephone") ? user->v("telephone") : ""
|
||||
]) );
|
||||
break;
|
||||
default:
|
||||
w("_PAGES_user_index", ([ "_username" : query["username"], "_password" : query["password"] ]));
|
||||
break;
|
||||
}
|
||||
|
||||
w("_PAGES_user_footer");
|
||||
}
|
||||
|
||||
auth(prot, query, headers, qs) {
|
||||
if(! stringp(query["username"]) || ! stringp(query["password"]))
|
||||
{
|
||||
w("_PAGES_user_login_body");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(query["username"] == "" || query["password"] == "")
|
||||
{
|
||||
w("_PAGES_user_login_empty");
|
||||
return 0;
|
||||
}
|
||||
|
||||
user = summon_person(query["username"]);
|
||||
if(!user || user->isNewbie())
|
||||
{
|
||||
w("_PAGES_user_login_notregistered");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ok = 1;
|
||||
user->checkPassword(query["password"], "plain", "", "", #'checkAuth, prot, query, headers, qs, user);
|
||||
}
|
||||
|
||||
settings(prot, query, headers, qs, user) {
|
||||
foreach(string k, string v : query) {
|
||||
int ok = 0;
|
||||
|
||||
switch(k) {
|
||||
case "password":
|
||||
ok = 1;
|
||||
break;
|
||||
case "speakaction":
|
||||
ok = 1;
|
||||
break;
|
||||
case "commandcharacter":
|
||||
ok = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if(! ok)
|
||||
continue;
|
||||
|
||||
if(v == "")
|
||||
{
|
||||
//if(v != "password")
|
||||
// user->vDel(k);
|
||||
// do nothing? maybe every setting is needed.. then this would be bad.
|
||||
}
|
||||
else
|
||||
user->vSet(k, v); // password won't be set? humm.
|
||||
}
|
||||
|
||||
w("_PAGES_user_settings_changed", ([ "_username" : query["username"], "_password" : query["password"] ]) );
|
||||
}
|
||||
|
||||
profile(prot, query, headers, qs, user) {
|
||||
foreach(string k, string v : query) {
|
||||
int ok = 0;
|
||||
|
||||
switch(k)
|
||||
{
|
||||
case "me":
|
||||
ok = 1;
|
||||
break;
|
||||
case "publicpage":
|
||||
ok = 1;
|
||||
break;
|
||||
case "publictext":
|
||||
ok = 1;
|
||||
break;
|
||||
case "publicname":
|
||||
ok = 1;
|
||||
break;
|
||||
case "animalfave":
|
||||
ok = 1;
|
||||
break;
|
||||
case "popstarfave":
|
||||
ok = 1;
|
||||
break;
|
||||
case "musicfave":
|
||||
ok = 1;
|
||||
break;
|
||||
case "privatetext":
|
||||
ok = 1;
|
||||
break;
|
||||
case "likestext":
|
||||
ok = 1;
|
||||
break;
|
||||
case "dislikestext":
|
||||
ok = 1;
|
||||
break;
|
||||
case "privatepage":
|
||||
ok = 1;
|
||||
break;
|
||||
case "email":
|
||||
ok = 1;
|
||||
break;
|
||||
case "telephone":
|
||||
ok = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if(! ok)
|
||||
continue;
|
||||
|
||||
if(v == "")
|
||||
user->vDel(k);
|
||||
else
|
||||
user->vSet(k, v);
|
||||
}
|
||||
|
||||
w("_PAGES_user_profile_changed", ([ "_username" : query["username"], "_password" : query["password"] ]) );
|
||||
}
|
||||
|
||||
w(mc, vars) { write(psyctext(T(mc, ""), vars)); }
|
||||
|
||||
#endif
|
||||
// $Id: profile.c,v 1.3 2008/04/22 22:43:14 lynx Exp $ vim:syntax=lpc
|
||||
//
|
||||
// <kuchn> profile.c, a web based user settings/profile changer,
|
||||
// called from net/http/server.
|
||||
//
|
||||
// TODO: please make use of the new convert_profile(vars, 0, "set") and
|
||||
// convert_profile(settings, "set", 0) to convert a mapping of settings
|
||||
// into a mapping of PSYC variables and back. this should make a lot of
|
||||
// code in here unnecessary. avoiding replication is g00000d.
|
||||
//
|
||||
// i'm unhappy with the way of authing.. first i thought this could be
|
||||
// inherited somehow to be a part of the user object, but thats schmarn.
|
||||
// but i think psyc auth would be a nice way here..
|
||||
// using checkPassword() the way you do is fine! we are not planning
|
||||
// to use a web-based editor for remote PSYC items.. and the
|
||||
// asynchronicity of it isn't something HTTP can easily handle.
|
||||
// HTTP isn't as cool as PSYC you know? hahahahahahahahahahah
|
||||
|
||||
// as long as this is in development it could cause security breaches
|
||||
// in production servers. so please only use this on experimental servers.
|
||||
#ifdef EXPERIMENTAL
|
||||
|
||||
#include <ht/http.h>
|
||||
#include <net.h>
|
||||
#include <text.h>
|
||||
#include <person.h>
|
||||
|
||||
object user;
|
||||
|
||||
create() {
|
||||
sTextPath(0, 0, "html");
|
||||
}
|
||||
|
||||
htget(prot, query, headers, qs) {
|
||||
htok3(prot, "text/html", "Cache-Control: no-cache\n");
|
||||
w("_PAGES_user_header");
|
||||
|
||||
auth(prot, query, headers, qs);
|
||||
}
|
||||
|
||||
checkAuth(val, prot, query, headers, qs, user) {
|
||||
if(! val)
|
||||
{
|
||||
w("_PAGES_user_login_failed");
|
||||
return;
|
||||
}
|
||||
|
||||
w("_PAGES_user_header");
|
||||
|
||||
switch(query["action"]) {
|
||||
case "settings":
|
||||
if(query["set"] == "1")
|
||||
settings(prot, query, headers, qs, user);
|
||||
else
|
||||
w("_PAGES_user_settings_body", ([
|
||||
"_username" : query["username"],
|
||||
"_password" : query["password"],
|
||||
|
||||
"_speakaction" : user->v("speakaction") ? user->v("speakaction") : "",
|
||||
"_commandcharacter" : user->v("commandcharacter") ? user->v("commandcharacter") : ""
|
||||
]) );
|
||||
break;
|
||||
case "profile":
|
||||
if(query["set"] == "1")
|
||||
profile(prot, query, headers, qs, user);
|
||||
else
|
||||
w("_PAGES_user_profile_body", ([
|
||||
"_username" : query["username"],
|
||||
"_password" : query["password"],
|
||||
|
||||
"_me" : user->v("me") ? user->v("me") : "",
|
||||
"_publicpage" : user->v("publicpage") ? user->v("publicpage") : "",
|
||||
"_publictext" : user->v("publictext") ? user->v("publictext") : "",
|
||||
"_publicname" : user->v("publicname") ? user->v("publicname") : "",
|
||||
"_animalfave" : user->v("animalfave") ? user->v("animalfave") : "",
|
||||
"_popstarfave" : user->v("popstarfave") ? user->v("popstarfave") : "",
|
||||
"_musicfave" : user->v("musicfave") ? user->v("musicfave") : "",
|
||||
"_privatetext" : user->v("privatetext") ? user->v("privatetext") : "",
|
||||
"_likestext" : user->v("likestext") ? user->v("likestext") : "",
|
||||
"_dislikestext" : user->v("dislikestext") ? user->v("dislikestext") : "",
|
||||
"_privatepage" : user->v("privatepage") ? user->v("privatepage") : "",
|
||||
"_email" : user->v("email") ? user->v("email") : "",
|
||||
"_color" : user->v("color") ? user->v("color") : "",
|
||||
"_language" : user->v("language") ? user->v("language") : "",
|
||||
"_telephone" : user->v("telephone") ? user->v("telephone") : ""
|
||||
]) );
|
||||
break;
|
||||
default:
|
||||
w("_PAGES_user_index", ([ "_username" : query["username"], "_password" : query["password"] ]));
|
||||
break;
|
||||
}
|
||||
|
||||
w("_PAGES_user_footer");
|
||||
}
|
||||
|
||||
auth(prot, query, headers, qs) {
|
||||
if(! stringp(query["username"]) || ! stringp(query["password"]))
|
||||
{
|
||||
w("_PAGES_user_login_body");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(query["username"] == "" || query["password"] == "")
|
||||
{
|
||||
w("_PAGES_user_login_empty");
|
||||
return 0;
|
||||
}
|
||||
|
||||
user = summon_person(query["username"]);
|
||||
if(!user || user->isNewbie())
|
||||
{
|
||||
w("_PAGES_user_login_notregistered");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ok = 1;
|
||||
user->checkPassword(query["password"], "plain", "", "", #'checkAuth, prot, query, headers, qs, user);
|
||||
}
|
||||
|
||||
settings(prot, query, headers, qs, user) {
|
||||
foreach(string k, string v : query) {
|
||||
int ok = 0;
|
||||
|
||||
switch(k) {
|
||||
case "password":
|
||||
ok = 1;
|
||||
break;
|
||||
case "speakaction":
|
||||
ok = 1;
|
||||
break;
|
||||
case "commandcharacter":
|
||||
ok = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if(! ok)
|
||||
continue;
|
||||
|
||||
if(v == "")
|
||||
{
|
||||
//if(v != "password")
|
||||
// user->vDel(k);
|
||||
// do nothing? maybe every setting is needed.. then this would be bad.
|
||||
}
|
||||
else
|
||||
user->vSet(k, v); // password won't be set? humm.
|
||||
}
|
||||
|
||||
w("_PAGES_user_settings_changed", ([ "_username" : query["username"], "_password" : query["password"] ]) );
|
||||
}
|
||||
|
||||
profile(prot, query, headers, qs, user) {
|
||||
foreach(string k, string v : query) {
|
||||
int ok = 0;
|
||||
|
||||
switch(k)
|
||||
{
|
||||
case "me":
|
||||
ok = 1;
|
||||
break;
|
||||
case "publicpage":
|
||||
ok = 1;
|
||||
break;
|
||||
case "publictext":
|
||||
ok = 1;
|
||||
break;
|
||||
case "publicname":
|
||||
ok = 1;
|
||||
break;
|
||||
case "animalfave":
|
||||
ok = 1;
|
||||
break;
|
||||
case "popstarfave":
|
||||
ok = 1;
|
||||
break;
|
||||
case "musicfave":
|
||||
ok = 1;
|
||||
break;
|
||||
case "privatetext":
|
||||
ok = 1;
|
||||
break;
|
||||
case "likestext":
|
||||
ok = 1;
|
||||
break;
|
||||
case "dislikestext":
|
||||
ok = 1;
|
||||
break;
|
||||
case "privatepage":
|
||||
ok = 1;
|
||||
break;
|
||||
case "email":
|
||||
ok = 1;
|
||||
break;
|
||||
case "telephone":
|
||||
ok = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if(! ok)
|
||||
continue;
|
||||
|
||||
if(v == "")
|
||||
user->vDel(k);
|
||||
else
|
||||
user->vSet(k, v);
|
||||
}
|
||||
|
||||
w("_PAGES_user_profile_changed", ([ "_username" : query["username"], "_password" : query["password"] ]) );
|
||||
}
|
||||
|
||||
w(mc, vars) { write(psyctext(T(mc, ""), vars)); }
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// this code contributed from symlynX webchat. currently not in use.
|
||||
|
||||
#include <ht/http.h>
|
||||
#include <net.h>
|
||||
#include <text.h>
|
||||
#include <person.h>
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
// $Id: server.c,v 1.58 2008/03/11 13:42:25 lynx Exp $ // vim:syntax=lpc
|
||||
// $Id: server.c,v 1.64 2008/05/13 09:51:07 lynx Exp $ // vim:syntax=lpc
|
||||
//
|
||||
// yes, psyced is also a web server, like every decent piece of code. ;)
|
||||
//
|
||||
#include <ht/http.h>
|
||||
#include <net.h>
|
||||
#include <server.h>
|
||||
#include <text.h>
|
||||
|
@ -20,7 +21,7 @@ parse_url(input);
|
|||
parse_header(input);
|
||||
devNull();
|
||||
|
||||
qScheme() { return "none"; }
|
||||
qScheme() { return "html"; }
|
||||
|
||||
logon() {
|
||||
D2(D("»»» New SmallHTTP user\n");)
|
||||
|
@ -122,6 +123,7 @@ process() {
|
|||
int done = 1;
|
||||
|
||||
// take defaults from cookie, then override by query string
|
||||
// lynXism cookie behaviour, normal one is below
|
||||
t = headers["cookie"];
|
||||
P4(("found cookie: %O\n", t))
|
||||
if (t && sscanf(t, "psyced=\"%s\"", t)) {
|
||||
|
@ -129,6 +131,24 @@ process() {
|
|||
query = parse_query(query, t);
|
||||
P4(("parsed cookie: %O\n", query))
|
||||
}
|
||||
#ifdef GENERIC_COOKIES // we might need them someday..?
|
||||
// if within the same domain other cookies are being used, like
|
||||
// by including google-analytics, then we might be receiving them
|
||||
// here and have no friggin' idea what they are good for.
|
||||
// thus: we *need* a way to ensure a cookie is our own.
|
||||
// FIXME: this is not really compliant
|
||||
else if (t) {
|
||||
mapping cook = ([ ]);
|
||||
string k, v;
|
||||
while(t && sscanf(t, "%s=%s;%t%s", k, v, t) >= 2) {
|
||||
cook[k] = v;
|
||||
}
|
||||
if (sscanf(t, "%s=%s", k, v))
|
||||
cook[lower_case(k)] = v; // case insensitive
|
||||
cook[0] = headers["cookie"]; // save cookie-string
|
||||
headers["cookie"] = cook;
|
||||
}
|
||||
#endif
|
||||
if (sscanf(url, "%s?%s", file, qs)) {
|
||||
P3(("got query: %O\n", qs))
|
||||
query = parse_query(query, qs);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// i'm unhappy with the way of authing.. first i thought this could be inheriated somehow to be a part of the user object, but thats schmarn.
|
||||
// but i think psyc auth would be a nice way here..
|
||||
//
|
||||
|
||||
#include <ht/http.h>
|
||||
#include <net.h>
|
||||
#include <text.h>
|
||||
#include <person.h>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// $Id: xmlrpc.c,v 1.23 2008/03/11 13:42:26 lynx Exp $ // vim:syntax=lpc
|
||||
// $Id: xmlrpc.c,v 1.24 2008/04/22 22:43:14 lynx Exp $ // vim:syntax=lpc
|
||||
//
|
||||
// TODO: shares to much code with url fetcher
|
||||
// in the ideal world this would only contain marshal/unmarshal code
|
||||
|
@ -6,8 +6,8 @@
|
|||
// possibly we can come up with an marshal/unmarshal api and use
|
||||
// the same framework for xml-rpc, soap and other things
|
||||
//
|
||||
#include <net.h>
|
||||
#include <ht/http.h>
|
||||
#include <net.h>
|
||||
#include <url.h>
|
||||
#include <xml.h>
|
||||
|
||||
|
@ -95,7 +95,7 @@ void request(string method, mixed params, closure cb) { // TODO: errback API
|
|||
|
||||
int logon(int arg) {
|
||||
buffer = "";
|
||||
httpheaders = ([ ]);
|
||||
headers = ([ ]);
|
||||
http_status = 500;
|
||||
|
||||
// this is all not https: compatible..
|
||||
|
@ -189,18 +189,18 @@ mixed unMarshal(XMLNode parsed) {
|
|||
}
|
||||
}
|
||||
|
||||
void disconnected(remainder) {
|
||||
int disconnected(string remainder) {
|
||||
mixed *args;
|
||||
|
||||
httpheaders["_fetchtime"] = isotime(ctime(time()), 1);
|
||||
if (httpheaders["last-modified"])
|
||||
modificationtime = httpheaders["last-modified"];
|
||||
if (httpheaders["etag"])
|
||||
etag = httpheaders["etag"]; // heise does not work with etag
|
||||
headers["_fetchtime"] = isotime(ctime(time()), 1);
|
||||
if (headers["last-modified"])
|
||||
modificationtime = headers["last-modified"];
|
||||
if (headers["etag"])
|
||||
etag = headers["etag"]; // heise does not work with etag
|
||||
|
||||
fetched = buffer;
|
||||
fheaders = httpheaders;
|
||||
buffer = httpheaders = 0;
|
||||
fheaders = headers;
|
||||
buffer = headers = 0;
|
||||
fetching = 0;
|
||||
if (pointerp(args)) // no fault
|
||||
funcall(callback, args...);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue