php-general Digest 24 Dec 2009 16:59:10 -0000 Issue 6504

Topics (messages 300659 through 300677):

Re: sending email with php
        300659 by: kranthi

Tracking file download progress
        300660 by: STEEL
        300661 by: Daniel Egeberg
        300662 by: STEEL
        300663 by: kranthi
        300666 by: Daniel Egeberg
        300667 by: STEEL
        300674 by: tedd

Re: Form validation issue
        300664 by: kranthi
        300665 by: Allen McCabe
        300675 by: tedd
        300676 by: tedd

PHP/SWFUpload progress
        300668 by: German Geek

strtotime - assumptions about default formatting of dates
        300669 by: Angus Mann
        300670 by: Pete Ford
        300671 by: Daniel Egeberg
        300673 by: tedd
        300677 by: Bastien Koert

Re: DailyWTF - Maybe I Needing Later
        300672 by: tedd

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


----------------------------------------------------------------------
--- Begin Message ---
No. You must have noticed gmail saying "images are blocked from .. ". This
is done to prevent spammers from knowing if your email is authentic or not.
Moreover you must have also noticed that all the news letters have a link
pointing to a web page version of the newsletter.

--- End Message ---
--- Begin Message ---
Hi all!
Here  is  the  problem: i have PHP script that takes URL of file from
client  and  downloads  it  to  my server. But when file is downloading,
clients  see blank page. How can I track file download progress on the
server  side(easier) and send result to client lively, to show it like
a progress bar in web browser?
Googled  around,  found  JQuery and JsHttpRequest, but can't understand
both for my task =) If everyone knows please give me some advice

Best regards


--- End Message ---
--- Begin Message ---
2009/12/24 STEEL <vla...@mail.kna.ru>:
> Hi all!
> Here  is  the  problem: i have PHP script that takes URL of file from
> client  and  downloads  it  to  my server. But when file is downloading,
> clients  see blank page. How can I track file download progress on the
> server  side(easier) and send result to client lively, to show it like
> a progress bar in web browser?
> Googled  around,  found  JQuery and JsHttpRequest, but can't understand
> both for my task =) If everyone knows please give me some advice
>
> Best regards

If I understand your question correctly, you cannot. PHP works on the
server-side so once you've sent your HTTP response request, you are no
longer in control. Besides, I don't know any downloading tool that
doesn't already show a progress bar to the user. Even wget does so.

You can of course track how much data *you* have sent, but that
doesn't mean the client has downloaded all of it. It may for instance
be that the client didn't finish downloading or that it is downloading
slower than you are sending.

-- 
Daniel Egeberg

--- End Message ---
--- Begin Message ---
> 2009/12/24 STEEL <vla...@mail.kna.ru>:
>> Hi all!
>> Here  is  the  problem: i have PHP script that takes URL of file from
>> client  and  downloads  it  to  my server. But when file is downloading,
>> clients  see blank page. How can I track file download progress on the
>> server  side(easier) and send result to client lively, to show it like
>> a progress bar in web browser?
>> Googled  around,  found  JQuery and JsHttpRequest, but can't understand
>> both for my task =) If everyone knows please give me some advice
>>
>> Best regards

> If I understand your question correctly, you cannot. PHP works on the
> server-side so once you've sent your HTTP response request, you are no
> longer in control. Besides, I don't know any downloading tool that
> doesn't already show a progress bar to the user. Even wget does so.

> You can of course track how much data *you* have sent, but that
> doesn't mean the client has downloaded all of it. It may for instance
> be that the client didn't finish downloading or that it is downloading
> slower than you are sending.

> -- 
> Daniel Egeberg

Thanks for response, but seems you haven't understood:
>> takes URL of file from client  and  downloads  it  to  my server.
User  don't download it at the downloading time to server, server gets
it thru PHP script and stores on itself!
ONly  i want is understand how to show progress bar to user. I have an
idea:  in  my  downloading  script in cycle add $_REQUEST['completed']
with  downloaded bytes, then at the client side via JavaScript(JQuery)
it will dynamically get data from backend variable. Would it work?



-- 
С уважением,
 STEEL                          mailto:vla...@mail.kna.ru


--- End Message ---
--- Begin Message ---
I dont think the problem in discussion has a solution. Your idea can
probably work but I could not understand how $_REQUEST['compleated']
variable is populated.

However it suffers from 2 problems.
1. It consumes a lot of unnecessary bandwidth.
2. How are you going to initiate the download ?

That said, there is a work around of using server push technology. Of
course it does not work in IE though.

www.howtocreate.co.uk/php/serverpushdemo.php

--- End Message ---
--- Begin Message ---
On Thu, Dec 24, 2009 at 09:55, STEEL <vla...@mail.kna.ru> wrote:
> Thanks for response, but seems you haven't understood:
>>> takes URL of file from client  and  downloads  it  to  my server.
> User  don't download it at the downloading time to server, server gets
> it thru PHP script and stores on itself!
> ONly  i want is understand how to show progress bar to user. I have an
> idea:  in  my  downloading  script in cycle add $_REQUEST['completed']
> with  downloaded bytes, then at the client side via JavaScript(JQuery)
> it will dynamically get data from backend variable. Would it work?

Oh, I see now. Sorry.

I had this in my bookmarks: http://www.swfupload.org/

I don't know if it's any good, but you can check it out.

-- 
Daniel Egeberg

--- End Message ---
--- Begin Message ---

> On Thu, Dec 24, 2009 at 09:55, STEEL <vla...@mail.kna.ru> wrote:
>> Thanks for response, but seems you haven't understood:
>>>> takes URL of file from client  and  downloads  it  to  my server.
>> User  don't download it at the downloading time to server, server gets
>> it thru PHP script and stores on itself!
>> ONly  i want is understand how to show progress bar to user. I have an
>> idea:  in  my  downloading  script in cycle add $_REQUEST['completed']
>> with  downloaded bytes, then at the client side via JavaScript(JQuery)
>> it will dynamically get data from backend variable. Would it work?

> Oh, I see now. Sorry.

> I had this in my bookmarks: http://www.swfupload.org/

> I don't know if it's any good, but you can check it out.

> -- 
> Daniel Egeberg

Thanks all, I've found the solution! PHP Backend + JQuery works great!
And  without  "eating"  lot of bandwith, graph updated only once per 2
seconds and data sent by server is only about 500 bytes


--- End Message ---
--- Begin Message ---
At 5:28 PM +1000 12/24/09, STEEL wrote:
Hi all!
Here  is  the  problem: i have PHP script that takes URL of file from
client  and  downloads  it  to  my server. But when file is downloading,
clients  see blank page. How can I track file download progress on the
server  side(easier) and send result to client lively, to show it like
a progress bar in web browser?
Googled  around,  found  JQuery and JsHttpRequest, but can't understand
both for my task =) If everyone knows please give me some advice

Best regards


Hi:

I usually solve that problem by presenting the user with an animated wait gif -- here are some examples (use as you may):

http://webbytedd.com/bb/wait/

If you think about it, the user doesn't really need to know how much has been downloaded. They just need to know that something is happening and this does that.

Cheers and Merry Christmas.

tedd

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

--- End Message ---
--- Begin Message ---
The javascript function formValidator() must return false if any
errors are formed.

>>The PHP only runs if the fields are set by testing using ‘isset”.
You should definitely have a better validation than that. Remember
that all users dont have javascript enabled. Moreover it is very easy
to modify the request variables.

>> However, if the server-side evaluation fails and the page is refreshed, then 
>> all the previous values are lost -- UNLESS -- you keep them in a cookie, 
>> database, or session. I suggest using a session.
This is true when the page is refreshed but I doubt that is the case
here. Since $_SERVER['PHP_SELF'] is being used I think value="<?php
echo $_POST[...] ?>" will be sufficient

--- End Message ---
--- Begin Message ---
Tedd,

If you are using a post method using $_SERVER['PHP_SELF'], then values are
present in the POST array, hence, you would write your html with
interspersed php like so:

<input type="text" name="username" value="<?php if
(isset($_POST['username'])) echo $_POST['username'] ?>" id="username" />

I sometimes use a function for the echoing of these values if I use the same
form for first time (ie. registration) and editing (update), and the
function checks for a $_POST value, then secondly for an existing database
value variable (ie. $row['username']). If either exist, populate the input
with it (precedence given to POST), otherwise it is empty.

The function looks something this:

function echoValue($post=null, $row=null) {
    if (isset($post)) {
        echo $post;
    } elseif (isset($row)) {
        echo $row;
    }
}

