Annotate

mod_webpresence/mod_webpresence.lua @ 134:744deabdee81

mod_ipcheck: Fixed: 'service-unavailable' was sent instead of 'forbidden' on unauthorized access.
author Waqas Hussain <waqas20@gmail.com>
date Sat, 06 Mar 2010 06:19:38 +0500
parent 4:63080b8973ee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1 do local e={};e["icons/status_online.png"]='PNG\r\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2 \
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3 \0\0\0\rIHDR\0\0\0\0\0\0\0\0\0V%\0\0\0sBIT|d\0\0\0 pHYs\0\0\r\0\0\rB(x\0\0\0tEXtSoftware\0www.inkscape.org<\0\0IDAT(U_h[u?woM65Kel]+a[uOE\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4 ">D܆Pd0/VӗXAa)Ctin7U$m&Mn{ׇ;kwp s뺬\'?7CjZԢ Tu\\;zVwxGn{f43 wiI//ѿ^;y^#jbB\0H["%v1k?R۶<\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5 \\bЬ*Z@C{A\rPQu% 3εjL\0ޕ{Yh TPyɟ\' ޫ?(a+d E((BAhc3T^Ob0a2K%uU-.x"-KŸ`ߖ}zbcz4PªґȲ9l6mibA.w\\Fn/7XQA GZЧ!~alcm"G"9 <xULEo.5"-->~@6@$ ><JӚ&q8<pZ )[<H \'\0I%~#tgR!X־ؽ2F #\0pC܈wp*<d3S/?oYV\\v6 Xa\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6 V SCT&[ζB5?1 2oe@uwDήI\'%+ƈݩQN{<J᱂TTd:\r6\\\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7 }qsCZӝ/Vjg-hEӯ_\'i~&\0\0\0\0IENDB`'e["icons/status_away.png"]='PNG\r\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8 \
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9 \0\0\0\rIHDR\0\0\0\0\0\0\0\0\0V%\0\0\0sBIT|d\0\0\0 pHYs\0\0\r\0\0\rB(x\0\0\0tEXtSoftware\0www.inkscape.org<\0\01IDAT(U_Lu\0{QD atԌpXHg\\5aVmڅEKE.Bm,\' H)” 9y{]s<R9/*nA<Ʀ]ms=nSlq2\0tc3wrIpw~xryTn0ii8.pԉ3J\0<X-V\0=0}|`?b`7A}m\0m5Ç0MsfDjK+XΚ<_0UzW8 @:a ~tˏfhBáf,ͤX([>cy@y()BI,Yueyz3o$胰Z&,PII*C$2dI{Cֻ|S<\0"r:p.dJI$x-6~/Q`ք1>Eb}t~x֣ͼwҨ{u5T%%%\0Ӿ}f&ԿGЪ`x7<IMGw3H@*;0K"UDtd/M}C#6nfol ^`E(5yz_Czcy+W umdsxITf`2\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 {~_SJQ]U+FFK3GϰőgƘYLzA>=4>=FuVCh?bɔ4C̠ɬwUjwv{Y[ҏ]@*Nn߼k^qRo,3v,j\0\0\0\0IENDB`'e["icons/status_xa.png"]="PNG\r\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 \
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 \0\0\0\rIHDR\0\0\0\0\0\0\0\0\0V%\0\0\0sBIT|d\0\0\0 pHYs\0\0\r\0\0\rB(x\0\0\0tEXtSoftware\0www.inkscape.org<\0\07IDAT(UmLUu\0s=s7LoC؂jm\rIlBhЋsEzqImI,m (6)|P,.쑄,Ϟ6ivFjYEqhFtCmE?KۤIHm LDm3rљPyuSm^JUMƥ\0XCpOKk-,>_SU180$d'xhST>uo_PD87s@~iҵ/M4ώ#8ӹk/Ot$Xʖk%|!XPKW6օxs bGuk;/?etJ %{F };yX/!8BaaҁD>7^Ӷ*>+~?Xƚ{y_IX&Eq9ic9acddi(\0`vp\0`׫Ӓ$j5T O\r7M\rӅat= P%px‚Y%j3ٌ]p񠷵Ѻ~Da&FFس\0wzvXԽ3R䡺L'\\+z װL3ZU딎͒á#Ngeʑ\\2Qm ,K2LM7^hQ\0ڎc+_ Ee'(.i-\\1mJXM1Q䋉;Vw>E*lwQ:E=wUU'v?hj\0\0\0\0IENDB`"e["icons/status_dnd.png"]="PNG\r\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 \
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 \0\0\0\rIHDR\0\0\0\0\0\0\0\0\0V%\0\0\0sBIT|d\0\0\0 pHYs\0\0\r\0\0\rB(x\0\0\0tEXtSoftware\0www.inkscape.org<\0\0IDAT(}k\\Us;IBj\"2hRLM[pQWnDtUQ(nZ*6]T\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 ªP-lL-I$w⚚ w^xD;{-SGZ宩_U٣6?jd\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 %!E`9x}W'zy?OZxi.+#Ei:mϷ{G~;ܡ\0h^xk}`m^D@ w)|xp_'浙7~0XS*'}z`@B\"v|_:;ڢ1Z RZ5(P\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17 _6ϙ(\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18 7\0i+R1J1A 1DiWL>Fb{s9sf=?=7j!!ƈk- (ͦJVj<w]>3B DAD֚Z]14[C/4jD!@ UY@}bSCBPʴzE,Enwp1e:]Yߕ_\\|jڭ{ɉ'֓{+ |_R:6rjxuRcፖN uj)ОO?y[]𶎼xt#fjWWdݿ(yRi\0\0\0\0IENDB`"e["icons/status_chat.png"]='PNG\r\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19 \
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20 \0\0\0\rIHDR\0\0\0\0\0\0\0\0\0V%\0\0\0sBIT|d\0\0\0 pHYs\0\0\r\0\0\rB(x\0\0\0tEXtSoftware\0www.inkscape.org<\0\0IDAT(ULus!D`sqY:3deS˭15d-mfrㇶ6;f-oZs؈X6`LԎ Kk?PWt:r5c0:75m\rLƌP/ުz[/=@4"Xb24~ğo/ǎ{_hh*Rnr"),I $3=]}8@m@J.Fk/Zк<-no:\0w//gMk6E)ŲbX}N\r`"&o++tyYŕMap\0к\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
21 PEhvsiw%]DagkBY e%,NݦG{buoXd(-+gE2twP\\<M3NGɓg7-I33ss&ׯoC?xzgc+YSf \0\0 LdD" jksb "|#Gpg,,K1qyGϦ̓gZ[/\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
22 uZ @\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
23 J 2ܝuȵX%WիauHHT7j*jލZ&cy\\={ $nCq.u~-" ".D}䧟7Knٲ7Su%XDx7{lK`-("j[ ,ϛ\rVTV/se}cȈaw^b@03\0\0\0\0IENDB`'e["icons/status_offline.png"]="PNG\r\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
24 \
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
25 \0\0\0\rIHDR\0\0\0\0\0\0\0\0\0V%\0\0\0sBIT|d\0\0\0 pHYs\0\0\r\0\0\rB(x\0\0\0tEXtSoftware\0www.inkscape.org<\0\0IDAT(UKcg^\\[;SAp)tmL)3V,dp`6 ]/BA2JAP(iNҚdD'~Nr?޷Xٝ=Q\\_?VAQv 埮gjCia(\0B<u].//ūT]>Z~PE o5Fo f0 \0P0wr{UFփ6660 41 ]!Jd޽<<P>߯F>H)ut:8###8F0>0{5놚ddppvFGGmn8Tft]GJQ\0Xy`eeYZZbI)F\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
26 (szzP#z{{bT*2Du<$MMME\
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
27 \0mL&<\0xjm7֬J#LRTH$eYhi)˸8dYΒfabb~u]|e>Ь¡RD\"Agg'S,RRWWGTUʓEJGw?ގ<\\.i#3y_?nTpztx\\CQ۶B ˲ ^EWlxVߥ aY7&Â3YD_~UUu۟_<1mUirrZ7gD\0\0\0\0IENDB`"function require_resource(r)return e[r]or error("resource '"..tostring(r).."' not found");end end local s=require"util.jid".prepped_split;if not require_resource then
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
28 function require_resource(e)local r=io.open((config.get("*","core","presence_icons")or"")..e);if r then
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
29 return r:read("*a");end
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
30 module:log("warn","Failed to open image file %s",(config.get("*","core","presence_icons")or"")..e);return"";end
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
31 end
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
32 local e={status="404 Not Found",body="<h1>Page Not Found</h1>Sorry, we couldn't find what you were looking for :("};local n={"online","away","xa","dnd","chat","offline"};for r,e in ipairs(n)do
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
33 n[e]={status="200 OK",headers={["Content-Type"]="image/png"},body=require_resource("icons/status_"..e..".png")};end
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
34 local function t(e,e,o)local e=o.url.path:match("[^/]+$");if e then
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
35 local r,e=s(e);if e and not r then
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
36 r,e=e,o.headers.host;if e then e=e:gsub(":%d+$","");end
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
37 end
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
38 if r and e then
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
39 local e=hosts[e]and hosts[e].sessions[r];if e then
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
40 local e=e.top_resources[1];if e and e.presence then
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
41 e=e.presence:child_with_name("show");if not e then
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
42 e="online";else
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
43 e=e:get_text();end
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
44 return n[e];end
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
45 end
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
46 end
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
47 end
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
48 return n.offline;end
63080b8973ee mod_webpresence: Initial commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
49 local e=config.get(module.host,"core","http_ports")or{5280};require"net.httpserver".new_from_config(e,"status",t);