diff --git a/routes/admin/index.php b/routes/admin/index.php index 01b773b..fa292bd 100644 --- a/routes/admin/index.php +++ b/routes/admin/index.php @@ -94,11 +94,9 @@ }); $this->respond('GET', '/user', function($request, $response, $service) { - if (Authentication::verifySession()) { - if (Authentication::checkPermission('panel.viewusers')) { - $perms['approveUser'] = Authentication::checkPermission('panel.approveuser'); - $service->render(HTML_DIR . 'index.phtml', array('action' => 'user', 'page' => HTML_DIR . 'cp/admin/user/index.phtml', 'perms' => $perms)); - } + if (Authentication::verifySession() && Authentication::checkPermission('panel.viewusers')) { + $perms['approveUser'] = Authentication::checkPermission('panel.approveuser'); + $service->render(HTML_DIR . 'index.phtml', array('action' => 'user', 'page' => HTML_DIR . 'cp/admin/user/index.phtml', 'perms' => $perms)); } else { $response->redirect("/auth/login", 302)->send(); } @@ -155,7 +153,7 @@ $daysBanned = $request->param('daysbanned'); - if(!is_numeric($daysBanned)) { + if (!is_numeric($daysBanned)) { $service->flash("Days to ban must be in integers (" . $daysBanned . ")"); $service->refresh(); return; @@ -168,7 +166,7 @@ if ($result) { foreach (explode(',', $request->param('channels')) as $chan) { - if(!Bans::addChannelToBan($result, trim($chan))) { + if (!Bans::addChannelToBan($result, trim($chan))) { $service->flash('Could not apply ban to channel: ' . $chan); } } diff --git a/tools/updatefactoids.php b/tools/updatefactoids.php new file mode 100644 index 0000000..0605085 --- /dev/null +++ b/tools/updatefactoids.php @@ -0,0 +1,33 @@ + 'localhost', + 'db' => 'panel', + 'user' => 'root', + 'pass' => getopt("p:")["p"] +); + +$database = new PDO("mysql:host=" . $_DATABASE['host'] . ";dbname=" . $_DATABASE['db'], $_DATABASE['user'], $_DATABASE['pass'], array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'")); + +$factoids = file_get_contents("http://vps.dope.ghoti.me/mcfaq/faqdatabase"); + +$list = explode("\n", $factoids); + +foreach ($list as $line) { + if (!trim($line)) { + continue; + } + list($name, $context) = explode('|', $line); + $set = $database->prepare("SELECT game FROM factoids WHERE name = ?"); + $set->execute(array($name)); + $record = $set->fetch(); + if (isset($record['game']) && $record['game'] == 0) { + $database->prepare("UPDATE factoids SET content = ? WHERE game = 0 AND name = ?") + ->execute(array($context, $name)); + } else { + $database->prepare("INSERT INTO factoids (name, game, content) VALUES (?, 1, ?) ON DUPLICATE KEY UPDATE content = ?") + ->execute(array($name, $context, $context)); + } +} \ No newline at end of file