Home > Backend Development > PHP Tutorial > Share discuz's php to prevent sql injection function

Share discuz's php to prevent sql injection function

WBOY
Release: 2016-07-25 09:11:47
Original
967 people have browsed it

Share the sql anti-injection function in discuz forum, it is well written.

  1. $magic_quotes_gpc = get_magic_quotes_gpc();
  2. @extract(daddslashes($_COOKIE));
  3. @extract(daddslashes($_POST));
  4. @extract(daddslashes($_GET));
  5. if(! $magic_quotes_gpc) {
  6. $_FILES = daddslashes($_FILES);
  7. }
  8. function daddslashes($string, $force = 0) {
  9. if(!$GLOBALS['magic_quotes_gpc'] || $force) {
  10. if( is_array($string)) {
  11. foreach($string as $key => $val) {
  12. $string[$key] = daddslashes($val, $force);
  13. }
  14. } else {
  15. $string = addslashes ($string);
  16. }
  17. }
  18. return $string;
  19. }
Copy code


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template