Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4587946
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:51:10+00:00 2026-05-21T21:51:10+00:00

My hosting company has disabled allow_url_fopen & allow_url_include. They recommend that I use cURL

  • 0

My hosting company has disabled allow_url_fopen & allow_url_include. They recommend that I use cURL instead, then I saw this patch on simplexml

$calendar = simplexml_load_file($source); with
if (ini_get('allow_url_fopen')) {
$calendar =       simplexml_load_file($source); 
}   
else {    
$ch = curl_init($source);    
curl_setopt  ($ch, CURLOPT_HEADER, false); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);    
$xml_raw = curl_exec($ch);    
$calendar = simplexml_load_string($xml_raw);  }

and it works on my hosting so I was wondering if I could use it on simplehtmldom here is the code I am using

<?php
include('simple_html_dom.php');
include ('phpQuery.php');   
// Create DOM from URL
$html = file_get_html('http://www.urlhere.com/');
   ?>

Can i use this? If yes what changes should I make, thank you for your help

Edited above code

<?php
include('simple_html_dom.php'); 
include ('phpQuery.php'); 

if (ini_get('allow_url_fopen')) {       
$html = file_get_html('http://www.weather.bm/'); }
else{       $ch = curl_init('http://www.weather.bm/');           
curl_setopt  ($ch, CURLOPT_HEADER, false);        
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);           
$src = curl_exec($ch);           
$html = str_get_html($src, false); 
var_dump($html);  }   

?>

<div id="leftwrapper">
<div id="CurrentConditions">
<h2>Current Conditions</h2>

<div id="current-content">
<div id="elementleft">
<?php
foreach($html->find('div.obElementLeft') as $e)
echo $e->outertext;
?>
</div>
<div id="elementright"><?php 
foreach($html->find('div.obElementRight') as $e)
echo $e->outertext; 
?>
</div></div></div>
<div id="rightwrapper"> 
<div id="TodayForecast">
<h2>24-Hour Forecast</h2>
<?php 
foreach($html->find('.TodaysForecastContainer') as $e)
$doc = phpQuery::newDocumentHTML( $e );  
$containers = pq('.TodaysForecastContainerInner', $doc); 
foreach( $containers as $container ) {     
$div = pq('div', $container);      
$div->eq(1)->removeAttr('style')->addClass('thumbnail')->
html( pq( 'img', $div->eq(1))->removeAttr('height')->
removeAttr('width')->removeAttr('alt') ); 
$div->eq(0)->removeAttr('style')->addClass('day')-> 
html( pq( 'u', $div->eq(0) )->html() );           
$div->eq(2)->removeAttr('style')->addClass('description');   }  
print $doc; 
?>

</div><!--end of todayforecast--> 
<div id="bws-foot">Weather data provided in part by the Bermuda Weather
Service</div>     <img id="bws-logo" src="images/bwslogo.jpg" />
<div id="hilo">
<p>Today's Temperature:</p>
<?php
foreach($html->find('div.HiLoContainer') as $e)
$doc = phpQuery::newDocumentHTML( $e );  
$containers = pq('div.HiLoContainer', $doc); 
foreach( $containers as $container ) {     $div = pq('div', $container);        
$div->eq(0)->removeAttr('style')->addClass('hi1');  
$div->eq(1)->removeAttr('style')->addClass('lo1'); 
}  print $doc; 
?>

Outlook

find(‘.SynopsisContainer span’) as $e)
echo $e->innertext . ‘
‘;
?>

4 Day Weather Forecast

foreach($html->find(‘.FourDayForecastContainer’) as $e)

$doc = phpQuery::newDocumentHTML( $e );
$containers = pq (‘.FourDayForecastContainerInner’, $doc);
foreach( $containers as $container ) { $div = pq(‘span’, $container);
$img = pq(‘img’, $container);
$div->eq(0)->removeAttr(‘style’)->addClass(‘day’)->
html( pq( ‘u’, $div->eq(0) )->html() );

$img->eq(0)->removeAttr(‘style’)->removeAttr(‘height’)->
removeAttr(‘width’)->removeAttr(‘alt’)->addClass(‘thumbnail’)->
html( pq( ‘img’, $img->eq(0)) );$imghtml = pq(‘a’, $container)->
html(); pq($container)->prepend($imghtml); pq(‘a’, $container)->remove();
$div->eq(1)->removeAttr(‘style’)->addClass(‘hi’);
$div->eq(3)->removeAttr(‘style’)->addClass(‘lo’);
$div->eq(5)->removeAttr(‘style’)->addClass(‘description’); } print $doc;
?>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T21:51:11+00:00Added an answer on May 21, 2026 at 9:51 pm

    You’d need to edit the simple_html_dom source. Its easier to just create your own function that does what the original does. The original (which you can’t use because of allow_url_fopen) is:

    function file_get_html() {
        $dom = new simple_html_dom;
        $args = func_get_args();
        @$dom->load(call_user_func_array('file_get_contents', $args), true);
        if (($error=error_get_last())!==null)
        throw new Exception($error['message']);
        return $dom;
    }
    

    You can just do this:

    if (ini_get('allow_url_fopen')) {
          $html = file_get_html('http://www.urlhere.com/');
    }else{
          $ch = curl_init('http://www.urlhere.com/');    
          curl_setopt  ($ch, CURLOPT_HEADER, false); 
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);    
          $src = curl_exec($ch);    
          $html = str_get_html($src, false);
    }
    

    No need to modify the source, and effectively does the same thing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web-site that has a hosting at some popular hosting company. The
OK, So my hosting company has suspended my account for the 4th damn time.
I have some PHP source code that I'm hosting with hosting company XYZ. I'm
My hosting company is now saying that their (8)Exec format error: exec of '/home/
I'm trying to run a python script using python 2.6.4. The hosting company has
The hosting company that my employer uses upgraded to Exchange 2010 over the weekend.
My hosting company recently upgraded me from Apache 1 to Apache 2, and I've
I'm considering using a third party hosting company to house an SVN repository. (I'm
any recommendation on which company providing scalable bosh hosting? p/s: is there exist any
We at the company want to convert all the sites we are hosting from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.