mirror of
git://git.psyced.org/git/psyced
synced 2024-08-15 03:25:10 +00:00
let the past begone in cvs land. welcome to igit igit!
This commit is contained in:
commit
4e601cf1c7
509 changed files with 77963 additions and 0 deletions
67
world/net/wap/common.c
Normal file
67
world/net/wap/common.c
Normal file
|
@ -0,0 +1,67 @@
|
|||
// $Id: common.c,v 1.2 2006/09/29 08:51:40 lynx Exp $ // vim:syntax=lpc
|
||||
//
|
||||
// WAP library
|
||||
//
|
||||
#include <sys/time.h>
|
||||
#include <net.h>
|
||||
#include <text.h>
|
||||
#include <person.h>
|
||||
#include "wap.h"
|
||||
|
||||
volatile object user;
|
||||
|
||||
volatile string username;
|
||||
volatile string password;
|
||||
|
||||
htget(prot, query, headers, qs) {
|
||||
username = query["u"];
|
||||
password = query["p"];
|
||||
|
||||
if (username && password) {
|
||||
checkPassword(username, password);
|
||||
} else {
|
||||
queryLogin();
|
||||
}
|
||||
}
|
||||
|
||||
printMsg(msg) {
|
||||
HTOK;
|
||||
HEADER_WML("info");
|
||||
NAV_WML;
|
||||
|
||||
write(msg);
|
||||
|
||||
FOOTER_WML;
|
||||
}
|
||||
|
||||
authChecked(val) {
|
||||
unless (val) {
|
||||
HTOK;
|
||||
HEADER_WML("login");
|
||||
write("Login failed.<br />");
|
||||
LOGIN_WML;
|
||||
FOOTER_WML;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
queryLogin() {
|
||||
HTOK;
|
||||
HEADER_WML("login");
|
||||
LOGIN_WML;
|
||||
FOOTER_WML;
|
||||
return;
|
||||
}
|
||||
|
||||
checkPassword(username, pass) {
|
||||
user = summon_person(username);
|
||||
|
||||
if(!user || user->isNewbie()) {
|
||||
queryLogin();
|
||||
return;
|
||||
}
|
||||
|
||||
user->checkPassword(pass, "plain", "", "", #'authChecked);
|
||||
}
|
54
world/net/wap/inbox.c
Normal file
54
world/net/wap/inbox.c
Normal file
|
@ -0,0 +1,54 @@
|
|||
// $Id: inbox.c,v 1.4 2007/07/12 06:08:29 lynx Exp $ // vim:syntax=lpc
|
||||
//
|
||||
// WAP account management
|
||||
//
|
||||
#include <sys/time.h>
|
||||
#include <net.h>
|
||||
#include <text.h>
|
||||
#include <person.h>
|
||||
#include "wap.h"
|
||||
|
||||
inherit NET_PATH "lastlog";
|
||||
inherit WAP_PATH "common";
|
||||
|
||||
volatile string inbox_buffer;
|
||||
|
||||
showInbox() {
|
||||
int count;
|
||||
array(mixed) log = user->logQuery();
|
||||
|
||||
HTOK;
|
||||
HEADER_WML("inbox");
|
||||
NAV_WML;
|
||||
|
||||
if (user->vQuery("new")) {
|
||||
logInit(copy(log));
|
||||
inbox_buffer = "";
|
||||
|
||||
count = logView(user->vQuery("new"), 1);
|
||||
|
||||
write(inbox_buffer);
|
||||
}
|
||||
|
||||
unless (count) {
|
||||
write("No new messages.");
|
||||
}
|
||||
|
||||
FOOTER_WML;
|
||||
}
|
||||
|
||||
msgView(source, mc, data, vars, showingLog) {
|
||||
array(int) t = localtime(vars["_time_INTERNAL"]);
|
||||
|
||||
// we want the newest message on top.. buffering output
|
||||
inbox_buffer = sprintf(" - %d:%d, %d.%d.%d<br/>%s<br/><br/>",
|
||||
t[TM_HOUR], t[TM_MIN], t[TM_MDAY], t[TM_MON], t[TM_YEAR], data) + inbox_buffer;
|
||||
// make person's nick clickable
|
||||
inbox_buffer = SEND_PERSON(vars["_nick_verbatim"] || vars["_nick"]) + inbox_buffer;
|
||||
}
|
||||
|
||||
authChecked(val) {
|
||||
if (::authChecked(val)) {
|
||||
showInbox();
|
||||
}
|
||||
}
|
22
world/net/wap/index.c
Normal file
22
world/net/wap/index.c
Normal file
|
@ -0,0 +1,22 @@
|
|||
#include <net.h>
|
||||
#include <text.h>
|
||||
#include "wap.h"
|
||||
|
||||
htget(prot, query, headers) {
|
||||
sTextPath(query["layout"], query["lang"], "wml");
|
||||
PT(("%O using %O\n", ME, _tpath))
|
||||
if (strstr(headers["user-agent"], "Mozilla") != -1) {
|
||||
htok(prot);
|
||||
w("_error_invalid_agent_HTML");
|
||||
return 1;
|
||||
}
|
||||
HTOK;
|
||||
// TODO!!! index should support all of barts new features!
|
||||
w("_CARD_index", 0, ([
|
||||
"_host": query_ip_name() || "?",
|
||||
"_version_agent": headers["user-agent"] || "?",
|
||||
"_list_charset": headers["accept-charset"] || "?", // _tab
|
||||
]));
|
||||
return 1;
|
||||
}
|
||||
|
74
world/net/wap/send.c
Normal file
74
world/net/wap/send.c
Normal file
|
@ -0,0 +1,74 @@
|
|||
// $Id: send.c,v 1.8 2007/04/20 11:49:35 lynx Exp $ // vim:syntax=lpc
|
||||
//
|
||||
// WAP msg delivery agent.
|
||||
//
|
||||
#include <net.h>
|
||||
#include <person.h>
|
||||
#include "wap.h"
|
||||
|
||||
inherit WAP_PATH "common";
|
||||
|
||||
volatile string recipient = "";
|
||||
volatile string message = "";
|
||||
|
||||
htget(prot, query, headers, qs) {
|
||||
// we don't want strings containing 0
|
||||
recipient = query["r"] || "";
|
||||
message = query["m"] || "";
|
||||
|
||||
::htget(prot, query, headers, qs);
|
||||
}
|
||||
|
||||
authChecked(val)
|
||||
{
|
||||
if(::authChecked(val)) {
|
||||
// send message or display send-form?
|
||||
if (recipient != "" && message != "") {
|
||||
checkMessage(recipient, message);
|
||||
} else {
|
||||
showCompose(recipient, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
checkMessage(recipient, message) {
|
||||
mixed palo;
|
||||
|
||||
unless (stringp(recipient) && stringp(message)) {
|
||||
showCompose(recipient, message);
|
||||
}
|
||||
|
||||
unless (palo = is_formal(recipient)) {
|
||||
if (recipient = legal_name(recipient)) {
|
||||
unless (palo = find_person(recipient)) {
|
||||
if (palo = summon_person(recipient, load_name())) {
|
||||
if (palo->isNewbie()) {
|
||||
destruct(palo);
|
||||
showCompose(recipient, message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sendmsg(palo, "_message_private", message, ([
|
||||
"_nick" : username,
|
||||
"_nick_source" : query_ip_name()
|
||||
]), user);
|
||||
|
||||
printMsg("Message delivered.<br/>");
|
||||
}
|
||||
|
||||
// shows msg-form, default values possible
|
||||
showCompose(recipient, message, notice) {
|
||||
HTOK;
|
||||
HEADER_WML("send msg");
|
||||
|
||||
write("Recipient:<br/><input type='text' name='r' emptyok='false' value='"+recipient+"'/><br/>");
|
||||
write("Text:<br/><input type='text' name='m' emptyok='false' value='"+message+"'/><br/>");
|
||||
write("<a href='send?u="+username+"&p="+password+"&r=$(r)&m=$(m)'>[send]</a>");
|
||||
|
||||
FOOTER_WML;
|
||||
}
|
||||
|
38
world/net/wap/users.c
Normal file
38
world/net/wap/users.c
Normal file
|
@ -0,0 +1,38 @@
|
|||
// $Id: users.c,v 1.7 2007/10/02 10:35:46 lynx Exp $ // vim:syntax=lpc
|
||||
//
|
||||
// inspect local /who list from a WAP phone
|
||||
//
|
||||
#include <net.h>
|
||||
#include "wap.h"
|
||||
|
||||
htget(prot, query, headers) {
|
||||
array(string) u;
|
||||
string list;
|
||||
string n;
|
||||
int i;
|
||||
|
||||
HTOK;
|
||||
write(WML_START + "<card title='" CHATNAME " chatters'><p>");
|
||||
|
||||
u = objects_people();
|
||||
list = "";
|
||||
for (i = sizeof(u)-1; i>=0; i--) {
|
||||
n = u[i]->qName();
|
||||
if (n) {
|
||||
if (list != "") list += ",\n";
|
||||
list += n;
|
||||
}
|
||||
}
|
||||
write(list);
|
||||
|
||||
write("</p></card>\n" + WML_END);
|
||||
|
||||
log_file("WAP", "[%s] %s users %O\n",
|
||||
#ifdef _flag_log_hosts
|
||||
query_ip_name(),
|
||||
#else
|
||||
"?",
|
||||
#endif
|
||||
ctime(), headers);
|
||||
return 1;
|
||||
}
|
26
world/net/wap/wap.h
Normal file
26
world/net/wap/wap.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
// $Id: wap.h,v 1.4 2006/09/29 08:51:40 lynx Exp $ // vim:syntax=lpc
|
||||
//
|
||||
#define HTOK htok3(prot, "text/vnd.wap.wml", "Cache-Control: no-cache\n")
|
||||
|
||||
// wml.textdb is the correct way to do this these days...
|
||||
|
||||
#define WML_START "<?xml version=\"1.0\"?>\
|
||||
<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\"\
|
||||
\"http://www.wapforum.org/DTD/wml_1.1.xml\"><wml>\
|
||||
<template><do type='prev' label='Back'><prev/></do></template>"
|
||||
|
||||
#define WML_END "</wml>"
|
||||
|
||||
#define LOGIN_WML write("User:<br/><input type='text' name='u' emptyok='false' /><br/>"); \
|
||||
write("Pass:<br/><input type='password' name='p' emptyok='false' /><br/>"); \
|
||||
write("<a href='login?u=$(u)&p=$(p)'>[login]</a>")
|
||||
|
||||
#define HEADER_WML(x) write(WML_START+"<card title='"+CHATNAME+" "+(x)+"'><p align='center'>")
|
||||
|
||||
#define NAV_WML write("<a href='inbox?u="+username+"&p="+password+"'>[inbox]</a><a href='send?u="+username+"&p="+password+"'>[send msg]</a><br/>");
|
||||
|
||||
#define SEND_PERSON(x) ("<a href='send?u="+username+"&p="+password+"&r="+(x)+"'>"+(x)+"</a>")
|
||||
|
||||
#define FOOTER_WML write("</p></card>\n" + WML_END)
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue