Bad Word Filter,如何与 URL Replace 结合使用
我有两个脚本 - javascript 和 php..
这会清理 url
<script type="text/javascript">
$(document).ready(function() {
$('.search-form').submit(function() {
window.location.href = "/file_"+ $('.search-form input:text').val() + ".html";
return false;
});
});
</script>
这是坏词过滤器
<?php
if (isset($_GET['search']))
{
$search=$_GET['search'];
if(is_array($badwords) && sizeof($badwords) >0)
{
foreach($badwords as $theword)
$search = ereg_replace($theword,"haha",$search);
}
$search=preg_replace("/\s+/"," ",$search);
$keyword = str_replace(" ", "+", $search);
}
else
{
$keyword = str_replace(" ", "+a", $keyword);
}
?>
我如何组合这两个脚本并将 url 中的坏词替换为“哈哈”?
I have two scripts - javascript and php..
this cleans the url
<script type="text/javascript">
$(document).ready(function() {
$('.search-form').submit(function() {
window.location.href = "/file_"+ $('.search-form input:text').val() + ".html";
return false;
});
});
</script>
this is the bad word filter
<?php
if (isset($_GET['search']))
{
$search=$_GET['search'];
if(is_array($badwords) && sizeof($badwords) >0)
{
foreach($badwords as $theword)
$search = ereg_replace($theword,"haha",$search);
}
$search=preg_replace("/\s+/"," ",$search);
$keyword = str_replace(" ", "+", $search);
}
else
{
$keyword = str_replace(" ", "+a", $keyword);
}
?>
how can i combine this two scripts and replace the bad word in the url with "haha"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在 PHP 中重定向
,形式为:
第二:
或者您可以使用 ajax 来检查和清理关键字:
clean.php:
您可以在以下位置查找有关 ajax/post/get (jQuery) 的更多信息:
You can redirect in the PHP
First, the form:
Second:
Or you can use ajax to check and clean the keyword:
Clean.php:
You can look for more information about ajax / post / get (jQuery) in: