OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 22 Sep 2006 23:36:20 -0000 Issue 4362

php-general-digest-helplists.php.net
Date: Fri Sep 22 2006 - 18:36:20 CDT


php-general Digest 22 Sep 2006 23:36:20 -0000 Issue 4362

Topics (messages 242061 through 242102):

Re: Help converting C to PHP
        242061 by: Jay Blanchard
        242067 by: Rory Browne
        242070 by: tedd
        242078 by: Martin Alterisio
        242080 by: Tom Atkinson
        242081 by: php.kermodebear.org
        242084 by: Martin Alterisio
        242093 by: Richard Lynch
        242094 by: Richard Lynch

Re: web browser shows blank page when accessing *.php file
        242062 by: Kae Verens
        242063 by: Kae Verens
        242072 by: Anna Barnes

Re: Fatal error: session_start(): Failed to initialize storage module
        242064 by: Kae Verens
        242065 by: Kae Verens

Re: +AFs-OT+AF0- Working with version control
        242066 by: Miles Thompson
        242071 by: Ray Hauge
        242095 by: Richard Lynch

Asking about failure of accessing mySQL database by PHP-5.1.6 on Windows 2003
        242068 by: Nguyen, Phuong Anh Ho
        242069 by: João Cândido de Souza Neto

[OFF] PHP/MySQL contractor needed
        242073 by: Brian Dunning
        242079 by: Robert Cummings
        242085 by: Google Kreme

reading urlencoded data from POST
        242074 by: Marek 'MMx' Ludha

Override php.ini
        242075 by: Beauford
        242076 by: Martin Bach Nielsen
        242077 by: Brad Bonkoski

Object Memory Leakage...
        242082 by: Jon Anderson

mime_content_type replacement
        242083 by: Chris Jett

File Upload Security and chmod
        242086 by: Andy Hultgren
        242087 by: Børge Holen
        242088 by: João Cândido de Souza Neto

Stop - Blog Time
        242089 by: Toby Osbourn
        242090 by: Robert Cummings

PHP General
        242091 by: Robert Cummings
        242092 by: Robert Cummings

Re: FTP Copy
        242096 by: Richard Lynch

Re: chown(), chgrp()
        242097 by: Richard Lynch

Re: preg_replace (again)
        242098 by: Richard Lynch

Re: Most stable combination of AMP?
        242099 by: Richard Lynch

Re: How to write PHP extension in FPC
        242100 by: Richard Lynch

Re: stripping with an OB callback
        242101 by: Richard Lynch
        242102 by: Richard Lynch

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


[snip]
Codegolf...

heh.. nice little twist.
[/snip]

At least we weren't asked to help someone write his homework.

attached mail follows:


On 9/22/06, Kevin Waterson <kevinoceania.net> wrote:
>
> This one time, at band camp, "Curt Zirzow" <czirzowgmail.com> wrote:
>
> > what about using:
> > php.net/pi
> >
> > note the precision description.
> >
> > or are we talking about a different pi.
>
> The goal of the codegolf.com challenge is to print pi to 1000 places.
> The programmer to do it in the least keystrokes is the winner.

I personally don't think this is a very healthy contest. It discourages
comments, and use of whitespace to make code readable.

I'd perfer a contest that rewarded code readability, and maintainability as
well as minimal keystrokes. After all you only enter the aforementioned
keystrokes once. Perhaps one like codegolf, with an enforced coding style (
eg KR Style, or GNU Style)

attached mail follows:


At 2:38 PM +0200 9/22/06, Rory Browne wrote:
>On 9/22/06, Kevin Waterson <kevinoceania.net> wrote:
>>The goal of the codegolf.com challenge is to print pi to 1000 places.
>>The programmer to do it in the least keystrokes is the winner.
>
>I personally don't think this is a very healthy contest. It discourages
>comments, and use of whitespace to make code readable.
>
>I'd perfer a contest that rewarded code readability, and maintainability as
>well as minimal keystrokes. After all you only enter the aforementioned
>keystrokes once. Perhaps one like codegolf, with an enforced coding style (
>eg KR Style, or GNU Style)

Agreed, but our old ways remain to haunt us.

tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

attached mail follows:


2006/9/22, Rory Browne <rory.brownegmail.com>:
>
> On 9/22/06, Kevin Waterson <kevinoceania.net> wrote:
> >
> > This one time, at band camp, "Curt Zirzow" <czirzowgmail.com> wrote:
> >
> > > what about using:
> > > php.net/pi
> > >
> > > note the precision description.
> > >
> > > or are we talking about a different pi.
> >
> > The goal of the codegolf.com challenge is to print pi to 1000 places.
> > The programmer to do it in the least keystrokes is the winner.
>
>
> I personally don't think this is a very healthy contest. It discourages
> comments, and use of whitespace to make code readable.
>
> I'd perfer a contest that rewarded code readability, and maintainability
> as
> well as minimal keystrokes. After all you only enter the aforementioned
> keystrokes once. Perhaps one like codegolf, with an enforced coding style
> (
> eg KR Style, or GNU Style)
>
>
I completely agree. This kind of contests do not provide any measure of the
good qualities of a programmer working as part of a team. The objectives
ussualy end up being something of the sort: "let's see who can fit the most
in a for declaration".

