This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

PHP Notice with the new update

Home Forums Product Support Forums Ajax Search Pro for WordPress Support PHP Notice with the new update

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #7196
    Jacques LetessonJacques Letesson
    Participant

    Hi there,

    Since the new update, I receive several php notices related to Ajax Search Pro :

    [code]Notice: Undefined index: SERVER_PORT in /home/restofra/public_html/wp-content/plugins/ajax-search-pro/functions.php on line 183

    Notice: Undefined index: SERVER_NAME in /home/restofra/public_html/wp-content/plugins/ajax-search-pro/functions.php on line 184

    Notice: Undefined index: SERVER_PORT in /home/restofra/public_html/wp-content/plugins/ajax-search-pro/functions.php on line 184[/code]

    It is somehow related to :

    [php] function wd_current_page_url() {
    $pageURL = ‘http’;
    if( isset($_SERVER["HTTPS"]) ) {
    if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
    }
    $pageURL .= "://";
    if ($_SERVER["SERVER_PORT"] != "80") {
    $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
    } else {
    $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
    }
    return $pageURL;
    }[/php]

    Could you please let me know how to fix this?

    Thank you.

    #7197
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi!

    I’ve googled a bit about this issue, and most likely there might have been a change on your hosting – either IPv6 address or something similar. This code has been around before the update, you just probably didn’t get notices before that.

    Can you please try to replace the code with this modified version of this function?

    [php] function wd_current_page_url() {
    $pageURL = ‘http’;

    $port = !empty($_SERVER["SERVER_PORT"]) ? $_SERVER["SERVER_PORT"] : 80;

    $server_name = !empty($_SERVER["SERVER_NAME"]) ? $_SERVER["SERVER_NAME"] : "";
    $server_name = empty($server_name) && !empty($_SERVER[‘HTTP_HOST’]) ? $_SERVER[‘HTTP_HOST’] : $server_name;

    if( isset($_SERVER["HTTPS"]) ) {
    if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
    }
    $pageURL .= "://";
    if ($port != "80") {
    $pageURL .= $server_name.":".$port.$_SERVER["REQUEST_URI"];
    } else {
    $pageURL .= $server_name.$_SERVER["REQUEST_URI"];
    }
    return $pageURL;
    }[/php]

    let me know if you see any notices with the change.

    #7276
    Jacques LetessonJacques Letesson
    Participant

    @Ernest

    Thank you it fixes the issue !

    Cheers,

    J.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.