/** * Construct. * * @param array $options * array( * 'Echo' => bool ; To echo to CLI or not. * 'NNTP' => NNTP ; Class NNTP. * 'Nfo' => Nfo ; Class Nfo. * 'NZB' => NZB ; Class NZB. * 'Settings' => DB ; Class newznab\db\Settings. * 'PostProcess' => PostProcess ; Class PostProcess. * ) * * @access public */ public function __construct(array $options = []) { $defaults = ['Echo' => false, 'NNTP' => null, 'Nfo' => null, 'NZB' => null, 'Settings' => null, 'PostProcess' => null]; $options += $defaults; $this->echooutput = $options['Echo'] && NN_ECHOCLI; $this->pdo = $options['Settings'] instanceof Settings ? $options['Settings'] : new Settings(); $this->nntp = $options['NNTP'] instanceof \NNTP ? $options['NNTP'] : new \NNTP(['Echo' => $this->echooutput, 'Settings' => $this->pdo]); $this->nfo = $options['Nfo'] instanceof \Nfo ? $options['Nfo'] : new \Nfo(['Echo' => $this->echooutput, 'Settings' => $this->pdo]); $this->pp = $options['PostProcess'] instanceof PostProcess ? $options['PostProcess'] : new PostProcess(['Echo' => $this->echooutput, 'Nfo' => $this->nfo, 'Settings' => $this->pdo]); $this->nzb = $options['NZB'] instanceof \NZB ? $options['NZB'] : new \NZB($this->pdo); $t = new Tmux(); $this->tmux = $t->get(); $this->lookuppar2 = $this->tmux->lookuppar2 == 1 ? true : false; $this->alternateNNTP = $this->pdo->getSetting('alternate_nntp') == 1 ? true : false; }
function window_sharing($tmux_session) { $pdo = new Settings(); $sharing = $pdo->queryOneRow('SELECT enabled, posting, fetching FROM sharing'); $t = new \Tmux(); $tmux = $t->get(); $tmux_share = isset($tmux->run_sharing) ? $tmux->run_sharing : 0; if ($tmux_share && $sharing['enabled'] == 1 && ($sharing['posting'] == 1 || $sharing['fetching'] == 1)) { exec("tmux new-window -t {$tmux_session} -n Sharing 'printf \"]2;comment_sharing\"'"); } }
<?php require_once dirname(__FILE__) . '/config.php'; use nzedb\db\Settings; passthru("clear"); $pdo = new Settings(); $t = new Tmux(); $tmux = $t->get(); $powerline = isset($tmux->powerline) ? $tmux->powerline : 0; $tmux_session = 'NNTPProxy'; function python_module_exist($module) { exec("python -c \"import {$module}\"", $output, $returnCode); return $returnCode == 0 ? true : false; } $nntpproxy = $pdo->getSetting('nntpproxy'); if ($nntpproxy === '0') { exit; } else { $modules = array("socketpool"); foreach ($modules as &$value) { if (!python_module_exist($value)) { exit($pdo->log->error("NNTP Proxy requires " . $value . " python module but it's not installed. Aborting.")); } } } function window_proxy($tmux_session, $powerline) { global $pdo; $DIR = nZEDb_MISC; if ($powerline === '1') {
<?php require_once './config.php'; $page = new AdminPage(); $tmux = new Tmux(); $id = 0; // Set the current action. $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'view'; switch ($action) { case 'submit': $error = ""; $ret = $tmux->update($_POST); $page->title = "Tmux Settings Edit"; $settings = $tmux->get(); $page->smarty->assign('ftmux', $settings); break; case 'view': default: $page->title = "Tmux Settings Edit"; $settings = $tmux->get(); $page->smarty->assign('ftmux', $settings); break; } $page->smarty->assign('yesno_ids', array(1, 0)); $page->smarty->assign('yesno_names', array('yes', 'no')); $page->smarty->assign('backfill_ids', array(0, 4, 2, 1)); $page->smarty->assign('backfill_names', array('Disabled', 'Safe', 'Group', 'All')); $page->smarty->assign('backfill_group_ids', array(1, 2, 3, 4, 5, 6)); $page->smarty->assign('backfill_group', array('Newest', 'Oldest', 'Alphabetical', 'Alphabetical - Reverse', 'Most Posts', 'Fewest Posts')); $page->smarty->assign('backfill_days', array('Days per Group', 'Safe Backfill day')); $page->smarty->assign('backfill_days_ids', array(1, 2));
<?php require_once dirname(__FILE__) . '/config.php'; use newznab\processing\PProcess; $c = new ColorCLI(); if (!isset($argv[1])) { exit($c->error("This script is not intended to be run manually, it is called from postprocess_threaded.py.")); } $tmux = new Tmux(); $torun = $tmux->get()->post; $pieces = explode(' =+= ', $argv[1]); $postprocess = new PProcess(['Echo' => true]); if (isset($pieces[6])) { // Create the connection here and pass $nntp = new NNTP(); if ($nntp->doConnect() === false) { exit($c->error("Unable to connect to usenet.")); } $postprocess->processAdditional($nntp, $argv[1]); $nntp->doQuit(); } else { if (isset($pieces[3])) { // Create the connection here and pass $nntp = new NNTP(); if ($nntp->doConnect() === false) { exit($c->error("Unable to connect to usenet.")); } $postprocess->processNfos($argv[1], $nntp); $nntp->doQuit(); } else { if (isset($pieces[2])) {
<?php /** * This file makes the tmux monitoring script activate the processing cycle. * It does so by changing the running setting in the database, so that the monitor script knows to * (re)start applicable scripts. * * It will start the tmux server and monitoring scripts if needed. */ require_once realpath(__DIR__ . '/../../../../www/config.php'); use newznab\db\Settings; $pdo = new Settings(); $tmux = new \Tmux(); $tmux_settings = $tmux->get(); $tmux_session = isset($tmux_settings->tmux_session) ? $tmux_settings->tmux_session : 0; $path = __DIR__; // Set running value to on. $tmux->startRunning(); // Create a placeholder session so tmux commands do not throw server not found errors. exec('tmux new-session -ds placeholder 2>/dev/null'); //check if session exists $session = shell_exec("tmux list-session | grep {$tmux_session}"); // Kill the placeholder exec('tmux kill-session -t placeholder'); if (count($session) == 0) { echo $pdo->log->info("Starting the tmux server and monitor script.\n"); passthru("php {$path}/run.php"); }
{ $returnVal = shell_exec("which {$cmd}"); return empty($returnVal) ? false : true; } if (command_exist('php5')) { $PHP = 'php5'; } else { $PHP = 'php'; } if (isset($argv[1])) { $tmux = new Tmux(); $restart = false; if ($argv[1] === 'true') { $restart = $tmux->isRunning(); } if ($tmux->get()->patchdb == '1') { exec("cd {$ROOTDIR} && git pull"); //remove folders from smarty if (count(glob("{$smarty}*")) > 0) { echo $pdo->log->info('Removing old stuff from ' . $smarty); exec('rm -rf ' . $smarty . '*'); } else { echo $pdo->log->info('Nothing to remove from ' . $smarty); } echo $pdo->log->primary('Patching database - ' . $dbname); exec("{$PHP} {$ROOTDIR}/cli/update_db.php true"); } $tablecnt = 0; $alltables = $pdo->query('SHOW TABLE STATUS WHERE Data_free / Data_length > 0.005'); $tablecnt = count($alltables); foreach ($alltables as $table) {