A question about PHP

Source: Internet
Author: User
PHPcode $ P_S_T $ t_array [0] + $ t_array [1]; $ timestamptime (); session_start (); $ ll_nowtime $ timestamp; if (session_is_registered ('ll _ lasttime ') {$ ll_lasttime $ _ SE a question about PHP
PHP code
  $P_S_T = $t_array[0] + $t_array[1];$timestamp = time();session_start();$ll_nowtime = $timestamp ;if (session_is_registered(‘ll_lasttime’)){  $ll_lasttime = $_SESSION['ll_lasttime'];  $ll_times = $_SESSION['ll_times'] + 1;  $_SESSION['ll_times'] = $ll_times;}else{  $ll_lasttime = $ll_nowtime;  $ll_times = 1;  $_SESSION['ll_times'] = $ll_times;  $_SESSION['ll_lasttime'] = $ll_lasttime;}if (($ll_nowtime – $ll_lasttime)<3){  if ($ll_times>=5){    header(sprintf(“Location: %s”,’http://127.0.0.1′));    exit;  }}else{  $ll_times = 0;  $_SESSION['ll_lasttime'] = $ll_nowtime;  $_SESSION['ll_times'] = $ll_times;}

Main function: Refresh the page more than 5 times in 3 seconds and direct it to the local http: // 127.0.0.1
A piece of code widely circulated on the Internet, but it is clear that this code is wrong, because // has been used for commenting, so how can I change this code to be used normally?
I am not very familiar with PHP, so please correct it. thank you. I don't have much to score. I can only score 30.

------ Solution --------------------
Incorrect quotation marks. the quotation marks of the code on the first floor are Chinese single quotes, not English single quotes...
------ Solution --------------------
Correct code:

Date_default_timezone_set ('prc ');
$ Timestamp = time ();
Session_start ();
$ Ll_nowtime = $ timestamp;
If (isset ($ ll_nowtime )){
$ Ll_lasttime = $ _ SESSION ['ll _ lasttime'];
$ Ll_times = $ _ SESSION ['ll _ times '] + 1;
$ _ SESSION ['ll _ times '] = $ ll_times;
} Else {
$ Ll_lasttime = $ ll_nowtime;
$ Ll_times = 1;
$ _ SESSION ['ll _ times '] = $ ll_times;
$ _ SESSION ['ll _ lasttime '] = $ ll_lasttime;
}

If ($ ll_nowtime-$ ll_lasttime) <3 ){
If ($ ll_times> = 5 ){
Header (sprintf ("Location: % s", 'http: // 127.0.0.1 '));
Exit ();
}
} Else {
$ Ll_times = 0;
$ _ SESSION ['ll _ lasttime'] = $ ll_nowtime;
$ _ SESSION ['ll _ times '] = $ ll_times;
}
?>
------ Solution --------------------
Google, this is a cc protection program
An error is reported when the program provided by the landlord runs locally. after a slight modification, it can be run after testing.

Session_start (); // enable session
$ Timestamp = time ();
$ Ll_nowtime = $ timestamp;

// Determine whether a session exists. if a session exists, assign an initialization value if it does not exist.
If ($ _ SESSION ){
$ Ll_lasttime = $ _ SESSION ['ll _ lasttime'];
$ Ll_times = $ _ SESSION ['ll _ times '] + 1;
$ _ SESSION ['ll _ times '] = $ ll_times;
} Else {
$ Ll_lasttime = $ ll_nowtime;
$ Ll_times = 1;
$ _ SESSION ['ll _ times '] = $ ll_times;
$ _ SESSION ['ll _ lasttime '] = $ ll_lasttime;
}

// Current Time-start logon time to determine if frequent logon jumps or the session is assigned a value
If ($ ll_nowtime-$ ll_lasttime) <3 ){
If ($ ll_times> = 5 ){
Header ("location: Http: // www.baidu.com ");
Exit;
}
} Else {
$ Ll_times = 0;
$ _ SESSION ['ll _ lasttime'] = $ ll_nowtime;
$ _ SESSION ['ll _ times '] = $ ll_times;
}
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.