This article analyzes the word filtering principle in ucenter. Share it with everyone for your reference, the details are as follows:
Filter word list
Build cache data:
//private function _get_badwords() { $data = $this->db->fetch_all("SELECT * FROM ".UC_DBTABLEPRE."badwords"); $return = array(); if(is_array($data)) { foreach($data as $k => $v) { $return['findpattern'][$k] = $v['findpattern']; $return['replace'][$k] = $v['replacement']; } } return $return; }
Calling method:
$_CACHE['badwords'] = $this->base->cache('badwords'); if($_CACHE['badwords']['findpattern']) { $subject = @preg_replace($_CACHE['badwords']['findpattern'], $_CACHE['badwords']['replace'], $subject); $message = @preg_replace($_CACHE['badwords']['findpattern'], $_CACHE['badwords']['replace'], $message); }
Each parameter of preg_replace() (except limit) can be an array. If both pattern and replacement are arrays, their keys will be processed in the order in which they appear in the array. This is not necessarily the same as the numerical order of the index. If an index is used to identify which pattern is to be replaced by which replacement, the array should be sorted with ksort() before calling preg_replace().
I hope this article will be helpful to everyone in PHP programming.
For more articles related to the analysis of word filtering principles in ucenter, please pay attention to the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 English version
Recommended: Win version, supports code prompts!

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Chinese version
Chinese version, very easy to use
