Coder Social home page Coder Social logo

safe_mode & open_basedir issue about apai-io HOT 12 CLOSED

exeu avatar exeu commented on May 23, 2024
safe_mode & open_basedir issue

from apai-io.

Comments (12)

Exeu avatar Exeu commented on May 23, 2024

You can instanciate the Rest-Request with some options as you can see here:

public function __construct(array $options = array())
    {
        $this->options = array(
            self::USERAGENT => "ApaiIO [" . ApaiIO::VERSION . "]",
            self::CONNECTION_TIMEOUT => 10,
            self::TIMEOUT => 10,
            self::FOLLOW_LOCATION => 1
        );
        $this->setOptions($options);
    }

So with this you are able to disable CURLOPT_FOLLOWLOCATION.

$x = new Rest\Request(array(Request::FOLLOW_LOCATION => 0));

Now you have to pass $x to the configuration object.

from apai-io.

Exeu avatar Exeu commented on May 23, 2024

so i think this issue is closed now?

from apai-io.

markhilton avatar markhilton commented on May 23, 2024

that fixed it for me

from apai-io.

Daijobou avatar Daijobou commented on May 23, 2024

Thank you! That help me too.

from apai-io.

enjoyjeremy-bc avatar enjoyjeremy-bc commented on May 23, 2024

Hi, sorry if this is an old thread but I'm having the same issue.

How do I pass $x into the configuration object? I tried adding it like this:

$x = new Rest\Request(array(Request::FOLLOW_LOCATION => 0));
$conf = new GenericConfiguration($x);
try {
    $conf
        ->setCountry('{omitted}')
        ->setAccessKey('{omitted}')
        ->setSecretKey('{omitted}')
        ->setAssociateTag('{omitted}');
} catch (\Exception $e) {
    echo $e->getMessage();
}
$apaiIO = new ApaiIO($conf);

When I add that line you mentioned, I get this error:

Fatal error: Class 'Rest\Request' not found in {omitted} on line 45

Thanks for the help!

from apai-io.

Exeu avatar Exeu commented on May 23, 2024

First follow the installation instructions: http://exeu.github.io/apai-io/installation.html

After you've done this try this:

$x = new \ApaiIO\Request\Rest\Request(array(\ApaiIO\Request\Rest\Request::FOLLOW_LOCATION => 0));
try {
    $conf
        ->setCountry('{omitted}')
        ->setAccessKey('{omitted}')
        ->setSecretKey('{omitted}')
        ->setAssociateTag('{omitted}')
       ->setRequest($x);
} catch (\Exception $e) {
    echo $e->getMessage();
}
$apaiIO = new ApaiIO($conf);

from apai-io.

enjoyjeremy-bc avatar enjoyjeremy-bc commented on May 23, 2024

That worked! Thanks!

from apai-io.

flowdee avatar flowdee commented on May 23, 2024

I've got a client with the same problem. In my case I already added the FOLLOW_LOCATION 0:

$conf = new GenericConfiguration();

$x = new \ApaiIO\Request\Rest\Request(array(\ApaiIO\Request\Rest\Request::FOLLOW_LOCATION => 0));

try {
    $conf
        ->setCountry($country)
        ->setAccessKey($aws_api_key)
        ->setSecretKey($aws_api_secret_key)
        ->setAssociateTag($aws_associate_tag)
        //->setRequest('\ApaiIO\Request\Rest\Request')
        //->setResponseTransformer('\ApaiIO\ResponseTransformer\XmlToDomDocument');
        //->setRequest('\ApaiIO\Request\Soap\Request')
        //->setResponseTransformer('\ApaiIO\ResponseTransformer\ObjectToArray');
        ->setRequest($x);
} catch (\Exception $e) {
    echo $e->getMessage();
}

$amazon = new ApaiIO($conf);

but nethertheless his shared hosting returns the error:

PHP Warning: curl_setopt(): CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set in /var/www/vhosts/.../libs/apai-io/exeu/apai-io/lib/ApaiIO/Request/Rest/Request.php on line 146

I followed the installation steps and my configuration is attached above. Any idea what it could be @Exeu ?

from apai-io.

flowdee avatar flowdee commented on May 23, 2024

In addition to my previous post, I tested a little bit around and found something interesting:

public function __construct(array $options = array())
{
    $this->options = array(
        self::USERAGENT          => "ApaiIO [" . ApaiIO::VERSION . "]",
        self::CONNECTION_TIMEOUT => 10,
        self::TIMEOUT            => 10,
        self::FOLLOW_LOCATION    => 0
    );
    $this->setOptions($options);
}

After setting the FOLLOW_LOCATION to 0 inside the constructor, the problem disappeared. Shouldn't be this setting be overwritten by the following line?

$x = new \ApaiIO\Request\Rest\Request(array(\ApaiIO\Request\Rest\Request::FOLLOW_LOCATION => 0));

from apai-io.

Exeu avatar Exeu commented on May 23, 2024

Yes it will ;) see setOptions function.

from apai-io.

flowdee avatar flowdee commented on May 23, 2024

Yeah but why does the error still occur? As I wrote CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set only disappears when I edit the Rest/Request.php constructor manually.

from apai-io.

Exeu avatar Exeu commented on May 23, 2024

Go ahead and grab a debugger. Step into it and investigate what is happening there in your case.
More i cannot do for you.

from apai-io.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.