home *** CD-ROM | disk | FTP | other *** search
/ Treasure Hunt 2001 PRESSKIT / TH2001_PRESSKIT.iso / demo / scol_install / Partition / locked / masterse.pkg < prev    next >
Encoding:
Text File  |  2000-11-09  |  24.7 KB  |  1 lines

  1.   var UpdPkg="locked/update/update.pkg";; var UpdLang="locked/update/lang/update.lang";; var UpdAdr="locked/etc/adr.txt";; var pendingUpd=0;; typeof chnComm=Chn;; var flagUpdContact=1;; var flagUpdMsg=2;; var voyagerDebugMode=0;;  typeof languages=[[S S] r1];; var AutoStartDelay=5000;; var packsusers=["locked/lib/stdlib.pkg" "" ""]::["locked/infocli.pkg" "" ""]::nil;; var scriptserver="";; var scriptuser="_load \"locked/lib/stdlib.pkg\"\n_load \"locked/infocli.pkg\"\nmain";; var versionuser=0;; defcom show=show;; defcom Cservice=service S S;; defcom Cservis=servis S S;; typeof chn0=Chn;; typeof font=ObjFont;;  struct VoyagerWin= [ win:ObjWin, x:I,  y:I,  w:I,  h:I,  bottomH:I  ] mkVoyagerWin;; typeof mainWin=VoyagerWin;;  typeof icon=ObjIcon;; typeof onLineIconbmp=ObjBitmap;; typeof offLineIconbmp=ObjBitmap;; var onLineIconS="locked/voyager/img/icononline16.bmp";; var onLineIconUnix="locked/voyager/img/icononline.bmp";; var offLineIconS="locked/voyager/img/iconoffline16.bmp";; var offLineIconUnix="locked/voyager/img/iconoffline.bmp";; var imageSplash="locked/voyager/img/splash.jpg";; struct Script=[nameScript:S,clearScript:S,rightsScript:I,sizeScript:I,sonsScript:[Script r1]]mkScript;; struct Run=[nameRun:S,canalRun:Chn,scriptRun:Script,pubRun:[[S I I] r1],tag:I,runnum:I] mkRun;; typeof current=Run;; typedef Link=urlLink [S S] | scriptLink [S S];; var currunnum=0;; typeof back=[S r1];;  typeof book=[[S r1] r1];;  typeof customs=[Script r1];; typeof running=[Run r1];; typeof contmenu=ObjMenu;; var firsttime=0;; typeof getservhttp=fun[HTTPcon S] S;; typeof getservdirect=fun[S] I;; typeof cbpublic=fun[S I] I;; typeof cbpublichttp=fun[S I] I;; typeof cbkilled=fun[Run I] I;; var h4="0000";; fun itoh4(i)= let itoh i -> s in strcat substr h4 0 4-strlen s s;; proto _contact=fun [u0 S] I;; proto createmenus=fun[] I;; proto iniwindow=fun[] I;;  proto iniVoyager=fun[] I;; proto startDNSres=fun[] I;; proto iniVoyagerInterface=fun[] I;; proto destroyVoyagerInterface=fun[] I;; proto showRegUserInterf=fun[] I;; proto updateTopContURL=fun[S] I;; proto refreshBookmarkInterf=fun[] I;; proto showAlertMessage=fun[S S S I] I;; proto forceUpdateDNSres=fun[] I;; proto getCookieIP=fun [S] S;; proto createPopupMenuUser=fun [ObjMenu I] I;; proto createPopupMenuStatus=fun [ObjMenu] I;; fun pubbyname(a,s)=let a->[x _ _] in !strcmp x s;; fun nameofpub(a)=let a->[x _ _] in x;; fun ipofpub(a)=let a->[_ port port2] in if port==nil then if port2==nil then nil else strcatn "scol://applet:http://"::_hostIP::":"::(itoa port2)::"/"::(itoh4 port2)::"?X"::nil else strcatn "scol://"::_hostIP::":"::(itoa port)::nil;; fun ipofpub2(a)=let a->[_ port port2] in if port==nil && port2==nil then nil else strcatn "scol://"::_hostIP::":"::(nameofpub a)::nil;; fun searchpub(l,n)= if l==nil then nil else let l->[r nxt] in let search_in_list r.pubRun @pubbyname n -> x in (if x==nil then searchpub nxt n else x);; fun searchpub2(l,n)= if l==nil then nil else let l->[r nxt] in let search_in_list r.pubRun @pubbyname n -> x in (if x==nil then searchpub2 nxt n else r);; fun _resizeT(a,t,x,y)=_SIZEtext t x-2 y-2 1 1;; fun getlibname(env)= if env==nil then nil else ((_envfirstname env)::nil)::getlibname _removepkg env;; fun _lib(a,b)= let _CRwindow chn0 mainWin.win 150 150 200 300 WN_MENU+WN_MINBOX+WN_SIZEBOX loc "SL" -> win in _CBwinSize win @_resizeT (_CRtext chn0 win 1 1 198 298 ET_VSCROLL+ET_HSCROLL strbuild getlibname _removepkg _removepkg _removepkg _removepkg _removepkg env_ref);; fun multiress(res)= if res==nil then 0 else let res ->[[l n] nxt] in (if strcmp l "#" then _setress l hd n else nil; multiress nxt);; fun getInfos(l,a)= if l==nil then nil else let l->[q nxt] in if !strcmp hd q a then tl q else getInfos nxt a;; fun getInfoI(l,a)= if l==nil then nil else let l->[q nxt] in if !strcmpi hd q a then hd tl q else getInfoI nxt a;; fun chgress2(l,a,b,s,k)= if l==nil then if k then s::nil else nil else let l->[ll n] in let hd hd strextr ll -> h in if h==nil || strcmp h a then ll::chgress2 n a b s k else if b==nil || k==0 then chgress2 n a b s 0 else s::chgress2 n a b s 0;; fun chgress(a,b)= let lineextr _loadressini -> l in let strbuild (a::b::nil)::nil -> s in _saveressini linebuild chgress2 l a b substr s 0 (strlen s)-1 1; multiress strextr _loadressini;; fun chgusm2(l,a,b,s,k)= if l==nil then if k then s::nil else nil else let l->[ll n] in let hd strextr ll -> [h [hh _]] in if (!strcmp h a)&&((b==nil)||(!strcmpi b substr hh 0 strlen b)) then s::chgusm2 n a b s 0 else ll::chgusm2 n a b s k;; fun chgusm(a,b,line)= _saveusmini linebuild chgusm2 (lineextr _loadusmini nil) a b line 1;; var port=0;; var rights=-1;; typeof SplashWin=ObjWin;; typeof SplashBitmap=ObjBitmap;; fun SplashPaint(a,b)= _BLTbitmap SplashWin SplashBitmap 0 0 ;; fun _regres(x,s,r)= if r==1 then chgress "Register" "Yes" else nil;;  fun SlpashRemove(a,b)= iniVoyager;  _deltimer a; _DSwindow SplashWin; _DSbitmap SplashBitmap; if strcmpi _getress "Register" "Yes" then (iniwindow; _DLGrflmessage _DLGMessageBox chn0 mainWin.win loc "WARN" loc "REG" 2 @_regres nil; 0) else if (firsttime==0)&&strcmpi _getress "Wizard" "Done" then (iniwindow; showRegUserInterf  ) else nil; 0;; fun SplashShow()= if strcmpi _getress "Start" "no" then (set SplashBitmap = _LDjpeg chn0 _checkpack imageSplash; let _GETbitmapSize SplashBitmap -> [wb hb]in let _GETscreenSize -> [w h]in set SplashWin = _CRwindow chn0 nil (w-wb)>>1 (h-hb)>>1 wb hb WN_NOCAPTION|WN_NOBORDER strloc loc "SE2" _versionname::nil; _CBwinPaint SplashWin @SplashPaint nil; SplashPaint nil nil; _rfltimer _starttimer chn0 2000 @SlpashRemove 1) else nil; 0;; fun buildl(l)=if l==nil then nil else let l->[a n] in let buildl n -> res in if (!strcmp substr a 0 19 "locked/lang/master.")&&(!strcmp substr a (strlen a)-5 5 ".lang")   then let hd getInfos strextr _getpack _checkpack a "LANGUAGE" -> s in if s==nil then res else [substr a 19 (strlen a)-24 s]::res else res;; fun insertstring(s,l,f)= if l==nil then s::nil else let exec f with [s hd l] -> res in if res==0 then insertstring s tl l f else if res<0 then s::l else (hd l)::insertstring s tl l f;; fun sort(l,f)= if l==nil then nil else insertstring hd l sort tl l f f;; fun cmpbyclear(x,y)=let x->[_ a] in let y->[_ b] in strcmp a b;; fun buildlanguages()=set languages=sort buildl _listoffiles "locked/lang" @cmpbyclear;; fun reinitloc()= buildlanguages;  if !strcmpi _getress "DefaultLanguage" "chinese" then (chgress "DefaultLanguage" "english"; _setress "DefaultLanguage" "english") else nil; startloc "locked/lang/master"; _SETdefaultFont set font=_CRfont chn0 atoi loc "FONTSZ" 0 0 loc "FONT"; 0;; fun launchmachine(n,r)= _newmachine n _getpack _checkpack n r 0;; fun launchscript(n)= launchmachine n.nameScript n.rightsScript;; fun search_in_script(l,f,i)= if l==nil then nil else let l->[a n] in if exec f with [a i] then a else let search_in_script a.sonsScript f i -> b in if b!=nil then b else search_in_script n f i;; fun srvbyname(r,s)= if !strcmp r.nameScript s then 1 else 0;; fun srvbyclear(r,s)= if !strcmp r.clearScript s then 1 else 0;; fun runbychan(r,c)= if r.canalRun==c then 1 else 0;; fun runbyname(r,n)= if !strcmp r.nameRun n then 1 else if !strcmp r.nameRun strcat n " *" then 1 else 0;; fun rebuild2(l)= if l==nil then nil else let l->[a b] in if b==nil then a::nil else a::" "::rebuild2 b;; fun rebuild(l)= if l==nil then nil else let l->[a nxt] in if (nth_char hd a 0)=='> then let rebuild nxt -> [nxt2 q] in let mkScript[nil strcatn rebuild2 a nil nil q]-> s in let rebuild nxt2->[nxt3 qq] in [nxt3 s::qq] else if !strcmp hd a "<" then [nxt nil] else let rebuild nxt->[n q] in [n (mkScript[hd tl a hd a nil nil nil])::q];; fun servics()= let search_in_list customs @srvbyclear loc "STARTUP"->s in s.sonsScript;; proto launch=fun[Timer [Script r1]] I;; fun launch(t,l)= if l==nil then _deltimer t else let l->[x n] in (launch nil x.sonsScript; if x.nameScript!=nil then launchscript x else nil; if t==nil then set t=_starttimer _channel AutoStartDelay else nil; _rfltimer t @launch n; nil);; fun newstart(l,olds)= if l==nil then 0 else let l->[x n] in (newstart x.sonsScript olds; let search_in_script olds @srvbyname x.nameScript -> s in if s==nil then launchscript x else nil; newstart n olds);; fun initcustserv()= let rebuild strextr _getpack _checkpack "locked/etc/custom.txt" ->[_ c] in set customs=c; set book=strextr _getpack _checkpack "locked/etc/bookmark.txt"; set back=lineextr _getpack _checkpack "locked/etc/history.txt" ;; fun _launch(t,n)=launchscript n;; fun _select(t,r)= set current=r; _scriptc r.canalRun "_load \"locked/master2.pkg\"\niniwindow"; 0;;  fun createpublic2(r,mpublic)= let ipofpub r -> url in _CBmenu (_APPitem chn0 mpublic ME_ENABLED strcat strcat nameofpub r " : " url) @_contact ipofpub r;; fun createpublic(r,mpublic)= apply_on_list r.pubRun @createpublic2 mpublic;; fun refreshpublic(m)= apply_on_list running @createpublic m;;  fun _destroycust(s)= if s==nil then 0 else let servics -> olds in (_storepack s "locked/etc/custom.txt"; initcustserv; createmenus; newstart servics olds; 0);; fun _editcust(a,b)= inibook chn0 nil 300 300 loc "ESM" loc "ESM" @_destroycust _getpack _checkpack "locked/etc/custom.txt" 1 nil; 0;; fun createcustom(l,menu)= if l==nil then 0 else let l->[s nxt] in if s.nameScript==nil then let _APPpopup chn0 menu substr s.clearScript 1 1000 -> z in (createcustom s.sonsScript z; createcustom nxt menu) else let _APPitem chn0 menu ME_ENABLED s.clearScript -> z in (_CBmenu z @_launch s; createcustom nxt menu);; fun refreshcustom(m)= _CBmenu (_APPitem chn0 m ME_ENABLED loc "ESM") @_editcust ""; _APPitem chn0 m ME_SEPARATOR ""; createcustom customs m;;  fun createactive(r,mactive)= if r.scriptRun==nil then let search_in_script servics @srvbyname r.nameRun -> s in if s==nil then nil else (set r.scriptRun=s; set r.nameRun=strcat r.nameRun " *") else if (search_in_script servics @srvbyname r.scriptRun.nameScript) != nil then nil else (set r.scriptRun=nil; set r.nameRun=substr r.nameRun 0 (strlen r.nameRun)-2); if r.canalRun==nil then nil else let _APPitem chn0 mactive ME_ENABLED r.nameRun -> z in _CBmenu z @_select r;; fun refreshactive(m)= apply_on_list running @createactive m;;  fun saveBack()= _storepack linebuild back "locked/etc/history.txt"; 0;; fun createback(name,mhistory)= let _APPitem chn0 mhistory ME_ENABLED name -> z in _CBmenu z @_contact name;; fun refreshback(m)= apply_on_list back @createback m;;  fun savebookmark()= _storepack strbuild book "locked/etc/bookmark.txt"; 0;; fun _destroybook(s)= if s==nil then 0 else (_storepack s "locked/etc/bookmark.txt"; initcustserv; createmenus; refreshBookmarkInterf;0);;  fun _editbook(a,b)= inibook chn0 nil 300 300 loc "EBK" loc "EBK" @_destroybook _getpack _checkpack "locked/etc/bookmark.txt" 0 nil; 0;; fun createbookm(l,menu)= if l==nil then nil else let l -> [first nxt] in let first -> [s [u _]] in if (nth_char s 0) == '> then let strcatn rebuild2 first -> s2 in let _APPpopup chn0 menu substr s2 1 1000 -> z in (createbookm (createbookm nxt z) menu) else if !strcmp s "<" then nxt else let _APPitem chn0 menu ME_ENABLED s -> z in (_CBmenu z @_contact u; createbookm nxt menu);; fun refreshbookmark(m)= _CBmenu (_APPitem chn0 m ME_ENABLED loc "EBK") @_editbook ""; _APPitem chn0 m ME_SEPARATOR ""; createbookm book m;;  fun labout(l)= if l==nil then nil else let l->[a b] in a::if b==nil then nil else ", "::labout b;; fun _about(a,b)= let _version -> v in _DLGMessageBox chn0 mainWin.win loc "AB" strloc loc "AB2" _versionname::(hd getInfos (strextr _loadusmini nil) "update")::_hostIP::nil 0;; fun cutlist(l,n,s)= if l==nil || n==0 then nil else let l-> [a nxt] in if !strcmp a s then cutlist nxt n s else [a cutlist nxt n-1 s];;   fun _settextsite(n)=updateTopContURL n;;  defcom maincom=main S I S;; var numb=0;; fun contact(s,env)= if (!strcmp substr s 0 8 "https://")||(!strcmp substr s 0 7 "http://")||(!strcmp substr s 0 7 "file://")|| (!strcmp substr s 0 6 "ftp://")||(!strcmp substr s 0 7 "mailto:") then (_openbrowserhttp s;nil) else _newmachine strcat "browser" itoa numb (strcat "_load \"locked/stduser.pkg\"\n" mkscript maincom [s rights env]) nil 0; set numb=numb+1; if s!=nil && strcmp s "" then (set back=[s cutlist back 10 s]; saveBack; createmenus;0) else nil;;  fun _destroyress(s)= if s==nil then nil else _saveressini s; 0;; fun _editress(a,b)= iniText chn0 nil 300 300 loc "RSE" loc "RSE" @_destroyress _loadressini; 0;;  fun _destroypart(s)= if s==nil then nil else _saveusmini s; 0;; fun _editpart(a,b)= iniText chn0 nil 300 300 loc "CFE" loc "CFE" @_destroypart _loadusmini nil; 0;; proto clockevent=fun [Timer I] I;; var firstping=0;;  fun _checkUpdate(a,b)= set firstping=0; clockevent nil b ;;  fun _contact(t,n)= _settextsite n; contact n nil;; fun _gotosite(a,b)= _contact nil b; 0;; fun _startscript(x,s)= launchmachine s nil;; fun callmenu(a,b,c)= _SETfocus nil; let _GETscreenPos->[x y] in _DRAWmenu nil contmenu x y PM_SCREEN|PM_RIGHT_ALIGN|PM_BOTTOM_ALIGN;; fun _showwin(a,b)=iniwindow;; fun _quitres(x,s,r)= if r then _closemachine else nil;; fun _quit(a,b)= _DLGrflmessage _DLGMessageBox chn0 mainWin.win loc "QUIT" loc "QMSG" 2 @_quitres 0;; fun dclicktask(a,b,c)=_showwin nil nil;;   fun iniwindow()=iniVoyagerInterface;; fun addlinkmenu(a,z)= let z->[chn root] in match a with (urlLink [n r] ->_CBmenu _APPitem chn root ME_ENABLED n @_gotosite r) |(scriptLink [n r] ->_CBmenu _APPitem chn root ME_ENABLED n @_startscript r);;   fun createmenus()= let _CRpopupMenu chn0 -> root in ( _CBmenu (_APPitem chn0 root ME_ENABLED loc "AB") @_about 0;  _APPitem chn0 root ME_SEPARATOR ""; _CBmenu (_APPitem chn0 root ME_ENABLED loc "QUIT") @_quit 0;  _APPitem chn0 root ME_SEPARATOR ""; refreshcustom _APPpopup chn0 root loc "ST";  let _APPpopup chn0 root loc "ADV" -> adv in  (refreshpublic _APPpopup chn0 adv loc "SRV"; _APPitem chn0 adv ME_SEPARATOR ""; refreshactive _APPpopup chn0 adv loc "CONS"; _CBmenu (_APPitem chn0 adv ME_ENABLED loc "SL") @_lib 0; _APPitem chn0 adv ME_SEPARATOR ""; _CBmenu (_APPitem chn0 adv ME_ENABLED loc "RSE") @_editress 0; _CBmenu (_APPitem chn0 adv ME_ENABLED loc "EXPERT") @_editpart 0; _APPitem chn0 adv ME_SEPARATOR ""; _CBmenu (_APPitem chn0 adv ME_ENABLED loc "CHKUPDATE") @_checkUpdate flagUpdMsg); _APPitem chn0 root ME_SEPARATOR ""; _CBmenu _APPitem chn0 root ME_ENABLED loc "DIR" @_gotosite "scol://scol.cryonetworks.com:SiteDirectory";  refreshbookmark _APPpopup chn0 root loc "BK";  refreshback _APPpopup chn0 root loc "HIS";  _APPitem chn0 root ME_SEPARATOR ""; if voyagerDebugMode==0 then nil   else (createPopupMenuUser root 0;  createPopupMenuStatus root;  _APPitem chn0 root ME_SEPARATOR ""); _CBmenu _APPitem chn0 root ME_ENABLED loc "OP" @_showwin 0;  _DSmenu contmenu; set contmenu=root; _SETtaskIconMenu icon contmenu; 0);;  var nbapps=0;; var portdirect=1234;; var portdef=80;; var pendingreq=0;; defcom Cgoto=goto S;; fun processpile(flags,l)= if l==nil then 0 else let l->[[com [arg1 [arg2 _]]] n] in (if !strcmp com "goto" then (contact arg1 nil; processpile flags n) else if !strcmp com "loadupdpkg" then (_storepack arg2 arg1; processpile flags n) else if !strcmp com "startupd" then (_openchannel nil strcatn (substr arg1 0 (strlen arg1)-1)::"\ "::(itoa flags)::"\n"::nil _envchannel _channel; processpile flags n) else processpile flags n);; fun fullurl(srv,port,req,first)= strcatn "http://"::srv::":"::(itoa if first then port else portdef)::"/"::(itoh4 port)::"?"::req::nil;; proto startreq=fun[I S I S I I] I;;  fun _recontact()= let _checkpack UpdAdr -> Pad in let _getpack Pad -> ad in if (ad!=nil) && (strlen ad)>0 then ( _deletepack Pad; contact ad nil ) else nil ;; fun cbmain(inet,z,s,reason)= let z->[flags srv port req napps first current] in if reason==0 then (mutate z<-[_ _ _ _ _ _ strcat current s]; 0) else let strextr current -> l in if !strcmp hd hd l "ok" then (if napps==nil then set firstping=1 else nil; processpile flags tl l; set pendingreq=0) else if first then (_fooS "try again via std port";startreq flags srv port req napps 0) else (_fooS "cannot reach server"; set pendingreq=0; if napps==nil then nil else set nbapps=nbapps+napps; if flags&flagUpdMsg then ( _DLGMessageBox chn0 mainWin.win loc "ERROR" loc "NOTAVAIL" 0; 0) else nil );;  fun startreq(flags,srv,port,req,napps,first)= _fooS "startreq"; set pendingreq=1; let INETGetURL chn0 _fooS fullurl srv port req first 0 @cbmain [flags srv port req napps first nil] -> url in if url==nil then (_fooS "cannot open url"; set pendingreq=0; if napps==nil then nil else set nbapps=nbapps+napps) else nil;; fun requestid()= let strextr _loadusmini nil -> usmini in strcat "PING" strbuild ("update"::(hd getInfos usmini "update")::nil):: ("lang"::(_getress "DefaultLanguage")::nil):: ("reg"::(_getress "Registering")::nil):: ("vernum"::(itoh _version)::nil):: ("version"::_versionname::nil):: ("email"::(_getress "DefaultEmail")::nil):: ("tr"::(_getress "License")::nil):: ("platform"::(hd getInfos usmini "platform")::nil):: ("platformid"::(itoa _platform)::nil):: ("updpkg"::(_getlongname _getpack _checkpack UpdPkg "" "#")::nil):: ("updlang"::(_getlongname _getpack _checkpack UpdLang "" "#")::nil):: nil;; fun requestn(n)= strcat "USE" strbuild ("tr"::(_getress "License")::nil):: ("n"::(itoa n)::nil):: nil;;  fun clockevent(t,flags)= _fooS "### clockevent"; if pendingreq then nil else let getCookieIP "update" -> ip in if ip==nil then nil else if firstping==0 then (startreq flags ip portdirect strtoweb requestid nil 1; 0) else if nbapps then (startreq 0 ip portdirect strtoweb requestn nbapps nbapps 1; set nbapps=0; 0) else nil;; fun iniping()=  _rfltimer (_starttimer chn0 60000) @clockevent 0;; proto _logfile=fun[[S r1]] I;; var http_header="HTTP/1.0 200 OK\13\10Server: SCOL HTTP server\13\10Content-Type: text/html\13\10\13\10";; var http_headerb="HTTP/1.0 200 OK\13\10Server: SCOL HTTP server\13\10Content-Type: applicaton/x-unknown\13\10\13\10";; fun htmlbin3(l,res)= if l==nil then res else let l->[x n] in htmlbin3 n ((nameofpub x)::(ipofpub2 x)::nil)::res;; fun htmlbin2(l,res)= if l==nil then res else let l->[a n] in htmlbin3 a.pubRun htmlbin2 n res;; fun htmlbin()= strcat http_headerb strbuild ("name"::(_getress "DefaultName")::nil)::htmlbin2 running nil;; fun htmldir3(l,res)= if l==nil then res else let l->[x n] in htmldir3 n "<a href=\""::(ipofpub2 x)::"\">"::(nameofpub x)::"</a><br>"::res;; fun htmldir2(l,res)= if l==nil then res else let l->[a n] in htmldir3 a.pubRun htmldir2 n res;; fun htmldir()= strcatn http_header::"<H1>"::(_getress "DefaultName")::" 's Scol Services</H1><br>\n"::htmldir2 running nil;; fun htmlreq(con,name)= let searchpub running name -> x in strcat http_header if x==nil then if getservhttp==nil then "OFF" else exec getservhttp with [con name] else ipofpub x;; fun htmlreqbin(name)= let searchpub running name -> x in strcat http_headerb if x==nil then "OFF" else ipofpub x;; fun cbprox(inet,z,s,reason)= let z->[con url flag] in ( if reason==0 then ( HTTPsend con s; 0) else (closeHTTPcon con; 0));; fun cbclose_http(con,reqhttp)=INETStopURL reqhttp;; fun htmlproxy(com,url,con,req)= if (nth_char url 6)=='C then _logfile "proxy"::(getHTTPclientIP con)::(itoa time)::nil else nil; if !strcmpi com "GET" then let INETGetURL chn0 strcatn "http://127.0.0.1:"::(itoa htoi substr url 1 4)::url::nil 1 @cbprox [con url 0] -> httpreq in if httpreq==nil then "" else (rflHTTPclose con @cbclose_http httpreq;nil) else let INETGetURLex chn0 com strcatn "http://127.0.0.1:"::(itoa htoi substr url 1 4)::url::nil (substr req (4+strfind "\13\10\13\10" req 0) strlen req) 1 @cbprox [con url 0] -> httpreq in if httpreq==nil then "" else (rflHTTPclose con @cbclose_http httpreq;nil);; fun http_onrequest(con,x,req)=  let hd strextr req -> l in let l->[com [url _]] in if ((nth_char url 0)=='/)&&((nth_char url 5)=='?) then htmlproxy com url con req else if (!strcmpi com "GET") then if !strcmp url "/" then htmldir else if !strcmp url "/?" then htmlbin else if !strcmp substr url 0 2 "/?" then htmlreqbin substr url 2 strlen url else htmlreq con substr url 1 strlen url else "";;  fun launchHTTP(listport)= if listport==nil then 0 else let listport -> [p n] in ( startHTTPserver chn0 atoi p @http_onrequest nil; launchHTTP n ) ;; fun main(p)= srand time; set chn0=_channel; multiress strextr _loadressini; set voyagerDebugMode=let _getress "voyagerDebugMode" -> n in if n==nil then 0 else atoi n;  _setLocalIPnumber atoi _getress "localIPindex"; reinitloc; set port=p; _load "locked/stdsrvlog.pkg"; if (_setserver _envchannel chn0 p "_load \"locked/stdsrvlog2.pkg\"")==nil then _closemachine else (if _isFirstScol!=2 then SplashShow else nil; iniping; initcustserv;  set onLineIconbmp=_LDbitmap chn0 _checkpack if _platform==1 then onLineIconS else onLineIconUnix; set offLineIconbmp=_LDbitmap chn0 _checkpack if _platform==1 then offLineIconS else offLineIconUnix; set icon=_CRtaskIcon2 chn0 offLineIconbmp strcat strcat loc "SE" " - " _versionname; _CBtaskIconClick icon @callmenu 0; _CBtaskIconDClick icon @dclicktask 0; createmenus; launch nil servics; if !strcmpi _getress "AutoSetup" "yes" then (chgress "AutoSetup" "No"; set firsttime=1) else nil; if nil==_getress "License" then chgress "License" strcat _getress "Origin" BigToAsc BigRand else nil; _movecache _getress "License"; startHTTPserver chn0 p-1 @http_onrequest nil; launchHTTP getInfos (strextr _loadusmini nil) "porthttp";  set _masterchannel=chn0; if !strcmpi _getress "LaunchCommutron" "no" then nil else set chnComm=_openchannel nil "_load \"locked/lib/loc.pkg\"\n_load \"comm/stdlib.pkg\"\n_load \"comm/COMUTRON1.PKG\"\nMain NIL NIL 0" nil; startDNSres;  _recontact;  0) ;; fun _killedrun(r,x)= if cbkilled==nil then nil else exec cbkilled with [r x];  set running=remove_from_list running r; if x && r.scriptRun != nil && (_channeltime _channel)>20 then launchscript r.scriptRun else nil; createmenus;; fun _killed(x)= let search_in_list running @runbychan _channel -> r in if r==nil then nil else _killedrun r x;; fun _closed()= _killed 1;; fun __norestart(x)= let search_in_list running @runbychan _channel -> r in (set r.scriptRun=nil; set r.nameRun="norestart");; fun filter()= let _fooS _channelIP _channel -> ip in if (strcmp ip "127.0.0.1") && (strcmp ip _hostIP) && (strcmp ip "unplugged")then 1 else 0;; fun __register(s)= if filter then nil else (if !strcmp s "vgh" then nil else set nbapps=nbapps+1; if (!strcmp substr s 0 2 "__") && (nil!=search_in_list running @runbyname s) then _killchannel _channel else ( let search_in_script servics @srvbyname s -> p in set running=(mkRun[strcat s (if p==nil then "" else " *") _channel p nil nil currunnum])::running; set currunnum=currunnum+1; createmenus ) ) ;; fun __setsite(s)= if filter then nil else _settextsite s;; fun __goto(s)= if filter then nil else (_settextsite s; _closechannel; contact s nil; _closed) ;; fun __open(s)= if filter then nil else (_settextsite s; contact s nil) ;; fun __gotoR(s,r)= if filter then nil else (_settextsite s; _closechannel; contact s r; _closed) ;; fun _openR(s,r)= if filter then nil else (_settextsite s; contact s r) ;; fun __public(s,p)= if filter then nil else let search_in_list running @runbychan _channel -> r in (if (sizelist r.pubRun)>9 then nil else set r.pubRun=[s p nil]::r.pubRun; if cbpublic==nil then nil else exec cbpublic with [s p]; createmenus) ;; fun __publicHTTP(s,p)= if filter then nil else let search_in_list running @runbychan _channel -> r in (if (sizelist r.pubRun)>9 then nil else set r.pubRun=[strcat s "-via_http" nil p]::r.pubRun; if cbpublichttp==nil then nil else exec cbpublichttp with [s p]; createmenus) ;; fun public(s,p)= set running=(mkRun ["Commutron" nil nil [s p nil]::nil nil nil])::running; createmenus ;; fun localinfos2(x,a)= let x->[name _ http] in _on _channel Cservice [name ipofpub2 x];; fun localinfos(r,x)= apply_on_list r.pubRun @localinfos2 nil;; fun __infos()= apply_on_list running @localinfos 0 ;; fun __getserv(s)= let searchpub running s -> x in if x==nil && getservdirect!=nil then exec getservdirect with [s] else _on _channel Cservis [s ipofpub x];; fun _addc(x,s,r)= if r then (_storepack strcat s _getpack _checkpack "locked/etc/custom.txt" "locked/etc/custom.txt"; initcustserv; createmenus; 0) else nil;; fun __addcustom(s)= if filter || (search_in_script customs @srvbyname s)!=nil then nil else _DLGrflmessage _DLGMessageBox chn0 mainWin.win loc "ADSRV" strloc loc "ADSM" s::nil 2 @_addc s;; fun _addb(x,s,r)= if r then if s==nil || (strlen s)<1 then 0 else let hd strextr s ->[a[b _]] in (set book=(a::b::nil)::book; savebookmark; createmenus; 0) else nil;; fun __addbookmark(s)= if filter then nil else _DLGrflmessage _DLGMessageBox chn0 mainWin.win loc "ADBK" strloc loc "ADBK?" s::nil 2 @_addb s;; fun _addres(x,s,r)= if r then let s->[a b] in chgress a b else nil;; fun __address(a,b)= if filter then nil else _DLGrflmessage _DLGMessageBox chn0 mainWin.win loc "ADRS" strloc loc "ADRS?" a::b::nil 2 @_addres [a b];; fun _restartUpd2(T,u)= _deltimer T;  _checkUpdate nil flagUpdContact|flagUpdMsg ;; fun __restartUpd(adr)= if filter then nil else (  _storepack adr UpdAdr;  _closechannel; let getCookieIP "update" -> ip in if ip==nil then (  forceUpdateDNSres; _rfltimer _starttimer chn0 5000 @_restartUpd2 nil; 0 ) else _restartUpd2 nil nil; _closed ) ;;