php-general Digest 1 Feb 2010 18:44:17 -0000 Issue 6569

Topics (messages 301705 through 301712):

Re: Appalling Dreamweaver performance
        301705 by: Richard Quadling
        301706 by: Ashley Sheridan
        301707 by: Allen McCabe
        301709 by: Adam Richardson

Including file from a registered shutown function on a syntax parse error
        301708 by: Marc Trudel

session variables and SVG documents
        301710 by: Aurelie REYMUND
        301711 by: Ashley Sheridan

magic_quotes_gpc on by default??
        301712 by: Rene Veerman

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 1 February 2010 00:28,  <[email protected]> wrote:
>
> I use Dreamweaver as my editor, mainly because I'm familiar with it, although 
> I only use
> about 1% of its capabilities. However it generally handles long files well.  
> The other day
> I downloaded the two shortest of Brian Dunning's sets of test data *.  I 
> opened the
> shortest in Dreamweaver, had a quick look at it, and realised I would have to 
> replace the
> quote, comma, quote separators with semicolons, as part of converting the 
> files to my
> format.
>
> So I thought I would do that while I was working out what else I had to do. I 
> entered the
> old separator and the replacement in the 'Find and replace' window, then hit 
> 'Replace
> all', expecting the job be done in a few seconds. First I thought nothing was 
> happening,
> but then I realised it was trudging through the file, as if it was wading 
> through waist
> high molasses.
>
> So I closed the results window, and opened another file, but a few seconds 
> later focus
> switched back to the original file. I tried a couple of times more, but each 
> time it
> returned to the original window. I watched in morbid fascination for a bit, 
> then decided I
> would let it go, just to see how long it took.
>
> The file contained 500 lines, and was about 80 K. It was taking five seconds 
> to process
> each line, and eventually finished in about 40 minutes.
>
> The problem appeared to be the results processing. I have only looked at the 
> results list
> about twice, out of idle curiosity, but never saw any thing that I thought 
> could be
> remotely useful. I would like to be able to turn results logging off 
> altogether, as it
> wastes real estate (and time!), but this appears to be impossible.
>
> On this occasion the program was apparently writing a new line every time it 
> replaced a
> separator (9 times in each line), and then when it finished processing a line 
> it would
> erase all the intermediate result lines, and write a new one for the whole 
> line.  At the
> same time it reopened the results window if I had closed it, and return focus 
> to the file
> being processed.
>
> I then wrote a PHP program to read the file, split it, clean up and 
> re-arrange the various
> elements, enter them into an array in my format, and finally save it as a 
> file my program
> could handle.
>
>  After I had got this running on the 500 line file I used it to process the 
> 5000 line
> file. The whole process was done in the blink of an eye -- literally a 
> fraction of a
> second.
>
>
> * http://www.briandunning.com/sample-data/
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

And the moral of the story is "Be happy that you learnt PHP!".


-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--- End Message ---
--- Begin Message ---
On Mon, 2010-02-01 at 11:28 +1100, [email protected] wrote:

> I use Dreamweaver as my editor, mainly because I'm familiar with it, although 
> I only use
> about 1% of its capabilities. However it generally handles long files well.  
> The other day
> I downloaded the two shortest of Brian Dunning's sets of test data *.  I 
> opened the
> shortest in Dreamweaver, had a quick look at it, and realised I would have to 
> replace the
> quote, comma, quote separators with semicolons, as part of converting the 
> files to my
> format.
> 
> So I thought I would do that while I was working out what else I had to do. I 
> entered the
> old separator and the replacement in the 'Find and replace' window, then hit 
> 'Replace
> all', expecting the job be done in a few seconds. First I thought nothing was 
> happening,
> but then I realised it was trudging through the file, as if it was wading 
> through waist
> high molasses.
> 
> So I closed the results window, and opened another file, but a few seconds 
> later focus
> switched back to the original file. I tried a couple of times more, but each 
> time it
> returned to the original window. I watched in morbid fascination for a bit, 
> then decided I
> would let it go, just to see how long it took.
> 
> The file contained 500 lines, and was about 80 K. It was taking five seconds 
> to process
> each line, and eventually finished in about 40 minutes.
> 
> The problem appeared to be the results processing. I have only looked at the 
> results list
> about twice, out of idle curiosity, but never saw any thing that I thought 
> could be
> remotely useful. I would like to be able to turn results logging off 
> altogether, as it
> wastes real estate (and time!), but this appears to be impossible.  
> 
> On this occasion the program was apparently writing a new line every time it 
> replaced a
> separator (9 times in each line), and then when it finished processing a line 
> it would
> erase all the intermediate result lines, and write a new one for the whole 
> line.  At the
> same time it reopened the results window if I had closed it, and return focus 
> to the file
> being processed.
> 
> I then wrote a PHP program to read the file, split it, clean up and 
> re-arrange the various
> elements, enter them into an array in my format, and finally save it as a 
> file my program
> could handle.
> 
>  After I had got this running on the 500 line file I used it to process the 
> 5000 line
> file. The whole process was done in the blink of an eye -- literally a 
> fraction of a
> second.
> 
> 
> * http://www.briandunning.com/sample-data/
> 
> 


Don't use Dreamweaver then :p

Joking aside (Dreamweaver is a very capable editor, although it is quite
large for simple find and replace tasks) how were you performing the
find and replace? Regular expression replacements will be much slower,
although it shouldn't account for quite the speed hit you saw. For
simple tasks like that, I'd recommend Notepad++. It has code
highlighting and folding, regex find/replace features, and a slew of
other bits that make it a very good editor, and it's very speedy to
boot.

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



--- End Message ---
--- Begin Message ---
Notepad++ also has session saving capabilities. This means you can save
which files you're working on, close Notepad++, and reload those files at a
later date. It's cool.

On Sun, Jan 31, 2010 at 4:51 PM, Ashley Sheridan
<[email protected]>wrote:

> On Mon, 2010-02-01 at 11:28 +1100, [email protected] wrote:
>
> > I use Dreamweaver as my editor, mainly because I'm familiar with it,
> although I only use
> > about 1% of its capabilities. However it generally handles long files
> well.  The other day
> > I downloaded the two shortest of Brian Dunning's sets of test data *.  I
> opened the
> > shortest in Dreamweaver, had a quick look at it, and realised I would
> have to replace the
> > quote, comma, quote separators with semicolons, as part of converting the
> files to my
> > format.
> >
> > So I thought I would do that while I was working out what else I had to
> do. I entered the
> > old separator and the replacement in the 'Find and replace' window, then
> hit 'Replace
> > all', expecting the job be done in a few seconds. First I thought nothing
> was happening,
> > but then I realised it was trudging through the file, as if it was wading
> through waist
> > high molasses.
> >
> > So I closed the results window, and opened another file, but a few
> seconds later focus
> > switched back to the original file. I tried a couple of times more, but
> each time it
> > returned to the original window. I watched in morbid fascination for a
> bit, then decided I
> > would let it go, just to see how long it took.
> >
> > The file contained 500 lines, and was about 80 K. It was taking five
> seconds to process
> > each line, and eventually finished in about 40 minutes.
> >
> > The problem appeared to be the results processing. I have only looked at
> the results list
> > about twice, out of idle curiosity, but never saw any thing that I
> thought could be
> > remotely useful. I would like to be able to turn results logging off
> altogether, as it
> > wastes real estate (and time!), but this appears to be impossible.
> >
> > On this occasion the program was apparently writing a new line every time
> it replaced a
> > separator (9 times in each line), and then when it finished processing a
> line it would
> > erase all the intermediate result lines, and write a new one for the
> whole line.  At the
> > same time it reopened the results window if I had closed it, and return
> focus to the file
> > being processed.
> >
> > I then wrote a PHP program to read the file, split it, clean up and
> re-arrange the various
> > elements, enter them into an array in my format, and finally save it as a
> file my program
> > could handle.
> >
> >  After I had got this running on the 500 line file I used it to process
> the 5000 line
> > file. The whole process was done in the blink of an eye -- literally a
> fraction of a
> > second.
> >
> >
> > * http://www.briandunning.com/sample-data/
> >
> >
>
>
> Don't use Dreamweaver then :p
>
> Joking aside (Dreamweaver is a very capable editor, although it is quite
> large for simple find and replace tasks) how were you performing the
> find and replace? Regular expression replacements will be much slower,
> although it shouldn't account for quite the speed hit you saw. For
> simple tasks like that, I'd recommend Notepad++. It has code
> highlighting and folding, regex find/replace features, and a slew of
> other bits that make it a very good editor, and it's very speedy to
> boot.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>

--- End Message ---
--- Begin Message ---
Dreamweaver is notorious for memory leaks (some releases have much more
severe issues than others.)  Sometimes just closing the app and then
reopening makes a big difference, especially when it comes to tasks that
take a large amount of memory.  That said, I'm certainly not sure this was
the issue, but I pointed it out just in case it was contributing to your
pain.

Adam

On Sun, Jan 31, 2010 at 8:02 PM, Allen McCabe <[email protected]> wrote:

> Notepad++ also has session saving capabilities. This means you can save
> which files you're working on, close Notepad++, and reload those files at a
> later date. It's cool.
>
> On Sun, Jan 31, 2010 at 4:51 PM, Ashley Sheridan
> <[email protected]>wrote:
>
> > On Mon, 2010-02-01 at 11:28 +1100, [email protected] wrote:
> >
> > > I use Dreamweaver as my editor, mainly because I'm familiar with it,
> > although I only use
> > > about 1% of its capabilities. However it generally handles long files
> > well.  The other day
> > > I downloaded the two shortest of Brian Dunning's sets of test data *.
>  I
> > opened the
> > > shortest in Dreamweaver, had a quick look at it, and realised I would
> > have to replace the
> > > quote, comma, quote separators with semicolons, as part of converting
> the
> > files to my
> > > format.
> > >
> > > So I thought I would do that while I was working out what else I had to
> > do. I entered the
> > > old separator and the replacement in the 'Find and replace' window,
> then
> > hit 'Replace
> > > all', expecting the job be done in a few seconds. First I thought
> nothing
> > was happening,
> > > but then I realised it was trudging through the file, as if it was
> wading
> > through waist
> > > high molasses.
> > >
> > > So I closed the results window, and opened another file, but a few
> > seconds later focus
> > > switched back to the original file. I tried a couple of times more, but
> > each time it
> > > returned to the original window. I watched in morbid fascination for a
> > bit, then decided I
> > > would let it go, just to see how long it took.
> > >
> > > The file contained 500 lines, and was about 80 K. It was taking five
> > seconds to process
> > > each line, and eventually finished in about 40 minutes.
> > >
> > > The problem appeared to be the results processing. I have only looked
> at
> > the results list
> > > about twice, out of idle curiosity, but never saw any thing that I
> > thought could be
> > > remotely useful. I would like to be able to turn results logging off
> > altogether, as it
> > > wastes real estate (and time!), but this appears to be impossible.
> > >
> > > On this occasion the program was apparently writing a new line every
> time
> > it replaced a
> > > separator (9 times in each line), and then when it finished processing
> a
> > line it would
> > > erase all the intermediate result lines, and write a new one for the
> > whole line.  At the
> > > same time it reopened the results window if I had closed it, and return
> > focus to the file
> > > being processed.
> > >
> > > I then wrote a PHP program to read the file, split it, clean up and
> > re-arrange the various
> > > elements, enter them into an array in my format, and finally save it as
> a
> > file my program
> > > could handle.
> > >
> > >  After I had got this running on the 500 line file I used it to process
> > the 5000 line
> > > file. The whole process was done in the blink of an eye -- literally a
> > fraction of a
> > > second.
> > >
> > >
> > > * http://www.briandunning.com/sample-data/
> > >
> > >
> >
> >
> > Don't use Dreamweaver then :p
> >
> > Joking aside (Dreamweaver is a very capable editor, although it is quite
> > large for simple find and replace tasks) how were you performing the
> > find and replace? Regular expression replacements will be much slower,
> > although it shouldn't account for quite the speed hit you saw. For
> > simple tasks like that, I'd recommend Notepad++. It has code
> > highlighting and folding, regex find/replace features, and a slew of
> > other bits that make it a very good editor, and it's very speedy to
> > boot.
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> >
>



-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com

--- End Message ---
--- Begin Message ---
Greetings,

If I register a shutdown function in PHP (to catch syntax parse errors and
send them in logs), it looks like I can open files, but I cannot do includes
- that is, if the reason of exit is a syntax parse error.

Is this a desired effect?  It seems a tad odd that I could do
eval(preg_replace("#^<\?[php]?#", "", file_get_contents($file))); but not
include($file);

-- 
Marc Trudel-Bélisle
www.wizcorp.jp

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

I have the following problem with the Adobe SVG viewer:
I try to generate a SVG document using PHP. the following code is working
well under Firefox, as well as IE with ASV:

<?php

header("Content-type: image/svg+xml");

$graph_title = 'title';


print('<?xml version="1.0" encoding="iso-8859-1" standalone="no"?>');
$svgwidth=500;
$svgheight=400;
?>

<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "
http://www.w3.org/TR/SVG/DTD/svg10.dtd";>
<svg width="<?php echo $svgwidth; ?>px" height="<?php echo $svgheight; ?>px"
xmlns="http://www.w3.org/2000/svg";>
    <desc>This is a php-random rectangle test</desc>
