diff --git a/public/admin.php b/public/admin.php
index a8d83bc..20024fb 100644
--- a/public/admin.php
+++ b/public/admin.php
@@ -62,26 +62,30 @@ function donothing()
function primary()
{
if (isset($_POST["submit"])) {
- $errors = [];
+ $form = validate($_POST, [
+ 'gamename' => ['alphanum-spaces', 'length:1-20'],
+ 'gamesize' => ['int', 'min:5'],
+ 'class1name' => ['alpha-spaces', 'length:1-18'],
+ 'class2name' => ['alpha-spaces', 'length:1-18'],
+ 'class3name' => ['alpha-spaces', 'length:1-18'],
+ 'gameopen' => ['bool'],
+ 'verifyemail' => ['bool'],
+ 'shownews' => ['bool'],
+ 'showonline' => ['bool'],
+ 'showbabble' => ['bool']
+ ]);
- $gn = trim($_POST['gamename'] ?? 'Dragon Knight');
- $gs = (int) trim($_POST['gamesize'] ?? 250);
- $c1n = trim($_POST['class1name'] ?? 'Mage');
- $c2n = trim($_POST['class2name'] ?? 'Warrior');
- $c3n = trim($_POST['class3name'] ?? 'Paladin');
+ if ($form['valid']) {
+ $form = $form['data'];
+ if (($form['gamesize'] % 5) != 0) exit('Map size must be divisible by five.');
- if (empty($gn)) $errors[] = "Game name is required.";
- if (!is_int($gs) || !($gs > 0) || ($gs % 5) != 0) $errors[] = "Map size must be a number greater than 0 and divisible by five.";
- if (empty($c1n) || empty($c2n) || empty($c3n)) $errors[] = "Class names are required.";
-
- if (count($errors) === 0) {
db()->query('UPDATE control SET gamename=?, gamesize=?, class1name=?, class2name=?, class3name=?, gameopen=?, verifyemail=?, gameurl=?, adminemail=?, shownews=?, showonline=?, showbabble=? WHERE id=1;', [
- $gn, $gs, $c1n, $c2n, $c3n, $_POST['gameopen'] ?? 1, $_POST['verifyemail'] ?? 1, $_POST['gameurl'] ?? '', $_POST['adminemail'] ?? '', $_POST['shownews'] ?? 1, $_POST['showonline'] ?? 1, $_POST['showbabble'] ?? 1
+ $form['gamename'], $form['gamesize'], $form['class1name'], $form['class1name'], $form['class1name'], $form['gameopen'], $form['verifyemail'], $form['gameurl'], $form['adminemail'], $form['shownews'], $form['showonline'], $form['showbabble']
]);
admindisplay("Settings updated.", "Main Settings");
} else {
- $errorlist = implode('
', $errors);
+ $errorlist = ul_from_validate_errors($form['errors']);
admindisplay("Errors:
Username: | ++ |
Password: | ++ |
Remember me? | ++ + Yes + | +
+ | |
+ Checking the "Remember Me" option will store your login information in a cookie so you don't have
+ to enter it next time you get online. Want to play? You gotta + register your own character. You may also + change your password, or + request a new one if you've lost yours. + |
+