https://www.icyphoenix.com/viewtopic.php?f=28&t=7740&p=52082#p52082 ----------------------------------- KugeLSichA Thu 24 Mar, 2011 16:41 New Thanks Per Post MOD ----------------------------------- Hey folks, I have rewritten the normal Thanks per Topic post to Thanks per POST... and have opened a new Topic to keep questions about the 2 different MODs clean... Some code is taken from spydie in this topic -> http://www.icyphoenix.com/viewtopic.php?f=2&t=7714 If you have installed spydie´s thanks per post MOD, first you need to completly deinstall the MOD! In my MOD you can activate/deactivate the MOD via ACP (where the normal Thanks settings was) [list][b]Whats the difference?[/b] [*]Thanks per Post in all Forums where Thank Post are allowed -> config via ACP Forum settings [*]you can turn on/off the complete Thanks MOD via ACP -> Icy Phoenix Settings -> SQL Opti [*]you can also set up if you want to show "Thanks given" / "Thanks received" in viewtopic and profile [*]you can search for the thanks and thanks_given Posts [*]uses lang files [*]works also with CASH MOD (if enabled)[/list] [color=red][b][size=14]If you want to install this MOD, do a complete backup of your files AND database...[/size][/b][/color] [b]Screenshots & Demo:[/b] [img]http://www.icyphoenix.com/files/images/6/thanks_1.png[/img] [img]http://www.icyphoenix.com/files/images/6/thanks_2.png[/img] [img]http://www.icyphoenix.com/files/images/6/thanks_3.png[/img] [img]http://www.icyphoenix.com/files/images/6/thanks_4.png[/img] [img]http://www.icyphoenix.com/files/images/6/thanks_5.png[/img] DEMO: viewtopic -> http://www.blademaniacs.de/viewtopic.php?f=1&t=516 DEMO: profile -> http://www.blademaniacs.de/profile.php?mode=viewprofile&u=2 (maybe not viewable as guest) Please post errors and/or suggestions in this topic... Special Thanks to [b]spydie[/b] and [b]TheSteffen[/b] [spoiler][code linenumbers=false]# #-----[ SQL QUERIES ]------------------------------------------ # # N O T E!!! change the table prefix "ip_" to your default one # DROP TABLE `ip_thanks`; CREATE TABLE IF NOT EXISTS `ip_thanks` ( `topic_id` mediumint(8) NOT NULL DEFAULT '0', `user_id` mediumint(8) NOT NULL DEFAULT '0', `user_poster` mediumint(8) NOT NULL DEFAULT '0', `post_id` mediumint(8) NOT NULL DEFAULT '0', `thanks_time` int(11) NOT NULL DEFAULT '0' ); INSERT INTO `ip_config` (`config_name`, `config_value`) VALUES ('show_thanks_given_viewtopic', '0'); INSERT INTO `ip_config` (`config_name`, `config_value`) VALUES ('show_thanks_given_profile', '0'); # #-----[ UPLOAD ]------------------------------------------ # # templates\images\cyan\lang_english\icon_post_thanks.gif # # If you have other languages and/or styles installed, you need # to add the image to all language/styles folders... # #-----[ OPEN ]------------------------------------------ # includes\mods_settings\mod_sql_charge.php # #-----[ FIND ]------------------------------------------ # 'show_thanks_viewtopic' => array( 'lang_key' => 'IP_show_thanks_viewtopic', 'type' => 'LIST_RADIO', 'default' => 'No', 'values' => $list_yes_no, ), # #-----[ AFTER ADD ]------------------------------------------ # 'show_thanks_given_profile' => array( 'lang_key' => 'IP_show_thanks_given_profile', 'type' => 'LIST_RADIO', 'default' => 'No', 'values' => $list_yes_no, ), 'show_thanks_given_viewtopic' => array( 'lang_key' => 'IP_show_thanks_given_viewtopic', 'type' => 'LIST_RADIO', 'default' => 'No', 'values' => $list_yes_no, ), # #-----[ OPEN ]------------------------------------------ # includes\functions_dbmtnc.php # #-----[ FIND ]------------------------------------------ # 'show_thanks_viewtopic' => '0', # #-----[ AFTER ADD ]------------------------------------------ # 'show_thanks_given_profile' => '0', 'show_thanks_given_viewtopic' => '0', # #-----[ OPEN ]------------------------------------------ # includes\functions_profile.php # #-----[ FIND ]------------------------------------------ # function user_get_thanks_received($user_id) { global $db; $total_thanks_received = 0; $sql = "SELECT COUNT(th.topic_id) AS total_thanks FROM " . THANKS_TABLE . " th, " . TOPICS_TABLE . " t WHERE t.topic_poster = '" . $user_id . "' AND t.topic_id = th.topic_id"; if(!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, "Could not query thanks informations", "", __LINE__, __FILE__, $sql); } if (!$row = $db->sql_fetchrow($result)) { message_die(GENERAL_ERROR, "Could not query thanks informations", "", __LINE__, __FILE__, $sql); } $total_thanks_received = $row['total_thanks']; $db->sql_freeresult($result); return $total_thanks_received; } # #-----[ REPLACE WITH ]------------------------------------------ # // Thanks per Post Mod - BEGIN function user_get_thanks_received($user_id) { global $db; $total_thanks_received = 0; $sql = "SELECT COUNT(user_id) AS total_thanks FROM " . THANKS_TABLE . " WHERE user_poster = '" . $user_id . "'"; //if (!($result = $db->sql_query($sql, false, 'users_thanks_rec_', USERS_CACHE_FOLDER))) if(!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Could not query thanks informations', '', __LINE__, __FILE__, $sql); } $row = $db->sql_fetchrow($result); $total_thanks_received = $row['total_thanks']; $db->sql_freeresult($result); return $total_thanks_received; } function user_get_thanks_given($user_id) { global $db; $total_thanks_given = 0; $sql = "SELECT COUNT(user_id) AS total_thanks_given FROM " . THANKS_TABLE . " WHERE user_id = '" . $user_id . "'"; //if (!($result = $db->sql_query($sql, false, 'users_thanks_giv_', USERS_CACHE_FOLDER))) if(!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Could not query thanks informations', '', __LINE__, __FILE__, $sql); } $row = $db->sql_fetchrow($result); $total_thanks_given = $row['total_thanks_given']; $db->sql_freeresult($result); return $total_thanks_given; } // Thanks per Post Mod - END # #-----[ OPEN ]------------------------------------------ # includes\usercp_viewprofile.php # #-----[ FIND ]------------------------------------------ # // Mighty Gorgon - Thanks Received - BEGIN $total_thanks_received = 0; if (($board_config['show_thanks_profile'] == true) && ($board_config['disable_thanks_topics'] == false)) { $total_thanks_received = user_get_thanks_received($profiledata['user_id']); $template->assign_block_vars('show_thanks_profile', array()); } // Mighty Gorgon - Thanks Received - END # #-----[ REPLACE WITH ]------------------------------------------ # // Mighty Gorgon - Thanks Received - BEGIN $total_thanks_received = 0; $total_thanks_given = 0; if (($board_config['show_thanks_profile'] == true) && ($board_config['disable_thanks_topics'] == false)) { $total_thanks_received = user_get_thanks_received($profiledata['user_id']); $template->assign_block_vars('show_thanks_profile', array()); } if (($board_config['show_thanks_given_profile'] == true) && ($board_config['disable_thanks_topics'] == false)) { $total_thanks_given = user_get_thanks_given($profiledata['user_id']); $template->assign_block_vars('show_thanks_given_profile', array()); } // Mighty Gorgon - Thanks Received - END # #-----[ FIND ]------------------------------------------ # 'THANKS_RECEIVED' => (($total_thanks_received > 0) ? ('' . $total_thanks_received . '') : $total_thanks_received), # #-----[ AFTER ADD ]------------------------------------------ # 'THANKS_GIVEN' => (($total_thanks_given > 0) ? ('' . $total_thanks_given . '') : $total_thanks_given), # #-----[ OPEN ]------------------------------------------ # language\lang_english\lang_extend_icy_phoenix.php # #-----[ FIND ]------------------------------------------ # 'IP_show_thanks_viewtopic' => 'Show Thanks received when viewing topics', # #-----[ AFTER ADD ]------------------------------------------ # 'IP_show_thanks_given_profile' => 'Show Thanks given when viewing profile', 'IP_show_thanks_given_viewtopic' => 'Show Thanks given when viewing topics', # #-----[ OPEN ]------------------------------------------ # language\lang_german\lang_extend_icy_phoenix.php # #-----[ FIND ]------------------------------------------ # 'IP_show_thanks_profile' => 'Zeigt "Erhaltene Danksagungen" beim Anschauen eines Profils an', 'IP_show_thanks_viewtopic' => 'Zeigt "Erhaltene Danksagungen" beim Lesen von Themen an', # #-----[ REPLACE WITH ]------------------------------------------ # 'IP_show_thanks_profile' => 'Zeigt "Danke erhalten" beim Anschauen eines Profils an', 'IP_show_thanks_viewtopic' => 'Zeigt "Danke erhalten" beim Lesen von Themen an', 'IP_show_thanks_given_profile' => 'Zeigt "Danke gesagt" beim Anschauen eines Profils an', 'IP_show_thanks_given_viewtopic' => 'Zeigt "Danke gesagt" beim Lesen von Themen an', # #-----[ OPEN ]------------------------------------------ # language\lang_english\lang_main.php # #-----[ FIND ]------------------------------------------ # // Begin Thanks Mod 'thankful' => 'Thankful People', 'thanks_to' => 'Thanks for the useful Topic', 'thanks_end' => ':', 'thanks_alt' => 'Thanks Topic', 'thanks_add_rate' => 'Thanks the author for the useful topic', 'thanked_before' => 'You have already thanked this topic', 'thanks_add' => 'Your thanks has been given', 'thanks_not_logged' => 'You need to log in to thank someone\'s post', 'thanks2' => 'Thank you very much!
', // End Thanks Mod # #-----[ REPLACE WITH ]------------------------------------------ # // Begin Thanks Mod 'thankful' => 'Thankful People', 'thanks_to' => 'Thanks for the useful Post,', 'thanks_end' => ':', 'thanks_alt' => 'Thanks Post', 'thanks_add_rate' => 'Thanks the author for the useful post', 'thanked_before' => 'You have already thanked this post', 'thanks_add' => 'Your thanks has been given', 'thanks_not_logged' => 'You need to log in to thank someone\'s post', 'thanks2' => 'Thank you very much!
', // End Thanks Mod # #-----[ FIND ]------------------------------------------ # 'THANKS_RECEIVED' => 'Thanks received', # #-----[ AFTER ADD ]------------------------------------------ # 'THANKS_GIVEN' => 'Thanks given', # #-----[ OPEN ]------------------------------------------ # language\lang_german\lang_main.php # #-----[ FIND ]------------------------------------------ # // Begin Thanks Mod 'thankful' => 'Dankbare Nutzer', 'thanks_to' => 'Danke für dieses hilfreiche Thema', 'thanks_end' => ':', 'thanks_alt' => 'Dankesbeitrag', 'thanks_add_rate' => 'Danke dem Autor für diesen nützlichen Beitrag', 'thanked_before' => 'Du hast dich für diesen Beitrag schon bedankt', 'thanks_add' => 'Dein Danke wurde hinzugefügt', 'thanks_not_logged' => 'Du muss dich einloggen, um dich für einen Beitrag zu bedanken.', 'thanks2' => 'Vielen Dank!
', // End Thanks Mod # #-----[ REPLACE WITH ]------------------------------------------ # // Begin Thanks Mod 'thankful' => 'Dankbare Nutzer', 'thanks_to' => 'Danke für diesen hilfreichen Beitrag,', 'thanks_end' => ':', 'thanks_alt' => 'Dankesbeitrag', 'thanks_add_rate' => 'Danke dem Autor für diesen nützlichen Beitrag', 'thanked_before' => 'Du hast dich für diesen Beitrag schon bedankt', 'thanks_add' => 'Dein Danke wurde hinzugefügt', 'thanks_not_logged' => 'Du muss dich einloggen, um dich für einen Beitrag zu bedanken.', 'thanks2' => 'Vielen Dank!
', // End Thanks Mod # #-----[ FIND ]------------------------------------------ # 'THANKS_RECEIVED' => 'Danke erhalten', # #-----[ AFTER ADD ]------------------------------------------ # 'THANKS_GIVEN' => 'Danke gesagt', # #-----[ OPEN ]------------------------------------------ # language\lang_english\lang_main_settings.php # #-----[ FIND ]------------------------------------------ # $lang['JOINED_DATE_FORMAT'] = 'F Y'; // Date format of Joined date, php date() format # #-----[ AFTER ADD ]------------------------------------------ # $lang['DATE_FORMAT_THANKS'] = 'd F'; // Date format of Thank Posts date, php date() format # #-----[ OPEN ]------------------------------------------ # language\lang_german\lang_main_settings.php # #-----[ FIND ]------------------------------------------ # $lang['JOINED_DATE_FORMAT'] = 'F Y'; // Datums-Format der Anmeldung, php date() format # #-----[ AFTER ADD ]------------------------------------------ # $lang['DATE_FORMAT_THANKS'] = 'd F'; // Datums-Format der Danke-Beiträge, php date() format # #-----[ OPEN ]------------------------------------------ # templates\default\default.cfg # #-----[ FIND ]------------------------------------------ # $images['kb_title'] = $buttons_lang_folder . 'kb.gif' . $img_fade; # #-----[ AFTER ADD ]------------------------------------------ # $images['icon_thanks'] = $buttons_lang_folder . 'icon_post_thanks.' . $buttons_extension . $img_fade . $extra_padding; # #-----[ OPEN ]------------------------------------------ # templates\default\profile_view_body.tpl # #-----[ FIND ]------------------------------------------ # {L_THANKS_RECEIVED} {THANKS_RECEIVED} # #-----[ AFTER ADD ]------------------------------------------ # {L_THANKS_GIVEN} {THANKS_GIVEN} # #-----[ OPEN ]------------------------------------------ # templates\default\viewtopic_body.tpl # #-----[ FIND ]------------------------------------------ # {postrow.POSTER_THANKS_RECEIVED} # #-----[ AFTER ADD ]------------------------------------------ # {postrow.POSTER_THANKS_GIVEN} # #-----[ FIND ]------------------------------------------ # {L_BACK_TOP}{L_BACK_BOTTOM} {postrow.thanks.THANKS3} {postrow.thanks.THANKS}  # #-----[ REPLACE WITH ]------------------------------------------ # {postrow.THANK_POST_IMG}{L_BACK_TOP}{L_BACK_BOTTOM} {postrow.thanks.THANKS3} {postrow.thanks.THANKS}  # #-----[ OPEN ]------------------------------------------ # posting.php # #-----[ FIND ]------------------------------------------ # elseif ($mode == 'thank') { $topic_id = intval($_GET[POST_TOPIC_URL]); $topic_id_append = (!empty($topic_id) ? (POST_TOPIC_URL . '=' . $topic_id) : ''); if (!($userdata['session_logged_in'])) { $message = $lang['thanks_not_logged']; $message .= '

