hi all,
i installed the karma mod in my nuke
after some modification i made to fit it to nuke
its work just fine
but i have a littel problem that the page after i vote didnt go back to the topic before the voting
here is the code of the mode:
Code:
##############################################################
## MOD Title: Advanced Karma Mod
## MOD Author: Nome <nome>
## MOD Original Author: countach44 <root>
## MOD Description: This will add the ability to give users karma points
## Stacks karma points in two different groups
## so that users both have + and - shown
## Has an hour based wait option (UNIX time based, no Windows here)
## MOD Version: 1.0.1
##
## Installation Level: easy
## Installation Time: 10 Minutes
## Files To Edit: 6
## viewtopic.php
## includes/usercp_viewprofile.php
## templates/subSilver/template.cfg
## templates/subSilver/profile_view_body.tpl
## templates/subSilver/viewtopic_body.tpl
## language/lang_english/lang_main.php
## Included Files: karma.php, icon_applaud.gif, icon_smite.gif,
## mysql_schema.sql (for not installed forums only!)
##############################################################
## Author Notes: Thanks to countach44 for starting the mode
## I've made a few changes to his file, so that the
## MOD looks more attractive. At least to me ;)
##
##############################################################
## This MOD is released under the GPL License.
## Intellectual Property is retained by the MOD Author(s) listed above
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ ALTER ]------------------------------------------
#
ALTER TABLE `phpbb_users` ADD `karma_plus` MEDIUMINT DEFAULT '0' NOT NULL ;
ALTER TABLE `phpbb_users` ADD `karma_minus` MEDIUMINT DEFAULT '0' NOT NULL ;
ALTER TABLE `phpbb_users` ADD `karma_time` BIGINT DEFAULT '0' NOT NULL ;
#
# NOTE: 'phpbb_' is our $table_prefix
#
#
#-----[ OPEN ]------------------------------------------
#
includes/usercp_viewprofile.php
#
#-----[ FIND ]------------------------------------------
#
//
// Calculate the number of days this user has been a member ($memberdays)
// Then calculate their posts per day
//
#
#-----[ BEFORE, ADD ]------------------------------------
#
//Fetch karma
$sql = "select karma_plus from " . USERS_TABLE . " where username='$profiledata[username]'";
$result = $db->sql_query($sql);
$array = mysql_fetch_array($result);
$karma_plus = $array[0];
$sql = "select karma_minus from " . USERS_TABLE . " where username='$profiledata[username]'";
$result = $db->sql_query($sql);
$array = mysql_fetch_array($result);
$karma_minus = $array[0];
#
#-----[ FIND ]------------------------------------------
#
'JOINED' => create_date($lang['DATE_FORMAT'], $profiledata['user_regdate'], $board_config['board_timezone']),
#
#-----[ AFTER, ADD ]------------------------------------
#
'KARMA_PLUS' => $karma_plus,
'KARMA_MINUS' => $karma_minus,
#
#-----[ FIND ]------------------------------------------
#
'L_EMAIL' => $lang['Email'],
#
#-----[ AFTER, ADD ]------------------------------------
#
'L_KARMA' => $lang['Karma'],
#
#-----[ OPEN ]------------------------------------------
#
viewtopic.php
#
#-----[ FIND ]------------------------------------------
#
'L_AUTHOR' => $lang['Author'],
#
#-----[ AFTER, ADD ]------------------------------------
#
'L_KARMA' => $lang['Karma'],
#
#-----[ FIND ]------------------------------------------
#
//
// Again this will be handled by the templating
// code at some point
#
#-----[ BEFORE, ADD ]------------------------------------
# It's the only way I could get it working, not very neat though :(
//Fetch karma
$sql = "select karma_plus from " . USERS_TABLE . " where username='$poster'";
$result = $db->sql_query($sql);
$array = mysql_fetch_array($result);
$karma_plus = $array[0];
$sql = "select karma_minus from " . USERS_TABLE . " where username='$poster'";
$result = $db->sql_query($sql);
$array = mysql_fetch_array($result);
$karma_minus = $array[0];
$applaud_img = '';
$applaud_alt = '';
$applaud_url = '';
$smite_img = '';
$smite_alt = '';
$smite_url = '';
if ( ( $userdata['session_logged_in'] ) && ( $userdata['user_id'] != $poster_id ) )
{
$applaud_alt = $lang['Applaud'];
$applaud_url = append_sid("karma.$phpEx?" . POST_TOPIC_URL . '=' . $topic_id . '&' . POST_USERS_URL . '=' . $poster_id . '&x=applaud');
$applaud_img = '<img>';
$smite_alt = $lang['Smite'];
$smite_url = append_sid("karma.$phpEx?" . POST_TOPIC_URL . '=' . $topic_id . '&' . POST_USERS_URL . '=' . $poster_id . '&x=smite');
$smite_img = '<img>';
}
#
#-----[ FIND ]------------------------------------------
#
'POSTER_NAME' => $poster,
#
#-----[ AFTER, ADD ]------------------------------------
#
'POSTER_ID' => $poster_id,
#
#-----[ FIND ]------------------------------------------
#
'POSTER_JOINED' => $poster_joined,
#
#-----[ AFTER, ADD ]------------------------------------
#
'POSTER_KARMA_PLUS' => $karma_plus,
'POSTER_KARMA_MINUS' => $karma_minus,
#
#-----[ FIND ]------------------------------------------
#
'MINI_POST_IMG' => $mini_post_img,
#
#-----[ AFTER, ADD ]------------------------------------
#
'APPLAUD_IMG' => $applaud_img,
'SMITE_IMG' => $smite_img,
#
#-----[ FIND ]------------------------------------------
#
'L_MINI_POST_ALT' => $mini_post_alt,
#
#-----[ AFTER, ADD ]------------------------------------
#
'L_APPLAUD_ALT' => $applaud_alt,
'L_SMITE_ALT' => $smite_alt,
#
#-----[ FIND ]------------------------------------------
#
'U_MINI_POST' => $mini_post_url,
#
#-----[ AFTER, ADD ]------------------------------------
#
'U_APPLAUD' => $applaud_url,
'U_SMITE' => $smite_url,
#*********************************************************************
#
# NOTE: You will have to apply these changes to all existing templates
# I use SubSilver as an example
#
#*********************************************************************
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/subSilver.cfg
#
#-----[ FIND ]------------------------------------------
#
$images['icon_minipost'] = "$current_template_images/icon_minipost.gif";
#
#-----[ AFTER, ADD ]------------------------------------
#
$images['icon_applaud'] = "$current_template_images/icon_applaud.gif";
$images['icon_smite'] = "$current_template_images/icon_smite.gif";
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/profile_view_body.tpl
#
#-----[ FIND ]------------------------------------------
#
<tr>
<td><span>{L_EMAIL_ADDRESS}:</span></td>
<td><span>{EMAIL_IMG}</span></td>
</tr>
#
#-----[ AFTER, ADD ]------------------------------------
#
<tr>
<td><span>{L_KARMA}:</span></td>
<td><span>+{KARMA_PLUS}/-{KARMA_MINUS}</span></td>
</tr>
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/viewtopic_body.tpl
#
#-----[ FIND ]------------------------------------------
#
{postrow.POSTER_POSTS}
#
#-----[ IN-LINE AFTER, ADD ]---------------------------------------
#
<font>{L_KARMA}: +{postrow.POSTER_KARMA_PLUS}/-{postrow.POSTER_KARMA_MINUS} <a>{postrow.APPLAUD_IMG}</a><a>{postrow.SMITE_IMG}</a></font>
#**************************************************************************
#
# NOTE: You will have to apply these changes to all existing language packs
# I use lang_english as an example
#
#**************************************************************************
#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_main.php
#
#-----[ FIND ]------------------------------------------
#
//
// That's all Folks!
// -------------------------------------------------
#
#-----[ BEFORE, ADD ]------------------------------------
#
$lang['Karma'] = 'Karma';
$lang['Applaud'] = 'Applaud';
$lang['Smite'] = 'Smelt';
$lang['Return_To_Topic'] = 'Return to topic';
$lang['Too_Soon'] = 'You can't change karma yet. Not enough time has passed';
$lang['No_Self_Karma'] = 'You can't change your karma';
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
and here is the karma.php code:
Code:
<php>sql_query($sql);
$array = mysql_fetch_array($result);
$time_old = $array[0];
$sql = "select user_id from " . USERS_TABLE . " where user_id='$userdata[user_id]'";//make sure no one votes for themselves
$result = $db->sql_query($sql);
$array = mysql_fetch_array($result);
$voter_id = $array[0];
if($voter_id == $user)
{
message_die(CRITICAL_MESSAGE, $lang['No_Self_Karma'] . '
<a> ' . $lang['Return_To_Topic'] . ' </a>');
}
else
{
$time = time();
$diff = $time - $time_old;
if($diff >= 3600 * $hours_past || $userdata['user_level'] > 0) //make sure they haven't voted in the last hour or if they're a mod or admin, they can continue
{
if ($x == 'applaud')
{
$sql = "select karma_plus from " . USERS_TABLE . " where user_id='$user'"; //Find the good guy
$result = $db->sql_query($sql);
$array = mysql_fetch_array($result);
$karma = $array[0];
// We only up karma by one
$karma = $karma + 1;
// Here comes the db update
$karma_update = "update " . USERS_TABLE . " set karma_plus ='$karma' where user_id='$user'";
}
else
// If someone tries to fake the x input, that someone will get bad karma ;)
{
$sql = "select karma_minus from " . USERS_TABLE . " where user_id='$user'"; //Find the bad guy
$result = $db->sql_query($sql);
$array = mysql_fetch_array($result);
$karma = $array[0];
// We only up karma by one
$karma = $karma + 1;
// Here comes the db update
$karma_update = "update " . USERS_TABLE . " set karma_minus ='$karma' where user_id='$user'";
}
//update the database with current time() for voter
$time_update = "update " . USERS_TABLE . " set karma_time ='$time' where user_id ='$userdata[user_id]'";
$result = $db->sql_query($karma_update);
$time_result = $db->sql_query($time_update);
if($result&&$time_result) //Both gotta happen...
{
if(!isset($topic_id))
{
header('Location: index.php');
break;
}
else
{
header('Location: viewtopic.php?t='.$topic_id);
}
}
else
{
message_die(GENERAL_ERROR, $lang['Critical_Error'] . '
<a> ' . $lang['Return_To_Topic'] . ' </a>', __LINE__, __FILE__, $sql);
}
}
else
{
message_die(CRITICAL_MESSAGE, $lang['Too_Soon'] . '
<a> ' . $lang['Return_To_Topic'] . ' </a>');
}
}
}
?>
can someone?
the topic id is ok.
cuse after the voting to some user i get
http://www.itpro.org.il/modules.php?...&u=4&x=applaud
if i change file-karma to file=viewtopic it gos back to the topic i want
if i chane the code in the install from:
Code:
if ( ( $userdata['session_logged_in'] ) && ( $userdata['user_id'] != $poster_id ) )
{
$applaud_alt = $lang['Applaud'];
$applaud_url = append_sid("karma.$phpEx?" . POST_TOPIC_URL . '=' . $topic_id . '&' . POST_USERS_URL . '=' . $poster_id . '&x=applaud');
$applaud_img = '<img>';
$smite_alt = $lang['Smite'];
$smite_url = append_sid("karma.$phpEx?" . POST_TOPIC_URL . '=' . $topic_id . '&' . POST_USERS_URL . '=' . $poster_id . '&x=smite');
$smite_img = '<img>';
}
to:
Code:
if ( ( $userdata['session_logged_in'] ) && ( $userdata['user_id'] != $poster_id ) )
{
$applaud_alt = $lang['Applaud'];
$applaud_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . '=' . $topic_id . '&' . POST_USERS_URL . '=' . $poster_id . '&x=applaud');
$applaud_img = '<img>';
$smite_alt = $lang['Smite'];
$smite_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . '=' . $topic_id . '&' . POST_USERS_URL . '=' . $poster_id . '&x=smite');
$smite_img = '<img>';
}
it gose back to the page i want after voting but dont add's point of karma to the user (it dont go to the karma.php file to do the changes in the DB)
i will appreciat any help
p.s.
my site is in hebrew
so if you want me to give u demo user and password and link to login page and forums just say.
regards,
Ofer
[/code]