phpbb2 thanks mod
phpbb2 .
. , " " "" , .

: http://shared.1gb.bg/wt/templates.rar>



:
http://shared.1gb.bg/viewtopic.php?t=6


##############################################################
## MOD Title: Thank You Mod for PhpBB
## MOD Author: Kinfule < kinfule@lycos.es > (Javier B) http://kinfule.tk
## MOD Description: This mod will add a feature for thanking the poster for his/her post.
##
## MOD Version: 1.1.9
##
## :
## : 20 ( )
## : 11
## admin/admin_forums.php,
## modcp.php,
## posting.php,
## viewtopic.php,
## includes/constants.php,
## includes/functions.php,
## includes/functions_post.php,
## langugage/lang_english/lang_main.php,
## langugage/lang_english/lang_admin.php,
## templates/-/viewtopic_body.tpl,
## templates/-/admin/forum_edit_body.tpl
## : 1
##
##
## : http://opensource.org/licenses/gpl-license.php GNU General Public License v2
##############################################################
##
## backup , .
##
## thanks . ? >>>
## .: "Allow to Thank posts:" /.
##
##############################################################
## :
## - You can edit a variable to choose auth_type default is auth_read.
## - It uses it own date format to chage the format, edit $timeformat value to another one.
## - This MOD needs to be enabled on a per forum basis.
##
##############################################################
## :
## 2005-02-25 - Version 0.0.1
## - First Release
##
## 2005-02-25 - Version 0.0.2
## - Fixed bug wich allowed guests to thank.
##
## 2005-02-26 - Version 1.0.0
## - Version 1.0.0 for the Mod Database.
##
## 2005-03-01 - Version 1.0.1
## - Fixed all said by the Mod Team on PhpBB.com.
## - Checked to work with PhpBB version 2.0.13.
##
## 2005-03-04 - Version 1.0.1
## - I was told about some errors in html, they are Fixed.
## - I was given a better image By Dude, Thanks Dude.
## - No version change cause no bugfixes have been done, just replaced a <tr></tr> to </tr><tr>.
##
## 2005-03-04 - Version 1.0.2
## - I got told about an error in viewtopic with the table, Fixed.
## - SQL fixed.
##
## 2005-03-06 - Version 1.0.3
## - Posible SQL injection fixed.
## - SQL fixed.
##
## 2005-03-12 - Version 1.0.4
## - Query Optimization in viewtopic.php
##
## 2005-04-08 - Version 1.1.0
## - Now it only appears in first page only.
## - Added the use of constants.
##
## 2005-04-24 - Version 1.1.1
## - XHTML compliant.
##
## 2005-06-06 - Version 1.1.2
## - Added: Delete thanks entries when a post is deleted.
##
## 2005-06-22 - Version 1.1.3
## - Added: Meta Redirection after thanking post.
## - Added: CSS hiding for complete thanks list.
##
## 2005-06-26 - Version 1.1.4
## - Fix some stuff with the mod template.
##
## 2005-07-07 - Version 1.1.5
## - Improved the display/hide method. (Thanks Stoebi)
##
## 2005-08-06 - Version 1.1.6
## - Fixed bug in modcp.php.
## - Now you cannot thank yourself.
## - Fixed grammar error on posting.php.
## - Commented some partial lines in FINDs to help people finding them.
##
## 2005-10-30 - Version 1.1.7
## - Allow to thank locked topics.
##
## 2005-12-06 - Version 1.1.8
## - PhpBB Mod Template fixes.
##
##############################################################
## BACKUP .
##############################################################
##
#
#-----[ ]------------------------------------------
#
thanks.gif templates/-/images/lang_english/thanks.gif
#
#-----[ SQL ]------------------------------------------
#
CREATE TABLE `phpbb_thanks` (
`topic_id` MEDIUMINT(8) NOT NULL,
`user_id` MEDIUMINT(8) NOT NULL,
`thanks_time` INT(11) NOT NULL
);

ALTER TABLE `phpbb_forums` ADD `forum_thank` TINYINT(1) DEFAULT '0' NOT NULL;

#
#-----[ ]------------------------------------------
#
admin/admin_forums.php

#
#-----[ ]------------------------------------------
#
$forumstatus = $row['forum_status'];

#
#-----[ ]------------------------------------------
#
$forumthank = $row['forum_thank'];

#
#-----[ ]------------------------------------------
#
$forumstatus = FORUM_UNLOCKED;

