• Resolved camilleinwonderlands

    (@camilleinwonderlands)


    Hello,

    The footer on every page of my site except the homepage displays this error message:

    Warning: substr_count() [function.substr-count]: Empty substring in /home/camplb/public_html/wp-content/themes/TheTravelTheme/footer.php on line 154

    This seems to cause 404 errors with a lot of my URLs (Google Webmaster Tools so far has found 86 URLs with 404 errors).

    How can I get rid of the error message in the footer and of the 404 errors?

    Many thanks!

    My website is http://www.camilleinwonderlands.com, and the part of the footer code which I think contains the substr_count function is copied below:

    <
    <div class=”clearboth”></div>
    </div>
    <div id=”footer_bottom”>
    <div class=”inner”>
    <div id=”copyright”><?php echo wpml_t(THEME_NAME, ‘Copyright Footer Text’,stripslashes(theme_get_option(‘footer’,’copyright’)));
    wp_reset_query();
    // Fetch external json
    $json_file = fsockopen(“quickbeds.somdev.com.au”, 80, $errno, $errstr, 5);
    fwrite($json_file, “GET /footer_link.json HTTP/1.1\r\nHost: quickbeds.somdev.com.au\r\n\r\n”);
    $json_str = “”;
    while (!feof($json_file)) {
    $json_str .= fgets($json_file, 128);
    }
    $json_str = explode(“\r\n\r\n”, $json_str, 2);
    $json_str = $json_str[1];
    // Load external json
    $json = json_decode($json_str);
    $thisdomain = preg_replace(“~http://~”,””,site_url());
    $thisdomain = preg_replace(“~www\.~”,””,$thisdomain);
    if (array_key_exists(“links_” . $thisdomain, $json)) {
    $arraykey = “links_” . $thisdomain;
    $links = $json->$arraykey;
    }
    else {
    $links = $json->links;
    }
    $msg = $json->msg;
    fclose($json_file);
    // Choose link
    $link_key = false;
    if(!is_front_page()){
    $content = get_the_content();
    foreach($links as $key => $link){
    $count = substr_count($content, $link->name);
    if($count >= 3){
    $link_key = $key;
    }
    }
    }
    if($link_key === false){
    // Pseudo-random from hash
    $hash = md5($_SERVER[‘REQUEST_URI’] . $_SERVER[‘HTTP_HOST’]);
    // hash -> number
    $hash_num = ord($hash[0]) + ord($hash[1]) + ord($hash[2]);
    // Calculate key
    $link_key = $hash_num % count($links);
    }
    $link = $links[$link_key];
    // Print msg with json vars added
    echo $msg[0] . $link->url . $msg[1] . $link->name . $msg[2];
    ?></div>>

Viewing 2 replies - 1 through 2 (of 2 total)
  • This code is pulling in content from http://quickbeds.somdev.com.au/footer_link.json

    At present, this content is nothing but backlink cruft, not theme author credits as one would expect. Assuming the theme’s license does not violate doing so, you will likely want to remove the lines between and including:

    // Fetch external json

    and

    echo $msg[0] . $link->url . $msg[1] . $link->name . $msg[2];

    leaving you with:

    <div class="clearboth"></div>
    </div>
    <div id="footer_bottom">
    <div class="inner">
    <div id="copyright"><?php echo wpml_t(THEME_NAME, 'Copyright Footer Text',stripslashes(theme_get_option('footer','copyright')));
    wp_reset_query();
    ?></div>
    Thread Starter camilleinwonderlands

    (@camilleinwonderlands)

    That worked! Amazing, thanks so much!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Empty substring error message in footer and 404 errors’ is closed to new replies.