471,071 Members | 1,355 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,071 software developers and data experts.

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_user_id, $p_file_path) {
$id = getId($p_file_path);

exec("wget -b ".
str_replace($_SERVER['DOCUMENT_ROOT'], "http://" .
$_SERVER['SERVER_NAME'], dirname(__FILE__) . "/filemanager/
process_file.php?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
Aug 19 '08 #1
2 1037
la***********@zipmail.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_user_id, $p_file_path) {
$id = getId($p_file_path);

exec("wget -b ".
str_replace($_SERVER['DOCUMENT_ROOT'], "http://" .
$_SERVER['SERVER_NAME'], dirname(__FILE__) . "/filemanager/
process_file.php?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.
js*******@attglobal.net
==================

Aug 20 '08 #2
On 19 Aug, 21:38, "laredotorn...@zipmail.com"
<laredotorn...@zipmail.comwrote:
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_user_id, $p_file_path) {
$id = getId($p_file_path);

exec("wget -b ".
str_replace($_SERVER['DOCUMENT_ROOT'], "http://" .
$_SERVER['SERVER_NAME'], dirname(__FILE__) . "/filemanager/
process_file.php?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_get_contents(str_replace($_SERVER['DOCUMENT_ROOT'],
"http://" .
$_SERVER['SERVER_NAME'], dirname(__FILE__) . "/filemanager/
process_file.php?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.php");
ob_end_clean(); // or fetch the buffer and parse it to see if it
worked

C.
Aug 20 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Brian Burgess | last post: by
3 posts views Thread by Michael Yanowitz | last post: by
17 posts views Thread by =?Utf-8?B?SmltIFJvZGdlcnM=?= | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.