print "\n------------------------------\n";
//APPROVE HIT
$num_accepted = 0;
$num_rejected = 0;
$raw_total_bonus = 0;
$num_50 = 0;
$num_01 = 0;
$num_undef = 0;
$num_err = 0;
if ($approve) {
    for ($i = 0; $i < count($wids); $i++) {
        if (in_array($wids[$i], $previously_affected)) {
            continue;
        }
        $sid = get_sid_from_mturk_id($wids[$i]);
        $finished = has_finished_by_sid($sid);
        if ($finished) {
            if (!$dry) {
                $res = $mturk->approveHIT($aids[$i]);
            }
            if ($giveBonus) {
                $email_sent = get_from_session($sid, 'email_sent');
                $bonus = 0;
                $data[$i]['bonus'] = 0.51;
                $bonusstr = '';
                if (strstr($email_sent, 'true')) {
                    $bonusstr = "You subscribed to SafeDelivery, therefore your bonus is \$0.01.";
                    $bonus = 0.01;
                    $num_01++;
                } elseif (strstr($email_sent, 'false')) {
                    $bonusstr = "You did not subscribe to SafeDelivery, therefore your bonus is \$0.50.";
function has_finished($sid)
{
    if (has_finished_by_ip()) {
        return true;
    }
    return has_finished_by_sid($sid);
}