1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Need a little help, please anyone??

Discussion in 'Programming' started by adviceforall, Sep 25, 2007.

  1. #1
    Hi all I have a script that gives me this error:

    Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in /home/*******/public_html/modules/import.php on line 531

    Any ideas where I have gone wrong how what this means or how to fix it please??

    Help much appreciated you will be repped :)

    Thanks

    Rick
     
    adviceforall, Sep 25, 2007 IP
  2. meetgs

    meetgs Active Member

    Messages:
    957
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    70
    #2
    your PHP configuration file prohibits such option to be enabled (because of the security risk).

    from this page:
    http://php.net/manual/en/function.curl-setopt.php
    eion at bigfoot dot com gave us an alternative. here it is:

      function curl_redir_exec($ch)
        {
            static $curl_loops = 0;
            static $curl_max_loops = 20;
            if ($curl_loops++ >= $curl_max_loops)
            {
                $curl_loops = 0;
                return FALSE;
            }
            curl_setopt($ch, CURLOPT_HEADER, true);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $data = curl_exec($ch);
            list($header, $data) = explode("\n\n", $data, 2);
            $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
            if ($http_code == 301 || $http_code == 302)
            {
                $matches = array();
                preg_match('/Location:(.*?)\n/', $header, $matches);
                $url = @parse_url(trim(array_pop($matches)));
                if (!$url)
                {
                    //couldn't process the url to redirect to
                    $curl_loops = 0;
                    return $data;
                }
                $last_url = parse_url(curl_getinfo($ch, CURLINFO_EFFECTIVE_URL));
                if (!$url['scheme'])
                    $url['scheme'] = $last_url['scheme'];
                if (!$url['host'])
                    $url['host'] = $last_url['host'];
                if (!$url['path'])
                    $url['path'] = $last_url['path'];
                $new_url = $url['scheme'] . '://' . $url['host'] . $url['path'] . ($url['query']?'?'.$url['query']:'');
                curl_setopt($ch, CURLOPT_URL, $new_url);
                debug('Redirecting to', $new_url);
                return curl_redir_exec($ch);
            } else {
                $curl_loops=0;
                return $data;
            }
        }
    PHP:
     
    meetgs, Sep 25, 2007 IP
    adviceforall likes this.
  3. adviceforall

    adviceforall Banned

    Messages:
    1,608
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you rep added much appreciated :)
     
    adviceforall, Sep 27, 2007 IP