<?php

if(!defined('DATALIFEENGINE'))
{
  die("Hacking attempt!");
}

$id = intval($_REQUEST['id']);

if ($id == 0)
	msg("info", $langms['sea_info'], "Вы ничего не выбрали.<br><br><input type='button' value=\" {$lang_repa['repa_go_back']} \" class='bbcodes' onclick=\"window.location='$PHP_SELF?mod=repa&action=control'\">", "");
else
{
	$result = $db->super_query("SELECT author, id FROM " . PREFIX . "_reputation WHERE id='$id' AND author <> '$repa_cf[robot]'");
	if ($result['id'] == $id)
	{
		$row2 = $db->super_query("SELECT name, user_id, repa, repa_mod, banned, user_group FROM " . USERPREFIX . "_users WHERE name='$result[author]'");
		$target = $result['author'];
		$date = date ("Y-m-d H:i:s");
		$robot = $repa_cf['robot'];
		$adm_msg = $repa_cf['adm_msg_plus'];
		$admin = 'totalplus';

		$how = $row2['repa'] + $vplus_autor;
		$repa_mod_mas = explode ("|", $row2['repa_mod']);
		$repa_mod_mas[0] = $repa_mod_mas[0] + $vplus_autor;
		$repa_mod = $repa_mod_mas[0]."|".$repa_mod_mas[1];

		$db->query("INSERT INTO " . USERPREFIX . "_reputation (how, date, author, komu, text) values ('$admin', '$date', '$robot', '$target', '$adm_msg')");
		$db->query("UPDATE `".USERPREFIX."_users` SET `repa` = '$how', `repa_mod` = '$repa_mod' WHERE `name`='$target'");

		$_TIME = time()+($config['date_adjust']*60);
		if ($repa_cf['repa_ban'] AND $row2['banned'] != "yes" AND $repa_cf['group_'.$row2[user_group]] != 1)
		{
			if (($row2['repa'] + $vplus_autor) <= $repa_cf['repa_ban_num'] OR $row2['repa'] == $repa_cf['repa_ban_num'])	
			{
				$this_time = $repa_cf['repa_ban_days'] ? $_TIME + ($repa_cf['repa_ban_days'] * 60 * 60 * 24) : 0;
				$db->query( "UPDATE " . USERPREFIX . "_users SET banned='yes' WHERE user_id = '{$row2[user_id]}'" );
				$db->query( "INSERT INTO " . USERPREFIX . "_banned (users_id, descr, date, days, ip) values ('$row2[user_id]', '$repa_cf[repa_ban_desc]', '$this_time', '$repa_cf[repa_ban_days]', '')" );
                $cache->delete('banned.php' );
			}
		}

        	if($repa_cf['msgs_status_adm'] == 'yes')
		{
			$what = $repa_cf['adm_msg_plus'];
			$izvestie = $repa_cf['msgs_template_adm'];
			$izvestie = str_replace('{%text%}', $what, $izvestie);
			$db->query("INSERT INTO " . USERPREFIX . "_pm (subj, text, user, user_from, date, pm_read, folder) values ('$lang_repa[repa_adm_msg_lc]', '$izvestie', '$row2[user_id]', '$robot', '$_TIME', 'no', 'inbox')");
			$db->query("UPDATE " . USERPREFIX . "_users set pm_all=pm_all+1, pm_unread=pm_unread+1  where user_id='$row2[user_id]'");
		}

		msg("info", $langms['sea_info'], "{$lang_repa['repa_done_minus_1']} $target {$lang_repa['repa_done_minus_2']} $vplus_autor <br><br><input type='button' value=\" {$lang_repa['repa_go_back']} \" class='bbcodes' onclick=\"window.location='$PHP_SELF?mod=repa&action=control'\">", "");
	}
	else
		msg("info", $langms['sea_info'], "В базе данных ничего не найдено.<br><br><input type='button' value=\" {$lang_repa['repa_go_back']} \" class='bbcodes' onclick=\"window.location='$PHP_SELF?mod=repa&action=control'\">", "");	
}

?>