Re: Database abstraction?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 16, 2008 at 9:15 AM, Richard Heyes <richardh@xxxxxxxxxxx> wrote:

> off-subject (yes total thread robbery here  [more of a side note really]).
> >  i saw a reference to some of your work in the Solar framework richard, for
> > clearing out the 'environment' or rather the superglobal arrays.  good
> > stuff.
> >
>
> Thanks (I think you're referring to clearing register_globals crapola).
> Credit also due to Stephan Esser.


ya; (reposting for list)

    /**
     *
     * Generates a simple exception, but does not throw it.
     *
     * This method attempts to automatically load an exception class
     * based on the error code, falling back to parent exceptions
     * when no specific exception classes exist.  For example, if a
     * class named 'Vendor_Example' extended from 'Vendor_Base' throws an
     * exception or error coded as 'ERR_FILE_NOT_FOUND', the method will
     Richard Heyes and Stefan Esser.
     *
     * @return void
     *
     */
    public function cleanGlobals()
    {
        $list = array(
            'GLOBALS',
            '_POST',
            '_GET',
            '_COOKIE',
            '_REQUEST',
            '_SERVER',
            '_ENV',
            '_FILES',
        );

        // Create a list of all of the keys from the super-global values.
        // Use array_keys() here to preserve key integrity.
        $keys = array_merge(
            array_keys($_ENV),
            array_keys($_GET),
            array_keys($_POST),
            array_keys($_COOKIE),
            array_keys($_SERVER),
            array_keys($_FILES),
            // $_SESSION is null if you have not started the session yet.
            // This insures that a check is performed regardless.
            isset($_SESSION) && is_array($_SESSION) ? array_keys($_SESSION)
: array()
        );

        // Unset the globals.
        foreach ($keys as $key) {
            if (isset($GLOBALS[$key]) && ! in_array($key, $list)) {
                unset($GLOBALS[$key]);
            }
        }
    }

hope ya dont mind if i borrow that one :D
i was reading through it, and i was like; holy shit; that dudes from the
list !!  btw, i talked to the guy who wrote solar, when i was in dc last
year.  really cool fellow; but i talked his ear off :O

-nathan

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux