This snippet opens a socket and lets you run small webpage(s) like a webserver
To Start: /ssws on [port] (/ssws on 80)
To Stop: /ssws off
To Turn on Debug: /ssws debug
To Get Webserver Info: /ssws info
;SSWS (Small Sock Web Server) v1.0 By: Humming_Hi
;To Start: /ssws on [port] (/ssws on 80)
;To Stop: /ssws off
;To Debug: /ssws debug
;To Get Webserver Info: /ssws info
;------- Main Part Of The Snippet (Edit if you want) ------
alias ssws {
if ($1 == $null) {
echo -a Commands Are:
echo -a On [port], Off, Debug, Info. (/ssws [command])
}
elseif ($1 == on) {
if ($sock(ssws_server)) { echo -a Server already enabled }
elseif (!$sock(ssws_server)) { .socklisten ssws_server $2 | echo -a Server Enabled on port $2 | .set %sswsp $2 | set %sswsurl http:// $+ $ip $+ : $+ %sswsp }
}
elseif ($1 == off) {
if (!$sock(ssws_server)) { echo -a Server not active }
elseif ($sock(ssws_server)) { .sockclose ssws_* | echo -a Web Server Disabled (/ssws on [port] To Enabled Again) }
}
elseif ($1 == debug) {
if ($window(@sswsd)) window -c @sswsd
elseif (!$window(@sswsd)) window @sswsd
}
elseif ($1 == info) {
echo -a -=Small Sock Web Server=-
echo -a Server IP: $ip (If you would like confirmation of your IP, please visit: http://www.whatismyip.com )
echo -a Server Port: %sswsp
echo -a URL: %sswsurl
}
}
on *:socklisten:ssws_server: {
.sockaccept ssws_visitor $+ $r(1000,9999)
}
on *:sockread:ssws_visitor*: {
var %x
sockread %x
tokenize 32 %x
if ($1 == GET) && ($2 == /) && (HTTP* iswmcs $3) { page1 $sockname }
if ($1 == GET) && (/page isin $2) && (HTTP* iswmcs $3) { $2 $sockname }
.sockclose $sockname
if ($window(@sswsd)) && (/favicon.ico !isin $2) echo @sswsd $1-
}
on *:unload: { unset %sswsurl | unset %sswsp | echo -a Thank you for useing SSWS. }
on *:load {
window @ssws
var %sswsload = echo @ssws
%sswsload -= SSWS (Small Sock Web Server) v1.0 By: Humming_Hi =-
%sswsload To Start: /ssws on [port] (/ssws on 80)
%sswsload To Stop: /ssws off
%sswsload To Debug: /ssws debug
%sswsload To Get Webserver Info: /ssws info
}
;----------- Basic Web page Layout For This Script ----------
alias page1 {
var %ssws = .sockwrite -n $1
%ssws <html><body style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px">
%ssws <center> This page is for testing the SSWS (Small Socket Web Server) Made by: Humming_Hi
%ssws <br/>Email me at skillers@your-mom-sucks.com for comments/questions/ideas/bugs </a>
%ssws <br/><a href=" $+ %sswsurl $+ /page2">Page 2</a></center></body></html>
}
alias page2 {
var %ssws = .sockwrite -n $1
%ssws <html><body style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px">
%ssws <center>This is Page 2 of the SSWS testing.
%ssws <br/>Email me at skillers@your-mom-sucks.com for comments/questions/ideas/bugs</a>
%ssws <br/><a href=" $+ %sswsurl $+ ">Page 1</a></center></body></html>
}
;------------Writing A Basic Page------------
;the SSWS can use any alias with the word page in it (you do not need to add any more to the main part of the script)
;make sure you use page in the alias (/page#)
;alias page3 {
;sets the var so you don't need to write the sockwrite -tn things
;var %ssws = .sockwrite -n $1
;sets the basic HTML items needed for a page
;%ssws <html><body style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px">
;sets what to put on the page (can even embed music videos and other items, use HTML code)
;%ssws [What you want on the page]
;}