php-general Digest 1 Jun 2009 02:54:13 -0000 Issue 6152

2009-05-31 Thread php-general-digest-help

php-general Digest 1 Jun 2009 02:54:13 - Issue 6152

Topics (messages 293399 through 293403):

spawning a process that uses pipes - doesn't terminate when webpage download is 
canceled
293399 by: flint
293402 by: bruce

Re: mysql_query takes long time...
293400 by: flint
293401 by: Phpster

Directing form to different handlers?
293403 by: Angus Mann

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---
sent this before, don't know if it went through... someone please reply if 
it went, even if they don't know answer?...


so here's the scenario..

I have a site that uses php with a database to offer sound files to
users using streaming methods.

the request page has options, allowing the user to modify the sound
file in various ways, before having it sent to them

Here's the problem:

The method i'm using to feed the data to the user is to run the source
file through various piped commands, with the resulting audio being
dumped to stdout, and then using passthru in php to get that data to
the enduser.

here's an example, for serving an MP3 with its pitch/speed changed by sox:

passthru(lame --quiet --decode \ . $in_file . \ - |  .
sox -V -S -t wav - -t wav - speed  . $speed_factor .  |  .
lame --quiet  . $lame_params .  - -);

This works just fine, except the problem is if the end user aborts the
transfer (e.g. stops playback in the media player, cancels download of
the mp3, whatever) then it leaves behind both the sox process and the
decoder LAMe process along with the sh that's running them. the only
process that exits is the final encoding lame process. If the sound
file runs to completion, everythign exits properly.

But this obviously means enough cancelling of downloads means the
server ends up with a huge batch of stuck processes! And I even tried
simply killing the 'host' sh process, and the lame and sox processes
remain anyway. The only way I've been able to deal with this is
manually killing the lame and sox processes directly.

is there any way I can make this work, such so that if the user
cancels the transfer, all relavent processes are killed rather than
just the single process that's feeding output into php?

-FM

---End Message---
---BeginMessage---
we answered this a number of times... 

was there something in the replies that didn't satisfy you?



-Original Message-
From: flint [mailto:fmill...@gmail.com]
Sent: Sunday, May 31, 2009 6:53 AM
To: PHP-General List
Subject: [PHP] spawning a process that uses pipes - doesn't terminate
when webpage download is canceled


sent this before, don't know if it went through... someone please reply if 
it went, even if they don't know answer?...

so here's the scenario..

I have a site that uses php with a database to offer sound files to
users using streaming methods.

the request page has options, allowing the user to modify the sound
file in various ways, before having it sent to them

Here's the problem:

The method i'm using to feed the data to the user is to run the source
file through various piped commands, with the resulting audio being
dumped to stdout, and then using passthru in php to get that data to
the enduser.

here's an example, for serving an MP3 with its pitch/speed changed by sox:

passthru(lame --quiet --decode \ . $in_file . \ - |  .
 sox -V -S -t wav - -t wav - speed  . $speed_factor .  |  .
 lame --quiet  . $lame_params .  - -);

This works just fine, except the problem is if the end user aborts the
transfer (e.g. stops playback in the media player, cancels download of
the mp3, whatever) then it leaves behind both the sox process and the
decoder LAMe process along with the sh that's running them. the only
process that exits is the final encoding lame process. If the sound
file runs to completion, everythign exits properly.

But this obviously means enough cancelling of downloads means the
server ends up with a huge batch of stuck processes! And I even tried
simply killing the 'host' sh process, and the lame and sox processes
remain anyway. The only way I've been able to deal with this is
manually killing the lame and sox processes directly.

is there any way I can make this work, such so that if the user
cancels the transfer, all relavent processes are killed rather than
just the single process that's feeding output into php?

-FM


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

---End Message---
---BeginMessage---


- Original Message - 
From: flint fmill...@gmail.com

To: דניאל דנון danondan...@gmail.com
Sent: Sunday, May 31, 2009 9:21 AM
Subject: Re: [PHP] 

