";
foreach($options as $option_value => $option) {
// numberic indexs mean value not specified, use same as display
if(is_string($option_value)==false) { $option_value = $option; }
$option_value = str_replace("'",''',$option_value);
$select_tag = ($option == $selected) ? 'selected="selected"' : '';
echo "";
}
echo "\n";
}
function text_format($text,$is_text_wrapped=true) {
// HTML comment to include raw html
if(stristr($text, '') !== false) return $text;
include_once('inc/inc.validate.php');
// remove starting and trailing whitespace and blank lines
$text = preg_replace('/^[\s\n]*/s' ,'',$text);
$text = preg_replace( '/[\s\n]*$/s','',$text);
// place into paragraph array and add spaces to both sides
if($is_text_wrapped == true) {
// strip out lines with only whitespace chars and reduce multiple blank lines to one
$text = preg_replace('/^(\s)*$/m','',$text);
$paragraphs = explode("\n\n",$text);
foreach($paragraphs as $key => $value) { $paragraphs[$key] = ' '.$value.' '; }
} else {
$paragraphs = array(' '.str_replace("\n","
\n ",$text).' '); // extra spaces are needed for pattern matching
}
$start = '%(\s[\*_/><]*)';
$end = "([\*_/><]*\s)%U";
$middle = "((?![^\S]).*(?![^\S]))";
$m1 = '((?![^\S])(.(?![';
$m2 = ']{2}))*[\S]*(?![^\S]))';
$patterns = array(
$start.'##'.$middle.'##'.$end => '$1
$2
$3', // ##Header##
$start.'\*'.$middle.'\*'.$end => '$1$2$3', // *Bold*
$start.'_' .$middle.'_' .$end => '$1$2$3', // _Underline_
$start.'//'.$middle.'//'.$end => '$1$2$3', // //Italics//
$start.'"' .$middle.'"' .$end => '$1"$2"$3', // "Italics"
$start.'>>'.$m1.'<'.$m2.'>>'.$end => '$1$2
$3', // >>AlignRight>>
$start.'<<'.$m1.'>'.$m2.'<<'.$end => '$1$2
$3', // <>'.$m1.'>'.$m2.'<<'.$end => '$1$2
$3', // >>Center<<
$start.'<<'.$m1.'<'.$m2.'>>'.$end => '$1$2
$3', // <>
);
// run formatting on paragraphs;
$paragraphs = preg_replace(array_keys($patterns),$patterns,$paragraphs);
// locate and a href emails and links
foreach($paragraphs as $key => $value) {
$paragraphs[$key] = highlight_emails($paragraphs[$key]);
$paragraphs[$key] = highlight_links ($paragraphs[$key]);
}
foreach($paragraphs as $key => $value) {
$html .= " ".$paragraphs[$key]."
\n";
}
return $html;
}
// scans the text and
function highlight_emails($text) {
if(strpos($text,'@') === false) { return $text; } // quick test for emails
$email_reg = "%([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})(?!\S)%";
preg_match_all($email_reg,' '.$text.' ',$find);
foreach($find[0] as $email) {
list($username,$domaintld) = split("@",$email);
if(getmxrr($domaintld,$mxrecords)) { // check its from a valid email domain
$encoded = email_encode($email);
$ahref = "$encoded";
$text = str_replace($email,$ahref,$text);
}
}
return $text;
}
function highlight_links($text) {
global $target_blank;
$link_reg = '%\s((http://|https://ftp://|www.)\S*)(?=\s)%';
preg_match_all($link_reg,' '.$text.' ',$find);
for($i=0;$i$link ";
$text = str_replace($find[0][$i],$ahref,$text); // need the starting space to avoid '>
}
}
return $text;
}
// james@starsfaq.com =
// james@starsfaq.com
function email_encode($email) {
for($i=0;$i