diff --git a/lib/copy_this/www/lib/Musik.php b/lib/copy_this/www/lib/Musik.php index b1f79c712..a8caedc72 100644 --- a/lib/copy_this/www/lib/Musik.php +++ b/lib/copy_this/www/lib/Musik.php @@ -92,7 +92,6 @@ class Musik */ public function getMusicInfo($id) { - $pdo = $this->pdo; return $this->pdo->queryOneRow(sprintf("SELECT musicinfo.*, genres.title AS genres FROM musicinfo LEFT OUTER JOIN genres ON genres.ID = musicinfo.genreID WHERE musicinfo.ID = %d ", $id)); } diff --git a/lib/copy_this/www/lib/TmuxOutput.php b/lib/copy_this/www/lib/TmuxOutput.php index cb714b55e..9766d4431 100644 --- a/lib/copy_this/www/lib/TmuxOutput.php +++ b/lib/copy_this/www/lib/TmuxOutput.php @@ -117,7 +117,7 @@ class TmuxOutput extends Tmux $buffer = ''; $state = ($this->runVar['settings']['is_running'] == 1) ? 'Running' : 'Disabled'; //$version = $this->_tvers . 'r' . $this->_vers; - $tversion = '0.6r0052'; + $tversion = '0.6r0053'; $buffer .= sprintf($this->tmpMasks[2], "Monitor $state v$tversion @ $this->_tvers [" . $this->_vers ."]: ", diff --git a/lib/copy_this/www/lib/util.php b/lib/copy_this/www/lib/util.php index 20c456679..d2ce450fa 100644 --- a/lib/copy_this/www/lib/util.php +++ b/lib/copy_this/www/lib/util.php @@ -13,6 +13,19 @@ class Utility */ const PATH_REGEX = '(?P[A-Za-z]:|)(?P[/\w.-]+|)'; + static public function clearScreen() + { + if (self::isCLI()) + { + if (self::isWin()) + { + passthru('cls'); + } else { + passthru('clear'); + } + } + } + /** * Replace all white space chars for a single space. * diff --git a/start.php b/start.php index f11053372..8d1644a0f 100644 --- a/start.php +++ b/start.php @@ -2,6 +2,7 @@ require_once(dirname(__FILE__)."/bin/config.php"); require_once(WWW_DIR . "lib/framework/db.php"); require_once (WWW_DIR.'/lib/site.php'); +require_once (WWW_DIR.'/lib/util.php'); require_once(WWW_DIR. '/lib/Tmux.php'); require_once(WWW_DIR . "/lib/ColorCLI.php"); @@ -24,16 +25,18 @@ $tablepergroup = ($tablepergroup != '') ? $tablepergroup : 0; $delaytimet = $site->delaytime; $delaytimet = ($delaytimet) ? (int)$delaytimet : 2; -// Search for NNTPProxy session that might be running froma userthreaded.php run. Setup a clean environment to run in. +Utility::clearScreen(); + +echo "Starting Tmux...\n"; +// Create a placeholder session so tmux commands do not throw server not found errors. +exec('tmux new-session -ds placeholder 2>/dev/null'); +// Search for NNTPProxy session that might be running from a user threaded.php run. Setup a clean environment to run in. exec("tmux list-session | grep NNTPProxy", $nntpkill); -if (count($nntpkill) === 0) { - exec("tmux list-session", $sessions); - if (count($sessions) === 0) { - echo $db->log->notice("The above is a notice generated by tmux. \nWhen starting this script, we first check that nntpproxy is not already running in a tmux session. If it is not, the above notice is generated by tmux.\nIt is not an error."); - } -} else { - echo $db->log->notice("Found NNTPProxy tmux session and killing it."); +if (count($nntpkill) !== 0) { exec("tmux kill-session -t NNTPProxy"); + echo $pdo->log->notice("Found NNTPProxy tmux session and killing it."); +} else { + exec("tmux list-session", $session); } // Check database patch version @@ -42,11 +45,22 @@ if ($patch < 117) { } //check if session exists -$exec = exec("tmux list-session | grep $tmux_session", $session); +$session = shell_exec("tmux list-session | grep $tmux_session"); +// Kill the placeholder +exec('tmux kill-session -t placeholder'); if (count($session) !== 0) { - exit($c->error("tmux session:" . $tmux_session . " is already running, aborting.Attach to session by typing tmux att\n")); -} else { - echo $c->notice("The above is a notice generated by tmux. \nWhen starting this script, we first check that you do not have a tmux session currently running. If you do not, the above notice is generated by tmux.\nIt is not an error."); + exit($pdo->log->error("tmux session: '" . $tmux_session . "' is already running, aborting.\n")); +} + +$nntpproxy = $site->nntpproxy; +if ($nntpproxy == '1') { + $modules = ["nntp", "socketpool"]; + foreach ($modules as &$value) { + if (!python_module_exist($value)) { + exit($pdo->log->error("\nNNTP Proxy requires " . $value . + " python module but it's not installed. Aborting.\n")); + } + } } //reset collections dateadded to now if dateadded > delay time check