Anyway... as you say, it would be nice to have a contest that rewards
readability and maintainability... but, how can we messure that qualities in
this type of games? Should your code be praised by others and voted on? Is
that reliable? I think enforcing a coding style is too restrictive... Also,
how do we measure the declarativity of var and function names?

attached mail follows:


Martin Alterisio wrote:
> 2006/9/22, Rory Browne <rory.brownegmail.com>:
>>
>> On 9/22/06, Kevin Waterson <kevinoceania.net> wrote:
>> >
>> > This one time, at band camp, "Curt Zirzow" <czirzowgmail.com> wrote:
>> >
>> > > what about using:
>> > > php.net/pi
>> > >
>> > > note the precision description.
>> > >
>> > > or are we talking about a different pi.
>> >
>> > The goal of the codegolf.com challenge is to print pi to 1000 places.
>> > The programmer to do it in the least keystrokes is the winner.
>>
>>
>> I personally don't think this is a very healthy contest. It discourages
>> comments, and use of whitespace to make code readable.
>>
>> I'd perfer a contest that rewarded code readability, and maintainability
>> as
>> well as minimal keystrokes. After all you only enter the aforementioned
>> keystrokes once. Perhaps one like codegolf, with an enforced coding style
>> (
>> eg KR Style, or GNU Style)
>>
>>
> I completely agree. This kind of contests do not provide any measure of the
> good qualities of a programmer working as part of a team. The objectives
> ussualy end up being something of the sort: "let's see who can fit the most
> in a for declaration".
>
> Anyway... as you say, it would be nice to have a contest that rewards
> readability and maintainability... but, how can we messure that
> qualities in
> this type of games? Should your code be praised by others and voted on? Is
> that reliable? I think enforcing a coding style is too restrictive... Also,
> how do we measure the declarativity of var and function names?
>

The value of these games is that they give you interesting problems to
solve without forcing you to maintain the code. That's the entire point.
It's exactly the sort of thing that's fun to write when you have to make
a living from your code the rest of the time. If you want to write
quality software in your free time then you start/join an FOSS project
and put the code to good use.

Nobody is claiming that this is a good way to write code or a good way
to learn PHP, it's just for fun.

attached mail follows:


Hello all,

> > I personally don't think this is a very healthy contest. It
> > discourages comments, and use of whitespace to make code readable.

> Anyway... as you say, it would be nice to have a contest that rewards
> readability and maintainability... but, how can we messure that
> qualities in this type of games? Should your code be praised by others
> and voted on? Is that reliable? I think enforcing a coding style is
> too restrictive... Also, how do we measure the declarativity of var
> and function names?

For some real trouble, try the International Obsfucated C Code Contest:
http://www.ioccc.org/

These contests like Code Golf are just for fun, I can't say that they
encourage bad practice as long as you understand what the contest is
about.

That aside, I think that it would be very beneficial to the community as a
whole if a contest was started that encouraged readability and good
practices.

The scoring and judging could be done by a panel, but I think that it
would be more fun if the community itself was able to vote on various
attributes; readability, efficiency, general approach, originality, etc.
Allow people to comment on each entry. I don't know about the winner
getting anything besides bragging rights, but it if gets large enough
maybe there can be a few corporate sponsors giving away licenses or
something. Who knows?

I think it would be a lot of fun if well executed.

-K.Bear

attached mail follows:


2006/9/22, Tom Atkinson <nibblercoppermine-gallery.net>:
>
> Martin Alterisio wrote:
> > 2006/9/22, Rory Browne <rory.brownegmail.com>:
> >>
> >> On 9/22/06, Kevin Waterson <kevinoceania.net> wrote:
> >> >
> >> > This one time, at band camp, "Curt Zirzow" <czirzowgmail.com> wrote:
> >> >
> >> > > what about using:
> >> > > php.net/pi
> >> > >
> >> > > note the precision description.
> >> > >
> >> > > or are we talking about a different pi.
> >> >
> >> > The goal of the codegolf.com challenge is to print pi to 1000 places.
> >> > The programmer to do it in the least keystrokes is the winner.
> >>
> >>
> >> I personally don't think this is a very healthy contest. It discourages
> >> comments, and use of whitespace to make code readable.
> >>
> >> I'd perfer a contest that rewarded code readability, and
> maintainability
> >> as
> >> well as minimal keystrokes. After all you only enter the aforementioned
> >> keystrokes once. Perhaps one like codegolf, with an enforced coding
> style
> >> (
> >> eg KR Style, or GNU Style)
> >>
> >>
> > I completely agree. This kind of contests do not provide any measure of
> the
> > good qualities of a programmer working as part of a team. The objectives
> > ussualy end up being something of the sort: "let's see who can fit the
> most
> > in a for declaration".
> >
> > Anyway... as you say, it would be nice to have a contest that rewards
> > readability and maintainability... but, how can we messure that
> > qualities in
> > this type of games? Should your code be praised by others and voted on?
> Is
> > that reliable? I think enforcing a coding style is too restrictive...
> Also,
> > how do we measure the declarativity of var and function names?
> >
>
> The value of these games is that they give you interesting problems to
> solve without forcing you to maintain the code. That's the entire point.
> It's exactly the sort of thing that's fun to write when you have to make
> a living from your code the rest of the time. If you want to write
> quality software in your free time then you start/join an FOSS project
> and put the code to good use.
>
> Nobody is claiming that this is a good way to write code or a good way
> to learn PHP, it's just for fun.

