Exemple #1
0
Fichier : chat.c Projet : wyat/kbs
static void query_user(chatcontext * pthis, const char *userid)
{
    int tuid = 0;
    char qry_mail_dir[STRLEN], inbuf[STRLEN * 2];
    char *newline;
    time_t exit_time, temp;
    struct userec *lookupuser;

    if (!(tuid = getuser(userid, &lookupuser))) {
        printchatline(pthis, "\033[32m这个ID不存在!\033[m");
        return;
    }
    setmailfile(qry_mail_dir, lookupuser->userid, DOT_DIR);
    /*--- modified by period 2000-11-02 hide posts/logins ---*/

    sprintf(genbuf, "%s (%s):      %s", lookupuser->userid,
            lookupuser->username,
            (check_query_mail(qry_mail_dir, NULL)) ? "有新信" : "    ");
    printchatline(pthis, genbuf);
    sprintf(genbuf, "共上站 %d 次,发表过 %d 篇文章,生命力[%d]%s",
            lookupuser->numlogins, lookupuser->numposts,
            compute_user_value(lookupuser),
            (lookupuser->userlevel & PERM_SUICIDE) ? " (自杀中)" : " ");
    printchatline(pthis, genbuf);

    strcpy(inbuf, ctime(&(lookupuser->lastlogin)));
    if ((newline = strchr(genbuf, '\n')) != NULL)
        *newline = '\0';
    strcpy(genbuf, "当前状态:");
    if (apply_utmpuid((APPLY_UTMP_FUNC) chat_status, tuid, (char *) pthis)) {
        char buf[1024];

        lookupuser->lasthost[IPLEN-1] = '\0';
        sprintf(buf, "目前正在线上: 来自 %s 上线时间 %s" /*\n" */ ,
                (lookupuser->lasthost[0] == '\0' /* || DEFINE(getCurrentUser(),DEF_HIDEIP) */ ? "(不详)" : SHOW_USERIP(lookupuser, lookupuser->lasthost)), inbuf);    /*Haohmaru.99.12.18 */
        printchatline(pthis, buf);
        printchatline(pthis, genbuf);
    } else {
        lookupuser->lasthost[IPLEN-1] = '\0';
        sprintf(genbuf, "上次上线来自  %s 时间为 %s " /*\n" */ ,
                (lookupuser->lasthost[0] == '\0' /* || DEFINE(getCurrentUser(),DEF_HIDEIP) */ ? "(不详)" : SHOW_USERIP(lookupuser, lookupuser->lasthost)), inbuf);    /* Haohmaru.99.12.18 */
        printchatline(pthis, genbuf);
        /* 获得离线时间 Luzi 1998/10/23 */
        exit_time = get_exit_time(lookupuser, genbuf);
        if ((newline = strchr(genbuf, '\n')) != NULL)
            *newline = '\0';
        if (exit_time > lookupuser->lastlogin)
            strcpy(inbuf, genbuf);
        /*Haohmaru.98.12.04.和菜单查询结果一致 */
        if (exit_time <= lookupuser->lastlogin)
            /*
               || (uin.active && uin.pid
               && (!uin.invisible || (uin.invisible && HAS_PERM(getCurrentUser(),PERM_SEECLOAK)))))
             */
            strcpy(inbuf, "因在线上或非常断线不详");
        if (exit_time <= lookupuser->lastlogin) {       /* && (uin.invisible&& !HAS_PERM(getCurrentUser(),PERM_SEECLOAK))) */
            temp = lookupuser->lastlogin + (lookupuser->numlogins % 7) + 5;
            strcpy(inbuf, ctime(&temp));        /*Haohmaru.98.12.04.让隐身用户看上去离线时间比上线时间晚5秒钟 */
            if ((newline = strchr(inbuf, '\n')) != NULL)
                *newline = '\0';
        }
        /*       else strcpy(inbuf,"[因非常断线不详]"); */
        sprintf(genbuf, "离线时间为 %s " /*\n" */ , inbuf);
        printchatline(pthis, genbuf);
    }
#ifdef DEBUG
    if (HAS_PERM(getCurrentUser(), PERM_SYSOP)) {
        sprintf(genbuf, "%d", tuid);
        printchatline(pthis, genbuf);
    }
#endif                          /* 
    */
}
Exemple #2
0
static int full_user_list(struct user_info *uentp, struct fulluserlistarg* arg,int count)
{
    struct user_info userinfo=*uentp;
    struct userec *lookupuser;
    zval* element;
    if (!userinfo.active || !userinfo.pid) {
        return 0;
    }
    if (!HAS_PERM(getCurrentUser(), PERM_SEECLOAK) && userinfo.invisible && strcmp(userinfo.userid, getCurrentUser()->userid)) {
        /*Haohmaru.99.4.24.让隐身者能看见自己 */
        return 0;
    }
    if (count+1<arg->start)
        return COUNT;
    if (count+1-arg->start>=arg->num)
        return QUIT;
    MAKE_STD_ZVAL ( element );
    array_init ( element );

    add_assoc_bool ( element, "invisible", userinfo.invisible );
    add_assoc_long ( element, "pid", userinfo.pid );
    add_assoc_bool ( element, "isfriend", isfriend(userinfo.userid) );
    add_assoc_string ( element, "userid", userinfo.userid, 1 );
    add_assoc_string ( element, "username", userinfo.username, 1 );
    if( getuser(userinfo.userid, &lookupuser) == 0 ) lookupuser=NULL;
    add_assoc_string ( element, "userfrom", HAS_PERM(getCurrentUser(), PERM_SYSOP)? userinfo.from: SHOW_USERIP(lookupuser, userinfo.from), 1 );
    add_assoc_string ( element, "mode", ModeType(userinfo.mode), 1 );
    add_assoc_long ( element, "idle", (long)(time(0) - userinfo.freshtime)/60 );
    
    zend_hash_index_update(Z_ARRVAL_P(arg->return_value), count+1-arg->start, (void *) &element, sizeof(zval *), NULL);
    return COUNT;
}