php-general Digest 28 May 2011 05:52:35 -0000 Issue 7331
Topics (messages 313163 through 313180):
Re: Need pro advice: Is Pear installed and/or setup correctly?
313163 by: Micky Hulse
313164 by: Philip Thompson
313165 by: Micky Hulse
313166 by: Micky Hulse
313168 by: Micky Hulse
phpsadness
313167 by: Daevid Vincent
313169 by: David Harkness
313170 by: Richard Quadling
313171 by: Robert Cummings
313172 by: Nathan Nobbe
313174 by: Robert Cummings
313178 by: Daniel Brown
Re: Detecting HTTPS connections under Apache
313173 by: Geoff Shang
313179 by: Curtis Maurand
Urgent help - Token Generation code!
313175 by: Shreyas Agasthya
313176 by: Jasper Mulder
313177 by: Jasper Mulder
What's up with Quercus?
313180 by: Arnold Hesnod
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:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
On Fri, May 27, 2011 at 10:27 AM, Micky Hulse
<[email protected]> wrote:
> Would it be safe for me to conclude that Pair is not setup properly?
Haha, "Pear" the package, not the host. :D
http://www.pair.com/
Typo. My bad.
Also, what the heck does this mean:
"It is not safe to rely on the system's timezone settings. Please use
the date.timezone setting, the TZ environment variable or the
date_default_timezone_set() function. In case you used any of those
methods and you are still getting this warning, you most likely
misspelled the timezone identifier. We selected 'America/New_York' for
'EDT/-4.0/DST' instead in /home/USER/public_html/test.php on line 6"
Never seen that warning message before when including files... Like I
said, I know nothing about this host, but so far I am wondering if
they have things setup properly?
Thanks for listening.
Cheers,
Micky
--- End Message ---
--- Begin Message ---
On Fri, May 27, 2011 at 1:36 PM, Micky Hulse <[email protected]>wrote:
> On Fri, May 27, 2011 at 10:27 AM, Micky Hulse
> <[email protected]> wrote:
> > Would it be safe for me to conclude that Pair is not setup properly?
>
> Haha, "Pear" the package, not the host. :D
>
> http://www.pair.com/
>
> Typo. My bad.
>
> Also, what the heck does this mean:
>
> "It is not safe to rely on the system's timezone settings. Please use
> the date.timezone setting, the TZ environment variable or the
> date_default_timezone_set() function. In case you used any of those
> methods and you are still getting this warning, you most likely
> misspelled the timezone identifier. We selected 'America/New_York' for
> 'EDT/-4.0/DST' instead in /home/USER/public_html/test.php on line 6"
>
The host is apparently using PHP 5.3 - this message started to appear in
this version. Use date_default_timezone_set() somewhere in your code to
explicitly set your timezone. I'm in the central US, so I use
'America/Chicago'. See the docs for more info.
Not sure about your original question.
Happy coding,
~Philip
http://lonestarlightandsound.com/
--- End Message ---
--- Begin Message ---
On Fri, May 27, 2011 at 12:06 PM, Philip Thompson
<[email protected]> wrote:
> The host is apparently using PHP 5.3 - this message started to appear in
> this version. Use date_default_timezone_set() somewhere in your code to
> explicitly set your timezone. I'm in the central US, so I use
> 'America/Chicago'. See the docs for more info.
Thanks Philip! I will give that a try. :)
Testing now...
Nice! That helped! :)
date_default_timezone_set('America/Los_Angeles');
Now all I got to do is convince my friend that the host needs to add
Pear to the include path (at least, I think this is the problem with
Pear).
Thanks again Philip!
Have a great day.
Cheers,
Micky
--- End Message ---
--- Begin Message ---
Looks like the host changed my include path:
(include_path='.:/usr/lib/php:/usr/local/lib/php:/usr/local/lib/php/PEAR')
I am still getting "file not found" include errors.
I am guess that Mail.php and Mail_Mime/mime.php are extras that are
not installed.
This is my first time trying to use Pear. Normally I use other code
for sending emails with attachments...
I think my friend setup an e-mail form using this tutorial:
http://www.html-form-guide.com/email-form/php-email-form-attachment.html
He could not get it to work, and I am just trying to get it to work for him.
I will probably ditch the whole Pear idea and use something else.
I hate working for free! :D
Thanks for listening all.. Sorry to bug the list with my crud.
Cheers,
Micky
--- End Message ---
--- Begin Message ---
On Fri, May 27, 2011 at 12:48 PM, Micky Hulse <[email protected]> wrote:
> Looks like the host changed my include path:
> I will probably ditch the whole Pear idea and use something else.
Well, actually, it looks like having PEAR on the include path did help.
Mail.php was found... It was Mail_Mime/mime.php that was not getting found.
This seems totally hackish, but I had to download Mail_Mime and put it
in the web root of my friend's server:
http://pear.php.net/package/Mail_Mime/download
And changed the Mail_Mime include path to point to the new location
and it worked.
What a headache. Lol.
Problem solved. Thanks for the help Philip, and thanks for listening all!
Have a nice day.
Cheers,
Micky
--- End Message ---
--- Begin Message ---
A friend sent me this URL today. While amusing, he's got many valid points
and I certainly share in his frustration.
http://www.phpsadness.com
--- End Message ---
--- Begin Message ---
On Fri, May 27, 2011 at 12:52 PM, Daevid Vincent <[email protected]> wrote:
> A friend sent me this URL today. While amusing, he's got many valid points
> and I certainly share in his frustration.
>
> http://www.phpsadness.com
>
Some points are valid, but many others show a lack of understanding of PHP
and OOP in general.
* #18 (as stated) is intentional. If you want an instance property--use an
instance property! A static variable in an instance method could do one of
two things: create a static variable private to the method or an instance
variable private to the method. But using "static" to create an instance
property would be very confusing.
* #24 on reflection methods. I agree that the lack of documentation is sad,
but allowsNull() and isOptional() are definitely separate. Any parameter
with a type hint (array or class) will allow null only if it has a null
default value. So a parameter can be optional and disallow null and vice
versa.
* #33 The point of private methods is to block subclasses (and other
classes) from accessing or overriding them. Yes, it makes mocking them
impossible, but this is a core OOP concept. Make those methods protected and
put a comment on them stating that they should not be overridden by
subclasses if you need to mock them.
* #41 You can create a final class with a private constructor or better yet
simply *avoid* instantiating the class. Problem solved. Seriously, who cares
if someone instantiates your class full of static methods?
Hopefully we're all a little less sad now. :)
David
--- End Message ---
--- Begin Message ---
On 27 May 2011 20:52, Daevid Vincent <[email protected]> wrote:
> A friend sent me this URL today. While amusing, he's got many valid points
> and I certainly share in his frustration.
>
> http://www.phpsadness.com
WOW. That's a LOT of unhappiness.
http://twitter.com/#!/topaz2078/status/73982006681276416
--
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea
--- End Message ---
--- Begin Message ---
On 11-05-27 03:52 PM, Daevid Vincent wrote:
A friend sent me this URL today. While amusing, he's got many valid points
and I certainly share in his frustration.
http://www.phpsadness.com
What a whiner!
Many of the things listed are things which give PHP character and history.
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.
--- End Message ---
--- Begin Message ---
On Fri, May 27, 2011 at 3:52 PM, Robert Cummings <[email protected]>wrote:
> On 11-05-27 03:52 PM, Daevid Vincent wrote:
>
>> A friend sent me this URL today. While amusing, he's got many valid points
>> and I certainly share in his frustration.
>>
>> http://www.phpsadness.com
>>
>
> What a whiner!
>
> Many of the things listed are things which give PHP character and history.
>
Too bad it's not a blog post with a comments section.
I'd point him to the internals list :)
-nathan
--- End Message ---
--- Begin Message ---
On 11-05-27 05:54 PM, Nathan Nobbe wrote:
On Fri, May 27, 2011 at 3:52 PM, Robert Cummings <[email protected]
<mailto:[email protected]>> wrote:
On 11-05-27 03:52 PM, Daevid Vincent wrote:
A friend sent me this URL today. While amusing, he's got many
valid points
and I certainly share in his frustration.
http://www.phpsadness.com
What a whiner!
Many of the things listed are things which give PHP character and
history.
Too bad it's not a blog post with a comments section.
I'd point him to the internals list :)
It's common trait of whiners to give criticism but not take any :)
Cheers,
Rob.
Ps. have a great weekend everyone!
--
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.
--- End Message ---
--- Begin Message ---
On Fri, May 27, 2011 at 17:59, Robert Cummings <[email protected]> wrote:
>
> It's common trait of whiners to give criticism but not take any :)
Where's my "Like" button when I need it?
--
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/
--- End Message ---
--- Begin Message ---
On Thu, 26 May 2011, [email protected] wrote:
So when you echo $_SERVER['SERVER_PORT'];
You get port 80 even if the url currently is https://www.yoursite.com ?
Yes.
If this is the case good luck. Because you have serious issues.
OK. This on its own is not particularly helpful. Surely I can't be the
only person in the universe who has experienced this. I'm running a
minimally-altered stock Debian Apache and PHP setup.
Geoff.
--- End Message ---
--- Begin Message ---
$_SERVER['HTTPS']
<?php
if($_SERVER['HTTPS']){
echo 'you are secured';
}else{
echo 'you are not secured';
}
?>
--Curtis
On 5/26/2011 3:37 PM, Geoff Shang wrote:
Hi,
Apologies if this is covered somewhere but I've searched fairly
extensively and not found anything.
I'm working on an application which has a function for redirecting to
a given URL. This is generally used for redirecting after a form has
been submitted.
Right now it sends an HTTP URL in the redirection, which means it
can't work under a secure connection.
I'd like to be able to use it over HTTPS but don't want to force
people to do this. So ideally I'd like to be able to detect the
protocol in use and send the appropriate protocol in the Location header.
The problem is that, at least on the system I'm working on, I can't
see any way of detecting the protocol. _SERVER["SERVER_SIGNATURE"]
and _SERVER["SERVER_ADDR"] both give the port as 80, even if I specify
port 443 in the URL. I've seen references to _SERVER["HTTPS"] or
something similar but it's not in the output I get from either
"print_r ($_SERVER)" or "phpinfo ()".
I'm running PHP Version 5.3.3-7+squeeze1 on Apache/2.2.16 (Debian).
The machine is an x86-64 VPS running Debian Squeeze.
I have full access to the VPS, so if something needs tweeking in
Apache (or anything else) then I can do this.
Thanks in advance,
Geoff.
--- End Message ---
--- Begin Message ---
I am re-visiting the world of PHP after a really big hiatus and I am finding
things veryslippery. Can someone please help me with the below code and let
me know how I can print the token that is getting generated?
I am using EasyPHP and I am trying to echo the $token but it wouldn't print
anything. I am trying it as : http://localhost/token/URLToken.php. May I
know where all I am going wrong here in my approach?
<?php
$sUrl = "/tstd_c_b1@s54782";
$sParam = "primaryToken";
$nTime = time();
$nEventDuration = 86400;
$nWindow = $nTime + $nEventDuration;
$sSalt = "akamai123!";
$sExtract = ""; // optional
function urlauth_gen_url($sUrl, $sParam, $nWindow,
$sSalt, $sExtract, $nTime) {
$sToken = urlauth_gen_token($sUrl, $nWindow, $sSalt,
$sExtract, $nTime);
echo $token;
if ($sToken == null) {
return ;
}
if (($sParam == "") || (!is_string($sParam))) {
$sParam = "__gda__";
}
if ((strlen($sParam) < 5) || (strlen($sParam) > 12)) {
return;
}
if (($nWindow < 0) || (!is_integer($nWindow))) {
return;
}
if (($nTime <= 0) || (!is_integer($nTime))) {
$nTime = time();
}
$nExpires = $nWindow + $nTime;
if (strpos($sUrl, "?") === false) {
$res = $sUrl . "?" . $sParam . "=" . $nExpires . "_" . $sToken;
} else {
$res = $sUrl . "&" . $sParam . "=" . $nExpires . "_" . $sToken;
}
return $res;
}
/**
* Returns the hash portion of the token. This function should not be
* called directly.
*/
function urlauth_gen_token($sUrl, $nWindow, $sSalt,
$sExtract, $nTime) {
if (($sUrl == "") || (!is_string($sUrl))) {
return;
}
if (($nWindow < 0) || (!is_integer($nWindow))) {
return;
}
if (($sSalt == "") || (!is_string($sSalt))) {
return;
}
if (!is_string($sExtract)) {
$sExtract = "";
}
if (($nTime <= 0) || (!is_integer($nTime))) {
$nTime = time();
}
$nExpires = $nWindow + $nTime;
$sExpByte1 = chr($nExpires & 0xff);
$sExpByte2 = chr(($nExpires >> 8) & 0xff);
$sExpByte3 = chr(($nExpires >> 16) & 0xff);
$sExpByte4 = chr(($nExpires >> 24) & 0xff);
$sData = $sExpByte1 . $sExpByte2 . $sExpByte3 . $sExpByte4
. $sUrl . $sExtract . $sSalt;
$sHash = _unHex(md5($sData));
$sToken = md5($sSalt . $sHash);
return $sToken;
}
/**
* Helper function used to translate hex data to binary
*/
function _unHex($str) {
$res = "";
for ($i = 0; $i < strlen($str); $i += 2) {
$res .= chr(hexdec(substr($str, $i, 2)));
}
return $res;
}
?>
--
Regards,
Shreyas Agasthya
--- End Message ---
--- Begin Message ---
----------------------------------------
> From: [email protected]
> To: [email protected]
> Subject: RE: [PHP] Urgent help - Token Generation code!
> Date: Sat, 28 May 2011 00:41:02 +0200
>
>
> ----------------------------------------
> > Date: Sat, 28 May 2011 03:56:26 +0530
> > From: [email protected]
> > To: [email protected]
> > Subject: [PHP] Urgent help - Token Generation code!
> >
> > I am re-visiting the world of PHP after a really big hiatus and I am finding
> > things veryslippery. Can someone please help me with the below code and let
> > me know how I can print the token that is getting generated?
> >
> > I am using EasyPHP and I am trying to echo the $token but it wouldn't print
> > anything. I am trying it as : http://localhost/token/URLToken.php. May I
> > know where all I am going wrong here in my approach?
> >
> > >
> > $sUrl = "/tstd_c_b1@s54782";
> > $sParam = "primaryToken";
> > $nTime = time();
> > $nEventDuration = 86400;
> > $nWindow = $nTime + $nEventDuration;
> > $sSalt = "akamai123!";
> > $sExtract = ""; // optional
> >
> >
> > function urlauth_gen_url($sUrl, $sParam, $nWindow,
> > $sSalt, $sExtract, $nTime) {
> >
> >
> >
> > $sToken = urlauth_gen_token($sUrl, $nWindow, $sSalt,
> > $sExtract, $nTime);
> > echo $token;
>
> There are two cases:
> 1. You made a typo and meant 'echo $sToken;' on the above line instead
> 2. You omitted the part where $token is defined and used
>
> > [More code that seemed fine]
> >
> > --
> > Regards,
> > Shreyas Agasthya
>
> Best regards,
> Jasper Mulder
>
I forgot to hit Reply All instead of Reply.
I am deeply sorry for such a careless omission.
Best regards,
Jasper Mulder
--- End Message ---
--- Begin Message ---
----------------------------------------
> From: [email protected]
> To: [email protected]
> Subject: Re: [PHP] Urgent help - Token Generation code!
> Date: Sat, 28 May 2011 04:15:59 +0530
>
> Jasper,
>
> Tried echoing $sToken but wouldn't work.
>
> Regards,
> Shreyas
>
> On 28-May-2011, at 4:11 AM, Jasper Mulder
> wrote:
>
> >
> > ----------------------------------------
> >> Date: Sat, 28 May 2011 03:56:26 +0530
> >> From: [email protected]
> >> To: [email protected]
> >> Subject: [PHP] Urgent help - Token Generation code!
> >>
> >> I am re-visiting the world of PHP after a really big hiatus and I
> >> am finding
> >> things veryslippery. Can someone please help me with the below code
> >> and let
> >> me know how I can print the token that is getting generated?
> >>
> >> I am using EasyPHP and I am trying to echo the $token but it
> >> wouldn't print
> >> anything. I am trying it as : http://localhost/token/URLToken.php.
> >> May I
> >> know where all I am going wrong here in my approach?
> >>
> >>>
> >> $sUrl = "/tstd_c_b1@s54782";
> >> $sParam = "primaryToken";
> >> $nTime = time();
> >> $nEventDuration = 86400;
> >> $nWindow = $nTime + $nEventDuration;
> >> $sSalt = "akamai123!";
> >> $sExtract = ""; // optional
> >>
As a second try, what happens if you add right here the line
$sGen = urlauth_gen_url($sUrl, $sParam, $nWindow, $sSalt, $sExtract, $nTime);
Because it seems as though you just declare three functions in the code
without calling them...
> >>
> >> function urlauth_gen_url($sUrl, $sParam, $nWindow,
> >> $sSalt, $sExtract, $nTime) {
> >>
> >>
> >>
> >> $sToken = urlauth_gen_token($sUrl, $nWindow, $sSalt,
> >> $sExtract, $nTime);
> >> echo $token;
> >
> > There are two cases:
> > 1. You made a typo and meant 'echo $sToken;' on the above line instead
> > 2. You omitted the part where $token is defined and used
> >
> >> [More code that seemed fine]
> >>
> >> --
> >> Regards,
> >> Shreyas Agasthya
> >
Best regards,
Jasper Mulder
--- End Message ---
--- Begin Message ---
Although I've been mostly using Java and Ruby in my professional software
development work for the past decade or so, in the past two or three years I've
started to do more and more PHP. I originally started using PHP because I
needed to set-up and customize Drupal for a project. Although as a programmer
I've come to feel comfortable writing PHP code, I still don't feel like I have
a good sense of where PHP is going as a platform and what's it's future is. As
the Drupal site has continued to grow both in terms of features and usage, it's
become clear that this is something that I need to research and educate myself
about.
That led me to give a closer look at Quercus, the implementation of PHP 5 that
runs on top of the JVM. I'd already heard about it somewhere along the line,
but it's only in the past couple of weeks that I've actually pulled it down,
read through the documentation and some of the source and tried it out. So far
I'm pretty impressed and enthusiastic about it. The cancellation of PHP 6
combined with the steady trickle of PHP-related bugs and security
vulnerabilities that have become public over the past few years had made me
very nervous about the future of the platform. Having an open-source
implementation of PHP that runs on the JVM, which is like the gold standard for
server application performance and reliability, is reassuring. The fact that
it makes it easy and fast to use the huge library of Java frameworks out there
in your PHP applications doesn't hurt either.
Although I've had great results so far in my experiments with Quercus, I'm
curious to hear about other PHP developers' experiences with it. Even though
it seems like a significant number of people are using it for production
applications, I'm curious why it's adoption isn't even higher than it is?
Given the difficulties of writing a Virtual Machine, it seems like leveraging
the JVM is a no brainer. Is there some technical drawback that I'm unaware of
or is it just a case of inertia?
Thanks.
-- Arnold
--- End Message ---