Better way to execute this call?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • laredotornado@zipmail.com

    Better way to execute this call?

    Hi,

    I'm using PHP 5. I'm wondering if there is a way to optimize the
    below. Specifically, I'm making a call in the background to wget, but
    I'm retrieving a page from my own server ...


    function saveFile($p_use r_id, $p_file_path) {
    $id = getId($p_file_p ath);

    exec("wget -b ".
    str_replace($_S ERVER['DOCUMENT_ROOT'], "http://" .
    $_SERVER['SERVER_NAME'], dirname(__FILE_ _) . "/filemanager/
    process_file.ph p?file_id=$id") );

    return $id;
    } // saveFile

    This seems wasteful. Is there a way to execute the equivalent of this
    call without going out on the web?

    Thanks, - Dave
  • Jerry Stuckle

    #2
    Re: Better way to execute this call?

    laredotornado@z ipmail.com wrote:
    Hi,
    >
    I'm using PHP 5. I'm wondering if there is a way to optimize the
    below. Specifically, I'm making a call in the background to wget, but
    I'm retrieving a page from my own server ...
    >
    >
    function saveFile($p_use r_id, $p_file_path) {
    $id = getId($p_file_p ath);
    >
    exec("wget -b ".
    str_replace($_S ERVER['DOCUMENT_ROOT'], "http://" .
    $_SERVER['SERVER_NAME'], dirname(__FILE_ _) . "/filemanager/
    process_file.ph p?file_id=$id") );
    >
    return $id;
    } // saveFile
    >
    This seems wasteful. Is there a way to execute the equivalent of this
    call without going out on the web?
    >
    Thanks, - Dave
    >
    The first question I have is - what exactly are you trying to accomplish?

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • C. (http://symcbean.blogspot.com/)

      #3
      Re: Better way to execute this call?

      On 19 Aug, 21:38, "laredotorn...@ zipmail.com"
      <laredotorn...@ zipmail.comwrot e:
      Hi,
      >
      I'm using PHP 5. I'm wondering if there is a way to optimize the
      below. Specifically, I'm making a call in the background to wget, but
      I'm retrieving a page from my own server ...
      >
      function saveFile($p_use r_id, $p_file_path) {
      $id = getId($p_file_p ath);
      >
      exec("wget -b ".
      str_replace($_S ERVER['DOCUMENT_ROOT'], "http://" .
      $_SERVER['SERVER_NAME'], dirname(__FILE_ _) . "/filemanager/
      process_file.ph p?file_id=$id") );
      >
      return $id;
      } // saveFile
      >
      This seems wasteful. Is there a way to execute the equivalent of this
      call without going out on the web?
      >
      Thanks, - Dave
      firstly, using the file wrappers or curl would avoid the overhead of
      starting a new process:
      $result=file_ge t_contents(str_ replace($_SERVE R['DOCUMENT_ROOT'],
      "http://" .
      $_SERVER['SERVER_NAME'], dirname(__FILE_ _) . "/filemanager/
      process_file.ph p?file_id=$id") );

      But there's no need to make a local HTTP request - just do:

      ob_start();
      $_GET['file_id']=$id;
      include("./filemanager/process_file.ph p");
      ob_end_clean(); // or fetch the buffer and parse it to see if it
      worked

      C.

      Comment

      Working...