phpbbslib.c

来自「bbs server linux平台下软件源码」· C语言 代码 · 共 2,310 行 · 第 1/5 页

C
2,310
字号
#ifdef HAVE_CONFIG_H#include "config.h"#endif#include "php.h"#include "php_ini.h"#include "ext/standard/info.h"#include "php_smth_bbs.h"#include "bbs.h"#include "bbslib.h"#include "vote.h"static unsigned char third_arg_force_ref_1111[] = { 4, BYREF_FORCE, BYREF_FORCE, BYREF_FORCE, BYREF_FORCE };static unsigned char third_arg_force_ref_011[] = { 3, BYREF_NONE, BYREF_FORCE, BYREF_FORCE };static unsigned char fourth_arg_force_ref_0001[] = { 4, BYREF_NONE, BYREF_NONE, BYREF_NONE, BYREF_FORCE };#ifdef HAVE_WFORUMstatic PHP_FUNCTION(bbs_get_article);static PHP_FUNCTION(bbs_is_yank);static PHP_FUNCTION(bbs_alter_yank);#endifstatic PHP_FUNCTION(bbs_getonline_user_list);static PHP_FUNCTION(bbs_get_elite_num);static PHP_FUNCTION(bbs_get_elite_list);#ifdef HAVE_USERMONEYstatic PHP_FUNCTION(bbs_getusermoney);static PHP_FUNCTION(bbs_setusermoney);static PHP_FUNCTION(bbs_addusermoney);static PHP_FUNCTION(bbs_getuserscore);static PHP_FUNCTION(bbs_setuserscore);static PHP_FUNCTION(bbs_adduserscore);#endifstatic PHP_FUNCTION(bbs_saveuserdata);static PHP_FUNCTION(bbs_checkuserpasswd);static PHP_FUNCTION(bbs_setuserpasswd);static PHP_FUNCTION(bbs_getuserparam);static PHP_FUNCTION(bbs_setuserparam);static PHP_FUNCTION(bbs_getuserlevel);static PHP_FUNCTION(bbs_get_today_article_num);static PHP_FUNCTION(bbs_searchtitle);static PHP_FUNCTION(bbs_getnumofsig);static PHP_FUNCTION(bbs_postmail);static PHP_FUNCTION(bbs_mailwebmsgs);static PHP_FUNCTION(bbs_getwebmsgs);static PHP_FUNCTION(bbs_get_thread_article_num);static PHP_FUNCTION(bbs_get_thread_articles);static PHP_FUNCTION(bbs_getuser);static PHP_FUNCTION(bbs_getonlineuser);static PHP_FUNCTION(bbs_getonlinenumber);static PHP_FUNCTION(bbs_getonlineusernumber);static PHP_FUNCTION(bbs_getwwwguestnumber);static PHP_FUNCTION(bbs_countuser);static PHP_FUNCTION(bbs_setfromhost);static PHP_FUNCTION(bbs_checkpasswd);static PHP_FUNCTION(bbs_getcurrentuser);static PHP_FUNCTION(bbs_setonlineuser);static PHP_FUNCTION(bbs_getcurrentuinfo);static PHP_FUNCTION(bbs_wwwlogin);static PHP_FUNCTION(bbs_wwwlogoff);static PHP_FUNCTION(bbs_printansifile);static PHP_FUNCTION(bbs_getboard);static PHP_FUNCTION(bbs_checkreadperm);static PHP_FUNCTION(bbs_getbname);static PHP_FUNCTION(bbs_checkpostperm);static PHP_FUNCTION(bbs_postarticle);#ifdef HAVE_BRC_CONTROLstatic PHP_FUNCTION(bbs_brcaddread);#endifstatic PHP_FUNCTION(bbs_ann_traverse_check);static PHP_FUNCTION(bbs_ann_get_board);static PHP_FUNCTION(bbs_getboards);static PHP_FUNCTION(bbs_getarticles);static PHP_FUNCTION(bbs_get_records_from_id);static PHP_FUNCTION(bbs_get_records_from_num);static PHP_FUNCTION(bbs_get_filename_from_num);static PHP_FUNCTION(bbs_get_threads_from_id);static PHP_FUNCTION(bbs_countarticles);static PHP_FUNCTION(bbs_is_bm);static PHP_FUNCTION(bbs_getannpath);static PHP_FUNCTION(bbs_getmailnum);static PHP_FUNCTION(bbs_getmailnum2);static PHP_FUNCTION(bbs_getmails);static PHP_FUNCTION(bbs_getmailusedspace);static PHP_FUNCTION(bbs_valid_filename);static PHP_FUNCTION(bbs_can_send_mail);static PHP_FUNCTION(bbs_loadmaillist);static PHP_FUNCTION(bbs_changemaillist);static PHP_FUNCTION(bbs_getwebmsg);static PHP_FUNCTION(bbs_sendwebmsg);static PHP_FUNCTION(bbs_sethomefile);static PHP_FUNCTION(bbs_setmailfile);static PHP_FUNCTION(bbs_mail_file);static PHP_FUNCTION(bbs_update_uinfo);static PHP_FUNCTION(bbs_createnewid);static PHP_FUNCTION(bbs_fillidinfo);static PHP_FUNCTION(bbs_createregform);static PHP_FUNCTION(bbs_findpwd_check);static PHP_FUNCTION(bbs_delfile);static PHP_FUNCTION(bbs_delmail);static PHP_FUNCTION(bbs_normalboard);static PHP_FUNCTION(bbs_setmailreaded);static PHP_FUNCTION(bbs_add_import_path);static PHP_FUNCTION(bbs_get_import_path);static PHP_FUNCTION(bbs_new_board);static PHP_FUNCTION(bbs_set_onboard);static PHP_FUNCTION(bbs_get_votes);static PHP_FUNCTION(bbs_get_vote_from_num);static PHP_FUNCTION(bbs_vote_num);static PHP_FUNCTION(bbs_get_explain);static PHP_FUNCTION(bbs_start_vote);/* favboard operation. by caltary  */static PHP_FUNCTION(bbs_load_favboard);static PHP_FUNCTION(bbs_fav_boards);static PHP_FUNCTION(bbs_release_favboard);static PHP_FUNCTION(bbs_is_favboard);static PHP_FUNCTION(bbs_add_favboarddir);static PHP_FUNCTION(bbs_add_favboard);static PHP_FUNCTION(bbs_del_favboard);static PHP_FUNCTION(bbs_sysconf_str);static PHP_FUNCTION(bbs_get_tmpls);static PHP_FUNCTION(bbs_get_tmpl_from_num);static PHP_FUNCTION(bbs_make_tmpl_file);#ifdef SMS_SUPPORTstatic PHP_FUNCTION(bbs_send_sms);static PHP_FUNCTION(bbs_register_sms_sendcheck);static PHP_FUNCTION(bbs_register_sms_docheck);static PHP_FUNCTION(bbs_unregister_sms);#endif#if HAVE_MYSQL == 1static PHP_FUNCTION(bbs_csv_to_al);#endifstatic PHP_FUNCTION(bbs_printoriginfile);static PHP_FUNCTION(bbs_caneditfile);static PHP_FUNCTION(bbs_updatearticle);static PHP_FUNCTION(bbs_getthreadnum);static PHP_FUNCTION(bbs_getthreads);/* * define what functions can be used in the PHP embedded script */static function_entry smth_bbs_functions[] = {#ifdef HAVE_WFORUM    PHP_FE(bbs_get_article, NULL)        PHP_FE(bbs_is_yank, NULL)        PHP_FE(bbs_alter_yank, NULL)#endif        PHP_FE(bbs_getonline_user_list, NULL)        PHP_FE(bbs_get_elite_num, NULL)        PHP_FE(bbs_get_elite_list, NULL)#ifdef HAVE_USERMONEY        PHP_FE(bbs_getusermoney, NULL)        PHP_FE(bbs_setusermoney, NULL)        PHP_FE(bbs_addusermoney, NULL)        PHP_FE(bbs_getuserscore, NULL)        PHP_FE(bbs_setuserscore, NULL)        PHP_FE(bbs_adduserscore, NULL)        PHP_FE(bbs_saveuserdata, NULL)#endif        PHP_FE(bbs_getuserparam, NULL)        PHP_FE(bbs_setuserparam, NULL)        PHP_FE(bbs_checkuserpasswd, NULL)        PHP_FE(bbs_setuserpasswd, NULL)        PHP_FE(bbs_getuserlevel, NULL)        PHP_FE(bbs_get_today_article_num, NULL)        PHP_FE(bbs_searchtitle, NULL)        PHP_FE(bbs_getnumofsig, NULL)        PHP_FE(bbs_postmail, NULL)        PHP_FE(bbs_mailwebmsgs, NULL)        PHP_FE(bbs_getwebmsgs, NULL)        PHP_FE(bbs_get_thread_article_num, NULL)        PHP_FE(bbs_get_thread_articles, NULL)        PHP_FE(bbs_getthreads, NULL)        PHP_FE(bbs_getthreadnum, NULL)        PHP_FE(bbs_getuser, NULL)        PHP_FE(bbs_getonlineuser, NULL)        PHP_FE(bbs_getonlinenumber, NULL)        PHP_FE(bbs_getonlineusernumber, NULL)        PHP_FE(bbs_getwwwguestnumber, NULL)        PHP_FE(bbs_countuser, NULL)        PHP_FE(bbs_setfromhost, NULL)        PHP_FE(bbs_checkpasswd, NULL)        PHP_FE(bbs_getcurrentuser, NULL)        PHP_FE(bbs_setonlineuser, NULL)        PHP_FE(bbs_getcurrentuinfo, NULL)        PHP_FE(bbs_wwwlogin, NULL)        PHP_FE(bbs_wwwlogoff, NULL)        PHP_FE(bbs_printansifile, NULL)        PHP_FE(bbs_printoriginfile, NULL)        PHP_FE(bbs_caneditfile, NULL)        PHP_FE(bbs_checkreadperm, NULL)        PHP_FE(bbs_getbname, NULL)        PHP_FE(bbs_checkpostperm, NULL)        PHP_FE(bbs_updatearticle, NULL)#ifdef HAVE_BRC_CONTROL        PHP_FE(bbs_brcaddread, NULL)#endif        PHP_FE(bbs_getboard, NULL)        PHP_FE(bbs_postarticle, NULL)        PHP_FE(bbs_ann_traverse_check, NULL)        PHP_FE(bbs_ann_get_board, NULL)        PHP_FE(bbs_getboards, NULL)        PHP_FE(bbs_getarticles, NULL)        PHP_FE(bbs_get_records_from_id, NULL)        PHP_FE(bbs_get_records_from_num, NULL)        PHP_FE(bbs_get_filename_from_num, NULL)        PHP_FE(bbs_get_threads_from_id, NULL)        PHP_FE(bbs_countarticles, NULL)        PHP_FE(bbs_is_bm, NULL)        PHP_FE(bbs_getannpath, NULL)        PHP_FE(bbs_getmailnum, third_arg_force_ref_011)        PHP_FE(bbs_getmailnum2, NULL)        PHP_FE(bbs_getmails, NULL)        PHP_FE(bbs_getmailusedspace, NULL)        PHP_FE(bbs_valid_filename, NULL)        PHP_FE(bbs_can_send_mail, NULL)        PHP_FE(bbs_loadmaillist, NULL)        PHP_FE(bbs_changemaillist, NULL)        PHP_FE(bbs_getwebmsg, third_arg_force_ref_1111)        PHP_FE(bbs_sendwebmsg, fourth_arg_force_ref_0001)        PHP_FE(bbs_sethomefile, NULL)        PHP_FE(bbs_setmailfile, NULL)        PHP_FE(bbs_mail_file, NULL)        PHP_FE(bbs_update_uinfo, NULL)        PHP_FE(bbs_createnewid, NULL)        PHP_FE(bbs_createregform, NULL)        PHP_FE(bbs_findpwd_check, NULL)        PHP_FE(bbs_fillidinfo, NULL)        PHP_FE(bbs_delfile, NULL)        PHP_FE(bbs_delmail, NULL)        PHP_FE(bbs_normalboard, NULL)        PHP_FE(bbs_setmailreaded, NULL)        PHP_FE(bbs_add_import_path, NULL)        PHP_FE(bbs_get_import_path, NULL)        PHP_FE(bbs_new_board, NULL)        PHP_FE(bbs_set_onboard, NULL)        PHP_FE(bbs_get_votes, NULL)        PHP_FE(bbs_get_vote_from_num, NULL)        PHP_FE(bbs_vote_num, NULL)        PHP_FE(bbs_get_explain, NULL)        PHP_FE(bbs_start_vote, NULL)        /*         * favboard operation. by caltary           */        PHP_FE(bbs_load_favboard, NULL)        PHP_FE(bbs_fav_boards, NULL)        PHP_FE(bbs_release_favboard, NULL)        PHP_FE(bbs_is_favboard, NULL)        PHP_FE(bbs_add_favboarddir, NULL)        PHP_FE(bbs_add_favboard, NULL)        PHP_FE(bbs_del_favboard, NULL)        PHP_FE(bbs_sysconf_str, NULL)        PHP_FE(bbs_get_tmpls, NULL)        PHP_FE(bbs_get_tmpl_from_num, NULL)        PHP_FE(bbs_make_tmpl_file, NULL)#ifdef SMS_SUPPORT        PHP_FE(bbs_send_sms, NULL)        PHP_FE(bbs_register_sms_sendcheck, NULL)        PHP_FE(bbs_unregister_sms, NULL)        PHP_FE(bbs_register_sms_docheck, NULL)#endif#if HAVE_MYSQL == 1        PHP_FE(bbs_csv_to_al, NULL)#endif    {NULL, NULL, NULL}};/* * This is the module entry structure, and some properties */zend_module_entry smth_bbs_module_entry = {    STANDARD_MODULE_HEADER,    "smth_bbs",    smth_bbs_functions,    PHP_MINIT(smth_bbs),    PHP_MSHUTDOWN(smth_bbs),    PHP_RINIT(smth_bbs),        /* Replace with NULL if there's nothing to do at request start */    PHP_RSHUTDOWN(smth_bbs),    /* Replace with NULL if there's nothing to do at request end */    PHP_MINFO(smth_bbs),    "1.0",                      /* Replace with version number for your extension */    STANDARD_MODULE_PROPERTIES};/* }}} */#ifdef COMPILE_DL_SMTH_BBSZEND_GET_MODULE(smth_bbs)#endif/* * Here is the function require when the module loadedDLEXPORT zend_module_entry *get_module(){    return &smth_bbs_module_entry;};static void setstrlen(pval * arg){    arg->value.str.len = strlen(arg->value.str.val);} */static void assign_user(zval * array, struct userec *user, int num){    struct userdata ud;    read_userdata(user->userid, &ud);    add_assoc_long(array, "index", num);    add_assoc_string(array, "userid", user->userid, 1);    add_assoc_long(array, "firstlogin", user->firstlogin);    add_assoc_stringl(array, "lasthost", user->lasthost, IPLEN, 1);    add_assoc_long(array, "numlogins", user->numlogins);    add_assoc_long(array, "numposts", user->numposts);    add_assoc_long(array, "flag1", user->flags);    add_assoc_long(array, "title", user->title);    add_assoc_string(array, "username", user->username, 1);    add_assoc_stringl(array, "md5passwd", (char *) user->md5passwd, 16, 1);    add_assoc_string(array, "realemail", ud.realemail, 1);    add_assoc_long(array, "userlevel", user->userlevel);    add_assoc_long(array, "lastlogin", user->lastlogin);    add_assoc_long(array, "stay", user->stay);    add_assoc_string(array, "realname", ud.realname, 1);    add_assoc_string(array, "address", ud.address, 1);    add_assoc_string(array, "email", ud.email, 1);    add_assoc_long(array, "signature", user->signature);    add_assoc_long(array, "userdefine", user->userdefine);    add_assoc_long(array, "notedate", user->notedate);    add_assoc_long(array, "noteline", user->noteline);    add_assoc_long(array, "notemode", user->notemode);#ifdef HAVE_USERMONEY    add_assoc_long(array, "money", user->money);    add_assoc_long(array, "score", user->score);#endif#ifdef HAVE_BIRTHDAY    add_assoc_long(array, "gender", ud.gender);    add_assoc_long(array, "birthyear", ud.birthyear);    add_assoc_long(array, "birthmonth", ud.birthmonth);    add_assoc_long(array, "birthday", ud.birthday);#endif    add_assoc_string(array, "reg_email", ud.reg_email, 1);    add_assoc_long(array, "mobilderegistered", ud.mobileregistered);    add_assoc_string(array, "mobilenumber", ud.mobilenumber, 1);#ifdef HAVE_WFORUM    add_assoc_string(array, "OICQ", ud.OICQ, 1);    add_assoc_string(array, "ICQ", ud.ICQ, 1);    add_assoc_string(array, "MSN", ud.MSN, 1);    add_assoc_string(array, "homepage", ud.homepage, 1);    add_assoc_long(array, "userface_img", ud.userface_img);    add_assoc_string(array, "userface_url", ud.userface_url, 1);    add_assoc_long(array, "userface_width", ud.userface_width);    add_assoc_long(array, "userface_height", ud.userface_height);    add_assoc_long(array, "group", ud.group);    add_assoc_string(array, "country", ud.country, 1);    add_assoc_string(array, "province", ud.province, 1);    add_assoc_string(array, "city", ud.city, 1);    add_assoc_long(array, "shengxiao", ud.shengxiao);    add_assoc_long(array, "bloodtype", ud.bloodtype);    add_assoc_long(array, "religion", ud.religion);    add_assoc_long(array, "profession", ud.profession);    add_assoc_long(array, "married", ud.married);    add_assoc_long(array, "education", ud.education);    add_assoc_string(array, "graduateschool", ud.graduateschool, 1);    add_assoc_long(array, "character", ud.character);    add_assoc_string(array, "photo_url", ud.photo_url, 1);    add_assoc_string(array, "telephone", ud.telephone, 1);#endif}static int foundInArray(unsigned int content, unsigned int array[], unsigned int len){    int i;    for (i = 0; i < len; i++) {        if (array[i] == content) {            return i;        }    }    return -1;}static void assign_userinfo(zval * array, struct user_info *uinfo, int num){    add_assoc_long(array, "index", num);    add_assoc_long(array, "active", uinfo->active);    add_assoc_long(array, "uid", uinfo->uid);    add_assoc_long(array, "pid", uinfo->pid);    add_assoc_long(array, "invisible", uinfo->invisible);    add_assoc_long(array, "sockactive", uinfo->sockactive);    add_assoc_long(array, "sockaddr", uinfo->sockaddr);    add_assoc_long(array, "destuid", uinfo->destuid);    add_assoc_long(array, "mode", uinfo->mode);    add_assoc_long(array, "pager", uinfo->pager);    add_assoc_long(array, "in_chat", uinfo->in_chat);    add_assoc_string(array, "chatid", uinfo->chatid, 1);    add_assoc_string(array, "from", uinfo->from, 1);    add_assoc_long(array, "logintime", uinfo->logintime);    add_assoc_long(array, "freshtime", uinfo->freshtime);    add_assoc_long(array, "utmpkey", uinfo->utmpkey);    add_assoc_string(array, "userid", uinfo->userid, 1);    add_assoc_string(array, "realname", uinfo->realname, 1);    add_assoc_string(array, "username", uinfo->username, 1);}//char* maillist, 40 bytes long, 30 bytes for the mailbox name,10 bytes for the mailbox path file name.static void asssign_maillist(zval * array, char *boxname, char *pathname){    add_assoc_string(array, "boxname", boxname, 1);    add_assoc_string(array, "pathname", pathname, 1);}static void assign_board(zval * array, const struct boardheader *board, const struct BoardStatus *bstatus, int num){    add_assoc_long(array, "NUM", num);    add_assoc_string(array, "NAME", board->filename, 1);    /*     * add_assoc_string(array, "OWNER", board->owner, 1);     */    add_assoc_string(array, "BM", board->BM, 1);    add_assoc_long(array, "FLAG", board->flag);    add_assoc_string(array, "DESC", board->title + 13, 1);    add_assoc_stringl(array, "CLASS", board->title + 1, 6, 1);    add_assoc_stringl(array, "SECNUM", board->title, 1, 1);    add_assoc_long(array, "LEVEL", board->level);    add_assoc_long(array, "CURRENTUSERS", bstatus->currentusers);    add_assoc_long(array, "TOTAL", bstatus->total);}static int currentusernum;static char fullfrom[255];static char php_fromhost[IPLEN + 1];static struct user_info *currentuinfo;static int currentuinfonum;static inline struct userec *getcurrentuser(){    return currentuser;}static inline struct user_info *getcurrentuinfo(){    return currentuinfo;}static inline void setcurrentuinfo(struct user_info *uinfo, int uinfonum){    currentuinfo = uinfo;    currentuinfonum = uinfonum;}static inline void setcurrentuser(struct userec *user, int usernum){    currentuser = user;    currentusernum = usernum;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?