[Owp-cvs] owp/inc/functions incoming_data_functions.inc,NONE,1.1
Status: Inactive
Brought to you by:
scader
From: <owp...@li...> - 2006-04-25 22:27:17
|
Update of /cvsroot/owp/owp/inc/functions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8738/functions Added Files: incoming_data_functions.inc Log Message: integrated main class with everything we need for work --- NEW FILE: incoming_data_functions.inc --- <?php /* Copyright (c) 2006, 2realities Group All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the 2realities Group nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /**Functions we need to process unsave input date to save input data * @author Artem Sidorenko <ar...@2r...> * @version $Id: incoming_data_functions.inc,v 1.1 2006/04/25 22:27:07 scader Exp $ * @package functions * @copyright (c) 2004-2006 2realities Group (www.2realities.com) */ /**Max count of dimensions of input array*/ @ define('security_input_array_max_level',5); /**Parse our incoming data *@param array $data incoming data *@param integer $level security issue, for no buffer overflow *@return array an array with clean and save data */ function parse_incoming_data($data,$level=1){ //overflow? if($level>=security_input_array_max_level) return array(); $rarray = array(); foreach($data as $k=>$v){ if(is_scalar($v)) $rarray[htmlspecialchars($k,ENT_QUOTES)]=htmlspecialchars($v,ENT_QUOTES); elseif(is_array($v)) $rarray[htmlspecialchars($k,ENT_QUOTES)] = parse_incoming_data($v,$level+1); }//\\foreach return $rarray; }//\\parse_incoming_data /**Function stripes magic quotes if they are enabled in php *@param array $data input data *@param integer $level security issue, for no overflow *@return array array without magic quotes */ function strip_magic_quotes($data,$level=1){ //overflow? if($level>=security_input_array_max_level) return array(); if(!get_magic_quotes_gpc()) return $data; $rarray = array(); foreach($data as $k=>$v){ if(is_scalar($v)) $rarray[$k]=stripslashes($v); elseif(is_array($v)) $rarray[$k] = strip_magic_quotes($v,$level+1); }//\\foreach return $rarray; }//\\strip_magic_quotes ?> |