<?php
srand((double) microtime() * 1000000); //initalizing random generator
for ($i = 0; $i < 20; $i+=1) {
    $x = floor(rand(0,$svgwidth-1)); //avoid getting a range 0..0 for rand
function
    $y = floor(rand(0,$svgheight-1));
    $width = floor(rand(0,$svgwidth-$x)); //avoid getting rect outside of
viewbox
    $height = floor(rand(0,$svgheight-$y));
    $red = floor(rand(0,255));
    $blue = floor(rand(0,255));
    $green = floor(rand(0,255));
    $color = "rgb(".$red.",".$green.",".$
blue.")";
    print "\t<rect x=\"$x\" y=\"$y\" width=\"$width\" height=\"$height\"
style=\"fill:$color;\"/>\n";
}
?>
    <text x="<?php echo $svgwidth/2;?>px" y="300" style="font-size:15;"
text-anchor="middle">The servers Date and Time is: <?php print
(strftime("%Y-%m-%d, %H:%M:%S")); ?></text>
    <text x="<?php echo $svgwidth/2;?>px" y="340" style="font-size:15;"
text-anchor="middle">You are running:</text>
    <text x="<?php echo $svgwidth/2;?>px" y="360" style="font-size:15;"
text-anchor="middle"><?php print $HTTP_USER_AGENT; ?></text>
</svg>

If now I want to include the session_start() at the beginning of the code,
in IE I got a pop-up dialog called "download file"

What am I doing wrong ?

Regards,
Aurelie

--- End Message ---
--- Begin Message ---
On Mon, 2010-02-01 at 11:37 +0100, Aurelie REYMUND wrote:

> Hello,
> 
> I have the following problem with the Adobe SVG viewer:
> I try to generate a SVG document using PHP. the following code is working
> well under Firefox, as well as IE with ASV:
> 
> <?php
> 
> header("Content-type: image/svg+xml");
> 
> $graph_title = 'title';
> 
> 
> print('<?xml version="1.0" encoding="iso-8859-1" standalone="no"?>');
> $svgwidth=500;
> $svgheight=400;
> ?>
> 
> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "
> http://www.w3.org/TR/SVG/DTD/svg10.dtd";>
> <svg width="<?php echo $svgwidth; ?>px" height="<?php echo $svgheight; ?>px"
> xmlns="http://www.w3.org/2000/svg";>
>     <desc>This is a php-random rectangle test</desc>
> <?php
> srand((double) microtime() * 1000000); //initalizing random generator
> for ($i = 0; $i < 20; $i+=1) {
>     $x = floor(rand(0,$svgwidth-1)); //avoid getting a range 0..0 for rand
> function
>     $y = floor(rand(0,$svgheight-1));
>     $width = floor(rand(0,$svgwidth-$x)); //avoid getting rect outside of
> viewbox
>     $height = floor(rand(0,$svgheight-$y));
>     $red = floor(rand(0,255));
>     $blue = floor(rand(0,255));
>     $green = floor(rand(0,255));
>     $color = "rgb(".$red.",".$green.",".$
> blue.")";
>     print "\t<rect x=\"$x\" y=\"$y\" width=\"$width\" height=\"$height\"
> style=\"fill:$color;\"/>\n";
> }
> ?>
>     <text x="<?php echo $svgwidth/2;?>px" y="300" style="font-size:15;"
> text-anchor="middle">The servers Date and Time is: <?php print
> (strftime("%Y-%m-%d, %H:%M:%S")); ?></text>
>     <text x="<?php echo $svgwidth/2;?>px" y="340" style="font-size:15;"
> text-anchor="middle">You are running:</text>
>     <text x="<?php echo $svgwidth/2;?>px" y="360" style="font-size:15;"
> text-anchor="middle"><?php print $HTTP_USER_AGENT; ?></text>
> </svg>
> 
> If now I want to include the session_start() at the beginning of the code,
> in IE I got a pop-up dialog called "download file"
> 
> What am I doing wrong ?
> 
> Regards,
> Aurelie


It sounds like it's the SVG plugin you're using on IE that's badly
misbehaving. That said, I've not seen any plugins that correctly pass
across the full headers that the browser would. I tried using sessions
once to secure media files by checking for a valid login against the
session id, but the plugins requesting the video clips didn't send any
cookie data in the header request. As such, it might be better to not
rely on it in this case.

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



--- End Message ---
--- Begin Message ---
I've just wasted a few hours by trying to find a bug in my code that
messed up my JSON-passed-on-$_GET.
I'm using fopen() so please no nagging about putting JSON in $_POST..

I finally found the answer; in my distro's /etc/php5/apache2/php.ini,
magic_quotes_gpc is ON.
I'd like to know why, since it's being depracted anyway:

http://nl.php.net/manual/en/info.configuration.php#ini.magic-quotes-gpc

I'm on
PHP 5.2.10-2ubuntu6.4 with Suhosin-Patch 0.9.7 (cli) (built: Jan  6
2010 22:41:56)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies

--- End Message ---

Reply via email to