print("LuaWebserver Lib Loaded")
Debug=print
function println(str,...)
	print(str:format(...),"<br/>\n")
end
function string:split(sSeparator, nMax, bRegexp)
	assert(sSeparator ~= '')
	assert(nMax == nil or nMax >= 1)

	local aRecord = {}

	if self:len() > 0 then
		local bPlain = not bRegexp
		nMax = nMax or -1

		local nField=1 nStart=1
		local nFirst,nLast = self:find(sSeparator, nStart, bPlain)
		while nFirst and nMax ~= 0 do
			aRecord[nField] = self:sub(nStart, nFirst-1)
			nField = nField+1
			nStart = nLast+1
			nFirst,nLast = self:find(sSeparator, nStart, bPlain)
			nMax = nMax-1
		end
		aRecord[nField] = self:sub(nStart)
	end

	return aRecord
end
function getCurrentFolder()
	local toplevel=1
	local info
	while true do
		if(not debug.getinfo(toplevel,"S")) then break end
		info=debug.getinfo(toplevel,"S")
		toplevel=toplevel + 1
	end
	local topsrc=info.source
	if(topsrc:sub(1,1)=="@") then topsrc=topsrc:sub(2) end
	local delimeter=topsrc:find("\\") and "\\" or "/"
	local split=string.split(topsrc,delimeter)
	table.remove(split,#split)
	local ppath=table.concat(split,delimeter)
	return ppath
end
function getCurrentFile()
	local toplevel=1
	local info
	while true do
		if(not debug.getinfo(toplevel,"S")) then break end
		info=debug.getinfo(toplevel,"S")
		toplevel=toplevel + 1
		
	end
	local topsrc=info.source
	if(topsrc:sub(1,1)=="@") then topsrc=topsrc:sub(2) end
	local delimeter=topsrc:find("\\") and "\\" or "/"
	local split=string.split(topsrc,delimeter)
	table.remove(split,#split)
	local ppath=table.concat(split,delimeter)
	return ppath..(ppath:sub(#ppath,#ppath)==delimeter and "" or delimeter)..path
end
function include(path)
	local toplevel=1
	local info
	while true do
		if(not debug.getinfo(toplevel,"S")) then break end
		info=debug.getinfo(toplevel,"S")
		toplevel=toplevel + 1
		
	end
	local topsrc=info.source
	if(topsrc:sub(1,1)=="@") then topsrc=topsrc:sub(2) end
	local delimeter=topsrc:find("\\") and "\\" or "/"
	local split=string.split(topsrc,delimeter)
	table.remove(split,#split)
	local ppath=table.concat(split,delimeter)
	dofile(ppath..(ppath:sub(#ppath,#ppath)==delimeter and "" or delimeter)..path)
end
for k,v in pairs(file.Find("lua")) do
	if(v~="lib.lua") then
		include(v)
		print("LuaWebserver Library Loaded: "..v)
	end
end
local STRMETA=getmetatable("")
function STRMETA:__mul(b)
	local ret=self
	for i=1,b-1 do
		ret=ret..self
	end
	return ret
end
function STRMETA:__div(b)
	return self:sub(0,b)
end
function escapehtmlentities(v)
	return tostring(tostring(v):gsub("<","&lt;"):gsub(">","&gt;"))
end
function PrintTable(tbl, done, indents)
	indents=indents or 1
	done=done or {}
	print(("&nbsp;&nbsp;")*(indents),"{<br>")
	for k,v in pairs(tbl) do
		print(("&nbsp;&nbsp;")*indents,"[",k,"] = ")
		if(type(v)=="table" and not done[v]) then
			done[v]=true
			PrintTable(v, done,indents+1)
			print(("&nbsp;&nbsp;")*indents)
		else
			print(escapehtmlentities(v))
		end
		print(("&nbsp;&nbsp;")*indents,",<br>")
	end
	print(("&nbsp;&nbsp;")*(indents),"}")
end
function BaseEncode(n,b)
	if not n then return "" end
	n = math.floor(n)
	if not b or b == 10 then return tostring(n) end
	local digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	local t = {}
	local sign = ""
	if n < 0 then
		sign = "-"
	n = -n
	end
	repeat
		local d = (n % b) + 1
		n = math.floor(n / b)
		table.insert(t, 1, digits:sub(d,d))
	until n == 0
	return sign .. table.concat(t,"")
end
function Color(r,g,b,a)
	return{r=r or 255,g=g or 255, b=b or 255, a=a or 255}
end
BaseDecode=tonumber
function crypto.MD5(str)
	return crypto.Encrypt("MD5",str)
end
function crypto.BCrypt(str, key)
	return crypto.Encrypt("BCRYPT",str,key)
end