and is used like this:

<input type... value="<?php echoValue($_POST['username'], $row['username'] )
?>" id="username" />

after performing a query on a query-string variable (eg. profile.php?id=57
---> 'SELECT * FROM `users` WHERE `id` = '.$_GET['id'] ) etc.

On Mon, Dec 21, 2009 at 8:03 AM, tedd <tedd.sperl...@gmail.com> wrote:

> At 9:43 PM -0500 12/20/09, Ernie Kemp wrote:
>
>> Good Day,
>>
>>                I need help in in validating a form.
>>                The for is valdated be a javascript frist then if all the
>> fields are filled in its valaded be PHP.
>>
>>                The Form starts with:
>>                <form name="myForm" action="<?php echo
>> $_SERVER['PHP_SELF'];?>" method="post" onsubmit='return formValidator()' >
>>
>> The "formValidator()" goes to a javascript and does display the missing
>> information in this case BUT then the page gets reloaded and clears all the
>> javascript error messages and does the PHP validation.
>>
>> The PHP only runs if the fields are set by testing using 'isset".
>>
>> Without puting on numeric lines of go can you suggest things I must have
>> overlooked. Silly request but there must be something I'm overlooking.    I
>> have simular code on other programs but this one is casuing me trouble.
>>
>> Thanks every so much..
>>
>>
>
> Ernie:
>
> Client-side javascript can help populate fields and correct any problems a
> user might have, but once the form is submitted to the server, then the data
> is sent and evaluated server-side, hence validation.
>
> However, if the server-side evaluation fails and the page is refreshed,
> then all the previous values are lost -- UNLESS -- you keep them in a
> cookie, database, or session. I suggest using a session.
>
> Cheers,
>
> 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 2:22 AM -0800 12/24/09, Allen McCabe wrote:
Tedd,

If you are using a post method using $_SERVER['PHP_SELF'], then values are present in the POST array, hence, you would write your html with interspersed php like so:

<input type="text" name="username" value="<?php if (isset($_POST['username'])) echo $_POST['username'] ?>" id="username" />


No, I wouldn't do it that way.

First, a "post method using $_SERVER['PHP_SELF']" is the same as action="". A form by default, defaults to itself and thus no need for $_SERVER['PHP_SELF'].

Second, I seldom use any POST variable without sanitizing it first. As such, my <input> statements always look like --

   <input type="text" name="user_name" value="<?php echo($user_name); ?>" >

-- where the variable $user_name has been"sanitized" in some fashion (i.e., trim, limit length, etc.).

I think that is easier to read and debug. Also, if I am using a javascript routine (as mentioned in the OP), then I add ' id="user_name" '

Cheers and Merry Christmas.

tedd

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

--- End Message ---
--- Begin Message ---
At 3:10 PM +0530 12/24/09, kranthi wrote:
The javascript function formValidator() must return false if any
errors are formed.

The PHP only runs if the fields are set by testing using 'isset".
You should definitely have a better validation than that. Remember
that all users dont have javascript enabled. Moreover it is very easy
to modify the request variables.

However, if the server-side evaluation fails and the page is refreshed, then all the previous values are lost -- UNLESS -- you keep them in a cookie, database, or session. I suggest using a session.
This is true when the page is refreshed but I doubt that is the case
here. Since $_SERVER['PHP_SELF'] is being used I think value="<?php
echo $_POST[...] ?>" will be sufficient

I forgot to mention that $_POST does hold on to the values as well -- so, one could use that. However, you still have to repopulate the form and that was what I was getting at.

Cheers and Merry Christmas.

tedd

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

--- End Message ---
--- Begin Message ---
Hi all,

Wishing you a merry xmas! As a gift to you a little thing that I figured out
through long googling and trial and error:

We are using the swfupload (flash) upload tool to upload files to a php
script. For a rather cryptic reason on some clients the progress would show
too quickly when AVG Link scanning was activated on a windows machine. The
upload would have completed, but it was actually still uploading. Sound
weird? Yes that's what we thought.

We ended up solving it by installing SSL (https) on that machine which
solved the problem because the anti virus cannot "see" the upload requests
and tamper with it.

I know this is not strictly PHP related, but since this list was always
helpful for me i thought i would share this for xmas.

There is a question that came up though:
When uploading to a php page i could find a temporary file that was growing
on the server. Couldn't one monitor the growth of that file and therefore
track the progress with AJAX poll requests? I know this is more overhead but
this seems more reliable to me when there is something funny going on on the
client machine, like with the above anti virus. I couldn't figure out how to
determine which temp file it was though, because the request would be still
going while the file is uploaded and you cannot read the $_FILES variable or
similar.

Kind regards,
Tim

++Tim Hinnerk Heuer++

http://www.ihostnz.com

--- End Message ---
--- Begin Message ---
Hi all. I need to allow users to enter dates and times, and for a while now 
I've been forcing them to use javascript date/time pickers so I can be 
absolutely sure the formatting is correct.

Some users are requesting to be able to type the entries themselves so I've 
decided to allow this.

I'm in Australia, and the standard formatting of dates here is DD/MM/YYYY or 
DD-MM-YYYY

I recognize this is different to what seems to happen in the US, where it is 
MM/DD/YYYY or MM-DD-YYYY

When I process an entered date using strtotime() it seems to work fine.

But of course I am concerned when dates like January 2 come up.

I find that 2/1/2009 is interpreted as January 2, 2009 on my installation, 
which is Windows 7 with location set to Australia.

But can I be sure that all installations of PHP, perhaps in different countries 
and on different operating systems will interpret dates the same?

I can't find much mention of this question online or in the manual.

Any help much appreciated.
Angus

--- End Message ---
--- Begin Message ---
On 24/12/09 12:20, Angus Mann wrote:
Hi all. I need to allow users to enter dates and times, and for a while now 
I've been forcing them to use javascript date/time pickers so I can be 
absolutely sure the formatting is correct.

Some users are requesting to be able to type the entries themselves so I've 
decided to allow this.

I'm in Australia, and the standard formatting of dates here is DD/MM/YYYY or 
DD-MM-YYYY

I recognize this is different to what seems to happen in the US, where it is 
MM/DD/YYYY or MM-DD-YYYY

When I process an entered date using strtotime() it seems to work fine.

But of course I am concerned when dates like January 2 come up.

I find that 2/1/2009 is interpreted as January 2, 2009 on my installation, 
which is Windows 7 with location set to Australia.

But can I be sure that all installations of PHP, perhaps in different countries 
and on different operating systems will interpret dates the same?

I can't find much mention of this question online or in the manual.

Any help much appreciated.
Angus


I wrote a little AJAX gadget which sent the string typed to a PHP backend which parsed it using strtotime and then formatting it out again as something unamiguous (like 2 January 2009). Then every time the date entry field is changed by the user (with an onKeyUp event), this AJAX call is triggered and displays the unambiguous form next to the input box, so users can see how their entry is being interpreted.
Of course, there's some overhead in the AJAX calls, and it requires JavaScript.

If you wanted to do without JavaScript you could do a similar parse-format sequence when the form is submitted and show a confirmation page with your server's interpretation of the date.

Cheers
Pete

--- End Message ---
--- Begin Message ---
On Thu, Dec 24, 2009 at 13:20, Angus Mann <angusm...@pobox.com> wrote:
> Hi all. I need to allow users to enter dates and times, and for a while now 
> I've been forcing them to use javascript date/time pickers so I can be 
> absolutely sure the formatting is correct.
>
> Some users are requesting to be able to type the entries themselves so I've 
> decided to allow this.
>
> I'm in Australia, and the standard formatting of dates here is DD/MM/YYYY or 
> DD-MM-YYYY
>
> I recognize this is different to what seems to happen in the US, where it is 
> MM/DD/YYYY or MM-DD-YYYY
>
> When I process an entered date using strtotime() it seems to work fine.
>
> But of course I am concerned when dates like January 2 come up.
>
> I find that 2/1/2009 is interpreted as January 2, 2009 on my installation, 
> which is Windows 7 with location set to Australia.
>
> But can I be sure that all installations of PHP, perhaps in different 
> countries and on different operating systems will interpret dates the same?
>
> I can't find much mention of this question online or in the manual.
>
> Any help much appreciated.
> Angus
>

strtotime() interprets dates according to the rules of the current
timezone. The specific rules are outlined in GNU's manual:
http://www.gnu.org/software/tar/manual/html_node/Date-input-formats.html

