07.10 lua saved
Jippi
Tags add more
lighttpd and lua  
Note
Jippi did not leave a note
  1. function check_path(path)
  2.      local rv = path
  3.      if (not file_info(path, "is_file")) then
  4.         rv = nil
  5.          local html_file = path .. ".html"
  6.          if (file_info(html_file, "is_file")) then
  7.              rv = html_file
  8.          else
  9.              -- handle directory indeces
  10.              -- we first check if we have a dir and than look for an index.html
  11.              local index_file = path .. "/index.html"
  12.              if (file_info(path,"is_dir") and file_info(index_file, "is_file")) then
  13.                  rv = index_file
  14.              end
  15.          end
  16.      end
  17.      if rv then
  18.          lighty.env["physical.path"] = rv
  19.      end
  20.      return rv
  21. end
  22.  
  23. function file_info(path, ftype)
  24.     local attr = lighty.stat(path)
  25.     if attr and attr[ftype] then
  26.         return attr[ftype]
  27.     end
  28.     return false
  29.     --return (attr and attr[ftype])
  30. end
  31.  
  32. if (not check_path(lighty.env["physical.path"])) then
  33.         lighty.env["uri.path"]          = "/index.php"
  34.         lighty.env["physical.rel-path"] = lighty.env["uri.path"]
  35.         lighty.env["request.orig-uri"]  = lighty.env["request.uri"]
  36.         lighty.env["physical.path"]     = lighty.env["physical.doc-root"] .. lighty.env["physical.rel-path"]
  37. end
  38.  
Parsed in 0.023 seconds, using GeSHi 1.0.7.14

Modify this Paste