php-general Digest 16 Nov 2011 00:04:49 -0000 Issue 7569

Topics (messages 315682 through 315703):

Using SimpleXMLIterator with a Iterator Filter.
        315682 by: Richard Quadling

Re: problem with sending AT command in php
        315683 by: Richard Quadling
        315684 by: Mike Mackintosh
        315685 by: Richard Quadling

Re: Sniping on the List
        315686 by: Tedd Sperling
        315687 by: tamouse mailing lists
        315688 by: Tamara Temple
        315689 by: Steven Staples
        315690 by: Eric Butera
        315692 by: Govinda

RSS Feed
        315691 by: Christopher Lee
        315693 by: Matijn Woudt
        315694 by: Christopher Lee
        315697 by: Tamara Temple

Safari and PDF
        315695 by: HallMarc Websites
        315696 by: Matijn Woudt
        315698 by: Ashley Sheridan
        315700 by: Tim Streater
        315702 by: Tamara Temple
        315703 by: HallMarc Websites

Think I found a PHP bug
        315699 by: Geoff Shang
        315701 by: Tim Streater

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 ---
Hi.

I can never seem to get the SPL right in my head.

So, I hope someone can help.

I have many XML streams that I can use SimpleXMLIterator on.

Each streams is structured slightly differently.

Some streams contain unused data and may or may not hold the data at
the same level in the stream.

I need to be able to filter out specific nodes on a per stream basis.

So, for example, in 1 stream, I only want to examine the /entry nodes,
not the /title, /id nodes.

In another, only the /products/product nodes.

Currently, code along the lines of the snippet below is functional ...

<?pseudo-php
// Get the stream.
$o_Stream = new SimpleXMLIterator($s_URL, 0, True);

// Add an xpath() filter if necessary.
if ('xxxx' === $s_URL) { $o_Stream->xpath('/products'); }
... (repeat as required for each URL that requires it)

// Iterate the stream.
foreach($o_Stream as $s_Tag => $o_Element) {
 // Filter out the unwanted tags, based upon the stream url.
 if ('xxxx' === $s_URL && 'entry' === $s_Tag) {
  // Process $o_Element
  $o_Product = new \FS\Product();
  $o_Product->id = (string)$o_Element->id;
  ... (process the remaining properties of the element into the product).
 }
 ... (repeat the filtering of the tags for each stream url)
}
?>

Whilst the code above works it is unwieldy and is getting more and
more complex as new streams become available. And so I need to
refactor it.


I would like to remove the specifics of the filtering and the
processing to a point that I can take a feed URL and a filter and get
back Products, irrespective of the feed or filter. e.g.

<?php
// Iterate the DB, getting the FilterClassName and the associated URL.
foreach($o_DB->getStreams() as $o_StreamInfo) {

  // Iterate the products for the URL (post filtering).
  foreach(new $o_StreamInfo->s_FilterClassName($o_StreamInfo->s_FeedUrl)
as $o_Product) {

    // The product is standardised irrespective of the feed or the filter.

  }

}

?>

(As an aside, the
$o_StreamInfo->s_FilterClassName($o_StreamInfo->s_FeedUrl) line works
fine. A property of a class containing the name of a class to be
instantiated.)



I cannot work out do I use FilterIterator or RecursiveFilterIterator
or something other.

I expect to have at least 1 concrete class per filter - some will be
shared amongst multiple streams. There may be an abstract base class
to consolidate any duplication.

I may also need a mapper class to take the data from the stream and
present it as a standardised Product. I suppose they are 2 separate
concerns and could be treated as such. At the moment, I do not have a
need to have a mapper apply to different streams structures, so
combining the mapper and the filter into 1 entity does work with the
existing data I have. But I think having them separate will help in
the long run.


But I just can't seem to get my head around this.

I think applying a filter to the SimpleXMLIterator is causing the
filter to examine every node. This is not what I want.


Any ideas, suggestions, reading. I've got the manual but the iterator
documentation isn't great. I don't know who knows this stuff inside
out, or how to describe things in a useful way for the documentation.

So. Help!

Regards,

Richard Quadling.


-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc : Fantasy Shopper
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea :
fan.sh/6/370