' . sprintf($lang['Click_return_topic'], '', ''); message_die(GENERAL_MESSAGE, $message); } if (empty($topic_id)) { message_die(GENERAL_MESSAGE, 'No topic Selected'); } $userid = $userdata['user_id']; $thanks_date = time(); // Check if user is the topic starter $sql = "SELECT `topic_poster` FROM " . TOPICS_TABLE . " WHERE topic_id = '" . $topic_id . "'"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Couldn\'t check for topic starter', '', __LINE__, __FILE__, $sql); } if (!($topic_starter_check = $db->sql_fetchrow($result))) { message_die(GENERAL_ERROR, 'Couldn\'t check for topic starter', '', __LINE__, __FILE__, $sql); } if ($topic_starter_check['topic_poster'] == $userdata['user_id']) { $message = $lang['t_starter']; $message .= '

' . sprintf($lang['Click_return_topic'], '', ''); message_die(GENERAL_MESSAGE, $message); } // Check if user had thanked before $sql = "SELECT `topic_id` FROM " . THANKS_TABLE . " WHERE topic_id = '" . $topic_id . "' AND user_id = '" . $userid . "'"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Couldn\'t check for previous thanks', '', __LINE__, __FILE__, $sql); } if (!($thankfull_check = $db->sql_fetchrow($result))) { // Insert thanks $sql = "INSERT INTO " . THANKS_TABLE . " (topic_id, user_id, thanks_time) VALUES ('" . $topic_id . "', '" . $userid . "', " . $thanks_date . ") "; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not insert thanks information', '', __LINE__, __FILE__, $sql); } $message = $lang['thanks_add']; // MG Cash MOD For IP - BEGIN if (defined('CASH_MOD')) { $message .= '
' . $GLOBALS['cm_posting']->cash_update_thanks($topic_starter_check['topic_poster']); } // MG Cash MOD For IP - END } else { $message = $lang['thanked_before']; } $redirect_url = append_sid(VIEWTOPIC_MG . '?' . (!empty($forum_id_append) ? ($forum_id_append . '&') : '') . $topic_id_append); meta_refresh(3, $redirect_url); $message .= '

' . sprintf($lang['Click_return_topic'], '', ''); message_die(GENERAL_MESSAGE, $message); } # #-----[ REPLACE WITH ]------------------------------------------ # // Thanks per Post Mod - BEGIN elseif ($mode == 'thank') { $topic_id = intval($_GET[POST_TOPIC_URL]); $topic_id_append = (!empty($topic_id) ? (POST_TOPIC_URL . '=' . $topic_id) : ''); if (!($userdata['session_logged_in'])) { $message = $lang['thanks_not_logged']; $message .= '

' . sprintf($lang['Click_return_topic'], '', ''); message_die(GENERAL_MESSAGE, $message); } if (empty($topic_id)) { message_die(GENERAL_MESSAGE, 'No topic Selected'); } $userid = $userdata['user_id']; $thanks_date = time(); // Check if user thanks himself $sql = "SELECT `poster_id` FROM " . POSTS_TABLE . " WHERE post_id = '" . $post_id . "'"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not check for post thanks', '', __LINE__, __FILE__, $sql); } $post_thank_check = $db->sql_fetchrow($result); if ($post_thank_check['poster_id'] == $userdata['user_id']) { $message = $lang['t_starter']; $message .= '

' . sprintf($lang['Click_return_topic'], '', ''); message_die(GENERAL_MESSAGE, $message); } // Check if user had thanked before $sql = "SELECT `post_id` FROM " . THANKS_TABLE . " WHERE post_id = '" . $post_id . "' AND user_id = '" . $userid . "'"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not check for previous thanks', '', __LINE__, __FILE__, $sql); } if (!($thankfull_check = $db->sql_fetchrow($result))) { // Insert thanks $sql = "INSERT INTO " . THANKS_TABLE . " (post_id, topic_id, user_poster, user_id, thanks_time) VALUES ('" . $_REQUEST['p'] . "', '" . $_REQUEST['t'] . "', '" . $_REQUEST['poster'] . "', '" . $userid . "', " . $thanks_date . ")"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not insert thanks information', '', __LINE__, __FILE__, $sql); } $message = $lang['thanks_add']; // MG Cash MOD For IP - BEGIN if (defined('CASH_MOD')) { $message .= '
' . $GLOBALS['cm_posting']->cash_update_thanks($post_thank_check['poster_id']); } // MG Cash MOD For IP - END } else { $message = $lang['thanked_before']; } $redirect_url = append_sid(VIEWTOPIC_MG . '?' . (!empty($forum_id_append) ? ($forum_id_append . '&') : '') . $topic_id_append); meta_refresh(3, $redirect_url); $message .= '

' . sprintf($lang['Click_return_topic'], '', ''); message_die(GENERAL_MESSAGE, $message); } // Thanks per Post Mod - END # #-----[ OPEN ]------------------------------------------ # search.php # #-----[ FIND ]------------------------------------------ # if (isset($_POST['search_thanks']) || isset($_GET['search_thanks'])) { $search_thanks = (isset($_POST['search_thanks'])) ? intval($_POST['search_thanks']) : intval($_GET['search_thanks']); } else { $search_thanks = '0'; } $search_thanks = (($search_thanks >= '2') && ($board_config['disable_thanks_topics'] == false)) ? $search_thanks : false; # #-----[ AFTER ADD ]------------------------------------------ # if (isset($_POST['search_thanks_given']) || isset($_GET['search_thanks_given'])) { $search_thanks_given = (isset($_POST['search_thanks_given'])) ? intval($_POST['search_thanks_given']) : intval($_GET['search_thanks_given']); } else { $search_thanks_given = '0'; } $search_thanks_given = (($search_thanks_given >= '2') && ($board_config['disable_thanks_topics'] == false)) ? $search_thanks_given : false; # #-----[ FIND ]------------------------------------------ # elseif (($search_keywords != '') || ($search_author != '') || $search_id || ($search_ip != '') || ($search_thanks != false)) # #-----[ REPLACE WITH ]------------------------------------------ # elseif (($search_keywords != '') || ($search_author != '') || $search_id || ($search_ip != '') || ($search_thanks != false) || ($search_thanks_given != false)) # #-----[ FIND ]------------------------------------------ # if (in_array($search_id, $search_id_filter_array) || ($search_keywords != '') || ($search_author != '') || ($search_ip != '') || ($search_thanks != false)) # #-----[ REPLACE WITH ]------------------------------------------ # if (in_array($search_id, $search_id_filter_array) || ($search_keywords != '') || ($search_author != '') || ($search_ip != '') || ($search_thanks != false) || ($search_thanks_given != false)) # #-----[ FIND ]------------------------------------------ # elseif ($search_thanks != false) { if ($userdata['session_logged_in']) { if ($auth_sql != '') { $sql = "SELECT DISTINCT(t.topic_id), f.forum_id FROM " . THANKS_TABLE . " th, " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f WHERE t.topic_poster = '" . $search_thanks . "' AND t.topic_id = th.topic_id AND t.forum_id = f.forum_id AND $auth_sql"; } else { $sql = "SELECT DISTINCT(t.topic_id) FROM " . THANKS_TABLE . " th, " . TOPICS_TABLE . " t WHERE t.topic_poster = '" . $search_thanks . "' AND t.topic_id = th.topic_id"; } } else { redirect(append_sid(LOGIN_MG . '?redirect=' . SEARCH_MG . '&search_thanks=' . $search_thanks, true)); } if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not obtain topics ids', '', __LINE__, __FILE__, $sql); } $search_ids = array(); while($row = $db->sql_fetchrow($result)) { $search_ids[] = $row['topic_id']; } $db->sql_freeresult($result); $total_match_count = count($search_ids); if ($total_match_count <= $start) // No results for the selected page { $start = $total_match_count - 1; $start = intval($start / $board_config['topics_per_page']) * $board_config['topics_per_page']; } $show_results = 'topics'; $sort_by = 0; $sort_dir = 'DESC'; } # #-----[ REPLACE WITH ]------------------------------------------ # elseif ($search_thanks != false) { if ($userdata['session_logged_in']) { if ($auth_sql != '') { $sql = "SELECT DISTINCT(p.topic_id), f.forum_id FROM " . THANKS_TABLE . " th, " . POSTS_TABLE . " p, " . FORUMS_TABLE . " f WHERE p.poster_id = '" . $search_thanks . "' AND p.post_id = th.post_id AND p.forum_id = f.forum_id AND $auth_sql"; } else { $sql = "SELECT DISTINCT(p.topic_id) FROM " . THANKS_TABLE . " th, " . POSTS_TABLE . " p WHERE p.poster_id = '" . $search_thanks . "' AND p.post_id = th.post_id"; } } else { redirect(append_sid(LOGIN_MG . '?redirect=' . SEARCH_MG . '&search_thanks=' . $search_thanks, true)); } if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not obtain topics ids', '', __LINE__, __FILE__, $sql); } $search_ids = array(); while($row = $db->sql_fetchrow($result)) { $search_ids[] = $row['topic_id']; } $db->sql_freeresult($result); $total_match_count = count($search_ids); if ($total_match_count <= $start) // No results for the selected page { $start = $total_match_count - 1; $start = intval($start / $board_config['topics_per_page']) * $board_config['topics_per_page']; } $show_results = 'topics'; $sort_by = 0; $sort_dir = 'DESC'; } elseif ($search_thanks_given != false) { if ($userdata['session_logged_in']) { if ($auth_sql != '') { $sql = "SELECT DISTINCT(p.topic_id), f.forum_id FROM " . THANKS_TABLE . " th, " . POSTS_TABLE . " p, " . FORUMS_TABLE . " f WHERE th.user_id = '" . $search_thanks_given . "' AND p.post_id = th.post_id AND p.forum_id = f.forum_id AND $auth_sql"; } else { $sql = "SELECT DISTINCT(p.topic_id) FROM " . THANKS_TABLE . " th, " . POSTS_TABLE . " p WHERE th.user_id = '" . $search_thanks_given . "' AND p.post_id = th.post_id"; } } else { redirect(append_sid(LOGIN_MG . '?redirect=' . SEARCH_MG . '&search_thanks=' . $search_thanks_given, true)); } if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not obtain topics ids', '', __LINE__, __FILE__, $sql); } $search_ids = array(); while($row = $db->sql_fetchrow($result)) { $search_ids[] = $row['topic_id']; } $db->sql_freeresult($result); $total_match_count = count($search_ids); if ($total_match_count <= $start) // No results for the selected page { $start = $total_match_count - 1; $start = intval($start / $board_config['topics_per_page']) * $board_config['topics_per_page']; } $show_results = 'topics'; $sort_by = 0; $sort_dir = 'DESC'; } # #-----[ OPEN ]------------------------------------------ # viewtopic.php # #-----[ FIND ]------------------------------------------ # // Thanks Mod - BEGIN if ($board_config['disable_thanks_topics'] == false) { // Check if the Thanks feature is active for this forum $sql = "SELECT forum_thanks FROM " . FORUMS_TABLE . " WHERE forum_id = '" . $forum_id . "' LIMIT 1"; if (!($result = $db->sql_query($sql, false, 'forums_thanks_', FORUMS_CACHE_FOLDER))) { message_die(GENERAL_ERROR, 'Could not obtain forum information', '', __LINE__, __FILE__, $sql); } $show_thanks = 0; $show_thanks_button = 0; while ($forum_thank_result = $db->sql_fetchrow($result)) { $show_thanks = ($forum_thank_result['forum_thanks'] == 1) ? 1 : 0; $show_thanks_button = 0; if ($show_thanks && $userdata['session_logged_in']) { $sql_thanked = "SELECT topic_id FROM " . THANKS_TABLE . " WHERE topic_id = '" . $topic_id . "' AND user_id = '" . $userdata['user_id'] . "' LIMIT 1"; if (!($result_thanked = $db->sql_query($sql_thanked))) { message_die(GENERAL_ERROR, 'Could not obtain thanks information', '', __LINE__, __FILE__, $sql); } if ($has_thanked = $db->sql_fetchrow($result_thanked)) { $show_thanks_button = 0; } else { $show_thanks_button = 1; } $db->sql_freeresult($result_thanked); } } $db->sql_freeresult($result); } else { $show_thanks = 0; } // Thanks Mod - END # #-----[ REPLACE WITH ]------------------------------------------ # // Thanks per Post Mod - BEGIN if ($board_config['disable_thanks_topics'] == false) { // Check if the Thanks feature is active for this forum $sql = "SELECT forum_thanks FROM " . FORUMS_TABLE . " WHERE forum_id = '" . $forum_id . "' LIMIT 1"; if (!($result = $db->sql_query($sql, false, 'forums_thanks_', FORUMS_CACHE_FOLDER))) { message_die(GENERAL_ERROR, 'Could not obtain forum information', '', __LINE__, __FILE__, $sql); } $show_thanks = 0; $show_thanks_button = 0; $forum_thank_result = $db->sql_fetchrow($result); $show_thanks = ($forum_thank_result['forum_thanks'] == 1) ? 1 : 0; } else { $show_thanks = 0; } // Thanks per Post Mod - END # #-----[ FIND & DELETE ]------------------------------------------ # // Begin Thanks Mod $thank_topic_url = append_sid('posting.' . PHP_EXT . '?mode=thank&' . $forum_id_append . '&' . $topic_id_append); // End Thanks Mod # #-----[ FIND & DELETE ]------------------------------------------ # // Begin Thanks Mod $thank_img = $images['thanks']; $thank_alt = $lang['thanks_alt']; if ($show_thanks_button && ($postrow[0]['topic_poster'] != $userdata['user_id'])) { $template->assign_var('S_THANKS', true); } // End Thanks Mod # #-----[ FIND & DELETE ]------------------------------------------ # 'THANKS_IMG' => $thank_img, # #-----[ FIND ]------------------------------------------ # 'L_THANKS' => $thank_alt, 'L_THANKS_ADD_RATE' => $lang['thanks_add_rate'], # #-----[ REPLACE WITH ]------------------------------------------ # 'L_THANKS_ADD_RATE' => $lang['thanks_add_rate'], // Thanks per Post Mod # #-----[ FIND & DELETE ]------------------------------------------ # 'U_THANKS' => $thank_topic_url, # #-----[ FIND & DELETE ]------------------------------------------ # // Begin Thanks Mod // Get topic thanks if ($show_thanks == FORUM_THANKABLE) { // Select Format for the date $timeformat = "d F"; $sql = "SELECT u.user_id, u.username, u.user_active, u.user_color, t.thanks_time FROM " . THANKS_TABLE . " t, " . USERS_TABLE . " u WHERE topic_id = $topic_id AND t.user_id = u.user_id"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, "Could not obtain thanks information", '', __LINE__, __FILE__, $sql); } $total_thank = $db->sql_numrows($result); $thanksrow = array(); if ($fil = $db->sql_fetchrow($result)) { do { $thanksrow[] = $fil; } while ($fil = $db->sql_fetchrow($result)); } $db->sql_freeresult($result); $thanks = ''; for($i = 0; $i < $total_thank; $i++) { // Get thanks date $thanks_date[$i] = create_date_ip($timeformat, $thanksrow[$i]['thanks_time'], $board_config['board_timezone'], true); // Make thanker profile link $thanks .= '' . (($thanks != '') ? ', ' : '') . colorize_username($thanksrow[$i]['user_id'], $thanksrow[$i]['username'], $thanksrow[$i]['user_color'], $thanksrow[$i]['user_active']) . ' (' . $thanks_date[$i] . ')'; } $sql = "SELECT t.topic_poster, u.user_id, u.username, u.user_active, u.user_color FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u WHERE t.topic_id = $topic_id AND t.topic_poster = u.user_id LIMIT 1"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, "Could not obtain user information", '', __LINE__, __FILE__, $sql); } $author = array(); if ($fil = $db->sql_fetchrow($result)) { $author[] = $fil; } $db->sql_freeresult($result); $author_name = colorize_username($author[0]['user_id'], $author[0]['username'], $author[0]['user_color'], $author[0]['user_active']); $thanks2 = $lang['thanks_to'] . ' ' . $author_name . $lang['thanks_end']; } // End Thanks Mod # #-----[ FIND ]------------------------------------------ # // End add - Birthday MOD # #-----[ AFTER ADD ]------------------------------------------ # // Thanks per Post Mod - BEGIN $thank_post_url = ''; $thank_post_img = ''; if (($show_thanks == FORUM_THANKABLE) && ($userdata['user_id'] != ANONYMOUS)) { // Check if user had thanked before $sql = "SELECT `post_id` FROM " . THANKS_TABLE . " WHERE post_id = '" . $post_id . "' AND user_id = '" . $userdata['user_id'] . "'"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, 'Could not check for previous thanks', '', __LINE__, __FILE__, $sql); } if (!($thankfull_check = $db->sql_fetchrow($result))) { $show_thanks_button = 1; } else { $show_thanks_button = 0; } $sql_t = "SELECT u.user_id, u.username, u.user_active, u.user_color, t.thanks_time FROM " . THANKS_TABLE . " t, " . USERS_TABLE . " u WHERE post_id = $post_id AND t.user_id = u.user_id ORDER by thanks_time ASC"; if (!($result_t = $db->sql_query($sql_t))) { message_die(GENERAL_ERROR, 'Could not obtain thanks information', '', __LINE__, __FILE__, $sql_t); } $thanks = ''; $thanks_row = $db->sql_fetchrowset($result_t); for ($x = 0; $x < count($thanks_row); $x++) { $bedanker = colorize_username($thanks_row[$x]['user_id'], $thanks_row[$x]['username'], $thanks_row[$x]['user_color'], $thanks_row[$x]['user_active']); $thanks_date = create_date_ip($lang['DATE_FORMAT_THANKS'], $thanks_row[$x]['thanks_time'], $board_config['board_timezone']); $thanks .= '' . (($thanks != '') ? ', ' : '') . $bedanker . '(' . $thanks_date . ')'; } $thanks2 = $lang['thanks_to'] . ' ' . $poster . $lang['thanks_end']; if (($show_thanks_button == 1) && ($userdata['user_id'] != $poster_id)) { $thank_post_url = append_sid('posting.' . PHP_EXT . '?mode=thank&' . $forum_id_append . '&' . $topic_id_append . '&poster=' . $poster_id . '&p=' . $post_id . '#p' . $post_id); $thank_post_img = '' . $lang['thanks_add_rate'] . ''; } } // Thanks per Post Mod - END # #-----[ FIND ]------------------------------------------ # $poster_thanks_received = ''; if (($poster_id != ANONYMOUS) && ($userdata['user_id'] != ANONYMOUS) && $board_config['show_thanks_viewtopic'] && !$board_config['disable_thanks_topics'] && !$lofi) { $total_thanks_received = user_get_thanks_received($poster_id); $poster_thanks_received = ($total_thanks_received > 0) ? ($lang['THANKS_RECEIVED'] . ': ' . '' . $total_thanks_received . '' . '
') : ''; } # #-----[ REPLACE WITH ]------------------------------------------ # // Thanks per Post Mod - BEGIN $poster_thanks_received = ''; $poster_thanks_given = ''; if (($poster_id != ANONYMOUS) && ($userdata['user_id'] != ANONYMOUS) && $board_config['show_thanks_viewtopic'] && !$board_config['disable_thanks_topics'] && !$lofi) { $total_thanks_received = user_get_thanks_received($poster_id); $poster_thanks_received = ($total_thanks_received > 0) ? ($lang['THANKS_RECEIVED'] . ': ' . '' . $total_thanks_received . '' . '
') : ''; } if (($poster_id != ANONYMOUS) && ($userdata['user_id'] != ANONYMOUS) && $board_config['show_thanks_given_viewtopic'] && !$board_config['disable_thanks_topics'] && !$lofi) { $total_thanks_given = user_get_thanks_given($poster_id); $poster_thanks_given = ($total_thanks_given > 0) ? ($lang['THANKS_GIVEN'] . ': ' . '' . $total_thanks_given . '' . '
') : ''; } // Thanks per Post Mod - END # #-----[ FIND ]------------------------------------------ # 'POSTER_THANKS_RECEIVED' => $poster_thanks_received, # #-----[ REPLACE WITH ]------------------------------------------ # // Thanks per Post Mod - BEGIN 'POSTER_THANKS_RECEIVED' => $poster_thanks_received, 'POSTER_THANKS_GIVEN' => $poster_thanks_given, // Thanks per Post Mod - END # #-----[ FIND ]------------------------------------------ # 'MINI_POST_IMG' => $mini_post_img, # #-----[ AFTER ADD ]------------------------------------------ # // Thanks per Post Mod 'THANK_POST_IMG' => $thank_post_img, # #-----[ FIND ]------------------------------------------ # if(($show_thanks == FORUM_THANKABLE) && ($i == 0) && ($current_page == 1) && ($thanks <> '')) { $template->assign_block_vars('postrow.thanks', array( 'THANKS' => $thanks, 'THANKFUL' => $lang['thankful'], 'THANKS2' => $lang ['thanks2'], 'THANKS3' => $thanks2 ) ); } # #-----[ REPLACE WITH ]------------------------------------------ # // Thanks per Post Mod - BEGIN if(($show_thanks == FORUM_THANKABLE) && ($thanks <> '')) { $template->assign_block_vars('postrow.thanks', array( 'THANKS' => $thanks, 'THANKFUL' => $lang['thankful'], 'THANKS2' => $lang ['thanks2'], 'THANKS3' => $thanks2 ) ); } // Thanks per Post Mod - END[/code][/spoiler]