phpbbslib.c
来自「bbs server linux平台下软件源码」· C语言 代码 · 共 2,310 行 · 第 1/5 页
C
2,310 行
}static inline int getcurrentuser_num(){ return currentusernum;}#ifdef HAVE_WFORUMstatic PHP_FUNCTION(bbs_is_yank){ RETURN_LONG(currentuinfo->yank);}static PHP_FUNCTION(bbs_alter_yank){ currentuinfo->yank = currentuinfo->yank ? 0 : 1; RETURN_LONG(currentuinfo->yank);};#endifstatic inline int getcurrentuinfo_num(){ return currentuinfonum;}/* * Here goes the real functions *//* arguments: userid, username, ipaddr, operation */static char old_pwd[1024];static PHP_FUNCTION(bbs_setfromhost){ char *s; int s_len; int full_len; char *fullfromhostptr; if (zend_parse_parameters(2 TSRMLS_CC, "ss", &s, &s_len, &fullfromhostptr, &full_len) != SUCCESS) { WRONG_PARAM_COUNT; } if (s_len > IPLEN) s[IPLEN] = 0; if (full_len > 80) fullfromhostptr[80] = 0; strcpy(fullfrom, fullfromhostptr); strcpy(fromhost, s); strcpy(php_fromhost, s); RETURN_NULL();}static PHP_FUNCTION(bbs_getuser){ long v1; struct userec *lookupuser; char *s; int s_len; zval *user_array; MAKE_STD_ZVAL(user_array); getcwd(old_pwd, 1023); chdir(BBSHOME); old_pwd[1023] = 0; if (zend_parse_parameters(2 TSRMLS_CC, "sa", &s, &s_len, &user_array) != SUCCESS) { WRONG_PARAM_COUNT; } if (s_len > IDLEN) s[IDLEN] = 0; v1 = getuser(s, &lookupuser); if (v1 == 0) RETURN_LONG(0); if (array_init(user_array) != SUCCESS) RETURN_LONG(0); assign_user(user_array, lookupuser, v1);/* RETURN_STRING(retbuf, 1); * */ RETURN_LONG(v1);}static PHP_FUNCTION(bbs_getonlineuser){ long idx, ret; struct user_info *uinfo; zval *user_array; MAKE_STD_ZVAL(user_array); getcwd(old_pwd, 1023); chdir(BBSHOME); old_pwd[1023] = 0; if (zend_parse_parameters(2 TSRMLS_CC, "la", &idx, &user_array) != SUCCESS) { WRONG_PARAM_COUNT; } uinfo = get_utmpent(idx); if (uinfo == NULL) ret = 0; else { if (array_init(user_array) != SUCCESS) ret = 0; else { assign_userinfo(user_array, uinfo, idx); ret = idx; } } RETURN_LONG(ret);}static PHP_FUNCTION(bbs_getonlinenumber){ RETURN_LONG(get_utmp_number() + getwwwguestcount());}static PHP_FUNCTION(bbs_getonlineusernumber){ RETURN_LONG(get_utmp_number());}static PHP_FUNCTION(bbs_getwwwguestnumber){ RETURN_LONG(getwwwguestcount());}static PHP_FUNCTION(bbs_countuser){ long idx; getcwd(old_pwd, 1023); chdir(BBSHOME); old_pwd[1023] = 0; if (zend_parse_parameters(2 TSRMLS_CC, "l", &idx) != SUCCESS) { WRONG_PARAM_COUNT; } RETURN_LONG(apply_utmpuid(NULL, idx, 0));}static PHP_FUNCTION(bbs_getnumofsig){ FILE *fp; char tmp[256]; int count = 0; int sigln; char signame[STRLEN]; int numofsig; getcwd(old_pwd, 1023); chdir(BBSHOME); old_pwd[1023] = 0; if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } if (currentuser == NULL) RETURN_LONG(-1); sethomefile(signame, currentuser->userid, "signatures"); if ((fp = fopen(signame, "r")) == NULL) RETURN_LONG(0); while (fgets(tmp, sizeof(tmp), fp) != NULL) count++; fclose(fp); sigln = count; numofsig = sigln / 6; if ((sigln % 6) != 0) numofsig += 1; RETURN_LONG(numofsig);}static PHP_FUNCTION(bbs_setuserpasswd){ char *s; int s_len; char *pw; int pw_len; long ret; int unum; struct userec *user; getcwd(old_pwd, 1023); chdir(BBSHOME); old_pwd[1023] = 0; if (zend_parse_parameters(2 TSRMLS_CC, "ss", &s, &s_len, &pw, &pw_len) != SUCCESS) { WRONG_PARAM_COUNT; } if (s_len > IDLEN) s[IDLEN] = 0; if (pw_len > PASSLEN) pw[PASSLEN] = 0; if (pw_len < 2) { RETURN_LONG(-1); } if (!(unum = getuser(s, &user))) { RETURN_LONG(-2); } setpasswd(pw, user); RETURN_LONG(0);}static PHP_FUNCTION(bbs_checkuserpasswd){ char *s; int s_len; char *pw; int pw_len; long ret; int unum; struct userec *user; getcwd(old_pwd, 1023); chdir(BBSHOME); old_pwd[1023] = 0; if (zend_parse_parameters(2 TSRMLS_CC, "ss", &s, &s_len, &pw, &pw_len) != SUCCESS) { WRONG_PARAM_COUNT; } if (s_len > IDLEN) s[IDLEN] = 0; if (pw_len > PASSLEN) pw[PASSLEN] = 0; if (pw_len < 2) { RETURN_LONG(-1); } if (!(unum = getuser(s, &user))) { RETURN_LONG(-2); } if (!checkpasswd2(pw, user)) { RETURN_LONG(-3); } RETURN_LONG(0);}static PHP_FUNCTION(bbs_checkpasswd){ char *s; int s_len; char *pw; int pw_len; long ret; int unum; struct userec *user; getcwd(old_pwd, 1023); chdir(BBSHOME); old_pwd[1023] = 0; if (zend_parse_parameters(2 TSRMLS_CC, "ss", &s, &s_len, &pw, &pw_len) != SUCCESS) { WRONG_PARAM_COUNT; } if (s_len > IDLEN) s[IDLEN] = 0; if (pw_len > PASSLEN) pw[PASSLEN] = 0; if ((s[0] != 0) && !(unum = getuser(s, &user))) ret = 2; else { if (s[0] == 0) user = currentuser; if (checkpasswd2(pw, user)) { ret = 0; if (s[0] != 0) setcurrentuser(user, unum); } else { ret = 1; logattempt(user->userid, php_fromhost); } } RETURN_LONG(ret);}static PHP_FUNCTION(bbs_getuserparam){ if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } if (currentuser == NULL) { RETURN_FALSE; } RETURN_LONG(currentuser->userdefine);}static PHP_FUNCTION(bbs_setuserparam){ int userparam; if (ZEND_NUM_ARGS() != 1 || zend_parse_parameters(1 TSRMLS_CC, "l", &userparam) != SUCCESS) { WRONG_PARAM_COUNT; } if (currentuser == NULL) { RETURN_LONG(-1); } currentuser->userdefine = userparam; RETURN_LONG(0);}static PHP_FUNCTION(bbs_wwwlogin){ long ret; long kick_multi = 0; struct user_info *pu = NULL; int utmpent; getcwd(old_pwd, 1023); chdir(BBSHOME); old_pwd[1023] = 0; if (ZEND_NUM_ARGS() == 1) { if (zend_parse_parameters(1 TSRMLS_CC, "l", &kick_multi) != SUCCESS) { WRONG_PARAM_COUNT; } } else if (ZEND_NUM_ARGS() != 0) WRONG_PARAM_COUNT; ret = www_user_login(getcurrentuser(), getcurrentuser_num(), kick_multi, php_fromhost,#ifdef SQUID_ACCL fullfrom,#else php_fromhost,#endif &pu, &utmpent); if (getcurrentuser() == NULL) { struct userec *user; int num; num = getuser("guest", &user); setcurrentuser(user, num); } setcurrentuinfo(pu, utmpent); RETURN_LONG(ret);}static PHP_FUNCTION(bbs_getuserlevel){ struct userec *u; char *user; int uLen; char title[USER_TITLE_LEN]; if (ZEND_NUM_ARGS() != 1 || zend_parse_parameters(1 TSRMLS_CC, "s", &user, &uLen) != SUCCESS) { WRONG_PARAM_COUNT; } if (getuser(user, &u) == 0) { RETURN_LONG(-1); } uleveltochar(title, u); title[9] = 0; RETURN_STRINGL(title, strlen(title), 1);}#ifdef HAVE_USERMONEYstatic PHP_FUNCTION(bbs_getusermoney){ struct userec *u; char *user; int uLen; if (ZEND_NUM_ARGS() != 1 || zend_parse_parameters(1 TSRMLS_CC, "s", &user, &uLen) != SUCCESS) { WRONG_PARAM_COUNT; } if (getuser(user, &u) == 0) { RETURN_LONG(-1); } RETURN_LONG(get_money(u));}static PHP_FUNCTION(bbs_setusermoney){ struct userec *u; char *user; int uLen, money; if (ZEND_NUM_ARGS() != 2 || zend_parse_parameters(2 TSRMLS_CC, "sl", &user, &uLen, &money) != SUCCESS) { WRONG_PARAM_COUNT; } if (getuser(user, &u) == 0) { RETURN_LONG(-1); } if (money < 0) { RETURN_LONG(-2); } RETURN_LONG(set_money(u, money));}static PHP_FUNCTION(bbs_addusermoney){ struct userec *u; char *user; int uLen, money; if (ZEND_NUM_ARGS() != 2 || zend_parse_parameters(2 TSRMLS_CC, "sl", &user, &uLen, &money) != SUCCESS) { WRONG_PARAM_COUNT; } if (getuser(user, &u) == 0) { RETURN_LONG(-1); } if (money < 0) { RETURN_LONG(-2); } RETURN_LONG(add_money(u, money));}static PHP_FUNCTION(bbs_getuserscore){ struct userec *u; char *user; int uLen; if (ZEND_NUM_ARGS() != 1 || zend_parse_parameters(1 TSRMLS_CC, "s", &user, &uLen) != SUCCESS) { WRONG_PARAM_COUNT; } if (getuser(user, &u) == 0) { RETURN_LONG(-1); } RETURN_LONG(get_score(u));}static PHP_FUNCTION(bbs_setuserscore){ struct userec *u; char *user; int uLen, score; if (ZEND_NUM_ARGS() != 2 || zend_parse_parameters(2 TSRMLS_CC, "sl", &user, &uLen, &score) != SUCCESS) { WRONG_PARAM_COUNT; } if (getuser(user, &u) == 0) { RETURN_LONG(-1); } if (score < 0) { RETURN_LONG(-2); } RETURN_LONG(set_score(u, score));}static PHP_FUNCTION(bbs_adduserscore){ struct userec *u; char *user; int uLen, score; if (ZEND_NUM_ARGS() != 2 || zend_parse_parameters(2 TSRMLS_CC, "sl", &user, &uLen, &score) != SUCCESS) { WRONG_PARAM_COUNT; } if (getuser(user, &u) == 0) { RETURN_LONG(-1); } if (score < 0) { RETURN_LONG(-2); } RETURN_LONG(add_score(u, score));}#endifstatic PHP_FUNCTION(bbs_getcurrentuinfo){ zval *user_array; long ret = 1; MAKE_STD_ZVAL(user_array); getcwd(old_pwd, 1023); chdir(BBSHOME); old_pwd[1023] = 0; if (ZEND_NUM_ARGS() == 1) { if (zend_parse_parameters(1 TSRMLS_CC, "a", &user_array) != SUCCESS) { WRONG_PARAM_COUNT; } if (array_init(user_array) != SUCCESS) {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?