* @param mixed $value Value to be sanitized
* @return mixed
*/
function recursiveSanitize($value) {
if (is_array($value)) {
$valmod = array();
foreach ($value as $key => $subval) {
if (is_array($subval)) {
$subval = recursiveSanitize($subval);
} else {
$subval = strip_tags($subval);
}
$valmod[$key] = $subval;
}
$value = $valmod;
} else {
$value = strip_tags($value);
}
return $value;
}
/**
* Truncate a string to a specific number of words
*/
function chopToWordCount($string, $count) {
$wc = str_word_count($string);
if ($wc > $count) {
$words = str_word_count($string, 2);
$last_word = array_slice($words, $count, 1, true);
$pos = key($last_word);
$string = substr($string, 0, $pos) . '...';
}
return $string;
}
/**
* Strip "dangerous" HTML to make it safe to print to web browsers
*/
function sanitizeForWeb($string) {
$string = preg_replace('/
/', "\n", $string);
$string = str_replace('$', '$', $string);
$string = str_replace('&', '&', $string);
$string = str_replace('<', '<', $string);
$string = str_replace('>', '>', $string);
$string = str_replace('\'', ''', $string);
$string = str_replace('"', '"', $string);
$string = str_replace('$', '$', $string);
$string = str_replace("\n", '
', $string);
$string = str_replace("\t", ' ', $string);
return $string;
}
if (!isset($_SERVER) && isset($HTTP_SERVER_VARS)) {
$_SERVER = &$HTTP_SERVER_VARS;
}
foreach ($_REQUEST as $key=>$val){
switch ($key){
case 'event_data':
# modify this to allow or disallow different HTML tags in event popups
$allowed = "