//Do the hidden work
function do_action()
{
global $mybb, $pid, $tid, $db, $lang, $theme;
$lang->load("thx");
if ($mybb->input['action'] == "thankyou")
{
$pid = $_GET['pid'];
$tid = $_GET['tid'];
$uid = $_GET['uid'];
$check_query = $db->query("SELECT * FROM ".TABLE_PREFIX."thx WHERE uid='".intval($uid)."' AND tid='".intval($tid)."' AND pid='".intval($pid)."'");
$check = $db->num_rows($check_query);
if ($check == 0)
{
$database = array (
"txid" => "NULL",
"uid" => $mybb->user['uid'],
"adduid" => $_GET['adduid'],
"pid" => $_GET['pid'],
"tid" => $_GET['tid'],
"time" => time()
);
//Insert entry to DB
$query = $db->insert_query(TABLE_PREFIX."thx", $database);
$thxuser = get_user($_GET['adduid']);
// Build array of reputation data.
$reputation = array(
"uid" => intval($mybb->user['uid']),
"adduid" => $_GET['adduid'],
"reputation" => "Der User <a href=\"".str_replace("{uid}", $_GET['adduid'], PROFILE_URL)."\">".$thxuser['username']."</a> hat sich bedankt.",
"dateline" => time(),
);
$plugins->run_hooks("reputation_do_add_process");
$db->insert_query(TABLE_PREFIX."reputation", $reputation);
// Recount the reputation of this user - keep it in sync.
$query = $db->simple_select(TABLE_PREFIX."reputation", "SUM(reputation) AS reputation_count", "uid='".intval($_GET['adduid'])."'");
$reputation_value = $db->fetch_field($query, "reputation_count");
$db->update_query(TABLE_PREFIX."users", array('reputation' => intval($reputation_value)), "uid='".intval($_GET['adduid'])."'");
$plugins->run_hooks("reputation_do_add_end");
//Output entries to row
echo "<html><head><script type=\"text/javascript\" src=\"jscripts/prototype.lite.js?ver=121\"></script><script type=\"text/javascript\" src=\"jscripts/general.js?ver=121\"></script><link rel=\"stylesheet\" type=\"text/css\" href=\"{$theme['css_url']}\" /></head><body>".read_entries($pid,$tid,"p")."</body></html>";
}
else
{
echo $lang->thx_error;
}
}
}