Re: [PHP] Could this be a bug?

2010-09-15 Thread Thijs Lensselink

 On 09/14/2010 11:31 PM, Camilo Sperberg wrote:

On Tue, Sep 14, 2010 at 02:46, Thijs Lensselinkd...@lenss.nl  wrote:


  On 09/14/2010 08:33 AM, Thijs Lensselink wrote:


  On 09/14/2010 12:16 AM, Camilo Sperberg wrote:


I have some really strange behaviour going on here, and I think it could
be
a (minor) PHP's bug.
I am not really sure about what happens internally, but my best guess
would
be that after a memory exhaustion, when I try to execute a custom error
handler with the register_shutdown_function (which is executed even after
a
fatal error) and try to access the element that provoked the memory
exhaustion, no error should raise instead of *Uninitialized string
offset:
0.

I have prepared a little test case to reproduce the error and (I hope)
can
explain the error.

?php
date_default_timezone_set('America/Santiago');
ini_set('memory_limit','1M');
ini_set('display_errors',1);
error_reporting(-1);

function my_error_handler($errno = '0', $errstr = '[FATAL] General
Error',
$errfile = 'N/A', $errline = 'N/A', $errctx = '') {


This seems to be your error. You set $errctx to be a string. But later on
you use it as an array.
Remove the = '' part. And it will function as expected.


You're right... However I don't like leaving non-default value in functions
so I did something like if(empty($errctx)) $errctx = array() in the first
line of the custom error handler which threw out the error message and
everything works ok now.
I think from 5.2 and up you can use the array keyword to force an array 
as parameter..

But -and correct me if I'm wrong- isn't isset (or empty) supposed to return
a FALSE whenever that variable doesn't exist?

With your help, I could reduce the test case into:

$asdf = 'hello world';
if (empty($asdf[4]['inventing'])) echo 'nice little world';
if (isset($asdf['inventing'][6])) echo 'little nice world';
// This works ok.
This works because the string $asdf is set with a value. So $asdf[4] 
exists but ['inventing'] doesn't so it will return false

$asdf = '';
if (empty($asdf[4]['inventing'])) echo 'nice little world';
if (isset($asdf['inventing'][6])) echo 'little nice world';
// This returns E_NOTICE
This doesn't work because the string $asdf is empty. So calling $asdf[4] 
will trigger a notice since there is no 4th character

Shouldn't these 2 examples work exactly the same way? (AKA as Nº 1). If
not... why not? Both are string types, onyl difference is that one has no
characters in it while the other does, but essentialy they are both the
same.

Greetings !




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Question about news.php.net

2010-09-15 Thread MikeB

Gary wrote:

MikeB wrote:

I understand that the news server is based on a mailing list, but I
can't handle another high-volume source dumping stuff into my email
(even if I filter it into a separate folder) so I am trying to subscribe
through the news group.

However, getting access seems to be hit-and-miss, since I more often
than not get a message that the connection to news.php.net timed out.


Tried nntp://news.gmane.org/gmane.comp.php.general ?


Bingo!  Thanks!


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Xpath arguments in variable

2010-09-15 Thread Sridhar Pandurangiah

Hi

I have the following statement that locates the node membernumber with 
the value A192. This works perfectly fine.


$v = $row-xpath('//membernumber[. = A192]');

But now I need to pass this value to XPath within a string variable say

$v = $row-xpath('//membernumber[. = $MemberId]');

But this doesnt work due to the quotes. What I intend PHP to do is to 
substitute the value for $MemberId and then execute the XPath query. I 
have grappled with it for a few days before posting this. Any ideas are 
most welcome


Best regards

Sridhar

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Xpath arguments in variable

2010-09-15 Thread Ashley Sheridan
On Wed, 2010-09-15 at 13:06 +0530, Sridhar Pandurangiah wrote:

 Hi
 
 I have the following statement that locates the node membernumber with 
 the value A192. This works perfectly fine.
 
 $v = $row-xpath('//membernumber[. = A192]');
 
 But now I need to pass this value to XPath within a string variable say
 
 $v = $row-xpath('//membernumber[. = $MemberId]');
 
 But this doesnt work due to the quotes. What I intend PHP to do is to 
 substitute the value for $MemberId and then execute the XPath query. I 
 have grappled with it for a few days before posting this. Any ideas are 
 most welcome
 
 Best regards
 
 Sridhar
 


Use double quotes instead, which should allow PHP to expand the
variables.

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




[PHP] Re: Xpath arguments in variable

2010-09-15 Thread Sridhar Pandurangiah


 Original Message 
Subject: Re: Xpath arguments in variable
From: php-gene...@garydjones.name (Gary)
To:
Date: Wed Sep 15 2010 13:34:11 GMT+0530 (IST)

Whats wrong with
$v = $row-xpath('//membernumber[. = ' . $MemberId . ']');
?

Am I not understanding what you are trying to ask?



I tried this but doesn't work. I guess the above statement is 
concatenating the entire string and the substitution isn't happening


What I am trying to do is as follows
$MemberId = 'A192';
$v = $row-xpath('//membernumber[. = ' . $MemberId . ']');

The $MemberId should be substituted with A192 and then the xpath query 
should be executed. The result should be that I locate the membernumber 
XML element that has the value A912.


Best regards

Sridhar



Sridhar Pandurangiah wrote:

now I need to pass this value to XPath within a string variable say

$v = $row-xpath('//membernumber[. = $MemberId]');

But this doesnt work due to the quotes. What I intend PHP to do is to
substitute the value for $MemberId and then execute the XPath query. I
have grappled with it for a few days before posting this.


Whats wrong with 
$v = $row-xpath('//membernumber[. = ' . $MemberId . ']');

?

Am I not understanding what you are trying to ask?



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Xpath arguments in variable

2010-09-15 Thread Ashley Sheridan
On Wed, 2010-09-15 at 14:03 +0530, Sridhar Pandurangiah wrote:

  Original Message 
 Subject: Re: Xpath arguments in variable
 From: php-gene...@garydjones.name (Gary)
 To:
 Date: Wed Sep 15 2010 13:34:11 GMT+0530 (IST)
 
 Whats wrong with
 $v = $row-xpath('//membernumber[. = ' . $MemberId . ']');
 ?
 
 Am I not understanding what you are trying to ask?
 
 
 
 I tried this but doesn't work. I guess the above statement is 
 concatenating the entire string and the substitution isn't happening
 
 What I am trying to do is as follows
 $MemberId = 'A192';
 $v = $row-xpath('//membernumber[. = ' . $MemberId . ']');
 
 The $MemberId should be substituted with A192 and then the xpath query 
 should be executed. The result should be that I locate the membernumber 
 XML element that has the value A912.
 
 Best regards
 
 Sridhar
 
 
  Sridhar Pandurangiah wrote:
  now I need to pass this value to XPath within a string variable say
 
  $v = $row-xpath('//membernumber[. = $MemberId]');
 
  But this doesnt work due to the quotes. What I intend PHP to do is to
  substitute the value for $MemberId and then execute the XPath query. I
  have grappled with it for a few days before posting this.
  
  Whats wrong with 
  $v = $row-xpath('//membernumber[. = ' . $MemberId . ']');
  ?
  
  Am I not understanding what you are trying to ask?
  
 


Did you try using double quotes?

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




[PHP] Re: Xpath arguments in variable

2010-09-15 Thread Pete Ford
If you needed the double-quotes in the Xpath expression when the constant is 
used , then you probably need them in the variable version.


$v = $row-xpath('//membernumber[. = '.$MemberId.']');

That should put the double-quotes in for you...

On 15/09/10 09:33, Sridhar Pandurangiah wrote:


 Original Message 
Subject: Re: Xpath arguments in variable
From: php-gene...@garydjones.name (Gary)
To:
Date: Wed Sep 15 2010 13:34:11 GMT+0530 (IST)

Whats wrong with
$v = $row-xpath('//membernumber[. = ' . $MemberId . ']');
?

Am I not understanding what you are trying to ask?



I tried this but doesn't work. I guess the above statement is
concatenating the entire string and the substitution isn't happening

What I am trying to do is as follows
$MemberId = 'A192';
$v = $row-xpath('//membernumber[. = ' . $MemberId . ']');

The $MemberId should be substituted with A192 and then the xpath query
should be executed. The result should be that I locate the membernumber
XML element that has the value A912.

Best regards

Sridhar



Sridhar Pandurangiah wrote:

now I need to pass this value to XPath within a string variable say

$v = $row-xpath('//membernumber[. = $MemberId]');

But this doesnt work due to the quotes. What I intend PHP to do is to
substitute the value for $MemberId and then execute the XPath query. I
have grappled with it for a few days before posting this.


Whats wrong with $v = $row-xpath('//membernumber[. = ' . $MemberId .
']');
?

Am I not understanding what you are trying to ask?




--
Peter Ford, Developer phone: 01580 89 fax: 01580 893399
Justcroft International Ltd.  www.justcroft.com
Justcroft House, High Street, Staplehurst, Kent   TN12 0AH   United Kingdom
Registered in England and Wales: 2297906
Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Xpath arguments in variable

2010-09-15 Thread Sridhar Pandurangiah

Managed to resolve it. Phew!

$v = $row-xpath('//membernumber[. = ' . '' . $MemberId . '' . ']');

works.

Best regards

Sridhar


 Original Message 
Subject: Re: [PHP] Re: Xpath arguments in variable
From: a...@ashleysheridan.co.uk (Ashley Sheridan)
To:
Date: Wed Sep 15 2010 14:04:33 GMT+0530 (IST)


On Wed, 2010-09-15 at 14:03 +0530, Sridhar Pandurangiah wrote:


 Original Message 
Subject: Re: Xpath arguments in variable
From: php-gene...@garydjones.name (Gary)
To:
Date: Wed Sep 15 2010 13:34:11 GMT+0530 (IST)

Whats wrong with
$v = $row-xpath('//membernumber[. = ' . $MemberId . ']');
?

Am I not understanding what you are trying to ask?



I tried this but doesn't work. I guess the above statement is 
concatenating the entire string and the substitution isn't happening


What I am trying to do is as follows
$MemberId = 'A192';
$v = $row-xpath('//membernumber[. = ' . $MemberId . ']');

The $MemberId should be substituted with A192 and then the xpath query 
should be executed. The result should be that I locate the membernumber 
XML element that has the value A912.


Best regards

Sridhar



Sridhar Pandurangiah wrote:

now I need to pass this value to XPath within a string variable say

$v = $row-xpath('//membernumber[. = $MemberId]');

But this doesnt work due to the quotes. What I intend PHP to do is to
substitute the value for $MemberId and then execute the XPath query. I
have grappled with it for a few days before posting this.
Whats wrong with 
$v = $row-xpath('//membernumber[. = ' . $MemberId . ']');

?

Am I not understanding what you are trying to ask?




Did you try using double quotes?

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





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Xpath arguments in variable

2010-09-15 Thread Ashley Sheridan
On Wed, 2010-09-15 at 14:27 +0530, Sridhar Pandurangiah wrote:
 Managed to resolve it. Phew!
 
 $v = $row-xpath('//membernumber[. = ' . '' . $MemberId . '' . ']');
 
 works.
 
 Best regards
 
 Sridhar
 
 
  Original Message 
 Subject: Re: [PHP] Re: Xpath arguments in variable
 From: a...@ashleysheridan.co.uk (Ashley Sheridan)
 To:
 Date: Wed Sep 15 2010 14:04:33 GMT+0530 (IST)
 
  On Wed, 2010-09-15 at 14:03 +0530, Sridhar Pandurangiah wrote:
  
   Original Message 
  Subject: Re: Xpath arguments in variable
  From: php-gene...@garydjones.name (Gary)
  To:
  Date: Wed Sep 15 2010 13:34:11 GMT+0530 (IST)
 
  Whats wrong with
  $v = $row-xpath('//membernumber[. = ' . $MemberId . ']');
  ?
 
  Am I not understanding what you are trying to ask?
 
  
 
  I tried this but doesn't work. I guess the above statement is 
  concatenating the entire string and the substitution isn't happening
 
  What I am trying to do is as follows
  $MemberId = 'A192';
  $v = $row-xpath('//membernumber[. = ' . $MemberId . ']');
 
  The $MemberId should be substituted with A192 and then the xpath query 
  should be executed. The result should be that I locate the membernumber 
  XML element that has the value A912.
 
  Best regards
 
  Sridhar
 
 
  Sridhar Pandurangiah wrote:
  now I need to pass this value to XPath within a string variable say
 
  $v = $row-xpath('//membernumber[. = $MemberId]');
 
  But this doesnt work due to the quotes. What I intend PHP to do is to
  substitute the value for $MemberId and then execute the XPath query. I
  have grappled with it for a few days before posting this.
  Whats wrong with 
  $v = $row-xpath('//membernumber[. = ' . $MemberId . ']');
  ?
 
  Am I not understanding what you are trying to ask?
 
  
  
  Did you try using double quotes?
  
  Thanks,
  Ash
  http://www.ashleysheridan.co.uk
  
  
  
 
Wouldn't

$v = $row-xpath('//membernumber[. = ' . $MemberId . ']');

be better? You're breaking the string into too many parts for now
reason.

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




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] php cli question

