|
|
@ -7,16 +7,24 @@ local json = require "cjson" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _M.new(cpath, rpath) |
|
|
|
function _M.new(cpath, rpath) |
|
|
|
ngx.log(ngx.ERR,"read:"..cpath..",rpath:"..rpath) |
|
|
|
-- ngx.log(ngx.ERR,"read:"..cpath..",rpath:"..rpath) |
|
|
|
local self = { |
|
|
|
local self = { |
|
|
|
cpath = cpath, |
|
|
|
cpath = cpath, |
|
|
|
rpath = rpath, |
|
|
|
rpath = rpath, |
|
|
|
|
|
|
|
config = '', |
|
|
|
|
|
|
|
site_config = '' |
|
|
|
} |
|
|
|
} |
|
|
|
local p = setmetatable(self, mt) |
|
|
|
local p = setmetatable(self, mt) |
|
|
|
return p |
|
|
|
return p |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _M.setConfData( self, config, site_config ) |
|
|
|
|
|
|
|
self.config = config |
|
|
|
|
|
|
|
self.site_config = site_config |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _M.return_message(self, status, msg) |
|
|
|
function _M.return_message(self, status, msg) |
|
|
|
ngx.header.content_type = "application/json;" |
|
|
|
ngx.header.content_type = "application/json;" |
|
|
@ -34,7 +42,7 @@ function _M.return_html(self,status,html) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
function _M.read_file_body(self, filename) |
|
|
|
function _M.read_file_body(self, filename) |
|
|
|
ngx.log(ngx.ERR,"read_file_body:"..filename) |
|
|
|
-- ngx.log(ngx.ERR,"read_file_body:"..filename) |
|
|
|
fp = io.open(filename, 'r') |
|
|
|
fp = io.open(filename, 'r') |
|
|
|
if fp == nil then |
|
|
|
if fp == nil then |
|
|
|
return nil |
|
|
|
return nil |
|
|
@ -47,6 +55,17 @@ function _M.read_file_body(self, filename) |
|
|
|
return fbody |
|
|
|
return fbody |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _M.continue_key(self,key) |
|
|
|
|
|
|
|
key = tostring(key) |
|
|
|
|
|
|
|
if string.len(key) > 64 then return false end; |
|
|
|
|
|
|
|
local keys = {"content","contents","body","msg","file","files","img","newcontent"} |
|
|
|
|
|
|
|
for _,k in ipairs(keys) |
|
|
|
|
|
|
|
do |
|
|
|
|
|
|
|
if k == key then return false end; |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _M.array_len(self, arr) |
|
|
|
function _M.array_len(self, arr) |
|
|
|
if not arr then return 0 end |
|
|
|
if not arr then return 0 end |
|
|
@ -98,6 +117,10 @@ function _M.read_file(self, name) |
|
|
|
return json.decode(fbody) |
|
|
|
return json.decode(fbody) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _M.read_file_table( self, name ) |
|
|
|
|
|
|
|
return self:select_rule(self:read_file('args')) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
function _M.t(self) |
|
|
|
function _M.t(self) |
|
|
|
ngx.say(',,,') |
|
|
|
ngx.say(',,,') |
|
|
|
end |
|
|
|
end |
|
|
|