There is a difficult problem, PHP to get the value of JavaScript to determine the origin of the domain name, late processing ~
The entire code is as follows
First you run in the browser, open the console to watch
http://localhost/test.php
Jump to Test1
Then jump to test1.php, code
Session_Start ();
Require "./test2.php";
Class a{
function __construct ()
{
$b =new B ();
$b->judge ();
}
Function judge ()
{
if ($_session[' status ']==1) {
return true;
}else{
return false;
}
}
function Run ()
{
if ($this->judge ()) {
echo ' success ';
}else{
echo ' ERROR ';
}
}
}
$a =new A ();
$a->run ();
?>
The role is in the implementation of Class A method of the first judgment of the name of the route, whether from localhost, if yes, output success, not output error
test2.php Code
Session_Start ();
Class b{
Function judge ()
{
Echo ';
}
}
?>
test3.php, calling Ajax execution file
Session_Start ();
if (Stristr ($_post[' data '), ' localhost ')} {
$_session[' status ']=1;
}else{
$_session[' status ']= ';
}
?>
------Solution--------------------
May I ask the question you are dealing with, or do you want to study the problem? Because I didn't understand what you were going to do, sorry.
------Solution--------------------
Tell me what you want to do. What's the problem?
------Solution--------------------
Can't understand the need,
You are PHP files, if you want to know the source of the previous page, with $_server[' Http_referer '] on it, it is necessary to do JS?
------Solution--------------------
The entire request can be forged.
This does make the forgery difficult, but the code becomes very complex ...
------Solution--------------------
Can be modified to use Cookie/session to get the user, do not get the error.
If the user requests too frequently, the request is masked. Then using the cache to implement the performance should also be possible.