How do major manufacturers conduct online voting?
On the Internet, we often see various kinds of voting. Today we will take a look at the online voting done by big manufacturers. Friends in need can refer to it.
I was watching Youku today and happened to see a great person on Youku - I am a legendary online voting person. I am very curious about how these big and awesome companies do online voting, so I would like to analyze it here. How does Youku do online voting?
Text:
Youku Talent--I am a legend online voting page: http://c.youku.com/niuren
Choose a player at random and you will A floating layer of playback will pop up with the voting button above. After clicking the vote successfully,
will vote again. To remind you: you have already voted, please vote again after an hour! -----It seems that this vote is normal, but these are superficial phenomena.
Using firebug we can find that each vote will trigger an http request.
We can put this http link:
http://minisite.youku.com/pub2/i_am_legend/vote.php?id=XMjc1NzExMzE2&callback=c&i=0.19621988418141467
My first impression is that this is a vote done using getjson method. We put this in In the browser, after refreshing it several times, I found that the data has been increasing by
, , and 689 votes. Is this how I can swipe votes? ?
With curiosity, I opened the page and found the vote count of this contestant:
My first impression was that this was very different from my usual voting. Similar, quickly look for the ajax request file on the list page;
Sure enough, I found it:
http://minisite.youku.com/pub2/i_am_legend/getvote.php?page=1&callback= cc&count=8&i=0.42276474971249034
This is a very typical data returned by the getjson method in jquery
(I use the jquery framework, Youku does not use jq framework, but it turns out to be similar), I found another source code for this request:
function vTpListGet(pg, pz, t){ pg = (pg || 1); pz = (pz || 8); t = (t || false); cc = function(oList, total){ if(oList.length > 0){ var html = ""; for(var i=0;i < oList.length;i++){ html += "<ul class=\"x\">\n"; html += " <li class=\"x_thumb\"><a href=\"javascript:;\" onclick=\"vTpSet('"+oList[i].videoid+"','"+oList[i].title+"');\" title=\""+oList[i].title+"\"><img src=\""+oList[i].thumburl+"\" alt=\""+oList[i].title+"\" /></a></li>\n"; html += " <li class=\"x_title\"><a href=\"javascript:;\" onclick=\"vTpSet('"+oList[i].videoid+"','"+oList[i].title+"');\" title=\""+oList[i].title+"\">"+oList[i].title+"</a></li>\n"; html += " <li class=\"x_data\">票数:<span class=\"num\">"+oList[i].total+"</span></li>\n"; html += " <li class=\"x_btn\"><span class=\"btn\" onclick=\"vTpSet('"+oList[i].videoid+"','"+oList[i].title+"');\"></span></li>\n"; html += "</ul>\n"; } html += "<p class=\"clear\"></p>"; //alert(html); document.getElementById('videosTpList').innerHTML = html; if(t){ //显示分页 max_cnt = pz; var js_pager = new jsPager(); js_pager.init(total, pz, pg, "vTpPager"); document.getElementById('videosTpPager').style.display = ""; document.getElementById('videosTpPager').innerHTML = js_pager.getHtml(); } } }; js_request("http://minisite.youku.com/pub2/i_am_legend/getvote.php?page="+pg+"&callback=cc&count="+pz+"&i=" + Math.random()); }
Let’s look at Youku’s method of limiting frequent voting:
function vTp(vid){ c = function(num,vid){ alert("投票成功,目前票数为:"+num+"票!"); var exp = new Date (); exp.setTime(exp.getTime() + 3600000); setCookie("nrtp", "true", exp); } if(getCookie("nrtp") != "true"){ js_request("http://minisite.youku.com/pub2/i_am_legend/vote.php?id="+vid+"&callback=c&i=" + Math.random()); }else{ alert("一小时内只能投票一次!"); return false; } }
actually writes cookies on the client side Judging, I can’t help but feel a little bit cheated. In the past, we often got swiped votes when doing online voting, but after all, we are using server-side verification and recording IP to limit it. However, Youku’s voting is completely based on client-side verification.
Summarize Youku’s voting:
The data on the list page is displayed in real time, which means it is displayed immediately after voting ---- Our voting that year was also displayed in real time. , but the pressure on the server was too great. When it came to brushing tickets, the database was frequently inserted and read, which put a lot of pressure on the data. The database server often went down. Later, a caching mechanism was used to solve this problem, and the data was displayed after one minute. .
There is something wrong with the voting api file. I put http://minisite.youku.com/pub2/i_am_legend/vote.php?id=XMjc1NzExMzE2&callback=c&i=0.19621988418141467 In the browser, constant refreshing can actually increase the number of votes. Obviously Youku programmers are lazy. They must at least determine the path and method of submitting the page to determine whether it comes from a normal voting request. , if this is the case, this vote will be too easy to swipe votes. Just put this URL in a different F5 of the browser. If it doesn't work, you can just write a js to refresh the page regularly.
The mechanism to prevent ticket fraud is definitely to use client cookies for verification. This is a bit of a novice. The most common method is to verify based on IP (although this method is also used by professional ticket fraud companies. Pediatrics, but still enough to deal with non-professionals) to prevent frequent ticket fraud.
Summary;
I am a little disappointed. I thought that the technology of big companies is more mature than ours. It seems a bit overestimated. It seems that we should not be blindly obsessed with and Worship big companies, be yourself, and believe in yourself is the key!
Recommended learning: php video tutorial
The above is the detailed content of How do major manufacturers conduct online voting?. For more information, please follow other related articles on the PHP Chinese website!

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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



PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.
