added admin "simple file" parsing
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40643
This commit is contained in:
parent
62bd9ee7f8
commit
cbf1bbec0f
@ -7,6 +7,11 @@ Groups
|
||||
* "immunity" - Specifies a group to be immune to. Use "*" for all or "$" for users with no group.
|
||||
* This key may be used multiple times.
|
||||
*/
|
||||
"Default"
|
||||
{
|
||||
"immunity" "$"
|
||||
}
|
||||
|
||||
"Full Admins"
|
||||
{
|
||||
/**
|
||||
|
@ -1,41 +1,38 @@
|
||||
/***************************************
|
||||
* READ THIS CAREFULLY! SEE BOTTOM FOR EXAMPLES
|
||||
*
|
||||
* For each admin, you need two settings:
|
||||
* "identity" "permissions" "password"
|
||||
*
|
||||
* For the Identity, you can use a SteamID, IP address, or Name (the type will be auto-detected).
|
||||
* For the Permissions, you can use a flag string or group (read below), and an optional password.
|
||||
*
|
||||
* There are 13 flags (a-i,z), and each flag has a specific meaning/role.
|
||||
* For example, the "b" flag means "kick permissions."
|
||||
*
|
||||
* You can combine flags into a string like this:
|
||||
* "abcdefgh"
|
||||
*
|
||||
* The default flags are:
|
||||
*
|
||||
* "reservation" "a" //Slot reservation
|
||||
"kick" "b" //Kick other players
|
||||
"ban" "c" //Ban other players
|
||||
"unban" "d" //Unban other players
|
||||
"slay" "e" //Slay other players
|
||||
"changemap" "f" //Change the map or gameplay type
|
||||
"cvars" "g" //Change cvars
|
||||
"configs" "h" //Run config files
|
||||
"chat" "i" //See dead/team chat and chat with other admins
|
||||
"votes" "j" //Display votes
|
||||
"password" "h" //Change server password
|
||||
"rcon" "i" //Use RCON
|
||||
"root" "z" //All permissions
|
||||
*
|
||||
*
|
||||
* Examples:
|
||||
* "STEAM_0:1:16" "bce" //kick, ban, slay for this steam ID
|
||||
* "127.0.0.1" "z" //all permissions for this ip
|
||||
* "BAILOPAN" "abc" "Gab3n" //name BAILOPAN, password "Gab3n": gets reservation, kick, ban
|
||||
*
|
||||
***************************************/
|
||||
//
|
||||
// READ THIS CAREFULLY! SEE BOTTOM FOR EXAMPLES
|
||||
//
|
||||
// For each admin, you need three settings:
|
||||
// "identity" "permissions" "password"
|
||||
//
|
||||
// For the Identity, you can use a SteamID or Name. To use an IP address, prepend a ! character.
|
||||
// For the Permissions, you can use a flag string and an optional password.
|
||||
//
|
||||
// PERMISSIONS:
|
||||
// Flag definitions are in "admin_levels.cfg"
|
||||
// You can combine flags into a string like this:
|
||||
// "abcdefgh"
|
||||
// There is also one additional "magic" flag, $, which gives admins default immunity.
|
||||
//
|
||||
// If you want to specify a group instead of a flag, use an @ symbol. Example:
|
||||
// "@Full Admins"
|
||||
//
|
||||
// PASSWORDS:
|
||||
// Passwords are generally not needed unless you have name-based authentication.
|
||||
// In this case, admins must type this in their console:
|
||||
//
|
||||
// setinfo "KEY" "PASSWORD"
|
||||
//
|
||||
// Where KEY is the "pw_auth" setting in your sourcemod.cfg file, and "PASSWORD"
|
||||
// is their password. This must be done before the authentication matches on the
|
||||
// server.
|
||||
//
|
||||
////////////////////////////////
|
||||
// Examples:
|
||||
// "STEAM_0:1:16" "bce" //kick, ban, slay for this steam ID
|
||||
// "127.0.0.1" "z" //all permissions for this ip
|
||||
// "BAILOPAN" "abc" "Gab3n" //name BAILOPAN, password "Gab3n": gets reservation, kick, ban
|
||||
//
|
||||
////////////////////////////////
|
||||
|
||||
"127.0.0.1" "z"
|
||||
"!127.0.0.1" "$z"
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
/**
|
||||
* Each sub-section of "Plugins" should have a title which specifies a plugin filename.
|
||||
* Filenames have a wildcard of *. Appending .amxx is not required.
|
||||
* Filenames have a wildcard of *. Appending .smx is not required.
|
||||
* If the filename has no explicit path, it will be patched to any sub-path in the plugins folder.
|
||||
*
|
||||
* Available properties for plugins are:
|
||||
* "pause" - Whether or not the plugin should load paused - "yes" or "no" (defualt)
|
||||
* "lifetime" - Lifetime of the plugin. Options:
|
||||
* "private" - Plugin is privately maintained and receives no forwards from Core
|
||||
* "private" - Plugin is privately maintained and receives no forwards from Core
|
||||
* "mapsync" - Plugins should be reloaded on mapchange if changed (default)
|
||||
* "maponly" - Plugin should be unloaded at the end of the map
|
||||
* "global" - Plugin will never be unloaded or updated
|
||||
|
@ -22,6 +22,9 @@
|
||||
#include <sourcemod>
|
||||
#include <textparse>
|
||||
|
||||
/* We like semicolons */
|
||||
#pragma semicolon 1
|
||||
|
||||
public Plugin:myinfo =
|
||||
{
|
||||
name = "Admin File Reader",
|
||||
@ -43,6 +46,7 @@ new String:g_Filename[PLATFORM_MAX_PATH]; /* Used for error messages */
|
||||
#include "admin-overrides.sp"
|
||||
#include "admin-groups.sp"
|
||||
#include "admin-users.sp"
|
||||
#include "admin-simple.sp"
|
||||
|
||||
public OnRebuildAdminCache(AdminCachePart:part)
|
||||
{
|
||||
@ -54,6 +58,7 @@ public OnRebuildAdminCache(AdminCachePart:part)
|
||||
ReadGroups();
|
||||
} else if (part == AdminCache_Admins) {
|
||||
ReadUsers();
|
||||
ReadSimpleUsers();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
static Handle:g_hGroupParser = INVALID_HANDLE;
|
||||
static GroupId:g_CurGrp = INVALID_GROUP_ID;
|
||||
static g_GroupState = GROUP_STATE_NONE;
|
||||
static g_GroupPass = 0
|
||||
static g_GroupPass = 0;
|
||||
static bool:g_NeedReparse = false;
|
||||
|
||||
public SMCResult:ReadGroups_NewSection(Handle:smc, const String:name[], bool:opt_quotes)
|
||||
|
132
plugins/admin-flatfile/admin-simple.sp
Normal file
132
plugins/admin-flatfile/admin-simple.sp
Normal file
@ -0,0 +1,132 @@
|
||||
/**
|
||||
* admin-simple.sp
|
||||
* Reads the admins.cfg file. Do not compile this directly.
|
||||
* This file is part of SourceMod, Copyright (C) 2004-2007 AlliedModders LLC
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
ReadSimpleUsers()
|
||||
{
|
||||
BuildPath(Path_SM, g_Filename, sizeof(g_Filename), "configs/admins_simple.ini");
|
||||
|
||||
new Handle:file = OpenFile(g_Filename, "rt");
|
||||
if (file == INVALID_HANDLE)
|
||||
{
|
||||
ParseError("Could not open file!");
|
||||
return;
|
||||
}
|
||||
|
||||
while (!IsEndOfFile(file))
|
||||
{
|
||||
decl String:line[255];
|
||||
ReadFileLine(file, line, sizeof(line));
|
||||
|
||||
if ((line[0] == '/' && line[1] == '/')
|
||||
|| (line[0] == ';' || line[0] == '\0'))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ReadAdminLine(line);
|
||||
}
|
||||
|
||||
CloseHandle(file);
|
||||
}
|
||||
|
||||
ReadAdminLine(const String:line[])
|
||||
{
|
||||
new String:auth[64];
|
||||
new cur_idx = StrBreak(line, auth, sizeof(auth));
|
||||
new idx = cur_idx;
|
||||
|
||||
if (cur_idx == -1)
|
||||
{
|
||||
/* This line is bad... we need at least two parameters */
|
||||
return;
|
||||
}
|
||||
|
||||
/* Create the admin */
|
||||
new AdminId:admin = CreateAdmin(auth);
|
||||
|
||||
/* Read flags */
|
||||
new String:flags[64];
|
||||
cur_idx = StrBreak(line[idx], flags, sizeof(flags));
|
||||
idx += cur_idx;
|
||||
|
||||
if (flags[0] == '@')
|
||||
{
|
||||
new GroupId:gid = FindAdmGroup(flags[1]);
|
||||
if (gid == INVALID_GROUP_ID)
|
||||
{
|
||||
ParseError("Invalid group detected: %s", flags[1]);
|
||||
return;
|
||||
}
|
||||
AdminInheritGroup(admin, gid);
|
||||
} else {
|
||||
new len = strlen(flags);
|
||||
new bool:is_default = false;
|
||||
for (new i=0; i<len; i++)
|
||||
{
|
||||
if (flags[i] < 'a' || flags[i] > 'z')
|
||||
{
|
||||
if (flags[i] == '$')
|
||||
{
|
||||
is_default = true;
|
||||
} else {
|
||||
ParseError("Invalid flag detected: %c", flags[i]);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
new val = flags[i] - 'a';
|
||||
if (!g_FlagsSet[val])
|
||||
{
|
||||
ParseError("Invalid flag detected: %c", flags[i]);
|
||||
continue;
|
||||
}
|
||||
SetAdminFlag(admin, g_FlagLetters[val], true);
|
||||
}
|
||||
|
||||
if (is_default)
|
||||
{
|
||||
new GroupId:gid = FindAdmGroup("Default");
|
||||
if (gid != INVALID_GROUP_ID)
|
||||
{
|
||||
AdminInheritGroup(admin, gid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Lastly, is there a password? */
|
||||
if (cur_idx != -1)
|
||||
{
|
||||
decl String:password[64];
|
||||
StrBreak(line[idx], password, sizeof(password));
|
||||
SetAdminPassword(admin, password);
|
||||
}
|
||||
|
||||
/* Now, bind the identity to something */
|
||||
if (StrContains(auth, "STEAM_") == 0)
|
||||
{
|
||||
BindAdminIdentity(admin, AUTHMETHOD_STEAM, auth);
|
||||
} else {
|
||||
if (auth[0] == '!')
|
||||
{
|
||||
BindAdminIdentity(admin, AUTHMETHOD_IP, auth[1]);
|
||||
} else {
|
||||
BindAdminIdentity(admin, AUTHMETHOD_NAME, auth);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user