Wing FTP Server - Weblink

<% include("language.html") function Split(fullstring, separator) local findstartindex = 1 local splitindex = 1 local splitarray = {} while true do local findlastindex = string.find(fullstring, separator, findstartindex) if not findlastindex then splitarray[splitindex] = string.sub(fullstring, findstartindex, string.len(fullstring)) break end splitarray[splitindex] = string.sub(fullstring, findstartindex, findlastindex-1) findstartindex = findlastindex+string.len(separator) splitindex = splitindex+1 end return splitarray end local file_list = _POST["filelist"] or "" local dir_list = _POST["dirlist"] or "" local expiretime = _POST["expiretime"] or "" local downloadlimit = _POST["downloadlimit"] or "" local downloadpass = _POST["downloadpass"] or "" local mailaddress = _POST["mailaddress"] or "" local sender_mailaddress = _POST["sender_mailaddress"] or "" local mail_message = _POST["mail_message"] or "" local localaddress = _POST["localaddress"] or "" if _SESSION["username"] == nil or _SESSION["currentpath"] == nil then print("") exit() end if string.find(file_list, "../") or string.find(file_list, "..\\") then print("") exit() end if string.find(dir_list, "../") or string.find(dir_list, "..\\") then print("") exit() end local currentpath = string.gsub(_SESSION["currentpath"],":{{","%[") currentpath = string.gsub(currentpath,"}}:","%]") local strPassword = "" local outputHTML = "" if file_list ~= "" or dir_list ~= "" then if downloadlimit == "" then downloadlimit = "-1" end if mail_message ~= "" then local msg = specialhtml_encode(mail_message) msg = msg.gsub(msg, "\n", "
") strPassword = strPassword.."
"..LANG["str_field_message"]..":
"..msg.."
" end if downloadpass ~= "" then strPassword = strPassword.."
"..LANG["password"].." "..specialhtml_encode(downloadpass).."
" end local files = Split(file_list, "||") for _,filename in pairs(files) do if filename ~= "" then result = c_UpdateWebLink(_SESSION["username"],filename,currentpath,expiretime,downloadlimit,downloadpass,mailaddress,sender_mailaddress) if result ~= "" and result ~= "noperm" then local url = localaddress.."?download&weblink="..result.."&realfilename="..urlencode(filename).."\n" outputHTML = outputHTML.."
"..specialhtml_encode(filename)..""..LANG["button_downpicture"].."
" c_AddWebLog("User '".._SESSION["username"].."' created Web-Link for '"..filename.."'",_SESSION_ID,DOMAIN_LOG_WEB_RESPOND) else if result == "noperm" then print(LANG["make_weblink_error"]) exit() end end end end local dirs = Split(dir_list, "||") for _,filename in pairs(dirs) do if filename ~= "" then result = c_UpdateWebLink(_SESSION["username"],filename,currentpath,expiretime,downloadlimit,downloadpass,mailaddress,sender_mailaddress) if result ~= "" and result ~= "noperm" then local url = localaddress.."?download&weblink="..result.."\n" outputHTML = outputHTML.."
"..specialhtml_encode(filename)..""..LANG["button_downpicture"].."
" c_AddWebLog("User '".._SESSION["username"].."' created Web-Link for '"..filename.."'",_SESSION_ID,DOMAIN_LOG_WEB_RESPOND) else if result == "noperm" then print(LANG["make_weblink_error"]) exit() end end end end if mailaddress ~= "" and localaddress ~= "" and outputHTML ~= "" then local subject = LANG["send_file_tip"].." (Wing FTP Server)" if sender_mailaddress == "" then subject = _SESSION["username"].." "..subject else subject = specialhtml_encode(sender_mailaddress).." "..subject end local content = [[

]]..strPassword..[[

]]..LANG["thread_name"]..[[ | ]]..LANG["geturl_title"]..[[
]]..outputHTML..[[

]] local result = c_SendMessage(mailaddress, subject, content, true, sender_mailaddress) if result == false then print("Error: sending email failed") else print("Sending files succeeded!") end else if outputHTML == "" then print("Error: generating web links failed") else print("Error: no recipients") end end else print("Error: no files selected") end %>