Sign in to follow this  
Followers 0
Mathias

Common input functions

3 posts in this topic

Note, all of my functions belong to classes, but I am posting only snippets of my functions to avoid boredom and giving away all my secrets. Please post corrections, suggestions, and your own related functions.


Understand this lad, fate is a fickle lady. Work with the hand you're dealt and you may just be able to run your flag up the pole. Don't, and well, you may just find your mast cut down.

Share this post


Link to post
Share on other sites


        //-----------------------------------------------------------------------
        // Function:    GetInput
        // Author:      Andrew Hinkle
        // Modified:    08/18/2007
        // Description: Return the merged $_GET and $_POST input.
        //-----------------------------------------------------------------------
        public function GetInput()
        {
            return array_merge((array)$_GET, (array)$_POST);
        }


Understand this lad, fate is a fickle lady. Work with the hand you're dealt and you may just be able to run your flag up the pole. Don't, and well, you may just find your mast cut down.

Share this post


Link to post
Share on other sites
        //-----------------------------------------------------------------------
        // Function:    CleanInput
        // Author:      Andrew Hinkle
        // Modified:    08/18/2007
        // Description: Return the cleaned array.
        //-----------------------------------------------------------------------
        public function CleanInput($aInput)
        {
            // Stripslashes
            if (is_array($aInput))
            {
                foreach ($aInput as $sKey => $sValue)
                {
                    // If magic quotes is on, it will automatically add backslashes.
                    // Remove the extra slashes.
                    $sValue = get_magic_quotes_gpc() ? stripslashes($sValue)  $sValue;
                    $aInput[$sKey] = !empty($sValue) && !is_null($sValue) ? trim($sValue)  "";
                }
            }
            else
            {
                // If magic quotes is on, it will automatically add backslashes.
                // Remove the extra slashes.
                $sValue = get_magic_quotes_gpc() ? stripslashes($aInput)  $aInput;
                $aInput = !empty($sValue) && !is_null($sValue) ? trim($sValue)  "";
            }

            return $aInput;
        }


Understand this lad, fate is a fickle lady. Work with the hand you're dealt and you may just be able to run your flag up the pole. Don't, and well, you may just find your mast cut down.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0