php-general Digest 6 Jul 2011 13:31:50 -0000 Issue 7392
Topics (messages 313932 through 313947):
Re: vend-bot?
313932 by: Kirk Bailey
313947 by: Stuart Dallas
Re: Top Posting
313933 by: Jim Giner
313934 by: Daniel Brown
313936 by: Lester Caine
313940 by: Ford, Mike
Self-whitelisting (WAS: Top Posting)
313935 by: George Langley
static variables inside static methods
313937 by: ÐмиÑÑий СÑепанов
313938 by: Andrew Williams
Re: Installing PHP
313939 by: David Robley
Constants in strings
313941 by: Dave Wilson
313943 by: Curtis Maurand
313944 by: Stuart Dallas
313945 by: Ashley Sheridan
313946 by: Geoff Lane
Re: Foreach question
313942 by: Dajka Tamás
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 ---
On 7/3/2011 4:53 PM, Stuart Dallas wrote:
Only allowing them to access the URL once is a bad idea. If their
download fails, is corrupt, or any number of other things go wrong
(think accelerators, browser accelerators, etc) then you end up
with a lot of support mail. Better to give them access for a short
period of time.
Ok, so it just got more complex- if we let them do it twice, ior
three times, we have a more complex design specification; if we let
them do it unlimited times, we just defeated thepurpose of the
exercise. How about this: if it fails, the customer can email us,
adn we can reply with a copy as an attachment; a ripoff artist will
not be in the log, and a complaint of failure to download gets them
nothing.
Personally I would generate a unique token linked to their
account, or if no user system exists then link it to their order
number. Stick that in a URL and forward them to it. That URL shows
them the thanks page and links to download the product(s). Each of
those links also contains the token. Expire that token after 24
hours, and on the page telling them it's expired give them a way
to contact you just in case they haven't successfully downloaded
the product yet.
There is no need to use cookies. There is no need to use basic
authentication (which is a horrible user experience). They come
back from PayPal to a script that sets up their unique URL, then
you take them to that URL. KISS it - the more complicated you make
this the worse the user experience will be and it won't be any
more secure than a time-limited unique token as described above.
-Stuart
--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
--
end
Very Truly yours,
- Kirk Bailey,
Largo Florida
kniht
+-----+
| BOX |
+-----+
think
--- End Message ---
--- Begin Message ---
On Wed, Jul 6, 2011 at 3:01 AM, Kirk Bailey <kbai...@howlermonkey.net>wrote:
>
>
> On 7/3/2011 4:53 PM, Stuart Dallas wrote:
>
>> Only allowing them to access the URL once is a bad idea. If their download
>> fails, is corrupt, or any number of other things go wrong (think
>> accelerators, browser accelerators, etc) then you end up with a lot of
>> support mail. Better to give them access for a short period of time.
>>
>> Ok, so it just got more complex- if we let them do it twice, ior three
> times, we have a more complex design specification; if we let them do it
> unlimited times, we just defeated thepurpose of the exercise. How about
> this: if it fails, the customer can email us, adn we can reply with a copy
> as an attachment; a ripoff artist will not be in the log, and a complaint of
> failure to download gets them nothing.
I don't see how it got more complex. You need to verify that the user has
paid for the file(s) they are trying to access, all this does is add an
expiry timestamp to that access rather than a counter.
I'm not sure what you're purpose is with this exercise, but usually this
sort of thing aims to provide customers with the digital assets they've
purchased in a way that's easy for them to understand and use, limits
expensive support costs, and protects the assets from being downloaded
without first being purchased. And for me, the priorities are in that order.
What do you think you gain by limiting the link to a single use? If you
think you're preventing them from passing it on to other people, then yes
you are, but if you do that then they'll simply send the digital file
instead so you're actually trading a poor user experience and increased
support costs for practically no benefit.
-Stuart
--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
--- End Message ---
--- Begin Message ---
Huh? You have a problem with a person having a spam filter that requires
one valid response to ensure that the mail from an address is from a real
person ONE TIME ONLY?
And what do you use to cut down on spam in your in-box?
--- End Message ---
--- Begin Message ---
On Tue, Jul 5, 2011 at 22:52, Jim Giner <jim.gi...@albanyhandball.com> wrote:
> Huh? You have a problem with a person having a spam filter that requires
> one valid response to ensure that the mail from an address is from a real
> person ONE TIME ONLY?
Not that you're asking me, but yes, I do. It's not a bad idea in
practice, but it's not a good idea either. If I'm sending an
out-of-the-blue email to you, then I understand that I may have to
introduce myself to the guard in the gatehouse. If you've sent
something to me and I need permission to reply, that's making you look
sanctimonious and unworthy of my time. That's not to say that you
are, or that anyone like you is, of course, but if you expect - or
even hope - to receive my reply, you should at least put me on the
guest list first.
(Pardon the analogies, but I've been watching documentaries on
18th Century Statesmanship, in relation to our Independence Day
weekend.)
A better use of everyone's time here would be to collaborate on
ways to reduce SPAM. So many folks bitch and whine about it, yet so
few seriously invest a few hours per month to help rid the world of it
all. For the record, though, test($_POSTING['position']='top') will
always return FALSE with a warning here.
Parting words: most programmers still code in a procedural manner,
yet so many can't comprehend reading top-to-bottom on a programming
list. I'm sure I'm not the only one who's used Google searches for
such intricacies as a minor evaluation of a prospective employee's
potential fit.
--
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/
--- End Message ---
--- Begin Message ---
Tamara Temple wrote:
And then, we have the case of a signature being 3 times as long as the
reply....
Which is less of a problem if the email client correctly trims it! I can
probably come up with a list of posts just to this list where a top poster has
included several signatures several times - along with all the advertising :(
The bottom line is that we are not going to get any agreement on this. It's just
a fact of life that people don't like to accept being told what to do so we have
to live with that. But as long as lists like this are coming conveniently into
my inbox *I* can do what I like with them. I have material going back to 1995
nicely manageable here even when the broadband is down so I'll put up with the
irritation - actually most top posted messages can simply be culled anyway - I
have the previous message listed :)
--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php
--- End Message ---
--- Begin Message ---
On 2011-07-05, Stuart Dallas penned the words:
> On Tue, Jul 5, 2011 at 3:29 PM, <ad...@buskirkgraphics.com> wrote:
>
>> Anyone know how to make Outlook changes its reply position.
>
> Google delivers...
> http://sourceforge.net/apps/mediawiki/macros4outlook/index.php?title
> =QuoteFix_Macro
Many thanks for that link, Stuart -- I've been using Dominik Jain's
Outlook QuoteFix for years, but hadn't noticed this development. Have
just installed it (and this reply is its first product!). It works well
enough, but needs some more development -- might have to look into that
as my VB is pretty good....
Cheers!
Mike
--
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,
Portland PD507, City Campus, Leeds Metropolitan University,
Portland Way, LEEDS, LS1 3HE, United Kingdom
E: m.f...@leedsmet.ac.uk T: +44 113 812 4730
To view the terms under which this email is distributed, please go to
http://disclaimer.leedsmet.ac.uk/email.htm
--- End Message ---
--- Begin Message ---
On 2011-07-05, at 8:52 PM, Jim Giner wrote:
> Huh? You have a problem with a person having a spam filter that requires
> one valid response to ensure that the mail from an address is from a real
> person ONE TIME ONLY?
--------------
I know that I do. I monitor our web site's registration system, and
will get a number of notices from things like Boxbe, stating that they've
delayed the email with the confirmation link that we send our clients, until we
confirm receipt of their notice. But, this can be used against you, as they now
know that your address is valid, and can in turn spam you! Can read the ugly
details on Wiki:
<http://en.wikipedia.org/wiki/Boxbe>
I won't subject my company to that nuisance.
George Langley
Multimedia Developer
--- End Message ---
--- Begin Message ---
Hello, everybody.
While working with static variables inside static class' methods, I have
found this very interesting (at least for me) behavior of PHP.
Consider the following class definitions (example #1):
class X {
public final static function test() {
static $i;
return ++$i;
}
}
class Y extends X {
}
By executing this code:
echo X::test();
echo Y::test(); // note Y class here
one would expect to see "12" as output, but apparently I get "11".
That's a bit confusing if you logically assume that "static vars" are "tied
to the scope" they're defined in. Since this static variable is
defined in a specific static method test(), that is NOT overloaded by class
Y, in my opinion it shoul've preserved it's value across static calls.
Let's look at another example (example #2):
class X {
public static $x =0;
public final static function test() {
return ++static::$x; // note static keyword here
}
}
class Y extends X {
}
If you run this code:
echo X::test();
echo Y::test();
you get "12" as output - the expected output. Notice that the "++static::$x"
expr. is taking advantage of late static binding. Now, if you change
body of test() to the following code:
public final static function test() {
return ++self::$x;
}
then you also get "12" as output.
Is this a bug that static context of $i is not preserved in example #1 or do
I misunderstand something?
I could not find any hints on this in the PHP documentation.
Dmitry.
--- End Message ---
--- Begin Message ---
I think you are confusing scope visibility level of the variable within
method and the class.
Variable within the method is going to 1 because it was declare within the
test method and there no link to the one declared outside the test method.
The second case is referencing the varible of the class.
2011/7/6 Дмитрий Степанов <dmit...@stepanov.lv>
> Hello, everybody.
>
> While working with static variables inside static class' methods, I have
> found this very interesting (at least for me) behavior of PHP.
>
> Consider the following class definitions (example #1):
>
> class X {
> public final static function test() {
> static $i;
> return ++$i;
> }
> }
>
> class Y extends X {
> }
>
> By executing this code:
>
> echo X::test();
> echo Y::test(); // note Y class here
>
> one would expect to see "12" as output, but apparently I get "11".
>
> That's a bit confusing if you logically assume that "static vars" are "tied
> to the scope" they're defined in. Since this static variable is
> defined in a specific static method test(), that is NOT overloaded by class
> Y, in my opinion it shoul've preserved it's value across static calls.
>
> Let's look at another example (example #2):
>
> class X {
> public static $x =0;
> public final static function test() {
> return ++static::$x; // note static keyword here
> }
> }
>
> class Y extends X {
> }
>
> If you run this code:
>
> echo X::test();
> echo Y::test();
>
> you get "12" as output - the expected output. Notice that the
> "++static::$x"
> expr. is taking advantage of late static binding. Now, if you change
> body of test() to the following code:
>
> public final static function test() {
> return ++self::$x;
> }
>
> then you also get "12" as output.
>
> Is this a bug that static context of $i is not preserved in example #1 or
> do
> I misunderstand something?
>
> I could not find any hints on this in the PHP documentation.
>
> Dmitry.
>
--- End Message ---
--- Begin Message ---
Jim Giner wrote:
> Eureka!
>
> The whole problem was my unfamiliarity with the php download page. To
> others - read the choices there very carefully (which I thought I did!) to
> be sure you get the "thread-safe" version.
>
> Thanks to all who contributed, but David gets the kudos for telling me to
> check the error logs first.
As you become more familiar with managing apache yourself, you will learn
that checking the error log is the 0th thing to do with any apache or
apache related problem, including 500 errors from CGI scripts and checking
for php errors.
Cheers
--
David Robley
Windows N'T: as in Wouldn't, Couldn't, and Didn't.
Today is Boomtime, the 41st day of Confusion in the YOLD 3177.
--- End Message ---
--- Begin Message ---
Hi all,
OK. We all know that constants cannot be accessed directly via their name
in double-quoted or heredoc strings. I knew this already but a read of
the PHP manual got me thinking.
The manual states that to get the $$ value of a variable, the form
"{${var}}" should be used. Therefore, I wondered if something similar
would work for constants.
Attempt 1 (just to be sure):
<?php
define ('XYZ','ABC');
echo "{XYZ}\n";
?>
Output - {XYZ}
Attempt 2:
<?php
define ('XYZ','ABC');
echo "{{XYZ}}\n";
?>
Output - {{XYZ}}
No luck there. I did encounter one oddity though:
<?php
define ('XYZ','ABC');
echo "{${XYZ}}\n";
?>
Output:
PHP Notice: Undefined variable: ABC in /home/wilsond/testScripts/l7.php
on line 3
Which appears to mean that PHP is able to pick up the value of the
constant and try to access a variable with that name.
Any ideas?
Cheers
Dave
--- End Message ---
--- Begin Message ---
On 7/6/2011 7:07 AM, Dave Wilson wrote:
Output - {XYZ}
Attempt 2:
<?php
define ('XYZ','ABC');
echo "{{XYZ}}\n";
?>
Output - {{XYZ}}
No luck there. I did encounter one oddity though:
<?php
define ('XYZ','ABC');
echo "{${XYZ}}\n";
?>
Output:
PHP Notice: Undefined variable: ABC in /home/wilsond/testScripts/l7.php
on line 3
Which appears to mean that PHP is able to pick up the value of the
constant and try to access a variable with that name.
Any ideas?
echo XYZ . "\n";
--Curtis
--- End Message ---
--- Begin Message ---
On Wed, Jul 6, 2011 at 12:07 PM, Dave Wilson <dai_bac...@hotmail.com> wrote:
> Hi all,
>
> OK. We all know that constants cannot be accessed directly via their name
> in double-quoted or heredoc strings. I knew this already but a read of
> the PHP manual got me thinking.
>
> The manual states that to get the $$ value of a variable, the form
> "{${var}}" should be used. Therefore, I wondered if something similar
> would work for constants.
>
> Attempt 1 (just to be sure):
> <?php
> define ('XYZ','ABC');
> echo "{XYZ}\n";
> ?>
>
> Output - {XYZ}
>
> Attempt 2:
> <?php
> define ('XYZ','ABC');
> echo "{{XYZ}}\n";
> ?>
>
> Output - {{XYZ}}
>
> No luck there. I did encounter one oddity though:
>
> <?php
> define ('XYZ','ABC');
> echo "{${XYZ}}\n";
> ?>
>
> Output:
> PHP Notice: Undefined variable: ABC in /home/wilsond/testScripts/l7.php
> on line 3
>
> Which appears to mean that PHP is able to pick up the value of the
> constant and try to access a variable with that name.
>
> Any ideas?
>
My guess is that the preceding $ causes PHP to interpret the next token
"{XYZ}" as a variable or a constant, but without that preceding $ it has no
way to know you're trying to use a constant. As Curtis points out, the only
way to insert a constant into a string is through concatenation.
-Stuart
--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
--- End Message ---
--- Begin Message ---
>> Any ideas?
>>
>echo XYZ . "\n";
>
>
>
>--Curtis
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
Which doesn't answer the original question Dave asked...
Thanks,
Ash
http://www.ashleysheridan.co.uk
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
--- End Message ---
--- Begin Message ---
On Wednesday, July 6, 2011, Dave Wilson wrote:
> OK. We all know that constants cannot be accessed directly via their
> name in double-quoted or heredoc strings.
FWIW, this looked like it might be a right royal PITA for me ATM.
However, I've got a work-around.
With about a dozen scripts written using 'heredoc', I discover the
need to include extra information for which I required a constant. The
answer for me was to initialize a variable to have the same value as
the constant and to use that in the heredoc string. e.g:
define ('KONST', 100);
$konst = KONST;
echo <<<END
Some sample text in which we need $konst
END;
A similar approach is to declare a 'pseudo-constant' variable instead
of defining the constant (e.g. $konst=100 instead of the first two
lines of code in the above sample).
HTH,
--
Geoff
--- End Message ---
--- Begin Message ---
And that's exactly how I did it :)
Since 'for' is traditionally pre-testing with excetuting the condition prior
looping it's working well :)
Thanks for all the help!
Cheers,
Tamas
-----Original Message-----
From: Louis Huppenbauer [mailto:louis.huppenba...@gmail.com]
Sent: Tuesday, July 05, 2011 5:47 PM
To: Robert Cummings
Cc: Dajka Tamás; php-gene...@lists.php.net
Subject: Re: [PHP] Foreach question
Just use count($arr) in your for-header, as it get's executed again
for each loop.
<?php
$arr = array(array('id'=>1), array('id'=>2));
for($i=0;$i<count($arr);$i++) {
echo $arr[$i]['id'];
if($i < 6) {
$arr[] = array('id' => $arr[$i]['id']+1);
}
}
?>
2011/7/5 Robert Cummings <rob...@interjinn.com>:
> On 11-07-05 10:48 AM, Dajka Tamás wrote:
>>
>> Thanks, that was interesting :) I think I got one step further in
>> understanding PHP :)
>>
>> BTW, I've changed the loop to 'for' and it's working well :)
>
> Can you show us your for loop? I'm not immediately sure how you use a for
> loop to traverse a growing number of entries in an array without either
> updating the extents of the traversal or using for( ; ; ) which is the same
> as while( 1 ). Or are you now using the low level array traversal functions
> like reset() and next()?
>
> Cheers,
> Rob.
> --
> E-Mail Disclaimer: Information contained in this message and any
> attached documents is considered confidential and legally protected.
> This message is intended solely for the addressee(s). Disclosure,
> copying, and distribution are prohibited unless authorized.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---