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();
// Find out when voter last changed someone's karma
$sql = 'SELECT karma_time, user_id FROM ' . USERS_TABLE . " WHERE user_id = {$user->data['user_id']}";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$voter_id = $row['user_id'];
$last_change = $row['karma_time'];
// Get variables
$topic_id = request_var('t', '');
$user = request_var('u', '');
$vote = request_var('x', '');
$sql = 'SELECT karma FROM ' . USERS_TABLE . " WHERE user_id = $user";
$result = $db->sql_query($sql);
$karma = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
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;
// Stop voter from changing karma during a delay period, fixed in the "phpbb3_config" table's "karma_time_limit" row
if ($time_elapsed >= 60 * $config['karma_time_limit'])
{
if ($vote == 'applaud')
{
if ($karma < 8)
{
$sql = 'UPDATE ' . USERS_TABLE . " SET karma = karma + 1 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>'));
}
}
}
?>
Code: Select all
if (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_'))
{
some code about unlimited changes, but they also affect karma_time
}
else if [insert code about post count, something like "$post_count > 10" if you do an SQL query to call that up directly]
{
some code about changes limited in time
}
else
{
some error about not being able to change karma
}
AH no I had a post count check on the actual viewtopic.php page.iGuru wrote:Thanks, I fixed the post count.
I edited my code up again
Now I mainly need:
Timer (not sure how to put that in my code)
Can't karma yourself (matching user id's?)
Change plus and minus image to become transparent
Add controls in the ACP
and more as I think of them.
Check my codeiGuru wrote:Timer (not sure how to put that in my code)
Can't karma yourself (matching user id's?)
Ah, I setup my mySQL database connection manually, ie. you enter in username, password and database yourself.iGuru wrote:AH no I had a post count check on the actual viewtopic.php page.iGuru wrote:Thanks, I fixed the post count.
I edited my code up again
Now I mainly need:
Timer (not sure how to put that in my code)
Can't karma yourself (matching user id's?)
Change plus and minus image to become transparent
Add controls in the ACP
and more as I think of them.
Ah - I'm not good at thisiGuru wrote:Ah, I setup my mySQL database connection manually, ie. you enter in username, password and database yourself.iGuru wrote:AH no I had a post count check on the actual viewtopic.php page.iGuru wrote:Thanks, I fixed the post count.
I edited my code up again
Now I mainly need:
Timer (not sure how to put that in my code)
Can't karma yourself (matching user id's?)
Change plus and minus image to become transparent
Add controls in the ACP
and more as I think of them.
And I didn't put anything in like define_inphpbb etc...iGuru wrote:Ah - I'm not good at thisiGuru wrote:Ah, I setup my mySQL database connection manually, ie. you enter in username, password and database yourself.iGuru wrote:AH no I had a post count check on the actual viewtopic.php page.iGuru wrote:Thanks, I fixed the post count.
I edited my code up again
Now I mainly need:
Timer (not sure how to put that in my code)
Can't karma yourself (matching user id's?)
Change plus and minus image to become transparent
Add controls in the ACP
and more as I think of them.
How would I add a timer into my code (i have the user being karmaed but not the logged in user)
Ah, my code is so basic compared to yours - I'm only 13 years old...iGuru wrote:And I didn't put anything in like define_inphpbb etc...iGuru wrote:Ah - I'm not good at thisiGuru wrote:Ah, I setup my mySQL database connection manually, ie. you enter in username, password and database yourself.iGuru wrote:AH no I had a post count check on the actual viewtopic.php page.iGuru wrote:Thanks, I fixed the post count.
I edited my code up again
Now I mainly need:
Timer (not sure how to put that in my code)
Can't karma yourself (matching user id's?)
Change plus and minus image to become transparent
Add controls in the ACP
and more as I think of them.
How would I add a timer into my code (i have the user being karmaed but not the logged in user)
I don't have anything in place yet for time between karmas, i would like it to be a one day wait though.PACraddock wrote:Create a second "karma_time" row ("karma_time_vote", or something like it) that applies to the voter instead of the "user getting karma". Then call it up as something like "$voter_time".
In my old forum I had a Karma mod that was extremly popular. It really made the quality of the posts better since people were happy to receive karma points.
This is what it should be able to do:
Give karma point togheter with comment (to withdraw points is not needed since it is so negative)
There should be a statistic page in the profile where you can view users karma points and comments along with info about in what thread/post he got the karma
Maybe a statistics page with top 20 karma users
Currently, you can remove the negative karma button. Comments are currently not used but karma points show on each user's profile. A statistics page with the top 20 karma users will be implemented at one of the later stages.azzurri wrote:I wrote this in a request thread...
In my old forum I had a Karma mod that was extremly popular. It really made the quality of the posts better since people were happy to receive karma points.
This is what it should be able to do:
Give karma point togheter with comment (to withdraw points is not needed since it is so negative)
There should be a statistic page in the profile where you can view users karma points and comments along with info about in what thread/post he got the karma
Maybe a statistics page with top 20 karma users