⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 edit_topic.php

📁 国外非常不错的论坛
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php/*	Copyright (C) 2003-2005 UseBB Team	http://www.usebb.net		$Header: /cvsroot/usebb/UseBB/sources/edit_topic.php,v 1.30 2005/08/13 11:36:09 pc_freak Exp $		This file is part of UseBB.		UseBB is free software; you can redistribute it and/or modify	it under the terms of the GNU General Public License as published by	the Free Software Foundation; either version 2 of the License, or	(at your option) any later version.		UseBB is distributed in the hope that it will be useful,	but WITHOUT ANY WARRANTY; without even the implied warranty of	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the	GNU General Public License for more details.		You should have received a copy of the GNU General Public License	along with UseBB; if not, write to the Free Software	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA*///// Die when called directly in browser//if ( !defined('INCLUDED') )	exit();//// Delete topics//if ( $_GET['act'] == 'delete' ) {		$session->update('deletetopic:'.$_GET['topic']);		//	// Include the page header	//	require(ROOT_PATH.'sources/page_head.php');		//	// Get info about the topic	//	$result = $db->query("SELECT t.id, t.forum_id, t.topic_title, t.count_replies, f.name AS forum_name, f.auth, f.last_topic_id, f.increase_post_count FROM ".TABLE_PREFIX."topics t, ".TABLE_PREFIX."forums f WHERE t.forum_id = f.id AND t.id = ".$_GET['topic']);	$topicdata = $db->fetch_result($result);		if ( !$topicdata['id'] ) {				//		// This topic does not exist		//		header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');		$template->set_page_title($lang['Error']);		$template->parse('msgbox', 'global', array(			'box_title' => $lang['Error'],			'content' => sprintf($lang['NoSuchTopic'], 'ID '.$_GET['topic'])		));			} else {				//		// Only if the user can delete topics		//		if ( $functions->auth($topicdata['auth'], 'delete', $topicdata['forum_id']) ) {						if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {								if ( !empty($_POST['delete']) ) {										$forum_counts_updated = false;										//					// 1. Delete the topic entry					//					$result = $db->query("DELETE FROM ".TABLE_PREFIX."topics WHERE id = ".$_GET['topic']);										//					// 2. Adjust latest updated topic of forum if needed					//					if ( $topicdata['last_topic_id'] == $_GET['topic'] ) {												$result = $db->query("SELECT p.topic_id FROM ".TABLE_PREFIX."posts p, ".TABLE_PREFIX."topics t WHERE p.topic_id = t.id AND t.forum_id = ".$topicdata['forum_id']." ORDER BY p.post_time DESC LIMIT 1");						$lasttopicdata = $db->fetch_result($result);												if ( !$lasttopicdata['topic_id'] ) {														$result = $db->query("UPDATE ".TABLE_PREFIX."forums SET topics = 0, posts = 0, last_topic_id = 0 WHERE id = ".$topicdata['forum_id']);														$forum_counts_updated = true;													} else {														$update_last_topic_id = ', last_topic_id = '.$lasttopicdata['topic_id'];													}											} else {												$update_last_topic_id = '';											}										//					// 3. Update the forum's counters					//					if ( !$forum_counts_updated ) {												$result = $db->query("UPDATE ".TABLE_PREFIX."forums SET topics = topics-1, posts = posts-". ( $topicdata['count_replies']+1 ) .$update_last_topic_id." WHERE id = ".$topicdata['forum_id']);											}										//					// 4. Adjust users' posts levels by defining which users posted and how many posts made					//					if ( $topicdata['increase_post_count'] ) {												$result = $db->query("SELECT poster_id FROM ".TABLE_PREFIX."posts WHERE topic_id = ".$_GET['topic']);												$users_posted = array();						while ( $postsdata = $db->fetch_result($result) ) {														if ( !array_key_exists($postsdata['poster_id'], $users_posted) )								$users_posted[$postsdata['poster_id']] = 1;							else								$users_posted[$postsdata['poster_id']]++;													}												//						// Adjust the count for every user that posted						//						foreach ( $users_posted as $userid => $postcount )							$result = $db->query("UPDATE ".TABLE_PREFIX."members SET posts = posts-".$postcount." WHERE id = ".$userid);											}										//					// 5. Delete posts within the deleted topic					//					$result = $db->query("DELETE FROM ".TABLE_PREFIX."posts WHERE topic_id = ".$_GET['topic']);										//					// 6. Adjust stats					//					$result = $db->query("UPDATE ".TABLE_PREFIX."stats SET content = content-1 WHERE name = 'topics'");										$result = $db->query("UPDATE ".TABLE_PREFIX."stats SET content = content-". ( $topicdata['count_replies']+1 ) ." WHERE name = 'posts'");										$functions->redirect('forum.php', array('id' => $topicdata['forum_id']));									} else {										$functions->redirect('topic.php', array('id' => $_GET['topic']));									}							} else {								$template->set_page_title($lang['DeleteTopic']);								$template->parse('confirm_form', 'global', array(					'form_begin' => '<form action="'.$functions->make_url('edit.php', array('topic' => $_GET['topic'], 'act' => 'delete')).'" method="post">',					'title' => $lang['DeleteTopic'],					'content' => sprintf($lang['ConfirmDeleteTopic'], '<em>'.unhtml(stripslashes($topicdata['topic_title'])).'</em>', '<em>'.unhtml(stripslashes($topicdata['forum_name'])).'</em>'),					'submit_button' => '<input type="submit" name="delete" value="'.$lang['Yes'].'" />',					'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'] == 'move' ) {		//	// Move topics	//	$session->update($_GET['act'].'topic:'.$_GET['topic']);			//	// Include the page header	//	require(ROOT_PATH.'sources/page_head.php');		//	// Get topic information	//	$result = $db->query("SELECT t.id, t.topic_title, t.forum_id, t.count_replies, p.post_time, f.name AS forum_name, f.auth, f.last_topic_id FROM ".TABLE_PREFIX."topics t, ".TABLE_PREFIX."posts p, ".TABLE_PREFIX."forums f WHERE t.forum_id = f.id AND p.id = t.last_post_id AND t.id = ".$_GET['topic']);	$topicdata = $db->fetch_result($result);		if ( !$topicdata['id'] ) {				//		// I didn't see that topic!?		//		header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');		$template->set_page_title($lang['Error']);		$template->parse('msgbox', 'global', array(			'box_title' => $lang['Error'],			'content' => sprintf($lang['NoSuchTopic'], 'ID '.$_GET['topic'])		));			} else {				//		// If the user is granted to move topics		//		if ( $functions->auth($topicdata['auth'], 'move', $topicdata['forum_id']) ) {						if ( !empty($_POST['new_forum_id']) && valid_int($_POST['new_forum_id']) ) {									if ( !empty($_POST['move']) ) {										//					// Get information about the new forum					//					$result = $db->query("SELECT f.id, f.last_topic_id, f.auth, p.post_time FROM ( ( ".TABLE_PREFIX."forums f LEFT JOIN ".TABLE_PREFIX."topics t ON t.id = f.last_topic_id ) LEFT JOIN ".TABLE_PREFIX."posts p ON p.id = t.last_post_id ) WHERE f.id = ".$_POST['new_forum_id']);					$forumdata = $db->fetch_result($result);										if ( !$forumdata['id'] ) {												$functions->redirect('topic.php', array('id' => $_GET['topic']));											} else {												if ( !$functions->auth($forumdata['auth'], 'view', $_POST['new_forum_id']) ) {														$functions->redirect('topic.php', array('id' => $_GET['topic']));													} else {														//							// Move the topic							//							$result = $db->query("UPDATE ".TABLE_PREFIX."topics SET forum_id = ".$_POST['new_forum_id']." WHERE id = ".$_GET['topic']);							$old_forum_counts_updated = false;														if ( $topicdata['last_topic_id'] == $_GET['topic'] ) {																//								// Adjust the last updated topic								//								$result = $db->query("SELECT p.topic_id FROM ".TABLE_PREFIX."posts p, ".TABLE_PREFIX."topics t WHERE p.topic_id = t.id AND t.forum_id = ".$topicdata['forum_id']." ORDER BY p.post_time DESC LIMIT 1");								$lasttopicdata = $db->fetch_result($result);																if ( !$lasttopicdata['topic_id'] ) {																		$result = $db->query("UPDATE ".TABLE_PREFIX."forums SET topics = 0, posts = 0, last_topic_id = 0 WHERE id = ".$topicdata['forum_id']);																		$old_forum_counts_updated = true;																	} else {																		$update_old_last_topic_id = ', last_topic_id = '.$lasttopicdata['topic_id'];																	}															} else {																$update_old_last_topic_id = '';															}														$update_new_last_topic_id = ( $topicdata['post_time'] > $forumdata['post_time'] ) ? ', last_topic_id = '.$_GET['topic'] : '';														//							// Adjust forum counts							//							if ( !$old_forum_counts_updated ) {								

⌨️ 快捷键说明

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