<%

if _SESSION["username"] ~= nil and _SESSION["currentpath"] ~= nil then
	local filename = _GET["filename"] or _POST["filename"] or nil
	local operation = _GET["operation"] or _POST["operation"] or "get"
	local nowdir = _GET["nowdir"] or _POST["nowdir"] or nil

	if nowdir == nil then
		nowdir = string.gsub(_SESSION["currentpath"],":{{","%[")
		nowdir = string.gsub(nowdir,"}}:","%]")
	end

	if filename ~= nil then
		local result = ""
		if operation == "get" then
			result = c_GetWebLink(_SESSION["username"],filename,nowdir)
		elseif operation == "del" then
			result = c_RemoveWebLink(_SESSION["username"],filename,nowdir)
			if result == "deleted" then
				c_AddWebLog("User '".._SESSION["username"].."' removed Web-Link for '"..filename.."'",_SESSION_ID,DOMAIN_LOG_WEB_RESPOND)
			end
		elseif operation == "add" then
			result = c_MakeWebLink(_SESSION["username"],filename,nowdir)
			if result ~= "" and result ~= "noperm" then
				c_AddWebLog("User '".._SESSION["username"].."' created Web-Link for '"..filename.."'",_SESSION_ID,DOMAIN_LOG_WEB_RESPOND)
			end
		end
		print(result)
	else
		print("")
	end
end

%>
