Hi Guys, Not sure why I get the following error on my page. Your advise is greatly appreciated: "Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in /home/tlimgh/public_html/starthomebusiness/inc/rss.inc on line 112" My web site: http://www.starthomebusiness.info/ What safe_mode on my server settings is this? What can I do to resolve this. My rss.inc code is as follows: <?php include("inc/ads-top.inc"); ?> <?php echo '<p><b><h1>Home Business News</h1></b></p>'; $nr_news=3; $rssfile=$_SERVER["DOCUMENT_ROOT"]."/rsslist.txt"; $rssurls=file($rssfile); $rand=rand(1,count($rssurls))-1; $file = $rssurls[$rand]; $rss_channel = array(); $currently_writing = ""; $main = ""; $item_counter = 0; function startElement($parser, $name, $attrs) { global $rss_channel, $currently_writing, $main; switch($name) { case "RSS": case "RDF:RDF": case "ITEMS": $currently_writing = ""; break; case "CHANNEL": $main = "CHANNEL"; break; case "IMAGE": $main = "IMAGE"; $rss_channel["IMAGE"] = array(); break; case "ITEM": $main = "ITEMS"; break; default: $currently_writing = $name; break; } } function endElement($parser, $name) { global $rss_channel, $currently_writing, $item_counter; $currently_writing = ""; if ($name == "ITEM") { $item_counter++; } } function characterData($parser, $data) { global $rss_channel, $currently_writing, $main, $item_counter; if ($currently_writing != "") { switch($main) { case "ITEMS": if (isset($rss_channel[$main][$item_counter][$currently_writing])) { $rss_channel[$main][$item_counter][$currently_writing] .= $data; } else { //print ("rss_channel[$main][$item_counter][$currently_writing] = $data<br>"); $rss_channel[$main][$item_counter][$currently_writing] = $data; } break; } } } $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, "startElement", "endElement"); xml_set_character_data_handler($xml_parser, "characterData"); /* if (!($fp = fopen($file, "r"))) { die("could not open XML input"); } /* while ($data = fread($fp, 4096)) { if (!xml_parse($xml_parser, $data, feof($fp))) { die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser))); } } */ $data=curl_string($file); xml_parse($xml_parser,$data); xml_parser_free($xml_parser); // putting in array $news=array(); if (isset($rss_channel["ITEMS"])) { if (count($rss_channel["ITEMS"]) > 0) for($i = 0;$i < count($rss_channel["ITEMS"]);$i++) $news[]=$rss_channel["ITEMS"][$i]; } $c=0; foreach($news as $key=>$val) { if($c<$nr_news) { echo "<p align=left>"; echo '<a href="'.$val['LINK'].'">'.$val['TITLE'].'</a> - '.$val['PUBDATE'].'<br>'.''.$val['DESCRIPTION'].'</font></p>'; } $c++; } function curl_string ($url,$user_agent='Mozilla 4.0'){ $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ch, CURLOPT_TIMEOUT, 120); $result = curl_exec ($ch); curl_close($ch); return $result; } ?>
Hello, Run a phpinfo(); and check what safemode is. It is an ini setting in which you can perform a ini_set. This should work: ini_set ( 'safemode', false ); Code (markup): ini_set ( 'safemode', true ); Code (markup): Depending on which one safemode is set to, change the opposite.
WHOA! That is bad advice! Before you just turn off safe mode, I think you should investigate the ramifications of that. You may open yourself up to security issues. Now let's look at what's really happening. CURLOPT_FOLLOWLOCATION tells CURL when fetching a URL to follow redirect headers. If you are not hitting a page that is redirected, and why should it be to begin with?, a better option is to elimiate that setting being set to true. I think you should take a closer look at the implications of just turning off safe mode. Seriously!