#
#-----[ ]------------------------------------------
#
$forumthank = FORUM_UNTHANKABLE;

#
#-----[ ]------------------------------------------
#
$statuslist .= "<option value=\"" . FORUM_LOCKED . "\" $forumlocked>" . $lang['Status_locked'] . "</option>\n";

#
#-----[ ]------------------------------------------
#
// Begin Thank Mod
$thank_yes = ($forumthank) ? 'checked="checked"' : '';
$thank_no = (!$forumthank) ? 'checked="checked"' : '';
// End Thank Mod

#
#-----[ ]------------------------------------------
#
'S_STATUS_LIST' => $statuslist,

#
#-----[ ]------------------------------------------
#
"THANK_ENABLE" => $thank_yes,
"THANK_DISABLE" => $thank_no,

#
#-----[ ]------------------------------------------
#
'L_FORUM_STATUS' => $lang['Forum_status'],

#
#-----[ ]------------------------------------------
#
'L_FORUM_THANK' => $lang['use_thank'],
'L_YES' => $lang['Yes'],
'L_NO' => $lang['No'],

#
#-----[ ]------------------------------------------
# , .
#
$sql = "INSERT INTO " . FORUMS_TABLE . "

#
#-----[ ]------------------------------------------
#
" . $field_sql . "

#
#-----[ ]------------------------------------------
#
, forum_thank

#
#-----[ ]------------------------------------------
# , .
#
VALUES ('" . $next_id . "', '" . str_replace("\'", "''",

#
#-----[ ]------------------------------------------
#
$value_sql . "

#
#-----[ ]------------------------------------------
#
, " . intval($HTTP_POST_VARS['forumthank']) . "

#
#-----[ FIND ]---------------------------------
# This may be a partial find and not the whole line.
$sql = "UPDATE " . FORUMS_TABLE . "
SET forum_name

#
#-----[ ]-------------------------
#
" . intval($HTTP_POST_VARS['prune_enable']) . "

#
#-----[ ]---------------------------------
#
, forum_thank = " . intval($HTTP_POST_VARS['forumthank']) . "

#
#-----[ ]------------------------------------------
#
modcp.php

#
#-----[ ]------------------------------------------
#
$sql = "DELETE
FROM " . TOPICS_TABLE . "
WHERE topic_id IN ($topic_id_sql)
OR topic_moved_id IN ($topic_id_sql)";
if ( !$db->sql_query($sql, BEGIN_TRANSACTION) )
{
message_die(GENERAL_ERROR, 'Could not delete topics', '', __LINE__, __FILE__, $sql);
}

#
#-----[ ]------------------------------------------
#
$sql = "DELETE FROM " . THANKS_TABLE . "
WHERE topic_id IN ($topic_id_sql)";
if ( !$db->sql_query($sql, BEGIN_TRANSACTION) )
{
message_die(GENERAL_ERROR, 'Error in deleting Thanks post Information', '', __LINE__, __FILE__, $sql);
}

#
#-----[ ]------------------------------------------
#
viewtopic.php

#
#-----[ ]---------------------------------
#
$forum_id = intval($forum_topic_data['forum_id']);

#
#-----[ ]---------------------------------
#
// Begin Thanks Mod

// Check if the Thanks feature is active for this forum
$sql = "SELECT `forum_thank`
FROM " . FORUMS_TABLE . "
WHERE forum_id =$forum_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not obtain forum information", '', __LINE__, __FILE__, $sql);
}
if ( !($forum_thank_result = $db->sql_fetchrow($result)) )
{
message_die(GENERAL_MESSAGE, $lang['thank_no_exist']);
}
// Setting if feature is active or not

$show_thanks = ($forum_thank_result['forum_thank'] == FORUM_THANKABLE) ? FORUM_THANKABLE : FORUM_UNTHANKABLE;

// End Thanks Mod

#
#-----[ ]---------------------------------
#
$reply_topic_url = append_sid("posting.$phpEx?mode=reply&" . POST_TOPIC_URL . "=$topic_id");

#
#-----[ ]---------------------------------
#
// Begin Thanks Mod
$thank_topic_url = append_sid("posting.$phpEx?mode=thank&" . POST_TOPIC_URL . "=$topic_id");
// End Thanks Mod

