


PHP filter advertising content part-time job, QQ account, Taobao part-time job, website
If your website has comments, you will definitely find that your website is often injected with advertisements by one person, such as part-time jobs, QQ accounts, Taobao part-time jobs, and website information. Let’s take a look at how to filter these contents.
The types of comments or other content advertisements posted by users generally have the following types:
1: Taobao part-time job, add QQ 123456789 group (with QQ number or WeChat number or other digital number)
2: Taobao part-time job, add QQ number (with English keywords)
3: Taobao part-time job, add QQ ① ① ① ① ① ① (Special digit number)
4: 22222222 (Full-width type number)
Filtering method:
Use regular rules to Match and replace the punctuation marks, numbers, and letters of the string to determine whether there are consecutive numbers or keywords (full-width and rounded corners are supported), because advertisements generally carry contact information such as QQ numbers. Therefore, we must first "purify" and replace the comments, convert the full-width ones into half-width ones, remove some "sand", such as punctuation marks, spaces, letters, etc., leaving only Chinese characters and numbers.
Example:
$comment= "This $% is a (1)8 artifact three or four website, come and join ④④he@#heqq 1 2 3 4 5 6 7 8″;
1:" "Purify" content and remove punctuation marks
$flag_arr=array('?','!','¥','(',')',':',''',''','"', '"','《','》',',','...','.',',','nbsp','】','【','~'); preg_replace('/s/','',preg_replace("/[[:punct:]]/",'',strip_tags(html_entity_decode(str_replace($flag_arr,'',$comment),ENT_QUOTES,'UTF-8 '))));
After processing, $comment becomes: "This is a (1)8 artifact 34 website. B come and join ①④hehe qqq12345678"
2: It may contain some full-width symbols. Or numbers, so use the following code to convert full-width symbols into half-width symbols that can be matched by regular expressions
$quanjiao = array('0' => '0', '1' => '1', '2' => ; '2', '3' => '3', '4' => '4','5' => '5', '6' => '6', '7' => ; '7', '8' => '8', '9' => '9', 'A' => 'A', 'B' => 'B', 'C' => 'C', 'D' => 'D', 'E' => 'E','F' => 'F', 'G' => 'G', 'H' => ; 'H', 'I' => 'I', 'J' => 'J', 'K' => 'K', 'L' => 'L', 'M' => ; 'M', 'N' => 'N', 'O' => 'O','P' => 'P', 'Q' => 'Q', 'R' => ; 'R', 'S' => 'S', 'T' => 'T','U' => 'U', 'V' => 'V', 'W' => ; 'W', 'X' => 'X', 'Y' => 'Y','Z' => 'Z', 'a' => 'a', 'b' => ; 'b', 'c' => 'c', 'd' => 'd','e' => 'e', 'f' => 'f', 'g' => ; 'g', 'h' => 'h', 'i' => 'i','j' => 'j', 'k' => 'k', 'l' => ; 'l', 'm' => 'm', 'n' => 'n','o' => 'o', 'p' => 'p', 'q' => ; 'q', 'rr' => 'r', 's' => 's', 't' => 't', 'u' => 'u', 'v' => ; 'v', 'w' => 'w', 'x' => 'x', 'y' => 'y', 'スz' => 'z','(' => ; '(', ')' => ')', '〔' => '[', '〕' => ']', '【' => '[','】' => ; ']', '〖' => '[', '〗' => ']', '"' => '[', '"' => ']',''' => ; '[', ''' => ']', '{' => '{', '}' => '}', '《' => ' '>','%' => '%', '+' => '+', '—' => '-', '-' => '-', '~' => '-',':' => ':', '. ' => '.', ',' => ',', ',' => '.', ',' => '.', ';' => ',', '? ' => '?', '! ' => '!', '…' => '-', '‖' => '|', '"' => '"', ''' => '`', '' ' => '`', '|' => '|', '〃' => '"',' ' => ' ');
$comment=strtr($comment, $quanjiao) ;
php’s strtr function is used to convert specific characters in a string.You can use
strtr(string,from,to)
or
strtr(string,array)
After processing, $comment becomes:” This is a 18 artifact 34 website. B come and join①④heheqq12345678″;
3: The comments may also contain special characters (you can expand new special characters in the array below)
$special_num_char=array('①'=>'1','②'=>'2','③'=>'3','④'=>'4','⑤'= >'5','⑥'=>'6','⑦'=>'7','⑧'=>'8','⑨'=>'9','⑩'= >'10','⑴'=>'1','⑵'=>'2','⑶'=>'3','⑷'=>'4','⑸'= >'5','⑹'=>'6','⑺'=>'7','⑻'=>'8','⑼'=>'9','⑽'= >'10','一'=>'1','二'=>'2','三'=>'3','四'=>'4','五'= >'5','six'=>'6','seven'=>'7','eight'=>'8','nine'=>'9','zero'= >'0');
$comment=strtr($comment, $special_num_char);
After processing, $comment becomes: "This is a 18 artifact website B Come and join 14heheqq12345678";
If you comment Traditional Chinese numbers appear in it, such as 'zero', 'one', 'two', 'three', 'four', 'five', 'Lu', 'seven', 'eight', 'nine', 'shi' For these, just add and expand the $special_num_char above.
4: There may also be a mixture of normal numbers and Chinese character numbers in the comments. Just use the method in point 3 to convert them into normal numbers.
Example: This is an advertisement qq 1二二45六7899
After conversion:
This is an advertisement qq 1224567899
5: Regular processing to filter advertisements
Use regular matching preg_match_all('/d+/',$comment, $match)
Analyze the obtained match[0] matching array
foreach($match[0] as $val)//Whether there is a digital QQ number and WeChat ID? if(strlen($val)> = 6)
{// There is a number of numbers with a continuous length of more than 6 digits, and the suspicion of advertising is very large
$ is_ad = true; )
{//There are a lot of intermittent numbers, and there is suspicion of advertising
$is_ad=true;
}
ok, so you can judge whether the content is advertising, and you can filter most common ads
$flag_arr=array('?','!','¥','(',')',':','‘','’','“','”','《','》',',','…','。','、','nbsp','】','【','~'); $comment=preg_replace('/\s/','',preg_replace("/[[:punct:]]/",'',strip_tags(html_entity_decode(str_replace($flag_arr,'',$comment),ENT_QUOTES,'UTF-8')))); $quanjiao = array('0' => '0', '1' => '1', '2' => '2', '3' => '3', '4' => '4','5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', 'A' => 'A', 'B' => 'B', 'C' => 'C', 'D' => 'D', 'E' => 'E','F' => 'F', 'G' => 'G', 'H' => 'H', 'I' => 'I', 'J' => 'J', 'K' => 'K', 'L' => 'L', 'M' => 'M', 'N' => 'N', 'O' => 'O','P' => 'P', 'Q' => 'Q', 'R' => 'R', 'S' => 'S', 'T' => 'T','U' => 'U', 'V' => 'V', 'W' => 'W', 'X' => 'X', 'Y' => 'Y','Z' => 'Z', 'a' => 'a', 'b' => 'b', 'c' => 'c', 'd' => 'd','e' => 'e', 'f' => 'f', 'g' => 'g', 'h' => 'h', 'i' => 'i','j' => 'j', 'k' => 'k', 'l' => 'l', 'm' => 'm', 'n' => 'n','o' => 'o', 'p' => 'p', 'q' => 'q', 'r' => 'r', 's' => 's', 't' => 't', 'u' => 'u', 'v' => 'v', 'w' => 'w', 'x' => 'x', 'y' => 'y', 'z' => 'z','(' => '(', ')' => ')', '〔' => '[', '〕' => ']', '【' => '[','】' => ']', '〖' => '[', '〗' => ']', '“' => '[', '”' => ']','‘' => '[', '\'' => ']', '{' => '{', '}' => '}', '《' => ' '>','%' => '%', '+' => '+', '—' => '-', '-' => '-', '~' => '-',':' => ':', '。' => '.', '、' => ',', ',' => '.', '、' => '.', ';' => ',', '?' => '?', '!' => '!', '…' => '-', '‖' => '|', '”' => '"', '\'' => '`', '‘' => '`', '|' => '|', '〃' => '"',' ' => ' '); $comment=strtr($comment, $quanjiao); $special_num_char=array('①'=>'1','②'=>'2','③'=>'3','④'=>'4','⑤'=>'5','⑥'=>'6','⑦'=>'7','⑧'=>'8','⑨'=>'9','⑩'=>'10','⑴'=>'1','⑵'=>'2','⑶'=>'3','⑷'=>'4','⑸'=>'5','⑹'=>'6','⑺'=>'7','⑻'=>'8','⑼'=>'9','⑽'=>'10','一'=>'1','二'=>'2','三'=>'3','四'=>'4','五'=>'5','六'=>'6','七'=>'7','八'=>'8','九'=>'9','零'=>'0'); $comment=strtr($comment, $special_num_char); preg_match_all('/\d+/',$comment,$match); $is_ad = false; foreach($match[0] as $val)//是否存在数字的qq号和微信号 { if(strlen($val)>=6) {//存在连续的长度超过6位的数字串,广告嫌疑很大 $is_ad=true; break; } } if(count($match[0])>=10) {//间断的数字很多,存在广告的嫌疑 $is_ad=true; }
The above introduces PHP filtering advertising content part-time job, QQ account, Taobao part-time job, website, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

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