You're right, it's just for fun.... but... they could still be fun and be
useful. These kind of games could easily be used for education and training.
We all know that the quest/mob grinding factor can be very addictive, why
don't use all that energy for the good? You could still learn how to do a
good job while having fun...

attached mail follows:


On Thu, September 21, 2006 9:32 pm, Curt Zirzow wrote:
> On 9/21/06, Tom Atkinson <nibblercoppermine-gallery.net> wrote:
>> Hello,
>>
>> I am attempting to convert this code for generating the digits of pi
>> from the original C (below) to PHP.
>>
>> long k=4e3,p,a[337],q,t=1e3;
>> main(j){for(;a[j=q=0]+=2,--k;)
>> for(p=1+2*k;j<337;q=a[j]*k+q%p*t,a[j++]=q/p)
>> k!=j>2?:printf("%.3d",a[j-2]%t+q/p/t);}
>
>
> wow this is rather bad. it would probably be better to write this in
> asm, it would be easier to read than the way it is in C.
>
>>
>> I converted this to a more readable form:
>
> what about using:
> php.net/pi
>
> note the precision description.
>
> or are we talking about a different pi.

We're probably talking about that silly contest started the other day
to calculate pi to 1000 digits...

:-)

My best guess is that the C code is relying on type-casting to hack
something somewhere.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Fri, September 22, 2006 11:59 am, Martin Alterisio wrote:
> Anyway... as you say, it would be nice to have a contest that rewards
> readability and maintainability... but, how can we messure that
> qualities in
> this type of games?

If you think of the Open Market of software "out there" as "the game"
and people's decisions to use or not use it, then you've got a pretty
good contest.

And PHP is winning. :-)

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


Anna Barnes wrote:

> [Tue Sep 19 15:53:57 2006] [error] PHP Fatal error: Maximum execution
> time of 60 seconds exceeded in /websites/ical/functions/ical_parser.php
> on line 494
>
> Not quite sure where to go from here.

"ical_parser" sounds like it is a function which sucks in information from
other computers. if one of those computers is down, then your program will
probably timeout while waiting for the information.

Kae

attached mail follows:


Anna Barnes wrote:

> [Tue Sep 19 15:53:57 2006] [error] PHP Fatal error: Maximum execution
> time of 60 seconds exceeded in /websites/ical/functions/ical_parser.php
> on line 494
>
> Not quite sure where to go from here.

"ical_parser" sounds like it is a function which sucks in information from
other computers. if one of those computers is down, then your program will
probably timeout while waiting for the information.

Kae

attached mail follows:


Hi All
This is all very weird and it may be that it isn't a php problem
after all.

Here is line 494 in ical_parser.php
          ereg ("([^:]+):(.*)", $line

Additional information is
a) the mac that publishes the ical is always up, no probs there
although I should check if a system update has been done recently.
b) The webserver that hosts the calendar is definitely up because all
the other web pages work.
c) The athentication definitely works since if I put in the wrong
username and password it comes back with an error.
d) the whole thing worked perfectly until a few days ago. I've
managed to get it up again by restarting httpd but then it fails
again shortly after.
e) I've made no changes to the webserver.
f) Is it possible that its trying to access too much data from the
calendar i.e it is possible to go back 18 months and look at the
schedule.

I'm just about to archive the existing scanner.ics file and republish
another one to see it that works.
thanks
Anna

On Sep 22, 2006, at 8:06 AM, Kae Verens wrote:

> Anna Barnes wrote:
>
>> [Tue Sep 19 15:53:57 2006] [error] PHP Fatal error: Maximum
>> execution time of 60 seconds exceeded in /websites/ical/functions/
>> ical_parser.php on line 494
>> Not quite sure where to go from here.
>
> "ical_parser" sounds like it is a function which sucks in
> information from other computers. if one of those computers is
> down, then your program will probably timeout while waiting for the
> information.
>
> Kae

attached mail follows:


afanafan.net wrote:
> Hi,
>
> "Fatal error: session_start(): Failed to initialize storage module in
> /home/vernoncompany.biz/includes/validations.php on line 2"
>
> validation.php:
> #1 <?php
> #2 session_start();
> # ...
>
> Two weeks ago I got this essage first time. And since, I'm getting more
> often. Last three days at aleast once a day when open my website.
>
> According Google, it's problem with php.ini setup.

possibly.

or it could be a disk-space problem.

what does your server's error_log say?

Kae

attached mail follows:


afanafan.net wrote:
> Hi,
>
> "Fatal error: session_start(): Failed to initialize storage module in
> /home/vernoncompany.biz/includes/validations.php on line 2"
>
> validation.php:
> #1 <?php
> #2 session_start();
> # ...
>
> Two weeks ago I got this essage first time. And since, I'm getting more
> often. Last three days at aleast once a day when open my website.
>
> According Google, it's problem with php.ini setup.

possibly.

or it could be a disk-space problem.

what does your server's error_log say?

Kae

attached mail follows:


At 06:21 PM 9/21/2006, Chris W. Parker wrote:

