{% local obj, files, usedSpace, tags, tagcount if DB.isobjhexvalid(request:path():sub(7, 7 + 31)) then obj = DB.getobj(DB.objshowid(request:path():sub(7, 7 + 31))) end function recalcfiles() local virt = "/objd/" .. DB.objhideid(obj.id) .. "/" local phys = DB.urltophysical(virt) files = {} usedSpace = 0 for f in LFS.dir(phys) do if f ~= "." and f ~= ".." then local attribs = LFS.attributes(phys .. f) table.insert(files, {name = f, size = attribs.size, modtime = attribs.modification, phys = phys .. f, virt = virt .. f}) usedSpace = usedSpace + attribs.size end end table.sort(files, function(a,b) if a.modtime == b.modtime then return a.name < b.name else return a.modtime < b.modtime end end) end if obj then -- !!!CHECK IF OWNER HAPPENS HERE!!! if verified and (verified.id ~= obj.owner) then verified = nil end recalcfiles() tags, tagcount = DB.getobjtags(obj.id) if verified then obj.sizequota = BigGlobe.cfg.maxtotalobjsize * 1024 -- Temporary local post = request:post() if post and post.csrf and DB.csrfverify(verified.id, Escapes.urlunescape(tostring(post.csrf))) then if post["createfiles"] then local sztoadd = 0 for fn, sz in post["createfiles"]:gmatch"([^;]+);(%d+)" do sztoadd = sztoadd + sz end if usedSpace + sztoadd > obj.sizequota then response:statusCode(409) else for fn, sz in post["createfiles"]:gmatch"([^;]+);(%d+)" do DB.createfile(obj.id, Escapes.urlunescape(fn), tonumber(sz)) end end return elseif post["upchu"] then DB.updatefile(obj.id, post["upchu"], tonumber(post["offset"]), post["data"].data) return elseif post["remfiles"] then for d in post["remfiles"]:gmatch"(%d+)" do DB.remfilefromobj(obj.id, files[tonumber(d) + 1].name) end return else recalcfiles() if tonumber(post.newthumbnail) and files[tonumber(post.newthumbnail)] then DB.genobjthumbnail(obj.id, files[tonumber(post.newthumbnail)].name, obj.sizequota - usedSpace) recalcfiles() end if post["objname"] then local newname = Escapes.urlunescape(post["objname"]) local newpublished = usedSpace > 0 if newname ~= obj.name or obj.published ~= newpublished then if DB.objupdate(obj.id, newname, newpublished) then obj.name = newname obj.published = newpublished end end end if post["objtags"] then local newtagset = {} for m in post["objtags"]:gmatch"%d+" do newtagset[tonumber(m)] = true end local tagstoremove = {} for k,_ in pairs(tags) do if not newtagset[k] then table.insert(tagstoremove, k) end end local tagstoadd = {} for k,_ in pairs(newtagset) do if not tags[k] then table.insert(tagstoadd, k) end end DB.remtagsfromobj(obj.id, tagstoremove) DB.addtagstoobj(obj.id, tagstoadd) tags, tagcount = DB.getobjtags(obj.id) end end end end end title = BigGlobe.cfg.sitename .. " - Editing " .. (obj and obj.name or "Object not found") function content() %} {% if obj then %} {% if verified then %}

Editing object

Once files are uploaded, the object will be considered published.

Object sized at {{ (usedSpace + 1023) // 1024 }}kB out of {{ (obj.sizequota + 1023) // 1024 }}kB maximum ({{math.floor(usedSpace / obj.sizequota * 1000 + 0.5) / 10}}%)

{% for idx,f in pairs(files) do %} {% end %}
FileSizeActions
{{ Escapes.htmlescape(f.name) }} {{ (f.size + 1023) // 1024 }}kB

Tags

0 then %} style="visibility:hidden;"{% end %}>Enter tags...

{% for _, tag in pairs(tags) do %}
{{ Escapes.htmlescape(tag.name) }}
{% end %}
{% if BigGlobe.cfg.enable18plus then %} {% end %}
{% else %}

You are not eligible to edit this object.

{% end %} {% else %}

Object was not found.

{% end %} {% end %} {# base.inc