READ THE RULES
0 Members and 1 Guest are viewing this topic.
--[[ PxWeb 1.0c LUA 5.11 [Strict] [API 2] By Mutor 07/21/07 Generates HTML pages for use with PtokaX/Other Web Server -A total rewrite of pxstats You can use this single script to: ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ - Generates all required folders and files with no user intervention required. - Display online users, recent chat, top shares, top uptimes, hub stats and file downloads. - Offer file downloads by merely copying files to the download folder and restarting script. - Display a list of hopefully useful web and dchub links. - Provide an E-Mail contact link for users that may have been banned for bad pass etc. - Edit site-wide style and colors through cascading style sheet. - Provides MainText parameter which allows you to display text file on the main page. - Provides Ad, a quickly ammenadable parameter that is appended to the text of MainText. - Both MainText and Ad may contain escaped HTML code [links, images, email, etc.] Note: This script will overwrite any existing files of the same name. Backup your existing web server files if this is of concern to you. Users that haven't used the Px web server , just set the server port on PtokaX -> Options tab, enable the server there and start the script. Changes from 1.0 08/03/07 +Added user commands and context menus [right click] *User commands sent with ZPipe [saves b/w] +Added command permission by profile per command +Added report 'option' for status messages +Added ASCII table & function +Added startup and connect message +Added error logging ~Fixed bum link to LUA-Users Wiki Changes from 1.0b 10/13/07 +Converted for the new PtokaX API]]local Web = {-- Name of hub ownerOwner = "Mutor",-- Send status / error messages to Admin nick? "on"/"off" [If = "on", set OpNick]Report = "on",-- Admins nick for status / error messages [Report must = "on"]OpNick = "Mutor",-- Advert to display to all at startup and each new connection ["" = disabled]Addy = "Please visit the hub's web site at http://mutor.no-ip.com:415",-- Botname pulled from the hub or use "CustomName"Bot = SetMan.GetString(21),-- Bot descriptionDesc = "I generate HTML for the hub's web server.",-- Bot/Website email addressMail = "admin@mutor.no-ip.com",-- Text file that will be displyed in main frame of homepage-- [This path/file should reside in PtokaX folder in root or subdirectory]-- Note: This file may contain [escaped LUA 'magic' chars] HTML code-- ie. - "\<br\>\<a href=\"http://www.yourlink.com/image.jpg\">Image\</a\>"MainText = "cfg/motd.txt",-- Addendum to the MainText [will appear at end of file]. "" = disable-- This text may contain [escaped LUA 'magic' chars] HTML codeAd = "\<br\>\<a href=\"http://validator.w3.org/\"\>\n".."\<img src=\"http://www.w3.org/Icons/valid-html401-blue\" ".."alt=\"Valid HTML 4.01 Frameset\" height=\"31\" width=\"88\" border=\"0\"\>\</a\>",--"\n\<br\>\n\<img src=\"http://www.w3.org/Icons/valid-html401-blue\"\>\</a\>",-- Links to display on the menu [idx] = {"http://linkaddress.com","Link Text"},Links = { [1] = {"http://ptokax.ath.cx/index.html","PtokaX DC Hub"}, [2] = {"http://bugtracker.ptokax.ath.cx/","The PtokaX Bugtracker"}, [3] = {"http://luaboard.sytes.net/index.php","The PtokaX Portal"}, [4] = {"http://uknnet.com/lua/index.php","The PtokaX LUA Board"}, [5] = {"http://wiki.ptokax.ath.cx/doku.php?id=homepage","The PtokaX Wiki"}, [6] = {"#","Hub Links:"}, [7] = {"dchub://ptokax-lua.damnserver.com:2006","PtokaX Admins Hub"}, --You can make a seperator like this [idx] = {"#","Separator Text"}, [8] = {"#","Reference:"}, [9] = {"http://www.lua.org/","LUA Home Page"}, [10] = {"http://www.lua.org/manual/5.1/","LUA 5.1 Ref. Manual"}, [11] = {"http://lua-users.org/wiki/","LUA-Users Wiki"}, [12] = {"http://luaforge.net/","LuaForge"}, [13] = {"http://validator.w3.org/","Validate This Page's HTML"}, },--Short message for new loginsGreeting = "Welcome [usr]. It's nice of you to stop by...",--Basic CSS Settings, use color codes or friendly color names--See DoCss function for extended CSS settingsStyle = { --Font Family font = "Verdana, Geneva, Arial, Helvetica, sans-serif", --Font Color fcolor = "Black", --Background Color bgcolor = "transparent", --Background Image (Path and Filename) bgimage = "",--images/bg.gif --Link Color lcolor = "Blue", --Visited Link Color vcolor = "Silver", --Link Hover Color hcolor = "Red", --Show Table Borders? "yes" = enabled /"no" = disabled tborder = "no", },}OnStartup = function() Web.Script,Web.HubPath,Web.Content = "PxWeb 1.0c",Core.GetPtokaXPath(),"motd.html" Web.Body,Web.Foot,Web.ErrLog,Web.Refresh = "\</head\>\n\<body\>\n","\</body\>\n\</html\>",{} Web.Downloads,Web.FileUrl,Web.Path = "..\\html\\webstats\\files","files","\\html\\webstats\\" Web.Url = ".."..Web.Path:gsub("\\","/") Web.Asc = { [34]=""",[38]="&",[39]="'",[60]="<",[62]=">",[94]="ˆ",[126]="˜",[127]="", [128]="€",[130]="‚",[131]="ƒ",[132]="„",[133]="…",[134]="†",[135]="‡", [136]="ˆ",[137]="‰",[138]="Š",[139]="‹",[140]="Œ",[142]="Ž",[145]="‘", [146]="’",[147]="“",[148]="”",[149]="•",[150]="–",[151]="—",[152]="˜", [153]="™",[154]="š",[155]="›",[156]="œ",[157]="Ť",[158]="ž",[159]="Ÿ", [160]=" ",[161]="ˇ",[162]="˘",[163]="Ł",[164]="¤",[165]="Ą",[166]="¦", [167]="§",[168]="¨",[169]="©",[170]="Ş",[171]="«",[172]="¬",[173]="­", [174]="®",[175]="Ż",[176]="°",[177]="±",[178]="²",[179]="ł",[180]="´", [181]="µ",[182]="¶",[183]="·",[184]="¸",[185]="ą",[186]="ş",[187]="»", [188]="Ľ",[189]="˝",[190]="ľ",[191]="ż",[192]="Ŕ",[193]="Á",[194]="Â", [195]="Ă",[196]="Ä",[197]="Ĺ",[198]="Ć",[199]="Ç",[200]="Č",[201]="É", [202]="Ę",[203]="Ë",[204]="Ě",[205]="Í",[206]="Î",[207]="Ď",[208]="Đ", [209]="Ń",[210]="Ň",[211]="Ó",[212]="Ô",[213]="Ő",[214]="Ö",[215]="×", [216]="Ř",[217]="Ů",[218]="Ú",[219]="Ű",[220]="Ü",[221]="Ý",[222]="Ţ", [223]="ß",[224]="à",[225]="á",[226]="â",[227]="ă",[228]="ä",[229]="ĺ", [230]="ć",[231]="ç",[232]="č",[233]="é",[234]="ę",[235]="ë",[236]="ě", [237]="í",[238]="î",[239]="ď",[240]="đ",[241]="ń",[242]="ň",[243]="ó", [244]="ô",[245]="ő",[246]="ö",[247]="÷",[248]="ř",[249]="ů",[250]="ú", [251]="ű",[252]="ü",[253]="ý",[254]="ţ",[255]="˙" } Web.Timer = TmrMan.AddTimer(60000) local r,e = os.rename("web","web") if e then if not e:find("Permission denied") then os.execute("md web") end end Initialize() DoCss() DoRoot(1) DoTabs(1) Web.Refresh = true Initialize,DoCss,DoRoot,Web.Links,Web.Style,Copy = nil,nil,nil,nil,nil,nil collectgarbage("collect") if Web.Addy ~= "" then Core.SendToAll("<"..Web.Bot.."> "..Web.Addy) end OnError(Web.Script.." has been started. Memory usage: "..string.format("%.2f Kb.",collectgarbage("count")))endOnExit = function() DoTabs(1,Web.Site[1]) local time = os.time() for _,v in ipairs(Times) do v[3] = (time - v[2]) + v[3] v[2] = time v[4] = 0 end SaveToFile(Web.Site[3][2],Shares,"Shares") SaveToFile(Web.Site[2][2],Chat ,"Chat") collectgarbage("collect") OnError(Web.Script.." has been stopped, freeing ".. string.format("%.2f Kb.",collectgarbage("count")).." of memory.")endOnError = function(msg) local stamp = os.date() table.insert(Web.ErrLog,{stamp,msg}) if Web.Report == "on" and Web.OpNick ~= "" then Core.SendToNick(Web.OpNick,"<"..Web.Bot.."> "..msg) endendOnTimer = function(Id) if Id == Web.Timer then SaveToFile(Web.Site[2][2],Chat ,"Chat") if next(Web.ErrLog) then SaveToFile("web/errlog.web",Web.ErrLog,"Web.ErrLog") Web.ErrLog = {} end DoTabs(1) collectgarbage("collect") endendUserConnected = function(user) DoTabs(1,Web.Site[1]) DoTabs(1,Web.Site[3]) DoTabs(1,Web.Site[4],user.sNick) Core.SendToNick(user.sNick,"<"..Web.Bot.."> "..Web.Greeting:gsub("%b[]",user.sNick)) if Web.Addy ~= "" then Core.SendToNick(user.sNick,"<"..Web.Bot.."> "..Web.Addy) end if user.iProfile ~= -1 then if GenCmds(user) then Core.SendToNick(user.sNick,"<"..Web.Bot.."> "..Web.Script.." commands enabled, see hub tab for more.") end endendOpConnected,RegConnected = UserConnected,UserConnectedUserDisconnected = function(user) DoTabs(1,Web.Site[1]) DoTabs(1,Web.Site[4],user.sNick)endOpDisconnected = UserDisconnectedChatArrival = function(user, data) local _,_,pfx = data:find("^%b<> (%p)%w+") if not pfx then local _,_,txt = data:find("^%b<> (.*)|$") if txt and txt:len() >= 2 then data = DoAscii(data:sub(1,-2)) local now = string.lower(os.date("[%I:%M %p]")) table.insert(Chat,{now,data}) if #Chat > 100 then table.remove(Chat,1) end end else local _,_,cmd = data:find("^%b<> %p(%a+)") if cmd then local str for i,v in ipairs(Web.Site) do if cmd:lower() == v[1]:lower() then if v[7][user.iProfile] and v[7][user.iProfile] == 1 then str = "\r\n\r\n\t"..v[4].."\r\n\t"..string.rep("¯",v[4]:len()).."\r\n" for idx,val in ipairs(v[6]()) do if cmd:lower() == "chat" or cmd:lower() == "hubstats" then str = str..val.."\r\n" else str = str.."\t"..idx.."\t"..val.."\r\n" end end str = str.."\r\n" return Core.SendPmToNick(user.sNick,Web.Bot,str),true else local prof if u.iProfile ~= -1 then prof = ProfMan.GetProfile(u.iProfile).sProfileName else prof = "Unregistered User" end local pfx = SetMan.GetString(29):sub(1,1) or "+" local msg = "Sorry "..user.sNick..", "..prof.."'s are ".. "not allowed use of the "..pfx..cmd:lower().." command." return Core.SendToNick(user.sNick,"<"..Web.Bot.."> "..msg), Core.SendPmToNick(user.sNick,Web.Bot,msg),true end end end end endendToArrival = ChatArrivalInitialize = function() local topic,desc = SetMan.GetString(10) or "",SetMan.GetString(5) or "" local HubApp,HubVer = "PtokaX", Core.Version Web.Root = { [1] = {"index.html","Index"}, [2] = {"top.html","Top"}, [3] = {"main.html","Main"}, [4] = {"bottom.html","Bottom"}, [5] = {"left.html","Menu"}, [6] = {"pxstyle.css","CSS"} } Web.Site = { [1] = {"Users","web/users.web","users.html","Online Users", function() local t,x = Core.GetOnlineUsers(),{} if t and next(t) then local s = " " s = s:rep(20) table.insert(x,{"\<b\>Profile\</b\>","\<b\>User Nick\</b\>"..s}) table.insert(x,{" "," "}) Users = {} for i,u in ipairs(t) do local p if u.iProfile ~= -1 then p = ProfMan.GetProfile(u.iProfile).sProfileName else p = "Unregistered User" end table.insert(x,{p,u.sNick}) table.insert(Users,{p,u.sNick}) end SaveToFile(Web.Site[1][2],Users,"Users") end return Web.Head..Web.Css.."\<meta http-equiv=\"refresh\" content=\"60\"\>\n".. Web.Body..GenTab(x,Web.Site[1][4],1)..Web.Foot end, function() local t = {} for i,v in ipairs(Users) do table.insert(t,table.concat(v," ")) end return t end, -- Adjust To Your Profiles [0 = disable / 1 = enable] {[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}}, [2] = {"Chat","web/chat.web","chat.html","Recent Chat", function() local t,x = Chat,{} if next(t) then table.insert(x,{"\<b\>Time\</b\>","\<b\>Chat Message\</b\>"}) table.insert(x,{" "," "}) for i,v in ipairs(t) do table.insert(x,{v[1],v[2]}) end end SaveToFile(Web.Site[2][2],Chat ,"Chat") return Web.Head..Web.Css.."\<meta http-equiv=\"refresh\" content=\"10\"\>\n".. Web.Body..GenTab(x,Web.Site[2][4],1)..Web.Foot end, function() local t = {} for i,v in ipairs(Chat) do table.insert(t,"\t"..v[1].." "..DoAscii(v[2],1):gsub("\r\n","%1\t\t ")) end return t end, -- Adjust To Your Profiles [0 = disable / 1 = enable] {[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}}, [3] = {"Shares","web/shares.web","shares.html","Top Shares", function() local t,x = Core.GetOnlineUsers(),{} if t and next(t) then local s = " " s = s:rep(20) table.insert(x,{"\<b\>User Nick\</b\>","\<b\>Share Value\</b\>"..s}) table.insert(x,{" "," "}) for i,u in ipairs(t) do if Core.GetUserAllData(u) then local exist if next(Shares) then for _,v in ipairs(Shares) do if v[1]:lower() == u.sNick:lower() then v[2] = u.iShareSize exist = true break end end end if not exist then table.insert(Shares,{u.sNick,u.iShareSize}) end end end table.sort(Shares, function(a,b)return a[2] > b[2] end) SaveToFile(Web.Site[3][2],Shares,"Shares") if next(Shares) then for z = 1, math.min(#Shares,10) do if Shares[z][2] > 0 then table.insert(x,{Shares[z][1],FmtSz(Shares[z][2])}) end end end end return Web.Head..Web.Css.."\<meta http-equiv=\"refresh\" content=\"60\"\>\n".. Web.Body..GenTab(x,Web.Site[3][4],1)..Web.Foot end, function() local t = {} for i,v in ipairs(Shares) do if v[2] > 0 then table.insert(t,FmtSz(v[2]).."\t\t"..v[1]) end end return t end, -- Adjust To Your Profiles [0 = disable / 1 = enable] {[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}}, [4] = {"Times","web/times.web","times.html","Top Uptimes", function(nick) local t,x,time = Core.GetOnlineUsers(),{},os.time() if t and next(t) or nick then table.insert(x,{"\<b\>User Nick\</b\>","\<b\>Uptime Value\</b\>"}) table.insert(x,{" "," "}) if nick then for _,v in ipairs(Times) do local z = 0 if v[1]:lower() == nick:lower() then exist = true if Core.GetUser(nick) then z = 1 v[2] = time v[4] = z else v[3] = (time - v[2]) + v[3] v[4] = z end break end end else for i,u in ipairs(t) do local exist for _,v in ipairs(Times) do if v[1]:lower() == u.sNick:lower() then exist = true if Web.Refresh then v[3] = (time - v[2]) + v[3] v[2] = time end v[4] = 1 break end end if not exist then table.insert(Times,{u.sNick,time,0,1}) end end end table.sort(Times, function(a,b)return a[3] > b[3] end) SaveToFile(Web.Site[4][2],Times,"Times") if next(Times) then for z = 1, math.min(#Times,10) do if (time - Times[z][3]) > 0 then table.insert(x,{Times[z][1],Convert(time - Times[z][3])}) end end end end return Web.Head..Web.Css.."\<meta http-equiv=\"refresh\" content=\"600\"\>\n".. Web.Body..GenTab(x,Web.Site[4][4],1)..Web.Foot end, function() local t,time = {},os.time() for i,v in ipairs(Times) do if v[2] > 0 and v[3] > 0 then table.insert(t,string.format("%-50.30s",v[1]).." \t•"..Convert(time - v[3])) end end return t end, -- Adjust To Your Profiles [0 = disable / 1 = enable] {[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}}, [5] = {"HubStats","web/stats.web","stats.html","Hub Statistics", function() local b,m = " ","Public, unregistered users welcome." local topic = SetMan.GetString(10) or "There is no current topic." local sr,hr,ss,hs = Chk(SetMan.GetNumber(8)),Chk(SetMan.GetNumber(7)),"slot","hub" if SetMan.GetBool(5) then m = "Private, registered users only." end if sr and type(sr) == "number" and sr > 1 then ss = ss.."s" end if hr and type(hr) == "number" and hr > 1 then hs = hs.."s" end local t = { [1] = {b.."Hub Name:",SetMan.GetString(0)}, [2] = {b.."Hub Desc.:",SetMan.GetString(5)..""}, [3] = {b.."Hub Topic:",topic..""}, [4] = {b.."Hub Time:",os.date("%B %d %Y %X")..""}, [5] = {b.."HubOwner:",Web.Owner..""}, [6] = {b.."Hub Uptime:",Convert(os.time() - Core.GetUpTime())..""}, [7] = {b.."Min Share:",FmtSz(SetMan.GetMinShare())..""}, [8] = {b.."Min Slots:",Chk(SetMan.GetNumber(5)).." per user."}, [9] = {b.."Max Slots:",Chk(SetMan.GetNumber(6)).." per user."}, [10] = {b.."Slot Ratio:",sr.." "..ss.." per "..hr.." "..hs.."."}, [11] = {b.."Max Hubs:",Chk(SetMan.GetNumber(9)).." per user."}, [12] = {b.."Peak Users:",Core.GetMaxUsersPeak()}, [13] = {b.."Hub Share:",FmtSz(Core.GetCurrentSharedSize())}, [14] = {b.."There Are:",#Core.GetOnlineUsers().." of a possible "..SetMan.GetNumber(0).." users online."}, [15] = {b.."Hub Mode:",m}, } table.insert(t,1,{" "," "}) SaveToFile(Web.Site[5][2],t ,Web.Site[5][1]) return Web.Head..Web.Css.."\<meta http-equiv=\"refresh\" content=\"60\"\>\n".. Web.Body..GenTab(t,Web.Site[5][4],1)..Web.Foot end, function() local t,time = {},os.time() for i,v in ipairs(HubStats) do if i > 1 then table.insert(t,"\t"..string.format("%-20.15s",v[1]:gsub(" "," ")).."\t•"..v[2]) end end return t end, -- Adjust To Your Profiles [0 = disable / 1 = enable] {[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}}, [6] = {"Downloads","web/files.web","files.html","File Downloads", function() if not Web.Refresh then local dirlist,path,url,t = "files.lst",Web.Downloads,Web.FileUrl,{} os.execute("dir "..path.." /o:gn > "..dirlist) Downloads = {} for line in io.lines(dirlist) do if line:find("^[%d]") and not line:find("%b<>") and not line:find("%b()") then for date,time,size,name in line:gmatch("(%S+)%s+([0-9:]+ [pPaAmM]+)%s+(%S+)%s+(.+)$") do time = time:gsub("%s%s+","") local ren = name:gsub(" ","_") os.rename(path.."\\"..name,path.."\\"..ren) table.insert(Downloads,{time,date,FmtSz(size:gsub("%,","")),"\<a href=\""..url.."/"..ren.."\"/>"..name.."\</a\>"}) table.insert(t,{time,date,FmtSz(size:gsub("%,","")),"\<a href=\""..url.."/"..ren.."\"/>"..name.."\</a\>"}) end end end os.remove(dirlist) table.insert(t,1,{"\<b\>Time\</b\>","\<b\>Date\</b\>","\<b\>Size\</b\>","\<b\>Name\</b\>"}) table.insert(t,2,{" "," "," "," "}) SaveToFile(Web.Site[6][2],Downloads,"Downloads") return Web.Head..Web.Css..Web.Body..GenTab(t,Web.Site[6][4],1)..Web.Foot end end, function() local t = {} for i,v in ipairs(Downloads) do local _,_,file = v[4]:find("%>(%S+)%</") if file then table.insert(t,file.."\t("..v[3]..")") end end return t end, -- Adjust To Your Profiles [0 = disable / 1 = enable] {[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}}, } Web.Head = "\<html\>\n\<head\>\n\<title\>"..SetMan.GetString(0).." - ‹›\</title\>\n".. "\<meta http-equiv=page-enter content=\"blendTrans(Duration=2)\"\>\n".. "\<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"\>\n".. "\<meta name=robots content=\"noindex,nofollow\"\>\n".. "\<meta http-equiv=pragma content=no-cache\>\n".. "\<meta http-equiv=\"content-type\" content=\"text/html; charset=iso-8859-1\"\>\n".. "\<link rel=\"shortcut icon\" href=\"favicon.ico\"\>\n" Web.Frame = "\<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\"\n".. "\"http://www.w3.org/TR/html4/frameset.dtd\"\>\n"..Web.Head Web.Head = "\<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n".. "\"http://www.w3.org/TR/html4/loose.dtd\"\>\n"..Web.Head Web.Css = "\<link rel=\"stylesheet\" href=\""..Web.Root[6][1].."\" type=\"text/css\"\>\n" --Index Web.Root[1][3] = Web.Frame.."\</head\>\n\<frameset rows=\"130,*,45\" cols=\"*\"\>\n".. "\<frame name=\"top\" src=\"top.html\" scrolling=\"no\" frameborder=\"0\"\>\n".. "\<frameset cols=\"200,800\" rows=\"*\" \>\n".. "\<frame name=\"menu\" src=\"left.html\" scrolling=\"no\" frameborder=\"0\"\>\n".. "\<frame name=\"contents\" src=\"main.html\" scrolling=\"no\" frameborder=\"0\"\>\n\</frameset\>\n".. "\<frame name=\"bottom\" scrolling=\"no\" noresize src=\"bottom.html\" frameborder=\"0\"\>\n".. "\<noframes\>\n\<p\>This document uses frames, but your browser doesn't support them.\</p\>\n".. "\</noframes\>\n\</frameset\>\n</html\>" --Top Web.Root[2][3] = Web.Head..Web.Css.."\</head\>\n\<body\>\n".. "\<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"\>\n".. "\<tr\>\n\<td class=\"table0\" align=\"left\"\>".. " \<script type=\"text/javascript\"\>document.write(Date())\</script\>\</td\>\n\</tr\>\n".. "\<tr\>\n\<td class=\"table1\" align=\"right\"\>"..HubApp.." "..HubVer..": "..desc.." \</td\>\n\</tr\>\n".. "\<tr align=\"center\" valign=\"top\"\>\n\<td class=\"table3\"\>\n\<div align=\"center\"\>\n\<h1\>".. SetMan.GetString(0).."\</h1\>\n\<h3\>..."..topic.."\</h3\>\n\</div\>\n\</td\>\n\</tr\>\n\</table\>\n".. Web.Foot --Main Web.Root[3][3] = Web.Head..Web.Css..Web.Body.. "\<table width=\"100%\" height=\"100%\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"\>\n".. "\<tr\>\<td class=\"table1\" valign=\"top\" align=\"left\"\>.:: "..Web.Root[3][2].." ::.\</td\>\n\</tr\>".. "\</table\>\n\<iframe name=\"main\" class=\"table2\" scrolling=yes width=\"100%\" ".. "height=\"400\" align=\"left\" frameborder=\"0\" src=\""..Web.Content.."\"\>\</iframe\>\n"..Web.Foot --Bottom Web.Root[4][3] = Web.Head..Web.Css..Web.Body.. "\<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"\>\n".. "\<tr\>\n\<td class=\"table1\" align=\"left\" colspan=\"2\" \>\</td\>\n\</tr\>\n\<tr\>\n".. "\<td class=\"table0\" align=\"center\" colspan=\"2\" \>\<script type=\"text/javascript\"\>".. "document.write(\"You're using: \"+navigator.appName+\" \"+navigator.appCodeName+\" \"+navigator.appVersion+\"\");\n".. "\</script\>\n\</td\>\n\</tr\>\n\</table\>\n"..Web.Foot --Left - Menu Web.Root[5][3] = Web.Head..Web.Css..Web.Body.. "\<table width=\"95%\" align=\"left\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"\>\n".. "\<tr\>\<td class=\"table1\"\>.:: Menu ::.\</td\>\</tr\>\n\<tr valign=\"top\"\>\n\<td class=\"table2\"\>".. "\<a href=\"#\" class=\"menu\" target=\"_self\"\>Navigation:\</a\>\n\<br\>\<a href=\"index.html\" target=\"_top\"\>Home\</a\>\n" for i,v in ipairs(Web.Site) do Web.Root[5][3] = Web.Root[5][3].."\<br\>\<a href=\"".. v[3].."\" target=\"main\"\>"..v[4].."\</a\>\n" end local t = { [1] = {"Connect to Hub","dchub://"..SetMan.GetString(2)..":"..SetMan.GetString(3):gsub("%;.*$","")}, [2] = {"Contact","mailto:"..Web.Mail.."?subject=About the "..SetMan.GetString(0).." website&body=Dear "..Web.Owner..","}, } t[2][2] = t[2][2]:gsub(" ","%%20") for i,v in ipairs(t) do Web.Root[5][3] = Web.Root[5][3].."\<br\>\<a href=\"".. v[2].."\" target=\"main\"\>"..v[1].."\</a\>\n" end Web.Root[5][3] = Web.Root[5][3].."\<br\>\<a href=\"#\" class=\"menu\" target=\"_self\"\>Web Links:\</a\>\n" for i,v in ipairs(Web.Links) do local url = v[1]:gsub(" ","%%20") Web.Root[5][3] = Web.Root[5][3].."\<br\>\<a href=\""..url.."\" " if v[1] == "#" or v[1]:find("dchub://") then if v[1] == "#" then Web.Root[5][3] = Web.Root[5][3].."class=\"menu\" " end Web.Root[5][3] = Web.Root[5][3].."target=\"_self\"\>" else Web.Root[5][3] = Web.Root[5][3].."target=\"_blank\"\>" end Web.Root[5][3] = Web.Root[5][3]..v[2].."\</a\>\n" end Web.Root[5][3] = Web.Root[5][3].."\</td\>\</tr\>\n\</table\>\n"..Web.Foot local HubDir = Web.HubPath:gsub("/","\\\\") local tab = {} for dir in string.gmatch(Web.Path.."images\\","(%a+)\\") do table.insert(tab,dir) end local CheckDir = HubDir..table.concat(tab,"\\\\") if not os.rename(CheckDir,CheckDir) then for _,folder in ipairs(tab) do HubDir = HubDir..folder if not os.rename(HubDir,HubDir) then os.execute("md "..HubDir) HubDir = HubDir.."\\\\" end end end Copy(Web.HubPath..Web.MainText,Web.HubPath.."html/webstats/"..Web.Content) local FileDir,FirstStart = Web.HubPath:gsub("/","\\\\")..Web.Path.."files",true local r,e = os.rename(FileDir,FileDir) if e then if not e:find("Permission denied") then os.execute("md "..FileDir) end else FirstStart = false end local sample = Web.HubPath.."html/webstats/files/Setting_Up_Downloads.txt" if FirstStart and not os.rename(sample,sample) then local directions = "Simply copy your files to this folder ".. "[ Default = C:\\Ptokax\\html\\webstats\\files ]\nThen restart this ".. "script and reload the dowloads page to see the new files you've added.\n".. "You may delete this file at any time.\r\n\r\n"..string.rep(string.char(9),6).." -Mutor" local f,e = io.open(sample,"w") if f then f:write(directions) f:flush() f:close() else OnError(e:sub(1,-2)) end endendGenTab = function(t,s,noidx) local txt = "\<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"\>\n" if s then txt = txt.."\t\<tr\>\<td class=\"table0\" valign=\"top\"\>.:: "..s.." ::.\</td\>\</tr\>\</table\>\n" else txt = txt.."\t\<tr\>\<td class=\"table0\" valign=\"top\"> \</td\>\</tr\>\n" end txt = txt.."\<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"\>" if next(t) then for i,v in ipairs(t) do if noidx then txt = txt.."\n\t\<tr height=\"12\" align=\"left\" valign=\"top\"\>" else txt = txt.."\n\t\<tr height=\"12\" align=\"left\" valign=\"top\"\>".. "\<td class=\"table3\" width=\"5\"%\> "..i.."\</td\>" end if type(v) == "table" then local z = #v for x=1, z do if x < z then txt = txt.."\<td class=\"table3\" width=\""..(12*x).. "%\"\> "..v[x].."\</b\></td\>" else local s = (100 - (x*12)) txt = txt.."\<td class=\"table3\"width=\""..s.."%\"\> "..v[x].."\</td\>" end end else txt = txt.."\<td class=\"table3\" width=\"90\"%\> "..v.."\</td\>" end end txt = txt.."\</tr\>\n" else txt = txt.."\t\<tr\>\<td\> No\</td\>\n\<td\>Data\</td\>\n\</tr\>\n" end txt = txt.."\</table\>\n\<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"\>\n".. "\t\<tr\>\<td class=\"table2\" valign=\"top\">\</td\>\</tr\>\n\</table\>\n" return txtendDoHtml = function(file,title,body) local method = "updated" if not os.rename(file,file) then method = "saved" end body = body:gsub("%b‹›",title) local f,e = io.open(file,"w") if f then if not Web.Refresh then OnError(title.." has been "..method) end f:write(body) f:flush() f:close() else OnError(e:sub(1,2)) endendDoRoot = function(x) for i,v in ipairs(Web.Root) do if v[3] then if x or not os.rename(Web.Url..v[1],Web.Url..v[1]) then DoHtml(Web.Url..v[1],v[2],v[3]) end end endendDoTabs = function(x,t,n) if x and t and n then if t[5] then local html = t[5](n) if html then DoHtml(Web.Url..t[3],t[4],html) end end else for i,v in ipairs(Web.Site) do local tab = v[1] if loadfile(v[2]) then dofile(v[2]) if v[1] == "Chat" and next(Chat) then if Chat[1][3] then local t = {} for i,v in ipairs(Chat) do table.insert(t,{v[1],"<"..v[2].."> ".. DoAscii(v[3]:gsub("•",""))}) end Chat = t end SaveToFile(Web.Site[2][2],Chat ,"Chat") end else tab = {} SaveToFile(v[2],tab,v[1]) dofile(v[2]) end if x or not os.rename(Web.Url..v[3],Web.Url..v[3]) then if v[5] then local html = v[5]() if html then DoHtml(Web.Url..v[3],v[4],html) end end end end endendDoCss = function() local css = "body {\n".. "\tcolor: "..Web.Style.fcolor..";\n".. "\tfont-family: "..Web.Style.font..";\n".. "\tbackground-image: url("..Web.Style.bgimage..");\n".. "\tbackground-repeat: repeat;\n".. "\tbackground-color: "..Web.Style.bgcolor..";\n".. "}\n".. "a:link {\n".. "\tcolor: "..Web.Style.lcolor..";\n".. "\ttext-decoration: none;\n".. "}\n".. "a:visited {\n".. "\tcolor: "..Web.Style.vcolor..";\n".. "\ttext-decoration: none;\n".. "}\n".. "a:hover {\n".. "\tcolor: "..Web.Style.hcolor..";\n".. "\ttext-decoration: underline overline;\n".. "}\n".. "a.menu:link {\n".. "\tcolor: #E9E9F8;\n".. "\ttext-decoration: none;\n".. "\twidth: 100%;\n".. "\tbackground: #1E2580;\n".. "}\n".. ".table0 {\n".. "\theight: 12px;\n".. "\tcolor: #E9E9F8;\n".. "\tfont-size : 12px;\n".. "\tbackground-color : #1E2580;\n" if Web.Style.tborders == "yes" then css = css.."\tborder-top: 1px solid #8784C6;\n".. "\tborder-bottom: 1px solid #8784C6;\n".. "\tborder-left: 1px solid #8784C6;\n".. "\tborder-right: 1px solid #8784C6;\n" end css = css.."}\n".. ".table1 {\n".. "\theight: 12px;\n".. "\ttext-indent: 5px;\n".. "\tcolor : White;\n".. "\tfont-size : 12px;\n".. "\tbackground : #8784C6;\n" if Web.Style.tborders == "yes" then css = css.."\tbackground-color : #8784C6;\n".. "\tborder-bottom: 2px solid Black;\n".. "\tborder-left: 1px solid Black;\n".. "\tborder-right: 1px solid Black;\n".. "\tborder-top: 1px solid Black;\n" end css = css.."}\n".. ".table2 {\n".. "\theight: 400px;\n".. "\twidth: 100%;\n".. "\tcolor: Black;\n".. "\tfont-size: 12px;\n".. "\tbackground: #E9E9F8;\n" if Web.Style.tborders == "yes" then css = css.."\tborder-top: 1px solid #8784C6;\n".. "\tborder-bottom: 1px solid #8784C6;\n".. "\tborder-left: 1px solid #8784C6;\n".. "\tborder-right: 1px solid #8784C6;\n" end css = css.."}\n".. ".table3 {\n".. "\theight: 12px;\n".. --"\twidth: auto;\n".. "\tcolor: Black;\n".. "\tfont-size: 12px;\n".. "\tbackground: #E9E9F8;\n" if Web.Style.tborders == "yes" then css = css.."\tborder-top: 1px solid #8784C6;\n".. "\tborder-bottom: 1px solid #8784C6;\n".. "\tborder-left: 1px solid #8784C6;\n".. "\tborder-right: 1px solid #8784C6;\n" end css = css.."}" local f,e = io.open(Web.Url..Web.Root[6][1], "w") if f then f:write(css) f:flush() f:close() else OnError(e:sub(1,-2)) endendfunction Chk(enable) if enable == "" or not enable then enable = "not set" end return enableendFmtSz = function(int) local i,u,x=tonumber(int) or 0,{"","K","M","G","T","P"},1 while i > 1024 do i,x = i/1024,x+1 end return string.format("%.2f %sB.",i,u[x])endConvert = function(time) time = time or 0 local s,x,n,tab = "",0,os.time(),{ [1] = {31556926,"year"}, [2] = {2592000,"month"}, [3] = {604800,"week"}, [4] = {86400,"day"}, [5] = {3600,"hour"}, [6] = {60,"minute"}, [7] = {1,"second"} } if time > 0 then if time < 2145876659 then if n > time then time = n - time for i,v in ipairs(tab) do if time > v[1] then x = math.floor(time/v[1]) if x > 1 then v[2] = v[2].."s" end if x > 0 then s = s..x.." "..v[2]..", " time = time-x*v[1] end end end end collectgarbage("collect") return s:sub(1,-3) else return "Invalid date or time supplied. [must be pre 12/31/2037]" end else return "No uptime recorded" endendCopy = function(source,target) local is,os,text local f,e = io.open(source) if f then text,is = f:read("*a"),f:seek("end") f:close() else OnError(e:sub(1,-2)) end if text then local f,e = io.open(target,"w") if f then text = Web.Head:gsub("%b‹›","MOTD")..Web.Css..Web.Body.. "\<table class=\"table2\" bgcolor=\"#E9E9F8\" width=\"100%\" ".. "border=\"0\" cellspacing=\"0\" cellpadding=\"0\"\>\n".. "\<tr\>\<td class=\"table3\" valign=\"top\"\>\n\<pre\>"..text..Web.Ad.."\</pre\>".. "\n\</td\>\</tr\>\n\</table\>\n"..Web.Foot f:write(text) f:flush() os = f:seek("end") f:close() else OnError(e:sub(1,-2)) end endend--Replace certain characters with html ASCII code & vice versaDoAscii = function(data,rev) if rev then for i,v in pairs(Web.Asc) do data = data:gsub(v,string.char(i)) end return data else for chr in data:gmatch(".") do local x = Web.Asc[string.byte(chr)] if x then data = data:gsub(chr,x) end end return data endendGenCmds = function(user) local c,t,x = "",{} local p,m,s = SetMan.GetString(29):sub(1,1),SetMan.GetString(0),Web.Script for i,v in ipairs(Web.Site) do if v[7][user.iProfile] and v[7][user.iProfile] == 1 then x = true c = c.."$UserCommand 1 1 "..m.."\\"..s.."\\".. v[4].."$<%[mynick]> "..p..v[1]:lower().."||" end end if x then Core.SendToNick(user.sNick,c:sub(1,-2)) return x endendfunction Serialize(tTable, sTableName, sTab) sTab = sTab or "" sTmp = "" sTmp = sTmp..sTab..sTableName.." = {\n" for key, value in ipairs(tTable) do local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key) if(type(value) == "table") then sTmp = sTmp..Serialize(value, sKey, sTab.."\t") else local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value) sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue end sTmp = sTmp..",\n" end sTmp = sTmp..sTab.."}" return sTmpendfunction SaveToFile(file , table , tablename) local handle = io.open(file,"w") handle:write(Serialize(table, tablename)) handle:flush() handle:close()end
where my hubname is: ...it use all my ports so the link do not work...
Web.Downloads,Web.FileUrl,Web.Path = "..\\html\\webstats\\files","files","\\html\\webstats\\"
[20071124 - 22:46:32] <Twisted's-Soul> Index has been updated[20071124 - 22:46:32] <Twisted's-Soul> Top has been updated[20071124 - 22:46:32] <Twisted's-Soul> Main has been updated[20071124 - 22:46:32] <Twisted's-Soul> Bottom has been updated[20071124 - 22:46:32] <Twisted's-Soul> Menu has been updated[20071124 - 22:46:32] <Twisted's-Soul> Online Users has been updated[20071124 - 22:46:32] <Twisted's-Soul> Recent Chat has been updated[20071124 - 22:46:32] <Twisted's-Soul> Top Shares has been updated[20071124 - 22:46:32] <Twisted's-Soul> Top Uptimes has been updated[20071124 - 22:46:32] <Twisted's-Soul> Hub Statistics has been updated[20071124 - 22:46:32] <Twisted's-Soul> File Downloads has been updated
Downloads = {}
It is better to remain silent and be thought a fool than to speak up and remove all doubt.-Abe Lincoln
--[[ PxWeb 1.0d LUA 5.11 [Strict] [API 2] By Mutor 07/21/07 Generates HTML pages for use with PtokaX/Other Web Server -A total rewrite of pxstats You can use this single script to: ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ - Generates all required folders and files with no user intervention required. - Display online users, recent chat, top shares, top uptimes, hub stats and file downloads. - Offer file downloads by merely copying files to the download folder and restarting script. - Display a list of hopefully useful web and dchub links. - Provide an E-Mail contact link for users that may have been banned for bad pass etc. - Edit site-wide style and colors through cascading style sheet. - Provides MainText parameter which allows you to display text file on the main page. - Provides Ad, a quickly ammenadable parameter that is appended to the text of MainText. - Both MainText and Ad may contain escaped HTML code [links, images, email, etc.] Note: This script will overwrite any existing files of the same name. Backup your existing web server files if this is of concern to you. Users that haven't used the Px web server , just set the server port on PtokaX -> Options tab, enable the server there and start the script. Changes from 1.0 08/03/07 +Added user commands and context menus [right click] *User commands sent with ZPipe [saves b/w] +Added command permission by profile per command +Added report 'option' for status messages +Added ASCII table & function +Added startup and connect message +Added error logging ~Fixed bum link to LUA-Users Wiki Changes from 1.0b 10/13/07 +Converted for the new PtokaX API Changes from 1.0c 10/13/07 + Added PxLuaFileSystem extension library to avoid shell pop ups. + Added target frame option for links ***Notes: This script requires the PXLuaFileSystem extension library. It will not run without it. You can get it and others here: http://ptokax.ath.cx/libs.html]]local Web = {-- Set MOTD ? string or falseMotd = false,--"WebReg 1.1.1.7 serving PxWeb 1.0d launched by PtokaX "..Core.Version.." running ".._VERSION,-- Name of hub ownerOwner = "Mutor",-- Send status / error messages to Admin nick? "on"/"off" [If = "on", set OpNick]Report = "on",-- Admins nick for status / error messages [Report must = "on"]OpNick = "Mutor",-- Advert to display to all at startup and each new connection ["" = disabled]Addy = "Please visit the hub's web site at http://mutor.no-ip.com:6803/",-- Botname pulled from the hub or use "CustomName"Bot = SetMan.GetString(21),-- Bot descriptionDesc = "I generate HTML for the hub's web server.",-- Bot/Website email addressMail = "admin@mutor.no-ip.com",-- Text file that will be displyed in main frame of homepage-- [This path/file should reside in PtokaX folder in root or subdirectory]-- Note: This file may contain [escaped LUA 'magic' chars] HTML code-- ie. - "<br><a href=\"http://www.yourlink.com/image.jpg\">Image</a>"MainText = "cfg/motd.txt",-- Addendum to the MainText [will appear at end of file]. "" = disable-- This text may contain [escaped LUA 'magic' chars] HTML codeAd = "<br> <a href=\"http://validator.w3.org/\">\n".."<img src=\"http://www.w3.org/Icons/valid-html401-blue\" ".."alt=\"Valid HTML 4.01 Frameset\" height=\"31\" width=\"88\" border=\"0\"></a>",--"\n<br>\n<img src=\"http://www.w3.org/Icons/valid-html401-blue\"></a>",-- Links to display on the menu [idx] = {"http://linkaddress.com","Link Text",target frame},Links = { --{"/register.htm","Register in "..SetMan.GetString(0),"main"}, {"/files/index.htm","Dynamic Downloads","main"}, {"#","PtokaX Links:"}, {"http://ptokax.ath.cx/index.html","PtokaX DC Hub"}, {"http://luaboard.sytes.net/index.php","The PtokaX Portal"}, {"http://uknnet.com/lua/index.php","The PtokaX LUA Board"}, --{"http://wiki.ptokax.ath.cx/doku.php?id=homepage","The PtokaX Wiki"}, {"#","Hub Links:"}, {"dchub://ptokax-lua.damnserver.com:2006","PtokaX Admins Hub"}, --You can make a seperator like this [idx] = {"#","Separator Text"}, {"#","Reference:"}, {"http://www.lua.org/","LUA Home Page"}, {"http://www.lua.org/manual/5.1/","LUA 5.1 Ref. Manual"}, {"http://lua-users.org/wiki/","LUA-Users Wiki"}, {"http://luaforge.net/","LuaForge"}, --{"http://validator.w3.org/","Validate HTML"}, },--Short message for new loginsGreeting = "Welcome [usr]. It's nice of you to stop by...",--Basic CSS Settings, use color codes or friendly color names--See DoCss function for extended CSS settingsStyle = { --Font Family font = "Verdana, Geneva, Arial, Helvetica, sans-serif", --Font Color fcolor = "Black", --Background Color bgcolor = "transparent", --Background Image (Path and Filename) bgimage = "",--images/bg.gif --Link Color lcolor = "Blue", --Visited Link Color vcolor = "Silver", --Link Hover Color hcolor = "Red", --Show Table Borders? "yes" = enabled /"no" = disabled tborder = "no", },}require"pxlfs"assert(lfs._VERSION)OnStartup = function() Web.Script,Web.HubPath,Web.Content = "PxWeb 1.0d",Core.GetPtokaXPath(),"motd.html" Web.Body,Web.Foot,Web.ErrLog,Web.Refresh = "</head>\n<body>\n","</body>\n</html>",{} Web.Path,Web.Downloads,Web.FileUrl = "web/","web/files","files" Web.Url = Web.HubPath..Web.Path if Web.Motd and SetMan.GetMOTD() ~= Web.Motd then SetMan.SetMOTD(Web.Motd) SetMan.Save() end Web.Asc = { [34]=""",[38]="&",[39]="'",[60]="<",[62]=">",[94]="ˆ",[126]="˜",[127]="", [128]="€",[130]="‚",[131]="ƒ",[132]="„",[133]="…",[134]="†",[135]="‡", [136]="ˆ",[137]="‰",[138]="Š",[139]="‹",[140]="Œ",[142]="Ž",[145]="‘", [146]="’",[147]="“",[148]="”",[149]="•",[150]="–",[151]="—",[152]="˜", [153]="™",[154]="š",[155]="›",[156]="œ",[157]="Ť",[158]="ž",[159]="Ÿ", [160]=" ",[161]="ˇ",[162]="˘",[163]="Ł",[164]="¤",[165]="Ą",[166]="¦", [167]="§",[168]="¨",[169]="©",[170]="Ş",[171]="«",[172]="¬",[173]="­", [174]="®",[175]="Ż",[176]="°",[177]="±",[178]="²",[179]="ł",[180]="´", [181]="µ",[182]="¶",[183]="·",[184]="¸",[185]="ą",[186]="ş",[187]="»", [188]="Ľ",[189]="˝",[190]="ľ",[191]="ż",[192]="Ŕ",[193]="Á",[194]="Â", [195]="Ă",[196]="Ä",[197]="Ĺ",[198]="Ć",[199]="Ç",[200]="Č",[201]="É", [202]="Ę",[203]="Ë",[204]="Ě",[205]="Í",[206]="Î",[207]="Ď",[208]="Đ", [209]="Ń",[210]="Ň",[211]="Ó",[212]="Ô",[213]="Ő",[214]="Ö",[215]="×", [216]="Ř",[217]="Ů",[218]="Ú",[219]="Ű",[220]="Ü",[221]="Ý",[222]="Ţ", [223]="ß",[224]="à",[225]="á",[226]="â",[227]="ă",[228]="ä",[229]="ĺ", [230]="ć",[231]="ç",[232]="č",[233]="é",[234]="ę",[235]="ë",[236]="ě", [237]="í",[238]="î",[239]="ď",[240]="đ",[241]="ń",[242]="ň",[243]="ó", [244]="ô",[245]="ő",[246]="ö",[247]="÷",[248]="ř",[249]="ů",[250]="ú", [251]="ű",[252]="ü",[253]="ý",[254]="ţ",[255]="˙" } Web.Timer = TmrMan.AddTimer(60000) local r,e = os.rename("web","web") if e and not e:lower():find("permission denied") then lfs.chdir(Web.HubPath.."scripts") lfs.mkdir("web") lfs.chdir(Web.HubPath) end Initialize() DoCss() DoRoot(1) DoTabs(1) Web.Refresh = true Initialize,DoCss,DoRoot,Web.Links,Web.Style,Copy = nil,nil,nil,nil,nil,nil collectgarbage("collect") if Web.Addy ~= "" then Core.SendToAll("<"..Web.Bot.."> "..Web.Addy) end OnError(Web.Script.." has been started. Memory usage: "..string.format("%.2f Kb.",collectgarbage("count")))endOnExit = function() DoTabs(1,Web.Site[1]) local time = os.time() for _,v in ipairs(Times) do v[3] = (time - v[2]) + v[3] v[2] = time v[4] = 0 end SaveToFile(Web.Site[3][2],Shares,"Shares") SaveToFile(Web.Site[2][2],Chat ,"Chat") collectgarbage("collect") OnError(Web.Script.." has been stopped, freeing ".. string.format("%.2f Kb.",collectgarbage("count")).." of memory.")endOnError = function(msg) local stamp = os.date() table.insert(Web.ErrLog,{stamp,msg}) if Web.Report == "on" and Web.OpNick ~= "" then Core.SendToNick(Web.OpNick,"<"..Web.Bot.."> "..msg) endendOnTimer = function(Id) if Id == Web.Timer then SaveToFile(Web.Site[2][2],Chat ,"Chat") if next(Web.ErrLog) then SaveToFile(Web.HubPath.."web/errlog.web",Web.ErrLog,"Web.ErrLog") Web.ErrLog = {} end DoTabs(1) collectgarbage("collect") endendUserConnected = function(user) DoTabs(1,Web.Site[1]) DoTabs(1,Web.Site[3]) DoTabs(1,Web.Site[4],user.sNick) Core.SendToNick(user.sNick,"<"..Web.Bot.."> "..Web.Greeting:gsub("%b[]",user.sNick)) if Web.Addy ~= "" then Core.SendToNick(user.sNick,"<"..Web.Bot.."> "..Web.Addy) end if user.iProfile ~= -1 then if GenCmds(user) then Core.SendToNick(user.sNick,"<"..Web.Bot.."> "..Web.Script.." commands enabled, see hub tab for more.") end endendOpConnected,RegConnected = UserConnected,UserConnectedUserDisconnected = function(user) DoTabs(1,Web.Site[1]) DoTabs(1,Web.Site[4],user.sNick)endOpDisconnected = UserDisconnectedChatArrival = function(user, data) local _,_,pfx = data:find("%b<> (["..SetMan.GetString(29).."])") local _,_,ctrl = data:find("%c") local _,_,sb = data:lower():find("is kicking because:",1,true) if not pfx and not ctrl and not sb then local _,_,txt = data:find("^%b<> (.*)|$") if txt and txt:len() >= 2 then data = DoAscii(data:sub(1,-2)) local now = string.lower(os.date("[%H:%M]")) table.insert(Chat,{now,data}) if #Chat > 100 then table.remove(Chat,1) end end else local _,_,cmd = data:find("^%b<> %p(%a+)") if cmd then local str for i,v in ipairs(Web.Site) do if cmd:lower() == v[1]:lower() then if v[7][user.iProfile] and v[7][user.iProfile] == 1 then str = "\r\n\r\n\t"..v[4].."\r\n\t"..string.rep("¯",v[4]:len()).."\r\n" for idx,val in ipairs(v[6]()) do if cmd:lower() == "chat" or cmd:lower() == "hubstats" then str = str..val.."\r\n" else str = str.."\t"..idx.."\t"..val.."\r\n" end end str = str.."\r\n" return Core.SendPmToNick(user.sNick,Web.Bot,str),true else local prof = "Unregistered User" if u.iProfile ~= -1 then prof = ProfMan.GetProfile(u.iProfile).sProfileName end local pfx = SetMan.GetString(29):sub(1,1) or "+" local msg = "Sorry "..user.sNick..", "..prof.."'s are ".. "not allowed use of the "..pfx..cmd:lower().." command." return Core.SendToNick(user.sNick,"<"..Web.Bot.."> "..msg), Core.SendPmToNick(user.sNick,Web.Bot,msg),true end end end end endendToArrival = ChatArrivalInitialize = function() local topic,desc = SetMan.GetString(10) or "",SetMan.GetString(5) or "" local HubApp,HubVer = "PtokaX", Core.Version Web.Root = { [1] = {"index.html","Index"}, [2] = {"top.html","Top"}, [3] = {"main.html","Main"}, [4] = {"bottom.html","Bottom"}, [5] = {"left.html","Menu"}, [6] = {"pxstyle.css","CSS"} } Web.Site = { [1] = {"Users","web/users.web","users.html","Online Users", function() local t,x = Core.GetOnlineUsers(),{} if t and next(t) then local s = " " s = s:rep(20) table.insert(x,{"<b>Profile</b>","<b>User Nick</b>"..s}) table.insert(x,{" "," "}) Users = {} for i,u in ipairs(t) do local p if u.iProfile ~= -1 then p = ProfMan.GetProfile(u.iProfile).sProfileName else p = "Unregistered User" end table.insert(x,{p,u.sNick}) table.insert(Users,{p,u.sNick}) end SaveToFile(Web.Site[1][2],Users,"Users") end return Web.Head..Web.Css.."<meta http-equiv=\"refresh\" content=\"60\">\n".. Web.Body..GenTab(x,Web.Site[1][4],1)..Web.Foot end, function() local t = {} for i,v in ipairs(Users) do table.insert(t,table.concat(v," ")) end return t end, -- Adjust To Your Profiles [0 = disable / 1 = enable] {[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}}, [2] = {"Chat","web/chat.web","chat.html","Recent Chat", function() local t,x = Chat,{} if next(t) then table.insert(x,{"<b>Time</b>","<b>Chat Message</b>"}) table.insert(x,{" "," "}) for i,v in ipairs(t) do table.insert(x,{v[1],v[2]}) end end SaveToFile(Web.Site[2][2],Chat ,"Chat") return Web.Head..Web.Css.."<meta http-equiv=\"refresh\" content=\"10\">\n".. Web.Body..GenTab(x,Web.Site[2][4],1)..Web.Foot end, function() local t = {} for i,v in ipairs(Chat) do table.insert(t,"\t"..v[1].." "..DoAscii(v[2],1):gsub("\r\n","%1\t\t ")) end return t end, -- Adjust To Your Profiles [0 = disable / 1 = enable] {[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}}, [3] = {"Shares","web/shares.web","shares.html","Top Shares", function() local t,x = Core.GetOnlineUsers(),{} if t and next(t) then local s = " " s = s:rep(20) table.insert(x,{"<b>User Nick</b>","<b>Share Value</b>"..s}) table.insert(x,{" "," "}) for i,u in ipairs(t) do if Core.GetUserAllData(u) then local exist if next(Shares) then for _,v in ipairs(Shares) do if v[1]:lower() == u.sNick:lower() then v[2] = u.iShareSize exist = true break end end end if not exist then table.insert(Shares,{u.sNick,u.iShareSize}) end end end table.sort(Shares, function(a,b)return a[2] > b[2] end) SaveToFile(Web.Site[3][2],Shares,"Shares") if next(Shares) then for z = 1, math.min(#Shares,10) do if Shares[z][2] > 0 then table.insert(x,{Shares[z][1],FmtSz(Shares[z][2])}) end end end end return Web.Head..Web.Css.."<meta http-equiv=\"refresh\" content=\"60\">\n".. Web.Body..GenTab(x,Web.Site[3][4],1)..Web.Foot end, function() local t = {} for i,v in ipairs(Shares) do if v[2] > 0 then table.insert(t,FmtSz(v[2]).."\t\t"..v[1]) end end return t end, -- Adjust To Your Profiles [0 = disable / 1 = enable] {[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}}, [4] = {"Times","web/times.web","times.html","Top Uptimes", function(nick) local t,x,time = Core.GetOnlineUsers(),{},os.time() if t and next(t) or nick then table.insert(x,{"<b>User Nick</b>","<b>Uptime Value</b>"}) table.insert(x,{" "," "}) if nick then for _,v in ipairs(Times) do local z = 0 if v[1]:lower() == nick:lower() then exist = true if Core.GetUser(nick) then z = 1 v[2] = time v[4] = z else v[3] = (time - v[2]) + v[3] v[4] = z end break end end else for i,u in ipairs(t) do local exist for _,v in ipairs(Times) do if v[1]:lower() == u.sNick:lower() then exist = true if Web.Refresh then v[3] = (time - v[2]) + v[3] v[2] = time end v[4] = 1 break end end if not exist then table.insert(Times,{u.sNick,time,0,1}) end end end table.sort(Times, function(a,b)return a[3] > b[3] end) SaveToFile(Web.Site[4][2],Times,"Times") if next(Times) then for z = 1, math.min(#Times,10) do if (time - Times[z][3]) > 0 then table.insert(x,{Times[z][1],Convert(time - Times[z][3])}) end end end end return Web.Head..Web.Css.."<meta http-equiv=\"refresh\" content=\"600\">\n".. Web.Body..GenTab(x,Web.Site[4][4],1)..Web.Foot end, function() local t,time = {},os.time() for i,v in ipairs(Times) do if v[2] > 0 and v[3] > 0 then table.insert(t,string.format("%-50.30s",v[1]).." \t•"..Convert(time - v[3])) end end return t end, -- Adjust To Your Profiles [0 = disable / 1 = enable] {[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}}, [5] = {"HubStats","web/stats.web","stats.html","Hub Statistics", function() local b,m = " ","Public, unregistered users welcome." local topic = SetMan.GetString(10) or "There is no current topic." local sr,hr,ss,hs = Chk(SetMan.GetNumber(8)),Chk(SetMan.GetNumber(7)),"slot","hub" if SetMan.GetBool(5) then m = "Private, registered users only." end if sr and type(sr) == "number" and sr > 1 then ss = ss.."s" end if hr and type(hr) == "number" and hr > 1 then hs = hs.."s" end local t = { [1] = {b.."Hub Name:",SetMan.GetString(0)}, [2] = {b.."Hub Desc.:",SetMan.GetString(5)..""}, [3] = {b.."Hub Topic:",topic..""}, [4] = {b.."Hub Time:",os.date("%B %d %Y %X")..""}, [5] = {b.."HubOwner:",Web.Owner..""}, [6] = {b.."Hub Uptime:",Convert(os.time() - Core.GetUpTime())..""}, [7] = {b.."Min Share:",FmtSz(SetMan.GetMinShare())..""}, [8] = {b.."Min Slots:",Chk(SetMan.GetNumber(5)).." per user."}, [9] = {b.."Max Slots:",Chk(SetMan.GetNumber(6)).." per user."}, [10] = {b.."Slot Ratio:",sr.." "..ss.." per "..hr.." "..hs.."."}, [11] = {b.."Max Hubs:",Chk(SetMan.GetNumber(9)).." per user."}, [12] = {b.."Peak Users:",Core.GetMaxUsersPeak()}, [13] = {b.."Hub Share:",FmtSz(Core.GetCurrentSharedSize())}, [14] = {b.."There Are:",#Core.GetOnlineUsers().." of a possible "..SetMan.GetNumber(0).." users online."}, [15] = {b.."Hub Mode:",m}, } table.insert(t,1,{" "," "}) SaveToFile(Web.Site[5][2],t ,Web.Site[5][1]) return Web.Head..Web.Css.."<meta http-equiv=\"refresh\" content=\"60\">\n".. Web.Body..GenTab(t,Web.Site[5][4],1)..Web.Foot end, function() local t,time = {},os.time() for i,v in ipairs(HubStats) do if i > 1 then table.insert(t,"\t"..string.format("%-20.15s",v[1]:gsub(" "," ")).."\t•"..v[2]) end end return t end, -- Adjust To Your Profiles [0 = disable / 1 = enable] {[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}}, [6] = {"Downloads","web/files.web","files.html","File Downloads", function() if not Web.Refresh then local path,url,t = Web.HubPath..Web.Downloads,Web.FileUrl,{} local Invalid = {"wr.cfg",".db",".pif",".lnk",".sys",".part",".msc",".vxd",".mft",".adm", ".mapimail",".ins",".cpl",".nt","~",".tmp",".$",".&",".chk",".shs",".desklink",".url",".htm"} local CheckFile = function(file) for i,v in ipairs(Invalid) do if file:find(v:lower(),1,true) then return false end end return true end Downloads = {} lfs.chdir(path) for item in lfs.dir(path) do if CheckFile(item) then local x = lfs.attributes(item) if x and x.mode == "file" then local time,size,name = os.date(nil,x.modification),x.size,item:gsub("%s","%%20") table.insert(Downloads,{time,FmtSz(size),"<a href=\""..url.."/"..name.."\"/>"..item.."</a>"}) table.insert(t,{time,FmtSz(size),"<a href=\""..url.."/"..name.."\"/>"..item.."</a>"}) end end end table.insert(t,1,{"<b>Date / Time</b>","<b>Size</b>","<b>Name</b>"}) table.insert(t,2,{" "," "," "}) lfs.chdir(Web.HubPath.."scripts") SaveToFile(Web.Site[6][2],Downloads,"Downloads") return Web.Head..Web.Css..Web.Body..GenTab(t,Web.Site[6][4],1)..Web.Foot end end, function() local t = {} for i,v in ipairs(Downloads) do local _,_,file = v[3]:find("%>(%S+)%</") if file then table.insert(t,file.."\t("..v[2]..")") end end return t end, -- Adjust To Your Profiles [0 = disable / 1 = enable] {[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}}, } Web.Head = "<html>\n<head>\n<title>"..SetMan.GetString(0).." - ‹›</title>\n".. "<meta http-equiv=page-enter content=\"blendTrans(Duration=2)\">\n".. "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n".. "<meta name=robots content=\"noindex,nofollow\">\n".. "<meta http-equiv=pragma content=no-cache>\n".. "<meta http-equiv=\"content-type\" content=\"text/html; charset=iso-8859-1\">\n".. "<link rel=\"shortcut icon\" href=\"favicon.ico\">\n" Web.Frame = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\"\n".. "\"http://www.w3.org/TR/html4/frameset.dtd\">\n"..Web.Head Web.Head = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n".. "\"http://www.w3.org/TR/html4/loose.dtd\">\n"..Web.Head Web.Css = "<link rel=\"stylesheet\" href=\""..Web.Root[6][1].."\" type=\"text/css\">\n" --Index Web.Root[1][3] = Web.Frame.."</head>\n<frameset rows=\"130,*,45\" cols=\"*\">\n".. "<frame name=\"top\" src=\"top.html\" scrolling=\"no\" frameborder=\"0\">\n".. "<frameset cols=\"200,800\" rows=\"*\" >\n".. "<frame name=\"menu\" src=\"left.html\" scrolling=\"no\" frameborder=\"0\">\n".. "<frame name=\"contents\" src=\"main.html\" scrolling=\"no\" frameborder=\"0\">\n</frameset>\n".. "<frame name=\"bottom\" scrolling=\"no\" noresize src=\"bottom.html\" frameborder=\"0\">\n".. "<noframes>\n<p>This document uses frames, but your browser doesn't support them.</p>\n".. "</noframes>\n</frameset>\n</html>" --Top Web.Root[2][3] = Web.Head..Web.Css.."</head>\n<body>\n".. "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n".. "<tr>\n<td class=\"table0\" align=\"left\">".. " <script type=\"text/javascript\">document.write(Date())</script></td>\n</tr>\n".. "<tr>\n<td class=\"table1\" align=\"right\">"..HubApp.." "..HubVer..": "..desc.." </td>\n</tr>\n".. "<tr align=\"center\" valign=\"top\">\n<td class=\"table3\">\n<div align=\"center\">\n<h1>".. SetMan.GetString(0).."</h1>\n<h3>..."..topic.."</h3>\n</div>\n</td>\n</tr>\n</table>\n".. Web.Foot --Main Web.Root[3][3] = Web.Head..Web.Css..Web.Body.. "<table width=\"100%\" height=\"100%\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n".. "<tr><td class=\"table1\" valign=\"top\" align=\"left\">.:: "..Web.Root[3][2].." ::.</td>\n</tr>".. "</table>\n<iframe name=\"main\" class=\"table2\" scrolling=yes width=\"100%\" ".. "height=\"400\" align=\"left\" frameborder=\"0\" src=\""..Web.Content.."\"></iframe>\n"..Web.Foot --Bottom Web.Root[4][3] = Web.Head..Web.Css..Web.Body.. "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n".. "<tr>\n<td class=\"table1\" align=\"left\" colspan=\"2\" ></td>\n</tr>\n<tr>\n".. "<td class=\"table0\" align=\"center\" colspan=\"2\" ><script type=\"text/javascript\">".. "document.write(\"You're using: \"+navigator.appName+\" \"+navigator.appCodeName+\" \"+navigator.appVersion+\"\");\n".. "</script>\n</td>\n</tr>\n</table>\n"..Web.Foot --Left - Menu Web.Root[5][3] = Web.Head..Web.Css..Web.Body.. "<table width=\"95%\" align=\"left\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n".. "<tr><td class=\"table1\">.:: Menu ::.</td></tr>\n<tr valign=\"top\">\n<td class=\"table2\">".. "<a href=\"#\" class=\"menu\" target=\"_self\">Navigation:</a>\n<br><a href=\"index.html\" target=\"_top\">Home</a>\n" for i,v in ipairs(Web.Site) do Web.Root[5][3] = Web.Root[5][3].."<br><a href=\"".. v[3].."\" target=\"main\">"..v[4].."</a>\n" end local t = { [1] = {"Connect to Hub","dchub://"..SetMan.GetString(2)..":"..SetMan.GetString(3):gsub("%;.*$","")}, [2] = {"Contact","mailto:"..Web.Mail.."?subject=About the "..SetMan.GetString(0).." website&body=Dear "..Web.Owner..","}, } t[2][2] = t[2][2]:gsub(" ","%%20") for i,v in ipairs(t) do Web.Root[5][3] = Web.Root[5][3].."<br><a href=\"".. v[2].."\" target=\"main\">"..v[1].."</a>\n" end Web.Root[5][3] = Web.Root[5][3].."<br><a href=\"#\" class=\"menu\" target=\"_self\">Web Links:</a>\n" for i,v in ipairs(Web.Links) do local url = v[1]:gsub(" ","%%20") Web.Root[5][3] = Web.Root[5][3].."<br><a href=\""..url.."\" " if v[1] == "#" or v[1]:find("^dchub://") then if v[1] == "#" then Web.Root[5][3] = Web.Root[5][3].."class=\"menu\" " end Web.Root[5][3] = Web.Root[5][3].."target=\"_self\">" else if v[3] then Web.Root[5][3] = Web.Root[5][3].."target=\""..v[3].."\">" else Web.Root[5][3] = Web.Root[5][3].."target=\"_blank\">" end end Web.Root[5][3] = Web.Root[5][3]..v[2].."</a>\n" end Web.Root[5][3] = Web.Root[5][3].."</td></tr>\n</table>\n"..Web.Foot local HubDir = Web.HubPath local tab = {} for dir in string.gmatch(Web.Path.."/images/","(%a+)/") do table.insert(tab,dir) end local CheckDir = HubDir..table.concat(tab,"//") if not os.rename(CheckDir,CheckDir) then for _,folder in ipairs(tab) do HubDir = HubDir..folder local r,e = os.rename(HubDir,HubDir) if e and not e:lower():find("permission denied") then lfs.chdir(Web.HubPath) lfs.mkdir(folder) end HubDir = HubDir.."/" end end Copy(Web.HubPath..Web.MainText,Web.HubPath..Web.Path..Web.Content) local FileDir,FirstStart = Web.HubPath..Web.Path..Web.FileUrl,true local r,e = os.rename(FileDir,FileDir) if e and not e:lower():find("permission denied") then lfs.chdir(Web.HubPath..Web.Path) lfs.mkdir(Web.FileUrl) else FirstStart = false end local sample = Web.HubPath..Web.FileUrl.."/Setting_Up_Downloads.txt" if FirstStart and not os.rename(sample,sample) then local directions = "Simply copy your files to this folder ".. "[ Default = C:/Ptokax/html/webstats/files ]\nThen restart this ".. "script and reload the dowloads page to see the new files you've added.\n".. "You may delete this file at any time.\r\n\r\n"..string.rep(string.char(9),6).." -Mutor" local f,e = io.open(sample,"w") if f then f:write(directions) f:flush() f:close() else OnError(e:sub(1,-2)) end endendGenTab = function(t,s,noidx) local txt = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n" if s then txt = txt.."\t<tr><td class=\"table0\" valign=\"top\">.:: "..s.." ::.</td></tr></table>\n" else txt = txt.."\t<tr><td class=\"table0\" valign=\"top\"> </td></tr>\n" end txt = txt.."<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" if next(t) then for i,v in ipairs(t) do if noidx then txt = txt.."\n\t<tr align=\"left\" valign=\"top\">" else txt = txt.."\n\t<tr align=\"left\" valign=\"top\">".. "<td class=\"table3\" width=\"10%\"> "..i.."</td>" end if type(v) == "table" then local z = #v for x=1, z do if x < z then txt = txt.."<td class=\"table3\" width=\""..(12*x).. "%\"> <b>"..v[x].."</b></td>" else local s = (100 - (x*12)) txt = txt.."<td class=\"table3\"width=\""..s.."%\"> "..v[x].."</td>" end end else txt = txt.."<td class=\"table3\" width=\"90%\"> "..v.."</td>" end end txt = txt.."</tr>\n" else txt = txt.."\t<tr><td> No</td>\n<td>Data</td>\n</tr>\n" end txt = txt.."</table>\n<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n".. "\t<tr><td class=\"table2\" valign=\"top\"></td></tr>\n</table>\n" return txtendDoHtml = function(file,title,body) local method = "updated" if not os.rename(file,file) then method = "saved" end body = body:gsub("%b‹›",title) local f,e = io.open(file,"w") if f then if not Web.Refresh then OnError(title.." has been "..method) end f:write(body) f:flush() f:close() else OnError(e:sub(1,2)) endendDoRoot = function(x) for i,v in ipairs(Web.Root) do if v[3] then if x or not os.rename(Web.Url..v[1],Web.Url..v[1]) then DoHtml(Web.Url..v[1],v[2],v[3]) end end endendDoTabs = function(x,t,n) if x and t and n then if t[5] then local html = t[5](n) if html then DoHtml(Web.Url..t[3],t[4],html) end end else for i,v in ipairs(Web.Site) do local tab = v[1] if loadfile(v[2]) then dofile(v[2]) if v[1] == "Chat" and next(Chat) then if Chat[1][3] then local t = {} for i,v in ipairs(Chat) do table.insert(t,{v[1],"<"..v[2].."> ".. DoAscii(v[3]:gsub("•",""))}) end Chat = t end SaveToFile(Web.Site[2][2],Chat ,"Chat") end else tab = {} SaveToFile(v[2],tab,v[1]) dofile(v[2]) end if x or not os.rename(Web.Url..v[3],Web.Url..v[3]) then if v[5] then local html = v[5]() if html then DoHtml(Web.Url..v[3],v[4],html) end end end end endendDoCss = function() local css = "body {\n".. "\tcolor: "..Web.Style.fcolor..";\n".. "\tfont-family: "..Web.Style.font..";\n".. "\tbackground-image: url("..Web.Style.bgimage..");\n".. "\tbackground-repeat: repeat;\n".. "\tbackground-color: "..Web.Style.bgcolor..";\n".. "}\n".. "a:link {\n".. "\tcolor: "..Web.Style.lcolor..";\n".. "\ttext-decoration: none;\n".. "}\n".. "a:visited {\n".. "\tcolor: "..Web.Style.vcolor..";\n".. "\ttext-decoration: none;\n".. "}\n".. "a:hover {\n".. "\tcolor: "..Web.Style.hcolor..";\n".. "\ttext-decoration: underline overline;\n".. "}\n".. ".menu {\n".. "\tcolor: #E9E9F8;\n".. "\ttext-decoration: none;\n".. "\twidth: 100%;\n".. "\tbackground-color: #8784C6;\n".. "}\n".. ".table0 {\n".. "\theight: 12px;\n".. "\tcolor: #E9E9F8;\n".. "\tfont-size: 12px;\n".. "\tbackground-color : #1E2580;\n" if Web.Style.tborders == "yes" then css = css.."\tborder-top: 1px solid #8784C6;\n".. "\tborder-bottom: 1px solid #8784C6;\n".. "\tborder-left: 1px solid #8784C6;\n".. "\tborder-right: 1px solid #8784C6;\n" end css = css.."}\n".. ".table1 {\n".. "\theight: 12px;\n".. "\ttext-indent: 5px;\n".. "\tcolor : White;\n".. "\tfont-size : 12px;\n".. "\tbackground : #8784C6;\n" if Web.Style.tborders == "yes" then css = css.."\tbackground-color : #8784C6;\n".. "\tborder-bottom: 2px solid Black;\n".. "\tborder-left: 1px solid Black;\n".. "\tborder-right: 1px solid Black;\n".. "\tborder-top: 1px solid Black;\n" end css = css.."}\n".. ".table2 {\n".. "\theight: 400px;\n".. "\twidth: 100%;\n".. "\tcolor: Black;\n".. "\tfont-size: 12px;\n".. "\tbackground: #E9E9F8;\n" if Web.Style.tborders == "yes" then css = css.."\tborder-top: 1px solid #8784C6;\n".. "\tborder-bottom: 1px solid #8784C6;\n".. "\tborder-left: 1px solid #8784C6;\n".. "\tborder-right: 1px solid #8784C6;\n" end css = css.."}\n".. ".table3 {\n".. "\theight: 12px;\n".. "\twidth: auto;\n".. "\tcolor: Black;\n".. "\tfont-size: 12px;\n".. "\tbackground: #E9E9F8;\n" if Web.Style.tborders == "yes" then css = css.."\tborder-top: 1px solid #8784C6;\n".. "\tborder-bottom: 1px solid #8784C6;\n".. "\tborder-left: 1px solid #8784C6;\n".. "\tborder-right: 1px solid #8784C6;\n" end css = css.."}\n".. ".table4 {\n".. "\theight: 12px;\n".. "\twidth: auto;\n".. "\tcolor: Black;\n".. "\tfont-size: 8px;\n".. "\tbackground: #E9E9F8;\n" if Web.Style.tborders == "yes" then css = css.."\tborder-top: 1px solid #8784C6;\n".. "\tborder-bottom: 1px solid #8784C6;\n".. "\tborder-left: 1px solid #8784C6;\n".. "\tborder-right: 1px solid #8784C6;\n" end css = css.."}" local f,e = io.open(Web.Url..Web.Root[6][1], "w") if f then f:write(css) f:flush() f:close() else OnError(e:sub(1,-2)) endendfunction Chk(enable) if enable == "" or not enable then enable = "not set" end return enableendFmtSz = function(int) local i,u,x=tonumber(int) or 0,{"","K","M","G","T","P"},1 while i > 1024 do i,x = i/1024,x+1 end return string.format("%.2f %sB.",i,u[x])endConvert = function(time) time = time or 0 local s,x,n,tab = "",0,os.time(),{ [1] = {31556926,"year"}, [2] = {2592000,"month"}, [3] = {604800,"week"}, [4] = {86400,"day"}, [5] = {3600,"hour"}, [6] = {60,"minute"}, [7] = {1,"second"} } if time > 0 then if time < 2145876659 then if n > time then time = n - time for i,v in ipairs(tab) do if time > v[1] then x = math.floor(time/v[1]) if x > 1 then v[2] = v[2].."s" end if x > 0 then s = s..x.." "..v[2]..", " time = time-x*v[1] end end end end collectgarbage("collect") return s:sub(1,-3) else return "Invalid date or time supplied. [must be pre 12/31/2037]" end else return "No uptime recorded" endendCopy = function(source,target) local is,os,text local f,e = io.open(source) if f then text,is = f:read("*a"),f:seek("end") f:close() else OnError(e:sub(1,-2)) end if text then local f,e = io.open(target,"w") if f then text = Web.Head:gsub("%b‹›","MOTD")..Web.Css..Web.Body.. "<table class=\"table2\" bgcolor=\"#E9E9F8\" width=\"100%\" ".. "border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n".. "<tr><td class=\"table3\" valign=\"top\">\n<pre>"..text.."</pre>"..Web.Ad.. "\n</td></tr>\n</table>\n"..Web.Foot f:write(text) f:flush() os = f:seek("end") f:close() else OnError(e:sub(1,-2)) end endend--Replace certain characters with html ASCII code & vice versaDoAscii = function(data,rev) if rev then for i,v in pairs(Web.Asc) do data = data:gsub(v,string.char(i)) end return data else for chr in data:gmatch(".") do local x = Web.Asc[string.byte(chr)] if x then data = data:gsub(chr,x) end end return data endendGenCmds = function(user) local c,t,x = "",{} local p,m,s = SetMan.GetString(29):sub(1,1),SetMan.GetString(0),Web.Script for i,v in ipairs(Web.Site) do if v[7][user.iProfile] and v[7][user.iProfile] == 1 then x = true c = c.."$UserCommand 1 1 "..m.."\\"..s.."\\".. v[4].."$<%[mynick]> "..p..v[1]:lower().."||" end end if x then Core.SendToNick(user.sNick,c:sub(1,-2)) return x endendfunction Serialize(tTable, sTableName, sTab) sTab = sTab or "" sTmp = "" sTmp = sTmp..sTab..sTableName.." = {\n" for key, value in ipairs(tTable) do local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key) if(type(value) == "table") then sTmp = sTmp..Serialize(value, sKey, sTab.."\t") else local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value) sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue end sTmp = sTmp..",\n" end sTmp = sTmp..sTab.."}" return sTmpendfunction SaveToFile(file , table , tablename) local handle,err = io.open(file,"w") if handle then handle:write(Serialize(table, tablename)) handle:flush() handle:close() else OnError(err:sub(1,2)) endend
0.3.5.2\scripts\PxWeb1.0d.5.11.lua:62: attempt to index global 'SetMan' (a nil value)
PxWeb 1.0d LUA 5.11 [Strict] [API 2]
--[[ PxWeb 1.0e LUA 5.11 [Strict] [API 2] By Mutor 07/21/07 Generates HTML pages for use with PtokaX/Other Web Server -A total rewrite of pxstats You can use this single script to: ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ - Generates all required folders and files with no user intervention required. - Display online users, recent chat, top shares, top uptimes, hub stats and file downloads. - Offer file downloads by merely copying files to the download folder and restarting script. - Display a list of hopefully useful web and dchub links. - Provide an E-Mail contact link for users that may have been banned for bad pass etc. - Edit site-wide style and colors through cascading style sheet. - Provides MainText parameter which allows you to display text file on the main page. - Provides Ad, a quickly ammenadable parameter that is appended to the text of MainText. - Both MainText and Ad may contain escaped HTML code [links, images, email, etc.] Note: This script will overwrite any existing files of the same name. Backup your existing web server files if this is of concern to you. Users that haven't used the Px web server , just set the server port on PtokaX -> Options tab, enable the server there and start the script. Changes from 1.0 08/03/07 +Added user commands and context menus [right click] *User commands sent with ZPipe [saves b/w] +Added command permission by profile per command +Added report 'option' for status messages +Added ASCII table & function +Added startup and connect message +Added error logging ~Fixed bum link to LUA-Users Wiki Changes from 1.0b 10/13/07 +Converted for the new PtokaX API Changes from 1.0c 10/13/07 +Added PxLuaFileSystem extension library to avoid shell pop ups. +Added target frame option for links Changes from 1.0d 08/27/10 +Added option for links submenu, requested by TZB ***Notes: This script requires the PXLuaFileSystem extension library. It will not run without it. You can get it and others here: http://board.ptokax.ch/index.php/board,38.0.html]]local Web = {-- Set MOTD ? string or falseMotd = false,-- Name of hub ownerOwner = "Mutor",-- Send status / error messages to Admin nick? "on"/"off" [If = "on", set OpNick]Report = "on",-- Admins nick for status / error messages [Report must = "on"]OpNick = "Mutor",-- List files for OpNick at script start? true/falseListFiles = false,-- Advert to display to all at startup and each new connection ["" = disabled]Addy = "Please visit the hub's web site at http://mutor.no-ip.com:6803/",-- Botname pulled from the hub or use "CustomName"Bot = SetMan.GetString(21),-- Bot descriptionDesc = "I generate HTML for the hub's web server.",-- Bot/Website email addressMail = "admin@mutor.no-ip.com",-- Text file that will be displyed in main frame of homepage-- [This path/file should reside in PtokaX folder in root or subdirectory]-- Note: This file may contain [escaped LUA 'magic' chars] HTML code-- ie. - "<br><a href=\"http://www.yourlink.com/image.jpg\">Image</a>"MainText = "cfg/motd.txt",-- Addendum to the MainText [will appear at end of file]. "" = disable-- This text may contain [escaped LUA 'magic' chars] HTML codeAd = "<br> <a href=\"http://validator.w3.org/\">\n".."<img src=\"http://www.w3.org/Icons/valid-html401-blue\" ".."alt=\"Valid HTML 4.01 Frameset\" height=\"31\" width=\"88\" border=\"0\"></a>",--"\n<br>\n<img src=\"http://www.w3.org/Icons/valid-html401-blue\"></a>",-- Links to display on the menu {"http://linkaddress.com","Link Text",target frame},Links = { {"http://mutor.no-ip.com:6804/register.htm","Register in "..SetMan.GetString(0),"main"}, {"/files/index.html","WebReg Downloads","main"}, {"/files/index.htm","Dynamic Downloads","main"}, --You can make a submenu like this: {"Number","Submenu Name"}, {"1","PtokaX Links:"}, --You can make a submenu links like this: {"Number","Link URL","Link Name"}, {"1","http://www.ptokax.org","PtokaX Home"}, {"1","http://www.ptokax.ch","PtokaX Home Mirror"}, {"1","http://board.ptokax.ch/index.php","The PtokaX Portal"}, {"1","http://wiki.ptokax.ch","The PotaX Wiki"}, {"#","Hub Links:"}, {"dchub://ptokax-lua.damnserver.com:2006","PtokaX Admins Hub"}, --You can make a seperator like this [idx] = {"#","Separator Text"}, {"#","Reference:"}, {"http://www.lua.org/","LUA Home Page"}, {"http://www.lua.org/manual/5.1/","LUA 5.1 Ref. Manual"}, {"http://lua-users.org/wiki/","LUA-Users Wiki"}, {"http://luaforge.net/","LuaForge"}, --{"http://validator.w3.org/","Validate HTML"}, },--Short message for new logins ["" = disable]Greeting = "Welcome [usr]. It's nice of you to stop by...",--Basic CSS Settings, use color codes or friendly color names--See DoCss function for extended CSS settingsStyle = { --Font Family font = "Verdana, Geneva, Arial, Helvetica, sans-serif", --Font Color fcolor = "Black", --Background Color bgcolor = "transparent", --Background Image (Path and Filename) bgimage = "",--images/bg.gif --Link Color lcolor = "Blue", --Visited Link Color vcolor = "Silver", --Link Hover Color hcolor = "Red", --Show Table Borders? "yes" = enabled /"no" = disabled tborder = "no", },}require"pxlfs"assert(lfs._VERSION)local path = Core.GetPtokaXPath().."scripts/"OnStartup = function() Web.Script,Web.HubPath,Web.Content = "PxWeb 1.0e",Core.GetPtokaXPath(),"motd.html" Web.Body,Web.Foot,Web.ErrLog,Web.Refresh = "</head>\n<body>\n","</body>\n</html>",{} Web.Path,Web.Downloads,Web.FileUrl = "web/",Web.HubPath.."web/files","files" Web.Url = Web.HubPath..Web.Path if Web.Motd and SetMan.GetMOTD() ~= Web.Motd then SetMan.SetMOTD(Web.Motd) SetMan.Save() end Web.Asc = { [34]=""",[38]="&",[39]="'",[60]="<",[62]=">",[94]="ˆ",[126]="˜",[127]="", [128]="€",[130]="‚",[131]="ƒ",[132]="„",[133]="…",[134]="†",[135]="‡", [136]="ˆ",[137]="‰",[138]="Š",[139]="‹",[140]="Œ",[142]="Ž",[145]="‘", [146]="’",[147]="“",[148]="”",[149]="•",[150]="–",[151]="—",[152]="˜", [153]="™",[154]="š",[155]="›",[156]="œ",[157]="Ť",[158]="ž",[159]="Ÿ", [160]=" ",[161]="ˇ",[162]="˘",[163]="Ł",[164]="¤",[165]="Ą",[166]="¦", [167]="§",[168]="¨",[169]="©",[170]="Ş",[171]="«",[172]="¬",[173]="­", [174]="®",[175]="Ż",[176]="°",[177]="±",[178]="²",[179]="ł",[180]="´", [181]="µ",[182]="¶",[183]="·",[184]="¸",[185]="ą",[186]="ş",[187]="»", [188]="Ľ",[189]="˝",[190]="ľ",[191]="ż",[192]="Ŕ",[193]="Á",[194]="Â", [195]="Ă",[196]="Ä",[197]="Ĺ",[198]="Ć",[199]="Ç",[200]="Č",[201]="É", [202]="Ę",[203]="Ë",[204]="Ě",[205]="Í",[206]="Î",[207]="Ď",[208]="Đ", [209]="Ń",[210]="Ň",[211]="Ó",[212]="Ô",[213]="Ő",[214]="Ö",[215]="×", [216]="Ř",[217]="Ů",[218]="Ú",[219]="Ű",[220]="Ü",[221]="Ý",[222]="Ţ", [223]="ß",[224]="à",[225]="á",[226]="â",[227]="ă",[228]="ä",[229]="ĺ", [230]="ć",[231]="ç",[232]="č",[233]="é",[234]="ę",[235]="ë",[236]="ě", [237]="í",[238]="î",[239]="ď",[240]="đ",[241]="ń",[242]="ň",[243]="ó", [244]="ô",[245]="ő",[246]="ö",[247]="÷",[248]="ř",[249]="ů",[250]="ú", [251]="ű",[252]="ü",[253]="ý",[254]="ţ",[255]="˙" } Web.Timer = TmrMan.AddTimer(60000) local r,e = os.rename("web","web") if e and not e:lower():find("permission denied") then lfs.chdir(Web.HubPath.."scripts") lfs.mkdir("web") lfs.chdir(Web.HubPath) end Initialize() DoCss() DoRoot(1) DoTabs(1) Web.Refresh = true Initialize,DoCss,DoRoot,DoPopMenu,Web.Links,Web.Style,Copy = nil,nil,nil,nil,nil,nil,nil collectgarbage("collect") if Web.Addy ~= "" then Core.SendToAll("<"..Web.Bot.."> "..Web.Addy) end OnError(Web.Script.." has been started. Memory usage: "..string.format("%.2f Kb.",collectgarbage("count")),true)endOnExit = function() DoTabs(1,Web.Site[1]) local time = os.time() for _,v in ipairs(Times) do v[3] = (time - v[2]) + v[3] v[2] = time v[4] = 0 end SaveToFile(Web.HubPath.."scripts/web/errlog.web",Web.ErrLog,"Web.ErrLog") SaveToFile(Web.Site[3][2],Shares,"Shares") SaveToFile(Web.Site[2][2],Chat,"Chat") collectgarbage("collect") OnError(Web.Script.." has been stopped, freeing ".. string.format("%.2f Kb.",collectgarbage("count")).." of memory.",true)endOnError = function(msg,nolog) local stamp = os.date() if not nolog then table.insert(Web.ErrLog,{stamp,msg}) end if Web.Report == "on" and Web.OpNick ~= "" then Core.SendToNick(Web.OpNick,"<"..Web.Bot.."> "..msg) endendOnTimer = function(Id) if Id == Web.Timer then SaveToFile(Web.Site[2][2],Chat ,"Chat") if next(Web.ErrLog) then SaveToFile(Web.HubPath.."scripts/web/errlog.web",Web.ErrLog,"Web.ErrLog") Web.ErrLog = {} end DoTabs(1) collectgarbage("collect") endendUserConnected = function(user) DoTabs(1,Web.Site[1]); DoTabs(1,Web.Site[4],user.sNick) if #Web.Greeting > 0 then Core.SendToNick(user.sNick,"<"..Web.Bot.."> "..Web.Greeting:gsub("%b[]",user.sNick)) end if Web.Addy ~= "" then Core.SendToNick(user.sNick,"<"..Web.Bot.."> "..Web.Addy) end if user.iProfile ~= -1 then if GenCmds(user) then Core.SendToNick(user.sNick,"<"..Web.Bot.."> "..Web.Script.." commands enabled, see hub tab for more.") end endendOpConnected,RegConnected = UserConnected,UserConnectedUserDisconnected = function(user) DoTabs(1,Web.Site[1]) DoTabs(1,Web.Site[4],user.sNick)endOpDisconnected = UserDisconnectedMyINFOArrival = function(user,data) DoTabs(1,Web.Site[3])endChatArrival = function(user,data) local _,_,pfx = data:find("%b<> (["..SetMan.GetString(29).."])") local _,_,ctrl = data:find("%c") local _,_,sb = data:lower():find("is kicking because:",1,true) if not pfx and not ctrl and not sb then local _,_,txt = data:find("^%b<> (.*)|$") if txt then local _,n = data:gsub("%p","%1") if n <= 5 and txt:len() >= 2 then data = DoAscii(data:sub(1,-2)) local now = string.lower(os.date("[%H:%M]")) table.insert(Chat,{now,data}) if #Chat > 100 then table.remove(Chat,1) end end end else local _,_,cmd = data:find("^%b<> %p(%a+)") if cmd then local str for i,v in ipairs(Web.Site) do if cmd:lower() == v[1]:lower() then if v[7][user.iProfile] and v[7][user.iProfile] == 1 then str = "\r\n\r\n\t"..v[4].."\r\n\t"..string.rep("¯",v[4]:len()).."\r\n" for idx,val in ipairs(v[6]()) do if cmd:lower() == "chat" or cmd:lower() == "hubstats" then str = str..val.."\r\n" else str = str.."\t"..idx.."\t"..val.."\r\n" end end str = str.."\r\n" return Core.SendPmToNick(user.sNick,Web.Bot,str),true else local prof = "Unregistered User" if u.iProfile ~= -1 then prof = ProfMan.GetProfile(u.iProfile).sProfileName end local pfx = SetMan.GetString(29):sub(1,1) or "+" local msg = "Sorry "..user.sNick..", "..prof.."'s are ".. "not allowed use of the "..pfx..cmd:lower().." command." return Core.SendToNick(user.sNick,"<"..Web.Bot.."> "..msg), Core.SendPmToNick(user.sNick,Web.Bot,msg),true end end end end endendToArrival = ChatArrivalInitialize = function() local topic,desc = SetMan.GetString(10) or "",SetMan.GetString(5) or "" local HubApp,HubVer = "PtokaX", Core.Version Web.Root = { [1] = {"index.html","Index"}, [2] = {"top.html","Top"}, [3] = {"main.html","Main"}, [4] = {"bottom.html","Bottom"}, [5] = {"left.html","Menu"}, [6] = {"pxstyle.css","CSS"} } Web.Site = { [1] = {"Users",path.."web/users.web","users.html","Online Users", function() local t,x = Core.GetOnlineUsers(),{} if t and next(t) then local s = " " s = s:rep(20) table.insert(x,{"<b>Profile</b>","<b>User Nick</b>"..s}) table.insert(x,{" "," "}) Users = {} for i,u in ipairs(t) do local p if u.iProfile ~= -1 then p = ProfMan.GetProfile(u.iProfile).sProfileName else p = "Unregistered User" end table.insert(x,{p,u.sNick}) table.insert(Users,{p,u.sNick}) end SaveToFile(Web.Site[1][2],Users,"Users") end return Web.Head..Web.Css.."<meta http-equiv=\"refresh\" content=\"60\">\n".. Web.Body..GenTab(x,Web.Site[1][4],1)..Web.Foot end, function() local t = {} for i,v in ipairs(Users) do table.insert(t,table.concat(v," ")) end return t end, -- Adjust To Your Profiles [0 = disable / 1 = enable] {[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}}, [2] = {"Chat",path.."web/chat.web","chat.html","Recent Chat", function() local t,x = Chat,{} if next(t) then table.insert(x,{"<b>Time</b>","<b>Chat Message</b>"}) table.insert(x,{" "," "}) for i,v in ipairs(t) do table.insert(x,{v[1],v[2]}) end end SaveToFile(Web.Site[2][2],Chat ,"Chat") local cform = "<form method=\"POST\" action=\"http://mutor.no-ip.com:6800\">".. "Nick:<input size=\"40\" maxlength=\"40\" type=\"text\" name=\"Nick\"><br>".. "Message:<input size=\"100\" maxlength=\"100\" type=\"text\" name=\"msg\"><br>".. "<input type=\"submit\" value=\"Send\"></center><br><br></form>" return Web.Head..Web.Css.."<meta http-equiv=\"refresh\" content=\"10\">\n".. Web.Body..GenTab(x,Web.Site[2][4],1)..Web.Foot end, function() local t = {} for i,v in ipairs(Chat) do table.insert(t,"\t"..v[1].." "..DoAscii(v[2],1):gsub("\r\n","%1\t\t ")) end return t end, -- Adjust To Your Profiles [0 = disable / 1 = enable] {[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}}, [3] = {"Shares",path.."web/shares.web","shares.html","Top Shares", function() local t,x = Core.GetOnlineUsers(),{} if t and next(t) then local s = " " s = s:rep(20) table.insert(x,{"<b>User Nick</b>","<b>Share Value</b>"..s}) table.insert(x,{" "," "}) for i,u in ipairs(t) do if Core.GetUserAllData(u) then local exist if next(Shares) then for _,v in ipairs(Shares) do if v[1]:lower() == u.sNick:lower() then v[2] = u.iShareSize exist = true break end end end if not exist then table.insert(Shares,{u.sNick,u.iShareSize}) end end end table.sort(Shares, function(a,b)return a[2] > b[2] end) SaveToFile(Web.Site[3][2],Shares,"Shares") if next(Shares) then for z = 1, math.min(#Shares,10) do if Shares[z][2] > 0 then table.insert(x,{Shares[z][1],FmtSz(Shares[z][2])}) end end end end return Web.Head..Web.Css.."<meta http-equiv=\"refresh\" content=\"60\">\n".. Web.Body..GenTab(x,Web.Site[3][4],1)..Web.Foot end, function() local t = {} for i,v in ipairs(Shares) do if v[2] > 0 then table.insert(t,FmtSz(v[2]).."\t\t"..v[1]) end end return t end, -- Adjust To Your Profiles [0 = disable / 1 = enable] {[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}}, [4] = {"Times",path.."web/times.web","times.html","Top Uptimes", function(nick) local t,x,time = Core.GetOnlineUsers(),{},os.time() if t and next(t) or nick then table.insert(x,{"<b>User Nick</b>","<b>Uptime Value</b>"}) table.insert(x,{" "," "}) if nick then for _,v in ipairs(Times) do local z = 0 if v[1]:lower() == nick:lower() then exist = true if Core.GetUser(nick) then z = 1 v[2] = time v[4] = z else v[3] = (time - v[2]) + v[3] v[4] = z end break end end else if next(t) then for i,u in ipairs(t) do local exist for _,v in ipairs(Times) do if v[1]:lower() == u.sNick:lower() then exist = true if Web.Refresh then v[3] = (time - v[2]) + v[3] v[2] = time end v[4] = 1 break end end if not exist then table.insert(Times,{u.sNick,time,0,1}) end end end end table.sort(Times, function(a,b)return a[3] > b[3] end) SaveToFile(Web.Site[4][2],Times,"Times") if next(Times) then for z = 1, math.min(#Times,10) do if (time - Times[z][3]) > 0 then table.insert(x,{Times[z][1],Convert(time - Times[z][3])}) end end end end return Web.Head..Web.Css.."<meta http-equiv=\"refresh\" content=\"600\">\n".. Web.Body..GenTab(x,Web.Site[4][4],1)..Web.Foot end, function() local t,time = {},os.time() for i,v in ipairs(Times) do if v[2] > 0 and v[3] > 0 then table.insert(t,string.format("%-50.30s",v[1]).." \t•"..Convert(time - v[3])) end end return t end, -- Adjust To Your Profiles [0 = disable / 1 = enable] {[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}}, [5] = {"HubStats",path.."web/stats.web","stats.html","Hub Statistics", function() local b,m = " ","Public, unregistered users welcome." local topic = SetMan.GetString(10) or "There is no current topic." local sr,hr,ss,hs = Chk(SetMan.GetNumber(8)),Chk(SetMan.GetNumber(7)),"slot","hub" if SetMan.GetBool(5) then m = "Private, registered users only." end if sr and type(sr) == "number" and sr > 1 then ss = ss.."s" end if hr and type(hr) == "number" and hr > 1 then hs = hs.."s" end local t = { [1] = {b.."Hub Name:",SetMan.GetString(0)}, [2] = {b.."Hub Desc.:",SetMan.GetString(5)..""}, [3] = {b.."Hub Topic:",topic..""}, [4] = {b.."Hub Time:",os.date("%B %d %Y %X")..""}, [5] = {b.."HubOwner:",Web.Owner..""}, [6] = {b.."Hub Uptime:",Convert(os.time() - Core.GetUpTime())..""}, [7] = {b.."Min Share:",FmtSz(SetMan.GetMinShare())..""}, [8] = {b.."Min Slots:",Chk(SetMan.GetNumber(5)).." per user."}, [9] = {b.."Max Slots:",Chk(SetMan.GetNumber(6)).." per user."}, [10] = {b.."Slot Ratio:",sr.." "..ss.." per "..hr.." "..hs.."."}, [11] = {b.."Max Hubs:",Chk(SetMan.GetNumber(9)).." per user."}, [12] = {b.."Peak Users:",Core.GetMaxUsersPeak()}, [13] = {b.."Hub Share:",FmtSz(Core.GetCurrentSharedSize())}, [14] = {b.."There Are:",#Core.GetOnlineUsers().." of a possible "..SetMan.GetNumber(0).." users online."}, [15] = {b.."Hub Mode:",m}, } table.insert(t,1,{" "," "}) SaveToFile(Web.Site[5][2],t ,Web.Site[5][1]) return Web.Head..Web.Css.."<meta http-equiv=\"refresh\" content=\"60\">\n".. Web.Body..GenTab(t,Web.Site[5][4],1)..Web.Foot end, function() local t,time = {},os.time() for i,v in ipairs(HubStats) do if i > 1 then table.insert(t,"\t"..string.format("%-20.15s",v[1]:gsub(" "," ")).."\t•"..v[2]) end end return t end, -- Adjust To Your Profiles [0 = disable / 1 = enable] {[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}}, [6] = {"Downloads",path.."web/files.web","files.html","File Downloads", function() if not Web.Refresh then local fpath,url,t = Web.Downloads,Web.FileUrl,{} local Invalid = {"wr.cfg",".db",".pif",".lnk",".sys",".part",".msc",".vxd",".mft",".adm", ".mapimail",".ins",".cpl",".nt","~",".tmp",".$",".&",".chk",".shs",".desklink",".url",".htm"} local CheckFile = function(file) for i,v in ipairs(Invalid) do if file:find(v:lower(),1,true) then return false end end return true end Downloads,Total = {},0 if Web.ListFiles then OnError("Listing files in: "..fpath) end lfs.chdir(fpath) for item in lfs.dir(fpath) do if CheckFile(item) then local x = lfs.attributes(item) if x and x.mode == "file" then local time,size,name = os.date(nil,x.modification),x.size,item:gsub("%s","%%20") Total = Total + size table.insert(Downloads,{time,FmtSz(size),"<a href=\""..url.."/"..name.."\"/>"..item.."</a>"}) table.insert(t,{time,FmtSz(size),"<a href=\""..url.."/"..name.."\"/>"..item.."</a>"}) if Web.ListFiles then OnError(tostring(#Downloads).." ) "..item) end end end end if Web.ListFiles then OnError("End of listing, "..tostring(#Downloads).." found.") else OnError(tostring(#Downloads).." downloads in "..fpath.." processed.") end local pl,sp = "s"," " if #Downloads == 1 then pl = "" end table.insert(t,{" "," "," "}) table.insert(t,{sp:rep(25).."<b>Totals:</b>","<b>"..FmtSz(Total).."</b>","<b>"..AddComma(#Downloads).." file"..pl}) table.insert(t,1,{"<b>Date / Time</b>","<b>Size</b>","<b>Name</b>"}) table.insert(t,2,{" "," "," "}) lfs.chdir(Web.HubPath.."scripts") SaveToFile(Web.Site[6][2],Downloads,"Downloads") return Web.Head..Web.Css..Web.Body..GenTab(t,Web.Site[6][4],1)..Web.Foot end end, function() local t = {} for i,v in ipairs(Downloads) do local _,_,file = v[3]:find("%>(%S+)%</") if file then table.insert(t,file.."\t("..v[2]..")") end end return t end, -- Adjust To Your Profiles [0 = disable / 1 = enable] {[-1] = 0,[0] = 1,[1] = 1,[2] = 1,[3] = 1,[4] = 1,[5] = 1,[6] = 1,}}, } Web.Head = "<html>\n<head>\n<title>"..SetMan.GetString(0).." - ‹›</title>\n".. "<meta http-equiv=page-enter content=\"blendTrans(Duration=2)\">\n".. "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n".. "<meta name=robots content=\"noindex,nofollow\">\n".. "<meta http-equiv=pragma content=no-cache>\n".. "<link rel=\"shortcut icon\" href=\"favicon.ico\">\n" Web.Frame = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\"\n".. "\"http://www.w3.org/TR/html4/frameset.dtd\">\n"..Web.Head Web.Head = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n".. "\"http://www.w3.org/TR/html4/loose.dtd\">\n"..Web.Head Web.Css = "<link rel=\"stylesheet\" href=\""..Web.Root[6][1].."\" type=\"text/css\">\n" --Index Web.Root[1][3] = Web.Frame.."</head>\n<frameset rows=\"130,*,45\" cols=\"*\">\n".. "<frame name=\"top\" src=\"top.html\" scrolling=\"no\" frameborder=\"0\">\n".. "<frameset cols=\"200,800\" rows=\"*\" >\n".. "<frame name=\"menu\" src=\"left.html\" scrolling=\"no\" frameborder=\"0\">\n".. "<frame name=\"contents\" src=\"main.html\" scrolling=\"no\" frameborder=\"0\">\n</frameset>\n".. "<frame name=\"bottom\" scrolling=\"no\" noresize src=\"bottom.html\" frameborder=\"0\">\n".. "<noframes>\n<p>This document uses frames, but your browser doesn't support them.</p>\n".. "</noframes>\n</frameset>\n</html>" --Top Web.Root[2][3] = Web.Head..Web.Css.."</head>\n<body>\n".. "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n".. "<tr>\n<td class=\"table0\" align=\"left\">".. " <script type=\"text/javascript\">document.write(Date())</script></td>\n</tr>\n".. "<tr>\n<td class=\"table1\" align=\"right\">"..HubApp.." "..HubVer..": "..desc.." </td>\n</tr>\n".. "<tr align=\"center\" valign=\"top\">\n<td class=\"table3\">\n<div align=\"center\">\n<h1>".. SetMan.GetString(0).."</h1>\n<h3>..."..topic.."</h3>\n</div>\n</td>\n</tr>\n</table>\n".. Web.Foot --Main Web.Root[3][3] = Web.Head..Web.Css..Web.Body.. "<table width=\"100%\" height=\"100%\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n".. "<tr><td class=\"table1\" valign=\"top\" align=\"left\">.:: "..Web.Root[3][2].." ::.</td>\n</tr>".. "</table>\n<iframe name=\"main\" class=\"table2\" scrolling=yes width=\"100%\" ".. "height=\"400\" align=\"left\" frameborder=\"0\" src=\""..Web.Content.."\"></iframe>\n"..Web.Foot --Bottom Web.Root[4][3] = Web.Head..Web.Css..Web.Body.. "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n".. "<tr>\n<td class=\"table1\" align=\"left\" colspan=\"2\" ></td>\n</tr>\n<tr>\n".. "<td class=\"table0\" align=\"center\" colspan=\"2\" ><script type=\"text/javascript\">".. "document.write(\"You're using: \"+navigator.appName+\" \"+navigator.appCodeName+\" \"+navigator.appVersion+\"\");\n".. "</script>\n</td>\n</tr>\n</table>\n"..Web.Foot --Left - Menu local ScpLinks = {} for i,v in ipairs(Web.Links) do local t = {} if tonumber(v[1]) and v[3] then table.insert(ScpLinks,{v[1],v[2],v[3]}) end end Web.Root[5][3] = Web.Head..DoPopMenu(ScpLinks)..Web.Css..Web.Body.. "<table width=\"95%\" align=\"left\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n".. "<tr><td class=\"table1\">.:: Menu ::.</td></tr>\n<tr valign=\"top\">\n<td class=\"table2\">".. "<a href=\"#\" class=\"menu\" target=\"_self\">Navigation:</a>\n<br><a href=\"index.html\" target=\"_top\">Home</a>\n" for i,v in ipairs(Web.Site) do Web.Root[5][3] = Web.Root[5][3].."<br><a href=\"".. v[3].."\" target=\"main\">"..v[4].."</a>\n" end local t = { [1] = {"Connect to Hub","dchub://"..SetMan.GetString(2)..":"..SetMan.GetString(3):gsub("%;.*$","")}, [2] = {"Contact","mailto:"..Web.Mail.."?subject=About the "..SetMan.GetString(0).." website&body=Dear "..Web.Owner..","}, } t[2][2] = t[2][2]:gsub(" ","%%20") for i,v in ipairs(t) do Web.Root[5][3] = Web.Root[5][3].."<br><a href=\"".. v[2].."\" target=\"main\">"..v[1].."</a>\n" end Web.Root[5][3] = Web.Root[5][3].."<br><a href=\"#\" class=\"menu\" target=\"_self\">Web Links:</a>\n" for i,v in ipairs(Web.Links) do if tonumber(v[1]) then if not v[3] then Web.Root[5][3] = Web.Root[5][3].."<br><a href=\"#\" onMouseover=\"showmenu(event,linkset[".. v[1].."], '130px')\" onMouseout=\"delayhidemenu()\">"..v[2].."</a> <b>»</b>\n" end else local url = v[1]:gsub(" ","%%20") Web.Root[5][3] = Web.Root[5][3].."<br><a href=\""..url.."\" " if v[1] == "#" or v[1]:find("^dchub://") then if v[1] == "#" then Web.Root[5][3] = Web.Root[5][3].."class=\"menu\" " end Web.Root[5][3] = Web.Root[5][3].."target=\"_self\">" elseif not tonumber(v[1]) then if v[3] then Web.Root[5][3] = Web.Root[5][3].."target=\""..v[3].."\">" else Web.Root[5][3] = Web.Root[5][3].."target=\"_blank\">" end end Web.Root[5][3] = Web.Root[5][3]..v[2].."</a>\n" end end Web.Root[5][3] = Web.Root[5][3].."</td></tr>\n</table>\n"..Web.Foot local HubDir = Web.HubPath local tab = {} for dir in string.gmatch(Web.Path.."/images/","(%a+)/") do table.insert(tab,dir) end local CheckDir = HubDir..table.concat(tab,"//") if not os.rename(CheckDir,CheckDir) then for _,folder in ipairs(tab) do HubDir = HubDir..folder local r,e = os.rename(HubDir,HubDir) if e and not e:lower():find("permission denied") then lfs.chdir(Web.HubPath) lfs.mkdir(folder) end HubDir = HubDir.."/" end end Copy(Web.HubPath..Web.MainText,Web.HubPath..Web.Path..Web.Content) local FileDir,FirstStart = Web.HubPath..Web.Path..Web.FileUrl,true local r,e = os.rename(FileDir,FileDir) if e and not e:lower():find("permission denied") then lfs.chdir(Web.HubPath..Web.Path) lfs.mkdir(Web.FileUrl) else FirstStart = false end local sample = Web.HubPath..Web.FileUrl.."/Setting_Up_Downloads.txt" if FirstStart and not os.rename(sample,sample) then local directions = "Simply copy your files to this folder ".. "[ Default = C:/Ptokax/html/webstats/files ]\nThen restart this ".. "script and reload the dowloads page to see the new files you've added.\n".. "You may delete this file at any time.\r\n\r\n"..string.rep(string.char(9),6).." -Mutor" local f,e = io.open(sample,"w") if f then f:write(directions) f:flush() f:close() else OnError(e:sub(1,-2)) end endendGenTab = function(t,s,noidx) local txt = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n" if s then txt = txt.."\t<tr><td class=\"table0\" valign=\"top\">.:: "..s.." ::.</td></tr></table>\n" else txt = txt.."\t<tr><td class=\"table0\" valign=\"top\"> </td></tr>\n" end txt = txt.."<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" if next(t) then for i,v in ipairs(t) do if noidx then txt = txt.."\n\t<tr align=\"left\" valign=\"top\">" else txt = txt.."\n\t<tr align=\"left\" valign=\"top\">".. "<td class=\"table3\" width=\"10%\"> "..i.."</td>" end if type(v) == "table" then local z = #v for x=1, z do if x < z then txt = txt.."<td class=\"table3\" width=\""..(12*x).. "%\"> <b>"..v[x].."</b></td>" else local s = (100 - (x*12)) txt = txt.."<td class=\"table3\"width=\""..s.."%\"> "..v[x].."</td>" end end else txt = txt.."<td class=\"table3\" width=\"90%\"> "..v.."</td>" end end txt = txt.."</tr>\n" else txt = txt.."\t<tr><td> No</td>\n<td>Data</td>\n</tr>\n" end txt = txt.."</table>\n<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n".. "\t<tr><td class=\"table2\" valign=\"top\"></td></tr>\n</table>\n" return txtendDoHtml = function(file,title,body) local method = "updated" if not os.rename(file,file) then method = "saved" end body = body:gsub("%b‹›",title) local f,e = io.open(file,"w") if f then if not Web.Refresh then OnError(title.." has been "..method) end f:write(body) f:flush() f:close() else OnError(e:sub(1,2)) endendDoRoot = function(x) for i,v in ipairs(Web.Root) do if v[3] then if x or not os.rename(Web.Url..v[1],Web.Url..v[1]) then DoHtml(Web.Url..v[1],v[2],v[3]) end end endendDoTabs = function(x,t,n) if x and t and n then if t[5] then local html = t[5](n) if html then DoHtml(Web.Url..t[3],t[4],html) end end else for i,v in ipairs(Web.Site) do local tab = v[1] if loadfile(v[2]) then dofile(v[2]) if v[1] == "Chat" and Chat and next(Chat) then if Chat[1][3] then local t = {} for i,v in ipairs(Chat) do table.insert(t,{v[1],"<"..v[2].."> ".. DoAscii(v[3]:gsub("•",""))}) end Chat = t end SaveToFile(Web.Site[2][2],Chat ,"Chat") end else tab = {} SaveToFile(v[2],tab,v[1]) dofile(v[2]) end if x or not os.rename(Web.Url..v[3],Web.Url..v[3]) then if v[5] then local html = v[5]() if html then DoHtml(Web.Url..v[3],v[4],html) end end end end endendDoCss = function() local css = "body {\n".. "\tcolor: "..Web.Style.fcolor..";\n".. "\tfont-family: "..Web.Style.font..";\n".. "\tbackground-image: url("..Web.Style.bgimage..");\n".. "\tbackground-repeat: repeat;\n".. "\tbackground-color: "..Web.Style.bgcolor..";\n".. "}\n".. "a:link {\n".. "\tcolor: "..Web.Style.lcolor..";\n".. "\ttext-decoration: none;\n".. "}\n".. "a:visited {\n".. "\tcolor: "..Web.Style.vcolor..";\n".. "\ttext-decoration: none;\n".. "}\n".. "a:hover {\n".. "\tcolor: "..Web.Style.hcolor..";\n".. "\ttext-decoration: underline overline;\n".. "}\n".. ".menu {\n".. "\tcolor: #E9E9F8;\n".. "\ttext-decoration: none;\n".. "\twidth: 100%;\n".. "\tbackground-color: #8784C6;\n".. "}\n".. ".table0 {\n".. "\theight: 12px;\n".. "\tcolor: #E9E9F8;\n".. "\tfont-size: 12px;\n".. "\tbackground-color : #1E2580;\n" if Web.Style.tborders == "yes" then css = css.."\tborder-top: 1px solid #8784C6;\n".. "\tborder-bottom: 1px solid #8784C6;\n".. "\tborder-left: 1px solid #8784C6;\n".. "\tborder-right: 1px solid #8784C6;\n" end css = css.."}\n".. ".table1 {\n".. "\theight: 12px;\n".. "\ttext-indent: 5px;\n".. "\tcolor : White;\n".. "\tfont-size : 12px;\n".. "\tbackground : #8784C6;\n" if Web.Style.tborders == "yes" then css = css.."\tbackground-color : #8784C6;\n".. "\tborder-bottom: 2px solid Black;\n".. "\tborder-left: 1px solid Black;\n".. "\tborder-right: 1px solid Black;\n".. "\tborder-top: 1px solid Black;\n" end css = css.."}\n".. ".table2 {\n".. "\theight: 400px;\n".. "\twidth: 100%;\n".. "\tcolor: Black;\n".. "\tfont-size: 12px;\n".. "\tbackground: #E9E9F8;\n" if Web.Style.tborders == "yes" then css = css.."\tborder-top: 1px solid #8784C6;\n".. "\tborder-bottom: 1px solid #8784C6;\n".. "\tborder-left: 1px solid #8784C6;\n".. "\tborder-right: 1px solid #8784C6;\n" end css = css.."}\n".. ".table3 {\n".. "\theight: 12px;\n".. "\twidth: auto;\n".. "\tcolor: Black;\n".. "\tfont-size: 12px;\n".. "\tbackground: #E9E9F8;\n" if Web.Style.tborders == "yes" then css = css.."\tborder-top: 1px solid #8784C6;\n".. "\tborder-bottom: 1px solid #8784C6;\n".. "\tborder-left: 1px solid #8784C6;\n".. "\tborder-right: 1px solid #8784C6;\n" end css = css.."}\n".. ".table4 {\n".. "\theight: 12px;\n".. "\twidth: auto;\n".. "\tcolor: Black;\n".. "\tfont-size: 8px;\n".. "\tbackground: #E9E9F8;\n" if Web.Style.tborders == "yes" then css = css.."\tborder-top: 1px solid #8784C6;\n".. "\tborder-bottom: 1px solid #8784C6;\n".. "\tborder-left: 1px solid #8784C6;\n".. "\tborder-right: 1px solid #8784C6;\n" end css = css.."}" local f,e = io.open(Web.Url..Web.Root[6][1], "w") if f then f:write(css) f:flush() f:close() else OnError(e:sub(1,-2)) endendDoPopMenu = function(t) if next(t) then local scp = "<style type=\"text/css\">\n".. "\n".. "#popitmenu{\n".. "position: absolute;\n".. "background-color: white;\n".. "border:1px solid black;\n".. "font: normal 12px Verdana;\n".. "line-height: 18px;\n".. "z-index: 100;\n".. "visibility: hidden;\n".. "}\n".. "\n".. "#popitmenu a{\n".. "text-decoration: none;\n".. "padding-left: 6px;\n".. "color: black;\n".. "display: block;\n".. "}\n".. "\n".. "#popitmenu a:hover{ /*hover background color*/\n".. "background-color: #E9E9F8;\n".. "}\n".. "\n".. "</style>\n".. "\n".. "<script type=\"text/javascript\">\n".. "\n".. "/***********************************************\n".. "* Pop-it menu- © Dynamic Drive (www.dynamicdrive.com)\n".. "* This notice MUST stay intact for legal use\n".. "* Visit http://www.dynamicdrive.com/ for full source code\n".. "***********************************************/\n".. "\n".. "var defaultMenuWidth=\"150px\" //set default menu width.\n".. "\n".. "var linkset=new Array()\n".. "\n" --"linkset[0]+='\<a href=\"http://www.javascriptkit.com\"\>JavaScript Kit\</a\>'\n".. for i,v in ipairs(t) do local add = "+" if i == 1 then add = "" end --OnError(tostring(i).."\t"..v[1].."\t"..v[2].."\t"..v[3]) scp = scp.."linkset["..v[1].."]"..add.."='<a href=\""..v[2].."\" target=\"_blank\">"..v[3].."</a>'\n" end scp = scp.."\n".. "var ie5=document.all && !window.opera\n".. "var ns6=document.getElementById\n".. "if (ie5||ns6)\n".. "document.write('<div id=\"popitmenu\" onMouseover=\"clearhidemenu();\" onMouseout=\"dynamichide(event)\"></div>')\n".. "function iecompattest(){\n".. "return (document.compatMode && document.compatMode.indexOf(\"CSS\")!=-1)? document.documentElement : document.body\n".. "}\n".. "function showmenu(e, which, optWidth){\n".. "if (!document.all&&!document.getElementById)\n".. "return\n".. "clearhidemenu()\n".. "menuobj=ie5? document.all.popitmenu : document.getElementById(\"popitmenu\")\n".. "menuobj.innerHTML=which\n".. "menuobj.style.width=(typeof optWidth!=\"undefined\")? optWidth : defaultMenuWidth\n".. "menuobj.contentwidth=menuobj.offsetWidth\n".. "menuobj.contentheight=menuobj.offsetHeight\n".. "eventX=ie5? event.clientX : e.clientX\n".. "eventY=ie5? event.clientY : e.clientY\n".. "//Find out how close the mouse is to the corner of the window\n".. "var rightedge=ie5? iecompattest().clientWidth-eventX : window.innerWidth-eventX\n".. "var bottomedge=ie5? iecompattest().clientHeight-eventY : window.innerHeight-eventY\n".. "//if the horizontal distance isn't enough to accomodate the width of the context menu\n".. "if (rightedge<menuobj.contentwidth)\n".. "//move the horizontal position of the menu to the left by it's width\n".. "menuobj.style.left=ie5? iecompattest().scrollLeft+eventX-menuobj.contentwidth+\"px\" : window.pageXOffset+eventX-menuobj.contentwidth-\"px\"\n".. "else\n".. "//position the horizontal position of the menu where the mouse was clicked\n".. "menuobj.style.left=ie5? iecompattest().scrollLeft+eventX+\"px\" : window.pageXOffset+eventX+\"px\"\n".. "//same concept with the vertical position\n".. "if (bottomedge<menuobj.contentheight)\n".. "menuobj.style.top=ie5? iecompattest().scrollTop+eventY-menuobj.contentheight+\"px\" : window.pageYOffset+eventY-menuobj.contentheight+\"px\"\n".. "else\n".. "menuobj.style.top=ie5? iecompattest().scrollTop+event.clientY+\"px\" : window.pageYOffset+eventY+\"px\"\n".. "menuobj.style.visibility=\"visible\"\n".. "return false\n".. "}\n".. "function contains_ns6(a, b) {\n".. "//Determines if 1 element in contained in another- by Brainjar.com\n".. "while (b.parentNode)\n".. "if ((b = b.parentNode) == a)\n".. "return true;\n".. "return false;\n".. "}\n".. "function hidemenu(){\n".. "if (window.menuobj)\n".. "menuobj.style.visibility=\"hidden\"\n".. "}\n".. "function dynamichide(e){\n".. "if (ie5&&!menuobj.contains(e.toElement))\n".. "hidemenu()\n".. "else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))\n".. "hidemenu()\n".. "}\n".. "function delayhidemenu(){\n".. "delayhide=setTimeout(\"hidemenu()\",500)\n".. "}\n".. "function clearhidemenu(){\n".. "if (window.delayhide)\n".. "clearTimeout(delayhide)\n".. "}\n".. "if (ie5||ns6)\n".. "document.onclick=hidemenu\n".. "</script>\n" return scp endendfunction Chk(enable) if enable == "" or not enable then enable = "not set" end return enableendFmtSz = function(int) local i,u,x=tonumber(int) or 0,{"","K","M","G","T","P"},1 while i > 1024 do i,x = i/1024,x+1 end return string.format("%.2f %sB.",i,u[x])endAddComma = function(i) i = tostring(i) repeat i,x = i:gsub("^(-?%d+)(%d%d%d)", '%1,%2') until x == 0 return i endConvert = function(time) time = time or 0 local s,x,n,tab = "",0,os.time(),{ [1] = {31556926,"year"}, [2] = {2592000,"month"}, [3] = {604800,"week"}, [4] = {86400,"day"}, [5] = {3600,"hour"}, [6] = {60,"minute"}, [7] = {1,"second"} } if time > 0 then if time < 2145876659 then if n > time then time = n - time for i,v in ipairs(tab) do if time > v[1] then x = math.floor(time/v[1]) if x > 1 then v[2] = v[2].."s" end if x > 0 then s = s..x.." "..v[2]..", " time = time-x*v[1] end end end end collectgarbage("collect") return s:sub(1,-3) else return "Invalid date or time supplied. [must be pre 12/31/2037]" end else return "No uptime recorded" endendCopy = function(source,target) local is,os,text local f,e = io.open(source) if f then text,is = f:read("*a"),f:seek("end") f:close() else OnError(e:sub(1,-2)) end local tab = { {"%[Hub%]",0},{"%[Admin%]",1},{"%[Addr%]",2},{"%[Desc%]",5},{"%[Redir%]",6}, {"%[List%]",7},{"%[Topic%]",10},{"%[Bot%]",21},{"%[OpChat%]",24},{"%[Email%]",30}, {"%[Lang%]",34}, } for i,v in ipairs(tab) do text = text:gsub(v[1],SetMan.GetString(v[2]) or "%1: Not Set In GUI!") end if text then local f,e = io.open(target,"w") if f then text = Web.Head:gsub("%b‹›","MOTD")..Web.Css..Web.Body.. "<table class=\"table2\" bgcolor=\"#E9E9F8\" width=\"100%\" ".. "border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n".. "<tr><td class=\"table3\" valign=\"top\">\n<pre>"..text.."</pre>"..Web.Ad.. "\n</td></tr>\n</table>\n"..Web.Foot f:write(text) f:flush() os = f:seek("end") f:close() else OnError(e:sub(1,-2)) end endend--Replace certain characters with html ASCII code & vice versaDoAscii = function(data,rev) if rev then for i,v in pairs(Web.Asc) do data = data:gsub(v,string.char(i)) end return data else for chr in data:gmatch(".") do local x = Web.Asc[string.byte(chr)] if x then data = data:gsub(chr,x) end end return data endendGenCmds = function(user) local c,t,x = "",{} local p,m,s = SetMan.GetString(29):sub(1,1),SetMan.GetString(0),Web.Script for i,v in ipairs(Web.Site) do if v[7][user.iProfile] and v[7][user.iProfile] == 1 then x = true c = c.."$UserCommand 1 1 "..m.."\\"..s.."\\".. v[4].."$<%[mynick]> "..p..v[1]:lower().."||" end end if x then Core.SendToNick(user.sNick,c:sub(1,-2)) return x endendfunction Serialize(tTable, sTableName, sTab) sTab = sTab or "" sTmp = "" sTmp = sTmp..sTab..sTableName.." = {\n" for key, value in ipairs(tTable) do local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key) if(type(value) == "table") then sTmp = sTmp..Serialize(value, sKey, sTab.."\t") else local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value) sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue end sTmp = sTmp..",\n" end sTmp = sTmp..sTab.."}" return sTmpendfunction SaveToFile(file , table , tablename,mode) if not mode then mode = "w" end local handle,err = io.open(file,mode) if handle then handle:write(Serialize(table, tablename)) handle:flush() handle:close() else OnError(err:sub(1,2)) endend