Table of Contents
Text:
Summarize Youku’s voting:
Summary;
Home Backend Development PHP Problem How do major manufacturers conduct online voting?

How do major manufacturers conduct online voting?

Jul 14, 2021 pm 04:46 PM
php

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());
}
Copy after login

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;
  }
}
Copy after login

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 of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

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

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

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

7 PHP Functions I Regret I Didn't Know Before 7 PHP Functions I Regret I Didn't Know Before Nov 13, 2024 am 09:42 AM

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

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

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

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

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,

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

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

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

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

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

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 PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

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.

See all articles