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

📄 edit_post.php

📁 国外非常不错的论坛
💻 PHP
📖 第 1 页 / 共 2 页
字号:
	//	// Get info about the post	//	$result = $db->query("SELECT p.id, p.poster_id, u.level AS poster_level, f.id AS forum_id, f.auth, f.last_topic_id, f.increase_post_count, t.id AS topic_id, t.count_replies, t.topic_title, t.first_post_id, t.last_post_id FROM ( ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."members u ON p.poster_id = u.id ), ".TABLE_PREFIX."forums f, ".TABLE_PREFIX."topics t WHERE t.id = p.topic_id AND f.id = t.forum_id AND p.id = ".$_GET['post']);	$postdata = $db->fetch_result($result);		if ( !$postdata['id'] ) {				//		// This post 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['NoSuchPost'], 'ID '.$_GET['post'])		));			} else {				//		// Only if the user can delete posts		//		if ( $session->sess_info['user_id'] && ( ( $postdata['poster_id'] == $session->sess_info['user_id'] && $postdata['last_post_id'] == $_GET['post'] ) || $functions->auth($postdata['auth'], 'delete', $postdata['forum_id']) ) && $postdata['poster_level'] <= $session->sess_info['user_info']['level'] ) {						if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {								if ( !empty($_POST['delete']) ) {										//					// 1. Delete the post entry (and eventually the topic entry)					//					$topic_deleted = false;					$result = $db->query("DELETE FROM ".TABLE_PREFIX."posts WHERE id = ".$_GET['post']);					if ( $postdata['count_replies'] < 1 ) {												$result = $db->query("DELETE FROM ".TABLE_PREFIX."topics WHERE id = ".$postdata['topic_id']);												$topic_deleted = true;						$update_topic_count = ', topics = topics-1';											} else {												$update_topic_count = '';											}										//					// 2. Adjust the topic's first and last post id if needed					//					if ( !$topic_deleted ) {												if ( $postdata['first_post_id'] == $_GET['post'] ) {														$result = $db->query("SELECT p.id FROM ".TABLE_PREFIX."posts p, ".TABLE_PREFIX."topics t WHERE p.topic_id = t.id AND t.id = ".$postdata['topic_id']." ORDER BY p.post_time ASC LIMIT 1");							$first_post_data = $db->fetch_result($result);							$update_first_post_id = ', first_post_id = '.$first_post_data['id'];													} else {														$update_first_post_id = '';													}												if ( $postdata['last_post_id'] == $_GET['post'] ) {														$result = $db->query("SELECT p.id FROM ".TABLE_PREFIX."posts p, ".TABLE_PREFIX."topics t WHERE p.topic_id = t.id AND t.id = ".$postdata['topic_id']." ORDER BY p.post_time DESC LIMIT 1");							$last_post_data = $db->fetch_result($result);							$update_last_post_id = ', last_post_id = '.$last_post_data['id'];													} else {														$update_last_post_id = '';													}											}										//					// 3. Adjust the topic's replies count if needed					//					if ( !$topic_deleted ) {												$result = $db->query("UPDATE ".TABLE_PREFIX."topics SET count_replies = count_replies-1".$update_first_post_id.$update_last_post_id." WHERE id = ".$postdata['topic_id']);											}										//					// 4. Adjust latest updated topic of forum if needed					//					if ( $postdata['last_topic_id'] == $postdata['topic_id'] ) {												$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 = ".$postdata['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 = ".$postdata['forum_id']);														$forum_counts_updated = true;													} else {														$update_last_topic_id = ', last_topic_id = '.$lasttopicdata['topic_id'];													}											} else {												$update_last_topic_id = '';											}										//					// 5. Update the forum's counters					//					if ( !isset($forum_counts_updated) ) {												$result = $db->query("UPDATE ".TABLE_PREFIX."forums SET posts = posts-1".$update_topic_count.$update_last_topic_id." WHERE id = ".$postdata['forum_id']);											}										//					// 6. Adjust user's posts level					//					if ( $postdata['poster_id'] > LEVEL_GUEST && $postdata['increase_post_count'] ) {												$result = $db->query("UPDATE ".TABLE_PREFIX."members SET posts = posts-1 WHERE id = ".$postdata['poster_id']);											}										//					// 7. Adjust stats					//					$result = $db->query("UPDATE ".TABLE_PREFIX."stats SET content = content-1 WHERE name = 'posts'");										if ( $topic_deleted ) {												$result = $db->query("UPDATE ".TABLE_PREFIX."stats SET content = content-1 WHERE name = 'topics'");												$functions->redirect('forum.php', array('id' => $postdata['forum_id']));											} else {												$functions->redirect('topic.php', array('id' => $postdata['topic_id']));											}									} else {										$functions->redirect('topic.php', array('post' => $_GET['post']), 'post'.$_GET['post']);									}							} else {								$template->set_page_title($lang['DeletePost']);				$template->parse('confirm_form', 'global', array(					'form_begin' => '<form action="'.$functions->make_url('edit.php', array('post' => $_GET['post'], 'act' => 'delete')).'" method="post">',					'title' => $lang['DeletePost'],					'content' => sprintf($lang['ConfirmDeletePost'], '<em>'.unhtml(stripslashes($postdata['topic_title'])).'</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');	}?>

⌨️ 快捷键说明

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