--- End Message ---
--- Begin Message ---
On 15 November 2011 11:50, a dehqan <dehqa...@gmail.com> wrote:
> \n is for Linux
> \r is for Windows
>
> On 11/14/11, Richard Quadling <rquadl...@gmail.com> wrote:
>> On 12 November 2011 20:02, a dehqan <dehqa...@gmail.com> wrote:
>>> dio_write($handle, 'AT') & dio_write($handle, "AT") make firefox times out
>>> on Waiting for localhost ... .
>>> But dio_write($handle, "AT\n") makes it prints AT exactly the same command
>>> or  Atttt > Atttt , ..
>>>
>>> On Sat, Nov 12, 2011 at 10:02 PM, Negin Nickparsa
>>> <nickpa...@gmail.com>wrote:
>>>
>>>> are you sure about ATD03518726535\n?
>>>>
>>>>  can you try if ( dio_write($handle, 'AT') )?
>>>>
>>>
>>
>> Don't use \n, use \r.
>>
>> http://en.wikipedia.org/wiki/AT_commands#Example_session
>>
>>
>>
>> --
>> Richard Quadling
>> Twitter : EE : Zend : PHPDoc : Fantasy Shopper
>> @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea :
>> fan.sh/6/370
>>
>

No, \r is the requirement of the modem. Nothing to do with the OS.

Windows uses \r\n as its line terminators, but when you talk to a
modem, you use \r.



-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc : Fantasy Shopper
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea :
fan.sh/6/370

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

On Nov 15, 2011, at 8:25, Richard Quadling <rquadl...@gmail.com> wrote:

> On 15 November 2011 11:50, a dehqan <dehqa...@gmail.com> wrote:
>> \n is for Linux
>> \r is for Windows
>> 
>> On 11/14/11, Richard Quadling <rquadl...@gmail.com> wrote:
>>> On 12 November 2011 20:02, a dehqan <dehqa...@gmail.com> wrote:
>>>> dio_write($handle, 'AT') & dio_write($handle, "AT") make firefox times out
>>>> on Waiting for localhost ... .
>>>> But dio_write($handle, "AT\n") makes it prints AT exactly the same command
>>>> or  Atttt > Atttt , ..
>>>> 
>>>> On Sat, Nov 12, 2011 at 10:02 PM, Negin Nickparsa
>>>> <nickpa...@gmail.com>wrote:
>>>> 
>>>>> are you sure about ATD03518726535\n?
>>>>> 
>>>>>  can you try if ( dio_write($handle, 'AT') )?
>>>>> 
>>>> 
>>> 
>>> Don't use \n, use \r.
>>> 
>>> http://en.wikipedia.org/wiki/AT_commands#Example_session
>>> 
>>> 
>>> 
>>> --
>>> Richard Quadling
>>> Twitter : EE : Zend : PHPDoc : Fantasy Shopper
>>> @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea :
>>> fan.sh/6/370
>>> 
>> 
> 
> No, \r is the requirement of the modem. Nothing to do with the OS.
> 
> Windows uses \r\n as its line terminators, but when you talk to a
> modem, you use \r.
> 
> 
> 
> -- 
> Richard Quadling
> Twitter : EE : Zend : PHPDoc : Fantasy Shopper
> @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea :
> fan.sh/6/370
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


I've had better luck with PHP_EOL instead of \r or \n.

--- End Message ---
--- Begin Message ---
On 15 November 2011 15:12, Mike Mackintosh
<mike.mackint...@angrystatic.com> wrote:
>
>
> On Nov 15, 2011, at 8:25, Richard Quadling <rquadl...@gmail.com> wrote:
>
>> On 15 November 2011 11:50, a dehqan <dehqa...@gmail.com> wrote:
>>> \n is for Linux
>>> \r is for Windows
>>>
>>> On 11/14/11, Richard Quadling <rquadl...@gmail.com> wrote:
>>>> On 12 November 2011 20:02, a dehqan <dehqa...@gmail.com> wrote:
>>>>> dio_write($handle, 'AT') & dio_write($handle, "AT") make firefox times out
>>>>> on Waiting for localhost ... .
>>>>> But dio_write($handle, "AT\n") makes it prints AT exactly the same command
>>>>> or  Atttt > Atttt , ..
>>>>>
>>>>> On Sat, Nov 12, 2011 at 10:02 PM, Negin Nickparsa
>>>>> <nickpa...@gmail.com>wrote:
>>>>>
>>>>>> are you sure about ATD03518726535\n?
>>>>>>
>>>>>>  can you try if ( dio_write($handle, 'AT') )?
>>>>>>
>>>>>
>>>>
>>>> Don't use \n, use \r.
>>>>
>>>> http://en.wikipedia.org/wiki/AT_commands#Example_session
>>>>
>>>>
>>>>
>>>> --
>>>> Richard Quadling
>>>> Twitter : EE : Zend : PHPDoc : Fantasy Shopper
>>>> @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea :
>>>> fan.sh/6/370
>>>>
>>>
>>
>> No, \r is the requirement of the modem. Nothing to do with the OS.
>>
>> Windows uses \r\n as its line terminators, but when you talk to a
>> modem, you use \r.
>>
>>
>>
>> --
>> Richard Quadling
>> Twitter : EE : Zend : PHPDoc : Fantasy Shopper
>> @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea :
>> fan.sh/6/370
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
>
> I've had better luck with PHP_EOL instead of \r or \n.

I think I've not explained myself properly.

The modem wants a carriage return. That is a \r.

It doesn't matter what OS you are on. If you don't send the right
string to the modem, then the modem won't process it properly.

If your OS maps \r to PHP_EOL, then, obviously PHP_EOL will be just
fine. But I would recommend ...

<?php
define('CR', chr(13));
?>



-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc : Fantasy Shopper
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea :
fan.sh/6/370

--- End Message ---
--- Begin Message ---
On Nov 14, 2011, at 12:51 PM, George Langley wrote:

>       Am concerned over the number of posts that appear to be from people 
> trying to over-inflate their self-importance.
>       If you are the world's best coder, then help those of us who aren't. If 
> you happen to know a better way to do something that I'm struggling with, 
> then please share it. But if you just want to take pot shots at us, then 
> please keep your comments to yourself.
> 
>       To that end, I wish to thank Ashley Sheridan, Daniel P. Brown, Tedd 
> Sperling and Tommy Pham, to name but just a few of those who have submitted 
> incredibly-helpful posts, that I have kept for reference. Your contributions 
> are very much appreciated - thanks.
> 
> George Langley
> Interactive Developer
> 

George:

Over-inflated self importance? That certainly sounds like me. :-)

On a serious note, don't be too hash on those who contribute -- keep in mind 
that in contributing we all learn -- this often includes the contributor as 
well. Nothing like being proven wrong to humble oneself.

For example, I teach this stuff and several times over the course of a semester 
I have had students ask questions and then question my answers. Then after 
investigation to find my answer wrong -- now that's humbling, but that's part 
of the leaning process.

So, my recommendation is to take and give what you can and leave judgement of 
the posters to the general audience -- the truth will win out.

Cheers,

tedd

PS: I know it's not Friday, but this question came up in class yesterday and I 
thought maybe all of you might like to guess why null is Wednesday?

_____________________
t...@sperling.com
http://sperling.com

--- End Message ---
--- Begin Message ---
On Tue, Nov 15, 2011 at 12:12 PM, Tedd Sperling <tedd.sperl...@gmail.com> wrote:
> PS: I know it's not Friday, but this question came up in class yesterday and 
> I thought maybe all of you might like to guess why null is Wednesday?

Wait.. What??

$ php -r 'echo date("l",NULL),"\n";'
Wednesday

Cos:

$ php -r 'echo date("r",NULL),"\n";'
Wed, 31 Dec 1969 18:00:00 -0600

(Personally, I would have thought Thursday should be NULL, but that's
just me. And Thursday.)

--- End Message ---
--- Begin Message --- On Tue, 15 Nov 2011 12:24:17 -0600, tamouse mailing lists <tamouse.li...@gmail.com> sent:
On Tue, Nov 15, 2011 at 12:12 PM, Tedd Sperling <tedd.sperl...@gmail.com> wrote:
PS: I know it's not Friday, but this question came up in class yesterday and I thought maybe all of you might like to guess why null is Wednesday?

Wait.. What??

$ php -r 'echo date("l",NULL),"\n";'
Wednesday

Cos:

$ php -r 'echo date("r",NULL),"\n";'
Wed, 31 Dec 1969 18:00:00 -0600

(Personally, I would have thought Thursday should be NULL, but that's
just me. And Thursday.)

Actually, It *is* Thursday if you use UTC:

