php-general Digest 11 Jan 2008 16:01:34 -0000 Issue 5229

Topics (messages 267062 through 267079):

Re: Why is some_function()[some_index] invalid syntax?
        267062 by: Jim Lucas
        267063 by: Casey
        267064 by: Nathan Nobbe
        267065 by: Jim Lucas
        267066 by: Nathan Nobbe
        267068 by: Zoltán Németh
        267078 by: Nathan Nobbe

Re: PHP shell commands
        267067 by: Chris
        267071 by: Lucas Prado Melo
        267073 by: Richard Heyes
        267074 by: Bipin Upadhyay
        267075 by: Lucas Prado Melo

Browser cache setting
        267069 by: Richard Heyes
        267070 by: Per Jessen
        267072 by: Richard Heyes

Determine which are user defined keys?
        267076 by: Christoph Boget
        267077 by: Zoltán Németh

Re: /etc/php.init changes not honored
        267079 by: Jürgen Wind

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 ---
Arlen Christian Mart Cuss wrote:
Hi there,

Why is it that if I try to evaluate an index of an array returned by a
function immediately, a syntax error is produced? (unexpected '[',
expecting ',' or ';')

Thanks,
Arlen.


I asked that question years ago. It was explained to me that php does not have, what is called, messaging. Something that is in lower level languages.
--- End Message ---
--- Begin Message --- On Jan 10, 2008, at 8:00 PM, Arlen Christian Mart Cuss <[EMAIL PROTECTED] > wrote:

Hi there,

Why is it that if I try to evaluate an index of an array returned by a
function immediately, a syntax error is produced? (unexpected '[',
expecting ',' or ';')

Thanks,
Arlen.

I've run into this problem. (It works in Javascript >.>)

While I don't know why, you could store it in a temporary variable or use the list() language construct.

-Casey

--- End Message ---
--- Begin Message ---
On Jan 10, 2008 11:00 PM, Arlen Christian Mart Cuss <[EMAIL PROTECTED]>
wrote:

> Hi there,
>
> Why is it that if I try to evaluate an index of an array returned by a
> function immediately, a syntax error is produced? (unexpected '[',
> expecting ',' or ';')


thats hillarious, i literally brought this up at the office like 2 days ago.
ill tell you why its really lame (imho), because php5 supports syntax
like this:
function someFunc() {
  return date_create();
}
echo someFunc()->format('Y-m-d');

that is, it allows you to chain a method invocation to the invocation of a
function
if the function returns an object.

-nathan

--- End Message ---
--- Begin Message ---
Nathan Nobbe wrote:
On Jan 10, 2008 11:00 PM, Arlen Christian Mart Cuss <[EMAIL PROTECTED]>
wrote:

Hi there,

Why is it that if I try to evaluate an index of an array returned by a
function immediately, a syntax error is produced? (unexpected '[',
expecting ',' or ';')


thats hillarious, i literally brought this up at the office like 2 days ago.
ill tell you why its really lame (imho), because php5 supports syntax
like this:
function someFunc() {
  return date_create();
}
echo someFunc()->format('Y-m-d');

that is, it allows you to chain a method invocation to the invocation of a
function
if the function returns an object.

-nathan


So, make all your functions return objects, and have the object have a method called get or index or something like that that returns the index requested. :)

Better yet, make everything an object: String, Numeric, Array, etc

--- End Message ---
--- Begin Message ---
On Jan 11, 2008 12:25 AM, Jim Lucas <[EMAIL PROTECTED]> wrote:

> So, make all your functions return objects, and have the object have a
> method called get or index or something like that that returns the index
> requested.   :)
>
> Better yet, make everything an object: String, Numeric, Array, etc
>

i like using stdClass as a container sometimes, however it doesnt have
the plethora of utility functions that arrays do :(
there are workarounds of course, but obviously i just store the result to
a variable and subsequently use that.
this is just one of those little things picky, non-commiters like myself
bitch about :)

-nathan

--- End Message ---
--- Begin Message ---
2008. 01. 10, csütörtök keltezéssel 21.25-kor Jim Lucas ezt írta:
> Nathan Nobbe wrote:
> > On Jan 10, 2008 11:00 PM, Arlen Christian Mart Cuss <[EMAIL PROTECTED]>
> > wrote:
> > 
> >> Hi there,
> >>
> >> Why is it that if I try to evaluate an index of an array returned by a
> >> function immediately, a syntax error is produced? (unexpected '[',
> >> expecting ',' or ';')
> > 
> > 
> > thats hillarious, i literally brought this up at the office like 2 days ago.
> > ill tell you why its really lame (imho), because php5 supports syntax
> > like this:
> > function someFunc() {
> >   return date_create();
> > }
> > echo someFunc()->format('Y-m-d');
> > 
> > that is, it allows you to chain a method invocation to the invocation of a
> > function
> > if the function returns an object.
> > 
> > -nathan
> > 
> 
> So, make all your functions return objects, and have the object have a 
> method called get or index or something like that that returns the index 
> requested.   :)
> 
> Better yet, make everything an object: String, Numeric, Array, etc

and call it Java ;)

greets
Zoltán Németh

> 

--- End Message ---
--- Begin Message ---
On Jan 11, 2008 3:45 AM, Zoltán Németh <[EMAIL PROTECTED]> wrote:

> and call it Java ;)
>

or perhaps javascript :)
function cool() {
    return [1, 2, 3];
}
alert(cool()[0]);

-nathan

--- End Message ---
--- Begin Message ---
Lucas Prado Melo wrote:
Hello,
Some php applications store database passwords into files which can be
read by the user www-data.
So, a malicious user which can write php scripts could read those passwords.
What should I do to prevent users from viewing those passwords?

