xntx
хнотик-багоискатель | Редактировать | Профиль | Сообщение | ICQ | Цитировать | Сообщить модератору Professor 1. Код: // Show First Post on Start of Every Page // Written by: Robbie Marsh // // Start Hack // Get First Post Information $sql = "SELECT u.username, u.user_id, u.user_from, u.user_viewemail, u.user_sig, u.user_sig_bbcode_uid, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt WHERE p.topic_id = $topic_id $limit_posts_time AND pt.post_id = p.post_id AND u.user_id = p.poster_id ORDER BY p.post_time $post_time_order LIMIT 0, 1"; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Could not obtain post/user information.", '', __LINE__, __FILE__, $sql); } if ( $row = $db->sql_fetchrow($result) ) { $postrow1 = array(); $postrow1[] = $row; $db->sql_freeresult($result); } else { message_die(GENERAL_MESSAGE, $lang['No_posts_topic']); } // Get Poster Name, ID and Post Date $poster_id1 = $postrow1[0]['user_id']; $poster1 = ( $poster_id1 == ANONYMOUS ) ? $lang['Guest'] : $postrow1[0]['username']; $post_date1 = create_date($board_config['default_dateformat'], $postrow1[0]['post_time'], $board_config['board_timezone']); // Define the little post icon for the first message if ( $userdata['session_logged_in'] && $postrow1[0]['post_time'] > $userdata['user_lastvisit'] && $postrow1[0]['post_time'] > $topic_last_read ) { $mini_post_img1 = $images['icon_minipost_new']; $mini_post_alt1 = $lang['New_post']; } else { $mini_post_img1 = $images['icon_minipost']; $mini_post_alt1 = $lang['Post']; } $mini_post_url1 = append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $postrow1[0]['post_id']) . '#' . $postrow1[0]['post_id']; // Set the Quote URL $temp_url = append_sid("posting.$phpEx?mode=quote&" . POST_POST_URL . "=" . $postrow1[0]['post_id']); $quote1 = '<a href="' . $temp_url . '"><img src="' . $images['icon_quote'] . '" alt="' . $lang['Reply_with_quote'] . '" title="' . $lang['Reply_with_quote'] . '" border="0" /></a>'; // Get the User Signature $user_sig1 = ( $postrow1[0]['enable_sig'] && $postrow1[0]['user_sig'] != '' && $board_config['allow_sig'] ) ? $postrow1[0]['user_sig'] : ''; // BBCode in text: $message1 = $postrow1[0]['post_text']; if ( $board_config['allow_bbcode'] ) { if ( $user_sig1 != '' && $postrow1[0]['user_sig_bbcode_uid'] != '' ) { $user_sig1 = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($user_sig1, $postrow1[0]['user_sig_bbcode_uid']) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $user_sig1); } if ( $postrow1[0]['bbcode_uid'] != '' ) { $message1 = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message1, $postrow1[0]['bbcode_uid']) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message1); } } $message1 = smilies_pass($message1); if ( $user_sig != '' ) { $user_sig1 = make_clickable($user_sig1); } $message1 = make_clickable($message1); // Get the Page Number - if it is the first page // don't show the first post preview if (floor( $start / $board_config['posts_per_page'] ) + 1 == 1 OR $userdata['user_allowfirstmsg'] == 0) { $startfm = "<!--"; $endfm = "-->"; } else { $startfm = ""; $endfm = ""; } // Assign Template variables $template->assign_vars(array( 'POSTER_NAME' => $poster1, 'POST_DATE' => $post_date1, 'POST_SUBJECT' => $postrow1[0]['post_subject'], 'FIRST_MESSAGE' => $message1, 'SIGNATURE' => $user_sig1, 'MINI_POST_IMG' => $mini_post_img1, 'QUOTE' => $quote1, 'L_MINI_POST_ALT' => $mini_post_alt1, 'U_MINI_POST' => $mini_post_url1, 'STARTFM' => $startfm, 'ENDFM' => $endfm ) ); // End Hack | 2. находим // doble_post_split start .... // doble_post_split end и заменяем на: Код: // doble_post_split start if ( $mode == 'reply' && $userdata['user_id'] != ANONYMOUS ) { $mytime = 6 * 60 * 60; // seconds $poster_id = $userdata['user_id']; $sql = "SELECT post_id, poster_id, MAX(post_time) FROM " . POSTS_TABLE . " WHERE topic_id = $topic_id GROUP BY post_time ORDER BY post_time DESC LIMIT 1"; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql); } $post_id_last_row = $db->sql_fetchrow($result); $post_id = $post_id_last_row['post_id']; $poster_topic_id = $post_id_last_row['poster_id']; if ( $post_id_last_row['poster_id'] == $poster_id && $post_id_last_row['MAX(post_time)'] + $mytime > time()) { $mode = 'editpost'; $sql = "SELECT post_text, bbcode_uid FROM " . POSTS_TEXT_TABLE . " WHERE post_id = $post_id"; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql); } $last_message_row = $db->sql_fetchrow($result); $bb_uid = ':' . $last_message_row['bbcode_uid']; // i don't know much about parsing the message, so it may well be that, there are some wrongs, anyway all seems to work fine $last_message = str_replace($bb_uid, '', $last_message_row['post_text']); $last_message = preg_replace('/\:[0-9a-z\:]+\]/si', ']', $last_message); $last_message = addslashes($last_message); } } // doble_post_split end | Добавлено ЗЫ: я поставил период на 6 часов. можно выставлять на 4той линии, там где переменная $mytime; но не забываем что это секунды
|