Baidu thieves: remove bids and advertisements

Source: Internet
Author: User
Functions are as follows. The rewrite rules are consistent with those of Wordpress. Compatible with IIS, Apache, and Nginx. Only one file implements all functions .? Phpif (isset ($ _ GET ['wd ']) {$ keywords = $ _ GET ['wd'];} $ uri = isset ($ _ SERVER ['http _ X_REWRITE_URL '] function example.
The rewrite rules are consistent with those of Wordpress.
Compatible with IIS, Apache, and Nginx.
Only one file implements all functions.
 

 

 
 
  1. If (isset ($ _ GET ['wd ']) {
  2. $ Keywords = $ _ GET ['wd '];
  3. }
  4. $ Uri = isset ($ _ SERVER ['http _ X_REWRITE_URL '])? $ _ SERVER ['http _ X_REWRITE_URL ']: $ _ SERVER ['request _ URI'];
  5. $ Content = file_get_contents ("http://www.baidu.com". $ uri );
  6.  
  7. If ($ uri = '/' | empty ($ uri )){
  8. Display ($ content );
  9. }
  10.  
  11. // Delete the "laibaidu promotion" LINK
  12. $ Start = preg_quote (" ");
  13. $ Content = preg_replace ("/". $ start ."((?!
    ).)*
    "."/Is ",'', $ content );
  14.  
  15. // Delete the bid on the left
  16. $ Start =" ).) *> ";
  17. $ Content = preg_replace_callback ("/". $ start ."((?! <\/Table>).) * <\/table>/is "," search_result_filter ", $ content );
  18.  
  19. // Delete the remaining multiple
     
  20. $ Content = str_ireplace ("
    \ N
    ",'', $ Content );
  21. // Delete the remaining multiple
     
  22. $ Content = str_ireplace ("
    \ N ",'', $ content );
  23. // Delete the promotion link on the right
  24. $ Start = preg_quote (" ");
  25. $ Content = preg_replace ("/". $ start ."((?! ", $ Content );
  26.  
  27. Display ($ content );
  28. /**
  29. * Search Result Filter
  30. */
  31. Function search_result_filter ($ matches ){
  32. // Background # f5f5f5 is an advertisement
  33. If (strpos ($ matches [0], "bgcolor = \" # f5f5f5 \ "") return '';
  34. // ID4-digit advertising
  35. If (preg_match ("/ ((?! <\/Table>).) * <\/table>/is ", $ matches [0]) {
  36. Return '';
  37. }
  38. Return $ matches [0];
  39. }
  40.  
  41. Function display ($ content ){
  42. Echo $ content;
  43. }

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.