Now it’s a relatively known fact that people tend to strip attribution links once they acquire designs from those free, open source design inventories. Be it Open Source Web Design templates, or Wordpress Themes, this has become a problem of many a developers and designers.
A designer/developer invests time in creating a theme, and this is generally done to spread the word linking to their portfolio. Now there are very few people who let these attributions stay, most tend to strip them off. (Heck! Even I did it, in the last theme I was using. Alright, go on, shoot me)
Here what I am going to teach you is to encode your footer links, such that when displayed in a PHP file it will look nothing more but gibberish text, but when the PHP file is called for it will output proper html text.
Let’s Begin
Let’s suppose we wanted to add some unremoveable text (e.g. a link back to our site) to the footer of a Wordpress theme. We could place some code in the theme’s functions.php file that looks something like this:
Code:
<?php
function theme_credits()
{
echo ‘Designed by <a href=”http://www.abhishektripathi.com”>Abhishek Tripathi</a>.’;
}
add_action(‘wp_footer’,‘theme_credits’,30);
?>
The function theme_credits in the above code echoes a simple link back to our site, and the next line of code registers it as one of the functions called in the footer of the theme — or wherever you placed the bit of code:
Code:
<?php wp_footer(); ?>
Anyone with a little PHP knowledge could figure out what we’re up to almost immediately — which is where encryption comes in.
At the very least we’ll need a couple of two-way encryption functions. One has to be text-based, and the other [optionally] byte-based. We’ll settle on base64_encode and gzdeflate. The text-based function encrypts the output of the byte-based function and outputs something we can paste in a text editor.
If we Echo:
Code:
<?php
echo base64_encode(gzdeflate(
‘function theme_credits()
{
echo \’Designed by <a href=”http://www.example”>Example Designs</a>.\’;
}
add_action(\’wp_footer\’,\’theme_credits\’,30);’
));
?>
We get the string:
VY7LCsIwFET3gv9w6SYtlERwZx8r/Y4QkxsTMA/SSBTx35WWLJzVmcUcR
j+8zDZ4yAYdcplQ2by03X4Ha95QCaUJQM642JtHBdcXjAJMQj0 1Jud4YqyUQv
EpXLwjlcE182UrsI1GJmZKhur7/MyVhVJcrD9aUiLXIWRMpCd/p0h/PHTDFw==
To run the code, we decrypt, then call eval on it:
Code:
<?php
eval(gzinflate(base64_decode(‘VY7LCsIwFET3gv9w6SYtlERwZx8r/Y4QkxsTMA/SSBTx35WWLJzVmcUcRj+8zDZ4yAYdcpl
Q2by03X4Ha95QCaUJQM642JtHBdcXjAJMQj01Jud4YqyUQvEpXLwjlcE182UrsI1GJmZKhur7/MyVhVJcrD
9aUiLXIWRMpCd/p0h/PHTDFw==‘)));
?>
This is alright as is, but calling echo instead of eval on the string will reveal our code. For an increased layer of complexity, we can have it eval over and over again. Here’s a simple loop you can use to generate the code:
Code:
<?php
$text = ‘function theme_credits()
{
echo \’Designed by <a href=”http://www.example.com”>Example Design</a>.\’;
}
add_action(\’wp_footer\’,\’theme_credits\’,30);’; // our code
$num_times = 20; // number of times to encrypt
for ($i = 0; $i < $num_times; $i++) {
$text = “eval(gzinflate(base64_decode(’” . base64_encode(gzdeflate($text)) . “‘)));”;
}
echo $text;
?>
The output in this case is:
eval(gzinflate(base64_decode(‘DdJHDqxWAkDR5dgWA6 DIsjwgP3KOkxaxSEXOq++/hHt0qzMb/v6+7VgP2V79nWdbReL/K6
tiKqu//xJSUxKXN2J7Pu5JJ0GEJtC+diGPxe/EuB2WtRX+0LpLTq8MMwf2I5cbeiZ4I9/T02+YCEMjrUMMo9
XZO9SFtJ6uYL2R2Q7BTr7pXgCik59IGSWZvpH73PHiEt806hst 3FwtR7urIATeMrweGnkCge8RPbzQ+zo4vaeK+
Uuu+TNMu33sRIcPDR1N+l774IE76G767ehYZ2zK8n2hWmfcGHX alVk5k8efagmfX4bWVItyCV6×2l6DZo5EiM6NRbMtx
4+xGZoctm3maiS1cunjUFpwZp3MPJDxCRuyqBJVet9ZvFb3cRC vZBOa8m2v+VaASZksNan78Uuhq1h9ke1EHX0y
JKE8YVNf+oETDpF9eD3E/Cu3Mnfp+42t/vscCiwmj4nybJvigNuum29elpzTEI9sgC3JrFc/8BrR1t+71OFerf0o2vfGBr
IwvKJbnYxxOoqGrPx0qYkdmsq4+VcbVJ5vt4VvuryiqBZnaOKo V9Kw/eTjO7VpZgG23OtQuO6HLopTuTMzqMJXBhQl
4p8ax/yOuIJYP1whbXcm6cDCJvSh5gUNZtgsTBYj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51WPdfX0NyB7dvGqCxxbT9DEoHZGQ49ptQlC z8Z4u0Qa7kTjuz2QAE9LUWcxnhLplVIrswoIJfy
eljn4gDFXCX4IrdQkkl0arP40m7j7OVjw9aF+Ef/a8NYOLcwEWV6NN1TgBIPYaLqHRoG/TNZU4n+9bJJM/nrCcMQdF
R1DVOMff3331///PPPv/8H’)));
So there you have it: a way to hide your code.
Hope some of you find it helpful. Happy Developing.
Note: For all encrypted strings posted here, ignore the new lines. I had to do them so the theme won’t break.
Bookmarks