· I made a vote and put it on the subscription number. I used cookies to prohibit ticket refresh. This is really only a matter of preventing the gentleman from defending against the villain and malicious votes. So I finally used IP addresses to restrict it; because it is a short activity, the IP record is written to the file and no longer written into the table. My validation rule is: within 3 minutes
· I made a vote and put it on the subscription number. I used cookies to prohibit ticket refresh. This is really only a matter of preventing the gentleman from defending against the villain and malicious votes. So I finally used IP addresses to restrict it; because it is a short activity, the IP record is written to the file and no longer written into the table. My validation rule is: within 3 minutes
· I made a vote and put it on the subscription number. I used cookies to prohibit ticket refresh. This is really only a matter of preventing the gentleman from defending against the villain and malicious votes. So I finally used IP addresses to restrict it;
Because it is a short activity, the IP address record is written into the file and no more data is written into the table;
My verification rule is: only one vote can be cast for the same IPaddress corresponding to the same ID within 3 minutes;
The code is not well written. I am in a hurry to hand in the Code. Let's look at it first and then improve it later.
Function GetIP () {if ($ _ SERVER ["HTTP_X_FORWARDED_FOR"]) $ ip = $ _ SERVER ["HTTP_X_FORWARDED_FOR"]; else if ($ _ SERVER ["HTTP_CLIENT_IP"]) $ ip = $ _ SERVER ["HTTP_CLIENT_IP"]; else if ($ _ SERVER ["REMOTE_ADDR"]) $ ip = $ _ SERVER ["REMOTE_ADDR"]; else if (getenv ("token") $ ip = getenv ("HTTP_X_FORWARDED_FOR"); else if (getenv ("HTTP_CLIENT_IP") $ ip = getenv ("HTTP_CLIENT_IP "); else if (getenv ("REMOT E_ADDR ") $ ip = getenv (" REMOTE_ADDR "); else $ ip =" Unknown "; return $ ip ;}$ iptxt = fopen (". /data/lovewall.txt "," a + "); $ ip = GetIP (); $ ifok = $ I = 1; while (! Feof ($ iptxt) {$ now = fgets ($ iptxt); // obtain the content of the traversal line if (! Empty ($ now) {$ now_arr = explode ('#', $ now ); if ($ now_arr [1] ===$ ip & $ now_arr [2] === _ G ['gp _ show ']. "\ n") {$ ifok = 0; if ($ now_arr ['0'] + 180> time () {$ return = array ('status' => 0, 'err _ msg '=>' a love letter can only be given once in three minutes '); echo json_encode ($ return); exit;} else {$ all = file_get_contents ('. /data/lovewall.txt '); $ new = time (). '#'. $ ip. '#'. $ _ G ['gp _ show ']. "\ n"; $ update_str = str_replace ($ now, $ new, $ all); // replace to indirectly modify file_put_contents ('. /data/lovewall.txt ', $ update_str) ;}}$ I ++;} if ($ ifok) {$ now = time (). "#". $ ip. "#". $ _ G ['gp _ show ']; fwrite ($ iptxt, $ now. "\ n");} fclose ($ iptxt );