$ TZ=UTC php -r 'echo date("r",NULL),"\n";'
Thu, 01 Jan 1970 00:00:00 +0000

:P


--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Tamara Temple [mailto:tamouse.li...@tamaratemple.com]
> Sent: November 15, 2011 1:33 PM
> To: php-gene...@lists.php.net
> Subject: Re: [PHP] Sniping on the List
> 
> On Tue, 15 Nov 2011 12:24:17 -0600, tamouse mailing lists
> <tamouse.li...@gmail.com> sent:
> > On Tue, Nov 15, 2011 at 12:12 PM, Tedd Sperling
> > <tedd.sperl...@gmail.com> wrote:
> >> PS: I know it's not Friday, but this question came up in class
> >> yesterday and I thought maybe all of you might like to guess why
> >> null is Wednesday?
> >
> > Wait.. What??
> >
> > $ php -r 'echo date("l",NULL),"\n";'
> > Wednesday
> >
> > Cos:
> >
> > $ php -r 'echo date("r",NULL),"\n";'
> > Wed, 31 Dec 1969 18:00:00 -0600
> >
> > (Personally, I would have thought Thursday should be NULL, but that's
> > just me. And Thursday.)
> 
> Actually, It *is* Thursday if you use UTC:
> 
> $ TZ=UTC php -r 'echo date("r",NULL),"\n";'
> Thu, 01 Jan 1970 00:00:00 +0000
> 
> :P

Perfect example of Tedd's last comment about being proven wrong (even though 
TECHNICALLY it isn't)

Good job :)


Steven Staples
Web Application Programmer




--- End Message ---
--- Begin Message ---
On Mon, Nov 14, 2011 at 12:51 PM, George Langley <george.lang...@shaw.ca> wrote:
>        Am concerned over the number of posts that appear to be from people 
> trying to over-inflate their self-importance.
>        If you are the world's best coder, then help those of us who aren't. 
> If you happen to know a better way to do something that I'm struggling with, 
> then please share it. But if you just want to take pot shots at us, then 
> please keep your comments to yourself.
>
>        To that end, I wish to thank Ashley Sheridan, Daniel P. Brown, Tedd 
> Sperling and Tommy Pham, to name but just a few of those who have submitted 
> incredibly-helpful posts, that I have kept for reference. Your contributions 
> are very much appreciated - thanks.
>
>
> George Langley
> Interactive Developer
>
> www.georgelangley.ca


You should have seen some of the lambasting that used to pass as
discourse back when this list had traffic.  :]

--- End Message ---
--- Begin Message ---
> 
> You should have seen some of the lambasting that used to pass as
> discourse back when this list had traffic.  :]

I have to (humbly) admit that I for one like it that this list has less traffic 
now....  because it gives the illusion that I am keeping up ;-)

-Govinda





--- End Message ---
--- Begin Message ---
Hello All,

I am interested in importing RSS Feed content into a MySQL database and 
displaying the aggregated content on a website. I am thinking of developing the 
website within a CMS type framework (i.e. Drupal). If anyone can refer me to 
any resources in this area then that would be great. I hope that I have 
adequately explained my needs. Thank you all in advance for your help.

Best,

Christopher
This message is for the designated recipient only and may contain privileged, 
proprietary, or otherwise private information. If you have received it in 
error, please notify the sender immediately and delete the original. Any other 
use of the email by you is prohibited.

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

Have you tried google?
I tried and top hit was this one:
http://stackoverflow.com/questions/1501394/writing-an-rss-feed-to-mysql-using-php

I guess that's all you need.

Matijn

On Tue, Nov 15, 2011 at 9:30 PM, Christopher Lee <ct...@ucensys.com> wrote:
> Hello All,
>
> I am interested in importing RSS Feed content into a MySQL database and 
> displaying the aggregated content on a website. I am thinking of developing 
> the website within a CMS type framework (i.e. Drupal). If anyone can refer me 
> to any resources in this area then that would be great. I hope that I have 
> adequately explained my needs. Thank you all in advance for your help.
>
> Best,
>
> Christopher
> This message is for the designated recipient only and may contain privileged, 
> proprietary, or otherwise private information. If you have received it in 
> error, please notify the sender immediately and delete the original. Any 
> other use of the email by you is prohibited.
>

--- End Message ---
--- Begin Message ---
Hello Matijn,

