Browse Source

RenX.Ladder.Web: Made more progress.

RenX.Commands: flags are now passed to banDatabase when adding ban entries in "addban"
pull/3/head
Jessica James 9 years ago
parent
commit
6b14cee64a
  1. 2
      RenX.Commands/RenX_Commands.cpp
  2. 58
      RenX.Ladder.Web/RenX_Ladder_Web.cpp
  3. 2
      RenX.Ladder.Web/RenX_Ladder_Web.h

2
RenX.Commands/RenX_Commands.cpp

@ -2207,7 +2207,7 @@ void AddBanIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString &c
else
flags |= RenX::BanDatabase::Entry::FLAG_USE_RDNS;
RenX::banDatabase->add(name, ip, prefix_length, steamid, rdns, banner, reason, duration);
RenX::banDatabase->add(name, ip, prefix_length, steamid, rdns, banner, reason, duration, flags);
RenX::getCore()->banCheck();
source->sendMessage(channel, Jupiter::StringS::Format("Ban added to the database with ID #%u", RenX::banDatabase->getEntries().size() - 1));
}

58
RenX.Ladder.Web/RenX_Ladder_Web.cpp

@ -76,7 +76,8 @@ int RenX_Ladder_WebPlugin::OnRehash()
RenX_Ladder_WebPlugin::web_profile_filename = Jupiter::IRC::Client::Config->get(RenX_Ladder_WebPlugin::name, "ProfileFilename"_jrs, "RenX.Ladder.Web.Profile.html"_jrs);
RenX_Ladder_WebPlugin::web_ladder_table_header_filename = Jupiter::IRC::Client::Config->get(RenX_Ladder_WebPlugin::name, "LadderTableHeaderFilename"_jrs, "RenX.Ladder.Web.Ladder.Table.Header.html"_jrs);
RenX_Ladder_WebPlugin::web_ladder_table_footer_filename = Jupiter::IRC::Client::Config->get(RenX_Ladder_WebPlugin::name, "LadderTableFooterFilename"_jrs, "RenX.Ladder.Web.Ladder.Table.Footer.html"_jrs);
RenX_Ladder_WebPlugin::entries_per_page = Jupiter::IRC::Client::Config->getInt(RenX_Ladder_WebPlugin::name, "EntriesPerPage"_jrs, 50);
RenX_Ladder_WebPlugin::entry_table_row = Jupiter::IRC::Client::Config->get(RenX_Ladder_WebPlugin::name, "EntryTableRow"_jrs, "<tr><td>{RANK}</td><td><a href=\"profile?id={STEAM}\">{NAME}</a></td><td>{SCORE}</td><td>{SPM}</td><td>{KILLS}</td><td>{DEATHS}</td><td>{KDR}</td><td>{NODGAMES}</td><td>{NODWINS}</td><td>{NODLOSSES}</td><td>{NWLR}</td><td>{GDIGAMES}</td><td>{GDIWINS}</td><td>{GDILOSSES}</td><td>{GWLR}</td></tr>"_jrs);
RenX::sanitizeTags(RenX_Ladder_WebPlugin::entry_table_row);
@ -150,12 +151,15 @@ int RenX_Ladder_WebPlugin::OnRehash()
return 0;
}
// Plugin instantiation and entry point.
RenX_Ladder_WebPlugin pluginInstance;
/** Search bar */
Jupiter::String generate_search(RenX::LadderDatabase *db)
{
Jupiter::String result(256);
result = R"database-search(<form action="search" method="get" class="leaderboard-search"><input type="text" class="leaderboard-input" name="name" size="30" placeholder="Player name" value=""/>)database-search"_jrs;
result = R"database-search(<form action="search" method="get" class="leaderboard-search"><input type="text" class="leaderboard-search-input" name="name" size="30" placeholder="Player name" value=""/>)database-search"_jrs;
if (db != nullptr && db != RenX::default_ladder_database)
{
@ -163,7 +167,7 @@ Jupiter::String generate_search(RenX::LadderDatabase *db)
result += db->getName();
result += R"database-search("/>)database-search"_jrs;
}
result += R"database-search(<input type="submit" class="leaderboard-input" value="Search"/></form>)database-search"_jrs;
result += R"database-search(<input type="submit" class="leaderboard-button" value="Search"/></form>)database-search"_jrs;
return result;
}
@ -211,7 +215,40 @@ Jupiter::String generate_database_selector(RenX::LadderDatabase *db, const Jupit
}
}
result += R"database-select(</select><input type="submit" class="leaderboard-input" value="Go"/></form>)database-select"_jrs;
result += R"database-select(</select><input type="submit" class="leaderboard-button" value="Go"/></form>)database-select"_jrs;
return result;
}
/** Page buttons */
Jupiter::String generate_page_buttons(RenX::LadderDatabase *db)
{
Jupiter::String result(256);
size_t entry_count = db->getEntries();
size_t entries_per_page = pluginInstance.getEntriesPerPage();
result = R"html(<div id="leaderboard-paging">)html"_jrs;
size_t entry_index = 0, page_index = 1;
while (entry_index < entry_count)
{
// Add page
result += R"html(<span class="leaderboard-page"><a href="?start=)html"_jrs;
result += Jupiter::StringS::Format("%u", entry_index);
if (db != RenX::default_ladder_database)
{
result += "&database="_jrs;
result += db->getName();
}
result += R"html(">)html"_jrs;
result += Jupiter::StringS::Format("%u", page_index);
result += R"html(</a></span>)html"_jrs;
// Increment indexes
entry_index += entries_per_page;
++page_index;
}
result += R"html(</div>)html"_jrs;
return result;
}
@ -254,6 +291,10 @@ Jupiter::String RenX_Ladder_WebPlugin::generate_entry_table(RenX::LadderDatabase
// table footer
result += RenX_Ladder_WebPlugin::ladder_table_footer;
// search buttons
result += generate_page_buttons(db);
return result;
}
@ -337,9 +378,6 @@ Jupiter::String *RenX_Ladder_WebPlugin::generate_profile_page(RenX::LadderDataba
return result;
}
// Plugin instantiation and entry point.
RenX_Ladder_WebPlugin pluginInstance;
/** Content functions */
Jupiter::ReadableString *generate_no_db_page(const Jupiter::INIFile::Section &query_params)
@ -361,12 +399,12 @@ Jupiter::ReadableString *handle_ladder_page(const Jupiter::ReadableString &query
{
Jupiter::HTTP::HTMLFormResponse html_form_response(query_string);
RenX::LadderDatabase *db = RenX::default_ladder_database;
size_t start_index = 0, count = 50;
size_t start_index = 0, count = pluginInstance.getEntriesPerPage();
if (html_form_response.table.size() != 0)
{
start_index = static_cast<size_t>(html_form_response.table.getInt("start"_jrs, 0));
count = static_cast<size_t>(html_form_response.table.getInt("count"_jrs, 50));
start_index = static_cast<size_t>(html_form_response.table.getInt("start"_jrs, start_index));
count = static_cast<size_t>(html_form_response.table.getInt("count"_jrs, count));
const Jupiter::ReadableString &db_name = html_form_response.table.get("database"_jrs);
if (db_name.isNotEmpty())

2
RenX.Ladder.Web/RenX_Ladder_Web.h

@ -36,6 +36,7 @@ public:
Jupiter::String *generate_ladder_page(RenX::LadderDatabase *db, size_t start_index, size_t count, const Jupiter::INIFile::Section &query_params);
Jupiter::String *generate_search_page(RenX::LadderDatabase *db, const Jupiter::ReadableString &name, const Jupiter::INIFile::Section &query_params);
Jupiter::String *generate_profile_page(RenX::LadderDatabase *db, uint64_t steam_id, const Jupiter::INIFile::Section &query_params);
inline size_t getEntriesPerPage() const { return this->entries_per_page; }
RenX_Ladder_WebPlugin();
~RenX_Ladder_WebPlugin();
@ -48,6 +49,7 @@ private:
STRING_LITERAL_AS_NAMED_REFERENCE(name, "RenX.Ladder.Web");
/** Configuration variables */
size_t entries_per_page;
Jupiter::StringS ladder_page_name, search_page_name, profile_page_name, ladder_table_header, ladder_table_footer;
Jupiter::StringS web_hostname;
Jupiter::StringS web_path;

Loading…
Cancel
Save