Location: PHPKode > projects > Content*Builder > libraries/comment/insertComment.php
<?php
	if(isset($_POST[$submitLabel])) {
		include_once($path[cb]."lib/CB_bb_code_parser.class.php");
		$parser = new CB_bb_code_parser($path[cb]."lib/");
		
		require_once($path['cb'].$cbDirLib.'CB_media.class.php');
		$myMedia  = new MediaManagement();
		$myMedia->setOptionObject($cbOption);
		$myMedia->setBranchID($cbOption->getSingleOption("rpBranch"));
		$mediaDirectory = $myMedia->getBranchDirectory();
		
		if(!$cbOption->getSingleOption("commentHTMLallowed")) {
			$COMMENT_text = htmlspecialchars($COMMENT_text);
		}
		if($cbOption->getSingleOption("commentBBTagsallowed")) {
			$COMMENT_text = $parser->getParsedText($COMMENT_text);
		}
			
		require_once($path['cb'].$cbDirLib.'CB_sext_rp.class.php');
		class my_sext_parser extends sext_rp {
			 function replaceImagesToValue($string){
				// Re - Replace all matches that fit pattern in DB
				if($this->replaceImageArray) {
					foreach($this->replaceImageArray as $key => $value) {
						$string	= str_replace($key, '<img src="'.$this->cbpath.$this->uploadDir.$this->mediaDirectory.'/'.$value.'" border="0">', $string);
					}
				}
				return $string;
		    }
		}
		$sextParser = new my_sext_parser();
		$sextParser->mediaDirectory = $mediaDirectory;
		$sextParser->cbpath = $path[cb];
		$sextParser->uploadDir = $myMedia->uploadDir;
		
		$COMMENT_text = $sextParser->replaceImagesToValue($COMMENT_text);
		$COMMENT_text = $sextParser->replaceTextToValue($COMMENT_text);
		
		if(!preg_match("/^([\w\.\-\_]+)*@([\w\.\-\_]+)+([a-zA-Z]{2,3})$/", $COMMENT_email)) {
			$COMMENT_email = "";
		}
		$COMMENT_homepage = htmlspecialchars($COMMENT_homepage);
		$COMMENT_author = htmlspecialchars($COMMENT_author);
		$COMMENT_text = short_words(nl2br($COMMENT_text), 25);
		$COMMENT_date = date("Y-m-d H:i:s");
		
		if(empty($COMMENT_author) || empty($COMMENT_text)) {
			$error = true;
		}
				
		if(!$error) {
			$query = mysql_query("INSERT INTO ".TABLE."_comment (type, entryID, author, title, text, homepage, email, datetime) VALUES ('$type', '$entryID', '$COMMENT_author', '$COMMENT_title', '$COMMENT_text', '$COMMENT_homepage', '$COMMENT_email', '$COMMENT_date')");
		}
	}
?>
Return current item: Content*Builder