function msg_get($id)
{
    if ($r = db_sab('SELECT * FROM phpgw_fud_msg WHERE id=' . $id)) {
        $r->body = read_msg_body($r->foff, $r->length, $r->file_id);
        un_register_fps();
        return $r;
    }
    error_dialog('Invalid Message', 'The message you are trying to view does not exist.');
}
function msg_get($id)
{
    if ($r = db_sab('SELECT * FROM phpgw_fud_msg WHERE id=' . $id)) {
        $r->body = read_msg_body($r->foff, $r->length, $r->file_id);
        un_register_fps();
        return $r;
    }
    error_dialog('Messaggio non valido', 'Il messaggio che stai cercando di visualizzare non esiste.');
}
            $this->close_connex();
            exit("Invalid STMP return code: " . $this->last_ret . "<br>\n");
        }
        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;
        }
function is_allowed_user(&$usr)
{
    if ($GLOBALS['FUD_OPT_2'] & 1024 && $usr->users_opt & 2097152) {
        error_dialog('Unverified Account', 'The administrator had chosen to review all accounts manually prior to activation. Until your account has been validated by the administrator you will not be able to utilize the full capabilities of your account.');
    }
    if ($usr->users_opt & 65536 || is_email_blocked($usr->email) || is_login_blocked($usr->login) || is_ip_blocked(get_ip())) {
        error_dialog('ERROR: you aren&#39;t allowed to post', 'Your account has been blocked from posting');
    }
}
function is_allowed_user(&$usr)
{
    if ($GLOBALS['FUD_OPT_2'] & 1024 && $usr->users_opt & 2097152) {
        error_dialog('Unverified Account', 'The administrator had chosen to review all accounts manually prior to activation. Until your account is validated by the administrator you will not be able to utilize the full capabilities of your account.');
    }
    if ($usr->users_opt & 65536 || is_email_blocked($usr->email) || is_login_blocked($usr->login) || is_ip_blocked(get_ip())) {
        error_dialog('ERRORE: non sei autorizzato a postare messaggi', 'A questo account è stata impedita la possibilità di scrivere messaggi');
    }
}
    return $tmp[0];
}
if (isset($_POST['add_login'])) {
    if (!($ignore_id = ignore_alias_fetch($_POST['add_login'], $is_mod))) {
        error_dialog('User not found', 'The user you&#39;ve tried to add to your ignore list was not found on the forum.');
    }
    if ($is_mod) {
        error_dialog('Info', 'You can&#39;t ignore this user');
    }
    if (!empty($usr->ignore_list)) {
        $usr->ignore_list = @unserialize($usr->ignore_list);
    }
    if (!isset($usr->ignore_list[$ignore_id])) {
        ignore_add(_uid, $ignore_id);
    } else {
        error_dialog('Info', 'You already have this user on your ignore list');
    }
}
/* incomming from message display page (ignore link) */
if (isset($_GET['add']) && ($_GET['add'] = (int) $_GET['add'])) {
    if (!empty($usr->ignore_list)) {
        $usr->ignore_list = @unserialize($usr->ignore_list);
    }
    if (($ignore_id = q_singleval('SELECT id FROM phpgw_fud_users WHERE id=' . $_GET['add'] . ' AND (users_opt & 1048576)=0')) && !isset($usr->ignore_list[$ignore_id])) {
        ignore_add(_uid, $ignore_id);
    }
    check_return($usr->returnto);
}
if (isset($_GET['del']) && ($_GET['del'] = (int) $_GET['del'])) {
    ignore_delete(_uid, $_GET['del']);
    /* needed for external links to this form */
            $this->close_connex();
            exit("Invalid STMP return code: " . $this->last_ret . "<br>\n");
        }
        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('ERROR: Private Messaging Disabled', 'You cannot use the private messaging system, it has been disabled by the administrator.');
}
if (!_uid) {
    std_error('login');
}
$tabs = '';
if (_uid) {
    $tablist = array('Settings' => 'register', 'Subscriptions' => '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;
        }
}
function make_perms_query(&$fields, &$join, $fid = '')
{
    if (!$fid) {
        $fid = 'f.id';
    }
    if (_uid) {
        $join = ' INNER JOIN phpgw_fud_group_cache g1 ON g1.user_id=2147483647 AND g1.resource_id=' . $fid . ' LEFT JOIN phpgw_fud_group_cache g2 ON g2.user_id=' . _uid . ' AND g2.resource_id=' . $fid . ' ';
        $fields = ' (CASE WHEN g2.id IS NOT NULL THEN g2.group_cache_opt ELSE g1.group_cache_opt END) AS group_cache_opt ';
    } else {
        $join = ' INNER JOIN phpgw_fud_group_cache g1 ON g1.user_id=0 AND g1.resource_id=' . $fid . ' ';
        $fields = ' g1.group_cache_opt ';
    }
}
if (!($FUD_OPT_2 & 512)) {
    error_dialog('Tree view of the topic listing has been disabled.', 'The administrator has disabled the tree view of the topic listing, please use the flat view instead.');
}
ses_update_status($usr->sid, 'Browsing forum (tree view) <a class="GenLink" href="/egroupware/fudforum/3814588639/index.php?t=threadt&amp;frm_id=' . $frm->id . '">' . htmlspecialchars($frm->name) . '</a>', $frm->id);
$announcements = '';
if ($frm->is_ann) {
    $today = gmdate('Ymd', __request_timestamp__);
    $res = uq('SELECT a.subject, a.text FROM phpgw_fud_announce a INNER JOIN phpgw_fud_ann_forums af ON a.id=af.ann_id AND af.forum_id=' . $frm->id . ' WHERE a.date_started<=' . $today . ' AND a.date_ended>=' . $today);
    while ($r = db_rowarr($res)) {
        $announcements .= '<tr><td class="AnnText" colspan="' . $ann_cols . '"><font class="AnnSubjText">' . $r[0] . '</font><br />' . $r[1] . '</td></tr>';
    }
}
function tmpl_create_forum_select($frm_id, $mod)
{
    $prev_cat_id = 0;
    $selection_options = '';
    if (!isset($_GET['t']) || $_GET['t'] != 'thread' && $_GET['t'] != 'threadt') {
    std_error('login');
}
if (isset($_POST['add_login'])) {
    if (!($buddy_id = q_singleval("SELECT id FROM phpgw_fud_users WHERE alias='" . addslashes(htmlspecialchars($_POST['add_login'])) . "'"))) {
        error_dialog('Unable to add user', 'The user you&#39;ve tried to add to your buddy list was not found on the forum.');
    }
    if ($buddy_id == _uid) {
        error_dialog('Info', 'Can&#39;t add your self to the buddy list');
    }
    if (!empty($usr->buddy_list)) {
        $usr->buddy_list = @unserialize($usr->buddy_list);
    }
    if (!isset($usr->buddy_list[$buddy_id])) {
        $usr->buddy_list = buddy_add(_uid, $buddy_id);
    } else {
        error_dialog('Info', 'You already have this user on your buddy list');
    }
}
/* incomming from message display page (add buddy link) */
if (isset($_GET['add']) && ($_GET['add'] = (int) $_GET['add'])) {
    if (!empty($usr->buddy_list)) {
        $usr->buddy_list = @unserialize($usr->buddy_list);
    }
    if (($buddy_id = q_singleval('SELECT id FROM phpgw_fud_users WHERE id=' . $_GET['add'])) && !isset($usr->buddy_list[$buddy_id])) {
        buddy_add(_uid, $buddy_id);
    }
    check_return($usr->returnto);
}
if (isset($_GET['del']) && ($_GET['del'] = (int) $_GET['del'])) {
    buddy_delete(_uid, $_GET['del']);
    /* needed for external links to this form */
    return $tmp[0];
}
if (isset($_POST['add_login'])) {
    if (!($ignore_id = ignore_alias_fetch($_POST['add_login'], $is_mod))) {
        error_dialog('Utente non trovato', 'L&#39;utente che hai cercato di inserire nella ignore list non risulta iscritto al forum. Attenzione: il motore di inserimento degli utenti distingue tra MAIUSCOLE e minuscole: controlla con attenzione!');
    }
    if ($is_mod) {
        error_dialog('Informazioni', 'Non puoi ignorare questo utente');
    }
    if (!empty($usr->ignore_list)) {
        $usr->ignore_list = @unserialize($usr->ignore_list);
    }
    if (!isset($usr->ignore_list[$ignore_id])) {
        ignore_add(_uid, $ignore_id);
    } else {
        error_dialog('Informazioni', 'Hai già inserito questo utente nella tua ignore list');
    }
}
/* incomming from message display page (ignore link) */
if (isset($_GET['add']) && ($_GET['add'] = (int) $_GET['add'])) {
    if (!empty($usr->ignore_list)) {
        $usr->ignore_list = @unserialize($usr->ignore_list);
    }
    if (($ignore_id = q_singleval('SELECT id FROM phpgw_fud_users WHERE id=' . $_GET['add'] . ' AND (users_opt & 1048576)=0')) && !isset($usr->ignore_list[$ignore_id])) {
        ignore_add(_uid, $ignore_id);
    }
    check_return($usr->returnto);
}
if (isset($_GET['del']) && ($_GET['del'] = (int) $_GET['del'])) {
    ignore_delete(_uid, $_GET['del']);
    /* needed for external links to this form */