#
#-----[ ]---------------------------------
#
$post_img = ( $forum_topic_data['forum_status'] == FORUM_LOCKED ) ? $images['post_locked'] : $images['post_new'];
$post_alt = ( $forum_topic_data['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked'] : $lang['Post_new_topic'];

#
#-----[ ]---------------------------------
#
// Begin Thanks Mod
$thank_img = $images['thanks'];
$thank_alt = $lang['thanks_alt'];
// End Thanks Mod

#
#-----[ ]---------------------------------
#
# : $pagination = ( $highlight != '' ) ? generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&postdays=$post_days&postorder=$post_order&highlight=$highlight", $total_replies, $board_config['posts_per_page'], $start) : generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&postdays=$post_days&postorder=$post_order", $total_replies, $board_config['posts_per_page'], $start);
#


$pagination =

#
#-----[ ]---------------------------------
#
$current_page = get_page($total_replies, $board_config['posts_per_page'], $start);

#
#-----[ ]---------------------------------
#
//
// Update the topic view counter
//
$sql = "UPDATE " . TOPICS_TABLE . "
SET topic_views = topic_views + 1
WHERE topic_id = $topic_id";
if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Could not update topic views.", '', __LINE__, __FILE__, $sql);
}
#
#-----[ ]---------------------------------
#
// Begin Thanks Mod
//
// Get topic thanks
//
if ($show_thanks == FORUM_THANKABLE)
{
// Select Format for the date
$timeformat = "d-m, G:i";

$sql = "SELECT u.user_id, u.username, 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();
$thanksrow = $db->sql_fetchrowset($result);

for($i = 0; $i < $total_thank; $i++)
{
$topic_thanks = $db->sql_fetchrow($result);
$thanker_id[$i] = $thanksrow[$i]['user_id'];
$thanker_name[$i] = $thanksrow[$i]['username'];
$thanks_date[$i] = $thanksrow[$i]['thanks_time'];

// Get thanks date
$thanks_date[$i] = create_date($timeformat, $thanks_date[$i], $board_config['board_timezone']);

// Make thanker profile link
$thanker_profile[$i] = append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$thanker_id[$i]");
$thanks .= '<a href="' .$thanker_profile[$i] . '">' . $thanker_name[$i] . '</a>(' . $thanks_date[$i] . '), ';

if ($userdata['user_id'] == $thanksrow[$i]['user_id'])
{
$thanked = TRUE;
}
}

$sql = "SELECT u.topic_poster, t.user_id, t.username
FROM " . TOPICS_TABLE . " u, " . USERS_TABLE . " t
WHERE topic_id = $topic_id
AND u.topic_poster = t.user_id";

if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not obtain user information", '', __LINE__, __FILE__, $sql);
}

if( !($autor = $db->sql_fetchrowset($result)) )
{
message_die(GENERAL_ERROR, "Could not obtain user information", '', __LINE__, __FILE__, $sql);
}

$autor_name = $autor[0]['username'];
$thanks .= "".$lang['thanks_to']." $autor_name ".$lang['thanks_end']."";

// Create button switch
if ($userdata['user_id'] != $autor['0']['user_id'] && !$thanked)
{
$template->assign_block_vars('thanks_button', array(
'THANK_IMG' => $thank_img,
'U_THANK_TOPIC' => $thank_topic_url,
'L_THANK_TOPIC' => $thank_alt
));
}

}
// End Thanks Mod

#
#-----[ ]---------------------------------
#
'U_POST_ID' => $postrow[$i]['post_id'])
);

#
#-----[ ]---------------------------------
#
// Begin Thanks Mod
if( ($show_thanks == FORUM_THANKABLE) && ($i == 0) && ($current_page == 1) && ($total_thank > 0))
{
$template->assign_block_vars('postrow.thanks', array(
'THANKFUL' => $lang['thankful'],
'THANKED' => $lang['thanked'],
'HIDE' => $lang['hide'],
'THANKS_TOTAL' => $total_thank,
'THANKS' => $thanks
)
);

}
// End Thanks Mod

#
#-----[ ]---------------------------------
#
posting.php

#
#-----[ ]---------------------------------
#
case 'topicreview':
$is_auth_type = 'auth_read';
break;

#
#-----[ ]---------------------------------
#
case 'thank':
$is_auth_type = 'auth_read';
break;

#
#-----[ ]---------------------------------
#
case 'reply':
case 'vote':

#-----[ ]---------------------------------
case 'thank':

#
#-----[ ]---------------------------------
#
else if ( $mode != 'newtopic' && $post_info['topic_status'] == TOPIC_LOCKED && !$is_auth['auth_mod'])