Re: [PHP] mysql_query takes long time...

2009-05-31 Thread Phpster

You can also stack the queries to run multiple rows in one insert

Insert into table values (row1col1, row1col2,'row1col3'), 
(row2col1,row2col2,'row2col3'),...(rowNcol1,rowNcol2,'rowNcol3')


Bastien

Sent from my iPod

On May 31, 2009, at 8:18, דניאל דנון danondan...@gmail.com  
wrote:


I've a file of about 500,000 lines, each line contains a string in  
variety
of lengths, but no less then 3 characters and  usually no more  
then 120.

average of about 80, and maximum of about 250.

I made a PHP script to fetch the data (using fgets), process it and  
insert

it to a MySQL database.

The problem is inserting to MySQL takes about 0.02 seconds, which  
looks like

nothing - but when you have 500,000 lines to insert...
The while goes like that:

fgets from file
x1 = some function about the string
x2 = some other function about the string
x3 = the string
insert into table (field1, field2, field3) VALUES (x1, x2, x3)

(pseudo-code)

I was wondering, is there any faster way to perform it, assuming I  
have to

do it with PHP?
also, if it matters - the MySQL table got id in auto increment.


Yours, Daniel.

--
Use ROT26 for best security


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] spawning a process that uses pipes - doesn't terminate when webpage download is canceled

2009-05-31 Thread bruce
we answered this a number of times... 

was there something in the replies that didn't satisfy you?



-Original Message-
From: flint [mailto:fmill...@gmail.com]
Sent: Sunday, May 31, 2009 6:53 AM
To: PHP-General List
Subject: [PHP] spawning a process that uses pipes - doesn't terminate
when webpage download is canceled


sent this before, don't know if it went through... someone please reply if 
it went, even if they don't know answer?...

so here's the scenario..

I have a site that uses php with a database to offer sound files to
users using streaming methods.

the request page has options, allowing the user to modify the sound
file in various ways, before having it sent to them

Here's the problem:

The method i'm using to feed the data to the user is to run the source
file through various piped commands, with the resulting audio being
dumped to stdout, and then using passthru in php to get that data to
the enduser.

here's an example, for serving an MP3 with its pitch/speed changed by sox:

passthru(lame --quiet --decode \ . $in_file . \ - |  .
 sox -V -S -t wav - -t wav - speed  . $speed_factor .  |  .
 lame --quiet  . $lame_params .  - -);

This works just fine, except the problem is if the end user aborts the
transfer (e.g. stops playback in the media player, cancels download of
the mp3, whatever) then it leaves behind both the sox process and the
decoder LAMe process along with the sh that's running them. the only
process that exits is the final encoding lame process. If the sound
file runs to completion, everythign exits properly.

But this obviously means enough cancelling of downloads means the
server ends up with a huge batch of stuck processes! And I even tried
simply killing the 'host' sh process, and the lame and sox processes
remain anyway. The only way I've been able to deal with this is
manually killing the lame and sox processes directly.

is there any way I can make this work, such so that if the user
cancels the transfer, all relavent processes are killed rather than
just the single process that's feeding output into php?

-FM


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Directing form to different handlers?

2009-05-31 Thread Angus Mann
Hi all. I realize this is more an HTML question than PHP but I'm sure someone 
here can help.

I have several forms with lots (dozens) of text inputs. If the user presses the 
Update button I want the form handled by update.php but if they press 
Delete it needs to be handled by delete.php or add.php and so-on 
depending on the button they press.

But when establishing the form I can only have form method=POST 
action=delete.php or add.php or whatever.

Is there a way to direct the content of the form do a different handler 
depending on the button?

I know I can use javascript to direct to a constructed URL and append 
?name=smithaddress=hishousetelephone=28376.and so on but this is not 
practical when there are dozens of entriesthe URL becomes massive. I prefer 
to use POST and then use PHP to extract the POST array.

Any ideas?

Much appreciated.
Angus


Re: [PHP] Directing form to different handlers?

2009-05-31 Thread Robert Cummings
On Mon, 2009-06-01 at 12:53 +1000, Angus Mann wrote:
 Hi all. I realize this is more an HTML question than PHP but I'm sure someone 
 here can help.
 
 I have several forms with lots (dozens) of text inputs. If the user presses 
 the Update button I want the form handled by update.php but if they press 
 Delete it needs to be handled by delete.php or add.php and so-on 
 depending on the button they press.
 
 But when establishing the form I can only have form method=POST 
 action=delete.php or add.php or whatever.
 
 Is there a way to direct the content of the form do a different handler 
 depending on the button?
 
 I know I can use javascript to direct to a constructed URL and append 
 ?name=smithaddress=hishousetelephone=28376.and so on but this is not 
 practical when there are dozens of entriesthe URL becomes massive. I 
 prefer to use POST and then use PHP to extract the POST array.
 
 Any ideas?

Yes, have the form submit to the URL that presented the form. Have THAT
PHP script determine which button was clicked. Then delegate to the
appropriate handler function.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] spawning a process that uses pipes - doesn't terminate when webpage download is canceled

2009-05-31 Thread Robert Cummings
On Sun, 2009-05-31 at 08:52 -0500, flint wrote:
 sent this before, don't know if it went through... someone please reply if 
 it went, even if they don't know answer?...
 
 so here's the scenario..
 
 I have a site that uses php with a database to offer sound files to
 users using streaming methods.
 
 the request page has options, allowing the user to modify the sound
 file in various ways, before having it sent to them
 
 Here's the problem:
 
 The method i'm using to feed the data to the user is to run the source
 file through various piped commands, with the resulting audio being
 dumped to stdout, and then using passthru in php to get that data to
 the enduser.
 
 here's an example, for serving an MP3 with its pitch/speed changed by sox:
 
 passthru(lame --quiet --decode \ . $in_file . \ - |  .
  sox -V -S -t wav - -t wav - speed  . $speed_factor .  |  .
  lame --quiet  . $lame_params .  - -);
 
 This works just fine, except the problem is if the end user aborts the
 transfer (e.g. stops playback in the media player, cancels download of
 the mp3, whatever) then it leaves behind both the sox process and the
 decoder LAMe process along with the sh that's running them. the only
 process that exits is the final encoding lame process. If the sound
 file runs to completion, everythign exits properly.
 
 But this obviously means enough cancelling of downloads means the
 server ends up with a huge batch of stuck processes! And I even tried
 simply killing the 'host' sh process, and the lame and sox processes
 remain anyway. The only way I've been able to deal with this is
 manually killing the lame and sox processes directly.
 
 is there any way I can make this work, such so that if the user
 cancels the transfer, all relavent processes are killed rather than
 just the single process that's feeding output into php?

Use something else to pass the data back to the user... popen() comes to
mind or proc_open(). Then disable auto abort on user disconnect via
ignore_user_abort(). Then after sending periodic data chunks, check the
user connection status via connection_aborted(). If your script finds
that the user has aborted, then kill all the processes in the pipeline
from the PHP script before finally aborting the PHP script itself.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] spawning a process that uses pipes - doesn't terminatewhen webpage download is canceled

2009-05-31 Thread bruce
hi robert.,,

now you've got me curious..

you state...

-Use something else to pass the data back to the user... popen() comes to
-mind or proc_open(). Then disable auto abort on user disconnect via
-ignore_user_abort(). Then after sending periodic data chunks, check the
-user connection status via connection_aborted(). If your script finds
-that the user has aborted, then kill all the processes in the pipeline
-from the PHP script before finally aborting the PHP script itself.

but if the user is using a browser session... which has a web server
connection... are you siggesting that the server app spawns off a child
process via the popen, and that the child somehow connects to the existing
browser session??

walk through the psuedo logic/flow of this if you don't mind.. i must be
missing something..

thanks