>Hello,
>
>This is off topic but I wanted to get the list member's opinions on the
>subject as it will probably benefit someone else.
>
>Currently I don't use version control at all. What I do instead is have
>one directory that contains my development website and one directory
>that contains the live website which I do not directly modify. When I
>need to fix something or add a new feature I edit the development site
>and copy the files that I've changed.
>
>Sometimes I will start on a new feature before I am able to finish a
>previous one. This is a major problem when the features overlap and I
>have to edit the same file for both features. Even if I finish one of
>the features I cannot publish the files because the other feature is not
>ready yet.
>
>What I'm looking to the list for is how I can overcome this through
>version control.
>
>What I'm thinking I'd do is create a base level (say v1.0) that I then
>create a branch for every new feature and then merge those things
>together. The issue I see in this case is the merging.
>
>Is this a sound strategy or should I just realize that I can't publish
>until all current features enhancements are completed?
>
>
>Thanks,
>Chris.

Not OT at all.

Use Subversion.
For a nice Windows interface - Tortoise. Sorry, I can't rememberthe name
ofthe Linux interface.

Miles

--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.12.7/454 - Release Date: 9/21/2006

attached mail follows:


On Friday 22 September 2006 07:29, Miles Thompson wrote:
> Use Subversion.
> For a nice Windows interface - Tortoise. Sorry, I can't rememberthe name
> ofthe Linux interface.
>
> Miles

I like kdesvn. It actually uses the svn API so it isn't just a wrapper for
the command line.

http://www.alwins-world.de/programs/kdesvn/

If you use SVN+SSH, and you run kdesvn from the command line, then it will ask
you for your password on the command line. Just a little hint.

--
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

attached mail follows:


On Thu, September 21, 2006 7:08 pm, Colin Guthrie wrote:

I've used CVS a fair amount, no branching, as everybody always said
what a bear it was to merge.

I keep hearing subversion is easier to branch/merge.

Tomorrow, I've been tasked by the boss to find out HOW easy and how to
do it for a big change that needs doing.

But I'd also like to hack away on the "little changes" in, err, the
trunk, I guess...

So can I keep those both around?
And would the branch live in a subdirectory or what?

I've read the docs and all, but it's all too nuts-and-bolts detail and
not enough of the slightly higher-level "How To"...

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


Hello Sir/ Madame,

I am a developer working with PHP-5.1.6-Win32 and mySQL database. Following is my question:

I successfully runs PHP-5.1.6-Win32 with Internet Information Services 6 (II6) on Windows 2003 under ISAPI mode. Then, I runs the index.php of phpMyAdmin software to connect to MySQL database, the result is "Cannot load mysql extension. Please check your PHP configuration".

Conditions such as php_mysql.dll and supplying information for extension_dir in php.ini are supplied.

Such a connection runs successfully on Windows XP but not on Windows 2003.

Please answer me the problem on Windows 2003. Thank you!

Best Regards,

Phuong

This email may contain material that is confidential, privileged and/or attorney work product for the sole use of the intended recipient. Any review, reliance or distribution by others or forwarding without express permission is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

attached mail follows:


Try to copy php_mysql.dll to your system32 folder. I did it and works fine.

""Nguyen, Phuong Anh Ho"" <panguyenfcg.com> escreveu na mensagem
news:6C351752FC9A6D4D8D72E992B5BA5CEF149411hont03.fcg.com...
Hello Sir/ Madame,

I am a developer working with PHP-5.1.6-Win32 and mySQL database. Following
is my question:

I successfully runs PHP-5.1.6-Win32 with Internet Information Services 6
(II6) on Windows 2003 under ISAPI mode. Then, I runs the index.php of
phpMyAdmin software to connect to MySQL database, the result is "Cannot load
mysql extension. Please check your PHP configuration".

Conditions such as php_mysql.dll and supplying information for extension_dir
in php.ini are supplied.

Such a connection runs successfully on Windows XP but not on Windows 2003.

Please answer me the problem on Windows 2003. Thank you!

Best Regards,

Phuong

This email may contain material that is confidential, privileged and/or
attorney work product for the sole use of the intended recipient. Any
review, reliance or distribution by others or forwarding without express
permission is strictly prohibited. If you are not the intended recipient,
please contact the sender and delete all copies.

attached mail follows:


We need a guy for some hourly PHP/MySQL work. Large project to start
with, plenty of incremental stuff down the road. Looking for someone
expert, with a flexible schedule who can make hours available when we
need them. Your regular hourly rate.

Also - only interested in someone local to south Orange County, CA.
No outsourcers or non-locals can be considered, sorry.

Please email me back-channel for details if interested. Thanks!

- Brian

attached mail follows:


On Fri, 2006-09-22 at 09:00 -0700, Brian Dunning wrote:
>
> Also - only interested in someone local to south Orange County, CA.
> No outsourcers or non-locals can be considered, sorry.

Geeeeeee, way to fight back against the shrinking distance of the global
community brought to you by the Internet. I'm just curious why so many
posters for jobs feel the need to force a local boundary. Is the quality
of work somehow better because you can knock on their door?

Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'

attached mail follows:


On 22 Sep 2006, at 11:14 , Robert Cummings wrote:
> Geeeeeee, way to fight back against the shrinking distance of the
> global
> community brought to you by the Internet. I'm just curious why so many
> posters for jobs feel the need to force a local boundary. Is the
> quality
> of work somehow better because you can knock on their door?