#
#-----[ ]---------------------------------
#
$mode != 'newtopic'

#
#-----[ ]---------------------------------
#
&& $mode != 'thank'

#
#-----[ ]---------------------------------
#
case 'reply':
case 'topicreview':

#
#-----[ ]---------------------------------
#
case 'thank':

#
#-----[ ]---------------------------------
#
else if ( $mode == 'vote' )
{

#
#-----[ ]---------------------------------
#
else if ( $mode == 'thank' )
{
$topic_id = intval($HTTP_GET_VARS[POST_TOPIC_URL]);
if ( !($userdata['session_logged_in']) )
{
$message = $lang['thanks_not_logged'];
$message .= '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . '">', '</a>');
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
AND topic_poster = $userid";
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 = $lang['t_starter'];
$message .= '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . '">', '</a>');
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 if he/she hasn't
$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'];
}
else
{
$message = $lang['thanked_before'];
}

$template->assign_vars(array(
'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . '">')
);

$message .= '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . '">', '</a>');

message_die(GENERAL_MESSAGE, $message);
}

#
#-----[ ]---------------------------------
#
includes/constants.php

#
#-----[ ]---------------------------------
#
define('FORUM_UNLOCKED', 0);
define('FORUM_LOCKED', 1);

#
#-----[ ]---------------------------------
#

// Forum Thanks state
define('FORUM_UNTHANKABLE', 0);
define('FORUM_THANKABLE', 1);

#
#-----[ ]---------------------------------
#
define('SMILIES_TABLE', $table_prefix.'smilies');

#
#-----[ ]---------------------------------
#
define('THANKS_TABLE', $table_prefix.'thanks');

#
#-----[ ]---------------------------------
#
includes/functions.php

#
#-----[ ]---------------------------------
#
function generate_pagination

#
#-----[ ]---------------------------------
#
function get_page($num_items, $per_page, $start_item)
{

$total_pages = ceil($num_items/$per_page);

if ( $total_pages == 1 )
{
return '1';
exit;
}

$on_page = floor($start_item / $per_page) + 1;
$page_string = '';

for($i = 0; $i < $total_pages + 1; $i++)
{
if( $i == $on_page )
{
$page_string = $i;
}

}
return $page_string;
}

#
#-----[ ]---------------------------------
#
includes/functions_post.php

#
#-----[ ]---------------------------------
#
$sql = "DELETE FROM " . TOPICS_TABLE . "
WHERE topic_id = $topic_id
OR topic_moved_id = $topic_id";
if (!$db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql);
}

#
#-----[ ]---------------------------------
#

$sql = "DELETE FROM " . THANKS_TABLE . "
WHERE topic_id = $topic_id";
if (!$db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Error in deleting Thanks post Information', '', __LINE__, __FILE__, $sql);
}

#
#-----[ ]------------------------------------------
#
language/lang_english/lang_admin.php

#
#-----[ ]---------------------------------
#
?>

#
#-----[ ]------------------------------------------
#
// Begin Thanks Mod
$lang['use_thank'] = 'Allow to Thank posts';
// End Thanks Mod

#
#-----[ ]------------------------------------------
#
language/lang_english/lang_main.php

#
#-----[ ]---------------------------------
#
?>

#
#-----[ ]------------------------------------------
#
// Begin Thanks Mod
$lang['thankful'] = 'Thankful People';
$lang['thanks_to'] = 'Thanks';
$lang['thanks_end'] = 'for his/her post';
$lang['thanks_alt'] = 'Thank Post';
$lang['thanked_before'] = 'You have already thanked this topic';
$lang['thanks_add'] = 'Your thanks has been given';
$lang['thanks_not_logged'] = 'You need to log in to thank someone\'s post';
$lang['thanked'] = 'user(s) is/are thankful for this post.';
$lang['hide'] = 'Hide';
$lang['t_starter'] = 'You cannot thank yourself';
$lang['thank_no_exist'] = 'Forum thank information doesn\'t exists';
// End Thanks Mod

#
#-----[ ]---------------------------------
#
templates/-/-.cfg

#
#-----[ ]---------------------------------
#
$images['reply_locked'] = "$current_template_images/{LANG}/reply-locked.gif";

#
#-----[ ]---------------------------------
#
$images['thanks'] = "$current_template_images/{LANG}/thanks.gif";

#
#-----[ ]---------------------------------
#
templates/-/admin/forum_edit_body.tpl

#
#-----[ ]---------------------------------
#
<tr>
<td class="row1">{L_FORUM_STATUS}</td>
<td class="row2"><select name="forumstatus">{S_STATUS_LIST}</select></td>
</tr>

#
#-----[ ]---------------------------------
#
<tr>
<td class="row1">{L_FORUM_THANK}</td>
<td class="row2"><INPUT TYPE="radio" NAME="forumthank" value="1" {THANK_ENABLE} />{L_YES} <INPUT TYPE="radio" NAME="forumthank" value="0" {THANK_DISABLE} />{L_NO}</td>
</tr>

#
#-----[ ]---------------------------------
#
templates/-/viewtopic_body.tpl

#
#-----[ ]---------------------------------
# - , ..
#
# , .
#
<a href="{U_POST_NEW_TOPIC}">

#
#-----[ ]---------------------------------
#
</a></span></td>

#
#-----[ ]------------------------------------------
#
</a>
#
#-----[ ]---------------------------------
#
<!-- BEGIN thanks_button -->
<a href="{thanks_button.U_THANK_TOPIC}"><img src="{thanks_button.THANK_IMG}" border="0" alt="{thanks_button.L_THANK_TOPIC}" align="middle" /></a>
<!-- END thanks_button -->
</span></td>

#
#-----[ ]---------------------------------
#
<!-- END postrow -->

#
#-----[ ]---------------------------------
#
<!-- BEGIN thanks -->
<tr>
<td colspan="2" class="row2">
<table class="forumline" cellspacing="1" cellpadding="3" border="0" width="100%">
<tr>
<th class="thLeft">{postrow.thanks.THANKFUL}</th>
</tr>
<tr>
<td class="row2" valign="top" align="left">
<span id="hide_thank" style="display: block;" class="gensmall">
<a href="javascript: void(0);" onclick="document.all.show_thank.style.display = 'block';document.all.hide_thank.style.display = 'none'">{postrow.thanks.THANKS_TOTAL}</a> {postrow.thanks.THANKED}
</span>
<span id="show_thank" style="display: none;" class="gensmall">
{postrow.thanks.THANKS}
<br /><br /><div align="right"><a href="javascript: void(0);" onClick="document.all.show_thank.style.display = 'none';document.all.hide_thank.style.display = 'block'">[ {postrow.thanks.HIDE} ]</a></div>
</span>
</td>
</tr>
</table>
</td>
</tr>
<!-- END thanks -->

#
#-----[ ]---------------------------------
# , .
#
<a href="{U_POST_NEW_TOPIC}">

#
#-----[ ]---------------------------------
#
</a></span></td>

#
#-----[ ]------------------------------------------
#
</a>
#
#-----[ ]---------------------------------
#
<!-- BEGIN thanks_button -->
<a href="{thanks_button.U_THANK_TOPIC}"><img src="{thanks_button.THANK_IMG}" border="0" alt="{thanks_button.L_THANK_TOPIC}" align="middle" /></a>
<!-- END thanks_button -->
</span></td>

#
#-----[ / ]------------------------------------------
#
# .


. , " " "". .

#
#-----[ ]---------------------------------
#
templates/-/viewtopic_body.tpl

#
#-----[ ]---------------------------------
#
#
<td align="left" valign="bottom" nowrap="nowrap"><span class="nav"><a href="{U_POST_NEW_TOPIC}"><img src="{POST_IMG}" border="0" alt="{L_POST_NEW_TOPIC}" align="middle" /></a><a href="{U_POST_REPLY_TOPIC}"><img src="{REPLY_IMG}" border="0" alt="{L_POST_REPLY_TOPIC}" align="middle" /></a></span></td>

#
#-----[ ]---------------------------------
#

<td align="left" valign="bottom" nowrap="nowrap"><span class="nav"><a href="{U_POST_NEW_TOPIC}"><img src="{POST_IMG}" border="0" alt="{L_POST_NEW_TOPIC}" align="middle" /></a><a href="{U_POST_REPLY_TOPIC}"><img src="{REPLY_IMG}" border="0" alt="{L_POST_REPLY_TOPIC}" align="middle" /></a></span>
<!-- BEGIN thanks_button -->
<a href="{thanks_button.U_THANK_TOPIC}"><img src="{thanks_button.THANK_IMG}" border="0" alt="{thanks_button.L_THANK_TOPIC}" align="middle" /></a>
<!-- END thanks_button -->


* .

, . :)











/ /
: hah
20:35 12-09-2009
?
1