MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 1 | // MorgenGrauen MUDlib |
| 2 | // |
| 3 | // www.who.c |
| 4 | // |
| 5 | // $Id: www.who.c 8755 2014-04-26 13:13:40Z Zesstra $ |
| 6 | |
| 7 | #pragma strong_types |
| 8 | #pragma combine_strings |
| 9 | |
| 10 | #include <config.h> |
| 11 | #include <properties.h> |
| 12 | #include <www.h> |
| 13 | |
Zesstra | be894b4 | 2019-11-27 19:56:32 +0100 | [diff] [blame] | 14 | string MakeLink(<object|string>* entry) |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 15 | { |
| 16 | string nm; |
| 17 | int idx; |
| 18 | |
| 19 | entry[1] = regreplace(entry[1], "<", "\\<", 1); |
| 20 | entry[1] = regreplace(entry[1], ">", "\\>", 1); |
| 21 | nm = getuid(entry[0]); |
| 22 | if(nm == " R O O T ") return "<TT>"+entry[1][0..2]+"</TT>"+entry[1][3..]; |
| 23 | idx = strstr(lower_case(entry[1]), nm); |
| 24 | return "<TT>"+entry[1][0..2]+"</TT>"+entry[1][3..idx-1] |
| 25 | + "<A HREF=\""+MUDWWW+"?"+REQ+"="+R_FINGER+"&"+USER+"="+nm+"\"><B>" |
| 26 | + entry[1][idx..idx = idx+sizeof(nm)] |
| 27 | + "</B></A>" |
| 28 | + entry[1][idx+1..]; |
| 29 | } |
| 30 | |
| 31 | string Request(mapping cmds) |
| 32 | { |
Zesstra | be894b4 | 2019-11-27 19:56:32 +0100 | [diff] [blame] | 33 | if (!sizeof(cmds)) |
| 34 | return ERROR("Anfrage ungültig!"); |
| 35 | // Wer-Liste abfragen |
| 36 | <object|string>** list = WHO; |
| 37 | int size=sizeof(list); |
| 38 | string *who = allocate(size); |
| 39 | |
| 40 | // Listenreihenfolge umkehren. |
| 41 | foreach(int i : size) { |
| 42 | who[i] = MakeLink(list[<i+1]); |
| 43 | } |
| 44 | |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 45 | return "<H2>Wer ist gerade in "MUDNAME"?</H2><HR>" |
| 46 | + "<OL><LI>"+implode(who, "\n<LI>")+"</OL>"; |
| 47 | } |