Hah! I'd say its worse, on average.

--
I gotta straighten my face
this mellow thighed chick just put my spine out of place

attached mail follows:


Hi.

I need to read urlencoded data from POST request. So far I have tried
$_POST['name'], but this converts each input %5C to two backslashes
(instead of one) and %00 to \0 (slash zero, not zero byte) for some
reason. Is there any other way to read the data apart from parsing
php://input myself?
Thanks in advance for any response.

--
Marek 'MMx' Ludha

attached mail follows:


Is there a way I can use <% %> instead of <? ?> for the opening and closing
tags of a php script. I thought I read this somewhere but can't find
anything on it now.

Is there something that I could do with override php.ini command? I don't
have access to the php.ini file on this server.

Thanks

B

attached mail follows:


http://us2.php.net/ini.core

asp_tags boolean

    Enables the use of ASP-like <% %> tags in addition to the usual <?php ?>
tags. This includes the variable-value printing shorthand of <%= $value %>.
For more information, see Escaping from HTML.

        Note: Support for ASP-style tags was added in 3.0.4.

I don't know if you can use a php.ini override command to do this, but it's
worth a try :)

// Martin

-----Original Message-----
From: Beauford [mailto:php-usernetscan.ca]
Sent: 22. september 2006 18:42
To: PHP
Subject: [PHP] Override php.ini

Is there a way I can use <% %> instead of <? ?> for the opening and closing
tags of a php script. I thought I read this somewhere but can't find
anything on it now.

Is there something that I could do with override php.ini command? I don't
have access to the php.ini file on this server.

Thanks

B

attached mail follows:


the ini directive for this is: asp_tags
and it appears you can set them in the .htaccess file on a per directory
basis.

See the user contributed notes on www.php.net/ini_set
HTH
-B

Beauford wrote:
> Is there a way I can use <% %> instead of <? ?> for the opening and closing
> tags of a php script. I thought I read this somewhere but can't find
> anything on it now.
>
> Is there something that I could do with override php.ini command? I don't
> have access to the php.ini file on this server.
>
> Thanks
>
> B
>
>

attached mail follows:


Sorry folks, this is a long one...I've re-read a bunch of the
documentation, and I can't find a solution.

In debugging an out of memory condition, I found that PHP doesn't seem
to garbage collect unreferenced objects. It seems to work fine for
anything other than objects. (Arrays, strings, integers, etc.)

Here's a simple example: define a class, create 3 instances, destroy
them in reverse order. I would expect that after each unset and/or NULL,
the memory usage would go down, they don't. See the output below.

<?php

class Tester {
        protected $test1;
        protected $test2;
        protected $test3;
        protected $test4;

        public function __construct() {
                $test1 = rand();
                $test2 = rand();
                $test3 = rand();
                $test4 = rand();
        }
}

echo memory_get_usage() . "\n";
$t1 = new Tester();
echo memory_get_usage() . "\n";
$t2 = new Tester();
echo memory_get_usage() . "\n";
$t3 = new Tester();
echo memory_get_usage() . "\n";
unset($t3);
$t3 = NULL;
echo memory_get_usage() . "\n";
$t2 = NULL;
echo memory_get_usage() . "\n";
unset($t1);
echo memory_get_usage() . "\n";

This outputs:

43344
43928
44232
44568
44640
44640
44640

Note: the memory usage remains constant after the objects are allocated,
even when they're unset/NULL'ed.

Some of the user contributed notes on the PHP documentation suggest that
the memory is actually freed and available for use by other
variables/objects even though memory_get_usage() says otherwise. Another
little test seems to disprove that too... The idea here is to allocate
close to 8 MB, then free it to show that it can allocate that data
within the memory limit. Then allocate enough class instances and free
them again such that the memory usage increases enough that the same
data allocated and freed initially doesn't fit anymore. If PHP did
indeed free the objects, the data would fit the second time too...

<?php

ini_set('memory_limit','8m');

class Tester {
        protected $test;

        public function __construct() {
                $this->test = rand();
        }
}

echo "Initial Memory Usage: " . memory_get_usage() . "\n";

$mb = 6 * 1024 * 1024;
echo "Allocating 7 MB of data...";
$dat = "";
for ($x=0;$x<$mb;$x++) {
        $dat .= "x";
}
echo "Memory Usage: " . memory_get_usage() . "\n";
unset($dat,$x,$mb);
echo "Unset Usage: " . memory_get_usage() . "\n";

$num = 32767;
$objects = array();

echo "Initial Memory Usage (2): " . memory_get_usage() . "\n";
echo "Allocating $num objects...";
for ($x=0;$x<$num;$x++) {
        $objects[$x] = new Tester();
}
echo "Done. Memory Usage: " . memory_get_usage() . "\n";
echo "Freeing $num objects...";
for ($x=0;$x<$num;$x++) {
        unset($objects[$x]); $objects[$x] = NULL;
}
echo "Done. Memory Usage: " . memory_get_usage() . "\n";

$mb = 6 * 1024 * 1024;
echo "Allocating 7 MB of data...";
$dat = "";
for ($x=0;$x<$mb;$x++) {
        $dat .= "x";
}

