All pastes #68701 Raw Edit

v3x

public php v1 · immutable
#68701 ·published 2006-06-21 23:58 UTC
rendered paste body
		function find_quotes_in_post($id , $post_body , $type = NULL)		{			if($type != NULL)			{				$query = "SELECT * FROM forum_" . (($type == TOPIC) ? "topics" : "posts") . " WHERE id = '" . $id . "'";				$result = mysql_query($query) or die(mysql_error());				if(mysql_num_rows($result) > 0)				{					$row = mysql_fetch_assoc($result);					$poster_id = $row["posterid"];					$body = $row["body"];					$stamp = $row["timestamp"];					$date = date("F j, Y, g:i a" , $stamp);					$str .= "<div class=\"quote\">";					$str .= "<img src=\"images/paper_folded2.gif\">&nbsp;Posted by <b><a href=\"#\">" . name($poster_id) . "</a></b> - " . $date . "<br \><br \>";					$str .= $body;					$str .= "</div>";				}				$strings = array();				$replace = array();				preg_match_all('|#QUOTE_TOPIC_(\d+)#|', $post_body, $matches, PREG_SET_ORDER);				foreach ($matches as $match) 				{					$strings[] = $match[0];					$replace[] = $str;				}				$post_body = str_replace($strings, $replace, $post_body);				preg_match_all('|#QUOTE_POST_(\d+)#|', $post_body, $matches, PREG_SET_ORDER);				foreach ($matches as $match) 				{					$strings[] = $match[0];					$replace[] = $str;				}				$post_body = str_replace($strings, $replace, $post_body);				return $post_body;			}		}	}