Skip to content

Commit

Permalink
Merge pull request #113 from pentium10/master
Browse files Browse the repository at this point in the history
Compatibility fixes
  • Loading branch information
pentium10 committed Sep 30, 2015
2 parents 5562e8f + 8d1356f commit bd2aad0
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 42 deletions.
2 changes: 1 addition & 1 deletion config.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

$config = array(
$GLOBALS['config'] = array(
/**
* List of servers available for all users
*/
Expand Down
53 changes: 26 additions & 27 deletions lib/include.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,20 @@ function __autoload($class) {
}

session_start();
require_once 'Pheanstalk/ClassLoader.php';
Pheanstalk_ClassLoader::register(dirname(__FILE__));

require_once 'BeanstalkInterface.class.php';
require_once dirname(__FILE__) . '/../config.php';
require_once dirname(__FILE__) . '/../src/Storage.php';

$server = !empty($_GET['server']) ? $_GET['server'] : '';
$action = !empty($_GET['action']) ? $_GET['action'] : '';
$state = !empty($_GET['state']) ? $_GET['state'] : '';
$count = !empty($_GET['count']) ? $_GET['count'] : '';
$tube = !empty($_GET['tube']) ? $_GET['tube'] : '';
$tplMain = !empty($_GET['tplMain']) ? $_GET['tplMain'] : '';
$tplBlock = !empty($_GET['tplBlock']) ? $_GET['tplBlock'] : '';
$GLOBALS['server'] = !empty($_GET['server']) ? $_GET['server'] : '';
$GLOBALS['action'] = !empty($_GET['action']) ? $_GET['action'] : '';
$GLOBALS['state'] = !empty($_GET['state']) ? $_GET['state'] : '';
$GLOBALS['count'] = !empty($_GET['count']) ? $_GET['count'] : '';
$GLOBALS['tube'] = !empty($_GET['tube']) ? $_GET['tube'] : '';
$GLOBALS['tplMain'] = !empty($_GET['tplMain']) ? $_GET['tplMain'] : '';
$GLOBALS['tplBlock'] = !empty($_GET['tplBlock']) ? $_GET['tplBlock'] : '';

class Console {

Expand Down Expand Up @@ -202,17 +205,15 @@ public function getSearchResult() {
}

protected function __init() {
global $server, $action, $state, $count, $tube, $config, $tplMain, $tplBlock;

$this->_globalVar = array(
'server' => $server,
'action' => $action,
'state' => $state,
'count' => $count,
'tube' => $tube,
'_tplMain' => $tplMain,
'_tplBlock' => $tplBlock,
'config' => $config);
'server' => $GLOBALS['server'],
'action' => $GLOBALS['action'],
'state' => $GLOBALS['state'],
'count' => $GLOBALS['count'],
'tube' => $GLOBALS['tube'],
'_tplMain' => $GLOBALS['tplMain'],
'_tplBlock' => $GLOBALS['tplBlock'],
'config' => $GLOBALS['config']);
$this->_tplVars = $this->_globalVar;
if (!in_array($this->_tplVars['_tplBlock'], array('allTubes', 'serversList'))) {
unset($this->_tplVars['_tplBlock']);
Expand All @@ -224,7 +225,7 @@ protected function __init() {
$this->_tplVars['_tplMain'] = 'main';
}

foreach ($config['servers'] as $key => $server) {
foreach ($GLOBALS['config']['servers'] as $key => $server) {
$this->serversConfig[$key] = $server;
}
if (null !== getenv('BEANSTALK_SERVERS')) {
Expand All @@ -238,7 +239,7 @@ protected function __init() {
}
}
try {
$storage = new Storage($config['storage']);
$storage = new Storage($GLOBALS['config']['storage']);
} catch (Exception $ex) {
$this->_errors[] = $ex->getMessage();
}
Expand Down Expand Up @@ -655,22 +656,20 @@ protected function _actionDeleteSample() {
}

protected function _actionMoveJobsTo() {
global $server, $tube, $state;
$destServer = (isset($_GET['server'])) ? $_GET['server'] : $server;
$destServer = (isset($_GET['server'])) ? $_GET['server'] : null;
$destTube = (isset($_GET['destTube'])) ? $_GET['destTube'] : null;
$destState = (isset($_GET['destState'])) ? $_GET['destState'] : null;
if (!empty($destTube) && in_array($state, array('ready', 'delayed', 'buried'))) {
$this->moveJobsFromTo($destServer, $tube, $state, $destTube);
if (!empty($destTube) && in_array($GLOBALS['state'], array('ready', 'delayed', 'buried'))) {
$this->moveJobsFromTo($destServer, $GLOBALS['tube'], $GLOBALS['state'], $destTube);
}
if (!empty($destState)) {
$this->moveJobsToState($destServer, $tube, $state, $destState);
$this->moveJobsToState($destServer, $GLOBALS['tube'], $GLOBALS['state'], $destState);
}
}

protected function _actionSearch() {
global $server, $tube, $state;
$this->actionTimeStart = microtime(true);
$timelimit_in_seconds = 10;
$timelimit_in_seconds = 15;
$searchStr = (isset($_GET['searchStr'])) ? $_GET['searchStr'] : null;
$states = array('ready', 'delayed', 'buried');
$jobList = array();
Expand All @@ -684,7 +683,7 @@ protected function _actionSearch() {
}

foreach ($states as $state) {
$jobList[$state] = $this->findJobsByState($tube, $state, $searchStr, $limit);
$jobList[$state] = $this->findJobsByState($GLOBALS['tube'], $state, $searchStr, $limit);
$jobList['total']+=count($jobList[$state]);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/tpl/ajax.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php require_once "../lib/tpl/{$_tplBlock}.php";?>
<?php require_once dirname(__FILE__) . "/{$_tplBlock}.php";?>
22 changes: 11 additions & 11 deletions lib/tpl/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,35 +192,35 @@
<div id="idServersCopy" style="display:none"></div>
<?php
if ($tplVars['_tplMain'] != 'ajax') {
require_once '../lib/tpl/modalAddServer.php';
require_once '../lib/tpl/modalFilterServer.php';
require_once dirname(__FILE__) . '/modalAddServer.php';
require_once dirname(__FILE__) . '/modalFilterServer.php';
}
?>
<?php elseif (!$tube):
?>
<div id="idAllTubes">
<?php require_once '../lib/tpl/allTubes.php'; ?>
<?php require_once '../lib/tpl/modalClearTubes.php'; ?>
<?php require_once dirname(__FILE__) . '/allTubes.php'; ?>
<?php require_once dirname(__FILE__) . '/modalClearTubes.php'; ?>
</div>
<div id="idAllTubesCopy" style="display:none"></div>
<div id='idAllTubesCopy' style="display:none"></div>
<?php elseif (!in_array($tube, $tubes)):
?>
<?php echo sprintf('Tube "%s" not found or it is empty', $tube) ?>
<br><br><a href="./?server=<?php echo $server ?>"> << back </a>
<?php else:
?>
<?php require_once '../lib/tpl/currentTube.php'; ?>
<?php require_once '../lib/tpl/modalAddJob.php'; ?>
<?php require_once '../lib/tpl/modalAddSample.php'; ?>
<?php require_once dirname(__FILE__) . '/currentTube.php'; ?>
<?php require_once dirname(__FILE__) . '/modalAddJob.php'; ?>
<?php require_once dirname(__FILE__) . '/modalAddSample.php'; ?>
<?php endif; ?>
<?php if (!isset($_tplPage)) { ?>
<?php require_once '../lib/tpl/modalFilterColumns.php'; ?>
<?php require_once dirname(__FILE__) . '/modalFilterColumns.php'; ?>
<?php } ?>
<?php require_once '../lib/tpl/modalSettings.php'; ?>
<?php require_once dirname(__FILE__) . '/modalSettings.php'; ?>
<?php endif; ?>
</div>

<script src="assets/vendor/jquery/jquery.js"></script>
<script src='assets/vendor/jquery/jquery.js'></script>
<script src="js/jquery.color.js"></script>
<script src="js/jquery.cookie.js"></script>
<script src="js/jquery.regexp.js"></script>
Expand Down
5 changes: 3 additions & 2 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
exit;
}

require_once '../lib/include.php';
require_once dirname(__FILE__) . '/../lib/include.php';

$console = new Console;
$errors = $console->getErrors();
$fields = $console->getTubeStatFields();
Expand All @@ -43,4 +44,4 @@
$tplVars = $console->getTplVars();
extract($tplVars);

require_once "../lib/tpl/{$_tplMain}.php";
require_once dirname(__FILE__) . "/../lib/tpl/{$_tplMain}.php";

0 comments on commit bd2aad0

Please sign in to comment.