怎么用cookie防止用户的灌水回复
如何用cookie防止用户的灌水回复?
今天没事瞎点 点到 凤凰网的一个链接了 http://yue.ifeng.com/y/detail_2011_12/07/11160676_0.shtml
评论框 内容是 :文明上网,登陆评论!
直接点按钮 js alert 请填写评论内容
再点一下文本框 文本框内容变成:请您先登录,再发布评论。
再点按钮 就提交了
打开的页面中的最新评论里就有了。然后我就复制了部分html
- HTML code
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> <meta http-equiv="Content-Type" content="text/html" charset="utf-8">
提交了就有了。
然后想到用curl post 模拟form的效果 但是没试成功 可能是 少了一些东西
- PHP code
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> header("content-type:text/html;charset:utf-8;"); /* chId 21202 content mmmmmmmmm docId 11160676 docName 吴卓羲女友张馨予家中大尺度内衣自拍照火辣曝光 docUrl http://yue.ifeng.com/y/detail_2011_12/07/11160676_0.shtml */ $url = "http://comment.ifeng.com/post.php"; //$url = "http://localhost/php/index.php"; $data = array( 'content'=>'xxxxxxxxxxoooooooooooo', 'docId'=>11160676, 'docName'=>'吴卓羲女友张馨予家中大尺度内衣自拍照火辣曝光', 'docUrl'=>'http://yue.ifeng.com/y/detail_2011_12/07/11160676_0.shtml', 'chId'=>21202 ); $ret = http_post($url,$data); var_dump($ret); function http_post($url, $data) { $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER,1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); $data = http_build_query($data); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_REFERER, "http://yue.ifeng.com/y/detail_2011_12/07/11160676_0.shtml"); $cookie = "userid=1323532473389_2814"; curl_setopt($ch, CURLOPT_COOKIE, $cookie); $rs = curl_exec($ch); curl_close($ch); return $rs; }
碰到的问题是:
1.评论的东西 人的头像跟其他不一样 是灰色的 正常的是银灰的。我换了浏览器 打开链接 没看到 灌水的内容 然后我用firebug 的firecookie插件看了一下 cookie 发现有 userid 和 cmtids 没灌水一个 cmtids 就多一个
http://comment.ifeng.com/view.php?doc_url=http%3A%2F%2Fyue.ifeng.com%2Fy%2Fdetail_2011_12%2F07%2F11160676_0.shtml&doc_name=%E5%90%B4%E5%8D%93%E7%BE%B2%E5%A5%B3%E5%8F%8B%E5%BC%A0%E9%A6%A8%E4%BA%88%E5%AE%B6%E4%B8%AD%E5%A4%A7%E5%B0%BA%E5%BA%A6%E5%86%85%E8%A1%A3%E8%87%AA%E6%8B%8D%E7%85%A7%E7%81%AB%E8%BE%A3%E6%9B%9D%E5%85%89&ishot=no
我清理cookie 刷新页面 cookie出现 userid = 1323533123324_5513
用上面的html提交一下 就出现 cmtids = 45583 再来一次 cmtids = 45583_45612
清理cookie 就没了
2.为啥要暂存这样的评论呢?既然是要登录后才能评论。。。js没判断好到最新评论页显示了个假的?
小弟才疏学浅,没事瞎捣鼓了一下,望各位大侠帮忙分析一下。。。嘎嘎
------解决方案--------------------
刚去看了一下,还真是直接就提交了,这个网站也真是够宽松的……
如果 curl 直接提交不被接受的话,那很有可能服务器端还是有一些额外的要求(比如特定的 cookie 啥的),建议在网页提交的时候查看一下 HTTP 数据流,然后用 curl 模拟得充分一点,应该能搞定。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



To update the curl version under Linux, you can follow the steps below: Check the current curl version: First, you need to determine the curl version installed in the current system. Open a terminal and execute the following command: curl --version This command will display the current curl version information. Confirm available curl version: Before updating curl, you need to confirm the latest version available. You can visit curl's official website (curl.haxx.se) or related software sources to find the latest version of curl. Download the curl source code: Using curl or a browser, download the source code file for the curl version of your choice (usually .tar.gz or .tar.bz2

Cookies are usually stored in the cookie folder of the browser. Cookie files in the browser are usually stored in binary or SQLite format. If you open the cookie file directly, you may see some garbled or unreadable content, so it is best to use Use the cookie management interface provided by your browser to view and manage cookies.

Cookies on your computer are stored in specific locations on your browser, depending on the browser and operating system used: 1. Google Chrome, stored in C:\Users\YourUsername\AppData\Local\Google\Chrome\User Data\Default \Cookies etc.

How to handle 301 redirection of web pages in PHPCurl? When using PHPCurl to send network requests, you will often encounter a 301 status code returned by the web page, indicating that the page has been permanently redirected. In order to handle this situation correctly, we need to add some specific options and processing logic to the Curl request. The following will introduce in detail how to handle 301 redirection of web pages in PHPCurl, and provide specific code examples. 301 redirect processing principle 301 redirect means that the server returns a 30

Cookies on the mobile phone are stored in the browser application of the mobile device: 1. On iOS devices, Cookies are stored in Settings -> Safari -> Advanced -> Website Data of the Safari browser; 2. On Android devices, Cookies Stored in Settings -> Site settings -> Cookies of Chrome browser, etc.

Understand the meaning of HTTP 301 status code: common application scenarios of web page redirection. With the rapid development of the Internet, people's requirements for web page interaction are becoming higher and higher. In the field of web design, web page redirection is a common and important technology, implemented through the HTTP 301 status code. This article will explore the meaning of HTTP 301 status code and common application scenarios in web page redirection. HTTP301 status code refers to permanent redirect (PermanentRedirect). When the server receives the client's

With the popularity of the Internet, we use browsers to surf the Internet have become a way of life. In the daily use of browsers, we often encounter situations where we need to enter account passwords, such as online shopping, social networking, emails, etc. This information needs to be recorded by the browser so that it does not need to be entered again the next time you visit. This is when cookies come in handy. What are cookies? Cookie refers to a small data file sent by the server to the user's browser and stored locally. It contains user behavior of some websites.

HTTP Status Code 200: Explore the Meaning and Purpose of Successful Responses HTTP status codes are numeric codes used to indicate the status of a server's response. Among them, status code 200 indicates that the request has been successfully processed by the server. This article will explore the specific meaning and use of HTTP status code 200. First, let us understand the classification of HTTP status codes. Status codes are divided into five categories, namely 1xx, 2xx, 3xx, 4xx and 5xx. Among them, 2xx indicates a successful response. And 200 is the most common status code in 2xx
