* applications/sgi-haserl: Added ffluci.http.upload for file uploads
authorSteven Barth <steven@midlink.org>
Tue, 13 May 2008 09:21:10 +0000 (09:21 +0000)
committerSteven Barth <steven@midlink.org>
Tue, 13 May 2008 09:21:10 +0000 (09:21 +0000)
* applications/sgi-webuci: Added stub for ffluci.http.upload

applications/sgi-haserl/src/sgi/haserl.lua
applications/sgi-webuci/src/sgi/webuci.lua
modules/admin-core/src/controller/admin/system.lua

index 027697e2e4e48ec20afea99b7ba5f2661b06da62..0e388391dbe976095c5aa2ff2ca5658d77532ac6 100644 (file)
@@ -24,6 +24,7 @@ limitations under the License.
 
 ]]--
 module("ffluci.sgi.haserl", package.seeall)
 
 ]]--
 module("ffluci.sgi.haserl", package.seeall)
+require("ffluci.fs")
 
 -- Environment Table
 ffluci.http.env = ENV
 
 -- Environment Table
 ffluci.http.env = ENV
@@ -70,6 +71,17 @@ function ffluci.http.redirect(url)
        print()
 end
 
        print()
 end
 
+-- Returns the path of an uploaded file
+-- WARNING! File uploads can be easily spoofed! Do additional sanity checks!
+function ffluci.http.upload(name)
+       local fpath = ffluci.http.formvalue(name)
+       local fname = ffluci.http.formvalue(name .. "_name")
+       
+       if fpath and fname and ffluci.fs.isfile(fpath) then
+               return fpath
+       end
+end
+
 -- Sets HTTP-Status-Header
 function ffluci.http.status(code, message)
        print("Status: " .. tostring(code) .. " " .. message)
 -- Sets HTTP-Status-Header
 function ffluci.http.status(code, message)
        print("Status: " .. tostring(code) .. " " .. message)
index bc1c7be7a235b33ddf231a43a3cb6038bd139d22..d3d4cd4dc2ef932fda57c54be96ad3cea0a02f06 100644 (file)
@@ -76,6 +76,12 @@ function ffluci.http.redirect(url)
        print()
 end
 
        print()
 end
 
+-- Returns the path of an uploaded file
+-- WARNING! File uploads can be easily spoofed! Do additional sanity checks!
+function ffluci.http.upload(name)
+       -- To be implemented
+end
+
 -- Sets HTTP-Status-Header
 function ffluci.http.status(code, message)
        print(webuci.env.SERVER_PROTOCOL .. " " .. tostring(code) .. " " .. message)
 -- Sets HTTP-Status-Header
 function ffluci.http.status(code, message)
        print(webuci.env.SERVER_PROTOCOL .. " " .. tostring(code) .. " " .. message)
index 7a927d6047f46047a0f2cda1dfd68ac013ef3e3e..a61266009224815f914bc380cd3adb7b6250ecd9 100644 (file)
@@ -178,11 +178,10 @@ function action_upgrade()
        local ret  = nil
        local plat = ffluci.fs.mtime("/lib/upgrade/platform.sh")
        
        local ret  = nil
        local plat = ffluci.fs.mtime("/lib/upgrade/platform.sh")
        
-       local image   = ffluci.http.formvalue("image")
-       local imgname = ffluci.http.formvalue("image_name")
+       local image   = ffluci.http.upload("image")
        local keepcfg = ffluci.http.formvalue("keepcfg")
        
        local keepcfg = ffluci.http.formvalue("keepcfg")
        
-       if plat and imgname then
+       if plat and image then
                local kpattern = nil
                if keepcfg then
                        local files = ffluci.model.uci.sections("luci").flash_keep
                local kpattern = nil
                if keepcfg then
                        local files = ffluci.model.uci.sections("luci").flash_keep