File_get_contents

software development

#1

I’d like to get some data from some Bureau of Reclamation servers to plot with my data. The BOR IT guys have been helpful and showed me how to construct urls to access the data from their old flat files on a VMS system. I thought I could use the screen scraping technique show by Welling and Thompson in “PHP and MySQL Web Development” http://www.monkee.us/~tyler/ebook/EBook/067232525X.pdf page 359, but when I tried the book’s script on DH I got

Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /home/.edison/ykfpdata/ykfp.org/php/BOR/lookup.php on line 17

Does this mean file_get_contents is disabled on DHs PHP?

This signature line intentionally blank.


#2

By using the forum search correctly this time, I was able to find many solutions to this problem, particularly provided by Simon Jessy, 4/28/06 http://discussion.dreamhost.com/showthreaded.pl?Cat=&Board=forum_programming&Number=44775&page=&view=&sb=&o=&vc=1#Post44775

This signature line intentionally blank.


#3

Just in case it wasn’t clear in those articles, you can use file_get_contents() on DH servers–just not on a remote URL. It still works fine on your own local files if you ever have a need for it.


:stuck_out_tongue: Save up to $96 at Dreamhost with ALMOST97 promo code (I get $1).
Or save $97 with THEFULL97.


#4

Excuse publishes this post in a new subject, but I believe that it goes here

I want to install componete to eWeather, and can install all good, but when publishing it in my page Web it sends the following message to me:

under the file, and I look for line 1645 and I have the following code:

I have seen the information that published in Wiki DreamHost, in
following articles:
http://wiki.dreamhost.com/index.php/URL_file-
access_is_disabled_in_the_server_configuration
http://wiki.dreamhost.com/index.php/Allow_url_fopen
http://wiki.dreamhost.com/index.php/CURL

but I do not understand very well that to do in my page so that it
works

Can you help me?


#5

Change this:

if ($this->httpConnection != null) { $response =& $this->httpConnection->get($filename); $this->httpConnection->disconnect(); return $response->getResponse(); } else if (function_exists('file_get_contents')) { //if (file_exists($filename)) { return file_get_contents($filename); //} } else { require_once(DOMIT_INCLUDE_PATH . 'php_file_utilities.php'); $fileContents =& php_file_utilities::getDataFromFile($filename, 'r'); return $fileContents; }to this:

if ($this->httpConnection != null) { $response =& $this->httpConnection->get($filename); $this->httpConnection->disconnect(); return $response->getResponse(); } else if (file_exists($filename)) { $ch = curl_init(); $timeout = 5; curl_setopt ($ch, CURLOPT_URL, $filename); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $file_contents = curl_exec($ch); curl_close($ch); return $file_contents; } else { require_once(DOMIT_INCLUDE_PATH . 'php_file_utilities.php'); $fileContents =& php_file_utilities::getDataFromFile($filename, 'r'); return $fileContents; }

Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]


#6

Thanks for the answer, I put the code that you mentioned, I do not mark any error, but it even follows without appearing to me the information in my page Web.

to check:
www.misionquintanaroo.org

Some idea of because it does not work?


#7

I’m not sure how I can be of any more help. I don’t have a clue what the script is supposed to do - I just replaced the existing file functions with their cURL alternative.


Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]


#8

You will find the answer to how to modify eWeather for use on Dreamhost in this post from the Joomla! extensions site. Generally speaking, the Joomla! forums, and other sites Joomla! specific sites, will be your best best for Joomla! component related issues. :wink: . Good Luck!

–rlparker


#9

Thank you very much… The component works correctly…

Thank´s rlparker and scjessey


#10

You’re welcome, and I’m glad to hear you got it working properly! :slight_smile:

–rlparker


#11

I thought I’d run my script that inserts the BOR data into the MySQL table as a cron job, but it doesn’t insert any lines in the table when run as from a command line, only when I call it with a browser. I’ve made the script executable, and it takes some time to get back to the command prompt. But no data is inserted. Is it the curl calls that need a browser environment|?

This signature line intentionally blank.