2010-09-15 Thread Bostjan Skufca
Here are the results I got when question of migration from apache to nginx
was brought up:
http://blog.a2o.si/2009/06/24/apache-mod_php-compared-to-nginx-php-fpm/
(BTW there is some FPM in main PHP distribution now)

As for resource management, I recommend looking at php sources
(Zend/zend_alloca.c:zend_mm_shutdown() specifically) and building a custom
extension that frees discarded memory resources on your request or timer or
sth else. Not sure if it is possible like that but this is just a
suggestion, don't quote me on that :)
Also, for such questions I recommend you to join php-internals mailing list,
it seems more appropriate.

b.


On 15 September 2010 04:19, J Ravi Menon jravime...@gmail.com wrote:

 On Tue, Sep 14, 2010 at 1:15 PM, Per Jessen p...@computer.org wrote:
  J Ravi Menon wrote:
 
  On Tue, Sep 14, 2010 at 12:43 AM, Per Jessen p...@computer.org wrote:
  J Ravi Menon wrote:
 
  Few questions:
 
  1) Does opcode cache really matter in such cli-based daemons? As
  'SomeClass' is instantiated at every loop, I am assuming it is only
  compiled once as it has already been 'seen'.
 
  Yup.
 
  Just to clarify, you mean we don't need the op-code cache here right?
 
  That is correct.
 
  2) What about garbage collection? In a standard apache-mod-php
  setup, we rely on the end of a request-cycle to free up resources -
  close file descriptiors, free up memory etc..
  I am assuming in the aforesaid standalone daemon case, we would
  have to do this manually?
 
  Yes.
 
  So 'unset($some_big_array)'  or 'unset($some_big_object)' etc.. is the
  right way to go for non-resource based items? i.e. it needs to be
  explicitly done?
 
  It's not quite like C - if you reassign something, the previous contents
  are automagically freed.  I use unset() if I know it could be a while
  (hours) before it'll likely be reassigned, but it won't be used in the
  meantime.
 

 Thanks Per for clarifying this for me. Now on my follow up question:

 [Note: I think it is related to the issues discussed above hence
 keeping it on this thread but if I am violating any guidelines here,
 do let me know]

 One reason the aforesaid questions got triggered was that in our
 company right now, there is a big discussion on moving away from
 apache+mod_php solution to nginx+fast-cgi based model for handling all
 php-based services. The move seems to be more based some anecdotal
 observations and possibly not based on a typical php-based app (i.e.
 the php script involved was trivial one acting as some proxy to
 another backend service).

 I have written fast-cgi servers in the past in C++, and I am aware how
 the apahcefast-cgi-servers work (in unix socket setups).  All
 our php apps are written with apache+mod_php in mind (no explicit
 resource mgmt ), so this was a concern to me.

 If the same scripts now need to run 'forever' as a fastcgi server, are
 we forced to do such manual resource mgmt? Or are there solutions here
 that work just as in mod_php?

 This reminded me of the cli daemons that I had written earlier where
 such manual cleanups were done, and hence my doubts on this
 nginx+fast-cgi approach.

 thx,
 Ravi


 
 
  --
  Per Jessen, Zürich (14.6°C)
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] How to store data that doesn't change?

