( bAndie9100 | 2015. 07. 08., sze – 15:59 )

inifile modul innen van: http://santos.nfshost.com/inifile.html


 	require 'inifile'

	if ngx.header.content_type == "text/html" then
		local file = ngx.var.request_filename
		local dir, cnt, err = ngx.re.gsub(file, "[^/]+$", "")
		local ini = dir .. "template.ini"

		local fh = io.open(ini, "r")
		if fh ~= nil then
		    io.close(fh)

			if ngx.get_phase() == "header_filter" then
				ngx.header.content_length = nil

			elseif ngx.get_phase() == "body_filter" then
				local tmpl = ngx.ctx.template_variables
				local buff = ngx.ctx.chunk_buffer
				local matched = 0
				local last_chunk = ngx.arg[2]
				
				if not tmpl then
					tmpl = inifile.parse(ini, false)
					ngx.ctx.template_variables = tmpl
				end
				if buff then
					ngx.arg[1] = buff .. ngx.arg[1]
				end

				if not last_chunk then
					grp, err = ngx.re.match(ngx.arg[1], "<(!(-(-(\\{([^\\}]+(\\}(-(-(>)?)?)?)?)?)?)?)?)?$")
					if err then
						ngx.log(ngx.ERR, "re.match error: ", err)
					else
						ngx.log(ngx.DEBUG, "possible chunked template tag: ", grp[0])
						matched = 1
					end
				end
				if not last_chunk and matched then
					buff = ngx.arg[1]
					ngx.arg[1] = nil
				else
					for tmplvar, tmplstr in pairs(tmpl["html"]) do
						local str, cnt, err = ngx.re.gsub(ngx.arg[1], "<!--\\{" .. tmplvar .. "\\}-->", tmplstr)
						if str then
							ngx.arg[1] = str
						else
							ngx.log(ngx.ERR, "re.gsub error: ", err)
						end
					end
				end
				
				ngx.ctx.chunk_buffer = buff
			end
		end
	end

~~~~~~~~
deb http://deb.uucp.hu/ wheezy yazzy repack