473,396 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 1111
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tim Williams | last post by:
I'm trying to write a simple python program to access a MySQL database. I'm having a problem with using MySQLdb to get the results of a SQL command in a cursor. Sometimes the cursor.execute works,...
7
by: Brian Burgess | last post by:
Hi all, Anyone know of any special issues with Server.Execute? Specifically for me it simply is not executing ... the server does not transfer to the page specified. The calling ASP just...
3
by: Chris | last post by:
I have yet to understand or get a response on the issue I'm having. I'm taking an asp web application and migrating it from Windows 2K to 2003. I have the new website location (2003) settings...
5
by: Gustavo Randich | last post by:
Hello, I'm writing an automatic SQL parser and translator from Informix to DB2. Now I'm faced with one of the most difficult things to translate, the "foreach execute procedure" functionality...
3
by: serge | last post by:
How do I determine which method I should use if I want to optimize the performance of a database. I took Northwind's database to run my example. My query is I want to retrieve the Employees'...
3
by: Michael Yanowitz | last post by:
Hello: I wrote the code below (much irrelevant code removed). This doesn't quite work. What I wanted it to do was a) Execute function ftimed, which takes a function and a timeout in seconds....
17
by: =?Utf-8?B?SmltIFJvZGdlcnM=?= | last post by:
I am trying to replace a huge chunck of code that currently I incorporate with an #Include directive. The program rarely has to flow through that code, so I thought it would be better if I used...
7
by: raylopez99 | last post by:
I find that I am using bool variables a lot when I code in Forms. I know how to overload event handlers, and that's great for offloading code from the 'base' event handler and/or creating helper...
1
by: mikegolden | last post by:
An application I'm working on makes extensive use of output parameters and return values, thus forcing me to use the ADODB Command object to execute the stored procs. For recordset returning stored...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.