NEOERR* inbox_multi_add(HDF *datanode, HASH *evth, char *inboxtype) { mevent_t *evt; int mid; HDF *child; NEOERR *err; MCS_NOT_NULLB(datanode, evth); evt = hash_lookup(evth, "aux"); MCS_NOT_NULLA(evt); child = hdf_obj_child(datanode); while (child) { mid = hdf_get_int_value(child, "mid", 0); if (mid > 0) { hdf_set_valuef(evt->hdfsnd, "mmid.%d=%d", mid, mid); } child = hdf_obj_next(child); } if (!hdf_get_obj(evt->hdfsnd, "mmid")) return nerr_raise(NERR_ASSERT, "请设置收信用户号码"); err = mtpl_InConfigRend_get(evt->hdfsnd, datanode, "inbox", inboxtype, g_datah); if (err != STATUS_OK) return nerr_pass(err); MEVENT_TRIGGER(evt, NULL, REQ_CMD_AUX_INBOX_ADD, FLAGS_NONE); return STATUS_OK; }
NEOERR* member_reset_data_get(CGI *cgi, HASH *dbh, HASH *evth, session_t *ses) { mevent_t *evt; char *mnick, *mname, *mname_esc = NULL; char rlink[LEN_CK]; NEOERR *err; HDF_GET_STR(cgi->hdf, PRE_QUERY".mname", mname); mstr_rand_string(rlink, sizeof(rlink)); evt = (mevent_t*)hash_lookup(evth, "member"); MCS_NOT_NULLB(cgi->hdf, evt); hdf_set_value(evt->hdfsnd, "mname", mname); hdf_set_value(evt->hdfsnd, "rlink", rlink); MEVENT_TRIGGER(evt, mname, REQ_CMD_MEMBER_SETRLINK, FLAGS_SYNC); mnick = hdf_get_value(evt->hdfrcv, "mnick", NULL); neos_url_escape(mname, &mname_esc, NULL); hdf_set_value(cgi->hdf, PRE_DATASET".Layout.mnick", mnick); hdf_set_value(cgi->hdf, PRE_DATASET".Layout.mname_esc", mname_esc); hdf_set_value(cgi->hdf, PRE_DATASET".Layout.rlink", rlink); err = email_add(cgi->hdf, evth, "MemberReset", mname); if (err != STATUS_OK) return nerr_pass(err); SAFE_FREE(mname_esc); return STATUS_OK; }
NEOERR* member_new_data_add(CGI *cgi, HASH *dbh, HASH *evth, session_t *ses) { mevent_t *evt = hash_lookup(evth, "member"); char *mnick, *mname, *mid; MCS_NOT_NULLB(cgi->hdf, evt); HDF_GET_STR(cgi->hdf, PRE_QUERY".mnick", mnick); HDF_GET_STR(cgi->hdf, PRE_QUERY".mname", mname); LEGAL_CHECK_NICK(mnick); LEGAL_CHECK_NAME(mname); hdf_copy(evt->hdfsnd, NULL, hdf_get_obj(cgi->hdf, PRE_QUERY)); MEVENT_TRIGGER(evt, mname, REQ_CMD_MEMBER_ADD, FLAGS_SYNC); mid = hdf_get_value(evt->hdfrcv, "mid", NULL); member_after_login(cgi, evth, mname, mnick, mid); char *s; HDF_FETCH_STR(cgi->hdf, PRE_QUERY".mnick", s); hdf_set_value(cgi->hdf, PRE_RESERVE".event.es_one", s); HDF_FETCH_STR(cgi->hdf, PRE_QUERY".mname", s); hdf_set_value(cgi->hdf, PRE_RESERVE".event.es_two", s); HDF *node = hdf_get_obj(cgi->hdf, PRE_RESERVE".event"); return nerr_pass(trace_event(node, evth, ses, TRACE_TYPE_MEMBER_REG)); }
NEOERR* system_plan_data_get(CGI *cgi, HASH *dbh, HASH *evth, session_t *ses) { mdb_conn *db = hash_lookup(dbh, "plan"); STRING str; string_init(&str); int count, offset; char *mname; HDF *node; NEOERR *err; MCS_NOT_NULLB(cgi->hdf, db); MEMBER_CHECK_ADMIN(); SET_DASHBOARD_ACTION(cgi->hdf); hdf_get_node(cgi->hdf, PRE_OUTPUT, &node); mdb_pagediv(hdf_get_obj(cgi->hdf, PRE_QUERY), NULL, &count, &offset, NULL, node); err = mdb_build_querycond(hdf_get_obj(cgi->hdf, PRE_QUERY), hdf_get_obj(g_cfg, "Db.QueryCond.system.plan"), &str, "intime > current_date - 1"); if (err != STATUS_OK) return nerr_pass(err); MDB_PAGEDIV_SET_N(node, db, "plan", "%s", NULL, str.buf); MDB_QUERY_RAW(db, "plan", _COL_PLAN_ADMIN, "%s ORDER BY id DESC LIMIT %d OFFSET %d", NULL, str.buf, count, offset); err = mdb_set_rows(cgi->hdf, db, _COL_PLAN_ADMIN, PRE_OUTPUT".rows", NULL, MDB_FLAG_EMPTY_OK); if (err != STATUS_OK) return nerr_pass(err); return STATUS_OK; }
NEOERR* system_who_data_get(CGI *cgi, HASH *dbh, HASH *evth, session_t *ses) { STRING str; string_init(&str); mdb_conn *db = hash_lookup(dbh, "trace"); char *mname; NEOERR *err; MCS_NOT_NULLB(cgi->hdf, db); MEMBER_CHECK_ADMIN(); SET_DASHBOARD_ACTION(cgi->hdf); hdf_set_int_value(cgi->hdf, PRE_QUERY".type", TRACE_TYPE_PAGEVIEW); err = mdb_build_querycond(hdf_get_obj(cgi->hdf, PRE_QUERY), hdf_get_obj(g_cfg, "Db.QueryCond.system.who"), &str, NULL); if (err != STATUS_OK) return nerr_pass(err); MDB_QUERY_RAW(db, "emap", _COL_EMAP_WHO, " %s GROUP BY sender ORDER BY min(intime) DESC LIMIT 100", NULL, str.buf); err = mdb_set_rows(cgi->hdf, db, _COL_EMAP_WHO, PRE_OUTPUT".who", NULL, MDB_FLAG_EMPTY_OK); if (err != STATUS_OK) return nerr_pass(err); string_clear(&str); hdf_set_attr(cgi->hdf, PRE_OUTPUT".who", "type", "array"); return STATUS_OK; }
NEOERR* system_view_detail_data_get(CGI *cgi, HASH *dbh, HASH *evth, session_t *ses) { STRING str; string_init(&str); mdb_conn *db = hash_lookup(dbh, "trace"); char *mname; NEOERR *err; MCS_NOT_NULLB(cgi->hdf, db); MEMBER_CHECK_ADMIN(); SET_DASHBOARD_ACTION(cgi->hdf); err = mdb_build_querycond(hdf_get_obj(cgi->hdf, PRE_QUERY), hdf_get_obj(g_cfg, "Db.QueryCond.system.viewdetail"), &str, NULL); if (err != STATUS_OK) return nerr_pass(err); MDB_QUERY_RAW(db, "emap", _COL_EMAP_VIEW_DETAIL, " %s ORDER BY intime LIMIT 100", NULL, str.buf); err = mdb_set_rows(cgi->hdf, db, _COL_EMAP_VIEW_DETAIL, PRE_OUTPUT".details", NULL, MDB_FLAG_EMPTY_OK); if (err != STATUS_OK) return nerr_pass(err); string_clear(&str); hdf_set_attr(cgi->hdf, PRE_OUTPUT".details", "type", "array"); return STATUS_OK; }
NEOERR* system_comment_data_get(CGI *cgi, HASH *dbh, HASH *evth, session_t *ses) { mdb_conn *db = hash_lookup(dbh, "aux"); STRING str; string_init(&str); char *mname; NEOERR *err; MCS_NOT_NULLB(cgi->hdf, db); MEMBER_CHECK_ADMIN(); SET_DASHBOARD_ACTION(cgi->hdf); if (!hdf_get_value(cgi->hdf, PRE_QUERY".times", NULL)) hdf_set_value(cgi->hdf, PRE_QUERY".timed", "current_date - 7"); err = mdb_build_querycond(hdf_get_obj(cgi->hdf, PRE_QUERY), hdf_get_obj(g_cfg, "Db.QueryCond.system.comment"), &str, NULL); if (err != STATUS_OK) return nerr_pass(err); MDB_QUERY_RAW(db, "comment", _COL_CMT, "%s ORDER BY id DESC", NULL, str.buf); err = mdb_set_rows(cgi->hdf, db, _COL_CMT, PRE_OUTPUT".rows", NULL, MDB_FLAG_EMPTY_OK); if (err != STATUS_OK) return nerr_pass(err); return STATUS_OK; }
NEOERR* member_home_data_get(CGI *cgi, HASH *dbh, HASH *evth, session_t *ses) { mevent_t *evt = hash_lookup(evth, "member"); char *mname = NULL; int mid; NEOERR *err; MCS_NOT_NULLB(cgi->hdf, evt); HDF_FETCH_INT(cgi->hdf, PRE_QUERY".mid", mid); if (mid == 0) { MEMBER_CHECK_LOGIN(); } else { hdf_set_int_value(evt->hdfsnd, "mid", mid); MEVENT_TRIGGER(evt, NULL, REQ_CMD_MEMBER_GET, FLAGS_SYNC); hdf_copy(cgi->hdf, PRE_OUTPUT".member", evt->hdfrcv); } evt = hash_lookup(evth, "plan"); MCS_NOT_NULLA(evt); if (mname) hdf_set_value(evt->hdfsnd, "mname", mname); hdf_copy(evt->hdfsnd, NULL, hdf_get_obj(cgi->hdf, PRE_QUERY)); hdf_set_value(evt->hdfsnd, "_npp", "5"); hdf_set_value(evt->hdfsnd, "_guest", "1"); MEVENT_TRIGGER(evt, NULL, REQ_CMD_PLAN_MINE, FLAGS_SYNC); hdf_copy(cgi->hdf, PRE_OUTPUT, evt->hdfrcv); return STATUS_OK; }
NEOERR* member_check_login_data_get(CGI *cgi, HASH *dbh, HASH *evth, session_t *ses) { mdb_conn *db = hash_lookup(dbh, "main"); char *mname, *mmsn; NEOERR *err; MCS_NOT_NULLB(cgi->hdf, db); HDF_FETCH_STR(cgi->hdf, PRE_QUERY".mname", mname); HDF_FETCH_STR(cgi->hdf, PRE_QUERY".mmsn", mmsn); if (!mname || !mmsn) { HDF_GET_STR_IDENT(cgi->hdf, PRE_COOKIE".mname", mname); HDF_GET_STR_IDENT(cgi->hdf, PRE_COOKIE".mmsn", mmsn); } hdf_set_value(cgi->hdf, PRE_RESERVE".mname", mname); MDB_QUERY_RAW(db, "member", _COL_MEMBER, "mname=$1", "s", mname); err = mdb_set_row(cgi->hdf, db, _COL_MEMBER, PRE_OUTPUT".member", MDB_FLAG_Z); if (err != STATUS_OK) return nerr_pass(err); char *mmsndb = hdf_get_value(cgi->hdf, PRE_OUTPUT".member.mmsn", NULL); if (!mmsndb || strcmp(mmsndb, mmsn)) { hdf_remove_tree(cgi->hdf, PRE_OUTPUT".member"); return nerr_raise(LERR_NOTLOGIN, "msn don't match"); } return STATUS_OK; }
NEOERR* mimg_create_from_string(char *s, char *path, double size, void **pic) { gdImagePtr im; int draw, back, brect[8], x, y; char *gderr; MCS_NOT_NULLB(s, pic); gderr = gdImageStringFT(NULL, &brect[0], 0, path, size, 0., 0, 0, s); if (gderr) return nerr_raise(NERR_ASSERT, "create image failure %s", gderr); x = brect[2]-brect[6] + 6; y = brect[3]-brect[7] + 6; im = gdImageCreate(x, y); if (!im) return nerr_raise(NERR_ASSERT, "create image failure"); /* background color */ back = gdImageColorResolve(im, 252, 252, 252); /* foreground color */ draw = gdImageColorResolve(im, 150, 40, 40); x = 3 - brect[6]; y = 3 - brect[7]; gderr = gdImageStringFT(im, &brect[0], draw, path, size, 0.0, x, y, s); if (gderr) return nerr_raise(NERR_ASSERT, "rend image failure %s", gderr); *pic = (void*)im; return STATUS_OK; }
NEOERR* member_exist_data_get(CGI *cgi, HASH *dbh, HASH *evth, session_t *ses) { mevent_t *evt = hash_lookup(evth, "member"); char *mname; MCS_NOT_NULLB(cgi->hdf, evt); HDF_GET_STR(cgi->hdf, PRE_QUERY".mname", mname); hdf_set_value(evt->hdfsnd, "mname", mname); mevent_trigger(evt, mname, REQ_CMD_MEMBER_GET, FLAGS_SYNC); if (PROCESS_OK(evt->errcode)) { hdf_set_value(cgi->hdf, PRE_OUTPUT".exist", "1"); hdf_set_value(cgi->hdf, PRE_OUTPUT".msg", "用户已被注册"); } else if (evt->errcode == LERR_MEMBER_NEXIST) { hdf_set_value(cgi->hdf, PRE_OUTPUT".exist", "0"); hdf_set_value(cgi->hdf, PRE_OUTPUT".msg", "用户还未注册"); } else { return nerr_raise(evt->errcode, "get member %s info failure %d", evt->ename, evt->errcode); } return STATUS_OK; }
NEOERR* member_pic_data_get(CGI *cgi, HASH *dbh, HASH *evth, session_t *ses) { mevent_t *evt = hash_lookup(evth, "member"); HDF *node; char *s = NULL, *defs = NULL, *path, *size; MCS_NOT_NULLB(cgi->hdf, evt); HDF_FETCH_STR(cgi->hdf, PRE_QUERY".defs", defs); HDF_FETCH_STR(cgi->hdf, PRE_QUERY".fpath", path); HDF_FETCH_STR(cgi->hdf, PRE_QUERY".fsize", size); node = hdf_get_child(cgi->hdf, PRE_QUERY".type"); if (!node) HDF_GET_STR(cgi->hdf, PRE_QUERY".type", s); hdf_copy(evt->hdfsnd, NULL, hdf_get_obj(cgi->hdf, PRE_QUERY)); MEVENT_TRIGGER(evt, NULL, REQ_CMD_MEMBER_PRIV_GET, FLAGS_SYNC); if (s) goto getval; while (node) { s = hdf_obj_value(node); getval: /* * turn & into & in url format */ mstr_html_unescape(evt->hdfrcv, s); s = hdf_get_value(evt->hdfrcv, s, NULL); if (s && *s) { if (!strncmp(s, "http:", 5)) { hdf_set_value(cgi->hdf, PRE_OUTPUT".302", s); return STATUS_OK; } break; } if (node) node = hdf_obj_next(node); } if (!s || !*s) { if (!defs) s = SITE_DOMAIN; else if (!strcmp(defs, "segv")) return STATUS_OK; else s = defs; } if (!path) path = hdf_get_value(g_cfg, "Config.font.member.path", "/usr/share/ttf/Times.ttf"); if (!size) size = hdf_get_value(g_cfg, "Config.font.member.size", "14."); return nerr_pass(mimg_create_from_string(s, path, atof(size), &ses->data)); }
NEOERR* mcs_hdf_copy_rep(HDF *dst, char *name, HDF *src, HDF *data) { NEOERR *err; MCS_NOT_NULLB(dst, src); err = hdf_copy(dst, name, src); if (err != STATUS_OK) return nerr_pass(err); mcs_hdf_rep(data, hdf_get_obj(dst, name)); return STATUS_OK; }
NEOERR* member_logout_data_get(CGI *cgi, HASH *dbh, HASH *evth, session_t *ses) { mdb_conn *db = hash_lookup(dbh, "main"); char *mname; NEOERR *err; MCS_NOT_NULLB(cgi->hdf, db); MEMBER_CHECK_LOGIN(); MDB_EXEC(db, NULL, "UPDATE member SET mmsn='0' WHERE mname=$1", "s", mname); return STATUS_OK; }
NEOERR* mfile_copy(FILE *dst, FILE *src) { char buf[1048576]; size_t len; MCS_NOT_NULLB(dst, src); fseek(dst, 0, SEEK_SET); fseek(src, 0, SEEK_SET); while ((len = fread(buf, 1, sizeof(buf), src)) > 0) { fwrite(buf, 1, len, dst); } return STATUS_OK; }
NEOERR* member_car_data_mod(CGI *cgi, HASH *dbh, HASH *evth, session_t *ses) { mevent_t *evt = hash_lookup(evth, "member"); char *mname; NEOERR *err; MCS_NOT_NULLB(cgi->hdf, evt); MEMBER_CHECK_LOGIN(); hdf_set_value(evt->hdfsnd, "mname", mname); hdf_copy(evt->hdfsnd, NULL, hdf_get_obj(cgi->hdf, PRE_QUERY)); MEVENT_TRIGGER(evt, mname, REQ_CMD_CAR_UP, FLAGS_NONE); return STATUS_OK; }
NEOERR* city_id_data_get(CGI *cgi, HASH *dbh, HASH *evth, session_t *ses) { mevent_t *evt = hash_lookup(evth, "city"); char *id; MCS_NOT_NULLB(cgi->hdf, evt); HDF_GET_STR(cgi->hdf, PRE_QUERY".id", id); hdf_set_value(evt->hdfsnd, "id", id); MEVENT_TRIGGER(evt, NULL, REQ_CMD_CITY_BY_ID, FLAGS_SYNC); hdf_copy(cgi->hdf, PRE_OUTPUT, evt->hdfrcv); return STATUS_OK; }
NEOERR* inbox_data_del(CGI *cgi, HASH *dbh, HASH *evth, session_t *ses) { mevent_t *evt = hash_lookup(evth, "aux"); char *mname; NEOERR *err; MCS_NOT_NULLB(cgi->hdf, evt); MEMBER_CHECK_LOGIN(); hdf_copy(evt->hdfsnd, NULL, hdf_get_obj(cgi->hdf, PRE_QUERY)); hdf_set_value(evt->hdfsnd, "mname", mname); MEVENT_TRIGGER(evt, NULL, REQ_CMD_AUX_INBOX_DEL, FLAGS_NONE); return STATUS_OK; }
NEOERR* member_logout_data_get(CGI *cgi, HASH *dbh, HASH *evth, session_t *ses) { mevent_t *evt = hash_lookup(evth, "member"); char *mname; NEOERR *err; MCS_NOT_NULLB(cgi->hdf, evt); MEMBER_CHECK_LOGIN(); hdf_set_value(evt->hdfsnd, "mname", mname); hdf_set_value(evt->hdfsnd, "mmsn", "0"); MEVENT_TRIGGER(evt, mname, REQ_CMD_MEMBER_UP, FLAGS_NONE); return STATUS_OK; }
NEOERR* inbox_system_data_get(CGI *cgi, HASH *dbh, HASH *evth, session_t *ses) { mevent_t *evt = hash_lookup(evth, "aux"); char *mname; NEOERR *err; MCS_NOT_NULLB(cgi->hdf, evt); MEMBER_CHECK_LOGIN(); SET_DASHBOARD_ACTION(cgi->hdf); hdf_copy(evt->hdfsnd, NULL, hdf_get_obj(cgi->hdf, PRE_QUERY)); hdf_set_value(evt->hdfsnd, "mname", mname); MEVENT_TRIGGER(evt, mname, REQ_CMD_AUX_INBOX_GET, FLAGS_SYNC); hdf_copy(cgi->hdf, PRE_OUTPUT, evt->hdfrcv); return STATUS_OK; }
NEOERR* base_msg_touser(char *cmd, HDF *datanode, int fd) { unsigned char *buf; size_t len; NEOERR *err; MCS_NOT_NULLB(cmd, datanode); err = base_msg_new(cmd, datanode, &buf, &len); if (err != STATUS_OK) return nerr_pass(err); err = base_msg_send(buf, len, fd); if (err != STATUS_OK) return nerr_pass(err); base_msg_free(buf); return STATUS_OK; }
NEOERR* mmg_count(mmg_conn *db, char *dbname, char *collname, int *ret, char *querys) { bson *doc; MCS_NOT_NULLC(db, dbname, collname); MCS_NOT_NULLB(querys, ret); mtc_noise("count %s.%s %s", dbname, collname, querys); doc = mbson_new_from_string(querys, true); if (!doc) return nerr_raise(NERR_ASSERT, "build doc: %s: %s", querys, strerror(errno)); *ret = (int)mongo_sync_cmd_count(db->con, dbname, collname, doc); bson_free(doc); return STATUS_OK; }
NEOERR* member_login_data_get(CGI *cgi, HASH *dbh, HASH *evth, session_t *ses) { mevent_t *evt = hash_lookup(evth, "member"); char *mname, *msn; MCS_NOT_NULLB(cgi->hdf, evt); HDF_GET_STR(cgi->hdf, PRE_QUERY".mname", mname); HDF_GET_STR(cgi->hdf, PRE_QUERY".msn", msn); hdf_set_value(evt->hdfsnd, "mname", mname); hdf_set_value(evt->hdfsnd, "msn", msn); MEVENT_TRIGGER(evt, mname, REQ_CMD_MEMBER_CHECK_MSN, FLAGS_SYNC); char *mnick = hdf_get_value(evt->hdfrcv, "mnick", "嘀嗒"); char *mid = hdf_get_value(evt->hdfrcv, "mid", NULL); member_after_login(cgi, evth, mname, mnick, mid); return STATUS_OK; }
NEOERR* member_info_data_get(CGI *cgi, HASH *dbh, HASH *evth, session_t *ses) { mevent_t *evt = hash_lookup(evth, "member"); char *mname; NEOERR *err; MCS_NOT_NULLB(cgi->hdf, evt); mname = hdf_get_value(cgi->hdf, PRE_QUERY".mname", NULL); if (!mname) { MEMBER_CHECK_LOGIN(); hdf_set_value(evt->hdfsnd, "mname", mname); MEVENT_TRIGGER(evt, NULL, REQ_CMD_MEMBER_PRIV_GET, FLAGS_SYNC); } else { hdf_set_value(evt->hdfsnd, "mname", mname); MEVENT_TRIGGER(evt, NULL, REQ_CMD_MEMBER_GET, FLAGS_SYNC); } hdf_copy(cgi->hdf, PRE_OUTPUT".member", evt->hdfrcv); return STATUS_OK; }
NEOERR* member_login_data_get(CGI *cgi, HASH *dbh, HASH *evth, session_t *ses) { mdb_conn *db = hash_lookup(dbh, "main"); char *mname, *msn; NEOERR *err; MCS_NOT_NULLB(cgi->hdf, db); HDF_GET_STR(cgi->hdf, PRE_QUERY".mname", mname); HDF_GET_STR(cgi->hdf, PRE_QUERY".msn", msn); MDB_QUERY_RAW(db, "member", _COL_MEMBER, "mname=$1", "s", mname); err = mdb_set_row(cgi->hdf, db, _COL_MEMBER, PRE_OUTPUT".member", MDB_FLAG_Z); if (err != STATUS_OK) return nerr_pass(err); char *msndb = hdf_get_value(cgi->hdf, PRE_OUTPUT".member.msn", NULL); if (!msndb || strcmp(msndb, msn)) { hdf_remove_tree(cgi->hdf, PRE_OUTPUT".member"); return nerr_raise(LERR_LOGINPSW, "msn incorrct"); } return nerr_pass(member_after_login(cgi, dbh, mname)); }
NEOERR* bore_data_get(CGI *cgi, HASH *dbh, HASH *evth, session_t *ses) { mevent_t *evt_member = hash_lookup(evth, "member"); mevent_t *evt = hash_lookup(evth, "aux"); NEOERR *err; MCS_NOT_NULLB(cgi->hdf, evt); err = member_check_login_data_get(cgi, dbh, evth, ses); if (err == STATUS_OK) { if (hdf_get_int_value(evt_member->hdfrcv, "verify", -1) >= MEMBER_VF_ADMIN) SET_ADMIN_ACTION(cgi->hdf); } nerr_ignore(&err); hdf_copy(evt->hdfsnd, NULL, hdf_get_obj(cgi->hdf, PRE_QUERY)); MEVENT_TRIGGER(evt, NULL, REQ_CMD_MEMORY_GET, FLAGS_SYNC); hdf_copy(cgi->hdf, PRE_OUTPUT".memory", evt->hdfrcv); return STATUS_OK; }
NEOERR* member_account_data_get(CGI *cgi, HASH *dbh, HASH *evth, session_t *ses) { mevent_t *evt = (mevent_t*)hash_lookup(evth, "member"); char *mnick, *mname, *mid, *rlink; NEOERR *err; MCS_NOT_NULLB(cgi->hdf, evt); HDF_FETCH_STR(cgi->hdf, PRE_QUERY".mname", mname); HDF_FETCH_STR(cgi->hdf, PRE_QUERY".rlink", rlink); if (mname && rlink) { hdf_set_value(evt->hdfsnd, "mname", mname); MEVENT_TRIGGER(evt, mname, REQ_CMD_MEMBER_GETRLINK, FLAGS_SYNC); mnick = hdf_get_value(evt->hdfrcv, "mnick", NULL); char *s = hdf_get_value(evt->hdfrcv, "rlink", NULL); if (!s || strcmp(s, rlink)) return nerr_raise(LERR_USERINPUT, "验证码错误"); hdf_set_value(evt->hdfsnd, "mname", mname); MEVENT_TRIGGER(evt, mname, REQ_CMD_MEMBER_GET, FLAGS_SYNC); hdf_copy(cgi->hdf, PRE_OUTPUT".member", evt->hdfrcv); mid = hdf_get_value(evt->hdfrcv, "mid", NULL); member_after_login(cgi, evth, mname, mnick, mid); hdf_set_value(cgi->hdf, PRE_OUTPUT".rlink", rlink); } else { MEMBER_CHECK_LOGIN(); } SET_DASHBOARD_ACTION(cgi->hdf); return STATUS_OK; }
NEOERR* email_multi_add(HDF *datanode, HASH *evth, char *emailtype) { mevent_t *evt; char *mname; HDF *child; int cnt = 0; NEOERR *err; MCS_NOT_NULLB(datanode, evth); evt = hash_lookup(evth, "aux"); MCS_NOT_NULLA(evt); child = hdf_obj_child(datanode); while (child) { mname = hdf_get_value(child, "mname", NULL); if (mname) { /* * use cnt instead of mname as hdf key because mname contain '.' */ hdf_set_valuef(evt->hdfsnd, "mto.%d=%s", cnt++, mname); } child = hdf_obj_next(child); } if (!hdf_get_obj(evt->hdfsnd, "mto")) return nerr_raise(NERR_ASSERT, "请设置收信用户名"); err = mtpl_InConfigRend_get(evt->hdfsnd, datanode, "email", emailtype, g_datah); if (err != STATUS_OK) return nerr_pass(err); MEVENT_TRIGGER(evt, NULL, REQ_CMD_AUX_EMAIL_ADD, FLAGS_NONE); return STATUS_OK; }
NEOERR* member_check_login_data_get(CGI *cgi, HASH *dbh, HASH *evth, session_t *ses) { mevent_t *evt = hash_lookup(evth, "member"); char *mname, *mmsn; MCS_NOT_NULLB(cgi->hdf, evt); HDF_FETCH_STR(cgi->hdf, PRE_QUERY".mname", mname); HDF_FETCH_STR(cgi->hdf, PRE_QUERY".mmsn", mmsn); if (!mname || !mmsn) { HDF_GET_STR_IDENT(cgi->hdf, PRE_COOKIE".mname", mname); HDF_GET_STR_IDENT(cgi->hdf, PRE_COOKIE".mmsn", mmsn); } hdf_set_value(cgi->hdf, PRE_RESERVE".mname", mname); hdf_set_value(evt->hdfsnd, "mname", mname); hdf_set_value(evt->hdfsnd, "mmsn", mmsn); MEVENT_TRIGGER(evt, mname, REQ_CMD_MEMBER_CHECK_MMSN, FLAGS_SYNC); hdf_copy(cgi->hdf, PRE_OUTPUT".member", evt->hdfrcv); return STATUS_OK; }
NEOERR* mimg_zoomout(int ftype, FILE *dst, FILE*src, int width, int height) { MCS_NOT_NULLB(dst, src); int ow, oh; gdImagePtr im; FILE *gdin, *gdout; if (width <= 0 && height <= 0) return STATUS_OK; gdin = mfile_get_std_from_safe(src); gdout = mfile_get_std_from_safe(dst); fseek(src, 0, SEEK_SET); fseek(dst, 0, SEEK_SET); switch (ftype) { case MIMG_TYPE_JPEG: im = gdImageCreateFromJpeg(gdin); break; case MIMG_TYPE_PNG: im = gdImageCreateFromPng(gdin); break; case MIMG_TYPE_GIF: im = gdImageCreateFromGif(gdin); break; case MIMG_TYPE_BMP: im = gdImageCreateFromWBMP(gdin); break; default: return nerr_raise(NERR_ASSERT, "file type %d not support", ftype); } if (!im) return nerr_raise(NERR_ASSERT, "读取图片出错,文件格式错误?"); ow = gdImageSX(im); oh = gdImageSY(im); if ((width > 0 && ow > width) || (height > 0 && oh > height)) { if (width <= 0) width = (float)height / oh * ow; if (height <= 0) height = (float)width / ow * oh; gdImagePtr dim = gdImageCreateTrueColor(width, height); gdImageCopyResized(dim, im, 0, 0, 0, 0, width, height, ow, oh); if (dim) { switch (ftype) { case MIMG_TYPE_JPEG: gdImageJpeg(dim, gdout, 70); break; case MIMG_TYPE_PNG: gdImagePng(dim, gdout); break; case MIMG_TYPE_GIF: gdImageGif(dim, gdout); break; case MIMG_TYPE_BMP: gdImageWBMP(dim, 0, gdout); break; default: return nerr_raise(NERR_ASSERT, "file type %d not suport", ftype); } } else return nerr_raise(NERR_ASSERT, "resize image error"); } else { mfile_copy(dst, src); } return STATUS_OK; }