コード例 #1
0
ファイル: NZBContents.php プロジェクト: RickDB/newznab-tmux
 /**
  * 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;
 }
コード例 #2
0
ファイル: TmuxOutput.php プロジェクト: Jay204/nZEDb
 /**
  * @param Settings $pdo
  */
 public function __construct(Settings $pdo = null)
 {
     parent::__construct($pdo);
     $this->_git = new \nzedb\utility\Git();
     $this->_vers = \nzedb\utility\Utility::getValidVersionsFile();
     $this->_setColourMasks();
 }
コード例 #3
0
ファイル: TmuxOutput.php プロジェクト: RickDB/newznab-tmux
 /**
  * @param newznab\db\Settings $pdo
  */
 public function __construct(Settings $pdo = null)
 {
     parent::__construct($pdo);
     $this->_git = new \newznab\utility\Git();
     // Do not remove the full namespace/ PHP gets confused for some reason without it.
     $this->_vers = Utility::getValidVersionsFile();
     $this->_setColourMasks();
 }
コード例 #4
0
ファイル: run.php プロジェクト: RickDB/newznab-tmux
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\"'");
    }
}
コード例 #5
0
ファイル: nntpproxy.php プロジェクト: Jay204/nZEDb
<?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') {
コード例 #6
0
ファイル: tmux-edit.php プロジェクト: Jay204/nZEDb
<?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));
コード例 #7
0
ファイル: TmuxRun.php プロジェクト: engine9-/newznab-tmux
 /**
  * @param newznab\db\Settings $pdo
  */
 public function __construct(Settings $pdo = null)
 {
     parent::__construct($pdo);
     $this->_dateFormat = '%Y-%m-%d %T';
 }
コード例 #8
0
<?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])) {
コード例 #9
0
ファイル: start.php プロジェクト: RickDB/newznab-tmux
<?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");
}
コード例 #10
0
ファイル: optimize.php プロジェクト: Jay204/nZEDb
$DIR = nZEDb_MISC;
$ROOTDIR = nZEDb_ROOT;
$smarty = SMARTY_DIR . 'templates_c/';
$dbname = DB_NAME;
function command_exist($cmd)
{
    $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");
コード例 #11
0
ファイル: TmuxRun.php プロジェクト: Jay204/nZEDb
 /**
  * @param Settings $pdo
  */
 public function __construct(Settings $pdo = null)
 {
     parent::__construct($pdo);
     $dateFormat = $this->pdo->getSetting(['section' => 'shell', 'subsection' => 'date', 'name' => 'format']);
     $this->_dateFormat = empty($dateFormat) ? '%Y-%m-%d %T' : $dateFormat;
 }