我在我的網站上有一個聊天,但它沒有帳戶,所以詛咒是猖獗的。我使用PHP將我的所有數據寫入user.txt
。有沒有一個簡單的過濾器在php中盲目詛咒?因爲這個js
我使用似乎並沒有工作得很清楚:PHP聊天審查
$(function() {
$("input:submit[name='submit']").on("click",function() {
var name = $("input:text[name='name']").val();
var message = $("input:text[name='field2']").val();
var badwords = ["dingbat", "poopy"];
/* do this */
if($.inArray(name, badwords) !==-1 || $.inArray(message, badwords) !==-1) {
alert("Your Message Contains Bad Words, Please Remove Them Before Proceeding");
return false;
}
});
});
這裏是我完整的代碼(減去txt.php
這只是顯示user.txt
)
@import url(https://fonts.googleapis.com/css?family=Lato:400,100,300);
#blu {
background: #F0FAFF;
padding: 3;
width: 310;
}
\t \t b, i, p {
-webkit-transition: all 0.5s ease;
font-size: 16px;
font-size: 1rem;
line-height: 23px;
line-height: 1.4375rem;
font-weight: 400;
font-style: normal;
font-family:"Lato";
}
iframe{border: 3px solid white;}
button,input, #rcp_submit, #rcp_update_card {
display: inline-block;
font-family: "Lato", sans-serif;
font-weight: 500;
outline: 0;
border-radius: 0;
color: black;
background: #FFFFFF;
white-space: nowrap;
padding: 9px 16px !important;
line-height: 1.4;
border: 0;
\t color:black;
position: relative;
-webkit-transition: 0.1s;
transition: 0.1s;
}
,!--this file is called c5.php-->
<?php
if(isset($_POST['field1']) && isset($_POST['field2'])) {
$data = $_POST['field1'] . '-' . $_POST['field2'] . "<br>";
$ret = file_put_contents('user.txt', $data, FILE_APPEND | LOCK_EX);
if($ret === false) {
die('There was an error writing this file');
}
else {
\t echo "$ret bytes written to file<a href ='javascript:history.go(-1)'>go back</a>";
}
}
else {
die('no post data to process');
}
?>
<html>
<body onload="reloadIFrame();">
<script>
window.setInterval("reloadIFrame();", 3000);
function reloadIFrame() {
document.getElementById("myIframe").src="txt.php";
}
</script>
<div id ="blu">
<table>
<p>Chat about your code</p>
<td>
<iframe src ="txt.php" id ="myIframe"></iframe><br/>
<button onclick="reloadIFrame();">Refresh feed</button>
<form action="c5.php" method="POST">
<p>Name:</p>
<input name="field1" type="text" />
\t <h3> </h3>
<p>Question:<p>
<input name="field2" type="text" />
<input type="submit" name="submit" value="Submit">
</form>
<a href="user.txt" download="chatlogs">download chat logs</a>
</td>
</table>
</div>
不會有任何效果,人們總能找到創造性的方法以c_u_r_s_e –
這樣一個基於JS的過濾器應該工作得很好,假設你有一個有效的,完整的目錄,你想過濾掉。那麼問題是什麼?你實際上是什麼意思「似乎不太好」? – arkascha
還有一個普遍的問題:當人們訪問你的網站時,他們怎麼會這麼生氣,以至於他們詛咒?這在互聯網上並不常見... – arkascha