By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,949 Members | 1,855 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,949 IT Pros & Developers. It's quick & easy.

Better way to execute this call?

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.