This gives:

Initial Memory Usage: 44248
Allocating 7 MB of data...Memory Usage: 6335888
Unset Usage: 44448
Initial Memory Usage (2): 44504
Allocating 32767 objects...Done. Memory Usage: 7752920
Freeing 32767 objects...Done. Memory Usage: 2807080
Allocating 7 MB of data...
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to
allocate 1 bytes) in /home/janderson/svn/memtest.php on line 44

Am I missing something? (Is there a force_garbage_collection() function
somewhere that I'm missing?) Any suggestions/workarounds/anything would
be most appreciated.

Cheers,

jon

attached mail follows:


I understand that fileinfo is supposed to be the replacement for
mime_content_type(), but the documentation is not real helpful. What
is the direct replacement for mime_content_type()?
--
Chris Jett
chrisjettfuel.net

attached mail follows:


Hi,
I am relatively new to php and am trying to set up a file upload
process for my website. I have read through the php security
documentation and a number of the security-related questions on these
lists and am attempting to implement as many of the measures as
possible.
One of the suggestions I have read is to have the uploaded files saved
somewhere outside of your root directory. Unfortunately I cannot do
that as my root directory is simply www.myDomain.com and not
".public_html/" and I am on a shared server where my root cannot be
changed (I have already asked). So, I am trying to keep the
permissions on my "saved_files" folder as tight as possible except
when the actual upload occurs. I this as follows:

1) The actual file upload comes through Flash8, and when the user
uploads a file it is sent to
www.domain.com/flash8directory/upload.php, which is in the same
directory as the Flash8 upload application.
2) upload.php first chmod 0740 the "saved_files" folder (which is
located at www.domain.com/flash8directory/saved_files/). Then it does
security checks to make sure an appropriate image has been uploaded,
and if everything looks good it moves the uploaded file to
"saved_files".
3) The Flash8 upload application is notified of the completion of the
upload and downloads the new image it its viewer.
4) Once the download is complete and Flash8 no longer needs to work
with the file, the Flash8 application notifies a separate php script
by sending the variable "complete=1" to lockdown.php (located at
www.domain.com/flash8directory/lockdown.php), which runs the following
simple script:

<?php

$success = 0;
$complete = $_POST['complete'];

if ($complete==1) {
        if(chmod("./saved_files", 0100)) {
                         success = yes;
                echo "success=yes";
        }
}
?>

This script works and "saved_files" is set to chmod 0100, but here is
the problem. If I then navigate directly to the url of the uploaded
file by entering its path in my
browser(www.domain.com/flash8directory/saved_files/uploadedFile.jpg),
the uploaded file appears in my browser! However, if I then refresh
the browser I get the desired error message saying I do not have
permission to access that file. Also, other browser windows never
have access to view the uploaded file, only the browser from which the
file was uploaded.

Any thoughts on why I can view the uploaded file even though it has
been set to chmod 0100? I'd really rather not have those files
accessible to anyone, as an extra security layer.

Thank you for your help!

Andy

attached mail follows:


On Friday 22 September 2006 22:58, Andy Hultgren wrote:
> Hi,
> I am relatively new to php and am trying to set up a file upload
> process for my website. I have read through the php security
> documentation and a number of the security-related questions on these
> lists and am attempting to implement as many of the measures as
> possible.
> One of the suggestions I have read is to have the uploaded files saved
> somewhere outside of your root directory. Unfortunately I cannot do
> that as my root directory is simply www.myDomain.com and not
> ".public_html/" and I am on a shared server where my root cannot be
> changed (I have already asked). So, I am trying to keep the
> permissions on my "saved_files" folder as tight as possible except
> when the actual upload occurs. I this as follows:
>
> 1) The actual file upload comes through Flash8, and when the user
> uploads a file it is sent to
> www.domain.com/flash8directory/upload.php, which is in the same
> directory as the Flash8 upload application.
> 2) upload.php first chmod 0740 the "saved_files" folder (which is
> located at www.domain.com/flash8directory/saved_files/). Then it does
> security checks to make sure an appropriate image has been uploaded,
> and if everything looks good it moves the uploaded file to
> "saved_files".
> 3) The Flash8 upload application is notified of the completion of the
> upload and downloads the new image it its viewer.
> 4) Once the download is complete and Flash8 no longer needs to work
> with the file, the Flash8 application notifies a separate php script
> by sending the variable "complete=1" to lockdown.php (located at
> www.domain.com/flash8directory/lockdown.php), which runs the following
> simple script:
>
> <?php
>
> $success = 0;
> $complete = $_POST['complete'];
>
> if ($complete==1) {
> if(chmod("./saved_files", 0100)) {
> success = yes;
> echo "success=yes";
> }
> }
> ?>
>
> This script works and "saved_files" is set to chmod 0100, but here is
> the problem. If I then navigate directly to the url of the uploaded
> file by entering its path in my
> browser(www.domain.com/flash8directory/saved_files/uploadedFile.jpg),
> the uploaded file appears in my browser! However, if I then refresh
> the browser I get the desired error message saying I do not have
> permission to access that file. Also, other browser windows never
> have access to view the uploaded file, only the browser from which the
> file was uploaded.
>
> Any thoughts on why I can view the uploaded file even though it has
> been set to chmod 0100? I'd really rather not have those files
> accessible to anyone, as an extra security layer.
>
> Thank you for your help!
>
> Andy

