karma mod in nuke have a littel problem after modification

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   karma mod in nuke have a littel problem after modification
oferelijah
CZ Newbie
oferelijah has been a member for over 17 year's 17 Year Member
israel.gif
Occupation: IT
Gender: Male
Website:
Status: Offline
Joined: Mar 04, 2007
0.00 posts per day
Posts: 3
Points: 0
   
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:
##############################################################
## 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><b><span>{EMAIL_IMG}</span></b></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}<br>

#
#-----[ 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><br>

#**************************************************************************
#                               
# 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:

<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'] . '<br><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'] . '<br><a> ' . $lang['Return_To_Topic'] . ' </a>', __LINE__, __FILE__, $sql);
            }
      }
   else
      {
         message_die(CRITICAL_MESSAGE, $lang['Too_Soon'] . '<br><a> ' . $lang['Return_To_Topic'] . ' </a>');
      }
}
}
?>


can someone?
the topic id is ok.
cuse after the voting to some user i get [ Register or login to view links on this board. ]

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:
   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:
   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]


Back to top Reply with quote
#2   re: karma mod in nuke have a littel problem after modificati
oferelijah
CZ Newbie
oferelijah has been a member for over 17 year's 17 Year Member
israel.gif
Occupation: IT
Gender: Male
Website:
Status: Offline
Joined: Mar 04, 2007
0.00 posts per day
Posts: 3
Points: 0
   
it seems that my problem is here:

         //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'] . '<br><a> ' . $lang['Return_To_Topic'] . ' </a>', __LINE__, __FILE__, $sql);
            }
      }
   else
      {
         message_die(CRITICAL_MESSAGE, $lang['Too_Soon'] . '<br><a> ' . $lang['Return_To_Topic'] . ' </a>');
      }
}
}

because when i press the + or - for karma points it add the point' that meens hes going to the karma.PHP
but he dont enter to that code i Quoted.
any one knows what goes on here?
mybe i have to incloud some files ?
icon_rolleyes.gif


Back to top Reply with quote
#3   
Telli
Site Admin
Occupation: Self Employed
Age: 46
Gender: Male
Fav. Sports Team: Detroit Red Wings
Website:
Status: Offline
Joined: May 26, 2003
1.03 posts per day
Posts: 8089
Points: 494,430
   
The location is wrong. Its still set up for phpBB change the URL's from:


viewtopic.php?t='.$topic_id



modules.php?name=Forums&file=viewtopic&t='.$topic_id




_________________
The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he, who in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee. Ezekiel 25:17
Back to top Reply with quote
#4   re: karma mod in nuke have a littel problem after modificati
oferelijah
CZ Newbie
oferelijah has been a member for over 17 year's 17 Year Member
israel.gif
Occupation: IT
Gender: Male
Website:
Status: Offline
Joined: Mar 04, 2007
0.00 posts per day
Posts: 3
Points: 0
   
10X
i will try it



Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum