如果删除信用链接,网站将停止工作

时间:2012-10-16 作者:Matt

我正在尝试向我创建的所有WP网站的页脚添加一个信用链接,并说:

设计人

虽然这很简单,但我想对其进行编码,以便在从页脚中删除此链接时,整个网站显示错误或无法加载等。

有人有想法吗?

2 个回复
最合适的回答,由SO网友:TaghaBoy 整理而成

----------------更新------------------

我对@Rizier123提供的代码做了一些更改

Now it will accept to add a link in the citation varibale

您需要更改preg_match (感谢@Rizier123)通过以下方式:

if(!preg_match("/" . preg_quote($citation_string, "/") . "/", $footer_contents))
最后的代码如下:

add_action(\'template_redirect\', \'foobar_explode_if_no_citation\');
function foobar_explode_if_no_citation(){

#Get the absolute server path to footer.php
$footer_path = locate_template(\'footer.php\');

#Store the footer file contents in a var
$footer_contents = file_get_contents($footer_path);

#The required string
$citation_string = \'Designed by Foo Bar <a href="http://YourLink.com">anchor</a>\';

#Set off the nuclear bomb if there is an egregious offense
if(!preg_match("/" . preg_quote($citation_string, "/") . "/", $footer_contents))
    exit(\'All your websitez are belong to me. Make sure this string "Designed by Foo Bar" is included in footer.php\');
}

? Who will work with this code ?

编码人员worked days and night 提供精彩内容,并将引用词或链接作为版权。。不想让脚本的用户remove it or replace it 用他自己的without permission...

it\'s just a simple way to respect the copyright! respect coders.

SO网友:Brian Fegter

虽然我认为这个前提是有缺陷的,有点黑帽子,但这是一个合法的WP问题,尽管这是一个徒劳的练习。

您可以执行以下操作:

add_action(\'template_redirect\', \'foobar_explode_if_no_citation\');
function foobar_explode_if_no_citation(){

    #Get the absolute server path to footer.php
    $footer_path = locate_template(\'footer.php\');

    #Store the footer file contents in a var
    $footer_contents = file_get_contents($footer_path);

    #The required string
    $citation_string = \'Designed by Foo Bar\';

    #Set off the nuclear bomb if there is an egregious offense
    if(!preg_match("/$citation_string/", $footer_contents))
        exit(\'All your websitez are belong to me. Make sure this string "Designed by Foo Bar" is included in footer.php\');
}
我希望你能听到我开玩笑的含沙射影,暗示这将是多么糟糕的用户体验。:)

注意,正如评论中所指出的,有无数种方法可以引导这种方法,以及任何与此相关的方法。任何人都可以轻松地对安装的任何机制进行反向工程。

结束

相关推荐