Skip to content

Commit

Permalink
Fix admin/user page which has incorrect checking, add vox importer
Browse files Browse the repository at this point in the history
  • Loading branch information
LordRalex committed Apr 3, 2015
1 parent 89e515d commit 0b8c698
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
12 changes: 5 additions & 7 deletions routes/admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
}
Expand Down
33 changes: 33 additions & 0 deletions tools/updatefactoids.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

use \PDO;

$_DATABASE = array(
'host' => '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));
}
}

0 comments on commit 0b8c698

Please sign in to comment.