我在一个旧的 HTML 网站上有一个查询表,它在旧版本的 PHP 上运行良好。现在的问题是构成代码一部分的函数 eregi() 在所有新版本的 PHP 中都已弃用。
我不会假装我明白这是怎么回事!:)
这是下面的现有代码 - 它包含 eregi() 位:
// check for any human hacking attempts
class clean {
function comments($message) {
$this->naughty = false;
$this->message = $message;
$bad = array("content-type","bcc:","to:","cc:","href");
$for = array( "\r", "\n", "%0a", "%0d");
foreach($bad as $b) {
if(eregi($b, $this->message)) {
$this->naughty = true;
}
}
$this->message = str_replace($bad,"#removed#", $this->message);
$this->message = stripslashes(str_replace($for, ' ', $this->message));
// check for HTML/Scripts
$length_was = strlen($this->message);
$this->message = strip_tags($this->message);
if(strlen($this->message) < $length_was) {
$this->naughty = true;
}
}
} // class
谷歌搜索后,我猜我需要用 preg_match 替换 eregi() 位?
我不知道在上面的代码中把它放在哪里才能工作?
有人有什么想法吗?
在此先感谢,亲切的问候
布赖恩