php-general Digest 24 Jul 2010 22:11:23 -0000 Issue 6863
Topics (messages 307127 through 307135):
Re: opening link in new window
307127 by: Robert Cummings
307128 by: Adam Richardson
307130 by: tedd
307131 by: Robert Cummings
307132 by: Andre Polykanine
307133 by: Ashley Sheridan
Re: Does class length slow down performance
307129 by: Nathan Rixham
Error on Signing & Encrypting PayPal Website Payment Button with openssl_
307134 by: Keith
Re: SOAP ERROR - Encoding
307135 by: Richard Quadling
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 10-07-24 02:06 AM, Paul M Foster wrote:
On Sat, Jul 24, 2010 at 01:08:49AM -0400, Robert Cummings wrote:
On 10-07-24 12:58 AM, Paul M Foster wrote:
On Fri, Jul 23, 2010 at 01:28:23AM -0400, David Mehler wrote:
Hello,
I've got a page with an external link. I'd like to open it in a new
window, but i'm using the xhtml 1.0 strict dtd so this isn't possible.
I was wondering if php could pull this off? Failing that, and not
really wanting to go there, would javascript work for this?
Thanks.
Dave.
I take it
<A HREF="newwindow.html" TARGET="_blank">a new window</A>
is not part of the xhtml 1.0 strict dtd? Because I recently solved this
problem using the above syntax.
The GP is correct, target="_blank" is not valid XHTML 1.0 strict.
Here's some JavaScript to put in your page and run once the page
completes loading. It looks for anchors having rel="nofollow" and
rel="external" attributes in anchors and adds a target="_blank" attribute.
function bahHumbugExternalLinks()
{
if( !document.getElementsByTagName )
{
return;
}
var anchor = null;
var anchors = document.getElementsByTagName( 'a' );
for( var i = 0; i< anchors.length; i++ )
{
anchor = anchors[i];
if( anchor.getAttribute( 'href' ) )
{
if( anchor.getAttribute( 'rel' ) == 'nofollow'
||
anchor.getAttribute( 'rel' ) == 'external' )
{
anchor.target = "_blank";
}
}
}
}
You know, if you're going to sneak target="_blank" in the back way in
order to avoid antagonizing the xhtml 1.0 deities, it seems like it'd be
easier to just say:
<?php echo '<A HREF="newwindow.html" TARGET="_blank">a new window</A>';
?>
Or, wait. With javascript, you're hacking the DOM. If you put my PHP
above in the file, the offending code will arrive at the client browser.
Will the xhtml 1.0 deities cast you into the pit of hell if this
happens?
Canadian Federal Government requires that all public government websites
validate to XHTML 1.0 strict. The validation is performed on what
arrives at the browser, not what arrives at the PHP interpreter :)
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 Sat, Jul 24, 2010 at 2:44 AM, Robert Cummings <[email protected]>wrote:
> On 10-07-24 02:06 AM, Paul M Foster wrote:
>
>> On Sat, Jul 24, 2010 at 01:08:49AM -0400, Robert Cummings wrote:
>>
>> On 10-07-24 12:58 AM, Paul M Foster wrote:
>>>
>>>> On Fri, Jul 23, 2010 at 01:28:23AM -0400, David Mehler wrote:
>>>>
>>>> Hello,
>>>>> I've got a page with an external link. I'd like to open it in a new
>>>>> window, but i'm using the xhtml 1.0 strict dtd so this isn't possible.
>>>>> I was wondering if php could pull this off? Failing that, and not
>>>>> really wanting to go there, would javascript work for this?
>>>>> Thanks.
>>>>> Dave.
>>>>>
>>>>
>>>> I take it
>>>>
>>>> <A HREF="newwindow.html" TARGET="_blank">a new window</A>
>>>>
>>>> is not part of the xhtml 1.0 strict dtd? Because I recently solved this
>>>> problem using the above syntax.
>>>>
>>>
>>> The GP is correct, target="_blank" is not valid XHTML 1.0 strict.
>>>
>>> Here's some JavaScript to put in your page and run once the page
>>> completes loading. It looks for anchors having rel="nofollow" and
>>> rel="external" attributes in anchors and adds a target="_blank"
>>> attribute.
>>>
>>> function bahHumbugExternalLinks()
>>> {
>>> if( !document.getElementsByTagName )
>>> {
>>> return;
>>> }
>>>
>>> var anchor = null;
>>> var anchors = document.getElementsByTagName( 'a' );
>>>
>>> for( var i = 0; i< anchors.length; i++ )
>>> {
>>> anchor = anchors[i];
>>>
>>> if( anchor.getAttribute( 'href' ) )
>>> {
>>> if( anchor.getAttribute( 'rel' ) == 'nofollow'
>>> ||
>>> anchor.getAttribute( 'rel' ) == 'external' )
>>> {
>>> anchor.target = "_blank";
>>> }
>>> }
>>> }
>>> }
>>>
>>>
>> You know, if you're going to sneak target="_blank" in the back way in
>> order to avoid antagonizing the xhtml 1.0 deities, it seems like it'd be
>> easier to just say:
>>
>> <?php echo '<A HREF="newwindow.html" TARGET="_blank">a new window</A>';
>> ?>
>>
>> Or, wait. With javascript, you're hacking the DOM. If you put my PHP
>> above in the file, the offending code will arrive at the client browser.
>> Will the xhtml 1.0 deities cast you into the pit of hell if this
>> happens?
>>
>
> Canadian Federal Government requires that all public government websites
> validate to XHTML 1.0 strict. The validation is performed on what arrives at
> the browser, not what arrives at the PHP interpreter :)
>
>
> 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
>
>
Code that resembled the below is how I used to open new windows before I
started using jQuery Note, this completely avoids use of the target
attribute.
function wireNewWindows(){
if(document.getElementsByTagName){
var anchors = document.getElementsByTagName("a");
for(var i = 0; i < anchors.length; i++){
var node = anchors[i];
if(node.getAttribute('rel') == 'external' ||
node.getAttribute('rel') == 'nofollow'){
node.onclick = function(){
var url = this.href;
window.open(
url,
'newWin','width=700,height=500,Menubar=yes,Toolbar=no,Location=no'
);
return false;
}
}
}
}
}
Adam
--
Nephtali: PHP web framework that functions beautifully
http://nephtaliproject.com
--- End Message ---
--- Begin Message ---
At 2:06 AM -0400 7/24/10, Paul M Foster wrote:
Or, wait. With javascript, you're hacking the DOM. If you put my PHP
above in the file, the offending code will arrive at the client browser.
Will the xhtml 1.0 deities cast you into the pit of hell if this
happens?
Paul
A minor clarification, it's not "hacking the DOM" -- it's simply DOM scripting.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
On 10-07-24 04:19 AM, Adam Richardson wrote:
Code that resembled the below is how I used to open new windows before I
started using jQuery Note, this completely avoids use of the target
attribute.
function wireNewWindows(){
if(document.getElementsByTagName){
var anchors = document.getElementsByTagName("a");
for(var i = 0; i< anchors.length; i++){
var node = anchors[i];
if(node.getAttribute('rel') == 'external' ||
node.getAttribute('rel') == 'nofollow'){
node.onclick = function(){
var url = this.href;
window.open(
url,
'newWin','width=700,height=500,Menubar=yes,Toolbar=no,Location=no'
);
return false;
}
}
}
}
}
I try to avoid window.open() due to the proliferation of popup blocking.
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 ---
Hi Rob and all,
Btw, is there a way to do window.close without any questions of a
browser? I know the only one: the window is generated via
window.open.
--
With best regards from Ukraine,
Andre
Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @
jabber.org
Yahoo! messenger: andre.polykanine; ICQ: 191749952
Twitter: m_elensule
----- Original message -----
From: Robert Cummings <[email protected]>
To: Adam Richardson <[email protected]>
Date: Saturday, July 24, 2010, 5:20:03 PM
Subject: [PHP] opening link in new window
On 10-07-24 04:19 AM, Adam Richardson wrote:
>
> Code that resembled the below is how I used to open new windows before I
> started using jQuery Note, this completely avoids use of the target
> attribute.
>
> function wireNewWindows(){
> if(document.getElementsByTagName){
> var anchors = document.getElementsByTagName("a");
> for(var i = 0; i< anchors.length; i++){
> var node = anchors[i];
> if(node.getAttribute('rel') == 'external' ||
> node.getAttribute('rel') == 'nofollow'){
> node.onclick = function(){
> var url = this.href;
> window.open(
> url,
>
> 'newWin','width=700,height=500,Menubar=yes,Toolbar=no,Location=no'
> );
> return false;
> }
> }
> }
> }
> }
I try to avoid window.open() due to the proliferation of popup blocking.
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 ---
--- Begin Message ---
On Sat, 2010-07-24 at 17:31 +0300, Andre Polykanine wrote:
> Hi Rob and all,
>
> Btw, is there a way to do window.close without any questions of a
> browser? I know the only one: the window is generated via
> window.open.
>
> --
> With best regards from Ukraine,
> Andre
> Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @
> jabber.org
> Yahoo! messenger: andre.polykanine; ICQ: 191749952
> Twitter: m_elensule
>
> ----- Original message -----
> From: Robert Cummings <[email protected]>
> To: Adam Richardson <[email protected]>
> Date: Saturday, July 24, 2010, 5:20:03 PM
> Subject: [PHP] opening link in new window
>
> On 10-07-24 04:19 AM, Adam Richardson wrote:
> >
> > Code that resembled the below is how I used to open new windows before I
> > started using jQuery Note, this completely avoids use of the target
> > attribute.
> >
> > function wireNewWindows(){
> > if(document.getElementsByTagName){
> > var anchors = document.getElementsByTagName("a");
> > for(var i = 0; i< anchors.length; i++){
> > var node = anchors[i];
> > if(node.getAttribute('rel') == 'external' ||
> > node.getAttribute('rel') == 'nofollow'){
> > node.onclick = function(){
> > var url = this.href;
> > window.open(
> > url,
> >
> > 'newWin','width=700,height=500,Menubar=yes,Toolbar=no,Location=no'
> > );
> > return false;
> > }
> > }
> > }
> > }
> > }
>
> I try to avoid window.open() due to the proliferation of popup blocking.
>
> 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
>
>
If the window wasn't generated by a script on the same domain as the one
trying to close it, then the user will be prompted.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
Sebastian Ewert wrote:
Hi,
I'm developing an joomla component and my helper an user classes are
crowing bigger and bigger. The helper class is for static use only.
Does class size decrease performance of my php scripts, even for static
usage?
Is there a general rule when to split a class to keep performance up?
If you think about it, each class, function, method, line of code all
gets interpreted in to opcodes and executed - so, no matter how you
split it up, it's still going to produce roughly equivalent opcodes.
Thus, no.
--- End Message ---
--- Begin Message ---
Hi, anyone has experience creating PayPal Encrypted Website Payment button?
I follow PayPal SDK example but the encrypted value is not correct.
I think the error should be with openssl_pkcs7_sign() since PayPal can
decrypt it with PayPal private key but does not recognize my signed data.
PayPal also told me that it is my encryption error.
Please kindly advice on the code below.
Thanks!
Keith
___________________________________________________________________________________________
//$buttonParams is key=value pair string with \n separation between each
key=value pair
$mypub = 'file://'.realpath('./mypubcert.pem');
$myprv = 'file://'.realpath('./myprvkey.pem');
$paypalpubcert= 'file://'.realpath('./paypal_cert_pem.pem');
$dataStrFile = realpath(tempnam('./tmp', 'pp_'));
$fd = fopen($dataStrFile, 'w');
fwrite($fd, $buttonParams);
fclose($fd);
$signedDataFile = realpath(tempnam('./tmp', 'pp_'));
openssl_pkcs7_sign($dataStrFile, $signedDataFile, $mypub, $myprv,array(),
PKCS7_BINARY);
unlink($dataStrFile);
$signedData = file_get_contents($signedDataFile);
$signedDataArray = explode("\n\n", $signedData); //I don't understand why
this code, just follow example only.
$signedData = base64_decode($signedDataArray[1]); //I don't understand why
this code, just follow example only.
unlink($signedDataFile);
$decodedSignedDataFile = realpath(tempnam('./tmp', 'pp_'));
$fd = fopen($decodedSignedDataFile, 'w');fwrite($fd,
$signedData);
fclose($fd);
$encryptedDataFile = realpath(tempnam('./tmp', 'pp_'));
openssl_pkcs7_encrypt($decodedSignedDataFile, $encryptedDataFile,
$paypalpubcert, array(), PKCS7_BINARY);
unlink($decodedSignedDataFile);
$encryptedData = file_get_contents($encryptedDataFile);
unlink($encryptedDataFile);
$encryptedDataArray = explode("\n\n", $encryptedData);
$encryptedData = trim(str_replace("\n", '', $encryptedDataArray[1])); //why
this?
$encryptedData = "-----BEGIN PKCS7-----".$encryptedData."-----END
PKCS7-----";
$encryptedBtn = "<form
action='https://www.sandbox.paypal.com/cgi-bin/webscr' method='post'><input
type='hidden' name='cmd' value='_s-xclick'><INPUT TYPE='hidden'
NAME='encrypted' VALUE='$encryptedData'><input type='image'
src='https://www.sandbox.paypal.com/en_US/i/btn/btn_paynowCC_LG.gif'
border='0' name='submit' alt='PayPal - The safer, easier way to pay
online!'><img alt='' border='0'
src='https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif' width='1'
height='1'></form>";
echo $encryptedBtn ;
_________________________________________________________________________________
--- End Message ---
--- Begin Message ---
On 22 July 2010 21:59, Augusto Flavio <[email protected]> wrote:
> Hi guys,
>
>
> I created a simple wsdl web service. Everything works fine, but when I fill
> the fields with accents and send the soap request, the PHP returns me an
> error:
>
>
> *Fatal error*: Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding:
> string 'ol\xe1...' is not a valid utf-8 string in PATH\cilent.php 16 Stack
> trace: #0 [internal function]: SoapClient->__call('Send', Array) #1
> PATH\cilent.php(16): SoapClient->Send(Array) #2 {main} thrown in *
> PATH\cilent.php* on line *16*
>
>
> I tested this same request using the eclipse web service explorer(It's a
> java client web service inside the eclipse IDE) and the response was ok.
>
>
> I found few topics about this issue on the google. One related solution to
> this problem is use the utf8_encode() function. I tried add this function
> before to send the soap request but didnt worked.
>
>
> I think that this problem is in the PHP soap client because using the
> eclipse web service explorer it works fine.
>
>
> Here is my php soap client:
>
>
> $client = new SoapClient('http://app/webservice.wsdl');
> $return = $client->Send(array('token' => '123123', 'message' => array(
> 'text' => 'This is a string with special characters á é í ó ú', 'dest' =>
> 'John', 'sender' => 'Augusto')));
>
> As I said I tried to use the utf8_encode() here:
>
> $return = $client->Send(array('token' => '123123', 'message' => array(
> 'text' => utf8_encode('This is a string with special characters á é í ó ú'),
> 'dest' => 'John', 'sender' => 'Augusto')));
>
> But the problem still.
>
> I tried also add the propertie defencoding in the soap server:
>
> $server->soap_defencoding = 'UTF-8';
>
> But still not working.
>
>
> What I'm missing?
>
>
>
> Thanks
>
>
>
> Augusto Morais
>
Not 100% sure on this, but, are you saving the source code in UTF-8 format?
If not, then the error is quite correct.
Also, utf8_encode() only deals with converting ISO-8859-1 to UTF-8,
so, again, if the source code is NOT in ISO-8859-1 then you are not
going to get the conversion.
--- End Message ---