0

If someone doesn't feel like reading the whole explanation, you can skip to the last 2 paragraphs where I have the actual question

So I have this bunch of websites made with CakePHP. In one of the pages (this is the same for all the websites), I load an XML file and process its contents (using the XML helper). This has been working for quite some time. Now, suddenly, it doesn't work anymore in any of the websites (and the code hasn't changed a bit), it gives an "error opening file".

At the same time, another script of those websites (which has nothing to do with the previous one, it's plain PHP, outside the cakephp "area") has stopped working too. In this case, it's a scripts that creates a connection with a video hosting provider (Fliqz) and retrieves the URL of a video given a video id. Suddently, it throws an error something like "session was not created" (the script creates some sort of session with Fliqz' server to get the URL).

All this sounds very weird, I know. The first thing I've done, after checking that the code is correct, is call 1&1 (the hosting provider) and ask if they have made any change in the server. They said that they changed to PHP5 a few months ago (which I was aware of, and everything was working fine after that change), but that they haven't changed anything else.

My question would be, is there anything I can do to figure out what is causing these problems? For example, I found some post of someone saying that his hosting had restricted some functionality that allowed external connections. Or in another post I saw a suggestion about doing this: echo file_get_contents("http://google.com/") and I got an error, meaning that some setting wasn't right. I even tried to use simplexml_load_file (instead of the XMl helper) in the page where I load the XML file and didn't work, giving another error...

I would like to know, if a PHP setting is causing this, which one could it be, so I can look at it and call again 1&1 to tell them what they need to change (if there's anything to change). Otherwise, how in the world can something just stop working?

Thank you for any advice! It is much appreciated!

EDIT: detailed explanation of errors

1. Error related to the XML not loading using CakePHP's XML helper

This is the code I use (which used to worked perfectly):

$completeurl = '/full/path/to/file/myfile.xml';

App::import('Xml'); 

$xml =& new XML($completeurl);
$this->list = Set::reverse($xml);

I don't get any error or warning. If I debug $xml, I get this:

Xml Object
(
[__parser] => 
[__file] => 
[__rawData] => 
[__header] => 
[__tags] => Array
    (
    )

[version] => 1.0
[encoding] => UTF-8
[name] => #document
[namespace] => 
[namespaces] => Array
    (
    )

[value] => 
[attributes] => Array
    (
    )

[children] => Array
    (
    )

[__parent] => 
)

If I debug $this->list I get an empty array. Before this problem, I would get an associative array with all the information of the XML file, perfectly structured. Oh, and the XML file is the same it used to be, and I've revalidated it just in case giving no errors.

2. Error related to XML file not loading using simplexml_load_file()

This is the code I've tried with "regular" php (without using any CakePHP helper):

$file = '/full/path/to/file/myfile.xml';

if(!$xml = simplexml_load_file($file))
exit('Failed to open '.$file);

And this are the errors (warnings):

Warning (2): simplexml_load_file() [function.simplexml-load-file]: URL file-access is disabled in the server configuration [APP/plugins/icd_discovery/webroot/videos.php, line 29]

Warning (2): simplexml_load_file(http://discovery.ingles100.com/icd_discovery/xml/videos_unidades.xml) [function.simplexml-load-file]: failed to open stream: no suitable wrapper could be found [APP/plugins/icd_discovery/webroot/videos.php, line 29]

Warning (2): simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "http://discovery.ingles100.com/icd_discovery/xml/videos_unidades.xml" [APP/plugins/icd_discovery/webroot/videos.php, line 29]

If I put a relative path for the file, I just get the last warning, but still not loading it.

** 3. Error related to script to load URL of hosted videos in Fliqz**

The page that contains this script is totally unrelated to the previous ones (meaning that the code there doesn't affect the code here). We use the following script (provided by Fliqz) to request the URL of our videos hosted there:

include_once '../fliqz/dlMetrics.php';

// initializing new session

$videoID = '123123123';
$applicationID = '456456456';
$uniqueID = null;

// create a new fliqzDownload Object
$metricsObj  = new dlMetrics();

// get new session, using Application ID from Account:
$sessionID = $metricsObj->newSession($applicationID,NULL,NULL,NULL,$uniqueID);

// show server time when new session was created:
$start = $metricsObj->getSessionStart();

// Get asset location (note: must use dashes in asset ID example: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
$video_URL = $metricsObj->initLoad($videoID);

By doing this, we would get the URL of the video in the $video_URL variable. Again, this used to work perfectly. Suddenly, it doesn't.

So is it a coincidence that all this things stop working? I think that something has changed somewhere. Not the code, I'm the only one who touches that. The PHP version changed a while ago, and everything was working fine. Something in the server? 1&1 says that they didn't, or at least the person I talked to. If I have to call back, I would like to be able to point a little better where do I think the problem might be coming from, that's why I need you help guys!

Again, thanks for any advice!

4

1 回答 1

1

创建一个名为的文件php.ini,其内容如下:

allow_url_fopen = ON

并将其放置在与这些脚本相同的文件夹(或多个文件夹)中。

于 2012-08-04T03:38:56.230 回答