$include $lib/gary'smufutils-lists $include $lib/gary'smufutils-misc $include $lib/alynna $include $lib/www_utils $include $lib/rp $include $muf/Scrp/registry $def .tell descr @ swap notify_descriptor $def .tell2 descr2 @ swap notify_descriptor $def VERSION prog "_version" getpropstr $def stripzeros begin dup "0*" smatch if 1 strcut swap pop else break then repeat dup not if pop "0" then $def }web }array "\r" array_join descr @ swap notify_descriptor $define }chunk }array "\r\n" array_join dup strlen itoh stripzeros "\r\n" strcat swap strcat descr @ swap notify_descriptor $enddef var cookies var player (-----------------------------------) (-------------VARIBLES=-------------) (-----------------------------------) lvar descr lvar user lvar host lvar params (-----------------------------------) (------------ACTUAL CODE------------) (-----------------------------------) : load_info "|" explode pop atoi descr ! host ! user ! params ! ; : exitfixup[ str:input -- str:output ] input @ "`EXITS`" instr 25 = not if input @ exit then 0 var! x input @ "" "`EXITS`" subst input ! "" var! output input @ "[\[[1;33m" explode_array foreach var! val pop x @ not if val @ output ! x @ ++ x ! continue then val @ "]" split swap { over "" }cat swap strcat "]" strcat swap strcat "[" swap strcat output @ swap strcat output ! repeat output @ ; : webnotify[ int:descr str:text -- ] { { "^normal^" text @ strcat dup "<" instring 9 = not if fixup exitfixup else "" "^normal^" subst then "
" }cat "" }web ; : main (s -- ) command @ "listen" instring if var! text systime trigger @ "Last Web Presence" getstatint - 60 > if exit then trigger @ "Web Descr" getstatint dup descr? not if pop trigger @ "Web Descr" 0 setstat exit then var! descr2 descr2 @ text @ webnotify trigger @ trigger @ "Web Listen#/101" text @ setprop trigger @ "Web Listen#/101/Timestamp" systime_precise setprop 90 var! x begin trigger @ "Web Listen#/" x @ 1 + intostr strcat getpropstr trigger @ "Web Listen#/" x @ intostr strcat rot setprop trigger @ "Web Listen#/" x @ 1 + intostr strcat "/Timestamp" strcat getprop tofloat trigger @ "Web Listen#/" x @ intostr strcat "/Timestamp" strcat rot setprop trigger @ "Web Listen#/" x @ 1 + intostr strcat "/Displayed?" strcat getprop toint trigger @ "Web Listen#/" x @ intostr strcat "/Displayed?" strcat rot setprop x @ 1 + x ! x @ 101 = until exit then load_info { { "HTTP/1.1 200 OK" }cat { "Date: %a %d %b %Y %T GMT" systime timefmt }cat { "Server: ProtoMUCK/" version }cat "Content-Type: text/html" { "X-Params: " command @ " " params @ }cat }web descr @ 13 notify_descriptor_char descr @ 10 notify_descriptor_char event_wait pop dup var! data "data" array_getitem "HeaderData" array_getitem "Cookie" array_getitem dup string? not if pop { }dict else "; " explode_array { swap foreach swap pop "=" split repeat }dict then cookies ! { "" }web hash @ not if cookies @ "Session" array_getitem hash ! then rpsys { "Web Logins/" hash @ "/Last Connect" }cat systime setprop rpsys { "Web Logins/" hash @ "/Player" }cat getprop toint dup 0 = swap dbref dup player ! player? not or if { "You should login to play." "Click Here" }web random 5 % case 0 = when #7887 end 1 = when #7559 end 2 = when #7610 end 3 = when #7616 end 4 = when #7631 end endcase player ! rpsys { "Web Logins/" hash @ "/Player" }cat player @ setprop then params @ "BackLog" instring 1 = if { "" "" "" }web player @ "Command Recall" getstatint 1 - 1 greater player @ "Command Recall" rot setstat exit then params @ "NextLog" instring 1 = if player @ "Command Recall" getstatint 1 + 10 lesser player @ "Command Recall" rot setstat { "" "" "" }web exit then params @ "Who" instring 1 = if { "" "" "" "" #0 "Web/Cookie Tabs#" array_get_proplist foreach swap pop repeat "" "" "" "
" "
" "

Room

" online_array dup array_union foreach var! cur pop cur @ location player @ location dbcmp not if continue then { cur @ name "
" }cat repeat "
" "
" "

Online

" online_array dup array_union foreach var! cur pop cur @ descrleastidle dup -1 = if pop else descridle 600 > if continue then then { cur @ name "
" }cat repeat "
" "
" "" }web exit then params @ "Update" instring if player @ "@alisten/Web" prog tostr setprop { "" "" "" "" player @ "Web Descr" descr @ setstat ( Alynna: ) "" "" 90 100 1 for var! x { "^normal^" player @ "Web Listen#/" x @ intostr strcat getpropstr strcat dup "<" instring 9 = not if fixup exitfixup else "" "^normal^" subst then "
" }cat repeat }web ( Stay connected Loop ) systime_precise var! time player @ "Last Web Presence" systime_precise setstat begin 0 var! found 1 100 1 for var! x Player @ "Web Listen#/" x @ intostr strcat "/Displayed?" strcat getprop not if { "^normal^" player @ "Web Listen#/" x @ intostr strcat getprop tostr strcat dup "<" instring 9 = not if fixup exitfixup else "" "^normal^" subst then "
" "" }web Player @ "Web Listen#/" x @ intostr strcat "/Displayed?" strcat 1 setprop then player @ "Last Web Presence" systime setstat repeat 1 sleep repeat ( end loop -- We probably never get here, ever ) { "
" }web { "" }web exit then params @ "Message" instring if params @ "=" debug_line split swap pop dup "&Submit" instring if "&Submit=Submit" split pop then cleanup ( "Public " swap strcat ) dup "*&" smatch if dup strlen 1 - strcut pop then ( "(WEB)" strcat ) dup " " instring 1 = if 1 strcut swap pop "+" swap strcat then dup text ! player @ toint dbref swap force player @ toint dbref "Last Web Action" systime setstat player @ toint dbref "Last Web Presence" systime setstat player @ "Web Command Log#/11" text @ setprop 1 var! x begin player @ "Web Command Log#/" x @ 1 + intostr strcat getpropstr player @ "Web Command Log#/" x @ intostr strcat rot setprop x @ 1 + x ! x @ 11 = until player @ "Command Recall" 10 setstat exit then #261 descr @ "Play" wwwUtils.displayheader player @ toint dbref player ! player @ player? not if #7887 player ! then { "" 0 sleep player @ location #-1 { "^cyan^" player @ name " has connected." }cat ansi_notify_except player @ toint dbref "Last Web Presence" systime setstat player @ toint dbref "Last Web Action" systime setstat "" #0 "Web/Form Without Reload Play#" array_get_proplist foreach swap pop repeat "" "" "" "" "" "" "
" "" "" "" "
Command:
Back Next
" "
" "" }web descr @ wwwUtils.displayfooter ;