On 10/06/2003 11:50 AM CST, the OP, 127.0.0.1, wrote:[color=blue]
> httpget $user_id;
> httppost $credit_card;
> session $really_importa nt_stuff;
>
> Each of these declaration lines would effectively enable
> register_global s for one specific variable in one particular method
> (GET, POST or session).
>
> Creative suggestions, comments would be welcome.[/color]
Justin Koivisto wrote:[color=blue]
> The proposal in the form of functions:
>
> <?php
> // usage example
> global_session( 'var1');
>
> function global_get($var ){
> if(!array_key_e xists($var,$_GE T))
> $_GET[$var]='';
> $GLOBALS[$var]=&$_GET[$var];
> }
>
> function global_post($va r){
> if(!array_key_e xists($var,$_PO ST))
> $_POST[$var]='';
> $GLOBALS[$var]=&$_POST[$var];
> }
>
> function global_session( $var){
> if(!array_key_e xists($var,$_SE SSION))
> $_SESSION[$var]='';
> $GLOBALS[$var]=&$_SESSION[$var];
> }
>
> function global_cookie($ var){
> if(!array_key_e xists($var,$_CO OKIE))
> $_COOKIE[$var]='';
> $GLOBALS[$var]=&$_COOKIE[$var];
> }
>
> function global_server($ var){
> if(!array_key_e xists($var,$_SE RVER))
> $_SERVER[$var]='';
> $GLOBALS[$var]=&$_SERVER[$var];
> }
>
> function global_files($v ar){
> if(!array_key_e xists($var,$_FI LES))
> $_FILES[$var]='';
> $GLOBALS[$var]=&$_FILES[$var];
> }
>
> function global_env($var ){
> if(!array_key_e xists($var,$_EN V))
> $_ENV[$var]='';
> $GLOBALS[$var]=&$_ENV[$var];
> }
>
> function global_request( $var){
> if(!array_key_e xists($var,$_RE QUEST))
> $_REQUEST[$var]='';
> $GLOBALS[$var]=&$_REQUEST[$var];
> }
> ?>
>[color=green]
>> The proposal makes it explicit which variables you expect to use from
>> the _GET array, so an unexpected variable won't get extracted and
>> overwrite the session variable you intended to use. You get nearly
>> the convenience of register_global s=on with none of the security
>> risk.[/color]
>
> I broadened the scope of the proposal in the process. These functions
> now support all of the super globals (except$ GLOBALS)in PHP. I also
> changed the names to be prefixed by global_ and then the lowercase
> name of the superglobal array to play with.
>
> Also, I thought about the case where the key didn't exist in the
> superglobal. If this is the case, the key is created and then
> referenced. This would likely be handy for _SESSION more than
> anything.[/color]
Just wanted to follow-up on this one. Did this actually satisfy the
proposal set forth by the OP? I haven't noticed any posts to the thread
since I submitted this.
Ideas/comments/suggestions welcome on this as well.
--
Justin Koivisto - spam@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.
> httpget $user_id;
> httppost $credit_card;
> session $really_importa nt_stuff;
>
> Each of these declaration lines would effectively enable
> register_global s for one specific variable in one particular method
> (GET, POST or session).
>
> Creative suggestions, comments would be welcome.[/color]
Justin Koivisto wrote:[color=blue]
> The proposal in the form of functions:
>
> <?php
> // usage example
> global_session( 'var1');
>
> function global_get($var ){
> if(!array_key_e xists($var,$_GE T))
> $_GET[$var]='';
> $GLOBALS[$var]=&$_GET[$var];
> }
>
> function global_post($va r){
> if(!array_key_e xists($var,$_PO ST))
> $_POST[$var]='';
> $GLOBALS[$var]=&$_POST[$var];
> }
>
> function global_session( $var){
> if(!array_key_e xists($var,$_SE SSION))
> $_SESSION[$var]='';
> $GLOBALS[$var]=&$_SESSION[$var];
> }
>
> function global_cookie($ var){
> if(!array_key_e xists($var,$_CO OKIE))
> $_COOKIE[$var]='';
> $GLOBALS[$var]=&$_COOKIE[$var];
> }
>
> function global_server($ var){
> if(!array_key_e xists($var,$_SE RVER))
> $_SERVER[$var]='';
> $GLOBALS[$var]=&$_SERVER[$var];
> }
>
> function global_files($v ar){
> if(!array_key_e xists($var,$_FI LES))
> $_FILES[$var]='';
> $GLOBALS[$var]=&$_FILES[$var];
> }
>
> function global_env($var ){
> if(!array_key_e xists($var,$_EN V))
> $_ENV[$var]='';
> $GLOBALS[$var]=&$_ENV[$var];
> }
>
> function global_request( $var){
> if(!array_key_e xists($var,$_RE QUEST))
> $_REQUEST[$var]='';
> $GLOBALS[$var]=&$_REQUEST[$var];
> }
> ?>
>[color=green]
>> The proposal makes it explicit which variables you expect to use from
>> the _GET array, so an unexpected variable won't get extracted and
>> overwrite the session variable you intended to use. You get nearly
>> the convenience of register_global s=on with none of the security
>> risk.[/color]
>
> I broadened the scope of the proposal in the process. These functions
> now support all of the super globals (except$ GLOBALS)in PHP. I also
> changed the names to be prefixed by global_ and then the lowercase
> name of the superglobal array to play with.
>
> Also, I thought about the case where the key didn't exist in the
> superglobal. If this is the case, the key is created and then
> referenced. This would likely be handy for _SESSION more than
> anything.[/color]
Just wanted to follow-up on this one. Did this actually satisfy the
proposal set forth by the OP? I haven't noticed any posts to the thread
since I submitted this.
Ideas/comments/suggestions welcome on this as well.
--
Justin Koivisto - spam@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.
Comment