function register_form_check($user_id)
{
    $_POST['reg_home_page'] = sanitize_url(trim($_POST['reg_home_page']));
    $_POST['reg_user_image'] = !empty($_POST['reg_user_image']) ? sanitize_url(trim($_POST['reg_user_image'])) : '';
    if (!empty($_POST['reg_icq']) && !(int) $_POST['reg_icq']) {
        /* ICQ # can only be an integer */
        $_POST['reg_icq'] = '';
    }
    /* Image count check */
    if ($GLOBALS['FORUM_IMG_CNT_SIG'] && $GLOBALS['FORUM_IMG_CNT_SIG'] < substr_count(strtolower($_POST['reg_sig']), '[img]')) {
        set_err('reg_sig', 'Stai cercando di utilizzare nella tua signature più immagini delle ' . $GLOBALS['FORUM_IMG_CNT_SIG'] . ' consentite.');
    }
    /* Url Avatar check */
    if (!empty($_POST['reg_avatar_loc']) && !($GLOBALS['reg_avatar_loc_file'] = fetch_img($_POST['reg_avatar_loc'], $user_id))) {
        set_err('avatar', 'L&#39;URL che hai inserito non contiene un&#39;immagine valida');
    }
    /* Alias Check */
    if ($GLOBALS['FUD_OPT_2'] & 128 && isset($_POST['reg_alias'])) {
        if ($_POST['reg_alias'] = trim(sanitize_login($_POST['reg_alias']))) {
            if (strlen($_POST['reg_alias']) > $GLOBALS['MAX_LOGIN_SHOW']) {
                $_POST['reg_alias'] = substr($_POST['reg_alias'], 0, $GLOBALS['MAX_LOGIN_SHOW']);
            }
            if (q_singleval("SELECT id FROM phpgw_fud_users WHERE alias='" . addslashes(htmlspecialchars($_POST['reg_alias'])) . "' AND id!=" . $user_id)) {
                set_err('reg_alias', 'Username già utilizzato');
            }
        }
    }
    if ($GLOBALS['FORUM_SIG_ML'] && strlen($_POST['reg_sig']) > $GLOBALS['FORUM_SIG_ML']) {
        set_err('reg_sig', 'Your signature exceeds the maximum allowed length of ' . $GLOBALS['FORUM_SIG_ML'] . ' characters characters.');
    }
    return $GLOBALS['error'];
}
function register_form_check($user_id)
{
    $_POST['reg_home_page'] = sanitize_url(trim($_POST['reg_home_page']));
    $_POST['reg_user_image'] = !empty($_POST['reg_user_image']) ? sanitize_url(trim($_POST['reg_user_image'])) : '';
    if (!empty($_POST['reg_icq']) && !(int) $_POST['reg_icq']) {
        /* ICQ # can only be an integer */
        $_POST['reg_icq'] = '';
    }
    /* Image count check */
    if ($GLOBALS['FORUM_IMG_CNT_SIG'] && $GLOBALS['FORUM_IMG_CNT_SIG'] < substr_count(strtolower($_POST['reg_sig']), '[img]')) {
        set_err('reg_sig', 'You are trying to use more then the allowed ' . $GLOBALS['FORUM_IMG_CNT_SIG'] . ' images in your signature.');
    }
    /* Url Avatar check */
    if (!empty($_POST['reg_avatar_loc']) && !($GLOBALS['reg_avatar_loc_file'] = fetch_img($_POST['reg_avatar_loc'], $user_id))) {
        set_err('avatar', 'The specified url does not contain a valid image');
    }
    /* Alias Check */
    if ($GLOBALS['FUD_OPT_2'] & 128 && isset($_POST['reg_alias'])) {
        if ($_POST['reg_alias'] = trim(sanitize_login($_POST['reg_alias']))) {
            if (strlen($_POST['reg_alias']) > $GLOBALS['MAX_LOGIN_SHOW']) {
                $_POST['reg_alias'] = substr($_POST['reg_alias'], 0, $GLOBALS['MAX_LOGIN_SHOW']);
            }
            if (q_singleval("SELECT id FROM phpgw_fud_users WHERE alias='" . addslashes(htmlspecialchars($_POST['reg_alias'])) . "' AND id!=" . $user_id)) {
                set_err('reg_alias', 'The alias you are trying to use is already in use by another forum member, please choose another.');
            }
        }
    }
    if ($GLOBALS['FORUM_SIG_ML'] && strlen($_POST['reg_sig']) > $GLOBALS['FORUM_SIG_ML']) {
        set_err('reg_sig', 'Your signature exceeds the maximum allowed length of ' . $GLOBALS['FORUM_SIG_ML'] . ' characters characters.');
    }
    return $GLOBALS['error'];
}