Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Rogier Lankhorst

    (@rogierlankhorst)

    Hi,

    In your screenshot I see there is an issue with the followlocation setting in curl, what happens if you disable that?

    comment out line 44 in class-url.php

    Plugin Author Rogier Lankhorst

    (@rogierlankhorst)

    The followlocation setting in curl seems to give issues in some cases. I’ve made an edited version of the curl function, which does not need the followlocation option. To check if this works for you, you can replace the current get_contents() function with this one, which works fine on my installs. If that solves your issue, and the tests work out, I’ll add it to the next update:

    public function get_contents($url, $timeout = 5) {
        $this->curl_installed = $this->is_curl_installed();
    
        //preferrably with curl, but else with file get contents
        if ($this->curl_installed) {
    
            $ch = curl_init();
            curl_setopt($ch,CURLOPT_URL,$url);
            curl_setopt($ch, CURLOPT_HEADER, true);
            curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
            curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
            //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
            curl_setopt($ch,CURLOPT_FRESH_CONNECT, TRUE);
            curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, false);
            //curl_setopt($ch, CURLOPT_MAXREDIRS, 3);
            $filecontents = curl_exec($ch);
    
            $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    
            if(curl_errno($ch)) {
              $this->error_number = curl_errno($ch);
            } elseif ($http_code>400) {
              $this->error_number = $http_code;
            } else {
              $this->error_number = 0;
            }
    
            curl_close($ch);
            if ($http_code != 200) {
                if ($http_code == 301 || $http_code == 302) {
                    list($header) = explode("\r\n\r\n", $filecontents, 2);
                    $matches = array();
                    preg_match("/(Location:|URI:)[^(\n)]*/", $header, $matches);
                    $url = trim(str_replace($matches[1],"",$matches[0]));
                    $url_parsed = parse_url($url);
                    return isset($url_parsed) ? $this->get_contents($url) : '';
                }
            }
    
          } else {
            set_error_handler(array($this,'custom_error_handling'));
            $filecontents = file_get_contents($url);
            //errors back to normal
            restore_error_handler();
          }
          return $filecontents;
      }
    Thread Starter leoventans

    (@leoventans)

    Hi,

    It’s work now! Thank you so much!!

    You can update this part on next version.

    Hope you continue creating awesome plugin and thank you for your efforts, your plugin it’s amazing.

    Thanks again!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘2.2.18 garbled text’ is closed to new replies.