(rewriting the mod/hack?
I think it's now re-written completely save for the "hours_past" part, because I'm not yet sure if I've done it right)Problem is, I'm getting the blank screen, yet again.

- Code: Select all
<?php
define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
// Some extra script settings. You can modify them
// How long do we have to wait before giving karma points again?
$hours_past = 1; // THIS PART WILL NO LONGER BE HERE!
$sql = 'SELECT karma_time FROM ' . USERS_TABLE . " WHERE user_id = '" . $user->data['user_id'] . "'"; // finds out when voter last changed someone's karma
$result = $db->sql_query($sql);
$last_change = $db->sql_fetchfield('karma_time');
$db->sql_freeresult($result);
$sql = 'SELECT user_id FROM ' . USERS_TABLE . " WHERE user_id = '" . $user->data['user_id'] . "'"; // this code will enable us to avoid 'self-karma'
$result = $db->sql_query($sql);
$voter_id = $db->sql_fetchfield('user_id');
$db->sql_freeresult($result);
// Get variables
$topic_id = request_var('t', '');
$user = request_var('u', '');
$vote = request_var('x', '');
if ($voter_id == $user)
{
trigger_error($user->lang['NO_SELF_KARMA'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=$topic_id") . '">', '</a>'));
}
else
{
if (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_'))
{
trigger_error($user->lang['NO_USER_KARMA'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=$topic_id") . '">', '</a>'));
}
else
{
$time = time();
$time_elapsed = $time - $last change;
if ($time_elapsed >= 0 * $config['karma_time_limit']) // stops voter from changing karma during a delay period [fixed in the "phpbb3_config" table's "karma_time_limit" field]
{
if ($vote == 'applaud')
{
$sql = 'UPDATE ' . USERS_TABLE . " SET karma = karma + 1 WHERE user_id = $user";
$db->sql_query($sql);
// stop karma from going beyond the maximum number set
if ($karma >= 8)
{
$sql = 'UPDATE ' . USERS_TABLE . " SET karma = 8 WHERE user_id = $user";
$db->sql_query($sql);
}
}
else
{
$sql = 'UPDATE ' . USERS_TABLE . " SET karma = karma - 1 WHERE user_id = $user";
$db->sql_query($sql);
// Add bans on reaching -8 karma
if ($karma <= -8)
{
$sql = 'INSERT INTO ' . BANLIST_TABLE . " VALUES (0, $user, '', NULL)";
$db->sql_query($sql);
}
}
// Update the database with the current time() for the voter
$sql = 'UPDATE ' . USERS_TABLE . " SET karma_time = '$time' WHERE user_id = '$voter_id' ";
$db->sql_query($sql);
$redirect = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=$topic_id");
}
else
{
trigger_error($user->lang['TOO_SOON'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t=$topic_id") . '">', '</a>'));
}
}
}
?>
(note that it's [almost] entirely re-written compared to the original phpBB2 version
)






