0
我有意見這個WordPress的形式,這是非常標準:是wordpress評論表單安全嗎?
<form action="http://sitename.com/wp-comments-post.php" target="writeIframe" method="post" id="commentform" class="comment-form">
<p class="comment-form-author">
<label for="author">Your name</label>
<input id="author" name="author" type="text" value="" size="30">
</p>
<p class="comment-form-comment">
<label for="comment">Comment</label>
<textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea>
</p>
<p class="form-submit">
<input name="submit" type="submit" id="submit" class="submit" value="Send">
<input type="hidden" name="comment_post_ID" value="1" id="comment_post_ID">
<input type="hidden" name="comment_parent" id="comment_parent" value="0">
</p>
</form>
它發出了一個隱藏的iframe內的用戶輸入數據到WP-評論-post.php中。這是安全的開箱即用Wordpress還是我應該添加代碼來防止通過我的評論表單進行攻擊?
所以我把下面的第一場在我的形式是這樣的:
是的,你也應該確保你正在驗證nonce。您應該使用此代碼驗證您的隨機數:if( !isset($ _POST ['my_nonce_name'])||!wp_verify_nonce($ _POST ['my_nonce_name']'my_nonce_action'){print'Sorry,your nonce沒有核實。';出口; } else {//你的代碼驗證成功} – MMK 2015-03-02 15:58:14
這樣做,在我的comments.php文件的頂部? $ retrieve_nonce = $ _REQUEST ['_ wpnonce'];如果(!wp_verify_nonce($ retrieve_nonce))死('失敗的安全檢查'); – 2015-03-03 13:54:45