Just as means of a quick intro, the idea behind this karma mod is that moderators & admin can change user karma, from -8 to +8. I won't start a discussion about the merits of this karma system, in comparison with others (*me winks at HoL*), but basically, it's fine for the use I have for it (i.e. thanking people who have helped me for my plug, ?).
Anyway, you call the karma.php file (karma.php?t= topic ID &u= target user ID &x= applaud/smite ), and this is karma.php:
Spoiler:
- Code: Select all
<?php
/***************************************************************************
* karma.php
* -------------------
* begin : Thursday, Jan 24, 2004
* copyright : (C) Nome
* email : nome@bk.ru
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
define('IN_PHPBB', true);
// PaceNote: I used to have an "include?? common.php", but removed it to see if it solved the problem. It didn't?
// Some extra script settings. You can modify them
// How long do we have to wait before giving karma points again?
$hours_past = 1; // In hours
// Do admins and moders have the permission to give karma points any time they like&
$allow_up = 1; // NOTE THAT 0 = yes, 1 (or above)= no and not otherwize!
// Start session management => PaceNote: taken from ucp.php. Used to be two other lines around it, removed to see if it helped.
$auth->acl($user->data);
$sql = "SELECT karma_time FROM ' . USERS_TABLE . ' WHERE user_id = ' . $user->data['user_id']' "; //get last time user tried a karma vote
$result = $db->sql_query($sql);
$array = mysql_fetch_array($result);
$time_old = $array[0];
$sql = "SELECT user_id FROM ' . USERS_TABLE . ' WHERE user_id = ' . $user->data['user_id']' ";//make sure no one votes for themselves
$result = $db->sql_query($sql);
$array = mysql_fetch_array($result);
$voter_id = $array[0];
// $_GET variables
if ( isset($_GET['t']) ) { $topic_id = $_GET['t']; } else { die("Hacking attempt"); }
if ( isset($_GET['u']) ) { $user = $_GET['u']; } else { die("Hacking attempt"); } // PaceNote: this is the thing I'm most annoyed with? Can I use $user without any worries?
if ( isset($_GET['x']) ) { $x = $_GET['x']; } else { die("Hacking attempt"); }
if($voter_id == $user)
{
message_die(CRITICAL_MESSAGE, $user->lang['No_Self_Karma'] . '<br /><a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id") . '"> ' . $user->lang['Return_To_Topic'] . ' </a>');
}
else
{
if(!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) // PaceNote: i.e., non-mods
{
message_die(CRITICAL_MESSAGE, $user->lang['No_User_Karma'] . '<br /><a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id") . '"> ' . $user->lang['Return_To_Topic'] . ' </a>');
}
else
{
$time = time();
$diff = $time - $time_old;
if($diff >= 3600 * $hours_past) //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 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 = '$karma' WHERE user_id = '$user' ";
}
else
// If someone tries to fake the x input, that someone will get bad karma ;)
{
$sql = "SELECT karma 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;
// Add bans on reaching -8 karma
if ($karma <= -8)
{
$sql = "INSERT INTO phpbb3_banlist VALUES (0, $user, '', NULL)";
$db->sql_query($sql);
}
// Here comes the db update
$karma_update = "UPDATE ' . USERS_TABLE . ' SET karma = '$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 = '$user->data['user_id']' ";
$result = $db->sql_query($karma_update);
$time_result = $db->sql_query($time_update);
if($result&&$time_result) //Both gotta happen...
{
header('Location:' . append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&u=' . $row['user_id']));
$template->assign_vars(array(
'L_SUBJECT' => $user->lang['Karma_Change'])
);
}
else
{
message_die(GENERAL_ERROR, $user->lang['Critical_Error'] . '<br /><a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id") . '"> ' . $user->lang['Return_To_Topic'] . ' </a>', __LINE__, __FILE__, $sql);
}
}
else
{
message_die(CRITICAL_MESSAGE, $user->lang['Too_Soon'] . '<br /><a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id") . '"> ' . $user->lang['Return_To_Topic'] . ' </a>');
}
}
}
?>
What causes this blank page?











(that you figured most of them out on your own)