示例#1
0
 /**
  * @param Settings $pdo
  */
 public function __construct(Settings $pdo = null)
 {
     parent::__construct($pdo);
     $this->_git = new \nzedb\utility\Git();
     // Do not remove the full namespace/ PHP gets confused for some reason without it.
     $this->_vers = Misc::getValidVersionsFile();
     $this->_setColourMasks();
 }
示例#2
0
文件: run.php 项目: kaibosh/nZEDb
/**
 * @param $tmux_session
 */
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\"'");
    }
}
示例#3
0
<?php

require_once './config.php';
use nzedb\Tmux;
$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', [1, 0]);
$page->smarty->assign('yesno_names', ['yes', 'no']);
$page->smarty->assign('backfill_ids', [0, 4, 2, 1]);
$page->smarty->assign('backfill_names', ['Disabled', 'Safe', 'Group', 'All']);
$page->smarty->assign('backfill_group_ids', [1, 2, 3, 4, 5, 6]);
$page->smarty->assign('backfill_group', ['Newest', 'Oldest', 'Alphabetical', 'Alphabetical - Reverse', 'Most Posts', 'Fewest Posts']);
$page->smarty->assign('backfill_days', ['Days per Group', 'Safe Backfill day']);
示例#4
0
<?php

require_once realpath(dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'indexer.php');
use nzedb\Tmux;
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;
示例#5
0
文件: start.php 项目: kaibosh/nZEDb
<?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(dirname(dirname(dirname(dirname(__DIR__)))) . DIRECTORY_SEPARATOR . 'indexer.php');
use nzedb\Tmux;
use nzedb\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");
}
示例#6
0
$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->stopIfRunning();
    }
    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");
示例#7
0
文件: TmuxRun.php 项目: zetas/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;
 }