PHP file_get_contents error

software development

#1

Let me preface this by stating clearly and unequivicably that I am completely at a loss when it come to programing and/or modifying code. That being said I was wondering if someone would point me in the right direction.

I’m trying to setup a (not so basic) web presence for a house that my parents are selling and I’ve run in to a problem I’d rather solve then work around.

I’m storing the photo’s of the house on flicker and using Wordpress to display the information about the house. I’ve been trying to get the notes I’ve made on my photos in flicker to be represented on my web page. Currently I’m using http://webdev.yuan.cc/flickr/flickrnotes.php as outlined on this site , but I’d rather not leech off his resources. I’ve installed flickrnotes.php on my server here and made it executable. It appears to partially work but I think I need to change the external php call to cURL calls?

That assumption is based on
Forum post that seemed to apply
Dreamhost wiki on cURL

Here is the error I get when flickernotes.php runs.

[quote]Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /home/.cerebus/jfrey/3619Bobolink.com/flickrnotes/flickrnotes.php on line 40

Warning: file_get_contents(http://www.flickr.com/services/rest/?method=flickr.photos.getInfo&api_key=api_key&photo_id=2478433811) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /home/.cerebus/jfrey/3619Bobolink.com/flickrnotes/flickrnotes.php on line 40

Warning: DOMDocument::loadXML() [function.DOMDocument-loadXML]: Empty string supplied as input in /home/.cerebus/jfrey/3619Bobolink.com/flickrnotes/flickrnotes.php on line 48

Fatal error: Call to a member function getAttribute() on a non-object in /home/.cerebus/jfrey/3619Bobolink.com/flickrnotes/flickrnotes.php on line 64[/quote]
and here is flickernotes.php as I’m using it.

[quote]<?
/*
Copyright © 2007 CK (webdev@yuan.cc)

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

// **** Setup your variables
$cache_folder= “/3619Bobolink.com/wp-content/cache”;
$api_key = “my_api_key_removed”;
//

$photoid = $_GET[‘photoid’];
$nocache = $_GET[‘nocache’];

$url = “http://www.flickr.com/services/rest/?method=flickr.photos.getInfo&api_key=".$api_key."&photo_id=” . $photoid;

$cache_file = md5(urldecode($url));
$cache_path = $cache_folder."/$cache_file";

if( @file_exists("$cache_path") && @filesize("$cache_path") > 0 && $nocache!=“1” ) {
$handle = fopen($cache_path, “r”);
$output = fread($handle, filesize($cache_path));
fclose($handle);
$hit = “CACHE”;
} else {
$hit = “GET”;
$output = file_get_contents($url);
$fp = @fopen($cache_path,“w+”);
@fwrite($fp,$output);
@fclose($fp);
}

$dom = new DomDocument;
$dom->preserveWhiteSpace = FALSE;
$dom->loadXML($output);
$photonotes = $dom->getElementsByTagName(‘note’);

$i = 0;
foreach ($photonotes as $note) {
$notes[$i][‘id’] = $note -> getAttribute(‘id’);
$notes[$i][‘x’] = $note -> getAttribute(‘x’);
$notes[$i][‘y’] = $note -> getAttribute(‘y’);
$notes[$i][‘w’] = $note -> getAttribute(‘w’);
$notes[$i][‘h’] = $note -> getAttribute(‘h’);
$str = ereg_replace("’", “”, $note -> nodeValue);
$notes[$i][‘value’] = ereg_replace("\n", “
”, $str);
$i++;
}

$photos = $dom->getElementsByTagName(‘photo’);
$server = $photos->item(0)->getAttribute(‘server’);
$secret = $photos->item(0)->getAttribute(‘secret’);
$photourl = $dom->getElementsByTagName(‘url’)->item(0)->nodeValue;
$img = “http://static.flickr.com/$server/".$photoid."_".$secret.".jpg”;

header(‘Content-type: application/x-javascript’);

?>

var _style = ‘’;
_style += ‘#photo_notes {position:absolute;margin:0px;padding:0px;border:0px solid #cc0000; z-index:1000; visibility:visible;}’;
_style += ‘.photo_note {position:absolute; min-width:500px; margin:0px; padding:0px;}’;
_style += ‘.photo_note_box_div {position:absolute; border:0px solid #d4d82d;}’;
_style += ‘.photo_note_box_inner_div {border:1px solid black;}’;
_style += ‘.photo_note_box_inner_inner_div {border:1px solid white;}’;
_style += ‘.photo_note_text_div {display:none;overflow:auto; position:relative; padding:0px; border: 0px solid black;z-index:2000;padding:0px 0px 0px 0px;width:200px;}’;
_style += ‘.photo_note_text_table { display:table;margin:0px; padding:1px;background-color:#ffffd3;border: 1px solid black;}’;
_style += ‘’;

var _IE4=(document.all);
var _box = new Array();
var _notes = new Array();

<? for($j=0;$j<$i;$j++) { ?>

_box[_box.length] = ‘

<? echo $notes[$j]['value'];?>
’;
_notes[notes.length] = 'photo_note<? echo $notes[$j]['id']; ?>’; <? } ?>

var site = ‘

Powered by YuanCC Scriptlet
’;
var _imgdiv = ‘
’+site+’
’;

document.write(_style);
document.write(’

’);
document.write(’
’);
for(var i=0;i<_box.length;i++) document.write(_box[i]);
document.write(’
’);
document.write(_imgdiv);
document.write(’
’);
document.getElementById(‘photo_notes’).style.visibility = ‘hidden’;

for(var i=0;i<_notes.length;i++) {
_n = document.getElementById(_notes[i]);
_n.onmouseover = function() {
document.getElementById(‘photo_notes’).style.visibility = ‘visible’;
this.lastChild.style.display = ‘block’;
return true;
}
_n.onmouseout = function() {
if(!_IE4) this.lastChild.style.display = ‘none’;
}
if(_IE4) _n.lastChild.style.display = ‘block’;
}

function showNote(x) {
document.getElementById(‘photo_notes’).style.visibility = ‘visible’;
}
function hideNotes() {
document.getElementById(‘photo_notes’).style.visibility = ‘hidden’;
}
function showNoteBox() {
document.getElementById(‘photo_notes’).style.visibility = ‘visible’;
}
[/quote]


#2

Yes. When accessing an external file with fopen or file_get_contents you will need to use cURL instead.

si-blog
Max discount on any plan with promocode SCJESSEYTOTAL