search
HomeBackend DevelopmentPHP ProblemHow 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.

How do major manufacturers conduct online voting?

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.

How do major manufacturers conduct online voting?

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

, How do major manufacturers conduct online voting?, and 689 votes. Is this how I can swipe votes? ?

With curiosity, I opened the page and found the vote count of this contestant:

How do major manufacturers conduct online voting?

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

How do major manufacturers conduct online voting?

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(&#39;"+oList[i].videoid+"&#39;,&#39;"+oList[i].title+"&#39;);\" 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(&#39;"+oList[i].videoid+"&#39;,&#39;"+oList[i].title+"&#39;);\" 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(&#39;"+oList[i].videoid+"&#39;,&#39;"+oList[i].title+"&#39;);\"></span></li>\n";
        html += "</ul>\n";
      }
      html += "<p class=\"clear\"></p>";
      //alert(html);
      document.getElementById(&#39;videosTpList&#39;).innerHTML = html;

      if(t){
        //显示分页
        max_cnt = pz;
        var js_pager = new jsPager();
        js_pager.init(total, pz, pg, "vTpPager");
        document.getElementById(&#39;videosTpPager&#39;).style.display = "";
        document.getElementById(&#39;videosTpPager&#39;).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!

Statement
This article is reproduced at:博客园. If there is any infringement, please contact admin@php.cn delete
ACID vs BASE Database: Differences and when to use each.ACID vs BASE Database: Differences and when to use each.Mar 26, 2025 pm 04:19 PM

The article compares ACID and BASE database models, detailing their characteristics and appropriate use cases. ACID prioritizes data integrity and consistency, suitable for financial and e-commerce applications, while BASE focuses on availability and

PHP Secure File Uploads: Preventing file-related vulnerabilities.PHP Secure File Uploads: Preventing file-related vulnerabilities.Mar 26, 2025 pm 04:18 PM

The article discusses securing PHP file uploads to prevent vulnerabilities like code injection. It focuses on file type validation, secure storage, and error handling to enhance application security.

PHP Input Validation: Best practices.PHP Input Validation: Best practices.Mar 26, 2025 pm 04:17 PM

Article discusses best practices for PHP input validation to enhance security, focusing on techniques like using built-in functions, whitelist approach, and server-side validation.

PHP API Rate Limiting: Implementation strategies.PHP API Rate Limiting: Implementation strategies.Mar 26, 2025 pm 04:16 PM

The article discusses strategies for implementing API rate limiting in PHP, including algorithms like Token Bucket and Leaky Bucket, and using libraries like symfony/rate-limiter. It also covers monitoring, dynamically adjusting rate limits, and hand

PHP Password Hashing: password_hash and password_verify.PHP Password Hashing: password_hash and password_verify.Mar 26, 2025 pm 04:15 PM

The article discusses the benefits of using password_hash and password_verify in PHP for securing passwords. The main argument is that these functions enhance password protection through automatic salt generation, strong hashing algorithms, and secur

OWASP Top 10 PHP: Describe and mitigate common vulnerabilities.OWASP Top 10 PHP: Describe and mitigate common vulnerabilities.Mar 26, 2025 pm 04:13 PM

The article discusses OWASP Top 10 vulnerabilities in PHP and mitigation strategies. Key issues include injection, broken authentication, and XSS, with recommended tools for monitoring and securing PHP applications.

PHP XSS Prevention: How to protect against XSS.PHP XSS Prevention: How to protect against XSS.Mar 26, 2025 pm 04:12 PM

The article discusses strategies to prevent XSS attacks in PHP, focusing on input sanitization, output encoding, and using security-enhancing libraries and frameworks.

PHP Interface vs Abstract Class: When to use each.PHP Interface vs Abstract Class: When to use each.Mar 26, 2025 pm 04:11 PM

The article discusses the use of interfaces and abstract classes in PHP, focusing on when to use each. Interfaces define a contract without implementation, suitable for unrelated classes and multiple inheritance. Abstract classes provide common funct

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools