39
« on: April 27, 2005, 01:45:47 AM »
Hi every one today I was looking the funtions.php code and I realized that some lines of that code apper in blue an red but the rest in black I just wanna make sure that there is not any problem with the code (use frontpage 2003)
$wh = get_resize($image_info[0], $image_info[1], $dim, $dim);
$text = "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$row['image_id'])."\"><img width = \"".$wh[0]."\" height=\"".$wh[1]."\" src=\"".$file_src."\" alt=\"".str_replace("\"", """, $row['image_name'])."\" align=\"".$align."\"></a>";
}
return $text;
}
function bb_code($text){
global $lang;
$text = strip_brackets($text);
$text = str_replace(" ", " ", $text);
// now Replace 2 spaces with " " to catch odd #s of spaces.
$text = str_replace(" ", " ", $text);
// Replace tabs with " " so tabbed code indents sorta right without making huge long lines.
$text = str_replace("\t", " ", $text);
$text = "<div class=\"codehead\"><b>".$lang['code'].":</b><div class=\"codeblock\">".stripslashes($text)."</div></div>";
return $text;
}
function format_text($text, $html = 0, $word_wrap = 0, $bbcode = 0, $bbcode_img = 0, $smiles = 0, $brackets = 1) {
global $lang;
$text = trim($text);
$text = str_replace("\\", "\\\\", $text);
if ($html == 0) {
$text = str_replace("<", "&lt;", $text);
$text = str_replace(">", "&gt;", $text);
$text = str_replace("<", "<", $text);
$text = str_replace(">", ">", $text);
}
// $text = preg_replace("/(\[)(php)(])(\r\n)*(.*)(\[\/php\])/esiU", "phphighlite('\\5')", $text);
$text = ($smiles) ? smiles($text) : $text;
if ($bbcode == 1) {
$text = preg_replace("/\[php\](.*?)\[\/php\]/esi", "phphighlite('\\1')", $text);
$text = preg_replace("/\[code\](.*?)\[\/code\]/esi", "bb_code('\\1')", $text);
}
if ($brackets) {
$entities_match = array('{', '}');
$entities_replace = array('{', '}');
$text = str_replace($entities_match, $entities_replace, $text);
}
if ($bbcode == 1) {
$text = preg_replace("/\[thumb=(.*?)\,(.*?)\,(.*?)\]/esi","thumb('\\1','\\2','\\3')",$text);
$text = preg_replace("/\[thumb=(.*?)\,(.*?)\]/esi","thumb('\\1','\\2' )",$text);
$text = preg_replace("/\[thumb=(.*?)\]/esi", "thumb('\\1')", $text);
$search_array = array(
"/\[b\](.*?)\[\/b\]/si",
"/\[i\](.*?)\[\/i\]/si",
"/\[u\](.*?)\[\/u\]/si",
"/\[email\](.*?)\[\/email\]/si",
"/\[email=(.*?)\](.*?)\[\/email\]/si",
"/\[quote=(.*?)\](.*?)/si",
"/\[quote\](.*?)/si",
"/\[\/quote\]/si",
"/\[url=(.*?)\](.*?)\[\/url\]/si",
"/\[url\](.*?)\[\/url\]/si",
"/\[urlb=(.*?)\](.*?)\[\/urlb\]/si",
"/\[urlb\](.*?)\[\/urlb\]/si",
"/\[sub\](.*?)\[\/sub\]/si",
"/\[sup\](.*?)\[\/sup\]/si",
"/\[color=(.*?)\](.*?)\[\/color\]/si",
"/\[size=(.*?)\](.*?)\[\/size\]/si",
"/\[tt\](.*?)\[\/tt\]/si",
"/\[s\](.*?)\[\/s\]/si",
"/\[move\](.*?)\[\/move\]/si",
// "/\[align=(.*?)\](.*?)\[\/align\]/si",
"/\[align=(.*?)\](.*?)\[\/align\](.<br \/>)?/si",
"/\[font=(.*?)\](.*?)\[\/font\]/si",
"/\[shadow=(.*?)\,(.*?)\,(.*?)\](.*?)\[\/shadow\]/si",
"/\[glow=(.*?)\,(.*?)\,(.*?)\](.*?)\[\/glow\]/si",
"/\[quote2=(.*?)\,(.*?)(\(.*?\))?\](.*?)/si",
"/\[\/quote2\]/si",
"/(\[)(list)(=)(['\"]?)([^\"']*)(\\4])(.*)(\[\/list)(((=)(\\4)([^\"']*)(\\4]))|(\]))/siU",
"/(\[)(list)(])(.*)(\[\/list\])/siU",
"/(\[\*\])/siU"
);
$replace_array = array(
"<b>\\1</b>",
"<i>\\1</i>",
"<u>\\1</u>",
"<a href=mailto:\\1>\\1</a>",
"<a href=mailto:\\1>\\2</a>",
"<div class=\"quotehead\"><b>\\1</b> ".$lang['wrote'].":<div class=\"quoteblock\">\\2",
"<div class=\"quotehead\"><b>".$lang['quote'].":</b><div class=\"quoteblock\">\\1",
"</div></div>",
"<a href=\"\\1\" target=_blank>\\2</a>",
"<a href=\\1 target=_blank>\\1</a>",
"<b><a href=\"\\1\" target=_blank>\\2</a></b>",
"<b><a href=\\1 target=_blank>\\1</a></b>",
"<sub>\\1</sub>",
"<sup>\\1</sup>",
"<font color=\"\\1\">\\2</font>",
"<font style=\"font-size: \\1px\">\\2</font>",
"<tt>\\1</tt>",
"<s>\\1</s>",
"<marquee>\\1</marquee>",
"<div align=\"\\1\">\\2</div>",
"<font face=\"\\1\">\\2</font>",
"<font style=\"Filter: Shadow(color=\\1, Direction=\\2); Width=\\3px;\">\\4</font>",
"<font style=\"Filter: Glow(color=\\1, Strength=\\2); Width=\\3px;\">\\4</font>",
"<div class=\"quotehead\">\\1<b>\\2</b>\\3:<div class=\"quoteblock\">\\4",
"</div></div>",
"<ol type=\"\\5\">\\7</ol>",
"<ul>\\4</ul>",
"<li>"
);
preg_match_all("/(\[quote=(.+?)\])|(\[quote\])/", $text, $regs);
$quoteopen = count($regs[0]);
preg_match_all("/(\[\/quote\])/", $text, $regs);
$quoteclose = count($regs[0]);
if($quoteopen > $quoteclose) {
$toclose = $quoteopen - $quoteclose;
for($i = 0 ; $i < $toclose ; $i++) {
$text .= "[/quote]";
}
} elseif($quoteclose > $quoteopen) {
$toopen = $quoteclose - $quoteopen;
for($i = 0 ; $i < $toopen ; $i++) {
$text = "[quote]$text";
}
}
$text = preg_replace($search_array, $replace_array, $text);
if (!$bbcode_img) {
$text = preg_replace("/\[img\](.*?)\[\/img\]/si", "<a href=\"\\1\" target=\"_blank\">\\1</a>", $text);
$text = preg_replace("/\[img=(.*?)\,(.*?)\](.*?)\[\/img\]/si","<a href=\"\\3\" target=\"_blank\">\\3</a>",$text);
$text = preg_replace("/\[img height=(.*?)\ width=(.*?)\](.*?)\[\/img\]/si","<a href=\"\\3\" target=\"_blank\">\\3</a>",$text);
$text = preg_replace("/\[img width=(.*?)\ height=(.*?)\](.*?)\[\/img\]/si","<a href=\"\\3\" target=\"_blank\">\\3</a>",$text);
$text = preg_replace("/\[flash=(.*?)\,(.*?)\](.*?)\[\/flash\]/si","<a href=\"\\3\" target=\"_blank\">\\3</a>",$text);
}else{
$text = preg_replace("/\[img\](.*?)\[\/img\]/si", "<img src=\"\\1\" border=\"0\">", $text);
$text = preg_replace("/\[img=(.*?)\,(.*?)\](.*?)\[\/img\]/si","<img src=\"\\3\" height=\"\\2\" width=\"\\1\">",$text);
$text = preg_replace("/\[img height=(.*?)\ width=(.*?)\](.*?)\[\/img\]/si","<img src=\"\\3\" height=\"\\1\" width=\"\\2\">",$text);
$text = preg_replace("/\[img width=(.*?)\ height=(.*?)\](.*?)\[\/img\]/si","<img src=\"\\3\" width=\"\\1\" height=\"\\2\">",$text);
$text = preg_replace("/\[flash=(.*?)\,(.*?)\](.*?)\[\/flash\]/si","<object classid=\"clsid: D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\\1 height=\\2><param name=movie value=\\3><param name=play value=true><param name=loop value=true><param name=quality value=high><embed src=\\3 width=\\1 height=\\2 play=true loop=true quality=high></embed></object>",$text);
}
$text = str_replace("[hr]", "<hr>", $text);
}
$text = replace_url($text);
if ($word_wrap && $text != "") {
$text = preg_replace("/([^\n\r ?&\.\/<>\"\\-]{".$word_wrap."})/i", " \\1\n", $text);
}
$text = str_replace("\n", "<br />", $text);
$text = str_replace("\\'", "'", $text);
$text = str_replace("\\\"", """, $text);
return replace_badwords(stripslashes($text));
}
function phphighlite($code) {
//PHP 4 only
if (floor(phpversion())<4) {
$buffer=$code;
} else {
// $code = str_replace("<br>", "", $code);
// $code = str_replace("<br />", "", $code);
$code = str_replace(">", ">", $code);
$code = str_replace("<", "<", $code);
$code = str_replace("&", "&", $code);
$code = str_replace('$', '\$', $code);
$code = str_replace('\n', '\\\\n', $code);
$code = str_replace('\r', '\\\\r', $code);
$code = str_replace('\t', '\\\\t', $code);
$code = stripslashes($code);
if (!strpos($code,"<?") and substr($code,0,2)!="<?") {
$code="<?\n".trim($code)."\n?>";
$addedtags=1;
}
ob_start();
$oldlevel=error_reporting(0);
highlight_string($code);
error_reporting($oldlevel);
$buffer = ob_get_contents();
ob_end_clean();
if ($addedtags) {
$openingpos = strpos($buffer,'<?');
$closingpos = strrpos($buffer, '?');
$buffer=substr($buffer, 0, $openingpos).substr($buffer, $openingpos+5, $closingpos-($openingpos+5)).substr($buffer, $closingpos+5);
}
// $buffer = str_replace(""", "\"", $buffer);
}
return "<div class=\"codehead\"><b>PHP:</b><div class=\"codeblock\">".preg_replace("/<code><font color=\"#000000\">\n<font color=\"(.*)\">\n/si", "<code><font color=\"#000000\"><font color=\"\\1\">", str_replace("\n</font>\n</code>", "</font></code>", $buffer))."</div></div>";
}
//--------------------------
//--------Smiles------------
//--------------------------
function smiles($text,$enablesmilies = 1) {
global $smileyfromcache, $smileytocache;
$imagesdir = TEMPLATE_PATH."/smiles";
if(gettype($smileyfromcache) != "array") {
$smilesfrom = get_smiles();
foreach ($smilesfrom as $key => $val) {
$smileyfromcache[] ='/(((>[^<]*)|(^[^<]*))([\s\n\r]|^|<br( \/)?[>]))('.str_replace('|','\|', quotemeta(str_replace("<", "<", str_replace(">", ">", str_replace("\/", "\\\/", $key))))).')/s';
$smileytocache[] = "\\1<img src=\"$imagesdir/$val.gif\" alt=\"\" border=\"0\">";
[/quote][/quote]