All pastes #162956 Raw Edit

Dr4g

public php v1 · immutable
·published 2006-09-07 00:30 UTC
rendered paste body
<?phpfunction outputAllTopics() {	// select all from topics	$query = "SELECT * FROM `topics`";	$retQuery = querySelect($query);	if(mysql_num_rows($retQuery) == 0){		echo "No Topics To Display";		exit();	}	else {		echo "			<table width=617 border=0>			<tr>				<td colspan=3><h3><a href=forum.php?mode=viewtopic&tid=".$row1['id'].">".$row1['name']."</a></h3></td>			</tr><tr>			    <th width=317 scope=col><div align=left>Topic</div></th>			    <th width=116 scope=col><div align=left>By</div></th>			    <th width=154 scope=col><div align=left>Last Active Thread</div></th>			  </tr>		";			// fetch_array all info			while(($row = mysql_fetch_array($retQuery))) {		//	$query2 = "SELECT `name` FROM `threads` WHERE `thread_id`='".$row['last_active_thread_id']."'";	//	retQuery2 = querySelect($query2);			// output all info in respectable manner			echo "			  <tr>				    <td valign=top height=23><div align=left>						<a href=forum.php?mode=viewtopic&tid="							.$row['id'].">".$row['name']."</a><br/>"							.$row['desc']."</div>					</td>			    <td valign=top><div align=left>".$row['by']."</div></td>			    <td valign=top><div align=left><a href=forum.php?mode=viewthread&tid="				.$row['last_active_thread_id'].">"				.""."</a></div>				</td>			  </tr><tr>			    <td height=42 valign=top>&nbsp;</td>				    <td valign=top>&nbsp;</td>			    <td valign=top>&nbsp;</td>			  </tr>			";		}		echo "</table>";		if(isset($_SESSION['alive'])) {			if($_SESSION['rank'] <= 2)				outputCreateTopicBox();		}	}}function outputThreadsByTopicID($id) {	// Grab the topic ID and name	$query = "SELECT `id`,`name` FROM `topics` WHERE `id`='$id'";	$retQuery = querySelect($query);	if(mysql_num_rows($retQuery) == 0) {		echo "No Topics To Display";		exit();	}		else {		$row1 = mysql_fetch_row($retQuery);		// Begin table and output topic id,name		echo "			<table width=617 border=0><tr>				<td colspan=3><h3><a href=forum.php?mode=viewtopic&tid="					.$row1[0].">".$row1[1]."</a></h3><br/></td>			  </tr><tr>		    <th width=317 scope=col><div align=left>Threads</div></th>		    <th width=116 scope=col><div align=left>By</div></th>		    <th width=154 scope=col><div align=left>Last Active User</div></th>		  </tr>		";				// Grab all thread info where topic_group_id=$id		$query2 = "SELECT * FROM `threads` WHERE `topic_group_id`='$id'";			$retQuery2 = querySelect($query2);		  			if(mysql_num_rows($retQuery2) == 0) {			echo "</table>";			echo "No Threads For Current Topic ID";			exit();		} else {						// fetch_array all thread info				while(($row = mysql_fetch_array($retQuery2))) {				echo "				  <tr>					    <td valign=top height=15><div align=left>							<a href=forum.php?mode=viewthread&tid=".$row['thread_id'].">".$row['name']."</a><br/>							".$row['desc']."</div>						</td>					    <td valign=top><div align=left>".$row['by']."</div></td>					    <td valign=top><div align=left>						<a href=user-profile.php?id=".$row['last_active_user_id'].">"							.grabUserFromID($row['last_active_user_id'])."</a></div>					</td>				  </tr><tr><Td><Br/></td></tr>				";			}			// End Table			echo "</table>";			if(isset($_SESSION['alive'])) {				if($_SESSION['rank'] >= 2) {					echo "<br/><Br/>";								outputCreateThreadBox($id);				}			}		}	}	} // End of Functionfunction outputPostsByThreadID($id) {	// Grab the Thread ID and name.	$query = "SELECT `thread_id`,`name` FROM `threads` WHERE `thread_id`='$id'";	$retQuery = querySelect($query);	if(mysql_num_rows($retQuery) == 0) {		echo "No Threads To To Display";		exit();	}		else {		$row1 = mysql_fetch_row($retQuery);		// Begin table and output thread id, name		echo "			<table width=630 border=0>				<td colspan=3><h3><a href=forum.php?mode=viewthread&tid=".$row1[0].">".$row1[1]."</a></h3><br/></td>			  </tr>		";				// Grab all post info where thread_id=$'id'		$query2 = "SELECT * FROM `posts` WHERE `thread_group_id`='$id'";			$retQuery2 = querySelect($query2);		  			if($retQuery2 == 0) {			echo "</table>";			echo "No Threads For Current Topic ID";			exit();		} else {						// fetch_array all posts info				while(($row = mysql_fetch_array($retQuery2))) {				echo "				  <tr>				    <td valign=top><div align=left><b>By:</b> 						<a href=user-profile.php?id=".$row['by'].">".grabUserFromID($row['by'])."</a></div>					</td>				  					    <td valign=top><div align=left><b>On:</b> ".$row['post_time']."</a></div>					</td>				  </tr><tr>				    <td colspan=3 height=60 valign=top>".nl2br($row['content'])."</td>				  </tr>				";			}			echo "</table>";			if(isset($_SESSION['alive'])) {				echo "<br/>";				outputReplyBox($id);			}						}		}	} // End of Functionfunction outputReplyBox($thread_id) {	echo "			<form action=forum.php?mode=reply&tid=".$thread_id." method=post>			<table width=400 height=130 border=0>			  <tr>			    <td height=97 colspan=2><textarea name=postReplyBoxContent cols=50 rows=7 /></textarea></td>			  </tr>			  <tr>			    <td width=365 height=25>&nbsp;</td>			    <td width=61><input type=submit name=postReplyBox value=Reply! /></td>			  </tr>			</table>		</form>	";}function replyToPost($id) {	if(isset($_POST['postReplyBox'])) {		if(isset($_POST['postReplyBoxContent'])) {			if(empty($_POST['postReplyBoxContent'])) {				echo "Error: No Content For Reply<br/>";				exit;			}else {				$content = $_POST['postReplyBoxContent'];				$content = strip_tags($content);				$content = escape($content);				$by = grabIDFromUser($_SESSION['name']);				$post_time = date("j F y, g:i a");				$thread_group_id = $id;								$query = "SELECT `thread_id` FROM `threads` WHERE `thread_id`='$thread_group_id'";				$ret = queryCheckIfExists($query);				if($ret==0) {					echo "Hacking Attempt Detected; Thread ID for this specific post, doesnt exist.";					exit();				}												$query = "INSERT INTO `posts` (`thread_group_id`,`by`,`post_time`,`content`)				VALUES ('$thread_group_id','$by','$post_time','$content')";								$retInsert = queryInsert($query);				if($retInsert==0) {					echo "Error Adding Post To Database !";					exit;				}				updateLastActivePostUser($id);			}		}	}}function updateLastActivePostUser($thread_id) {	$user_id = grabIDFromUser($_SESSION['name']);	$query = "SELECT `last_active_user_id` FROM `threads` WHERE `last_active_user_id`='$user_id'";	$ret = queryCheckIfExists($query);	if($ret==0) {	$query2 = "UPDATE `threads` SET `last_active_user_id`='$user_id' WHERE `thread_id`='$thread_id'";		queryUpdate($query2);	}}function outputCreateThreadBox($topic_id) {	echo "			<h3>Create New Thread</h3>			<form action=forum.php?mode=addthread&tid=".$topic_id." method=post>			<table width=400 height=178 border=0>			  <tr>			    <td height=24 colspan=3><strong>Description</strong></td>			  </tr>			  <tr>			    <td height=48 colspan=3><textarea name=threadDesc cols=50 rows=5 /></textarea></td>		      </tr>			  <tr>			    <td width=100 height=25><strong>Thread Name</strong> </td>			    <td width=217><input type=text name=threadName size=20 maxlength=20 /></td>			    <td width=69><input type=submit name=createNewThread value=Reply! /></td>			  </tr>			</table>		</form>	";	}function createNewThread($topic_id) {	if(isset($_POST['createNewThread'])) {		if(isset($_SESSION['rank'])) {			if(!isset($_POST['threadName'])) {				echo "Thread Name Not Entered";				exit();			} 			if(!isset($_POST['threadDesc'])) {				echo "Thread Desc Not Entered";				exit();			}					$name = $_POST['threadName'];			$name = strip_tags($name);			$name = escape($name);						$by = $_SESSION['name'];			$desc = $_POST['threadDesc'];			$desc = strip_tags($desc);			$desc = escape($desc);				$last_active_date = date("j F y, g:i a");							$query = "SELECT `id` FROM `topics` WHERE `id`='$topic_id'";			$ret = queryCheckIfExists($query);			if($ret==0) {				echo "Hacking Attempt Detected; Topic ID for this specific thread, doesnt exist.";				exit();			}				$query2 = "INSERT INTO `threads` (`topic_group_id`,`name`,`by`,`desc`,`last_active_date`)			VALUES ('$topic_id','$name','$by','$desc','$last_active_date')";			$ret2 = queryInsert($query2);			if($ret2==0)				echo "Thread Not Created!";			elseif($ret2==1)				echo "Thread Successfully Created";			}	}}function createNewTopic() {	if(isset($_POST['createNewTopic'])) {		if($_SESSION['rank'] < 3) {			if(!isset($_POST['topicName'])) {				echo "Thread Name Not Entered";				exit();			} 			if(!isset($_POST['topicDesc'])) {				echo "Thread Desc Not Entered";				exit();			}					$name = $_POST['topicName'];			$name = strip_tags($name);			$name = escape($name);			$by = $_SESSION['name'];			$desc = $_POST['topicDesc'];			$desc = strip_tags($desc);			$desc = escape($desc);				$last_active_date = date("j F y, g:i a");					$query = "INSERT INTO `threads` (`name`,`by`,`desc`,`last_active_date`)			VALUES ('$name','$by','$desc',`$last_active_date`)";			$ret = queryInsert($query);			if($ret==0)				echo "Topic Not Created!";			elseif($ret==1)				echo "Topic Successfully Created";						}	}}function outputCreateTopicBox() {	echo "			<h3>Create New Topic</h3>			<form action=forum.php?mode=addtopic method=post>			<table width=400 height=178 border=0>			  <tr>			    <td height=24 colspan=3><strong>Description</strong></td>			  </tr>			  <tr>			    <td height=48 colspan=3><textarea name=topicDesc cols=50 rows=5 /></textarea></td>		      </tr>			  <tr>			    <td width=100 height=25><strong>Topic Name</strong> </td>			    <td width=217><input type=text name=topicName size=20 maxlength=20 /></td>			    <td width=69><input type=submit name=createNewTopic value=Reply! /></td>			  </tr>			</table>		</form>	";	}?>