Problems with CURL - need a bit of help

software development


I have been trying to run a script that pulls in some advertising links. Originally I was given a script to use that was like this:

<?php if($_SERVER['REQUEST_URI']=="/") { $page=$_SERVER['PHP_SELF']; } else { $page = $_SERVER['REQUEST_URI']; } $lnkvar = file_get_contents("".$page); echo $lnkvar; ?>

But Dreamhost security stops that from working, so it’s been changed to this:

<?php if($_SERVER['REQUEST_URI']=="/") { $page=$_SERVER['PHP_SELF']; } else { $page = $_SERVER['REQUEST_URI']; } $site_url = '' . $page; $ch = curl_init(); $timeout = 5; // set to zero for no timeout curl_setopt ($ch, CURLOPT_URL, $site_url); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); ob_start(); curl_exec($ch); curl_close($ch); $file_contents = ob_get_contents(); ob_end_clean(); echo $file_contents; ?>

[based on advice given here:]

The problem is it just isn’t working for me - it’s trying to pull in the file and partly works but errors:

Warning: eregi() [function.eregi]: REG_EMPTY in /usr/home/cyl0n/domains/ on line 33
Yahoo Google Quality Virtual Servers

You can see it on this page:

So, the question is:

Is the problem with the CURL script that I have on my page, or is there a problem with the page that I’m trying to pull in?

I think it’s the latter, but I’m unfamiliar with CURL, so I don’t want to go pointing the finger at them just yet :slight_smile:

Would appreciate any comments that enlighten me!


The problem is with the multi_links.php page.

On a side note, I’m not sure why output buffering would be needed. The curl option returntransfer should be set to true, which returns the results as a string, meaning that there will be no output until it is echoed so there should be no reason to use the output buffer.

Read my blog. You know you want to…