Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
static void member_after_login(CGI *cgi, HASH *evth,
                               char *mname, char *mnick, char *mid)
{
    char tm[LEN_TM_GMT], *p, mmsn[LEN_CK];
    mevent_t *evt = (mevent_t*)hash_lookup(evth, "member");
    if (!evt) return;

    memset(mmsn, 0x0, sizeof(mmsn));
    mstr_rand_string(mmsn, sizeof(mmsn));
    mutil_getdatetime_gmt(tm, sizeof(tm), "%A, %d-%b-%Y %T GMT", ONE_WEEK);

    /*
     * set cookie
     */
    cgi_cookie_set(cgi, "mname", mname, NULL, SITE_DOMAIN, tm, 1, 0);
    cgi_cookie_set(cgi, "mnick", mnick, NULL, SITE_DOMAIN, tm, 1, 0);
    neos_url_escape(mnick, &p, NULL);
    cgi_cookie_set(cgi, "mnick_esc", p, NULL, SITE_DOMAIN, tm, 1, 0);
    free(p);

    //cgi_url_escape(mmsn, &p);
    cgi_cookie_set(cgi, "mmsn", mmsn, NULL, SITE_DOMAIN, tm, 1, 0);
    cgi_cookie_set(cgi, "mid",  mid,  NULL, SITE_DOMAIN, tm, 1, 0);

    hdf_set_value(evt->hdfsnd, "mname", mname);
    hdf_set_value(evt->hdfsnd, "mmsn", mmsn);
    MEVENT_TRIGGER_NRET(evt, mname, REQ_CMD_MEMBER_UP, FLAGS_NONE);

    hdf_set_copy(cgi->hdf, PRE_OUTPUT".mnick", PRE_QUERY".mnick");
    hdf_set_copy(cgi->hdf, PRE_OUTPUT".mname", PRE_QUERY".mname");
    hdf_set_value(cgi->hdf, PRE_OUTPUT".mmsn", mmsn);
    hdf_set_value(cgi->hdf, PRE_OUTPUT".mid", mid);
}
Ejemplo n.º 3
0
static NEOERR* member_after_login(CGI *cgi, HASH *dbh, char *mname)
{
    char tm[LEN_TM_GMT], *p, mmsn[LEN_CK];
    mdb_conn *db = hash_lookup(dbh, "main");
    NEOERR *err;

    memset(mmsn, 0x0, sizeof(mmsn));
    mstr_rand_string(mmsn, sizeof(mmsn));
    mutil_getdatetime_gmt(tm, sizeof(tm), "%A, %d-%b-%Y %T GMT", ONE_WEEK);

    /*
     * set cookie 
     */
    neos_url_escape(mname, &p, NULL);

    cgi_cookie_set(cgi, "mname",     mname, NULL, SITE_DOMAIN, tm, 1, 0);
    cgi_cookie_set(cgi, "mname_esc", p,     NULL, SITE_DOMAIN, tm, 1, 0);
    cgi_cookie_set(cgi, "mmsn",      mmsn,  NULL, SITE_DOMAIN, tm, 1, 0);

    free(p);

    hdf_set_value(cgi->hdf, PRE_OUTPUT".mname", mname);
    hdf_set_value(cgi->hdf, PRE_OUTPUT".mmsn", mmsn);

    MDB_EXEC(db, NULL, "UPDATE member SET mmsn=$1 WHERE mname=$2",
             "ss", mmsn, mname);

    return STATUS_OK;
}
Ejemplo n.º 4
0
Archivo: str.c Proyecto: dodoma/reef
void test_advance()
{
    char rands[101] = {0}, *s;
    MSTR astr;
    MLIST *alist;
    MERR *err;

    mstr_rand_string(rands, 100);
    MTEST_ASSERT(strlen(rands) < 100);

    mstr_rand_string_fixlen(rands, 100);
    MTEST_ASSERT(strlen(rands) == 100);

    s = "";
    err = mstr_array_split(&alist, s, " ", 100);
    MTEST_ASSERT(err == MERR_OK);
    mlist_destroy(&alist);

    s = "hello";
    err = mstr_array_split(&alist, s, " ", 100);
    MTEST_ASSERT(err == MERR_OK);
    mlist_destroy(&alist);

    s = " he   llo ";
    err = mstr_array_split(&alist, s, " ", 100);
    MTEST_ASSERT(err == MERR_OK);
    mlist_destroy(&alist);

    s = "xxxx hexxxxxllxxxxxoxx";
    err = mstr_array_split(&alist, s, "xx", 100);
    MTEST_ASSERT(err == MERR_OK);
    MTEST_ASSERT(mlist_length(alist) == 3);
    mlist_destroy(&alist);

    s = "hello string array     split  ";
    err = mstr_array_split(&alist, s, " ", 100);
    MTEST_ASSERT(err == MERR_OK);
    MTEST_ASSERT(mlist_length(alist) == 4);
    mlist_destroy(&alist);
}