I don't quite understand why you cannot save to another catalog.
is www.myDomain.com yer actual directory name of merely the domain?
If either, login to yer domain and simply go either one step up, is that
possible?
You can also make use of a .htaccess file inside a sub directory to keep
others from it till you have checked the file, then move it out in the open
or delete after specifications.

Do you have access to /tmp ? That one is possible to use, in fact any system
wide directory writable by any/you is usable.

--
---
Børge
Kennel Arivene
http://www.arivene.net
---

attached mail follows:


I always use the ftp functions of php to upload files. I think it´s more
safe than move_uploaded_file function.

""Andy Hultgren"" <wearhdphpgmail.com> escreveu na mensagem
news:3d9c688e0609221358j55d1d49fg9e29969b5028023fmail.gmail.com...
> Hi,
> I am relatively new to php and am trying to set up a file upload
> process for my website. I have read through the php security
> documentation and a number of the security-related questions on these
> lists and am attempting to implement as many of the measures as
> possible.
> One of the suggestions I have read is to have the uploaded files saved
> somewhere outside of your root directory. Unfortunately I cannot do
> that as my root directory is simply www.myDomain.com and not
> ".public_html/" and I am on a shared server where my root cannot be
> changed (I have already asked). So, I am trying to keep the
> permissions on my "saved_files" folder as tight as possible except
> when the actual upload occurs. I this as follows:
>
> 1) The actual file upload comes through Flash8, and when the user
> uploads a file it is sent to
> www.domain.com/flash8directory/upload.php, which is in the same
> directory as the Flash8 upload application.
> 2) upload.php first chmod 0740 the "saved_files" folder (which is
> located at www.domain.com/flash8directory/saved_files/). Then it does
> security checks to make sure an appropriate image has been uploaded,
> and if everything looks good it moves the uploaded file to
> "saved_files".
> 3) The Flash8 upload application is notified of the completion of the
> upload and downloads the new image it its viewer.
> 4) Once the download is complete and Flash8 no longer needs to work
> with the file, the Flash8 application notifies a separate php script
> by sending the variable "complete=1" to lockdown.php (located at
> www.domain.com/flash8directory/lockdown.php), which runs the following
> simple script:
>
> <?php
>
> $success = 0;
> $complete = $_POST['complete'];
>
> if ($complete==1) {
> if(chmod("./saved_files", 0100)) {
> success = yes;
> echo "success=yes";
> }
> }
> ?>
>
> This script works and "saved_files" is set to chmod 0100, but here is
> the problem. If I then navigate directly to the url of the uploaded
> file by entering its path in my
> browser(www.domain.com/flash8directory/saved_files/uploadedFile.jpg),
> the uploaded file appears in my browser! However, if I then refresh
> the browser I get the desired error message saying I do not have
> permission to access that file. Also, other browser windows never
> have access to view the uploaded file, only the browser from which the
> file was uploaded.
>
> Any thoughts on why I can view the uploaded file even though it has
> been set to chmod 0100? I'd really rather not have those files
> accessible to anyone, as an extra security layer.
>
> Thank you for your help!
>
> Andy

attached mail follows:


I don't want to spam a new blog I have created, so I won't post a link to
it, but I was thinking about every so often talking about PHP and its many
uses - to that end, if anyone has anything they want to blog, but couldn't
be bothered actually making a blog, please email me - naturally you will get
full credit for the article etc. etc.

attached mail follows:


On Fri, 2006-09-22 at 23:09 +0100, Toby Osbourn wrote:
> I don't want to spam a new blog I have created, so I won't post a link to
> it, but I was thinking about every so often talking about PHP and its many
> uses - to that end, if anyone has anything they want to blog, but couldn't
> be bothered actually making a blog, please email me - naturally you will get
> full credit for the article etc. etc.

I was thinking about writing a blog about people who write blogs and
advertise on PHP General for ideas on which to blog. :B

Cheers,
Rob.

Ps. this has been written in light humour... not as a flame :)
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'

attached mail follows:


