Fix register_globals

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Fix register_globals

    PHP Code:
    //GLOBALS OFF WORK ROUND
    if (!ini_get('register_globals')) {
    $reg_globals = array($_POST$_GET$_FILES$_ENV$_SERVER$_COOKIE);
    if (isset(
    $_SESSION)) {
    array_unshift($reg_globals$_SESSION);
    }
    foreach (
    $reg_globals as $reg_global) {
    extract($reg_globalEXTR_SKIP);
    }

    Add to header and now the script will load register_globals to be on is a safer way.

  • #2
    shouldn't rely on reg globals being on at all. not saying your code is irrelevant, but coding the correct way to begin with is always the best way to go.

    Comment


    • #3
      If you command the globals right and str_replace all mysql base then should be safe

      Comment


      • #4
        no point php 5.2 will be gone soon, as soon as 5.3 is manditory it wont work

        Comment


        • #5
          Originally posted by crazybrumi View Post
          no point php 5.2 will be gone soon, as soon as 5.3 is manditory it wont work
          Isn't that the point of this topic? to make a script wrote with globals work, where no globals is possible

          Comment


          • #6
            If you are using php version below 5.4 you can use:
            import_request_variables ('gp');

            for gets and posts and even set a prefix for the variables if required.
            http://php.net/manual/en/function.im...-variables.php

            and for 5.4 and after you could use:
            extract($_REQUEST, EXTR_PREFIX_ALL|EXTR_REFS);

            http://php.net/manual/en/function.extract.php

            Comment

            Working...
            X