URL file-access is disabled , how can i fix?

software development

#1

hi, i know that URL file-access is disabled in the server configuration of dreamhost, so the thing is that, as i have already read in this forum, i should change to “CURL” or something like that… the thing is that i dont know anything about programming…

could someone help me?:


<?php /** * @version $Id: mod_jvtempo.php 2007-04-28 22:22:22Z Lisboa $ * @package Joomla * @copyright Copyright (C) 2006 Joao vieira. All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * Joomla! is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See COPYRIGHT.php for copyright notices and details. */ // no direct access defined( '_VALID_MOS' ) or die( 'Restricted access' ); global $mosConfig_offset, $mosConfig_cachepath; $cidades = $params->def( 'cidades' ); $graus = $params->def( 'graus' ); $font_header = $params->def( 'font_header' ); function converte_data($strdata) { $strdata_partir = explode(" ", $strdata); $strdata = str_replace(":", "", $strdata_partir[1]); $strdata_partir = explode("/", $strdata_partir[0]); $strdata = $strdata_partir[0] . $strdata_partir[1] . $strdata_partir[2] . $strdata; return $strdata; } function apanha_tempo($accid, $graus, $mosConfig_cachepath) { //puxa dados em cache, caso existam if ( !file_exists( $mosConfig_cachepath . '/jvtempo.txt') ) { $ficha = fopen($mosConfig_cachepath . '/jvtempo.txt', "w"); $dcache[$accid]['LastUp'] = ""; $dcache[$accid]['Temp'] = ""; $dcache[$accid]['CIcon'] = ""; fputs($ficha, serialize($dcache)); fclose($ficha); }else { $ficha = fopen($mosConfig_cachepath . '/jvtempo.txt', "r"); $dcache = unserialize(fgets($ficha, 1000)); fclose($ficha); } $cidade = explode("=", $accid); $accid = $cidade[0]; $url ="http://weather.msn.com/local.aspx?wealocations=wc:$accid"; $ConteudoRemoto = file_get_contents($url); $posx = explode('', $ConteudoRemoto); $posx = explode(',', $posx[1]); $xcity = trim(strip_tags($posx[0])); $posx = strpos($ConteudoRemoto, '
', $ConteudoRemoto[1]); $ConteudoRemoto = explode('°', $ConteudoRemoto[1]); $xtemperature = trim(strip_tags($ConteudoRemoto[0])); $xdate = date("Y/m/d H:00:00"); $MsnWeather['City'] = $xcity; $MsnWeather['LastUp'] = $xdate; $MsnWeather['Temp'] = $xtemperature; $MsnWeather['CIcon'] = $xicon; if (count($cidade)>1) $MsnWeather['City'] = $cidade[1]; //verifica se os dados que estão em cache são mais actuais ou não $alterou = false; if ( converte_data($MsnWeather['LastUp']) > converte_data($dcache[$accid]['LastUp']) ) { $dcache[$accid]['LastUp'] = $MsnWeather['LastUp']; if ($MsnWeather['Temp']) $dcache[$accid]['Temp'] = $MsnWeather['Temp']; if ($MsnWeather['CIcon']) $dcache[$accid]['CIcon'] = $MsnWeather['CIcon']; $alterou = true; }else { $MsnWeather['LastUp'] = $dcache[$accid]['LastUp']; $MsnWeather['Temp'] = $dcache[$accid]['Temp']; $MsnWeather['CIcon'] = $dcache[$accid]['CIcon']; } if ( $alterou && file_exists( $mosConfig_cachepath . '/jvtempo.txt') ) { $ficha = fopen($mosConfig_cachepath . '/jvtempo.txt', "w"); fputs($ficha, serialize($dcache)); fclose($ficha); } //faz calculos de temperatura if ( !($MsnWeather['Temp']) ) { $temperatura = "-"; $MsnWeather['CIcon'] = "44"; } elseif ($graus == 'c') { $temperatura = $MsnWeather['Temp']; $temperatura = $temperatura-32; $temperatura = $temperatura/9; $temperatura = $temperatura*5; $temperatura = round($temperatura, 0); } elseif ($graus == 'f') { $temperatura = $MsnWeather['Temp']; } if (!$MsnWeather['CIcon']) $MsnWeather['CIcon'] = "44"; $varlocal = ""; $varlocal .= "".$MsnWeather['City']." ".$temperatura."°".strtoupper($graus)." "; return $varlocal; } $cidades = explode(",", $cidades); $content .=""; for($i=0; $i<count($cidades); $i++) { $content .="<tr><td>"; $content .= apanha_tempo($cidades[$i],$graus, $mosConfig_cachepath); $content .="</td></tr>"; } $content .= "
"; ?>

#2

MORE INFO: The code is from a Joomla Module, that loads temperature from http://weather.msn.com/

The module is called jvtempo


#3

ERROR
Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /home/.snapple/xiondesigns/xiondesigns.com.ar/clientes/diario/modules/mod_jvtempo.php on line 52

Warning: file_get_contents(http://weather.msn.com/local.aspx?wealocations=wc:ARBA0009) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /home/.snapple/xiondesigns/xiondesigns.com.ar/clientes/diario/modules/mod_jvtempo.php on line 52


#4

The correct way to deal with this situation is to re-write the code to use cURL.

http://wiki.dreamhost.com/Allow_url_fopen
http://wiki.dreamhost.com/CURL

–rlparker
–DreamHost Tech Support


#5

Yea, but i dont know how…

i was expecting if someone could help me.

Bye :wink: