if (!$data) {
            $data = null;
        }
    } else {
        /* register single vote */
        $data[$poll_id][1] += 1;
    }
}
if (isset($_GET['del']) && ($del = (int) $_GET['del'])) {
    if ($usr->users_opt & 1048576 || q_singleval('SELECT mr.id FROM phpgw_fud_msg_report mr INNER JOIN phpgw_fud_msg m ON m.id=mr.msg_id INNER JOIN phpgw_fud_thread t ON t.id=m.thread_id INNER JOIN phpgw_fud_mod mm ON mm.forum_id=t.forum_id AND mm.user_id=' . _uid . ' WHERE mr.id=' . $del)) {
        q('DELETE FROM phpgw_fud_msg_report WHERE id=' . $del);
        if (db_affected()) {
            logaction(_uid, 'DELREPORT');
        }
    } else {
        std_error('access');
    }
}
$r = $query_type('SELECT
			m.*,
			t.thread_opt, t.root_msg_id, t.last_post_id, t.forum_id,
			f.message_threshold, f.name AS frm_name,
			u.id AS user_id, u.alias AS login, u.avatar_loc, u.email, u.posted_msg_count, u.join_date, u.location,
			u.sig, u.custom_status, u.icq, u.jabber, u.affero, u.aim, u.msnm, u.yahoo, u.users_opt, u.last_visit AS time_sec,
			l.name AS level_name, l.level_opt, l.img AS level_img,
			p.max_votes, p.expiry_date, p.creation_date, p.name AS poll_name, p.total_votes,
			mr.id AS report_id, mr.stamp AS report_stamp, mr.reason AS report_reason,
			u2.id AS report_user_id, u2.alias AS report_user_login, u2.last_visit AS time_sec_r,
			m2.subject AS thread_subject,
			pot.id AS cant_vote
		FROM phpgw_fud_msg_report mr
        $k['p'] = 0;
    }
    return $k['v'][$k['p']++];
}
function convert_bdate($val, $month_fmt)
{
    $ret['year'] = substr($val, 0, 4);
    $ret['day'] = substr($val, 6, 2);
    $ret['month'] = strftime($month_fmt, mktime(1, 1, 1, substr($val, 4, 2), 11, 2000));
    return $ret;
}
if (!isset($_GET['id']) || !(int) $_GET['id']) {
    invl_inp_err();
}
if (!($u = db_sab('SELECT u.*, l.name AS level_name, l.level_opt, l.img AS level_img FROM phpgw_fud_users u LEFT JOIN phpgw_fud_level l ON l.id=u.level_id WHERE u.id=' . (int) $_GET['id']))) {
    std_error('user');
}
$avatar = $FUD_OPT_1 & 28 && $u->users_opt & 8388608 && !($u->level_opt & 2) ? '<tr class="' . alt_var('search_alt', 'RowStyleA', 'RowStyleB') . '"><td nowrap valign="top" class="GenText">Avatar:</td><td class="GenText">' . $u->avatar_loc . '</td></tr>' : '';
if ($avatar && $u->level_opt & 1) {
    $level_name = $level_image = '';
} else {
    $level_name = $u->level_name ? '' . $u->level_name . '<br />' : '';
    $level_image = $u->level_img ? '<img src="images/' . $u->level_img . '" /><br />' : '';
}
$custom_tags = $u->custom_status ? '' . $u->custom_status . '<br />' : '';
if (!($usr->users_opt & 1048576)) {
    $frm_perms = get_all_read_perms(_uid, $usr->users_opt & 524288);
}
$moderation = '';
if ($u->users_opt & 524288) {
    $c = uq('SELECT f.id, f.name FROM phpgw_fud_mod mm INNER JOIN phpgw_fud_forum f ON mm.forum_id=f.id INNER JOIN phpgw_fud_cat c ON f.cat_id=c.id WHERE ' . ($usr->users_opt & 1048576 ? '' : 'f.id IN(' . implode(',', array_keys($frm_perms)) . ') AND ') . 'mm.user_id=' . $u->id);
        if (!$this->send_to_hdr()) {
            $this->close_connex();
            exit("Invalid STMP return code: " . $this->last_ret . "<br>\n");
        }
        if (!$this->send_data()) {
            $this->close_connex();
            exit("Invalid STMP return code: " . $this->last_ret . "<br>\n");
        }
        $this->close_connex();
    }
}
if (!($FUD_OPT_1 & 1024)) {
    error_dialog('ERRORE: Messaggi personali disabilitati', 'Non puoi usare i messaggi personali, sono stati disabilitati dall&#39;amministratore.');
}
if (!_uid) {
    std_error('login');
}
$tabs = '';
if (_uid) {
    $tablist = array('Impostazioni' => 'register', 'Iscrizioni' => 'subscribed', 'Referrals' => 'referals', 'Buddy List' => 'buddy_list', 'Ignore List' => 'ignore_list');
    if (isset($_POST['mod_id'])) {
        $mod_id_chk = $_POST['mod_id'];
    } else {
        if (isset($_GET['mod_id'])) {
            $mod_id_chk = $_GET['mod_id'];
        } else {
            $mod_id_chk = null;
        }
    }
    if (!$mod_id_chk) {
        if ($FUD_OPT_1 & 1024) {
			WHERE mm.id IS NOT NULL OR ((CASE WHEN g2.id IS NOT NULL THEN g2.group_cache_opt ELSE g1.group_cache_opt END) & 1) > 0
			ORDER BY v.id');
}
$old_cat = $forum_limit_data = '';
while ($r = db_rowarr($c)) {
    if ($old_cat != $r[2]) {
        $selected = 'c' . $r[2] == $forum_limiter ? ' selected' : '';
        $forum_limit_data .= '<option value="c' . $r[2] . '"' . $selected . '>' . htmlspecialchars($r[3]) . '</option>';
        $old_cat = $r[2];
    }
    $selected = $r[0] == $forum_limiter ? ' selected' : '';
    $forum_limit_data .= '<option value="' . $r[0] . '"' . $selected . '>&nbsp;&nbsp;&nbsp;' . htmlspecialchars($r[1]) . '</option>';
}
/* user has no permissions to any forum, so as far as they are concerned the search is disabled */
if (!$forum_limit_data) {
    std_error('disabled');
}
function trim_body($body)
{
    /* remove stuff in quotes */
    while (($p = strpos($body, '<table border="0" align="center" width="90%" cellpadding="3" cellspacing="1"><tr><td class="SmallText"><b>')) !== false) {
        $e = strpos($body, '<br></td></tr></table>', $p) + strlen('<br></td></tr></table>');
        $body = substr($body, 0, $p) . substr($body, $e);
    }
    $body = strip_tags($body);
    if (strlen($body) > $GLOBALS['MNAV_MAX_LEN']) {
        $body = substr($body, 0, $GLOBALS['MNAV_MAX_LEN']) . '...';
    }
    return $body;
}
$search_options = tmpl_draw_radio_opt('field', "all\nsubject", "Entire Message\nSubject Only", $field, '', '', '&nbsp;&nbsp;');
        $msg_body = apply_reverse_replace($msg_body);
    }
    if (!$msg_smiley_disabled) {
        $msg_body = post_to_smiley($msg_body);
    }
    if ($GLOBALS['FUD_OPT_1'] & 4096) {
        $msg_body = html_to_tags($msg_body);
    } else {
        if ($GLOBALS['FUD_OPT_1'] & 2048) {
            reverse_fmt($msg_body);
            reverse_nl2br($msg_body);
        }
    }
}
if (!_uid) {
    std_error('perms');
}
if (!($FUD_OPT_1 & 1024)) {
    error_dialog('ERROR: Private Messaging Disabled', 'You cannot use the private messaging system, it has been disabled by the administrator.');
}
if (!($usr->users_opt & 32)) {
    error_dialog('Private Messaging Disabled', 'You cannot send private messages until you enable the &#39;Allow Private Messages&#39; option in your profile.');
}
if (($fldr_size = q_singleval('SELECT SUM(length) FROM phpgw_fud_pmsg WHERE duser_id=' . _uid)) > $MAX_PMSG_FLDR_SIZE) {
    error_dialog('No space left!', 'Your private message folders exceed the allowed storage size of <b>' . $GLOBALS['MAX_PMSG_FLDR_SIZE'] . ' bytes</b>, as they currently contain <b>' . $fldr_size . ' bytes</b> worth of messages.<br><br><font class="ErrorText">Remove some old messages to clear up space</font>.');
}
is_allowed_user($usr);
$attach_control_error = null;
$pm_find_user = $FUD_OPT_1 & (8388608 | 4194304) ? '[<a href="javascript://" class="GenLink" onClick="javascript: window_open(\'/egroupware/fudforum/3814588639/index.php?t=pmuserloc&amp;' . _rsid . '&amp;js_redr=post_form.msg_to_list\',\'user_list\',250,250);">Find User</a>]' : '';
$attach_count = 0;
$file_array = '';
 } else {
     if ($th_id && !$msg_id) {
         $msg_post->thread_id = $th_id;
         $msg_post->add_reply($reply_to, $th_id, $perms & (64 | 4096), false);
     } else {
         if ($msg_id) {
             $msg_post->id = $msg_id;
             $msg_post->thread_id = $th_id;
             $msg_post->post_stamp = $msg->post_stamp;
             $msg_post->sync(_uid, $frm->id, $frm->message_threshold, $perms & (64 | 4096));
             /* log moderator edit */
             if (_uid && _uid != $msg->poster_id) {
                 logaction($usr->id, 'MSGEDIT', $msg_post->id);
             }
         } else {
             std_error('systemerr');
         }
     }
 }
 /* write file attachments */
 if ($perms & 256 && isset($attach_list)) {
     attach_finalize($attach_list, $msg_post->id);
 }
 if (!$msg_id && (!($frm->forum_opt & 2) || $MOD)) {
     $msg_post->approve($msg_post->id, true);
 }
 if (_uid && !$msg_id) {
     /* deal with notifications */
     if (isset($_POST['msg_poster_notif'])) {
         thread_notify_add(_uid, $msg_post->thread_id);
     } else {