<?php
define( '_UEXEC', 1 ); 

/*This will strip html from every variable unless it contains the word text ( introtext ) */
/* also this will conver all ' and " into text due to problems with sqlite and others */

function dbencode($str)
	{
	$str = addslashes($str);
	$str = str_replace(array("\r","\n","\\","'","\""),array("[CR]","[NL]","[ES]","[SQ]","[DQ]"), $str);
	return $str;
	//return urlencode($str);
	}
	
function dbdecode($str)
	{
	if(is_numeric($str))return $str;
	//return urldecode($str);
	$str = str_replace(array("[CR]","[NL]","[ES]","[SQ]","[DQ]"),array("\r","\n","\\","'","\""), $str);
	return stripslashes($str);
	//return stripslashes(urldecode($str));
	}
	
function check_var($var,$val)
{
if(is_array($val)){ 
$keys=array_keys ($val); 
foreach($keys as $key) 
{
$val[$key]=dbencode(strip_tags($val[$key]));
}
return $val;
}
if(!defined( "_VALID_LM_ADMIN") && !strstr($var,'text'))
{
$val=strip_tags($val);
}
if(strstr($var,"_data"))return $val;
return dbencode($val);
}

foreach($_POST as $postvar => $postval){ ${$postvar} = check_var($postvar,$postval); }
foreach($_GET as $getvar => $getval){ ${$getvar} = check_var($getvar,$getval); }

?>