Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of the internal API in a different domain on the same Server #483

Closed
Jako opened this issue Dec 28, 2008 · 9 comments
Closed

Use of the internal API in a different domain on the same Server #483

Jako opened this issue Dec 28, 2008 · 9 comments
Labels
Bug For errors / faults / flaws / inconsistencies etc. Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical.
Milestone

Comments

@Jako
Copy link

Jako commented Dec 28, 2008

I’ve got a warning message if I use the API from a different domain on the same server.

Warning: Invalid argument supplied for foreach() in /users/XXXXXXX/data/websites/myDomain/plugins/LanguagesManager/API.php on line 34

The Piwik installation is located on ‘/users/XXXXXXX/data/websites/myDomain’ on the server and I call the Piwik API from a different domain (roor: ‘/users/XXXXXXX/data/websites/mySecondDomain’) on the same server with the Internal PHP calling example in the wiki.

After the warning messages the result of the API is displayed correctly.

I think the line 32 in /plugins/LanguagesManager/API.php

```
$languages = glob( “lang/*”);
```

points to a wrong folder if the API-call is not executed in the piwik Folder.
Keywords: api,warning,internal

@Jako
Copy link
Author

Jako commented Dec 31, 2008

Seems not to work.

```
$olddir: ‘/users/XXXXXXX/data/websites/MyDomain’
$SERVER[’SCRIPTFILENAME’]: ‘/users/XXXXXXX/data/websites/myDomain/testing.php’
```

In testing.php piwik is executed by including (see the example in the wiki):

```
define(‘PIWIK_INCLUDE_PATH’, ‘/users/XXXXXXX/data/websites/MyPiwikDomain’);
define(‘ENABLE_DISPATCH’, false);
require_once PIWIK_INCLUDE_PATH . “/index.php”;
require_once PIWIK_INCLUDE_PATH . “/core/API/Request.php”;
```

@Jako
Copy link
Author

Jako commented Dec 31, 2008

Maybe something like this:

```
$olddir = getcwd();
if (defined (‘PIWIK_INCLUDE_PATH’))
chdir(PIWIK_INCLUDE_PATH);
$languages = glob( “lang/*”);
chdir( $olddir );
```

@robocoder
Copy link
Contributor

Here’s a simpler patch.

@robocoder
Copy link
Contributor

Attachment:
[483.patch](http://issues.piwik.org/attachments/483/483.patch)

@mattab
Copy link
Member

mattab commented Jan 14, 2009

vipsoft and Jako, did you test the patch with the use case? Please confirm before commit. Thanks

@robocoder
Copy link
Contributor

I didn’t hear back from Jako, but I tested the patch (in the attachment).

@robocoder
Copy link
Contributor

Attachment: Modified example from wiki.
[testing.php](http://issues.piwik.org/attachments/483/testing.php)

@mattab
Copy link
Member

mattab commented Jan 14, 2009

thanks for patch Anthon. Fixed in 877(just slight style changes)

@Jako
Copy link
Author

Jako commented Jan 14, 2009

Sorry for answering late. The patch works for me. Thanks!

@Jako Jako added this to the RobotRock milestone Jul 8, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical.
Projects
None yet
Development

No branches or pull requests

3 participants