# remove this line; added to prevent possible RFI $v){ $out[$k] = clean($v); } return $out; } /** * Convenience wrapper for htmlentities, customized for UTF-8 * * @param string $string Input text * @return string, with non-browser-safe characters replaced with entities * @author Walter Lee Davis */ function h($string) { return stripslashes(htmlentities($string,ENT_COMPAT,'UTF-8')); } /** * Gracefully loads the contents of a text file and unserializes them. * * @param string $strPathToTextFile Filesystem path to the text file * @return array * @author Walter Lee Davis */ function load($strPathToTextFile){ if( !file_exists($strPathToTextFile) || !$array = unserialize(file_get_contents($strPathToTextFile)) ) $array = array(); ksort($array); return $array; } /** * Stores an array in a given text file, discarding duplicate entries * * @param array $arrData * @param string $strPathToTextFile * @return boolean * @author Walter Lee Davis */ function store($arrData, $strPathToTextFile){ $input = clean($arrData); $array = load($strPathToTextFile); foreach($input as $key => $val){ if(!empty($val)){ if(!isset($array[$key])){ $array[$key][] = $val; }elseif(is_array($array[$key]) && !in_array($val,$array[$key])){ $array[$key][] = $val; }else{ continue; } } } return file_put_contents($strPathToTextFile,serialize($array),LOCK_EX); } /** * Prints an array for debugging * * @param mixed $mxdInput * @return string (HTML) * @author Walter Lee Davis */ function pre_print($mxdInput){ print '
'; print_r($mxdInput); print ''; } function notify($arrNames,$arrEmail,$arrPhone,$arrTimes){ $arrNames = clean($arrNames); $arrEmail = clean($arrEmail); $arrPhone = clean($arrPhone); $count = 0; foreach($arrNames as $key => $name){ $body = ''; if(!empty($name)){ $body = $name . "\n"; $body .= $arrEmail[$key] . "\n"; $body .= $arrPhone[$key] . "\n\n"; $body .= $arrTimes[$key] . "\n\n"; mail(ADMIN_MAIL,'New Bell-ringing registration',$body, 'From: ' . ADMIN_MAIL,'-f' . ADMIN_MAIL); $count ++; } } if($count > 0) return '