简体   繁体   English

如何将javascript代码更改为php

[英]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.一些网站复制了我的网站数据,他们使用了我网站的所有内容。当我创建任何页面时,例如 example.com/abc.php,同一页面也会同时在该网站上创建,如果我在 abc 中添加 123 .php 页面比那里的网站页面上也会有 b 123。 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.如果我将我的网站 url 放在我的任何页面中,它们会自动替换为自己的网站 url。现在当我在我的网站上添加此 javascript 代码时,此代码可以将这些网站重定向到我的网站,但这些人可以隐藏该 javascript 代码在那里的网站上,而不是在那里的网站上不显示 javascript 代码。 i want to convert this code into php pls help me我想将此代码转换为 php 请帮助我

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:使用php查看域名:

$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.然后您可以编写一个脚本来收集所有引用 IP 地址,并检查 IP 地址中是否存在“标记”页面。 If it is, the script would stick the IP in a blacklist file.如果是,脚本会将 IP 粘贴到黑名单文件中。

Example:例子:

Marker Page: example.com/abcdefg_content , which would have a random string as content: example.aZx4lm5d .标记页面: example.com/abcdefg_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.然后编写一个简单的脚本来检查所有引用 IP 并查找标记页面,如果内容相同,则将引用者列入黑名单。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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