This repository has been archived on 2024-11-28. You can view files and clone it, but cannot push or open issues or pull requests.
MatritumCantat_Web/www/components/com_simpleboard/sb_karma.php
2012-09-18 20:02:43 +00:00

135 lines
6.2 KiB
PHP

<?php
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
//Modify this to change the minimum time between karma modifications from the same user
$karma_min_seconds = '21600'; // 21600 seconds = 6 hours
?>
<link rel="stylesheet" href="components/com_simpleboard/template/<?php echo $sbConfig['template']; ?>/forum.css" type="text/css" />
<table border=0 cellspacing=0 cellpadding=0 width="100%" align="center">
<tr>
<td align="center">
<p align="center">
<table border="0" width="100%">
<?php include ($sbp.'/searchbox.php');?>
<tr>
<td align="center">
<b><font size="2"><?php echo $board_title;?></font></b>
<?php echo $sbConfig['board_offline'] ? '<br /><font color="red">' ._FORUM_IS_OFFLINE. '</font>' : '&nbsp;' ;?>
</td>
</tr>
</table>
<a href="<?php echo sefRelToAbs('index.php?option=com_simpleboard&amp;Itemid='.$Itemid);?>">
<?php echo $sbIcons['home'] ? '<img src="'.$mls.'/modules/mod_sbicons/'.$sbIcons['home'].'" border=0 alt="'._HOME.'" title="'._HOME.'" />' : _HOME; ?>
</a>
<?php
if ($my_id != 0)
{
?>
<a href="<?php echo sefRelToAbs('index.php?option=com_simpleboard&amp;Itemid='.$Itemid.'&amp;func=userprofile&amp;do=show');?>">
<?php echo $sbIcons['profile'] ? '<img src="'.$mls.'/modules/mod_sbicons/'.$sbIcons['profile'].'" border=0 alt="'._GEN_MYPROFILE.'" title="'._GEN_MYPROFILE.'"/>' : ' | '._GEN_MYPROFILE; ?>
</a>
<?php
}
?>
<a href="<?php echo sefRelToAbs('index.php?option=com_simpleboard&amp;Itemid='.$Itemid.'&amp;func=faq');?>">
<?php echo $sbIcons['help'] ? '<img src="'.$mls.'/modules/mod_sbicons/'.$sbIcons['help'].'" border=0 alt="'._GEN_HELP.'" title="'._GEN_HELP.'"/>' : ' | '._GEN_HELP; ?>
</a>
</form>
</p>
</td>
</tr>
<tr>
<td>
<br>
<center>
<?php
//I hope these are needed :)
$catid=(int)$catid;
$pid=(int)$pid;
//This checks:
// - if the karma function is activated by the admin
// - if a registered user submits the modify request
// - if he specifies an action related to the karma change
// - if he specifies the user that will have the karma modified
if ($sbConfig['showkarma'] && $my->id != "" && $my->id != 0 && $do != '' && $userid != '' )
{
$time = time();
if ($my->id != $userid)
{
// This checkes to see if it's not too soon for a new karma change
if ( ! $is_moderator) {
$database->setQuery('SELECT karma_time FROM #__sb_users WHERE userid='.$my->id.'');
$karma_time_old = $database->loadResult();
$karma_time_diff = $time - $karma_time_old;
}
if($karma_time_diff >= $karma_min_seconds || $is_moderator )
{
if ($do == "increase")
{
$database->setQuery('UPDATE #__sb_users SET karma_time='.$time.' WHERE userid='.$my->id.'');
$database->query();
$database->setQuery('UPDATE #__sb_users SET karma=karma+1 WHERE userid='.$userid.'');
$database->query();
echo _KARMA_INCREASED.'<br /> <a href="'.sefRelToAbs('index.php?option=com_simpleboard&Itemid='.$Itemid.'&func=view&catid='.$catid.'&id='.$pid).'">'._POST_CLICK.'</a>.';
?>
<script language="javascript">
setTimeout("location='<?php echo sefRelToAbs('index.php?option=com_simpleboard&Itemid='.$Itemid.'&func=view&catid='.$catid.'&id='.$pid); ?>'",3500);
</script>
<?php
}
else if ($do == "decrease")
{
$database->setQuery('UPDATE #__sb_users SET karma_time='.$time.' WHERE userid='.$my->id.'');
$database->query();
$database->setQuery('UPDATE #__sb_users SET karma=karma-1 WHERE userid='.$userid.'');
$database->query();
echo _KARMA_DECREASED.'<br /> <a href="'.sefRelToAbs('index.php?option=com_simpleboard&Itemid='.$Itemid.'&func=view&catid='.$catid.'&id='.$pid).'">'._POST_CLICK.'</a>.';
?>
<script language="javascript">
setTimeout("location='<?php echo sefRelToAbs('index.php?option=com_simpleboard&Itemid='.$Itemid.'&func=view&catid='.$catid.'&id='.$pid); ?>'",3500);
</script>
<?php
}
else
{//you got me there... don't know what to $do
echo _USER_ERROR_A;
echo _USER_ERROR_B."<br /><br />";
echo _USER_ERROR_C."<br /><br />"._USER_ERROR_D.": <code>SB001-karma-02NoDO</code><br /><br />";
}
} else echo _KARMA_WAIT.'<br /> '._KARMA_BACK.' <a href="'.sefRelToAbs('index.php?option=com_simpleboard&Itemid='.$Itemid.'&func=view&catid='.$catid.'&id='.$pid).'">'._POST_CLICK.'</a>.';
}
else if ($my->id == $userid) // In case the user tries modifing his own karma by changing the userid from the URL...
{
if ($do == "increase") // Seriously decrease his karma if he tries to increase it
{
$database->setQuery('UPDATE #__sb_users SET karma=karma-10, karma_time='.$time.' WHERE userid='.$my->id.'');
$database->query();
echo _KARMA_SELF_INCREASE.'<br />'._KARMA_BACK.' <a href="'.sefRelToAbs('index.php?option=com_simpleboard&Itemid='.$Itemid.'&func=view&catid='.$catid.'&id='.$pid).'">'._POST_CLICK.'</a>.';
}
if ($do == "decrease") // Stop him from decreasing his karma but still update karma_time
{
$database->setQuery('UPDATE #__sb_users SET karma_time='.$time.' WHERE userid='.$my->id.'');
$database->query();
echo _KARMA_SELF_DECREASE.'<br /> '._KARMA_BACK.' <a href="'.sefRelToAbs('index.php?option=com_simpleboard&Itemid='.$Itemid.'&func=view&catid='.$catid.'&id='.$pid).'">'._POST_CLICK.'</a>.';
}
}
}
else
{//get outa here, you fraud!
echo _USER_ERROR_A;
echo _USER_ERROR_B."<br /><br />";
echo _USER_ERROR_C."<br /><br />"._USER_ERROR_D.": <code>SB001-karma-01NLO</code><br /><br />";
//that should scare 'em off enough... ;-)
}
?>
</center></td></tr></table>