Ejemplo n.º 1
0
 /**
  * DataStore constructor.
  * @param bool $skipWriteableTest
  */
 public function __construct($skipWriteableTest = false)
 {
     if (!$skipWriteableTest && !is_writable(\PBPanel\AppLoader::getBaseDir() . '/app/content/')) {
         die('The webserver needs read/write permissions on "' . \PBPanel\AppLoader::getBaseDir() . '/app/content/' . '" and it\'s contents!');
     }
     $this->db = new \SQLite3(\PBPanel\AppLoader::getBaseDir() . '/app/content/dataStore.sqlite', SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE, null);
     register_shutdown_function([$this, 'shutdown']);
 }
Ejemplo n.º 2
0
<?php

/**
 * part-template.php
 * Created with PhpStorm
 * User: Robin | Juraji
 * Date: 12 okt 2015
 * Time: 12:47
 */
require_once '../../../AppLoader.class.php';
\PBPanel\AppLoader::load();
$session = new \PBPanel\Util\PanelSession();
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();
$users = $dataStore->getTableAsArray('users');
$usersDataRows = '';
$usersDataRowsCurrentPosition = 0;
$usersDataRowsIsFirst = true;
$currentValidatedUser = filter_input(INPUT_POST, 'username');
$userIsAdmin = false;
foreach ($users as $username => $md5Password) {
    $uuid = $templates->randomId();
    $usersDataRowsIsFirst = $username == $currentValidatedUser;
    ++$usersDataRowsCurrentPosition;
    if ($usersDataRowsCurrentPosition == 1 && $username != $currentValidatedUser) {
        continue;
Ejemplo n.º 3
0
<?php

/**
 * Created by PhpStorm.
 * User: Robin
 * Date: 4-12-2015
 * Time: 18:31
 */
require_once 'AppLoader.class.php';
\PBPanel\AppLoader::loadUtil('DataStore');
$dataStore = new \PBPanel\Util\DataStore();
$done = false;
$input = filter_input_array(INPUT_POST);
if ($dataStore->getVar('connector', 'botIp') != '') {
    $done = true;
}
if (count($input) == 7 && !$done) {
    $dataStore->setVar('users', $input['username'], $input['password']);
    $dataStore->setVar('connector', 'botIp', $input['botIp']);
    $dataStore->setVar('connector', 'botBasePort', $input['botBasePort']);
    $dataStore->setVar('connector', 'botName', $input['botName']);
    $dataStore->setVar('connector', 'botOauthToken', $input['botOauthToken']);
    $dataStore->setVar('connector', 'channelOwner', $input['channelOwner']);
    $done = true;
}
?>
<!DOCTYPE html>
<html>
<head lang="en">
  <meta charset="UTF-8">
  <title></title>
 * Date: 12 okt 2015
 * Time: 12:40
 */
require_once '../../../AppLoader.class.php';
\PBPanel\AppLoader::load();
$session = new \PBPanel\Util\PanelSession();
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');
$currentTheme = $dataStore->getVar('misc', 'theme', 'style_dark');
$themeFiles = new \PBPanel\Util\SortedDirectoryIterator(\PBPanel\AppLoader::getBaseDir() . '/app/css', false);
$themesOptions = '';
/* @var \DirectoryIterator $themeFile */
foreach ($themeFiles as $themeFile) {
    if ($themeFile->getExtension() == 'css' && strpos($themeFile->getBasename(), 'style_') === 0) {
        $themesOptions .= '<option value="' . $themeFile->getBasename('.css') . '">' . ucfirst(str_replace('style_', '', $themeFile->getBasename('.css'))) . '</option>';
    }
}
?>
<script>
  $('#toggle-information-button').prop('checked', pBotStorage.get(pBotStorage.keys.informationActive, true));
  $('#toggle-tooltips-button').prop('checked', !pBotStorage.get(pBotStorage.keys.tooltipsActive, false));
  $('#toggle-chat-default-button').prop('checked', pBotStorage.get(pBotStorage.keys.chatDefaultState, false));
</script>
<div class="app-part">
  <div class="panel panel-default">
Ejemplo n.º 5
0
      <small><?php 
echo $dataStore->getVar('misc', 'currentVersion');
?>
</small>
      &#xFF0F; <a href="//juraji.nl" target="_blank">juraji</a> &copy;<?php 
echo date('Y');
?>
      &#xFF0F; Compatible with <a href="//www.phantombot.net/"
                                  target="_blank">PhantomBot <?php 
echo $dataStore->getVar('misc', 'pbCompat');
?>
</a>
    </div>
  </div>
</div>
<div id="chat-sidebar" class="chat-responsive">
  <iframe id="chat-iframe" src="" scrolling="no"></iframe>
</div>
<div id="general-alert" class="alert"></div>
<div id="music-player-controls">
  <?php 
require_once \PBPanel\AppLoader::getBaseDir() . '/app/parts/static/music-player-controls.php';
?>
</div>
<?php 
echo $templates->sideTab('Twitch Preview', 'http://www.twitch.tv/' . strtolower($dataStore->getVar('connector', 'channelOwner')) . '/embed', 'fa-video-camera');
echo $templates->sideTab('Music Player', 'pops/music-player.php?botControl=true', 'fa-music', true);
?>
</body>
</html>
Ejemplo n.º 6
0
/**
 * Created by PhpStorm.
 * User: Robin | Juraji
 * Date: 4-12-2015
 * Time: 16:59
 */
require_once 'AppLoader.class.php';
\PBPanel\AppLoader::loadUtil('DataStore');
$dataStore = new \PBPanel\Util\DataStore();
$currentVersion = floatval($dataStore->getVar('misc', 'currentVersion', 0.0));
$hasUpdate = \PBPanel\AppLoader::updateAvailable($dataStore);
$messages = [];
$messagesString = '';
if ($hasUpdate) {
    $updateFiles = glob(\PBPanel\AppLoader::getBaseDir() . '/updates/*');
    foreach ($updateFiles as $file) {
        $updateFileVersion = floatval(basename($file, '.php'));
        if ($updateFileVersion > $currentVersion) {
            require_once $file;
            $messages[] = 'Applied update ' . $updateFileVersion;
        }
    }
} else {
    $messages[] = 'There are no updates available!';
}
foreach ($messages as $message) {
    $messagesString .= '<p>' . $message . '</p>';
}
?>
<!DOCTYPE html>
Ejemplo n.º 7
0
require_once 'AppLoader.class.php';
if (!class_exists('SQLite3')) {
    $botIp = $botBasePort = 'Unknown (Settings could not be read by SQLite3)';
    $foundBot = false;
} else {
    \PBPanel\AppLoader::load();
    $dataStore = new \PBPanel\Util\DataStore(true);
    $botConnection = new \PBPanel\Util\BotConnectionHandler($dataStore);
    $browser = new PBPanel\Util\Browser();
    $foundBot = $botConnection->testConnection();
    $botIp = $dataStore->getVar('connector', 'botIp', 'Unknown (Not Set)');
    $botBasePort = $dataStore->getVar('connector', 'botBasePort', 'Unknown (Not Set)');
}
$clientIp = filter_input(INPUT_SERVER, 'REMOTE_ADDR') == '::1' ? 'localhost' : filter_input(INPUT_SERVER, 'REMOTE_ADDR');
$serverHasInternet = @file_get_contents('http://www.google.com');
$contentWriteable = is_writeable(\PBPanel\AppLoader::getBaseDir() . '/app/content');
function yesNoText($state)
{
    return $state ? '<span class="text-success">Yes</span>' : '<span class="text-danger">No</span>';
}
function validateIpAdress($botIp)
{
    $groups = explode('.', $botIp);
    $isIp = true;
    foreach ($groups as $group) {
        $group = intval($group);
        if ($group < 0 || $group > 255) {
            $isIp = false;
            break;
        }
    }
Ejemplo n.º 8
0
<?php

/**
 * Created by PhpStorm.
 * User: Robin
 * Date: 3-12-2015
 * Time: 14:12
 */
$oldConfig = [];
if (file_exists(\PBPanel\AppLoader::getBaseDir() . '/app/content/vars/config.php')) {
    $oldConfig = json_decode(file_get_contents(\PBPanel\AppLoader::getBaseDir() . '/app/content/vars/config.php'), JSON_OBJECT_AS_ARRAY);
    $messages[] = '<span class="text-warning">Please delete the "vars" folder in "./app/content", since it are no longer used.</span>';
}
/* Create bot connector table */
if ($dataStore->getVar('connector', 'botIp') == '') {
    $dataStore->setVar('connector', 'botIp', array_key_exists('botIp', $oldConfig) ? $oldConfig['botIp'] : '');
    $dataStore->setVar('connector', 'botBasePort', array_key_exists('botBasePort', $oldConfig) ? $oldConfig['botBasePort'] : '25000');
    $dataStore->setVar('connector', 'botName', array_key_exists('botName', $oldConfig) ? $oldConfig['botName'] : '');
    $dataStore->setVar('connector', 'botOauthToken', array_key_exists('botOauthToken', $oldConfig) ? $oldConfig['botOauthToken'] : '');
    $dataStore->setVar('connector', 'channelOwner', array_key_exists('channelOwner', $oldConfig) ? $oldConfig['channelOwner'] : '');
}
/* Create panel users table */
if (array_key_exists('panelUsers', $oldConfig)) {
    foreach ($oldConfig['panelUsers'] as $username => $hash) {
        $dataStore->setVar('users', $username, $hash);
    }
}
/* Create paths table */
$dataStore->setVar('paths', 'latestFollower', array_key_exists('latestFollower', $oldConfig['paths']) ? $oldConfig['paths']['latestFollower'] : '/web/latestfollower.txt');
$dataStore->setVar('paths', 'latestDonation', array_key_exists('latestDonation', $oldConfig['paths']) ? $oldConfig['paths']['latestDonation'] : '/addons/donationchecker/latestdonation.txt');
$dataStore->setVar('paths', 'youtubeCurrentSong', array_key_exists('youtubeCurrentSong', $oldConfig['paths']) ? $oldConfig['paths']['youtubeCurrentSong'] : '/addons/youtubePlayer/currentsong.txt');
Ejemplo n.º 9
0
 public function getDefaultAlertCSS()
 {
     return file_get_contents(AppLoader::getBaseDir() . '/app/css/defaultAlertCSS.css');
 }
Ejemplo n.º 10
0
function loadDefaultCommands()
{
    $file = @file(\PBPanel\AppLoader::getDocRoot() . '/app/content/botcommands.dat', FILE_SKIP_EMPTY_LINES | FILE_IGNORE_NEW_LINES);
    return $file ? $file : [];
}
Ejemplo n.º 11
0
/**
 * index.php
 * Created with PhpStorm
 * User: Robin | Juraji
 * Date: 12 okt 2015
 * Time: 12:47
 */
require_once 'AppLoader.class.php';
\PBPanel\AppLoader::load();
$dataStore = new \PBPanel\Util\DataStore();
if (\PBPanel\AppLoader::runInstall($dataStore)) {
    require_once 'install.php';
    exit;
}
if (\PBPanel\AppLoader::updateAvailable($dataStore)) {
    require_once 'update.php';
    exit;
}
?>
<!DOCTYPE html>
<html>
<head lang="en">
  <meta charset="UTF-8">
  <title></title>
  <link href="app/css/<?php 
echo $dataStore->getVar('misc', 'theme', 'style_dark');
?>
.css"
        rel="stylesheet" type="text/css"/>
  <link rel="icon" href="favicon.ico" type="image/x-icon"/>
Ejemplo n.º 12
0
?>
"/>
              <span class="input-group-btn">
                <button class="btn btn-primary"
                        onclick="saveToConfig('misc/alertWindowSize', 'setting-window-size', this)">
                  Save
                </button>
              </span>
            </div>
          </div>
        </div>
      </div>
      <div class="row">
        <div class="col-sm-8">
          <?php 
echo $templates->informationPanel('<p>Use (name) in the Alert Text to insert the new follower/hoster\'s name.</p>' . '<p>Use <code>//' . \PBPanel\AppLoader::getBaseUrl() . '/stream-alerts-player.php</code> in your OBS browser, to embed the alerts easilly in your stream!</p>' . '<p>Leave the sound field empty if you don\'t want to use sound effects on alerts.</p>' . '<p>Empty the CSS field and save to reset it\'s original value!</p>' . '<p>Donation alerts will be available soon!</p>');
?>
        </div>
      </div>
      <hr/>
      <h4 class="collapsible-master">Follower Alerts</h4>

      <div class="collapsible-content">
        <div class="row">
          <div class="col-sm-4">
            <div class="form-group">
              <span>Alert Background <span class="text-muted">(file has to be hosted online!)</span></span>

              <div class="input-group">
                <input type="text" class="form-control" id="setting-alert-bg-follower"
                       placeholder="url"