All pastes #798783 Raw Edit

Miscellany

public php v1 · immutable
#798783 ·published 2007-11-27 00:45 UTC
rendered paste body
<?php	/*	+----------------------------------------------------------------------------------------	|	Set the variable $id that is passed through the URL	+----------------------------------------------------------------------------------------	*/	$id = $_GET["thread"] + 0;		/*	+----------------------------------------------------------------------------------------	|	When the button "reply" has been clicked, clean the input and insert into the SQL	+----------------------------------------------------------------------------------------	*/	if (isset($_POST["reply"]))	{		$tblname 	= 'forum_threads';		$message	= clean($_POST["message"]);		$username	= $_SESSION["username"];		$time		= time();		$time_show	= date("F j, Y, g:i a");		echo $thread_topic;		/*		+----------------------------------------------------------------------------------------		|	Makes sure something has been enetered in the message textbox		+----------------------------------------------------------------------------------------		*/		if (	!$message	)		{			echo '<script type="text/javascript"> alert(\'The post must contain at least one character\');</script>';		}				/*		+----------------------------------------------------------------------------------------		|	If a character has been specified, insert into the MySQL table		+----------------------------------------------------------------------------------------		*/		else		{					//mysql_query("INSERT INTO $tblname (Post, Owner, Posted_On, ParentID, Topic) VALUES ('$message','$username','$time','$id','$thread_topic') ");			//mysql_query("UPDATE $tblname SET Replies=Replies+'1' WHERE `ParentID`='$id'");			//mysql_query("UPDATE $tblname SET `Last_replied_to` =Last_replied_to+'1' WHERE `ID`=1 LIMIT 1");		}	}	/*	+----------------------------------------------------------------------------------------	|	Display the "thread form"	+----------------------------------------------------------------------------------------	*/	echo '<DIV class="main" style="width: 95%;">';	echo '<h4>Viewing thread</h4>';		/*	+----------------------------------------------------------------------------------------	|	Generate the variable for the table name	|	Execute the MySQL query	+----------------------------------------------------------------------------------------	*/		$tblname 	= 'forum_threads';	$result 	= mysql_query("SELECT * FROM `".$tblname."` WHERE `ParentID`='$id'"); // Change to only the fields you need		/*	+----------------------------------------------------------------------------------------	|	Display the posts that have been made on the thread	|	No need for a row = 0 and there will always be a post	+----------------------------------------------------------------------------------------	*/	while(	$thread_r=@mysql_fetch_array($result)	) // Supress errors	{			/*		+----------------------------------------------------------------------------------------		|	Set all the variables that are returned from the query		+----------------------------------------------------------------------------------------		*/		$thread_id		= $thread_r['ParentID'];		if ($thread_r['Topic'] != 0)		{			$thread_topic	= $thread_r['Topic'];		}		$thread_post	= $thread_r['Post'];		$thread_owner	= $thread_r['Owner'];		$thread_time	= $thread_r['Posted_On'];		if (auth() == 0) {					$auth = 'Edit - Remove</td>';		}		else {				$auth = 'No Options</td>';	  	}?>		<p>		<table style="border: 1px solid silver" bgcolor="#FFFFFF" border="0" bordercolor="#ececec" cellpadding="0" cellspacing="0" width="96%">			<tr>				<td width="113" align="center" valign="top" style="border-right: 1px solid silver; padding: 5px"><a href="/profile/$thread_owner/"><?php echo $thread_owner; ?></a></td>								<td style="padding: 5px;" valign="top"><?php echo $thread_post; ?></td>			</tr>			<tr>				<td width="113" align="center" valign="middle" style="border-right: 1px solid silver; border-top: 1px solid silver; padding: 5px">				<?php echo $auth; ?>				<td style="padding: 5px; border-top: 1px solid silver"><em><strong>Posted on <?php echo date("F j, Y, g:i a", $thread_time);?></strong></em></td>			</tr>		</table>		</p><?php	}		/*	+----------------------------------------------------------------------------------------	|	Display the "reply form"	+----------------------------------------------------------------------------------------	*/	if (auth() == 1) {	echo '</DIV>';	echo '<DIV class="main" style="width: 95%;">';	echo '<h4>Reply to thread</h4>'; ?>	<form name="form1" method="post" action="">	<p> <table style="border: 1px solid silver" bgcolor="#FFFFFF" border="0" bordercolor="#ececec" cellpadding="0" cellspacing="0" width="96%">		<tr>			<td width="113" align="right" valign="top" style="border-right: 1px solid silver; padding: 5px">Message:</td>			<td style="padding: 5px;" valign="top"><textarea name="message"  cols="75" rows="10"></textarea></td>		</tr>		<tr>			<td width="113" align="right" valign="top" style="border-right: 1px solid silver; padding: 5px">&nbsp;</td>			<td style="border-top: 1px solid silver; padding: 5px" valign="top"><input type="submit" name="reply" value="Reply"> - BBCode Enabled</td>										</tr>		</table>	</form>	</p>	<?php	}	?>