-Original Message-
From: Robert Cummings [mailto:rob...@interjinn.com]
Sent: Sunday, May 31, 2009 8:16 PM
To: flint
Cc: PHP-General List
Subject: Re: [PHP] spawning a process that uses pipes - doesn't
terminatewhen webpage download is canceled


On Sun, 2009-05-31 at 08:52 -0500, flint wrote:
 sent this before, don't know if it went through... someone please reply if
 it went, even if they don't know answer?...

 so here's the scenario..

 I have a site that uses php with a database to offer sound files to
 users using streaming methods.

 the request page has options, allowing the user to modify the sound
 file in various ways, before having it sent to them

 Here's the problem:

 The method i'm using to feed the data to the user is to run the source
 file through various piped commands, with the resulting audio being
 dumped to stdout, and then using passthru in php to get that data to
 the enduser.

 here's an example, for serving an MP3 with its pitch/speed changed by sox:

 passthru(lame --quiet --decode \ . $in_file . \ - |  .
  sox -V -S -t wav - -t wav - speed  . $speed_factor .  | 
.
  lame --quiet  . $lame_params .  - -);

 This works just fine, except the problem is if the end user aborts the
 transfer (e.g. stops playback in the media player, cancels download of
 the mp3, whatever) then it leaves behind both the sox process and the
 decoder LAMe process along with the sh that's running them. the only
 process that exits is the final encoding lame process. If the sound
 file runs to completion, everythign exits properly.

 But this obviously means enough cancelling of downloads means the
 server ends up with a huge batch of stuck processes! And I even tried
 simply killing the 'host' sh process, and the lame and sox processes
 remain anyway. The only way I've been able to deal with this is
 manually killing the lame and sox processes directly.

 is there any way I can make this work, such so that if the user
 cancels the transfer, all relavent processes are killed rather than
 just the single process that's feeding output into php?

Use something else to pass the data back to the user... popen() comes to
mind or proc_open(). Then disable auto abort on user disconnect via
ignore_user_abort(). Then after sending periodic data chunks, check the
user connection status via connection_aborted(). If your script finds
that the user has aborted, then kill all the processes in the pipeline
from the PHP script before finally aborting the PHP script itself.

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: PHP vs ASP.NET

2009-05-31 Thread Manuel Lemos
Hello,

on 05/28/2009 10:20 AM Olexandr Heneralov said the following:
 Hi!
 Guys, you of course, know that  ASP.NET becomes more and more popular in the
 world.
 I have a question for everyone:
 Can it happen so that PHP will be replaced with ASP.NET?

ASP.NET is not a language. It is more like a framework that can run
multiple languages. It can run VB.NET, C# and even PHP (although it is
not usual).

I am not sure what are the current numbers, but the latest statistics
that I have seen Apache was running on 72% of the Internet Web servers
against only 17% of Microsoft IIS. Although you can run ASP.NET on
Apache via mono, that is unusual.

Also PHP is the most popular Apache extension present in between 40% and
50% of Apache installations. This means that PHP is present in 1/3 of
the Internet Web servers, which represents about half of the PHP market
share.

This article provides more details about PHP market share.

http://www.phpclasses.org/blog/post/95-How-large-is-the-PHP-market.html

As of ASP.NET becoming more popular than PHP, I don't think that even
Microsoft believes that is possible. Actually Microsoft is very
concerned that PHP runs well on Windows and is sponsoring a lot of PHP
activity.

This other article talks about what is Microsoft so interested in PHP now.

http://www.phpclasses.org/blog/post/85-What-is-Microsoft-up-to-with-PHP.html

-- 

Regards,
Manuel Lemos

Find and post PHP jobs
http://www.phpclasses.org/jobs/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Jacob's Calendar

2009-05-31 Thread Jacob Kutty
Hi

I am creating a birthday calendar of all my friends and family.  Can you please 
click on the link below to enter your birthday for me?

http://www.birthdayalarm.com/bd2/85206071a420999425b1469532889c603775600d905

Thanks,
Jacob


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php