void render(mg_connection* conn, int id, bool reverse){ ConfigManager configs; // int id = cc_extract_uri_num(conn); int limit, count; auto r = unq_read_thread_sp(pDb, 0); // get the root thread count = r.get()->childCount; limit = count - configs.global().get<int>("user::viewable_threads"); // delete r; if (id < 0 || (id < limit && limit != 0) || id > count){ views::info::render(conn, templates.invoke("misc").toggle("invalid_thread_no").build_destory().c_str()); return; } r = unq_read_thread_sp(pDb, id); // get the root thread int pid = unq_thread_parent(pDb, r.get()); if ((pid == -1) && !is_admin(conn)){ views::info::render(conn, templates.invoke("misc").toggle("invalid_thread_no").build_destory().c_str()); // delete r; return; } templates.invoke("site_header").toggle("thread_page").toggle("is_admin", is_admin(conn)) \ .var("THREAD_NO", id).var("THREAD_TITLE", r.get()->author).pipe_to(conn).destory(); templates.invoke("single_thread_header").toggle("homepage", !pid).var("THREAD_NO", id) \ .var("PARENT_NO", pid).toggle("thread", strstr(conn->uri, "/thread/")).pipe_to(conn).destory(); clock_t startc = clock(); // bool reverse = strstr(conn->uri, "/daerht/"); bool admin_view = is_admin(conn); string username = cck_verify_ssid(conn); views::each_thread(conn, r.get(), 0, admin_view); mg_printf_data(conn, "<hr>"); char iid[10]; strcpy(iid, r.get()->ssid); if(!configs.global().get<bool>("archive")) templates.invoke("post_form") \ .var("THREAD_NO", to_string(id)).toggle("reply_to_thread"). \ toggle("is_admin", admin_view || !is_assist(conn).empty()).pipe_to(conn).destory(); if (r.get()->childThread) { // int r_childThread = r->childThread; // delete r; int limit = configs.global().get<int>("user::collapse_image"); r = unq_read_thread_sp(pDb, r.get()->childThread); // beginning of the circle int rid = r.get()->threadID; //the ID bool too_many_replies = (r.get()->childCount > limit); int di = 1; if(reverse) { int n_rid = r.get()->prevThread; // delete r; r = unq_read_thread_sp(pDb, r.get()->prevThread); views::each_thread(conn, r.get(), SEND_IS_REPLY + SEND_SHOW_REPLY_LINK, admin_view, iid, username.c_str()); while (r.get()->prevThread != n_rid){ di++; // int r_prevThread = r->prevThread; // delete r; r = unq_read_thread_sp(pDb, r.get()->prevThread); if(too_many_replies && (di > limit)) views::each_thread(conn, r.get(), SEND_IS_REPLY + SEND_SHOW_REPLY_LINK + SEND_CUT_IMAGE, admin_view, iid, username.c_str()); else views::each_thread(conn, r.get(), SEND_IS_REPLY + SEND_SHOW_REPLY_LINK, admin_view, iid, username.c_str()); } } else { views::each_thread(conn, r.get(), SEND_IS_REPLY + SEND_SHOW_REPLY_LINK, admin_view, iid, username.c_str()); while (r.get()->nextThread != rid){ // int r_nextThread = r->nextThread; // delete r; r = unq_read_thread_sp(pDb, r.get()->nextThread); di++; //views::each_thread(conn, r, true, true, false, too_many_replies && (di > 20), admin_view, iid); if(too_many_replies && (di > limit)) views::each_thread(conn, r.get(), SEND_IS_REPLY + SEND_SHOW_REPLY_LINK + SEND_CUT_IMAGE, admin_view, iid, username.c_str()); else views::each_thread(conn, r.get(), SEND_IS_REPLY + SEND_SHOW_REPLY_LINK, admin_view, iid, username.c_str()); } // if(r) delete r; } } clock_t endc = clock(); // site_footer(conn, (float)(endc-startc)/CLOCKS_PER_SEC); templates.invoke("site_footer").var("TIME", (int)((endc-startc) * 1000 / CLOCKS_PER_SEC)).pipe_to(conn).destory(); }
void create_guest_avatar (DESCRIPTOR_DATA * d, char *argument) { CHAR_DATA *ch = NULL; char buf[MAX_STRING_LENGTH]; char buf2[MAX_STRING_LENGTH]; char account_name[MAX_STRING_LENGTH]; char tname_buf[MAX_STRING_LENGTH]; int roll, i = 1; extern int finished_booting; extern int guest_conns; if (!d) return; *buf = '\0'; *buf2 = '\0'; *account_name = '\0'; *tname_buf = '\0'; if (d->character) extract_char (d->character); sprintf (tname_buf, "%s-Guest", d->acct->name.c_str ()); d->character = new_char (1); //clear_char (d->character); d->character->deleted = 0; d->original = NULL; ch = d->character; ch->color = d->acct->color; d->character->pc->create_state = STATE_APPROVED; d->prompt_mode = 1; d->character->desc = d; d->character->pc->owner = d; d->character->pc->load_count = 1; roll = number (1, 11); if (roll == 1) ch->race = 0; else if (roll == 2) ch->race = 21; else if (roll == 3) ch->race = 16; else if (roll == 4) ch->race = 23; else if (roll == 5) ch->race = 120; else if (roll == 6) ch->race = 119; else if (roll == 7) ch->race = 89; else if (roll == 8) ch->race = 3; else if (roll == 9) ch->race = 28; else if (roll == 10) ch->race = 69; else if (roll == 11) ch->race = 64; else ch->race = 0; d->character->race = ch->race; d->character->flags |= FLAG_GUEST; /* Bestow the random traits to the new guest avatar */ randomize_mobile (ch); ch->pc->account_name = duplicateString (d->acct->name.c_str ()); if (is_guide (d->acct->name.c_str ())) ch->pc->is_guide = true; ch->fight_mode = 2; ch->clans = duplicateString (""); /* Address naming issues with our user's new account handle */ ch->tname = duplicateString (tname_buf); if (ch->pc->is_guide) sprintf (buf2, "%s Guide %s", ch->name, ch->tname); else sprintf (buf2, "%s %s", ch->name, ch->tname); if (ch->name) free_mem (ch->name); ch->name = duplicateString (buf2); ch->hit = 100; ch->max_hit = 100; ch->move = 100; ch->max_move = 100; if (d->character->race >= 0 && d->character->race <= 120) { for (i = 0; i <= MAX_SKILLS; i++) { d->character->skills[i] = 0; d->character->pc->skills[i] = 0; } //Get the native tongue of each race and cap it - Vader int native_tongue = get_native_tongue(ch); if (native_tongue) { ch->skills[native_tongue] = calc_lookup (ch, REG_CAP, native_tongue); ch->pc->skills[native_tongue] = calc_lookup (ch, REG_CAP, native_tongue); } ch->speaks = native_tongue; } guest_conns++; if (ch->description) free_mem (ch->description); if (ch->pc->is_guide) ch->description = duplicateString ("One of our friendly player #BGuides#0 is here, awaiting questions.\n"); else ch->description = duplicateString ("Another Guest is here, passing through. Be sure to welcome them!\n"); ch->plr_flags |= NEWBIE_HINTS; if (is_admin (ch->pc->account_name)) { ch->flags |= FLAG_ISADMIN; ch->flags |= FLAG_WIZNET; } else ch->flags &= ~FLAG_ISADMIN; if (ch->race != 89 && ch->race != 69 && ch->race != 64) equip_newbie (ch); else if (ch->race == 64) equip_char (ch, load_object (5261), WEAR_BODY); ch->hunger = -1; ch->thirst = -1; // If we're recreating, we're either recovering from a reboot or returning a dead // guest to the lounge, in which case we can skip a lot of this. pc_to_game (ch); char_to_room (ch, OOC_LOUNGE); if (str_cmp (argument, "recreate")) { act ("$n is incarnated in a soft glimmer of light.", true, d->character, 0, 0, TO_ROOM | _ACT_FORMAT); sprintf (buf, "%s [%s] has entered the lounge.", ch->tname, ch->desc->strClientHostname); send_to_gods (buf); d->connected = CON_PLYNG; guest_conns++; sprintf (buf, "%s has logged in from %s as %s.", char_short (d->character), d->strClientHostname, d->character->tname); *buf = toupper (*buf); system_log (buf, false); mysql_safe_query ("UPDATE newsletter_stats SET guest_logins=guest_logins+1"); do_look (ch, "", 0); } else { if (finished_booting) // Dead Guest being returned to the lounge. act ("$n appears in a sudden glimmer of light, looking slightly dazed.", true, ch, 0, 0, TO_ROOM | _ACT_FORMAT); act ("You feel your form briefly waver before it solidifies into yet another new guise, returned safely to the pleasant confines of Club Endore.", false, ch, 0, 0, TO_CHAR | _ACT_FORMAT); } }
static void cs_cmd_status(sourceinfo_t *si, int parc, char *parv[]) { char *chan = parv[0]; if (chan) { mychan_t *mc = mychan_find(chan); unsigned int flags; if (*chan != '#') { command_fail(si, fault_badparams, STR_INVALID_PARAMS, "STATUS"); return; } if (!mc) { command_fail(si, fault_nosuch_target, _("Channel \2%s\2 is not registered."), chan); return; } logcommand(si, CMDLOG_GET, "STATUS: \2%s\2", mc->name); if (metadata_find(mc, "private:close:closer")) { command_fail(si, fault_noprivs, _("\2%s\2 is closed."), chan); return; } flags = chanacs_source_flags(mc, si); if (flags & CA_AKICK && !(flags & CA_REMOVE)) command_success_nodata(si, _("You are banned from \2%s\2."), mc->name); else if (flags != 0) { command_success_nodata(si, _("You have access flags \2%s\2 on \2%s\2."), bitmask_to_flags(flags), mc->name); } else command_success_nodata(si, _("You have no special access to \2%s\2."), mc->name); return; } logcommand(si, CMDLOG_GET, "STATUS"); if (!si->smu) command_success_nodata(si, _("You are not logged in.")); else { command_success_nodata(si, _("You are logged in as \2%s\2."), entity(si->smu)->name); if (is_soper(si->smu)) { soper_t *soper = si->smu->soper; command_success_nodata(si, _("You are a services operator of class %s."), soper->operclass ? soper->operclass->name : soper->classname); } } if (si->su != NULL) { mynick_t *mn; mn = mynick_find(si->su->nick); if (mn != NULL && mn->owner != si->smu && myuser_access_verify(si->su, mn->owner)) command_success_nodata(si, _("You are recognized as \2%s\2."), entity(mn->owner)->name); } if (si->su != NULL && is_admin(si->su)) command_success_nodata(si, _("You are a server administrator.")); if (si->su != NULL && is_ircop(si->su)) command_success_nodata(si, _("You are an IRC operator.")); }