-- 
Daniel Egeberg

--- End Message ---
--- Begin Message ---
At 10:20 PM +1000 12/24/09, Angus Mann wrote:
Hi all. I need to allow users to enter dates and times, and for a while now I've been forcing them to use javascript date/time pickers so I can be absolutely sure the formatting is correct.

Some users are requesting to be able to type the entries themselves so I've decided to allow this.

I'm in Australia, and the standard formatting of dates here is DD/MM/YYYY or DD-MM-YYYY

I recognize this is different to what seems to happen in the US, where it is MM/DD/YYYY or MM-DD-YYYY

When I process an entered date using strtotime() it seems to work fine.

But of course I am concerned when dates like January 2 come up.

I find that 2/1/2009 is interpreted as January 2, 2009 on my installation, which is Windows 7 with location set to Australia.

But can I be sure that all installations of PHP, perhaps in different countries and on different operating systems will interpret dates the same?

I can't find much mention of this question online or in the manual.

Any help much appreciated.
Angus

Angus:

You are running into a problem that cannot be solved by allowing the user to do whatever they want. As you realize, if I enter 01-02-09 you don't know if I mean January 2, 2009 or February 1, 2009 and there is no way to figure out what I meant.

The solution is simply to use the html <option> and give the user that way to enter month and day.

I would set it to day-month-year and let US visitors live with it for I personally think that's a better format.

Cheers and Merry Christmas.

tedd


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

--- End Message ---
--- Begin Message ---
On Thu, Dec 24, 2009 at 9:12 AM, tedd <tedd.sperl...@gmail.com> wrote:
> At 10:20 PM +1000 12/24/09, Angus Mann wrote:
>>
>> Hi all. I need to allow users to enter dates and times, and for a while
>> now I've been forcing them to use javascript date/time pickers so I can be
>> absolutely sure the formatting is correct.
>>
>> Some users are requesting to be able to type the entries themselves so
>> I've decided to allow this.
>>
>> I'm in Australia, and the standard formatting of dates here is DD/MM/YYYY
>> or DD-MM-YYYY
>>
>> I recognize this is different to what seems to happen in the US, where it
>> is MM/DD/YYYY or MM-DD-YYYY
>>
>> When I process an entered date using strtotime() it seems to work fine.
>>
>> But of course I am concerned when dates like January 2 come up.
>>
>> I find that 2/1/2009 is interpreted as January 2, 2009 on my installation,
>> which is Windows 7 with location set to Australia.
>>
>> But can I be sure that all installations of PHP, perhaps in different
>> countries and on different operating systems will interpret dates the same?
>>
>> I can't find much mention of this question online or in the manual.
>>
>> Any help much appreciated.
>> Angus
>
> Angus:
>
> You are running into a problem that cannot be solved by allowing the user to
> do whatever they want. As you realize, if I enter 01-02-09 you don't know if
> I mean January 2, 2009 or February 1, 2009 and there is no way to figure out
> what I meant.
>
> The solution is simply to use the html <option> and give the user that way
> to enter month and day.
>
> I would set it to day-month-year and let US visitors live with it for I
> personally think that's a better format.
>
> Cheers and Merry Christmas.
>
> 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
>
>

I would agree with tedd. Use a JS calendar widget (requires js) or use
three select boxes for mm , dd and year

-- 

Bastien

Cat, the other other white meat

--- End Message ---
--- Begin Message ---
At 11:17 AM -0800 12/23/09, Adam Randall wrote:
Unfortunately, this is how government works too. About 10 years ago while
maintaining the Golden Gate website I had to post contracts to their site.
These would be for things like seismic retrofits, etc. Contractors would bid
on the contracts, and whoever came up the lowest was the winner.

Nice to know that the guys making your bridges more earthquake resistant are
the ones who are the cheapest.

Adam.

Adam:

The problem is not who is the "cheapest", but rather who is "approved" by a bunch of government bureaucrats who have no idea of what is actually needed to make a bridge earthquake resistant.

I submitted several Federal applications for grants in the Geophysical discipline and you would not believe the submission and review process -- it was a joke. IMO, it's a "good-old-boys-club" of handing out favors to those who support government misconceptions. Much like the Global Warming nonsense of today.

In any event, Merry Christmas.

tedd


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

--- End Message ---

Reply via email to