简体   繁体   中英

how to change javascript code into php

some sites copied my website data and they use every thing of my site.when i create any page like example.com/abc.php than the same page will create on there website as well on same time and if i add 123 in my abc.php page than there will b 123 on there website page also. when i update anything in my website than there website also update the same my data on same time aswell. and if i put my site url in any of my page than they replace automatically with there own site url.now when i add this javascript code on my site than this code can redirect there sites to my website but these guys can hide that javascript code on there website and than that javascript code not shows on there websites. i want to convert this code into php pls help me

var re = /^(www\.)?((example|site2|site3)\.com|(site4|site5)\.com)$/;
if ( !re.test( location.hostname ) ) {
    location.href = 'http://example.com';
}

use php to check the domain name:

$current_page = basename($_SERVER['PHP_SELF']); 

if($current_page != 'exmaple.com'){

and if its not your domain name use:

   header("Location: http://example.com/");

You could create a 'marker' page in your site. Then you could write a script to gather all the referrer IP addresses, and check if the 'marker' page is present in the IP addresses. If it is, the script would stick the IP in a blacklist file.

Example:

Marker Page: example.com/abcdefg_content , which would have a random string as content: example.aZx4lm5d .

Then one would write a simple script to check all the referring IPs and look for the marker page, and if the content is the same, then blacklist the referrer.

$referrers = ...
foreach($referrers as $referrer){
    if(check_for_marker_page_on_ip($referrer)){
        blacklist_ip($referrer);
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM