Фильтрация данных перед вставкой в базу

В редакторе

Фильтрация данных перед вставкой в базу

Brain_Script
1814
2018-12-11 19:51:41
function cleanInput($input) { $search = array( '@<script[^>]*?>.*?</script>@si', // javascript '@<[\/\!]*?[^<>]*?>@si', // HTML теги '@<style[^>]*?>.*?</style>@siU', // теги style '@<![\s\S]*?--[ \t\n\r]*>@' // многоуровневые комментарии ); $output = preg_replace($search, '', $input); return $output; } ?> <?php function sanitize($input) { if (is_array($input)) { foreach($input as $var=>$val) { $output[$var] = sanitize($val); } } else { if (get_magic_quotes_gpc()) { $input = stripslashes($input); } $input = cleanInput($input); $output = mysql_real_escape_string($input); } return $output; }
Войдите для добавления комментария.
Нет комментариев
Яндекс.Метрика Яндекс.Метрика