cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

cURL very slow to fetch internal page

From: <lobos_at_webvida.com>
Date: Wed, 24 Nov 2004 14:37:11 +1300

Hi there,

I am using cURL to embedd an external php script into another php script, here is the code:

function gallery2_user_main()
{
 $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
 $url = eregi_replace("index.php([^>]+)","",$url);
  
 /*$wvURL = fopen($url.'modules/gallery2/main.php', "rb");
  while (!feof($wvURL)) {
      $readfile = $readfile . fread($wvURL, 1024);
   }
  fclose($wvURL);*/
  
 if (function_exists('curl_init')) {
  $ch = curl_init($url.'modules/gallery2/main.php');
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
        $readfile = curl_exec($ch);
        curl_close($ch);
 } else {
  $readfile = implode('', file($url.'modules/gallery2/main.php'));
 }
  
 $pat1 = "(modules/gallery2/main.php\?)";
 $pat2 = "(index.php\?module=gallery2&func=showimage&g2_view=core:DownloadItem)";
 $pat3 = "(Greetings,|Guest!|login)";
 
    $readfile = eregi_replace($pat1,"index.php?module=gallery2&func=showimage&",$readfile);
 $readfile = eregi_replace($pat2,"modules/gallery2/main.php?g2_view=core:DownloadItem",$readfile);
 $readfile = eregi_replace($pat3,"",$readfile);
 
 $output =& new pnHTML();
    $output->SetInputMode(_PNH_VERBATIMINPUT);
 if (pnSecAuthAction(0, '::', '::', ACCESS_ADMIN)) {
 $output->Text('Administration');
 }
 $output->Text('<div style="visibility:hidden;position:absolute;">themes</div>');
 $output->Text($readfile);
    return $output->GetOutput();
}

you can see it working at:

http://stopkillingchildren.com/index.php?module=gallery2

Now sometimes the page loads fast (1-2 seconds) and other times it loads slow (8-10 seconds)

should I be using cURL or should I use fread or fopen?

Thanks for your help.

Kindest regards
Adam
 
Received on 2004-11-24