Did this list get a new server? Just wondering because lately my posts
have been showing up within 1 or 2 minutes and they haven't done that in
years. So either PHP General got a new zippy server or the mail system
was quarantining my mails before I fixed my DNS (which had some issues I
didn't notice until a few days ago :)

Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'

attached mail follows:


On Fri, 2006-09-22 at 18:55 -0400, Robert Cummings wrote:
> Did this list get a new server? Just wondering because lately my posts
> have been showing up within 1 or 2 minutes and they haven't done that in
> years. So either PHP General got a new zippy server or the mail system
> was quarantining my mails before I fixed my DNS (which had some issues I
> didn't notice until a few days ago :)

1 minute 10 seconds for that post to show up... wheeeeeeeeeeee! :B

Rob,
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'

attached mail follows:


On Tue, September 19, 2006 8:14 pm, Chris wrote:
... FTP copy ...

Depending on the security issues, and SCP from exec() may be more
suitable...

Another option would be to upload a PHP script to one or the other
that does the FTP you want one way or the other... :-)

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


775 needs to be 0775 for starters, as I recall...

On Tue, September 19, 2006 11:07 am, Rahul S. Johari wrote:
>
> Here's the interesting things. I did exactly that to begin with... And
> I
> never got the "file can't be chmoded!" ... Instead, I actually got the
> "Mode
> changed to" notification that I had set in the "else {" case.
> However... The mode of the file never changed! Even though !chmod
> didn't say
> that mode cannot be changed.... It wasn't really changing the mode.
> Which is
> why I thought it doesn't work this way.
>
>
> On 9/19/06 11:58 AM, "Jay Paulson" <Jay.Paulsonwholefoods.com> wrote:
>
>> If (!chmod("/somedir/somefile", 775)) {
>> echo "file can't be chmoded!";
>> }
>
> Rahul S. Johari
> Supervisor, Internet & Administration
> Informed Marketing Services Inc.
> 500 Federal Street, Suite 201
> Troy NY 12180
>
> Tel: (518) 687-6700 x154
> Fax: (518) 687-6799
> Email: rahulinformed-sources.com
> http://www.informed-sources.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Wed, September 20, 2006 11:20 am, Pawel Miroslawski wrote:
> Hi
> it's example script:
>
> <?php
> $string = "This is some _color:pink_ colored text _color_";
>
> $patterns[0] = '/_color:(.*?)_/';
> $patterns[1] = '/_color_/';
> $replacements[0] = '<font color="$1">';
> $replacements[1] = '</font>';
>
> echo preg_replace($patterns, $replacements, $string);
> ?>
>
> It should be ok, but i don't test it.

For the sanitization...

.*? could be something more like: [#a-z0-9A-Z]+

The # assumes you want to allow #ff0000 style colors.

Since this whitelists the specific characters you allow, it's probably
better than the strip_tags thing.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Wed, September 20, 2006 1:04 pm, James Tu wrote:
> I was thinking more along the lines of what version of Apache, MySQL
> and PHP I should install...

If you are comfy installing from source, visit each site and download
the version marked "latest stable release"

MAYBE for Apache stick with 1.x as there's not much point to 2.x with
PHP as you're stuck with pre-fork mode which means you might as well
just use 1.x as I understand it, or probably mis-understand it...

If you are not comfy with source, then whatever the distro is touting
as "stable" is probably the most stable for their distro...

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Thu, September 21, 2006 4:25 am, Bronislav Klucka wrote:
> Sorry for previous question, was not that clear at all
>
> Does anybody know how to write PHP extension in FreePascal?

Port the FreePascal to C first? :-)

I dunno... I mean, maybe there's some fancy FreePascal->C bridge
thingie to make it all work...

Can you include a bunch of C header files and make them work?

Cuz there's a TON of stuff in PHP C header files of macros and whatnot
that make it easy to write an extension.

Working without those or rolling those all over again in FreePascal
would be a nightmare, I suspect...

I just gave a talk at the Chicago PHP User Group "Extension Writing
for Dummies" based on my experience with: http://l-i-e.com/perror

I really think you'll have an eaiser time porting the FreePascal to C
than trying to marry C and FreePascal, but I'm no expert.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Wed, September 20, 2006 7:13 pm, Christopher Watson wrote:
> I've been coding with PHP for maybe a year. So I'm somewhat new to
> it. But I've learned quickly, and created a fairly serious LAMP app
> that is capable of returning large query results. During my
> investigation into various means for incrementally reducing the
> response sizes, I've discovered output buffering with a callback
> function. So, as an experiment, I bracketed my includes of the
> Fusebox files in index.php with ob_start('sweeper') and
> ob_end_flush(), and placed the simple callback function at the top of
> the file that performs a preg_replace on the buffer to strip all
> excess space:
>
> function sweeper($buffer) {
> return preg_replace("/\s\s+/", " ", $buffer);
> }

Here's where you MIGHT get bit in the butt:
  1. Anything in a PRE tag is gonna suck big-time
  2. Any kind of DATA from your db with multiple spaces will lose data

Now, you might maybe be able to fix these by religiously always doing
$output = str_replace(' ', '&nbsp', $output);
on the DATA from the DB, or any kind of PRE tags stuff you use.

Or maybe in YOUR application, neither of these matters.

Test it with JUST the output buffer and without the whitespace crunch
-- You may find that the ob is the big win, especially if you have a
zillion echo statements going on.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


Cannot compression be set in .htaccess?

Or even within the script???

I suspect you could even find a PHP class out there to compress and
send the right headers to do it all in PHP, regardless of server
settings...

On Wed, September 20, 2006 7:33 pm, Christopher Watson wrote:
> Hi Robert,
>
> Well, I think the main reason I'm not using transparent output
> compression is because this app shares php.ini with several other PHP
> apps on the server, and I don't want to foist this change on the
> admins of those apps. I was trying to come up with a localized
> strategy for trimming my app's output.
>
> The <pre></pre> issue is not an issue for me.
>
> -Christopher
>
> On 9/20/06, Robert Cummings <robertinterjinn.com> wrote:
>> Should be an issue as long as you're not stripping whitespace from
>> between <pre></pre> tags. Although, one must wonder why you don't
>> just
>> use output compression since all that whitespace would just compress
>> anyways as would all the other content. In fact 900k with fairly
>> standard content would shrink to about 90k.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
Like Music?
http://l-i-e.com/artists.htm