if (preg_match('^'.preg_quote($this->config_document_root), $filename)) {
$AbsoluteFilename = $filename;
$this->DebugMessage('ResolveFilenameToAbsolute() NOT prepending $this->config_document_root ('.$this->config_document_root.') to $filename ('.$filename.') resulting in ($AbsoluteFilename = "'.$AbsoluteFilename.'")', __FILE__, __LINE__);
} else {
$AbsoluteFilename = $this->config_document_root.$filename;
$this->DebugMessage('ResolveFilenameToAbsolute() prepending $this->config_document_root ('.$this->config_document_root.') to $filename ('.$filename.') resulting in ($AbsoluteFilename = "'.$AbsoluteFilename.'")', __FILE__, __LINE__);
}
}
此代碼已經解決了第一個答案的說明,但我該如何修復此代碼?如何在此代碼中將de eregi更改爲preg_match?
if (!$this->config_allow_src_above_docroot && !preg_match('^'.preg_quote(str_replace(DIRECTORY_SEPARATOR, '/', realpath($this->config_document_root))), $AbsoluteFilename)) {
解決了,感謝所有的答案!
@ user461672我已經用第二個代碼提取的例子更新了答案。另外,在Stackoverflow上發佈代碼時,您應該選擇它並使用'101010'按鈕(或按Ctrl + K)將其格式化爲代碼。 – mikej 2010-09-29 12:20:33