if (!array_key_exists('username', $input) || !array_key_exists('password', $input) || !$functions->isValidUser($input['username'], $input['password'])) {
    $functions->sendBackError('No login');
    exit;
}
if (array_key_exists('action', $input) && $input['action'] != '') {
    $action = $input['action'];
    switch ($action) {
        case 'config':
            $functions->getJSConfig();
            break;
        case 'getConfig':
            $functions->getConfig();
            break;
        case 'command':
            if (array_key_exists('command', $input) && $input['username']) {
                echo json_encode($connection->send('!' . $input['command'], array_key_exists(strtolower($input['username']), $functions->getDbTableArray('visited')) ? $input['username'] : $dataStore->getVar('connector', 'channelOwner')));
            } else {
                $functions->sendBackError('Command is empty');
            }
            break;
        case 'getIni':
            if (array_key_exists('uri', $input)) {
                $functions->getDbTableArray($input['uri'], false);
            } else {
                $functions->sendBackError('Missing ini uri');
            }
            break;
        case 'getOtherFile':
            if (array_key_exists('uri', $input)) {
                $functions->getOtherFile($input['uri'], false);
            } else {
if (!$session->checkSessionToken(filter_input(INPUT_POST, 'token'))) {
    die('Invalid session token. Are you trying to hack me?!');
}
$dataStore = new \PBPanel\Util\DataStore();
$connection = new \PBPanel\Util\BotConnectionHandler($dataStore);
$functions = new \PBPanel\Util\Functions($dataStore, $connection);
$templates = new \PBPanel\Util\ComponentTemplates();
$botSettings = $functions->getIniArray('settings');
$pastRaiders = $functions->getIniArray('raiders');
$pastRaidersTableRows = '';
$doRaidCommandResponse = $functions->getIniValueByKey('command', 'doraid');
$firstTime = false;
$addCommandJsActive = $functions->getModuleStatus('addCommand.js');
$doRaidCommandForm = $templates->botCommandForm('doraid', 'Raid target', '[username]');
if ($addCommandJsActive == 1 && (!$doRaidCommandResponse || $doRaidCommandResponse == '')) {
    $connection->send('!addcom doraid Let\'s raid (1)! Go to http://twitch.tv/(1) and say "' . $dataStore->getVar('connector', 'channelOwner') . ' Raid!", throw them a follow and show the love! <3');
    $firstTime = true;
} elseif ($addCommandJsActive == '0') {
    $doRaidCommandForm = $templates->addTooltip($templates->botCommandForm('doraid', 'Raid target', '[username]', null, 'Send', true), 'Enable the addCommand.js module to use this form.' . $templates->botCommandButton('!module enable ./commands/addCommand.js', 'Enable addCommand.js Now', 'primary btn-block'));
}
foreach ($pastRaiders as $username => $timesRaided) {
    $pastRaidersTableRows .= '<tr><td>' . str_replace('_count', '', $username) . '</td><td>' . $timesRaided . ' raids</td></tr>';
}
?>
<div class="app-part">
  <div class="panel panel-default">
    <div class="panel-heading">
      <h3 class="panel-title">
        Raid System
        <?php 
echo $templates->toggleFavoriteButton();