Location: PHPKode > projects > PHP-Fusion: Guestbook > inf_guestbook_v4.12/files/infusions/guest_book/includes/bbcode_include_v7.php
<?php
/*-------------------------------------------------------+
| Guestbook Infusion 4.12
| Author: Sebastian Schüssler (slaughter)
| Download:
| http://basti2web.de
+--------------------------------------------------------+
| Filename: bbcode_include_v7.php
| Version: 4.10
| Author: lelebart (based on Wooya's page, and maincore.php)
+--------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2008 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
if (!defined("IN_FUSION")) { die("Access Denied"); }

// Cache bbcode mysql
function cache_gb_bbcode() {
	global $bbcode_gb_cache;
	$result = dbquery("SELECT * FROM ".DB_GB_BBCODES." ORDER BY bbcode_order ASC");
	if (dbrows($result)) {
		$bbcode_gb_cache = array();
		while ($data = dbarray($result)) {
			$bbcode_gb_cache[] = $data['bbcode_name'];
		}
	} else {
		$bbcode_gb_cache = array();
	}
}

// Parse bbcode
function gb_parseubb_v7($text, $selected=false) {
	global $bbcode_gb_cache;
	if (!$bbcode_gb_cache) { cache_gb_bbcode(); }
	if (is_array($bbcode_gb_cache) && count($bbcode_gb_cache)) {
		if ($selected) { $sel_bbcodes = explode("|", $selected); }
		foreach ($bbcode_gb_cache as $bbcode) {
			if ($selected && in_array($bbcode, $sel_bbcodes)) {
				if (file_exists(INCLUDES."bbcodes/".$bbcode."_bbcode_include.php")) {
					if (file_exists(LOCALE.LOCALESET."bbcodes/".$bbcode.".php")) {
						include (LOCALE.LOCALESET."bbcodes/".$bbcode.".php");
					} elseif (file_exists(LOCALE."English/bbcodes/".$bbcode.".php")) {
						include (LOCALE."English/bbcodes/".$bbcode.".php");
          }
					include (INCLUDES."bbcodes/".$bbcode."_bbcode_include.php");
				}
			} elseif (!$selected) {
				if (file_exists(INCLUDES."bbcodes/".$bbcode."_bbcode_include.php")) {
					if (file_exists(LOCALE.LOCALESET."bbcodes/".$bbcode.".php")) {
						include (LOCALE.LOCALESET."bbcodes/".$bbcode.".php");
					} elseif (file_exists(LOCALE."English/bbcodes/".$bbcode.".php")) {
						include (LOCALE."English/bbcodes/".$bbcode.".php");
          }
					include (INCLUDES."bbcodes/".$bbcode."_bbcode_include.php");
				}
			}
		}
	}	
	$text = descript($text, false);
	return $text;
}

function display_bbcodes_v7($width, $textarea_name = "guest_message", $inputform_name = "inputform", $selected = false) {
	global $bbcode_gb_cache, $p_data;

	if (!$bbcode_gb_cache) { cache_gb_bbcode(); }
	if ($selected) { $sel_bbcodes = explode("|", $selected); }
	$__BBCODE__ = array(); $bbcodes = "";
	
	if (is_array($bbcode_gb_cache) && count($bbcode_gb_cache)) {
		foreach ($bbcode_gb_cache as $bbcode) {
			if ($selected && in_array($bbcode, $sel_bbcodes)) {
				if (file_exists(LOCALE.LOCALESET."bbcodes/".$bbcode.".php")) {
					include (LOCALE.LOCALESET."bbcodes/".$bbcode.".php");
				} elseif (file_exists(LOCALE."English/bbcodes/".$bbcode.".php")) {
					include (LOCALE."English/bbcodes/".$bbcode.".php");
        }
				include (INCLUDES."bbcodes/".$bbcode."_bbcode_include_var.php");
			} elseif (!$selected) {
				if (file_exists(LOCALE.LOCALESET."bbcodes/".$bbcode.".php")) {
					include (LOCALE.LOCALESET."bbcodes/".$bbcode.".php");
				} elseif (file_exists(LOCALE."English/bbcodes/".$bbcode.".php")) {
					include (LOCALE."English/bbcodes/".$bbcode.".php");
        }
				include (INCLUDES."bbcodes/".$bbcode."_bbcode_include_var.php");
			}
		}	
	}

	if (sizeof($__BBCODE__) != 0) {
		foreach ($__BBCODE__ as $key => $bbdata) {
			if (file_exists(INCLUDES."bbcodes/images/".$bbdata['value'].".png")) {
				$type = "type='image' src='".INCLUDES."bbcodes/images/".$bbdata['value'].".png'";
			} else if (file_exists(INCLUDES."bbcodes/images/".$bbdata['value'].".gif")) {
				$type = "type='image' src='".INCLUDES."bbcodes/images/".$bbdata['value'].".gif'";
			} else if (file_exists(INCLUDES."bbcodes/images/".$bbdata['value'].".jpg")) {
				$type = "type='image' src='".INCLUDES."bbcodes/images/".$bbdata['value'].".jpg'";
			} else {
				$type = "type='button' value='".$bbdata['value']."'";
			}
         	
			if (array_key_exists('onclick', $bbdata) && $bbdata['onclick'] != "") {
				$onclick = $bbdata['onclick'];
			} else {
				if (array_key_exists('bbcode_end', $bbdata) && $bbdata['bbcode_end'] != "") {
					$onclick = "addText('".$textarea_name."','".$bbdata['bbcode_start']."','".$bbdata['bbcode_end']."','".$inputform_name."');return false;";
				} else {
					$onclick = "insertText('".$textarea_name."','".$bbdata['bbcode_start']."','".$inputform_name."');return false;";
				}
			}
           
			if (array_key_exists('onmouseover', $bbdata) && $bbdata['onmouseover'] != "") {
				$onmouseover = "onMouseOver=\"".$bbdata['onmouseover']."\"";
			} else {
				$onmouseover = "";
			}

			if (array_key_exists('onmouseout', $bbdata) && $bbdata['onmouseout'] != "") {
				$onmouseout = "onMouseOut=\"".$bbdata['onmouseout']."\"";
			} else {
				$onmouseout = "";
			}
           
			if (array_key_exists('phpfunction', $bbdata) && $bbdata['phpfunction'] != "") {
				$php = $bbdata['phpfunction'].(substr($bbdata['phpfunction'], -1, 1) != ";" ? ";" : "");
				ob_start(); 
				eval($php);
				$phpfunction = ob_get_contents();
				ob_end_clean();
			} else {
				$phpfunction = "";
			}
			
			$bbcodes .= substr($bbdata['value'], 0, 1) != "!" ? "<input ".$type." class='bbcode' onclick=\"".$onclick."\" ".$onmouseover." ".$onmouseout." title='".$bbdata['description']."' />\n":"";
			if (array_key_exists('html_start', $bbdata) && $bbdata['html_start'] != "") { $bbcodes .= $bbdata['html_start']."\n"; }
			if (array_key_exists('includejscript', $bbdata) && $bbdata['includejscript'] != "") { $bbcodes .= "<script type='text/javascript' src='".INCLUDES."bbcodes/".$bbdata['includejscript']."'></script>\n"; }
			if (array_key_exists('calljscript', $bbdata) && $bbdata['calljscript'] != "") { $bbcodes .= "<script type='text/javascript'>\n<!--\n".$bbdata['calljscript']."\n-->\n</script>\n"; }
			if (array_key_exists('phpfunction', $bbdata) && $bbdata['phpfunction'] != "") { $bbcodes .= $phpfunction; }
			if (array_key_exists('html_middle', $bbdata) && $bbdata['html_middle'] != "") { $bbcodes .= $bbdata['html_middle']."\n"; }
			if (array_key_exists('html_end', $bbdata) && $bbdata['html_end'] != "") { $bbcodes .= $bbdata['html_end']."\n"; }
		}
	}
	unset ($__BBCODE__);

	return "<div style='width:".$width."'>\n".$bbcodes."</div>\n";
}

function strip_gb_bbcodes($text) {
  global $bbcode_gb_cache, $p_data;
  $textarea_name = "";
  $inputform_name = "";
	if (!iADMIN) {
    if (!$bbcode_gb_cache) { cache_gb_bbcode(); }
  	if (is_array($bbcode_gb_cache) && count($bbcode_gb_cache)) {
  		foreach ($bbcode_gb_cache as $bbcode) {
  			if (file_exists(LOCALE.LOCALESET."bbcodes/".$bbcode.".php")) {
  				include (LOCALE.LOCALESET."bbcodes/".$bbcode.".php");
  			}
  			include (INCLUDES."bbcodes/".$bbcode."_bbcode_include_var.php");
  		}
  	}
  	if (isset($__BBCODE_NOT_QUOTABLE__) && sizeof($__BBCODE_NOT_QUOTABLE__) != 0) {
  		foreach ($__BBCODE_NOT_QUOTABLE__ as $key => $bbname) {
        $text = preg_replace('#\['.$bbname.'(.*?)\](.*?)\[/'.$bbname.'\]#si', '', $text);
  		}
	  	unset ($__BBCODE_NOT_QUOTABLE__);
  	}
  }
	return $text;
}
?>
Return current item: PHP-Fusion: Guestbook