ПОМОГИТЕ ОЧЕНЬ ВАЖНО !, Хорошая Идея помогите |
Здравствуйте, гость ( Вход | Регистрация )
ПОМОГИТЕ ОЧЕНЬ ВАЖНО !, Хорошая Идея помогите |
13.12.2009, 21:48
Сообщение
#1
|
|
Начинающий Группа: Пользователи Сообщений: 11 Регистрация: 1.8.2009 Пользователь №: 4 036 Спасибо сказали: 0 раз |
Помогите Плиз , Помогите Зделать С Этого Скрипта Приветствие Сморется будет Хорошо !!
--################################################################################### -- StatPX 1.03 beta by alex82 -- -- PtokaX 0.4.0/0.4.1, LUA 5.1.3 -- В скрипте использованы фрагменты кода <TopHubbers 2.01 by jiten & NRJ> --################################################################################### path = debug.getinfo(1).source:match("^@(.+[/\\]).-$"):gsub("\\","/").."StatPX/" dofile(path.."config.lu") --################################################################################### --ОСНОВНЫЕ ФУНКЦИИ СКРИПТА Months = {"янв","фев","мар","апр","мая","июл","июн","авг","сен","окт","ноя","дек"} Chars = {["\r"] = "\\r",["\n"] = "\\n",["\t"] = "\\t",["\<"] = "\\<",["\>"] = "\\>",["\""] = "\\\"",["\>"] = "\\>",} tMode = {A = "Актив",P = "\<font color=\"red\"\>Пассив\</font\>"} WebStatForceCount,UpdateOnlineCount,Template = 0,0,1 tUserStat,tUserNicks = {},{} tHubStat = {MaxUsers = 0, MaxUsersTime = 0, MaxShare = 0, MaxShareTime = 0} --TempFile = true Version = "1.03 beta2" function OnStartup() sBot = SetMan.GetString(21) HubName = SetMan.GetString(0) if loadfile(fOnline) then dofile(fOnline) end TmrMan.AddTimer(60000,"MainTimer") TmrMan.AddTimer(iSave*60000,"Save") TmrMan.AddTimer(iCleanMemory*60000,"CleanMemory") UpdateOnline() UpdateHubStats() if bSendMOTD then LoadMOTD() end if WebStat then TmrMan.AddTimer(WebStatUpdate*60000,"WebTimer") TmrMan.AddTimer(TopHubbersUpdate*60000,"BuildTopHubbers") if AllowChangeSkins and loadfile(fTplConfig) then dofile(fTplConfig) end LoadTemplates() if next(tUserStat) then BuildTopHubbers() end BuildWebStat() else UpdateUserStats() end end function MainTimer() UpdateHubStats() UpdateOnlineCount = UpdateOnlineCount+1 if UpdateOnlineCount == 60 then UpdateOnlineCount = 0 UpdateOnline() end for i, v in pairs(tUserStat) do if v.Online > 0 then v.SessionTime = v.SessionTime + 1; v.TotalTime = v.TotalTime + 1 end end end function WebTimer() BuildWebStat() end function CleanMemory() collectgarbage("collect") end function OnExit() Save() if WebStat then ScriptStopped = true BuildWebStat() BuildTopHubbers() end end function UserConnected(user) Core.GetUserAllData(user) if WebStat then WebStatForceCount = WebStatForceCount + 1 if WebStatForceCount >= WebStatForceUpdate then WebStatCount = 0 WebStatForceCount = 0 BuildWebStat(user) end end if tUserStat[user.sIP] then tUserStat[user.sIP].Name = user.sNick tUserStat[user.sIP].Profile = user.iProfile if tUserNicks[user.sIP] then if tUserNicks[user.sIP][user.sNick] then tUserNicks[user.sIP][user.sNick] = tUserNicks[user.sIP][user.sNick] + 1 else tUserNicks[user.sIP][user.sNick] = 1 end else tUserNicks[user.sIP] = {[user.sNick] = 1} end if tSettings.bWarning then local iAverage = os.difftime(os.time(os.date("*t")), tUserStat[user.sIP].FirstVisit)/86400 if iAverage < 1 then iAverage = 1 end if tUserStat[user.sIP].TotalTime/iAverage < tSettings.iAUT*60 then Core.SendPmToNick(user.sNick,sBot, "Ваше среднее время прибывания на хабе меньше, чем "..tSettings.iAUT.. " час(ов). Мы планируем ввести ограничения для таких пользователей!") end end tUserStat[user.sIP].Online = tUserStat[user.sIP].Online+1 tUserStat[user.sIP].SessionTime = 0; tUserStat[user.sIP].Enter = os.time(os.date("*t")) if tSettings.bRankOnConnect then Core.SendToUser(user,"<"..sBot.."> "..BuildStats(user.sIP)) end else tUserStat[user.sIP] = { Name = user.sNick, Profile = user.iProfile, FirstVisit = os.time(os.date("*t")), Enter = os.time(os.date("*t")), SessionTime = 0, TotalTime = 0, Leave = os.time(os.date("*t")), Online = 1} tUserNicks[user.sIP] = {[user.sNick] = 1} end Core.SendToUser(user,"$UserCommand 1 3 "..sMenu.."\\Общая статистика $<%[mynick]> "..sPrefix..tCmd.MainStat.."|") Core.SendToUser(user,"$UserCommand 1 3 "..sMenu.."\\Показать Топ "..tSettings.iMax.." $<%[mynick]> "..sPrefix..tCmd.Top.."|") Core.SendToUser(user,"$UserCommand 1 3 "..sMenu.."\\Показать часть топа (x-y) $<%[mynick]> "..sPrefix..tCmd.Top.." %[line:Введите диапазон номеров x-y]|") Core.SendToUser(user,"$UserCommand 1 3 "..sMenu.."\\Твоя статистика $<%[mynick]> "..sPrefix..tCmd.MyStat.."|") if pAdmin[user.iProfile] == 1 then Core.SendToUser(user,"$UserCommand 1 2 "..sUserMenu.."\\Статистика юзера $<%[mynick]> "..sPrefix..tCmd.StatNick.." %[nick]|") Core.SendToUser(user,"$UserCommand 1 3 "..sAdminMenu.."\\Статистика ника... $<%[mynick]> "..sPrefix..tCmd.StatNick.." %[line:Введите ник]|") Core.SendToUser(user,"$UserCommand 1 3 "..sAdminMenu.."\\Поиск ника... $<%[mynick]> "..sPrefix..tCmd.SearchNick.." %[line:Введите ник или часть ника]|") Core.SendToUser(user,"$UserCommand 1 3 "..sAdminMenu.."\\Статистика IP... $<%[mynick]> "..sPrefix..tCmd.StatIP.." %[line:Введите IP]|") Core.SendToUser(user,"$UserCommand 1 3 "..sAdminMenu.."\\Поиск IP... $<%[mynick]> "..sPrefix..tCmd.SearchIP.." %[line:Введите начальные символы IP адреса]|") end if user.iProfile == 0 then Core.SendToUser(user,"$UserCommand 0 3") Core.SendToUser(user,"$UserCommand 1 3 "..sAdminMenu.."\\Очистка базы данных $<%[mynick]> "..sPrefix..tCmd.CleanDB.." %[line:За сколько дней сохранить записи?]|") if bSendMOTD then Core.SendToUser(user,"$UserCommand 1 3 "..sAdminMenu.."\\Перезагрузить сообщение дня $<%[mynick]> "..sPrefix..tCmd.ReLoadMOTD.."|") end end if user.iProfile == 0 and WebStat then Core.SendToUser(user,"$UserCommand 1 3 "..sAdminMenu.."\\Перезагрузить шаблоны $<%[mynick]> "..sPrefix..tCmd.ReLoadTemplates.."|") if AllowChangeSkins then for i in ipairs(tSkins) do Core.SendToUser(user,"$UserCommand 1 3 "..sAdminMenu.."\\Выбор скина\\"..tSkins[i][1].." $<%[mynick]> "..sPrefix..tCmd.SetTemplate.." "..i.."|") end end end if bSendMOTD then if LastUpdate+iUpdateTime*60 < os.time(os.date("*t")) then UpdateUserStats() end msg = GetMOTD(user) Core.SendToUser(user,"<"..sBot.."> "..msg) end end OpConnected = UserConnected RegConnected = UserConnected function UserDisconnected(user) if tUserStat[user.sIP] then tUserStat[user.sIP].Online = tUserStat[user.sIP].Online-1 tUserStat[user.sIP].Leave = os.time(os.date("*t")) if tUserStat[user.sIP].Online < 0 then UpdateOnline() end end end OpDisconnected = UserDisconnected RegDisconnected = UserDisconnected function ChatArrival(user,data) Core.GetUserAllData(user) local data = data:sub(1,-2) local pre,cmd = string.match(data,"%b<>%s*(%p)(%S+)") if pre and pre == sPrefix then if cmd then if cmd == tCmd.MainStat then if not(WebStat) then UpdateUserStats() end local msg = "\r\n\t"..string.rep("=", 40).."\r\n\t\t\tСтатистика хаба\r\n\t"..string.rep("-", 80).. "\r\n\tПользователей за сутки:\t\t"..UsersDay.."\r\n\tПользователей за неделю:\t\t"..UsersWeek.. "\r\n\tПользователей за месяц\t\t"..UsersMonth.."\r\n\tПользователей за всё время\t"..UsersTotal.. "\r\n\tНовых пользователей за сутки:\t"..NewUsersDay.."\r\n\tНовых пользователей за неделю\t"..NewUsersWeek.."\r\n".. "\r\n\tРекорд по количеству пользователей: "..tHubStat.MaxUsers.."\r\n\tРекорд зафиксирован\t"..GetDate(tHubStat.MaxUsersTime).."\r\n".. "\r\n\tРекорд по общему размеру шары: "..GetNormalShare(tHubStat.MaxShare).."\r\n\tРекорд зафиксирован\t"..GetDate(tHubStat.MaxShareTime).."\r\n".. "\r\n\t"..string.rep("-", 80) Core.SendPmToNick(user.sNick,sBot,msg) return true elseif cmd == tCmd.Top then if next(tUserStat) then local iStart, iEnd = string.match(data, "%b<>%s*%p%S+%s(%d+)%-(%d+)$") iStart, iEnd = (iStart or 1), (iEnd or tSettings.iMax) local tCopy, msg = {}, "\r\n\t"..string.rep("=", 125).."\r\n\t№\tВсего:\t\t\tСессия:\t".. "Пришел на хаб:\tПокинул хаб:\tРанг:\t\t" if user.iProfile == 0 then msg = msg.."IP:\t\t" end msg = msg.."Ник:\r\n\t"..string.rep("-", 250).."\r\n" for i, v in pairs(tUserStat) do table.insert(tCopy, { sEnter = GetDate(v.Enter), iSessionTime = tonumber(v.SessionTime), iOnline = v.Online, iTotalTime = tonumber(v.TotalTime), sLeave = GetDate(v.Leave), sNick = v.Name, sIP = i, sRank = GetRank(i) } ) end table.sort(tCopy, function(a, b) return (a.iTotalTime > b.iTotalTime) end) for i = iStart, iEnd, 1 do if tCopy[i] then local v = tCopy[i] local sLeave = v.sLeave local sRank = v.sRank if v.iOnline > 0 then sLeave = "*Онлайн*\t" end if string.len(v.sRank) < 9 then sRank = sRank.."\t" end msg = msg.."\t"..i..". "..MinutesToTime(v.iTotalTime).."\t\t"..v.iSessionTime.. " мин\t"..v.sEnter.."\t"..sLeave.."\t"..sRank.."\t" if user.iProfile == 0 then msg = msg..v.sIP.."\t" end msg = msg..v.sNick.."\r\n" end end msg = msg.."\t"..string.rep("-", 250) Core.SendPmToNick(user.sNick,sBot, "Топ юзеров по проведенному на хабе времени:\r\n"..msg.."\r\n") else Core.SendToUser(user,"<"..sBot.."> *** Ошибка: таблица топа хабберов пуста!") end return true elseif cmd == tCmd.MyStat then local msg = BuildStats(user.sIP) if msg then Core.SendToUser(user,"<"..sBot.."> ".. msg) else Core.SendToUser(user,"<"..sBot.."> *** Ошибка: Не найдено информации по IP: '"..IP.."'!") end return true end if pAdmin[user.iProfile] == 1 then if cmd == tCmd.StatNick then local nick = string.match(data, "%b<>%s*%p%S+%s(%S+)$") if nick then local msg = "" for i in pairs(tUserNicks) do for i2 in pairs(tUserNicks[i]) do if i2 == nick then msg = msg..BuildStats(i,true) end end end if msg == "" then Core.SendToUser(user,"<"..sBot.."> Информация по нику "..nick.." не найдена в базе.") else Core.SendToUser(user,"<"..sBot.."> "..msg) end else Core.SendToUser(user,"<"..sBot.."> *** Ошибка! Введите "..sPrefix..tCmd.StatNick.." <nick>") end return true elseif cmd == tCmd.SearchNick then local nick = string.match(data, "%b<>%s*%p%S+%s(%S+)$") if nick then local msg = "" local results = 0 for i in pairs(tUserNicks) do for i2 in pairs(tUserNicks[i]) do if string.find(i2:lower(),nick:lower()) then msg = msg..BuildStats(i,true) results = results+1 break end end end if results == 0 then Core.SendToUser(user,"<"..sBot.."> Информация по нику "..nick.." не найдена в базе.") else msg = "\r\n\t"..string.rep("=", 40).."\r\n\tРезультат поиска по нику \""..nick.."\": ".."\r\n\t"..string.rep("=", 40).. msg.."\r\n\t"..string.rep("=", 40).."\r\n\t\tВсего записей: "..results.."\r\n\t"..string.rep("=", 40) Core.SendPmToNick(user.sNick,sBot,msg) end else Core.SendToUser(user,"<"..sBot.."> *** Ошибка! Введите "..sPrefix..tCmd.StatNick.." <nick>") end return true elseif cmd == tCmd.StatIP then local IP = string.match(data, "%b<>%s*%p%S+%s(%S+)$") if IP then local msg = BuildStats(IP,true) if msg then Core.SendToUser(user,"<"..sBot.."> ".. msg) else Core.SendToUser(user,"<"..sBot.."> *** Ошибка: Не найдено информации по IP: '"..IP.."'!") end else Core.SendToUser(user,"<"..sBot.."> *** Ошибка! Введите "..sPrefix..tCmd.StatIP.." <IP>") end return true elseif cmd == tCmd.SearchIP then local IP = string.match(data, "%b<>%s*%p%S+%s(%S+)$") if IP then local msg = "" local results = 0 for i,v in pairs(tUserStat) do if i:find("^"..IP) then msg = msg..BuildStats(i,true) results = results+1 end end if results == 0 then Core.SendToUser(user,"<"..sBot.."> *** Ошибка: Не найдено информации по IP: '"..IP.."'!") else msg = "\r\n\t"..string.rep("=", 40).."\r\n\tРезультат поиска по IP "..IP..": ".."\r\n\t"..string.rep("=", 40).. msg.."\r\n\t"..string.rep("=", 40).."\r\n\t\tВсего записей: "..results.."\r\n\t"..string.rep("=", 40) Core.SendPmToNick(user.sNick,sBot,msg) end else Core.SendToUser(user,"<"..sBot.."> *** Ошибка! Введите "..sPrefix..tCmd.SearchIP.." <IP>") end return true end end if user.iProfile == 0 then if cmd == tCmd.CleanDB then local number = string.match(data, "%b<>%s*%p%S+%s(%d+)$") number = tonumber(number) if number then Core.SendToUser(user,"Очистка базы данных...") local result = CleanDatabase(number) Core.SendToUser(user,"Очистка базы данных завершена. Удалено "..result.." записей.") else Core.SendToUser(user,"<"..sBot.."> *** Ошибка! Вы должны указать количество дней.") end return true end end if user.iProfile == 0 and bSendMOTD then if cmd == tCmd.ReLoadMOTD then Core.SendToUser(user,"Перезагрузка сообщения дня...") LoadMOTD() return true end end if user.iProfile == 0 and WebStat then if cmd == tCmd.ReLoadTemplates then Core.SendToUser(user,"Перезагрузка шаблонов...") LoadTemplates() BuildWebStat() BuildTopHubbers() return true end if AllowChangeSkins and cmd == tCmd.SetTemplate then local num = string.match(data, "%b<>%s*%p%S+%s(%d+)$") if num then num = tonumber(num) if tSkins[num] then Core.SendToUser(user,"Выбран скин \""..tSkins[num][1].."\"") Template = num SaveTplCfg() LoadTemplates() BuildWebStat() BuildTopHubbers() else Core.SendToUser(user,"Ошибка! Информация о скине в настройках не найдена") end else Core.SendToUser(user,"Ошибка! Вы должны указать номер скина.") end return true end end end end end function BuildStats(IP,Ext) if tUserStat[IP] then local iAverage = os.difftime(os.time(os.date("*t")), tUserStat[IP].FirstVisit)/(60*60*24) if iAverage < 1 then iAverage = 1 end local sMsg = "\r\n\r\n\t"..string.rep("=", 40).."\r\n\t\tСтатистика пользователя:\r\n\t".. string.rep("-", 80).."\r\n\t- Ник: "..tUserStat[IP].Name.."\r\n\t- IP: "..IP.."\r\n\t- Общее время на хабе: ".. MinutesToTime(tUserStat[IP].TotalTime, true).."\r\n\t- Среднее время на хабе в сутки: ".. MinutesToTime((tUserStat[IP].TotalTime/iAverage), true).."\r\n\t- Ранг: "..GetRank(IP).."\r\n" if Ext then sMsg = sMsg.."\r\n\t- Первый визит:\t"..GetDate(tUserStat[IP].FirstVisit).."\r\n\t- Пришёл на хаб:\t"..GetDate(tUserStat[IP].Enter).."\r\n" if tUserStat[IP].Online < 1 then sMsg = sMsg.."\t- Покинул хаб:\t"..GetDate(tUserStat[IP].Leave).."\r\n" end sMsg = sMsg.."\r\n\tС данного адреса заходили под никами:\r\n" if tUserNicks[IP] then for nick in pairs(tUserNicks[IP]) do sMsg = sMsg.."\t- "..nick.." - "..tUserNicks[IP][nick].." раз(а)\r\n" end end end return sMsg else return nil end end function GetRank(IP) local sRank = "" local first = true for i in pairs(tSettings.tRanks) do if tUserStat[IP].TotalTime >= tSettings.tRanks[i][1]*60*24 or first == true then sRank = tSettings.tRanks[i][2] end first = false end return sRank end function MinutesToTime(iSeconds, bSmall) local T = os.date("!*t", tonumber(iSeconds*60)); local sTime = "" T.month = T.month-1 T.day = T.day-1 if T.month ~= 0 then sTime = T.month.." мec. "..T.day.." д. "..T.hour.." ч. "..T.min.." м." else if T.day ~= 0 then sTime = T.day.." дн. "..T.hour.." час. "..T.min.." мин." else if T.hour ~= 0 then sTime = T.hour.." часов "..T.min.." минут" else sTime = T.min.." минут\t" end end end return sTime end function GetDate(data) return os.date("%d "..Months[os.date("*t",data).month].." в %H:%M",data) end tShare = {" B"," kB"," MB"," GB"," TB"," PB"," EB"} function GetNormalShare(share) local i = 1 while share > 1024 do share = share/1024 i = i+1 end return string.format("%.3f",share)..tShare[i] end function UpdateHubStats() local sTotalUsers = Core.GetUsersCount() local sTotalShare = Core.GetCurrentSharedSize() if sTotalUsers > tHubStat.MaxUsers then tHubStat.MaxUsers = sTotalUsers tHubStat.MaxUsersTime = os.time(os.date("*t")) Core.SendToAll("<"..sBot.."> Установлен новый рекорд по количеству пользователей: "..sTotalUsers.." !") end if sTotalShare > tHubStat.MaxShare then tHubStat.MaxShare = sTotalShare tHubStat.MaxShareTime = os.time(os.date("*t")) Core.SendToAll("<"..sBot.."> Установлен новый рекорд по общему размеру шары: "..GetNormalShare(sTotalShare).." !") end end function UpdateOnline() for i,v in pairs(tUserStat) do v.Online = 0 end for i,v in pairs(Core.GetOnlineUsers(true)) do if tUserStat[v.sIP] then tUserStat[v.sIP].Online = tUserStat[v.sIP].Online+1 else tUserStat[v.sIP] = { Name = v.sNick, Profile = v.iProfile, FirstVisit = os.time(os.date("*t")), Enter = os.time(os.date("*t")), SessionTime = 0, TotalTime = 0, Leave = os.time(os.date("*t")),Online = 1} tUserNicks[v.sIP] = {[v.sNick] = 1} end end end function UpdateUserStats() NewUsersDay, NewUsersWeek, UsersDay, UsersWeek, UsersMonth, UsersTotal = 0, 0, 0, 0, 0, 0 local Time = os.time(os.date("*t")) for i, v in pairs(tUserStat) do UsersTotal = UsersTotal + 1 if v.FirstVisit+86400 >= Time then NewUsersDay = NewUsersDay + 1 end if v.FirstVisit+604800 >= Time then NewUsersWeek = NewUsersWeek + 1 end if v.Leave+604800 >= Time or v.Online > 0 then UsersWeek = UsersWeek + 1 end if v.Leave+2592000 >= Time or v.Online > 0 then UsersMonth = UsersMonth + 1 end if v.Leave+86400 >= Time or v.Online > 0 then UsersDay = UsersDay + 1 end end LastUpdate = os.time(os.date("*t")) end function CleanDatabase(days) local Time = os.time(os.date("*t")) local result = 0 for i, v in pairs(tUserStat) do if tNotClean[v.Profile] == 0 and Time-days*86400 > v.Leave and v.Online == 0 then result = result+1 tUserStat[i] = nil tUserNicks[i] = nil end end Save() return result end function LoadMOTD() local f = io.open(fMOTD, "r") if f then MOTD = f:read("*all") MOTD = "\r\n"..MOTD:gsub("%[HUBNAME%]",HubName) f:close() else SendError("Ошибка при загрузке сообщения дня: файл "..fMOTD.." не найден.") MOTD = "" end end function GetMOTD(user) local sTotalTime = MinutesToTime(tUserStat[user.sIP].TotalTime) local sFirstVisit = GetDate(tUserStat[user.sIP].FirstVisit) local sMaxUsersTime = FormatDate(tHubStat.MaxUsersTime) local sSharePeak = GetNormalShare(tHubStat.MaxShare) local sMaxShareTime = FormatDate(tHubStat.MaxShareTime) local sMinShare = SetMan.GetMinShare() local sMaxShare = SetMan.GetMaxShare() local sMinSlots = SetMan.GetNumber(5) local sMaxSlots = SetMan.GetNumber(6) local sHubRatio = SetMan.GetNumber(7) local sSlotRatio = SetMan.GetNumber(8) local sMaxHubs = SetMan.GetNumber(9) local sMinNick = SetMan.GetNumber(60) local sMaxNick = SetMan.GetNumber(61) if sMinShare == 0 then sMinShare = "-" else sMinShare = GetNormalShare(sMinShare) end if sMaxShare == 0 then sMaxShare = "-" else sMaxShare = GetNormalShare(sMaxShare) end if sMinSlots == 0 then sMinSlots = "-" end if sMaxSlots == 0 then sMaxSlots = "-" end local sHubSlot = sHubRatio.."/"..sSlotRatio if sHubRatio == 0 and sSlotRatio == 0 then sHubSlot = "-" end if sMaxHubs == 0 then sMaxHubs = "-" end if sMinNick == 0 then sMinNick = "-" end if sMaxNick == 0 then sMaxNick = "-" end local result = MOTD result = result:gsub("%[USERNAME%]",user.sNick) result = result:gsub("%[IP%]",user.sIP) result = result:gsub("%[RANK%]",GetRank(user.sIP)) result = result:gsub("%[FIRST%]",sFirstVisit) result = result:gsub("%[TOTAL%]",sTotalTime) result = result:gsub("%[NEWUSERSDAY%]",NewUsersDay) result = result:gsub("%[NEWUSERSWEEK%]",NewUsersWeek) result = result:gsub("%[USERSDAY%]",UsersDay) result = result:gsub("%[USERSWEEK%]",UsersWeek) result = result:gsub("%[USERSMONTH%]",UsersMonth) result = result:gsub("%[USERSTOTAL%]",UsersTotal) result = result:gsub("%[USERSPEAK%]",tHubStat.MaxUsers) result = result:gsub("%[USERSPEAKTIME%]",sMaxUsersTime) result = result:gsub("%[SHAREPEAK%]",sSharePeak) result = result:gsub("%[SHAREPEAKTIME%]",sMaxShareTime) result = result:gsub("%[MINSHARE%]",sMinShare) result = result:gsub("%[MAXSHARE%]",sMaxShare) result = result:gsub("%[MINSLOTS%]",sMinSlots) result = result:gsub("%[MAXSLOTS%]",sMaxSlots) result = result:gsub("%[HUBSLOT%]",sHubSlot) result = result:gsub("%[MAXHUBS%]",sMaxHubs) result = result:gsub("%[MINNICK%]",sMinNick) result = result:gsub("%[MAXNICK%]",sMaxNick) return result end function SaveTable(sTableName, hFile, bQuote) hFile:write(sTableName.." = {\n"); for key, value in pairs(_G[sTableName]) do hFile:write("\t"..key.." = "..value..",\n") end hFile:write("}\n"); end function SaveTable2(sTableName, hFile, bQuote) hFile:write(sTableName.." = {\n"); for key in pairs(_G[sTableName]) do hFile:write("\t"..string.format("[%q]", key).." = {") for i,v in pairs(_G[sTableName][key]) do local sKey = bQuote and string.format("[%q]", i) or i local sValue = (type(v) == "string") and string.format("%q", v) or tostring(v); hFile:write("\t"..sKey.." = "..sValue..", "); end hFile:write("},\n") end hFile:write("}\n"); end function Save() local hFile = io.open(fOnline, "w+") SaveTable("tHubStat", hFile) SaveTable2("tUserStat", hFile) SaveTable2("tUserNicks", hFile, true) hFile:close() end function OnError(ErrorMsg) SendError (ErrorMsg) end function SendError(ErrorMsg) local hFile = io.open (path.."error.log" , "a+") if hFile then hFile:write(os.date()..": "..ErrorMsg.."\r\n") hFile:close() end Core.SendToOps ("Ошибка StatPX: "..ErrorMsg) end --################################################################################### --ФУНКЦИИ WEB-СТАТИСТИКИ function BuildWebStat(user) WebstatUpdateTime=FormatDate(os.time(os.date("*t"))) if ScriptStopped then WebstatUpdateTime=WebstatUpdateTime.." (скрипт остановлен)" end BuildDailyUsers() BuildMainStat(user) BuildOnline() BuildBans() if CleanAfterUpdate then collectgarbage("collect") end end function BuildDailyUsers() NewUsersDay, NewUsersWeek, UsersDay, UsersWeek, UsersMonth, UsersTotal = 0, 0, 0, 0, 0, 0 local Time = os.time(os.date("*t")) local html = DAILY local tCopy = {} for i, v in pairs(tUserStat) do UsersTotal = UsersTotal + 1 if v.FirstVisit+86400 >= Time then NewUsersDay = NewUsersDay + 1 end if v.FirstVisit+604800 >= Time then NewUsersWeek = NewUsersWeek + 1 end if v.Leave+604800 >= Time or v.Online > 0 then UsersWeek = UsersWeek + 1 end if v.Leave+2592000 >= Time or v.Online > 0 then UsersMonth = UsersMonth + 1 end if v.Leave+86400 >= Time or v.Online > 0 then UsersDay = UsersDay + 1 if DailyUsersTable then local nick = RemovePrefix(v.Name) local b1,b2,b3 = string.byte(string.lower(nick), 1,3) b1 = b1*1000000 b2 = b2 or 0 b2 = b2*1000 b3 = b3 or 0 local Sort = b1+b2+b3 table.insert(tCopy, {iSort = Sort, sEnter = v.Enter, iSessionTime = tonumber(v.SessionTime), iOnline = v.Online, iTotalTime = tonumber(v.TotalTime), sLeave = v.Leave, sNick = nick, iProfile = v.Profile, sIP = i, sRank = GetRank(i) } ) end end end table.sort(tCopy, function(a, b) return (a.iSort < b.iSort) end) local rows,disabled = "","" if DailyUsersTable then local SecondRow = false for i,v in pairs(tCopy)do local rowstyle = SecondRow and "StatRow2" or "StatRow1" SecondRow = not SecondRow local v = tCopy[i] local sEnter = FormatDate(v.sEnter) local sLeave = FormatDate(v.sLeave) local sRank = v.sRank local sOnline = " " if v.iOnline > 0 then sOnline = "<font color=green>Онлайн</font>";sLeave = "*Онлайн*" end rows=rows..BuildDailyRow(rowstyle,v.iProfile,v.sNick,GetNormalTime(v.iTotalTime*60), GetNormalTime(v.iSessionTime*60),sEnter,sLeave,sRank,sOnline) end else disabled = " (Отключено администратором)" end html = html:gsub("%[ROWS%]",rows) html = html:gsub("%[UPDATE%]",FormatDate(os.time(os.date("*t")))..disabled) html = html:gsub("%[UPDATETIME%]",TopHubbersUpdate) html = html:gsub("%[PAGENAME%]","Пользователи, посетившие хаб за прошедшие сутки"..disabled) local hFile = io.open (WebstatDaily , "w") if not(hFile) then MakeDir() hFile = io.open (WebstatDaily,"w") end if hFile then hFile:write(html.."\r\n<!--StatPX "..Version.." by alex82-->") hFile:close() else SendError ("невозможно сохранить данные в файл "..WebstatDaily) end LastUpdate = os.time(os.date("*t")) end function BuildMainStat(user) local html = MAINSTAT local sUpime = GetNormalTime(Core.GetUpTime()) local sTotalUsers = Core.GetUsersCount() local tTmp = Core.GetOnlineOps(true) or {} local sTotalOps = #tTmp local sTotalShare = Core.GetCurrentSharedSize() local sMaxUsersTime = FormatDate(tHubStat.MaxUsersTime) local sSharePeak = GetNormalShare(tHubStat.MaxShare) local sMaxShareTime = FormatDate(tHubStat.MaxShareTime) local sBanned = #BanMan.GetBans() local sMinShare = SetMan.GetMinShare() local sMaxShare = SetMan.GetMaxShare() local sMinSlots = SetMan.GetNumber(5) local sMaxSlots = SetMan.GetNumber(6) local sHubRatio = SetMan.GetNumber(7) local sSlotRatio = SetMan.GetNumber(8) local sMaxHubs = SetMan.GetNumber(9) local sMinNick = SetMan.GetNumber(60) local sMaxNick = SetMan.GetNumber(61) if sMinShare == 0 then sMinShare = "<small>∞</small>" else sMinShare = GetNormalShare(sMinShare) end if sMaxShare == 0 then sMaxShare = "<small>∞</small>" else sMaxShare = GetNormalShare(sMaxShare) end if sMinSlots == 0 then sMinSlots = "<small>∞</small>" end if sMaxSlots == 0 then sMaxSlots = "<small>∞</small>" end local sHubSlot = sHubRatio.."/"..sSlotRatio if sHubRatio == 0 and sSlotRatio == 0 then sHubSlot = "<small>∞</small>" end if sMaxHubs == 0 then sMaxHubs = "<small>∞</small>" end if sMinNick == 0 then sMinNick = "<small>∞</small>" end if sMaxNick == 0 then sMaxNick = "<small>∞</small>" end if ShowTopic then local sTopic = SetMan.GetString(10) or "" if sTopic ~= "" then sTopic = string.gsub(TOPIC,"%[TOPICTEXT%]",sTopic) end html = html:gsub("%[TOPIC%]",sTopic) end if user then sTotalUsers = sTotalUsers+1 sTotalShare = sTotalShare+user.iShareSize end sTotalShare = GetNormalShare(sTotalShare) local function Parse() html = html:gsub("%[UPTIME%]",sUpime) html = html:gsub("%[TOTALUSERS%]",sTotalUsers) html = html:gsub("%[TOTALOPS%]",sTotalOps) html = html:gsub("%[TOTALSHARE%]",sTotalShare) html = html:gsub("%[UPDATE%]",WebstatUpdateTime) html = html:gsub("%[UPDATETIME%]",WebStatUpdate) html = html:gsub("%[NEWUSERSDAY%]",NewUsersDay) html = html:gsub("%[NEWUSERSWEEK%]",NewUsersWeek) html = html:gsub("%[USERSDAY%]",UsersDay) html = html:gsub("%[USERSWEEK%]",UsersWeek) html = html:gsub("%[USERSMONTH%]",UsersMonth) html = html:gsub("%[USERSTOTAL%]",UsersTotal) html = html:gsub("%[USERSPEAK%]",tHubStat.MaxUsers) html = html:gsub("%[USERSPEAKTIME%]",sMaxUsersTime) html = html:gsub("%[SHAREPEAK%]",sSharePeak) html = html:gsub("%[SHAREPEAKTIME%]",sMaxShareTime) html = html:gsub("%[BANNED%]",sBanned) end Parse() html = html:gsub("%[MINSHARE%]",sMinShare) html = html:gsub("%[MAXSHARE%]",sMaxShare) html = html:gsub("%[MINSLOTS%]",sMinSlots) html = html:gsub("%[MAXSLOTS%]",sMaxSlots) html = html:gsub("%[HUBSLOT%]",sHubSlot) html = html:gsub("%[MAXHUBS%]",sMaxHubs) html = html:gsub("%[MINNICK%]",sMinNick) html = html:gsub("%[MAXNICK%]",sMaxNick) html = html:gsub("%[PAGENAME%]","Общая статистика") local hFile = io.open (WebstatMain,"w") if not(hFile) then MakeDir() hFile = io.open (WebstatMain,"w") end if hFile then hFile:write(html.."\r\n<!--StatPX "..Version.." by alex82-->") hFile:close() else SendError ("невозможно сохранить данные в файл "..WebstatMain) end if AdditMainStat then html = ADDITMAINSTAT Parse() local hFile = io.open (AdditMainStatFile,"w") if hFile then hFile:write(html.."\r\n<!--StatPX "..Version.." by alex82-->") hFile:close() else SendError ("невозможно сохранить данные в файл "..AdditMainStatFile) end end end function BuildOnline() local html,rows,SecondRow,tcopy = ONLINE,"",false,{} local OnlineTab = Core.GetOnlineUsers(true) or {} for i, v in pairs(OnlineTab) do local nick = RemovePrefix(v.sNick) local b1,b2,b3 = string.byte(nick:lower(), 1,3) b1 = b1*1000000 b2 = b2 or 0 b2 = b2*1000 b3 = b3 or 0 local Sort = b1+b2+b3 local Descr,Tag,Email = "","","" if v.sDescription then Descr = string.match(v.sDescription,"^(.-)<") Tag = string.match(v.sDescription,"(%b<>)") if not Descr then Descr = v.sDescription end else Descr = "" end local Tag = Tag or v.sTag local client, version, limit, hubs, slots = "" ,"" ,0 ,"" ,"" if Tag then client,version,mode = Tag:match("<(%S+)%sV:(.-),M:(.)") limit = Tag:match("L:(%d+)") hubs = Tag:match("H:(%d+/%d+/%d+),") slots = Tag:match("S:(%d+)") end local Mode = tMode[mode] or mode or "?" if v.sEmail and v.sEmail ~= "" then if string.find(v.sEmail,"@") then Email = "\<a href = \"mailto:"..v.sEmail.."\"\>Email\</a\>" elseif string.len(v.sEmail) > 4 and string.find(v.sEmail,"^%d+$") then Email = "\<a href = \"http://www.icq.com/people/about_me.php?to="..v.sEmail.."\" target=\"_blank\"\>ICQ\</a\>" else Email = "\<font color=\"red\"\>Email\</font\>" end else Email = " " end tcopy[i] = {nick,{Name = nick, Sort = Sort, Share = v.iShareSize, Profile = v.iProfile, Client = client or "?", Version = version or "", Descr = Descr or "",Email = Email, Mode = Mode, Hubs = hubs or "?", Slots = slots or "?", Limit = GetNormalSpeed(limit)}} end table.sort(tcopy,function(a,b) return(a[2].Sort<b[2].Sort) end) for i,v in ipairs(tcopy) do local rowstyle = SecondRow and "StatRow2" or "StatRow1" SecondRow = not SecondRow local client = (GetClient(tcopy[i][2].Client)).." "..tcopy[i][2].Version rows = rows..BuildOnlineRow(rowstyle,tcopy[i][2].Name,tcopy[i][2].Profile,GetNormalShare(tcopy[i][2].Share) ,tcopy[i][2].Descr, tcopy[i][2].Email,client,tcopy[i][2].Mode,tcopy[i][2].Hubs,tcopy[i][2].Slots,tcopy[i][2].Limit) end html = html:gsub("%[ROWS%]",rows) html = html:gsub("%[UPDATE%]",WebstatUpdateTime) html = html:gsub("%[PAGENAME%]","Пользователи на хабе") local hFile = io.open (WebstatOnline , "w") if hFile then hFile:write(html.."\r\n<!--StatPX "..Version.." by alex82-->") hFile:close() else SendError ("невозможно сохранить данные в файл "..WebstatOnline) end html,rows,SecondRow = TOPSHARE,"",false table.sort(tcopy,function(a,b) return(a[2].Share>b[2].Share) end) for i = 1, TopShareMax do if tcopy[i] then local rowstyle = SecondRow and "StatRow2" or "StatRow1" SecondRow = not SecondRow local client = (GetClient(tcopy[i][2].Client)).." "..tcopy[i][2].Version rows = rows..BuildTopShareRow(rowstyle,i,tcopy[i][2].Name,tcopy[i][2].Profile,GetNormalShare(tcopy[i][2].Sh are),tcopy[i][2].Descr, tcopy[i][2].Email,client,tcopy[i][2].Mode,tcopy[i][2].Hubs,tcopy[i][2].Slots,tcopy[i][2].Limit) end end html = html:gsub("%[ROWS%]",rows) html = html:gsub("%[UPDATE%]",WebstatUpdateTime) html = html:gsub("%[PAGENAME%]","Топ пользователей по размеру шары") local hFile = io.open (WebstatTopShare , "w") if hFile then hFile:write(html.."\r\n<!--StatPX "..Version.." by alex82-->") hFile:close() else SendError ("невозможно сохранить данные в файл "..WebstatTopShare) end end function BuildTopHubbers() local html,rows,SecondRow,tCopy = TOPHUBBERS,"",false,{} for i, v in pairs(tUserStat) do table.insert(tCopy, { sEnter = v.Enter, iSessionTime = tonumber(v.SessionTime), iOnline = v.Online, iTotalTime = tonumber(v.TotalTime), sLeave = v.Leave, sNick = v.Name, iProfile = v.Profile, sIP = i, sRank = GetRank(i) } ) end table.sort(tCopy, function(a, b) return (a.iTotalTime > b.iTotalTime) end) for i = 1, StatMax, 1 do if tCopy[i] then local rowstyle = SecondRow and "StatRow2" or "StatRow1" SecondRow = not SecondRow local v = tCopy[i] local sEnter = FormatDate(v.sEnter) local sLeave = FormatDate(v.sLeave) local sRank = v.sRank local sOnline = " " if v.iOnline > 0 then sOnline = "<font color=green>Онлайн</font>";sLeave = "*Онлайн*" end rows=rows..BuildTopHubbersRow(rowstyle,i,v.iProfile,RemovePrefix(v.sNick),GetNormalTime(v.iTotalTime *60), GetNormalTime(v.iSessionTime*60),sEnter,sLeave,sRank,sOnline) end end html = html:gsub("%[ROWS%]",rows) html = html:gsub("%[UPDATE%]",FormatDate(os.time(os.date("*t")))) html = html:gsub("%[UPDATETIME%]",TopHubbersUpdate) html = html:gsub("%[PAGENAME%]","Топ пользователей по проведённому на хабе времени") local hFile = io.open (WebstatTop , "w") if not(hFile) then MakeDir() hFile = io.open (WebstatTop,"w") end if hFile then hFile:write(html.."\r\n<!--StatPX "..Version.." by alex82-->") hFile:close() else SendError ("невозможно сохранить данные в файл "..WebstatTop) end end function BuildBans() local html,rows,SecondRow = BANS,"",false local function ParseBans(tbl) for i,v in pairs(tbl) do local rowstyle = SecondRow and "StatRow2" or "StatRow1" SecondRow = not SecondRow local row = BANS_ROW local ip = v.sIP or " " local nick = v.sNick or " " local by = v.sBy or " " local reason = v.sReason or " " local unban = "<постоянный>" if v.iExpireTime then unban = FormatDate(v.iExpireTime) end row = row:gsub("%[ROWSTYLE%]",rowstyle) row = row:gsub("%[IP%]",ip) row = row:gsub("%[NICK%]",nick) row = row:gsub("%[BY%]",by) row = row:gsub("%[REASON%]",reason) row = row:gsub("%[UNBAN%]",unban) rows = rows..row end end ParseBans(BanMan.GetTempBans()) ParseBans(BanMan.GetPermBans()) html = html:gsub("%[ROWS%]",rows) html = html:gsub("%[UPDATE%]",WebstatUpdateTime) html = html:gsub("%[PAGENAME%]","Баны") local hFile = io.open (WebstatBans , "w") if hFile then hFile:write(html.."\r\n<!--StatPX "..Version.." by alex82-->") hFile:close() else SendError ("невозможно сохранить данные в файл "..WebstatBans) end end function LoadTemplates() local folder = "" if AllowChangeSkins then folder = tSkins[Template][2].."/" TemplateURL = tSkins[Template][3] AddHeaderFooter = tSkins[Template][4] AdditMainStat = tSkins[Template][5] end MAINSTAT = LoadTemplate(path..folder.."mainstat.tpl") ONLINE,row = LoadTableTemplate(path..folder.."online.tpl") row = ReplaceChars(row) row = row:gsub("%[ROWSTYLE%]","\"..Rowstyle..\"") row = row:gsub("%[NICK%]","\"..Name..\"") row = row:gsub("%[NICKSTYLE%]","Profile_\"..Profile..\"") row = row:gsub("%[SHARE%]","\"..Share..\"") row = row:gsub("%[DESCR%]","\"..Descr..\"") row = row:gsub("%[EMAIL%]","\"..Email..\"") row = row:gsub("%[CLIENT%]","\"..Client..\"") row = row:gsub("%[MODE%]","\"..Mode..\"") row = row:gsub("%[HUBS%]","\"..Hubs..\"") row = row:gsub("%[SLOTS%]","\"..Slots..\"") row = row:gsub("%[SPEED%]","\"..Limit..\"") FuncTpl="function BuildOnlineRow(Rowstyle,Name,Profile,Share,Descr,Email,Client,Mode,Hubs,Slots,Limit)\n\tlocal tmp=\""..row.."\"\n\treturn tmp\nend" TOPSHARE,row = LoadTableTemplate(path..folder.."topshare.tpl") row=ReplaceChars(row) row = row:gsub("%[ROWSTYLE%]","\"..Rowstyle..\"") row = row:gsub("%[NUMBER%]","\"..i..\"") row = row:gsub("%[NICK%]","\"..Name..\"") row = row:gsub("%[NICKSTYLE%]","Profile_\"..Profile..\"") row = row:gsub("%[SHARE%]","\"..Share..\"") row = row:gsub("%[DESCR%]","\"..Descr..\"") row = row:gsub("%[EMAIL%]","\"..Email..\"") row = row:gsub("%[CLIENT%]","\"..Client..\"") row = row:gsub("%[MODE%]","\"..Mode..\"") row = row:gsub("%[HUBS%]","\"..Hubs..\"") row = row:gsub("%[SLOTS%]","\"..Slots..\"") row = row:gsub("%[SPEED%]","\"..Limit..\"") FuncTpl=FuncTpl.."\n\nfunction BuildTopShareRow(Rowstyle,i,Name,Profile,Share,Descr,Email,Client,Mode,Hubs,Slots,Limit)\n\tlocal tmp=\""..row.."\"\n\treturn tmp\nend" TOPHUBBERS,row = LoadTableTemplate(path..folder.."tophubbers.tpl") row=ReplaceChars(row) row = row:gsub("%[ROWSTYLE%]","\"..Rowstyle..\"") row = row:gsub("%[NUMBER%]","\"..i..\"") row = row:gsub("%[NICKSTYLE%]","Profile_\"..Profile..\"") row = row:gsub("%[NICK%]","\"..Name..\"") row = row:gsub("%[TOTAL%]","\"..Total..\"") row = row:gsub("%[SESSION%]","\"..Session..\"") row = row:gsub("%[ENTER%]","\"..Enter..\"") row = row:gsub("%[LEAVE%]","\"..Leave..\"") row = row:gsub("%[RANK%]","\"..Rank..\"") row = row:gsub("%[ONLINE%]","\"..Online..\"") FuncTpl=FuncTpl.."\n\nfunction BuildTopHubbersRow(Rowstyle,i,Profile,Name,Total,Session,Enter,Leave,Rank,Online)\n\tlocal tmp=\""..row.."\"\n\treturn tmp\nend" DAILY,row = LoadTableTemplate(path..folder.."daily.tpl") row=ReplaceChars(row) row = row:gsub("%[ROWSTYLE%]","\"..Rowstyle..\"") row = row:gsub("%[NICKSTYLE%]","Profile_\"..Profile..\"") row = row:gsub("%[NICK%]","\"..Name..\"") row = row:gsub("%[TOTAL%]","\"..Total..\"") row = row:gsub("%[SESSION%]","\"..Session..\"") row = row:gsub("%[ENTER%]","\"..Enter..\"") row = row:gsub("%[LEAVE%]","\"..Leave..\"") row = row:gsub("%[RANK%]","\"..Rank..\"") row = row:gsub("%[ONLINE%]","\"..Online..\"") FuncTpl=FuncTpl.."\n\nfunction BuildDailyRow(Rowstyle,Profile,Name,Total,Session,Enter,Leave,Rank,Online)\n\tlocal tmp=\""..row.."\"\n\treturn tmp\nend" BANS,BANS_ROW = LoadTableTemplate(path..folder.."bans.tpl") loadstring(FuncTpl)() if TempFile then local hFile = io.open (path.."temp.lu" , "w") if hFile then hFile:write(FuncTpl) hFile:close() dofile(path.."temp.lu") else SendError ("невозможно сохранить данные в файл "..path.."temp.lu") end end if AdditMainStat then ADDITMAINSTAT = LoadTemplate(path..folder.."hubstat.tpl") end if AddHeaderFooter then HEADER = LoadTemplate(path..folder.."header.tpl") FOOTER = LoadTemplate(path..folder.."footer.tpl") MAINSTAT = HEADER..MAINSTAT..FOOTER ONLINE = HEADER..ONLINE..FOOTER TOPSHARE = HEADER..TOPSHARE..FOOTER TOPHUBBERS = HEADER..TOPHUBBERS..FOOTER BANS = HEADER..BANS..FOOTER DAILY = HEADER..DAILY..FOOTER end if ShowTopic then TOPIC = string.match(MAINSTAT,"%[TOPIC_BEGIN%](.*)%[TOPIC_END%]") if TOPIC then TOPIC = string.gsub(TOPIC,"%%","%%%%") MAINSTAT = string.gsub(MAINSTAT,"%[TOPIC_BEGIN%].*%[TOPIC_END%]","%[TOPIC%]") else TOPIC = "" SendError("не найден шаблон топика. Проверьте синтаксис шаблона главной страницы.") end else MAINSTAT = string.gsub(MAINSTAT,"%[TOPIC_BEGIN%].*%[TOPIC_END%]","") end collectgarbage("collect") end function LoadTemplate(filename) local tpl = "" local f = io.open( filename, "r" ) if f then tpl = f:read("*all") tpl = tpl:gsub("%[THEME%]",TemplateURL) tpl = tpl:gsub("%[HUBNAME%]",HubName) f:close() else SendError("Ошибка при загрузке шаблона "..filename..": файл не найден.") tpl = "Ошибка при загрузке шаблона" end return tpl end function LoadTableTemplate(filename) local tpl,tpl_row = "","" local f = io.open( filename, "r" ) if f then tpl = f:read("*all") tpl_row = string.match(tpl,"%[ROW_BEGIN%](.*)%[ROW_END%]") if tpl_row then tpl_row = string.gsub(tpl_row,"%%","%%%%") else tpl_row = "" SendError("Ошибка в файле "..filename..": не найден шаблон строки. Проверьте синтаксис шаблона.") end tpl = tpl:gsub("%[ROW_BEGIN%].*%[ROW_END%]","%[ROWS%]") tpl = tpl:gsub("%[THEME%]",TemplateURL) tpl = tpl:gsub("%[HUBNAME%]",HubName) f:close() else SendError("Ошибка при загрузке шаблона "..filename..": файл не найден.") tpl = "Ошибка при загрузке шаблона" end return tpl, tpl_row end function RemovePrefix(nick) for i,v in ipairs(Prefixes) do nick=nick:gsub(v,""); end return nick end function GetNormalTime(iSeconds) local T = os.date("!*t", tonumber(iSeconds)); local sTime = "" T.month = T.month-1 T.day = T.day-1 if T.month ~= 0 then sTime = T.month.." м. "..T.day.." д. "..T.hour.." ч. "..T.min.." м." else if T.day ~= 0 then sTime = T.day.." дн. "..T.hour.." час. "..T.min.." мин." else if T.hour ~= 0 then sTime = T.hour.." час. "..T.min.." мин." else sTime = T.min.." минут" end end end return sTime end function GetClient(client) if Clients[client] then return Clients[client] else return client end end function GetNormalSpeed(speed) if speed then speed = tonumber(speed) local tspeed="" if speed >= 1024 then tspeed = tostring(math.floor(100*speed/1024)/100).." MB/s" else tspeed = tostring(sspeed).." kB/s" end return tspeed else return "<small>∞</small>" end end function FormatDate(data) local T = os.date("*t",data) local minutes = T.min if T.min < 10 then minutes = "0"..minutes end local msg = T.day.." "..Months[T.month].." в "..T.hour..":"..minutes return msg end function SaveTplCfg() local hFile = io.open(fTplConfig, "w+") hFile:write("Template = "..Template); hFile:close() end function MakeDir() os.execute("md \""..WebstatPath.."\"") end function ReplaceChars(str) for i,v in pairs(Chars) do str=str:gsub(i,v) end return str end
Прикрепленные файлы
|
|
|
Похожие темы
|
Сейчас: 23.11.2024, 10:02 |