2010-09-15 Thread Peter van der Does
Hi,

How do you people store data that doesn't change, an example of this
would be the version number of your software. You might want to use it
through out your program but how to you store it?

As far as I can see there are several options to use this data.
1. Global Variable
2. Store it in a registry class
3. Store it in a named constant.
4. Use a function that will return the data (kind of like a regsitry
class but it's not a class)

Personally I don't like option 1 but what about the other options. Is
any of them faster then the others. What other pros and cons are there.

-- 
Peter van der Does

GPG key: E77E8E98

IRC: Ganseki on irc.freenode.net
Twitter: @petervanderdoes

WordPress Plugin Developer
Blog: http://blog.avirtualhome.com
Forums: http://forums.avirtualhome.com
Twitter: @avhsoftware

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to store data that doesn't change?

2010-09-15 Thread Peter Lind
On 15 September 2010 14:46, Peter van der Does pvanderd...@gmail.com wrote:
 Hi,

 How do you people store data that doesn't change, an example of this
 would be the version number of your software. You might want to use it
 through out your program but how to you store it?

 As far as I can see there are several options to use this data.
 1. Global Variable
 2. Store it in a registry class
 3. Store it in a named constant.
 4. Use a function that will return the data (kind of like a regsitry
 class but it's not a class)

 Personally I don't like option 1 but what about the other options. Is
 any of them faster then the others. What other pros and cons are there.


3. Constant, as long as you're dealing with scalars.

Regards
Peter

-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
/hype

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to store data that doesn't change?

2010-09-15 Thread Ashley Sheridan
On Wed, 2010-09-15 at 08:46 -0400, Peter van der Does wrote:

 Hi,
 
 How do you people store data that doesn't change, an example of this
 would be the version number of your software. You might want to use it
 through out your program but how to you store it?
 
 As far as I can see there are several options to use this data.
 1. Global Variable
 2. Store it in a registry class
 3. Store it in a named constant.
 4. Use a function that will return the data (kind of like a regsitry
 class but it's not a class)
 
 Personally I don't like option 1 but what about the other options. Is
 any of them faster then the others. What other pros and cons are there.
 
 -- 
 Peter van der Does
 
 GPG key: E77E8E98
 
 IRC: Ganseki on irc.freenode.net
 Twitter: @petervanderdoes
 
 WordPress Plugin Developer
 Blog: http://blog.avirtualhome.com
 Forums: http://forums.avirtualhome.com
 Twitter: @avhsoftware
 


I'd go with a constant, for the simple reason that it means the variable
can't and shouldn't change in the execution of the script. The constant
could be within a class or a global, however you prefer. There will be
slightly more memory used in a class, but it avoids the constant from
conflicting with others in the script possibly.

Creating a whole function or class for this does seem a little overkill
probably, so a simple global constant should do the job really.

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




Re: [PHP] 1984 (Big Brother)

2010-09-15 Thread Marc Guay
 if(file_exists('boss_man_say_okay') ){ // let monkeys work }

Is there an acronym for the sound of sad, knowing laughter?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Install library

2010-09-15 Thread Jordan Jovanov

Hello All,

I have one very funny question. A need me PDFlibrary.
Can somebody tall me how can I download and install on my server this 
library. I use PuTTy to connect to my server.

Does somebody know the command line for download in istall library in php.

Thanks a lot.

Best Regards,
Jordan

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Install library

2010-09-15 Thread Ashley Sheridan
On Wed, 2010-09-15 at 15:16 +0200, Jordan Jovanov wrote:

 Hello All,
 
 I have one very funny question. A need me PDFlibrary.
 Can somebody tall me how can I download and install on my server this 
 library. I use PuTTy to connect to my server.
 Does somebody know the command line for download in istall library in php.
 
 Thanks a lot.
 
 Best Regards,
 Jordan
 


I assume you mean the PDFLibrary that is offered as an SDK from Adobe?
I'm also assuming a Linux server if you're using Putty to connect.

Are these assumptions right? If they are, then I don't think you'll have
much luck. You can't just plug in any old thing into PHP and have it
work. Have you maybe considered using something like fpdf instead, which
is written in PHP and can produce PDF documents with just a small amount
of code.

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




[PHP] bcompiler: compile in a diferent directory

2010-09-15 Thread Ramiro Gonzalez
I use bcompiler in my php
code(bcompiler_write_header+bcompiler_write_file+bcompiler_write_footer).
If the original phps are not located in the deployment directory, when I
ejecute the compiled code(In deployment directory)
I get an error because require_once use the path to the not compiled phps.
I'd like to know if there is any way to compile the phps and use the
compiled versión from a different directory.

Thanks
Ramiro


[PHP] Sending Encrypted Email

2010-09-15 Thread Floyd Resler
This is kind of both on and off topic.  I need to send encrypted email.  I have 
found code to do this but I'm not sure which certificate file to use.  Can I 
use our server's signed certificate we use for Apache?  Does anyone know of a 
clear, step-by-step tutorial?

Thanks!
Floyd


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Xpath arguments in variable

2010-09-15 Thread David Harkness
And let's not forget

$v = $row-xpath(//membernumber[. = \$MemberId\]);

The \ inside the string turns into a double-quote and using  to delimit
the string allows for variable substitution.


Re: [PHP] Question about news.php.net

2010-09-15 Thread MikeB

Daniel Brown wrote:

On Mon, Sep 13, 2010 at 19:51, MikeBmpbr...@gmail.com  wrote:


As part of the bug report I included a link to an image of my nntp config.


 I saw that, thanks.  I'll look into creating a mirror of the news
server, as well, for NNTP-only access.  I won't lie and say that it's
a priority, but I'll try to get to it as soon as I have time, Mike.


You must have already done something. It's working a lot better today.

Thanks.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] php cli question

2010-09-15 Thread J Ravi Menon
Thanks Bostjan for the suggestion. I did raise the issue and here is the reply:

http://news.php.net/php.internals/49672

Thx,
Ravi


On Wed, Sep 15, 2010 at 2:38 AM, Bostjan Skufca bost...@a2o.si wrote:
 Here are the results I got when question of migration from apache to nginx
 was brought up:
 http://blog.a2o.si/2009/06/24/apache-mod_php-compared-to-nginx-php-fpm/
 (BTW there is some FPM in main PHP distribution now)

 As for resource management, I recommend looking at php sources
 (Zend/zend_alloca.c:zend_mm_shutdown() specifically) and building a custom
 extension that frees discarded memory resources on your request or timer or
 sth else. Not sure if it is possible like that but this is just a
 suggestion, don't quote me on that :)
 Also, for such questions I recommend you to join php-internals mailing list,
 it seems more appropriate.

 b.


 On 15 September 2010 04:19, J Ravi Menon jravime...@gmail.com wrote:

 On Tue, Sep 14, 2010 at 1:15 PM, Per Jessen p...@computer.org wrote:
  J Ravi Menon wrote:
 
  On Tue, Sep 14, 2010 at 12:43 AM, Per Jessen p...@computer.org wrote:
  J Ravi Menon wrote:
 
  Few questions:
 
  1) Does opcode cache really matter in such cli-based daemons? As
  'SomeClass' is instantiated at every loop, I am assuming it is only
  compiled once as it has already been 'seen'.
 
  Yup.
 
  Just to clarify, you mean we don't need the op-code cache here right?
 
  That is correct.
 
  2) What about garbage collection? In a standard apache-mod-php
  setup, we rely on the end of a request-cycle to free up resources -
  close file descriptiors, free up memory etc..
  I am assuming in the aforesaid standalone daemon case, we would
  have to do this manually?
 
  Yes.
 
  So 'unset($some_big_array)'  or 'unset($some_big_object)' etc.. is the
  right way to go for non-resource based items? i.e. it needs to be
  explicitly done?
 
  It's not quite like C - if you reassign something, the previous contents
  are automagically freed.  I use unset() if I know it could be a while
  (hours) before it'll likely be reassigned, but it won't be used in the
  meantime.
 

 Thanks Per for clarifying this for me. Now on my follow up question:

 [Note: I think it is related to the issues discussed above hence
 keeping it on this thread but if I am violating any guidelines here,
 do let me know]

 One reason the aforesaid questions got triggered was that in our
 company right now, there is a big discussion on moving away from
 apache+mod_php solution to nginx+fast-cgi based model for handling all
 php-based services. The move seems to be more based some anecdotal
 observations and possibly not based on a typical php-based app (i.e.
 the php script involved was trivial one acting as some proxy to
 another backend service).

 I have written fast-cgi servers in the past in C++, and I am aware how
 the apahcefast-cgi-servers work (in unix socket setups).  All
 our php apps are written with apache+mod_php in mind (no explicit
 resource mgmt ), so this was a concern to me.

 If the same scripts now need to run 'forever' as a fastcgi server, are
 we forced to do such manual resource mgmt? Or are there solutions here
 that work just as in mod_php?

 This reminded me of the cli daemons that I had written earlier where
 such manual cleanups were done, and hence my doubts on this
 nginx+fast-cgi approach.

 thx,
 Ravi


 
 
  --
  Per Jessen, Zürich (14.6°C)
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] 1984 (Big Brother)

2010-09-15 Thread Yousif Masoud

On 12/09/10 17:32, tedd wrote:

Hi gang:

I have a client who wants his employees' access to their online 
business database restricted to only times when he is logged on. 
(Don't ask why)


In other words, when the boss is not logged on, then his employees 
cannot access the business database in any fashion whatsoever 
including checking to see if the boss is logged on, or not. No access 
whatsoever!


Normally, I would just set up a field in the database and have that 
set to yes or no as to if the employees could access the database, 
or not. But in this case, the boss does not want even that type of 
access to the database permitted. Repeat -- No access whatsoever!


I was thinking of the boss' script writing to a file that accomplished 
the yes or no thing, but if the boss did not log off properly then 
the file would remain in the yes state allowing employees undesired 
access. That would not be acceptable.


So, what methods would you suggest?

Cheers,

tedd


Hi Tedd,
One aspect of software design to keep in mind is change.  Today the 
customer wants everyone to have access when they are logged in.  They 
may want that rule relaxed a little.  Perhaps, employees can login when 
members of a certain group are logged in.


I recommend using some form of external device that instructs the system 
to enable/disable access to the database. Depending on the sensitivity 
of the data, the solution can utilize a card reader (once the boss takes 
the card out of the reader, database access is terminated for the 
company) and either a fingerprint or retinal scanner [for extra 
security].  If it is really sensitive data, then a retinal scanner and 
some form of code generator that generates one-time eight digit (at 
least) code to enable access to the database.  The algorithm that 
generates the codes would be a deeply guarded secret (that would mostly 
be their problem -- you will need to ensure that once you sign off the 
project, there is no way it can be retrieved from you).


No need to shut down the database server, just instruct the firewall to 
block the MySQL port and/or Web server port.  Might be a good idea to 
choose a different port than 3306 for MySQL.


What would happen if, for some reason the boss couldn't make it in or 
is on Holiday?


Good luck,
Yousif

PS. It might be a good idea to introduce them to the concept of RBAC and 
see what they think.




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] 1984 (Big Brother)

2010-09-15 Thread Matty Sarro
Ooooh, how about a pressure sensor on his seat??? Like the ones they have in
cars to make that little airbag light illuminate.

if buttDetected{
allowAccess();
}

On Wed, Sep 15, 2010 at 7:00 PM, Yousif Masoud yousif.mas...@gmail.comwrote:

 On 12/09/10 17:32, tedd wrote:

 Hi gang:

 I have a client who wants his employees' access to their online business
 database restricted to only times when he is logged on. (Don't ask why)

 In other words, when the boss is not logged on, then his employees cannot
 access the business database in any fashion whatsoever including checking to
 see if the boss is logged on, or not. No access whatsoever!

 Normally, I would just set up a field in the database and have that set to
 yes or no as to if the employees could access the database, or not. But
 in this case, the boss does not want even that type of access to the
 database permitted. Repeat -- No access whatsoever!

 I was thinking of the boss' script writing to a file that accomplished the
 yes or no thing, but if the boss did not log off properly then the file
 would remain in the yes state allowing employees undesired access. That
 would not be acceptable.

 So, what methods would you suggest?

 Cheers,

 tedd

  Hi Tedd,
 One aspect of software design to keep in mind is change.  Today the
 customer wants everyone to have access when they are logged in.  They may
 want that rule relaxed a little.  Perhaps, employees can login when members
 of a certain group are logged in.

 I recommend using some form of external device that instructs the system to
 enable/disable access to the database. Depending on the sensitivity of the
 data, the solution can utilize a card reader (once the boss takes the card
 out of the reader, database access is terminated for the company) and either
 a fingerprint or retinal scanner [for extra security].  If it is really
 sensitive data, then a retinal scanner and some form of code generator that
 generates one-time eight digit (at least) code to enable access to the
 database.  The algorithm that generates the codes would be a deeply guarded
 secret (that would mostly be their problem -- you will need to ensure that
 once you sign off the project, there is no way it can be retrieved from
 you).

 No need to shut down the database server, just instruct the firewall to
 block the MySQL port and/or Web server port.  Might be a good idea to choose
 a different port than 3306 for MySQL.

 What would happen if, for some reason the boss couldn't make it in or is
 on Holiday?

 Good luck,
 Yousif

 PS. It might be a good idea to introduce them to the concept of RBAC and
 see what they think.



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] 1984 (Big Brother)

2010-09-15 Thread Phpster
Next we'll be suggesting sharks with frikking laser attached to their heads to 
guard the door!

Bastien

Sent from my iPod

On Sep 15, 2010, at 19:53, Matty Sarro msa...@gmail.com wrote:

 Ooooh, how about a pressure sensor on his seat??? Like the ones they have in
 cars to make that little airbag light illuminate.
 
 if buttDetected{
 allowAccess();
 }
 
 On Wed, Sep 15, 2010 at 7:00 PM, Yousif Masoud yousif.mas...@gmail.comwrote:
 
 On 12/09/10 17:32, tedd wrote:
 
 Hi gang:
 
 I have a client who wants his employees' access to their online business
 database restricted to only times when he is logged on. (Don't ask why)
 
 In other words, when the boss is not logged on, then his employees cannot
 access the business database in any fashion whatsoever including checking to
 see if the boss is logged on, or not. No access whatsoever!
 
 Normally, I would just set up a field in the database and have that set to
 yes or no as to if the employees could access the database, or not. But
 in this case, the boss does not want even that type of access to the
 database permitted. Repeat -- No access whatsoever!
 
 I was thinking of the boss' script writing to a file that accomplished the
 yes or no thing, but if the boss did not log off properly then the file
 would remain in the yes state allowing employees undesired access. That
 would not be acceptable.
 
 So, what methods would you suggest?
 
 Cheers,
 
 tedd
 
 Hi Tedd,
 One aspect of software design to keep in mind is change.  Today the
 customer wants everyone to have access when they are logged in.  They may
 want that rule relaxed a little.  Perhaps, employees can login when members
 of a certain group are logged in.
 
 I recommend using some form of external device that instructs the system to
 enable/disable access to the database. Depending on the sensitivity of the
 data, the solution can utilize a card reader (once the boss takes the card
 out of the reader, database access is terminated for the company) and either
 a fingerprint or retinal scanner [for extra security].  If it is really
 sensitive data, then a retinal scanner and some form of code generator that
 generates one-time eight digit (at least) code to enable access to the
 database.  The algorithm that generates the codes would be a deeply guarded
 secret (that would mostly be their problem -- you will need to ensure that
 once you sign off the project, there is no way it can be retrieved from
 you).
 
 No need to shut down the database server, just instruct the firewall to
 block the MySQL port and/or Web server port.  Might be a good idea to choose
 a different port than 3306 for MySQL.
 
 What would happen if, for some reason the boss couldn't make it in or is
 on Holiday?
 
 Good luck,
 Yousif
 
 PS. It might be a good idea to introduce them to the concept of RBAC and
 see what they think.
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php