Not too much really.

The webserver needs to be able to read a config file.

You could obfuscate the fields/entries or encrypt them somehow, but it needs to be a two-way encryption (ie you're going to need to undo the encryption to be able to use the password).

--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
Suppose we were using apache webserver.
I think obfuscation won't work since with some work a user could read
the password.
How to encrypt/decrypt the password?

On Jan 11, 2008 3:37 AM, Chris <[EMAIL PROTECTED]> wrote:
> Not too much really.
>
> The webserver needs to be able to read a config file.
>
> You could obfuscate the fields/entries or encrypt them somehow, but it
> needs to be a two-way encryption (ie you're going to need to undo the
> encryption to be able to use the password).
>

--- End Message ---
--- Begin Message ---
Some php applications store database passwords into files which can be
read by the user www-data.
So, a malicious user which can write php scripts could read those passwords.
What should I do to prevent users from viewing those passwords?

You could encode your file(s) using something like the Zend Encoder. This turns them into byte code IIRC, so it's hard (not totally impossible I think) to get the clear text.

--
Richard Heyes
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support

** NOW OFFERING FREE ACCOUNTS TO CHARITIES AND NON-PROFITS **

--- End Message ---
--- Begin Message ---
Lucas Prado Melo wrote:
Hello,
Some php applications store database passwords into files which can be
read by the user www-data.
Why not keep them out of the web tree and inform the application regarding the same. I am sure almost all good applications would provide a simple way for doing it.

So, a malicious user which can write php scripts could read those passwords.
What should I do to prevent users from viewing those passwords?
I am not sure I understand this. Do you mean the attacker would upload scripts and execute them to read th config files? If yes then that's a different problem altogether.

regards


Regards,
Bipin Upadhyay.
http://projectbee.org

--- End Message ---
--- Begin Message ---
On Jan 11, 2008 9:33 AM, Bipin Upadhyay <[EMAIL PROTECTED]> wrote:
> Lucas Prado Melo wrote:
> > Hello,
> > Some php applications store database passwords into files which can be
> > read by the user www-data.
> Why not keep them out of the web tree and inform the application
> regarding the same. I am sure almost all good applications would provide
> a simple way for doing it.
> > So, a malicious user which can write php scripts could read those passwords.
> > What should I do to prevent users from viewing those passwords?
> I am not sure I understand this. Do you mean the attacker would upload
> scripts and execute them to read th config files? If yes then that's a
> different problem altogether.
Yes, I mean so.

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

What's the default setting for caching in browsers? With IE is it "Automatically" as I think it is? And what about other browsers? Some equivalent?

Thanks.

--
Richard Heyes
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support

** NOW OFFERING FREE ACCOUNTS TO CHARITIES AND NON-PROFITS **

--- End Message ---
--- Begin Message ---
Richard Heyes wrote:

> Hi,
> 
> What's the default setting for caching in browsers? With IE is it
> "Automatically" as I think it is? And what about other browsers? Some
> equivalent?

I'm pretty certain it's automatic in most. I think Firefox has a default
50Mb of cache-space. 


/Per Jessen, Zürich

--- End Message ---
--- Begin Message ---
I'm pretty certain it's automatic in most. I think Firefox has a default
50Mb of cache-space.

Great, thanks.

--
Richard Heyes
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support

** NOW OFFERING FREE ACCOUNTS TO CHARITIES AND NON-PROFITS **

--- End Message ---
--- Begin Message ---
Given the following array:

<?php
  $myArr = array( 'joe' => 'bob', "0" => 'briggs', 'whatever', 'whereever');
  echo '<pre>' . print_r( $myArr, TRUE ) . '</pre>';
?>

Array
(
 [joe] => bob
 [0] => briggs
 [1] => whatever
 [2] => whereever
)

"joe" and "0" are keys that I created whereas the key "1" and "2" are
keys assigned by PHP when the array was created.  When iterating
through an array, is there a way to determine which were generated by
PHP?  I can't rely on whether or not the key is an integer because
it's quite possible that such a key was user generated.  I've gone
through the docs and based on what I've read, I don't think something
like this is possible but I'm hoping that's not the case.

Any pointers?

thnx,
Christoph

--- End Message ---
--- Begin Message ---
2008. 01. 11, péntek keltezéssel 08.12-kor Christoph Boget ezt írta:
> Given the following array:
> 
> <?php
>   $myArr = array( 'joe' => 'bob', "0" => 'briggs', 'whatever', 'whereever');
>   echo '<pre>' . print_r( $myArr, TRUE ) . '</pre>';
> ?>
> 
> Array
> (
>  [joe] => bob
>  [0] => briggs
>  [1] => whatever
>  [2] => whereever
> )
> 
> "joe" and "0" are keys that I created whereas the key "1" and "2" are
> keys assigned by PHP when the array was created.  When iterating
> through an array, is there a way to determine which were generated by
> PHP?  I can't rely on whether or not the key is an integer because
> it's quite possible that such a key was user generated.  I've gone
> through the docs and based on what I've read, I don't think something
> like this is possible but I'm hoping that's not the case.

I don't think you can do that. Why not apply some modification to the
'user created' keys, like prepend them with a _ sign or something. in
that case you can know for sure if its a php generated key or not.

greets
Zoltán Németh

> 
> Any pointers?
> 
> thnx,
> Christoph
> 

--- End Message ---
--- Begin Message ---
>I do not see an entry stating "Loaded Configuration File" in the output 
this only available since php 5.2 (iirc)
-- 
View this message in context: 
http://www.nabble.com/-etc-php.init-changes-not-honored-tp14746039p14759509.html
Sent from the PHP - General mailing list archive at Nabble.com.

--- End Message ---

Reply via email to