Example #1
0
/**
 * connect.php
 * Created with PhpStorm
 * User: Robin | Juraji
 * Date: 12 okt 2015
 * Time: 12:46
 */
require_once '../../AppLoader.class.php';
\PBPanel\AppLoader::load();
$dataStore = new \PBPanel\Util\DataStore();
$connection = new \PBPanel\Util\BotConnectionHandler($dataStore);
$functions = new \PBPanel\Util\FunctionLibrary($dataStore, $connection);
$input = filter_input_array(INPUT_POST);
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 {
Example #2
0
<?php

/**
 * login.php
 * Created with PhpStorm
 * User: Robin | Juraji
 * Date: 12 okt 2015
 * Time: 12:46
 */
require_once '../../AppLoader.class.php';
\PBPanel\AppLoader::load();
$dataStore = new \PBPanel\Util\DataStore();
$connection = new \PBPanel\Util\BotConnectionHandler($dataStore);
$functions = new \PBPanel\Util\FunctionLibrary($dataStore, $connection);
$input = filter_input_array(INPUT_POST);
if (!array_key_exists('username', $input) || trim($input['username']) == '') {
    $functions->sendBackError('No username defined', 203);
} elseif (!array_key_exists('password', $input) || trim($input['password']) == '') {
    $functions->sendBackError('No password defined', 203);
} elseif (!$functions->isValidUser($input['username'], $input['password'])) {
    $functions->sendBackError('No Access', 203);
} else {
    $functions->sendBackOk(true);
}