Foros del Web » Programando para Internet » PHP »

Como apagar "register_globals"?

Estas en el tema de Como apagar "register_globals"? en el foro de PHP en Foros del Web. Hola. Tengo una web alojada en freehostia (jaja) y le he instalado Joomla! Me dice que por seguridad apague un tal "register_globals". La verdad es ...
  #1 (permalink)  
Antiguo 05/04/2007, 15:22
 
Fecha de Ingreso: abril-2007
Mensajes: 1
Antigüedad: 17 años
Puntos: 0
Como apagar "register_globals"?

Hola. Tengo una web alojada en freehostia (jaja) y le he instalado Joomla!

Me dice que por seguridad apague un tal "register_globals". La verdad es que no se lo que es, ni donde lo puedo desactivar.

Alguien me puede ayudar? Supongo que sera un archivo.php, y tendre que cambiar algo del texto de "on" a "off". En ese caso, me podriais decir donde esta de las carpetas de Joomla! ?

Gracias y saludos ;)
  #2 (permalink)  
Antiguo 05/04/2007, 15:30
Avatar de canzoneta  
Fecha de Ingreso: diciembre-2003
Ubicación: Mendoza
Mensajes: 79
Antigüedad: 20 años, 4 meses
Puntos: 1
Re: Como apagar "register_globals"?

Hola x2v1jump.

Lamentablemente el "register_globals" se controla con el php.ini, que es un archivo que sólo tienen acceso los administradores del hosting.

En el caso de los servidores pagos, tu puedes pedirles que hagan las modificaciones que nesecitas. Pero al tratarse de un free hosting, no sé si cuentas con esa posibilidad.
  #3 (permalink)  
Antiguo 05/04/2007, 15:36
Avatar de nicolaspar  
Fecha de Ingreso: noviembre-2004
Ubicación: Villa Ballester Bs-As|Ar
Mensajes: 2.002
Antigüedad: 19 años, 5 meses
Puntos: 34
Re: Como apagar "register_globals"?

Todo se puede canzoneta ;)

Poné esto en el head de todas las páginas (un include en común mejor aún)

Código PHP:
if (ini_get("register_globals")){
    foreach (
$_REQUEST as $k => $v){
        unset(
$GLOBALS[$k]);
        unset($
$k);
    }


También podes hacer un .htaccess, pero esto es más simple.
__________________
Mi punto de partida es Que Bueno Lo Nuevo
  #4 (permalink)  
Antiguo 05/04/2007, 16:24
Avatar de canzoneta  
Fecha de Ingreso: diciembre-2003
Ubicación: Mendoza
Mensajes: 79
Antigüedad: 20 años, 4 meses
Puntos: 1
Re: Como apagar "register_globals"?

Gracias por la sugerencia nicolaspar, pero yo soy usuario de joomla, y éste ya trae un emulador de "register globals = off". Abajo te lo muestro.

Incluso, activando éste emulador, joomla sigue con su molesto mensaje en el que se recomienda desactivar "register_globals". Tal vez, tanto x2v1jump como yo deberíamos visitar el fotro joomla.

Código PHP:
defined'_VALID_MOS' ) or die( 'Restricted access' );

define'RG_EMULATION');

function 
checkInputArray( &$array$globalise=false ) {
    static 
$banned = array( '_files''_env''_get''_post''_cookie''_server''_session''globals' );

    foreach (
$array as $key => $value) {
        
$intval intval$key );
        
// PHP GLOBALS injection bug 
        
$failed in_arraystrtolower$key ), $banned );
        
// PHP Zend_Hash_Del_Key_Or_Index bug
        
$failed |= is_numeric$key );
        if (
$failed) {
            die( 
'Illegal variable <b>' implode'</b> or <b>'$banned ) . '</b> passed to script.' );
        }
        if (
$globalise) {
            
$GLOBALS[$key] = $value;
        }
    }
}

/**
 * Emulates register globals = off
 */
function unregisterGlobals () {
    
checkInputArray$_FILES );
    
checkInputArray$_ENV );
    
checkInputArray$_GET );
    
checkInputArray$_POST );
    
checkInputArray$_COOKIE );
    
checkInputArray$_SERVER );

    if (isset( 
$_SESSION )) {
        
checkInputArray$_SESSION );
    }

    
$REQUEST $_REQUEST;
    
$GET $_GET;
    
$POST $_POST;
    
$COOKIE $_COOKIE;
    if (isset ( 
$_SESSION )) {
        
$SESSION $_SESSION;
    }
    
$FILES $_FILES;
    
$ENV $_ENV;
    
$SERVER $_SERVER;
    foreach (
$GLOBALS as $key => $value) {
        if ( 
$key != 'GLOBALS' ) {
            unset ( 
$GLOBALS $key ] );
        }
    }
    
$_REQUEST $REQUEST;
    
$_GET $GET;
    
$_POST $POST;
    
$_COOKIE $COOKIE;
    if (isset ( 
$SESSION )) {
        
$_SESSION $SESSION;
    }
    
$_FILES $FILES;
    
$_ENV $ENV;
    
$_SERVER $SERVER;
}

/**
 * Emulates register globals = on
 */
function registerGlobals() {
    
checkInputArray$_FILEStrue );
    
checkInputArray$_ENVtrue );
    
checkInputArray$_GETtrue );
    
checkInputArray$_POSTtrue );
    
checkInputArray$_COOKIEtrue );
    
checkInputArray$_SERVERtrue );

    if (isset( 
$_SESSION )) {
        
checkInputArray$_SESSIONtrue );
    }

    foreach (
$_FILES as $key => $value){
        
$GLOBALS[$key] = $_FILES[$key]['tmp_name'];
        foreach (
$value as $ext => $value2){
            
$key2 $key '_' $ext;
            
$GLOBALS[$key2] = $value2;
        }
    }
}

if (
RG_EMULATION == 0) {
    
// force register_globals = off
    
unregisterGlobals();    
} else if (
ini_get('register_globals') == 0) {
    
// php.ini has register_globals = off and emulate = on
    
registerGlobals();
} else {
    
// php.ini has register_globals = on and emulate = on
    // just check for spoofing
    
checkInputArray$_FILES );
    
checkInputArray$_ENV );
    
checkInputArray$_GET );
    
checkInputArray$_POST );
    
checkInputArray$_COOKIE );
    
checkInputArray$_SERVER );

    if (isset( 
$_SESSION )) {
        
checkInputArray$_SESSION );
    }

  #5 (permalink)  
Antiguo 05/04/2007, 16:58
 
Fecha de Ingreso: julio-2005
Ubicación: Buenos Aires, Argentina
Mensajes: 1.304
Antigüedad: 18 años, 9 meses
Puntos: 6
Re: Como apagar "register_globals"?

En ese caso, siempre y cuando este permitido en tu servicio de hosting, podrias usar un archivo .htaccess:

php_flag register_globals off

Y listo.

Saludos.
__________________
Federico.

Mi página: www.jourmoly.com.ar
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Tema Cerrado




La zona horaria es GMT -6. Ahora son las 04:03.