Thank you for the response and the link. I had not tried Google but, instead, 
reached out to the list first. Thought I would get people who have developed 
similar tools with success..:-) I will certainly reference the link and give 
this  try.

Best,

Christopher

-----Original Message-----
From: Matijn Woudt [mailto:tijn...@gmail.com]
Sent: Tuesday, November 15, 2011 4:38 PM
To: Christopher Lee
Cc: php-gene...@lists.php.net
Subject: Re: [PHP] RSS Feed

Hi,

Have you tried google?
I tried and top hit was this one:
http://stackoverflow.com/questions/1501394/writing-an-rss-feed-to-mysql-using-php

I guess that's all you need.

Matijn

On Tue, Nov 15, 2011 at 9:30 PM, Christopher Lee <ct...@ucensys.com> wrote:
> Hello All,
>
> I am interested in importing RSS Feed content into a MySQL database and 
> displaying the aggregated content on a website. I am thinking of developing 
> the website within a CMS type framework (i.e. Drupal). If anyone can refer me 
> to any resources in this area then that would be great. I hope that I have 
> adequately explained my needs. Thank you all in advance for your help.
>
> Best,
>
> Christopher
> This message is for the designated recipient only and may contain privileged, 
> proprietary, or otherwise private information. If you have received it in 
> error, please notify the sender immediately and delete the original. Any 
> other use of the email by you is prohibited.
>
This message is for the designated recipient only and may contain privileged, 
proprietary, or otherwise private information. If you have received it in 
error, please notify the sender immediately and delete the original. Any other 
use of the email by you is prohibited.

--- End Message ---
--- Begin Message ---
On Tue, 15 Nov 2011 20:30:29 +0000, Christopher Lee <ct...@ucensys.com> sent:
Hello All,

I am interested in importing RSS Feed content into a MySQL database and displaying the aggregated content on a website. I am thinking of developing the website within a CMS type framework (i.e. Drupal). If anyone can refer me to any resources in this area then that would be great. I hope that I have adequately explained my needs. Thank you all in advance for your help.

First of all, note that not all RSS feeds are the same. Some contain
information and tags that go far beyond the scope of the RSS
standard. Frequently (and hopefully!) these are in different name
spaces. I'll give an example:

If you look at the feed from the USGS on Mag 5+ earthquakes over the
past week at:

  < http://earthquake.usgs.gov/earthquakes/catalogs/eqs7day-M7.xml >

You will see these sorts of things in each entry:

      <item>
      <pubDate>Sun, 06 Nov 2011 03:53:10 GMT</pubDate>
      <title>M 5.2, Oklahoma</title>
      <description>November 06, 2011 03:53:10 GMT</description>
<link>http://earthquake.usgs.gov/earthquakes/recenteqsww/Quakes/usb0006klz.php</link>
      <geo:lat>35.5993</geo:lat>
      <geo:long>-96.7515</geo:long>
      <dc:subject>5</dc:subject>
      <dc:subject>pasthour</dc:subject>
      <dc:subject>5.00 km</dc:subject>
      <guid isPermaLink="false">usb0006klz</guid>
      </item>

The pubDate, title, description, link and guid tags are all part of
the RSS standard. The geo: and dc: tags are not, and are specified in
the opening rss tag:

     <rss version="2.0"
     xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#";
     xmlns:dc="http://purl.org/dc/elements/1.1/";>

by those xmlns attributes. So, unless you're lucky, almost any canned
solution for dealing with RSS might not work with any particular feed.

The best solution I've come up with just using SimpleXML (or one of
it's derivatives). Here's a quickie I wrote to test out the above
link:

$feed_raw = file_get_contents("http://earthquake.usgs.gov/earthquakes/catalogs/eqs1day-M2.5.xml";);
        $feed = new SimpleXMLElement($feed_raw);
        
$feed->registerXPathNamespace('geo','http://www.w3.org/2003/01/geo/wgs84_pos#');
        $feed->registerXPathNamespace('dc','http://purl.org/dc/elements/1.1/');

        echo "<pre>";
        print_r($feed->getNamespaces(TRUE));
        print_r($feed->getDocNamespaces(TRUE));
        echo "</pre>";

(I know these are going to get wrapped and possibly garbled. See here
for a better view: http://pastebin.com/6k7JPydX)

I really like using SimpleXML -- so far it's met pretty much all my
needs regarding parsing and handling XML data.



--- End Message ---
--- Begin Message ---
I'm sure everyone here is aware that the latest Mac OS and Safari 5.1.x do not 
support opening PDFs in the browser window with Acrobat Reader plugin anymore. 
It is now necessary to open them with Preview instead. My question is this, 
does anyone know if it is possible to force Safari to use Preview with PHP?


--- End Message ---
--- Begin Message ---
On Tue, Nov 15, 2011 at 11:08 PM, HallMarc Websites
<m...@hallmarcwebsites.com> wrote:
> I'm sure everyone here is aware that the latest Mac OS and Safari 5.1.x do 
> not support opening PDFs in the browser window with Acrobat Reader plugin 
> anymore. It is now necessary to open them with Preview instead. My question 
> is this, does anyone know if it is possible to force Safari to use Preview 
> with PHP?
>

Hi,

I don't have a Mac to test, but you can force PDF download with
Content-Disposition header in php. Look at Example 1 of the manual
page for the header function:
http://php.net/manual/en/function.header.php#example-3913
You might need some check if browser is Safari first..

Cheers,

Matijn

--- End Message ---
--- Begin Message ---
On Tue, 2011-11-15 at 23:15 +0100, Matijn Woudt wrote:

> On Tue, Nov 15, 2011 at 11:08 PM, HallMarc Websites
> <m...@hallmarcwebsites.com> wrote:
> > I'm sure everyone here is aware that the latest Mac OS and Safari 5.1.x do 
> > not support opening PDFs in the browser window with Acrobat Reader plugin 
> > anymore. It is now necessary to open them with Preview instead. My question 
> > is this, does anyone know if it is possible to force Safari to use Preview 
> > with PHP?
> >
> 
> Hi,
> 
> I don't have a Mac to test, but you can force PDF download with
> Content-Disposition header in php. Look at Example 1 of the manual
> page for the header function:
> http://php.net/manual/en/function.header.php#example-3913
> You might need some check if browser is Safari first..
> 
> Cheers,
> 
> Matijn
> 


I always thought that opening a PDF inside the browser was a rubbish
idea anyway. I've uninstalled Adobe Reader from my work machine now and
the world is a happier place!

-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
On 15 Nov 2011 at 22:36, Ashley Sheridan <a...@ashleysheridan.co.uk> wrote: 

> I always thought that opening a PDF inside the browser was a rubbish
> idea anyway. I've uninstalled Adobe Reader from my work machine now and
> the world is a happier place!

Well I'd rather it displays in the browser initially, which it does but not 
always (sometimes goes straight to disk). But if it shows in the browser window 
then there are buttons to save or open in Preview. I've not needed Acrobat on a 
Mac for years.

--
Cheers  --  Tim

--- End Message ---
--- Begin Message --- On Tue, 15 Nov 2011 22:36:58 +0000, Ashley Sheridan <a...@ashleysheridan.co.uk> sent:
On Tue, 2011-11-15 at 23:15 +0100, Matijn Woudt wrote:
On Tue, Nov 15, 2011 at 11:08 PM, HallMarc Websites
<m...@hallmarcwebsites.com> wrote:
> I'm sure everyone here is aware that the latest Mac OS and Safari 5.1.x do not support opening PDFs in the browser window with Acrobat Reader plugin anymore. It is now necessary to open them with Preview instead. My question is this, does anyone know if it is possible to force Safari to use Preview with PHP?

On the face of it, if you are writing a PHP application for others to
use, *forcing* a particular behaviour on them (on *their* own machine)
is probably not a good idea. Why not let the user deal with this as
they see fit? One can go way too far trying to ensure a uniform
experience among users, who may not even care what other users are
experiencing. One size *never* fits all.



--- End Message ---
--- Begin Message ---
> On the face of it, if you are writing a PHP application for others to use,
> *forcing* a particular behaviour on them (on *their* own machine) is
> probably not a good idea. Why not let the user deal with this as they see fit?
> One can go way too far trying to ensure a uniform experience among users,
> who may not even care what other users are experiencing. One size *never*
> fits all.
> 
> 
On the face of it; Apple needs to stop mucking with what already works! The 
issue is this, Apple in all of its wonderful glory decided to drop support for 
pdf via the acrobat plugin. Didn't bother to tell anyone about this. You now 
need to use their Preview feature ONLY if you want to view a pdf in your 
browser. Otherwise you get nothing but a big white empty screen. No notice, no 
warning, just a big white screen. Know what I've been getting from my clients? 
Grief! I'm the one writing the code for their site and since Apple can do no 
wrong it's me that must be the idiot.
[>] 

Sorry, just sick and tired of Apple trying to bring everything under their 
tightly locked proprietary software mitts. 

As to why do I want to do this... because it is better than telling my client 
that they need to give their clients instruction on how to view something they 
have been comfortably using and viewing without issue until recently. 




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

A couple of weeks ago, I discovered what I'm pretty sure is a PHP bug. In addition, I looked in the PHP changelog and I haven't seen any mention of a fix for it.

I'm writing here because I was wondering if anyone else can confirm it and what to do about it.

The bug is that if a server's timezone is set to Europe/London and you don't set an explicit timezone in your script, if it's winter time in the UK, PHP thinks the timezone is UTC instead of Europe/London.

Example:

First, lets confirm that the system time is in fact set to Europe/London.

$ cmp --verbose /etc/localtime /usr/share/zoneinfo/Europe/London
$ echo $?
0

Now lets see what PHP thinks it is.

$ php -r 'echo date_default_timezone_get();'
UTC

What about if we set it in the environment?

$ export TZ=Europe/London
$ php -r 'echo date_default_timezone_get();'
Europe/London

OK, so we appear to have an issue. But is this just semantics? Well no. consider the following (with TZ once again unset):

$ php -r 'echo date ("r", strtotime ("1 July 2011 12:00 pm"'
Fri, 01 Jul 2011 12:00:00 +0000

But of course, Europe/London isn't on +0000 in July.

$ export TZ=Europe/London
$ php -r 'echo date ("r", strtotime ("1 July 2011 12:00 pm"));'
Fri, 01 Jul 2011 12:00:00 +0100

The problem comes in when we view times created in one and printed in the other:

$ unset TZ
$ php -r 'echo strtotime ("1 July 2011 12:00 pm");'
1309521600
$ export TZ=Europe/London
$ php -r 'echo date ("r", 1309521600);'
Fri, 01 Jul 2011 13:00:00 +0100

And the opposite:

$ export TZ=Europe/London
$ php -r 'echo strtotime ("1 July 2011 12:00 pm");'
1309518000
$ unset TZ
$ php -r 'echo date ("r", 1309518000);'
Fri, 01 Jul 2011 11:00:00 +0000

This last one is what led me to discover this bug. We use automation software to run our Internet radio station. The playout system is written in C and the web front-end is written in PHP, with the data they work on the only point of commonality between them. The station was set up during the European summer. When the clocks changed, the playout system coped but the PHP front-end was showing everything an hour out.

Now of course, I personally can force the front-end to use Europe/London and it will work for me. And I guess ultimately it would make sense to program the system to allow the user to specify a timezone rather than relying on the server default. But right now it doesn't, and any solution would need to take the playout system into account.

At any rate, none of this is the point. If you're using the system default timezone, you expect it to (a) be correct and (b) be consistant.

Note that this bug may affect other timezones which are on UTC durin the winter or summer, but I've not tested any other timezones as this would mean changing the system timezone and I'm not real keen on doing that on any of my systems.

This bug was found on a Debian Squeeze system running the following version of PHP:

PHP 5.3.3-7+squeeze3 with Suhosin-Patch (cli) (built: Jun 28 2011 08:24:40)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

I realise this is 5.3.3 and that 5.3.8 is now out. It's possible that this has been fixed but I could not find any traces of such a fix in the changelogs.

I'd be interested to know if anyone else can confirm this bug and, if confirmed, what I should do about it.

Thanks,
Geoff.


--- End Message ---
--- Begin Message ---
On 15 Nov 2011 at 22:34, Geoff Shang <ge...@quitelikely.com> wrote: 

> The bug is that if a server's timezone is set to Europe/London and you
> don't set an explicit timezone in your script, if it's winter time in
> the UK, PHP thinks the timezone is UTC instead of Europe/London.

I find I need to do this:

  date_default_timezone_set (@date_default_timezone_get ());

in all my scripts since 5.x.x to avoid rude messages.

--
Cheers  --  Tim

--- End Message ---

Reply via email to