tags:

views:

61

answers:

3

Example link on my footer

$powered = 'Powered by <a href="htp://stackoverflow.com">Stackoverflow</a>';

theme file

<?php echo $powered; ?>

How to make if $powered removed from my footer and the error/reminder notice it.

Example die('Do not remove the powered link')

+6  A: 

Short answer: not possible.

zaf
+2  A: 

It's possible... you can use Zend Guard to protect your code from being altered.

tpae
That is a much better solution if protecting the code from modification important.
RandyMorris
+2  A: 

Long answer:

<?php

$powered = 'Powered by <a href="htp://stackoverflow.com">Stackoverflow</a>';

ob_start();
echo $powered;
$html = ob_get_clean();

/*
 * If you remove the "echo $powered;" part, please don't remove the following lines
 * so I can detect the license violation. Thank you for your cooperation!
 */
if( strpos($html, $powered)===FALSE ){
    echo die('Do not remove the powered link');
}else{
    echo $html;
}

?>
Álvaro G. Vicario
So you rely on the user obeying your command!?
zaf
at least it possible.
bob
Let's say it's just a general grasp of how can be done. This is supposed to be implemented in a larger system and we don't know its internals. There are always tricks to enforce compliance (server settings, obfuscated code...) and there're always tricks to skip it (remove the checks from code, hide the notice with CSS...).
Álvaro G. Vicario
Erm, ok. Then the simplest answer is "echo $powered; // DO NOT REMOVE!"
zaf
There is a way around everything for those who have skill and don't give up, however, this is a good example for at least a working solution.
RandyMorris
zaf.. actually the main of `$powered =''` protected by ioncube. the echo $powered just on the template file.
bob