本文整理汇总了PHP中AZLib::get_badword方法的典型用法代码示例。如果您正苦于以下问题:PHP AZLib::get_badword方法的具体用法?PHP AZLib::get_badword怎么用?PHP AZLib::get_badword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AZLib
的用法示例。
在下文中一共展示了AZLib::get_badword方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: on_submit
function on_submit()
{
$id = intval(AZLib::getParam('id'));
$cmd = AZLib::getParam('cmd');
$exact = AZLib::getParam('exact');
$is_phone = AZLib::getParam('is_phone');
// $contents = trim(AZLib::getParam('contents'));
// $contents = AZLib::delDoubleSpace(AZLib::trimSpace($contents));
// $contents = trim($contents,",");
$contents = Url::get("contents");
$reason = Url::get("reason");
if ($is_phone == 1) {
$contents = BadWord::badword_phone_type($contents);
}
$where = "";
if ($cmd == 'edit' && $id && $contents) {
$where = " AND id <> {$id}";
}
$re = DB::query("SELECT id FROM bad_words WHERE checksum = '" . md5($contents) . "' " . $where);
$item = mysql_fetch_assoc($re);
if ($item["id"]) {
$this->setFormError('adv_banner', "<b>Từ khóa '{$contents}' đã tồn tại.</b>");
return false;
}
if ($cmd == 'edit' && $id && $contents) {
if (DB::query('UPDATE bad_words SET contents="' . $contents . '", exact="' . $exact . '", reason="' . $reason . '", is_phone="' . $is_phone . '", checksum="' . md5($contents) . '" WHERE id="' . $id . '"')) {
AZLib::get_badword(1, 0);
}
} elseif ($cmd == 'add' && $contents) {
if (DB::query('INSERT INTO bad_words(contents,exact,is_phone,checksum,reason) VALUES ("' . $contents . '","' . $exact . '","' . $is_phone . '","' . md5($contents) . '","' . $reason . '")')) {
AZLib::get_badword(1, 0);
}
}
Url::redirect_current();
}
示例2: checkBadWord
static function checkBadWord($str_check = '', $return = false, $del_cache = false, $getReason = false)
{
if ($str_check == "" && !$del_cache) {
return false;
}
for ($i = 65; $i <= 90; $i++) {
$str_check = str_replace("&#" . $i . ";", chr($i), $str_check);
}
for ($i = 97; $i <= 122; $i++) {
$str_check = str_replace("&#" . $i . ";", chr($i), $str_check);
}
$str_check = eregi_replace("<br[^>]*>", "\n", $str_check);
$str_check = eregi_replace("<p[^>]*>", "\n", $str_check);
$str_check = eregi_replace("</p[^>]*>", "\n", $str_check);
$str_check = strip_tags($str_check);
$str_check = str_replace(chr(9), ' ', $str_check);
$str_check = str_replace(" ", " ", $str_check);
$matches = array();
$arr_badword = AZLib::get_badword();
if (!$del_cache) {
foreach ($arr_badword as $badword) {
$realBad = str_replace('*', '', $badword['contents']);
$bad = preg_quote($badword['contents']);
$badword['contents'] = preg_quote($badword['contents']);
$badword['contents'] = str_replace(array('\\*', '\\?'), array('(.{0,3})', '(.+)'), $badword['contents']);
if ($badword['exact']) {
if (preg_match('#(^|\\s|\\b)' . $badword['contents'] . '(\\b|\\s|!|\\?|\\.|,|$)#ui', $str_check, $match)) {
if ($return) {
$bad_arrs[$bad] = $bad;
$matches[] = $match[0];
$reason_arrs[$realBad] = $badword['reason'];
} else {
return true;
}
}
} else {
if (preg_match('#' . $badword['contents'] . '#ui', $str_check, $match)) {
if ($return) {
$bad_arrs[$bad] = $bad;
$matches[] = $match[0];
$reason_arrs[$realBad] = $badword['reason'];
} else {
return true;
}
}
}
}
if ($return && isset($bad_arrs)) {
$arrReturn = array('bad' => implode(', ', $matches), 'bad_key' => str_replace(array('\\*', '\\?'), '', implode(', ', $bad_arrs)));
if ($getReason) {
$arrReturn += array('reason' => $reason_arrs);
}
return $arrReturn;
} else {
return false;
}
}
}