public Boolean check(http_request req, DataAccessLayer d) { Boolean retval = false; switch (_match) { case "!-d": retval = !d.DirectoryExists (cgi.get_var(_subject_t,req)); break; case "!-f": retval = !d.FileExists (cgi.get_var (_subject_t, req)); break; default: #if DEBUG Console.Error.WriteLine ("RewriteCond " + _match + " is Regex?"); #endif Regex reg = new Regex (_match); if (_match.StartsWith ("!")) { string _tempmatch = _match.TrimStart ("!".ToCharArray ()); reg = new Regex (_tempmatch); retval = !reg.IsMatch (cgi.get_var (_subject_t, req)); } else { retval = reg.IsMatch (cgi.get_var (_subject_t, req)); } break; } return retval; }
private void inpath_php(http_request req, DataAccessLayer d) { if(!d.DirectoryExists(req.script_name) && !d.FileExists(req.script_name)) { Boolean done = false; foreach(String ext in _extentions) { if(req.script_name.Contains(ext +"/")) { int index = req.script_name.IndexOf(ext +"/") + ext.Length; req.script_name = req.script_name.Substring(0,index); done = true; break; } } if(!done) { String[] folders = req.script_name.Split("/".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); String path = req.script_name; for(int i = folders.Length -1; i > -1; i --) { if(!d.DirectoryExists(path) & !d.FileExists(path)) { path = path.TrimEnd("/".ToCharArray()); int index = path.LastIndexOf(folders[i]); path = path.Remove(index); } else { break; } } req.script_name = path; } } }
private Boolean index_check(http_request req, DataAccessLayer d,http_response res) { Boolean retval = false; if (d.DirectoryExists (req.script_name)) { foreach (string index_file in _indexes) { String possible_index = Path.Combine (req.script_name, index_file); if (d.FileExists (possible_index)) { if(_redirectdirtoindex) { res.Header.Statuscode = "302"; res.Header.Statusmessage = "Found"; res.Header.SetValue ("Location", req.script_name + index_file); res.Header.ContentLength = 0; res.Respond(req.Connection,req.Connection.GetStream()); retval = true; } else { req.script_name = possible_index; retval = false; } break; } } } return retval; }