edit_topic.php

来自「国外非常不错的论坛」· PHP 代码 · 共 570 行 · 第 1/2 页

PHP
570
字号
								$result = $db->query("UPDATE ".TABLE_PREFIX."forums SET topics = topics-1, posts = posts-". ( $topicdata['count_replies']+1 ) .$update_old_last_topic_id." WHERE id = ".$topicdata['forum_id']);															}														$result = $db->query("UPDATE ".TABLE_PREFIX."forums SET topics = topics+1, posts = posts+". ( $topicdata['count_replies']+1 ) .$update_new_last_topic_id." WHERE id = ".$_POST['new_forum_id']);														$functions->redirect('topic.php', array('id' => $_GET['topic']));													}											}								} else {										$functions->redirect('topic.php', array('id' => $_GET['topic']));									}							} else {								$template->set_page_title($lang['MoveTopic']);								$result = $db->query("SELECT c.id AS cat_id, c.name AS cat_name, f.id, f.name, f.auth FROM ".TABLE_PREFIX."cats c, ".TABLE_PREFIX."forums f WHERE c.id = f.cat_id AND f.id <> ".$topicdata['forum_id']." ORDER BY c.sort_id ASC, c.name ASC, f.sort_id ASC, f.name ASC");				$forums = array();				while ( $forumdata = $db->fetch_result($result) ) {										if ( $functions->auth($forumdata['auth'], 'view', $forumdata['id']) )						$forums[] = $forumdata;									}								if ( !count($forums) ) {										$functions->redirect('topic.php', array('id' => $_GET['topic']));									} elseif ( count($forums) === 1 ) {										$new_forum_input = '<a href="'.$functions->make_url('forum.php', array('id' => $forumdata['id'])).'">'.unhtml(stripslashes($forumdata['name'])).'</a><input type="hidden" name="new_forum_id" value="'.$forumdata['id'].'" />';									} else {										//					// Get a list of available forums to move to					//					$new_forum_input = '<select name="new_forum_id">';					$seen_cats = array();					foreach ( $forums as $forumdata ) {												if ( !in_array($forumdata['cat_id'], $seen_cats) ) {														$new_forum_input .= ( !count($seen_cats) ) ? '' : '</optgroup>';							$new_forum_input .= '<optgroup label="'.unhtml(stripslashes($forumdata['cat_name'])).'">';							$seen_cats[] = $forumdata['cat_id'];													}												$new_forum_input .= '<option value="'.$forumdata['id'].'">'.unhtml(stripslashes($forumdata['name'])).'</option>';											}					$new_forum_input .= '</optgroup></select>';									}								$template->parse('move_topic_form', 'various', array(					'form_begin' => '<form action="'.$functions->make_url('edit.php', array('topic' => $_GET['topic'], 'act' => 'move')).'" method="post">',					'topic_v' => '<a href="'.$functions->make_url('topic.php', array('id' => $_GET['topic'])).'">'.unhtml(stripslashes($topicdata['topic_title'])).'</a>',					'old_forum_v' => '<a href="'.$functions->make_url('forum.php', array('id' => $topicdata['forum_id'])).'">'.unhtml(stripslashes($topicdata['forum_name'])).'</a>',					'new_forum_input' => $new_forum_input,					'submit_button' => '<input type="submit" name="move" value="'.$lang['OK'].'" />',					'cancel_button' => '<input type="submit" value="'.$lang['Cancel'].'" />',					'form_end' => '</form>'				));							}					} else {						$functions->redir_to_login();					}			}		//	// Include the page footer	//	require(ROOT_PATH.'sources/page_foot.php');	} elseif ( $_GET['act'] == 'lock' ) {		//	// Lock topics	//	$session->update();		$result = $db->query("SELECT t.id, t.status_locked, f.id, f.auth FROM ".TABLE_PREFIX."topics t, ".TABLE_PREFIX."forums f WHERE t.id = ".$_GET['topic']." AND f.id = t.forum_id");	$topicdata = $db->fetch_result($result);		if ( !$topicdata['id'] ) {				$functions->redirect('topic.php', array('id' => $_GET['topic']));			} else {				if ( !$functions->auth($topicdata['auth'], 'lock', $topicdata['id']) ) {						//			// Include the page header			//			require(ROOT_PATH.'sources/page_head.php');						$functions->redir_to_login();						//			// Include the page footer			//			require(ROOT_PATH.'sources/page_foot.php');					} else {						if ( $topicdata['status_locked'] ) {								$functions->redirect('topic.php', array('id' => $_GET['topic']));							} else {								$result = $db->query("UPDATE ".TABLE_PREFIX."topics SET status_locked = 1 WHERE id = ".$_GET['topic']);								$functions->redirect('topic.php', array('id' => $_GET['topic']));							}					}			}	} elseif ( $_GET['act'] == 'unlock' ) {		//	// Unlock topics	//	$session->update();		$result = $db->query("SELECT t.id, t.status_locked, f.id, f.auth FROM ".TABLE_PREFIX."topics t, ".TABLE_PREFIX."forums f WHERE t.id = ".$_GET['topic']." AND f.id = t.forum_id");	$topicdata = $db->fetch_result($result);		if ( !$topicdata['id'] ) {				$functions->redirect('topic.php', array('id' => $_GET['topic']));			} else {				if ( !$functions->auth($topicdata['auth'], 'lock', $topicdata['id']) ) {						//			// Include the page header			//			require(ROOT_PATH.'sources/page_head.php');						$functions->redir_to_login();						//			// Include the page footer			//			require(ROOT_PATH.'sources/page_foot.php');					} else {						if ( !$topicdata['status_locked'] ) {								$functions->redirect('topic.php', array('id' => $_GET['topic']));							} else {								$result = $db->query("UPDATE ".TABLE_PREFIX."topics SET status_locked = 0 WHERE id = ".$_GET['topic']);								$functions->redirect('topic.php', array('id' => $_GET['topic']));							}					}			}	} elseif ( $_GET['act'] == 'sticky' ) {		//	// Sticky topics	//	$session->update();		$result = $db->query("SELECT t.id, t.status_sticky, f.id, f.auth FROM ".TABLE_PREFIX."topics t, ".TABLE_PREFIX."forums f WHERE t.id = ".$_GET['topic']." AND f.id = t.forum_id");	$topicdata = $db->fetch_result($result);		if ( !$topicdata['id'] ) {				$functions->redirect('topic.php', array('id' => $_GET['topic']));			} else {				if ( !$functions->auth($topicdata['auth'], 'sticky', $topicdata['id']) ) {						//			// Include the page header			//			require(ROOT_PATH.'sources/page_head.php');						$functions->redir_to_login();						//			// Include the page footer			//			require(ROOT_PATH.'sources/page_foot.php');					} else {						if ( $topicdata['status_sticky'] ) {								$functions->redirect('topic.php', array('id' => $_GET['topic']));							} else {								$result = $db->query("UPDATE ".TABLE_PREFIX."topics SET status_sticky = 1 WHERE id = ".$_GET['topic']);								$functions->redirect('topic.php', array('id' => $_GET['topic']));							}					}			}	} elseif ( $_GET['act'] == 'unsticky' ) {		//	// "Unsticky" topics	// -does that word exist?-	//	$session->update();		$result = $db->query("SELECT t.id, t.status_sticky, f.id, f.auth FROM ".TABLE_PREFIX."topics t, ".TABLE_PREFIX."forums f WHERE t.id = ".$_GET['topic']." AND f.id = t.forum_id");	$topicdata = $db->fetch_result($result);		if ( !$topicdata['id'] ) {				$functions->redirect('topic.php', array('id' => $_GET['topic']));			} else {				if ( !$functions->auth($topicdata['auth'], 'sticky', $topicdata['id']) ) {						//			// Include the page header			//			require(ROOT_PATH.'sources/page_head.php');						$functions->redir_to_login();						//			// Include the page footer			//			require(ROOT_PATH.'sources/page_foot.php');					} else {						if ( !$topicdata['status_sticky'] ) {								$functions->redirect('topic.php', array('id' => $_GET['topic']));							} else {								$result = $db->query("UPDATE ".TABLE_PREFIX."topics SET status_sticky = 0 WHERE id = ".$_GET['topic']);								$functions->redirect('topic.php', array('id' => $_GET['topic']));							}					}			}	}?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?