Well editing the text file gets pretty tedious.
File Manager -> Navigate to Folder -> Edit as Text -> Add IP and Comment.
Ideally I'd prefer to see /openaccess ip:xxx.xxx.xxx.xxx but this will have to do until then.
The bare-bones of an IP Banning script:
PHP Code:
function onCreated() {
setTimer(1);
}
function onTimeout() {
if (this.timedipbans.size() > 0) {
for (temp.ip: this.timedipbans) {
if (timevar2 > getIPReleaseTime(temp.ip)) {
ipUnBan(temp.ip);
}
}
setTimer(60);
}
}
public function ipBan(ip, comment, noupdate) {
if (!(ip in this.ipbans)) {
this.ipbans.add(ip);
}
this.comment.(@ip) = comment;
this.trigger("saveData", "");
if (!noupdate) saveIPBanned();
}
public function ipBanTimed(ip, comment, seconds) {
if (!(ip in this.ipbans)) {
this.ipbans.add(ip);
}
if (!(ip in this.timedipbans)) {
this.timedipbans.add(ip);
}
this.comment.(@ip) = comment;
this.release.(@ip) = timevar2 + seconds;
this.trigger("saveData", "");
saveIPBanned();
setTimer(1);
}
public function ipUnBan(ip) {
if (isIPBanned(ip)) {
this.ipbans.remove(ip);
this.timedipbans.remove(ip);
this.comment.(@ip) = "";
this.release.(@ip) = "";
this.trigger("saveData", "");
saveIPBanned();
return true;
}
return false;
}
public function getIPBans() {
return this.ipbans;
}
public function getIPBanComment(ip) {
return this.comment.(@ip);
}
public function getIPReleaseTime(ip) {
return this.release.(@ip);
}
public function isIPBanned(ip) {
return (ip in this.ipbans);
}
function loadIPBanned() {
temp.lines.loadlines("levels/ipbanned.txt");
for (temp.line: temp.lines) {
if (temp.line.starts("#") || temp.line == "") continue;
if (temp.line.positions(".").size() == 3) {
ipBan(temp.line, "", true);
}
}
saveIPBanned();
}
function saveIPBanned() {
temp.lines = {
"###################################",
"# Automatically generated IP Bans #",
"###################################",
"",
};
for (temp.ip: getIPBans()) {
temp.comment = getIPBanComment(ip);
if (temp.comment) {
if (temp.lines[temp.lines.size()-1] != "") {
temp.lines.add("");
}
temp.lines.add("#" SPC temp.comment);
temp.lines.add(temp.ip);
temp.lines.add("");
} else {
temp.lines.add(temp.ip);
}
}
temp.lines.savelines("levels/ipbanned.txt", 0);
}
I've provided a load/save function but they are fairly basic, you'll have to write your own to format it the way you like and take any comments into consideration.
I'd like to add 'time-length' features to it but that can be in V2 of it. The bans and comments could also be stored in SQL table. Anyway enjoy.