There is a difficult question about PHP to get the value of JavaScript to determine the routing of the domain name, late bad processing

Source: Internet
Author: User
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.
  • 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.