<%
include("language.html")

if _SESSION["username"] ~= nil and _SESSION["currentpath"] ~= nil then
	
	local operation = _GET["operation"] or _POST["operation"] or "get"
	local subfolder = _POST["subfolder"] or ""
	local folderpath = string.gsub(_SESSION["currentpath"],":{{","%[")
	folderpath = string.gsub(folderpath,"}}:","%]")

	if subfolder ~= "" and not string.find(subfolder,"/") and not string.find(subfolder,"\\") then
		if c_GetUserAbsolutePath(domain, _SESSION["username"], folderpath.."/"..subfolder) ~= "" then
			folderpath = folderpath.."/"..subfolder
		end
	end

	if operation == "add" then
		c_AddBookmark(_SESSION["username"], folderpath)
	elseif operation == "del" then
		c_DeleteBookmark(_SESSION["username"], _GET["folder"] or _POST["folder"] or folderpath)
	end

	local liststr = ""
	local result = c_GetBookmark(_SESSION["username"])
	for _,row in pairs(result) do
		liststr = liststr..row[0].."\n"
	end
	print(liststr)
else
	print("session expired")
end

%>