Thursday, June 10, 2010

Decrypting Wordpress Themes Footer in function.php

I was struggling for a client to remove some of the link back on the footer of his wordpress theme from MagPress. He wanted to provide full credit to the author but thought it was unfair to include some cheap linkbacks for unrelated sites. I understand the level of effort it takes to develop these themes but rather charge for it than encrypt footers. Thats just lame and makes us think you're hiding something else. I see MagPress solicits these in lots of a 100 on Digitalpoint, which seriously has deteriorated into an un-moderated mess. Check it:

http://forums.digitalpoint.com/showthread.php?t=1783251

I managed to figure out a solution which took me about 5 minutes once I found the files:

  1. Locate the functions.php file in your theme folder.


  2. Scroll to the bottom and find the encrypted code that begins with: eval(base64_decode and end with ; (Make sure you do not include any PHP tags all you want it the encrypted part. This is the code that compares what is written in the footer.php and throws that huge error message.


  3. Ends up you're copying something like this:
    eval(base64_decode('xpZCAjRk...lots of stuff in between..OyBpZinKTs='));


  4. Use this decoding tool to decrypt the code into readable PHP.



  5. End up looking something like this which you'll paste and replace the encrypted code above in functions.php

    if (!empty($_REQUEST["theme_credit"])) {

    theme_usage_message(); exit();

    }

    function theme_usage_message() {

    if (empty($_REQUEST["theme_credit"])) {

    $theme_credit_false = get_bloginfo("url") . "/index.php?theme_credit=false";

    echo "< equiv="\" content="\" url="$theme_credit_false\">"; exit();

    } else {

    $rk_url = get_bloginfo('template_directory');
    $homepage = get_bloginfo('home');

    echo ("
    ");
    echo ("

    ");

    echo ("
    Opps..You Have Modified The Footer Links..
    ");

    echo ("
    This Theme Is Released Free For Use Under Creative Commons Licence. All Links In The Footer Must Remain Intact AS IS. These Links Are All Family Friendly And Will Not Hurt Your Site In Any Way. Please Appreciate These Supporters Effort In Providing You This Great Theme For Free.
    ");

    echo ("
    Please Follow These Steps To Restore The Footer:
    1. Please open the default folder, you'll find footer.php inside
    2. Copy & paste it to overwrite the current footer.php you've modified.
    3. Finally, refresh your page HERE to go back to your homepage.
    ");

    }

    }

    function check_theme_footer() {

    $l = 'CoreMag WordPress Theme By MagPress
    Thanks To http://XXX | Whatever.com | BuyXX XXX';


    $f = dirname(__file__) . "/footer.php";

    $fd = fopen($f, "r");

    $c = fread($fd, filesize($f));

    fclose($fd); if (strpos($c, $l) == 0) {

    theme_usage_message();

    die;

    }

    }

    check_theme_footer();


    if(!function_exists('get_sidebar')) {

    function get_sidebar() {

    check_theme_header();

    get_sidebar();

    }
    }

    function check_theme_header() {

    if (!(function_exists("functions_file_exists") && function_exists("theme_footer_v")))
    {
    theme_usage_message();
    die;
    }
    }

    function functions_file_exists() {

    if (!file_exists(dirname(__file__) . "/functions.php") || !function_exists("theme_usage_message") )
    {
    theme_usage_message();
    die;
    }
    }

    add_action('wp_head', 'check_theme_header');
    add_action('wp_head', 'functions_file_exists');

  6. This is the code that matters and I replaced this part in it's entirety to retain the author credit and made sure it matched the HTML code in the footer.php exactly!

  7. You can also merely comment out check_theme_footer();

    // check_theme_footer();

6 comments:

varun said...

Thank you very much.

rhoula said...

Hello...
Thank you for the great post. Wouldn't be easier to find the tag that compares the functions.php file and the footer.php file and delete the tag only rather than decoding the code and replacing the whole thing?
Just curious

Anonymous said...

thank you!!!
just to mention: be sure you have the TWO versions of footer.php edited exactly the same.

/default/footer.php
footer.php

J (Encrypted Flash Drive Guy) said...

I have installed SNMP on Ubuntu, it’s really so easy. I am really happy to lean about SNMP which describes a network protocol as well as an organizational structure that is called the Structure of Management Information.

J (Encrypted Flash Drive Guy) said...

Thanks for the great stuff. I think decrypting the encrypted footer of Wordpress theme is actually confusion task as encrypted footers are available in lots of forms and it would be not possible to create a particular guide to face them all. But the specified function is also helpful.

Sudarshan said...

thanks man.. it was really helpful :) i was trying this out since past 1 hr..