Unstoppable Domains

CURL alternative to fopen

Spacemail by SpaceshipSpacemail by Spaceship
Watch

Momo

VIP Member
Impact
72
I'm installing a script which uses the fopen function, but my host Dreamhost has disabled this feature for security reasons. The suggested alternative was to use CURL, but I'm clueless as to what should I replace the code with.

Here is the part of the code which uses the said function:

Code:
$file = fopen($filename, "r");
        if (!$file) 
        {
            echo "<p>Unable to open remote file $filename.\n";
        }
        else
        {
            while (!feof($file))
            {
                $var = fgets($file, 1024);
                if(eregi("<font color=#008000>(.*)</font><nobr>",$var,$out))
                {
                    $out[1] = strtolower(strip_tags($out[1]));

$s1=str_replace("http://","",$out[1]);  
$ur1=str_replace("www.","",$s1);
$s=strpos($ur1," ");
if ($s > 3)$ur1=substr($ur1,0,$s);
$s=strpos($ur1,"/");
if ($s > 3)$ur1=substr($ur1,0,$s);
$ur1=str_replace("/","",$ur1);

                    $position++;
           
                   if($ur==$ur1)
                    {
                        $found = $position;          
                        break;
                    } 
                }
            }
        }
        fclose($file);    
    }

Could anybody guide me as to how to replace the fopen, fgets, etc functions with the CURL alternatives? Thanks a lot!
 
1
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
.US domains.US domains
Something like:
PHP:
$url = 'http://www.someurl.com/';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$var = curl_exec($ch);

if(eregi("<font color=#008000>(.*)</font><nobr>", $var, $out))
{
  $out[1] = strtolower(strip_tags($out[1]));
  $s1 = str_replace("http://", "", $out[1]);
  $ur1 = str_replace("www.", "", $s1);
  $s = strpos($ur1, " ");

  if($s > 3)
  {
    $ur1=substr($ur1, 0, $s);
  }
  $s = strpos($ur1, "/");

  if($s > 3)
  {
    $ur1 = substr($ur1, 0, $s);
  }
  $ur1 = str_replace("/", "", $ur1);
  $position++;

  if($ur == $ur1)
  {
    $found = $position;
    break;
  }
}
//Once done with everything...
curl_close($ch);
 
1
•••
Thank you SecondVersion, the code your posted worked well for me! :D Thanks again!
 
0
•••
No problem :)
 
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99
Appraise.net

We're social

Unstoppable Domains
Domain Recover
NameMaxi - Your Domain Has Buyers
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back