php-general Digest 6 Aug 2006 20:30:21 -0000 Issue 4278

Topics (messages 240198 through 240202):

Re: Sending data to persistent process stdin
        240198 by: David Tulloh

Re: The difference between ereg and preg? [SOLVED]
        240199 by: Dave M G

client<->server upload communication?
        240200 by: tedd
        240201 by: Jeffrey Sambells
        240202 by: tedd

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

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


----------------------------------------------------------------------
--- Begin Message ---
Ville Mattila wrote:
> Hello readers,
> 
> I have been thinking of making a simple web-based interface to control
> my media center box (running debian linux). Being a bit enthustiatic, I
> thought I could use some generic tools for playing media files and write
> the whole UI by my own.
> 
> I found mpg123 program that can be run in "remote mode" (mpg123 -R) so
> that playback can be controlled via stdin. Writing "LOAD <mp3 file>" to
> the stdin will begin output, "PAUSE" will stop it and so on.
> 
> How could I use PHP and its process functions to send something to stdin
> of a persistent process? I would like to run mpg123 only once,
> whichafter a few PHP scripts would send data and proper commands to its
> stdin. Maybe a kind of daemon process would be needed? Anyway, sending
> data to a daemon can be problematic... Maybe a kind of socket wrapper?
> Well - I have no experience about socket functions of PHP...
> 
> Tips and tricks are welcome, or should I just go to the local hi-tech
> market and by a CD player LOL :D
> 

I have done something similar using both mpg321 and madplay.  However I
used signals rather than holding open stdin.  It's a little ugly but
very simple, From memory:
STOP pauses
CONT resumes
QUIT causes it to stop playing and terminates the process
To play a new song, start a new process.
USR1 does something, I think USR2 does something too.  I just can't
remember what.

There should be documentation for mpg123 that explains all the signals
and how it reacts.  If not you could find it fairly easily by browsing
the source.


David

--- End Message ---
--- Begin Message ---
Robert,

Thank you for pointing me to the relevant part of TFM that I needed to R.

The final regular expression that I have settled on that is reliably producing expected results is:
#<li>(.*)<br>#isU"

This finds all the text between a <li> and <br> tag.

I found that it was helpful for me to restrict the the tags down to simple constructs, instead of having "<li[^>]*>", because in the source I'm using, the <li> and <br> tags never have additional parameters. Having a more flexible <li> definition was causing confusion with a <link> tag elsewhere in the source.

Anyway, the point is that it works very well now.

Thanks to the PHP list, especially Jochem, Ligaya, Dave, Robert, Mike, Robert, Adam, and John, for all your helpful information and advice.

--
Dave M G

--- End Message ---
--- Begin Message ---
Hi gang:

I posted this question on a js list, but didn't received an answer. Maybe someone here might be able to provide some insight or direction.

In my ajax "experiment" monitoring states, namely:

http://xn--ovg.com/ajax_readystate

I can see the readyState replies/conditions.

Is there something similar when uploading a file or image?

There has to be some sort of communication between the sender and the receiver, right?

If so, is there a way to tap into that communication?

Thanks in advance for any replies.

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
Your page currently has a JS error but...

The short answer is not in PHP. The PHP script doesn't 'process' the upload of the file. When the file is received by the server, the script (line 1) starts executing AFTER the file is already fully uploaded, and the files temporary location is references in the $_FILES array.

You may be able to get access the the state of the upload using a PECL extension, I remember reading something somewhere...

My assumption here is you're trying to write a progress bar or something similar?

If all you're after is a 'state' then you could submit your form to an embedded <iframe> and have the resulting page run an "I'm done" javascript, but that would only give you the start (when the user clicks submit) and the end (when the done function runs), it won't give you a true state during the course of the upload.

- Jeff

P.S. You could use perl as it has access to the file WHILE it's uploading, not just after, but that's for a different list :c)


On 6-Aug-06, at 10:56 AM, tedd wrote:

Hi gang:

I posted this question on a js list, but didn't received an answer. Maybe someone here might be able to provide some insight or direction.

In my ajax "experiment" monitoring states, namely:

http://xn--ovg.com/ajax_readystate

I can see the readyState replies/conditions.

Is there something similar when uploading a file or image?

There has to be some sort of communication between the sender and the receiver, right?

If so, is there a way to tap into that communication?

Thanks in advance for any replies.

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

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


--- End Message ---
--- Begin Message ---
At 1:18 PM -0400 8/6/06, Jeffrey Sambells wrote:
My assumption here is you're trying to write a progress bar or something similar?

Yep.

If all you're after is a 'state' then you could submit your form to an embedded <iframe> and have the resulting page run an "I'm done" javascript, but that would only give you the start (when the user clicks submit) and the end (when the done function runs), it won't give you a true state during the course of the upload.

I've done something similar, namely:

http://xn--ovg.com/aa

But, it's faux upload -- I might as well stick with:

http://xn--ovg.com/a/wait.php

I'll look into your PERL suggestion -- that sounds intriguing.

Thanks Jeff.

tedd <off to find his old Perl books>

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---

Reply via email to