📄 phpbbs.board.c
字号:
} indexlist=(int*)emalloc(sizeof(int*)*(total)); if (indexlist==NULL) { RETURN_FALSE; } for (n = 0; n < total; n++) { bptr = getboard(n + 1); if (!bptr) continue; if (*(bptr->filename)==0) continue; if ( group == -2 ){ if( ( tnow - bptr->createtime ) > 86400*30 || ( bptr->flag & BOARD_GROUP ) ) continue; }else if (!all_boards && (bptr->group!=group)) continue; if (!check_see_perm(getCurrentUser(),bptr)) { continue; } if ((group==0)&&( strchr(prefix, bptr->title[0]) == NULL && prefix[0] != '*')) continue; /* if (yank || getSession()->zapbuf[n] != 0 || (bptr->level & PERM_NOZAP)) */ { /*都要排序*/ for (i=0;i<brdnum;i++) { if ( strcasecmp(namelist[i], bptr->filename)>0) break; } for (j=brdnum;j>i;j--) { namelist[j]=namelist[j-1]; indexlist[j]=indexlist[j-1]; } namelist[i]=bptr->filename; indexlist[i]=n; brdnum++; } } newpost_buffer = (struct newpostdata*)emalloc(sizeof(struct newpostdata) * brdnum); for (i=0;i<brdnum;i++) { ptr=&(newpost_buffer[i]); bptr = getboard(indexlist[i]+1); ptr->dir = bptr->flag&BOARD_GROUP?1:0; ptr->name = (char*)bptr->filename; ptr->title = (char*)bptr->title; ptr->BM = (char*)bptr->BM; ptr->flag = bptr->flag | ((bptr->level & PERM_NOZAP) ? BOARD_NOZAPFLAG : 0); ptr->pos = indexlist[i]; if (bptr->flag&BOARD_GROUP) { ptr->total = bptr->board_data.group_total; } else ptr->total=-1; ptr->zap = (getSession()->zapbuf[indexlist[i]] == 0); check_newpost(ptr, no_brc); } if (new_return_mode) { if (array_init(return_value) == FAILURE) { RETURN_FALSE; } for(i=0;i<brdnum;i++) { MAKE_STD_ZVAL(element); array_init(element); assign_board_zval(element, &(newpost_buffer[i])); zend_hash_index_update(Z_ARRVAL_P(return_value), i, (void *)&element, sizeof(zval*), NULL); } } else { /* * setup column names */ if (array_init(return_value) == FAILURE) { RETURN_FALSE; } columns = emalloc(BOARD_COLUMNS * sizeof(zval *)); if (columns==NULL) { RETURN_FALSE; } for (i = 0; i < BOARD_COLUMNS; i++) { MAKE_STD_ZVAL(element); array_init(element); columns[i] = element; zend_hash_update(Z_ARRVAL_P(return_value), brd_col_names[i], strlen(brd_col_names[i]) + 1, (void *) &element, sizeof(zval *), NULL); } for (i=0;i<brdnum;i++) { ptr=&(newpost_buffer[i]); for (j = 0; j < BOARD_COLUMNS; j++) { MAKE_STD_ZVAL(element); bbs_make_board_zval(element, brd_col_names[j], ptr); zend_hash_index_update(Z_ARRVAL_P(columns[j]), i, (void *) &element, sizeof(zval *), NULL); } } efree(columns); } efree(newpost_buffer); efree(namelist); efree(indexlist); }}PHP_FUNCTION(bbs_checkorigin){ char *board; int board_len; int ac = ZEND_NUM_ARGS(); int total; /* * getting arguments */ if (ac != 1 || zend_parse_parameters(1 TSRMLS_CC, "s", &board, &board_len) == FAILURE) { WRONG_PARAM_COUNT; } if (!setboardorigin(board, -1)) { RETURN_LONG(0); } total = board_regenspecial(board,DIR_MODE_ORIGIN,NULL); RETURN_LONG(total);}PHP_FUNCTION(bbs_checkmark){ char *board; int board_len; int ac = ZEND_NUM_ARGS(); int total; /* * getting arguments */ if (ac != 1 || zend_parse_parameters(1 TSRMLS_CC, "s", &board, &board_len) == FAILURE) { WRONG_PARAM_COUNT; } if (!setboardmark(board, -1)) { RETURN_LONG(0); } total = board_regenspecial(board,DIR_MODE_MARK,NULL); RETURN_LONG(total);}PHP_FUNCTION(bbs_getbdes){ char *board; int board_len; const struct boardheader *bp=NULL; int ac = ZEND_NUM_ARGS(); if (ac != 1 || zend_parse_parameters(1 TSRMLS_CC, "s", &board, &board_len) == FAILURE) { WRONG_PARAM_COUNT; } if ((bp = getbcache(board)) == NULL) { RETURN_LONG(0); } RETURN_STRING((char *)(bp->des),1);}PHP_FUNCTION(bbs_getbname){ long brdnum; const struct boardheader *bp=NULL; int ac = ZEND_NUM_ARGS(); if (ac != 1 || zend_parse_parameters(1 TSRMLS_CC, "l", &brdnum) == FAILURE) { WRONG_PARAM_COUNT; } if ((bp = getboard(brdnum)) == NULL) { RETURN_LONG(0); } RETURN_STRING((char *)(bp->filename),1);}PHP_FUNCTION(bbs_checkreadperm){ long user_num, boardnum; struct userec *user; if (zend_parse_parameters(2 TSRMLS_CC, "ll", &user_num, &boardnum) != SUCCESS) WRONG_PARAM_COUNT; user = getuserbynum(user_num); if (user == NULL) RETURN_LONG(0); RETURN_LONG(check_read_perm(user, getboard(boardnum)));}PHP_FUNCTION(bbs_checkpostperm){ long user_num, boardnum; struct userec *user; const struct boardheader *bh; if (zend_parse_parameters(2 TSRMLS_CC, "ll", &user_num, &boardnum) != SUCCESS) WRONG_PARAM_COUNT; user = getuserbynum(user_num); if (user == NULL) RETURN_LONG(0); bh=getboard(boardnum); if (bh==0) { RETURN_LONG(0); } RETURN_LONG(haspostperm(user, bh->filename));}/** * check a board is normal board * prototype: * int bbs_normal(char* boardname); * * @return the result * 1 -- normal board * 0 -- no * @author kcn */PHP_FUNCTION(bbs_normalboard){ int ac = ZEND_NUM_ARGS(); char* boardname; int name_len; if (ac != 1 || zend_parse_parameters(1 TSRMLS_CC, "s", &boardname, &name_len) == FAILURE) { WRONG_PARAM_COUNT; } RETURN_LONG(normal_board(boardname));}/** * search board by keyword * function bbs_searchboard(string keyword,int exact,array boards) * @author: windinsn May 17,2004 * return true/false */PHP_FUNCTION(bbs_searchboard){ char *keyword; int keyword_len; long exact; zval *element,*boards; boardheader_t *bc; int i; char *board1,*title; int ac = ZEND_NUM_ARGS(); if (ac != 3 || zend_parse_parameters(3 TSRMLS_CC, "sla", &keyword, &keyword_len, &exact ,&boards) == FAILURE) WRONG_PARAM_COUNT; if (!*keyword) RETURN_FALSE; if (array_init(boards) != SUCCESS) RETURN_FALSE; bc = bcache; if (exact) { //精确查找 for (i = 0; i < MAXBOARD; i++) { board1 = bc[i].filename; title = bc[i].title + 13; if (!check_read_perm(getCurrentUser(), &bc[i])) continue; if (!strcasecmp(keyword, board1)) { MAKE_STD_ZVAL(element); array_init(element); add_assoc_string(element,"NAME",board1,1); add_assoc_string(element,"DESC",bc[i].des,1); add_assoc_string(element,"TITLE",title,1); zend_hash_index_update(Z_ARRVAL_P(boards),0,(void*) &element, sizeof(zval*), NULL); RETURN_TRUE; } } RETURN_FALSE; } else { //模糊查找 int total = 0; for (i = 0; i < MAXBOARD; i++) { board1 = bc[i].filename; title = bc[i].title + 13; if (!check_read_perm(getCurrentUser(), &bc[i])) continue; if (strcasestr(board1,keyword) || strcasestr(title,keyword) || strcasestr(bc[i].des,keyword)) { MAKE_STD_ZVAL(element); array_init(element); add_assoc_string(element,"NAME",board1,1); add_assoc_string(element,"DESC",bc[i].des,1); add_assoc_string(element,"TITLE",title,1); zend_hash_index_update(Z_ARRVAL_P(boards),total,(void*) &element, sizeof(zval*), NULL); total ++; } } RETURN_LONG(total); }}/** * int bbs_useronboard(string baord,array users) * show users on board * $users = array( * string 'USERID' * string 'HOST' * ); * return user numbers , less than 0 when failed * @author: windinsn * */PHP_FUNCTION(bbs_useronboard){ char *board; int board_len; zval *element,*users; int bid,i,j; long seecloak=0; int ac = ZEND_NUM_ARGS(); if (ac != 2 || zend_parse_parameters(2 TSRMLS_CC, "sz", &board, &board_len, &users) == FAILURE) { if (ac != 3 || zend_parse_parameters(3 TSRMLS_CC, "szl", &board, &board_len, &users, &seecloak) == FAILURE) { WRONG_PARAM_COUNT; } } bid = getbid(board, NULL); if (bid == 0) RETURN_LONG(-1);#ifndef ALLOW_PUBLIC_USERONBOARD if(! HAS_PERM(getCurrentUser(), PERM_SYSOP)) RETURN_LONG(-1); seecloak = 1;#endif if (array_init(users) != SUCCESS) RETURN_LONG(-1); j = 0; for (i=0;i<USHM_SIZE;i++) { struct user_info* ui; ui=get_utmpent(i+1); if (ui->active&&ui->currentboard) { if (!seecloak && ui->invisible==1) continue; if (ui->currentboard == bid) { MAKE_STD_ZVAL(element); array_init(element); add_assoc_string(element,"USERID",ui->userid,1); add_assoc_string(element,"HOST",ui->from,1); zend_hash_index_update(Z_ARRVAL_P(users),j,(void*) &element, sizeof(zval*), NULL); j ++; } } } resolve_guest_table(); for (i=0;i<MAX_WWW_GUEST;i++) { if (wwwguest_shm->use_map[i / 32] & (1 << (i % 32))) if (wwwguest_shm->guest_entry[i].currentboard) { if (wwwguest_shm->guest_entry[i].currentboard == bid) { char buf[IPLEN+4];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -