protected function _backupDb() { if (Utility::hasCommand("php5")) { $PHP = "php5"; } else { $PHP = "php"; } system("{$PHP} " . nZEDb_MISC . 'testing' . DS . 'DB' . DS . $this->_DbSystem . 'dump_tables.php db dump'); $this->backedup = true; }
/** * @param array $options Class instances / echo to cli. */ public function __construct(array $options = []) { $defaults = ['Echo' => false, 'Categorize' => null, 'Groups' => null, 'NameFixer' => null, 'Nfo' => null, 'NNTP' => null, 'NZB' => null, 'ReleaseExtra' => null, 'ReleaseFiles' => null, 'ReleaseImage' => null, 'Settings' => null, 'SphinxSearch' => null]; $options += $defaults; $this->_echoCLI = $options['Echo'] && nZEDb_ECHOCLI && strtolower(PHP_SAPI) === 'cli'; $this->_echoDebug = nZEDb_DEBUG; $this->pdo = $options['Settings'] instanceof Settings ? $options['Settings'] : new Settings(); $this->_nntp = $options['NNTP'] instanceof NNTP ? $options['NNTP'] : new \NNTP(['Echo' => $this->_echoCLI, 'Settings' => $this->pdo]); $this->_nzb = $options['NZB'] instanceof NZB ? $options['NZB'] : new \NZB($this->pdo); $this->_groups = $options['Groups'] instanceof Groups ? $options['Groups'] : new \Groups(['Settings' => $this->pdo]); $this->_archiveInfo = new \ArchiveInfo(); $this->_releaseFiles = $options['ReleaseFiles'] instanceof ReleaseFiles ? $options['ReleaseFiles'] : new \ReleaseFiles($this->pdo); $this->_categorize = $options['Categorize'] instanceof Categorize ? $options['Categorize'] : new \Categorize(['Settings' => $this->pdo]); $this->_nameFixer = $options['NameFixer'] instanceof NameFixer ? $options['NameFixer'] : new \NameFixer(['Echo' => $this->_echoCLI, 'Groups' => $this->_groups, 'Settings' => $this->pdo, 'Categorize' => $this->_categorize]); $this->_releaseExtra = $options['ReleaseExtra'] instanceof ReleaseExtra ? $options['ReleaseExtra'] : new \ReleaseExtra($this->pdo); $this->_releaseImage = $options['ReleaseImage'] instanceof ReleaseImage ? $options['ReleaseImage'] : new \ReleaseImage($this->pdo); $this->_par2Info = new \Par2Info(); $this->_nfo = $options['Nfo'] instanceof Nfo ? $options['Nfo'] : new \Nfo(['Echo' => $this->_echoCLI, 'Settings' => $this->pdo]); $this->sphinx = $options['SphinxSearch'] instanceof SphinxSearch ? $options['SphinxSearch'] : new \SphinxSearch(); $this->_innerFileBlacklist = $this->pdo->getSetting('innerfileblacklist') == '' ? false : $this->pdo->getSetting('innerfileblacklist'); $this->_maxNestedLevels = $this->pdo->getSetting('maxnestedlevels') == 0 ? 3 : $this->pdo->getSetting('maxnestedlevels'); $this->_extractUsingRarInfo = $this->pdo->getSetting('extractusingrarinfo') == 0 ? false : true; $this->_7zipPath = false; $this->_unrarPath = false; // Pass the binary extractors to ArchiveInfo. $clients = array(); if ($this->pdo->getSetting('unrarpath') != '') { $clients += array(\ArchiveInfo::TYPE_RAR => $this->pdo->getSetting('unrarpath')); $this->_unrarPath = $this->pdo->getSetting('unrarpath'); } if ($this->pdo->getSetting('zippath') != '') { $clients += array(\ArchiveInfo::TYPE_ZIP => $this->pdo->getSetting('zippath')); $this->_7zipPath = $this->pdo->getSetting('zippath'); } $this->_archiveInfo->setExternalClients($clients); $this->_hasGNUFile = \nzedb\utility\Utility::hasCommand('file') === true ? true : false; $this->_killString = '"'; if ($this->pdo->getSetting('timeoutpath') != '' && $this->pdo->getSetting('timeoutseconds') > 0) { $this->_killString = '"' . $this->pdo->getSetting('timeoutpath') . '" --foreground --signal=KILL ' . $this->pdo->getSetting('timeoutseconds') . ' "'; } $this->_showCLIReleaseID = version_compare(PHP_VERSION, '5.5.0', '>=') ? PHP_BINARY . ' ' . __DIR__ . DS . 'ProcessAdditional.php ReleaseID: ' : false; // Maximum amount of releases to fetch per run. $this->_queryLimit = $this->pdo->getSetting('maxaddprocessed') != '' ? (int) $this->pdo->getSetting('maxaddprocessed') : 25; // Maximum message ID's to download per file type in the NZB (video, jpg, etc). $this->_segmentsToDownload = $this->pdo->getSetting('segmentstodownload') != '' ? (int) $this->pdo->getSetting('segmentstodownload') : 2; // Maximum message ID's to download for a RAR file. $this->_maximumRarSegments = $this->pdo->getSetting('maxpartsprocessed') != '' ? (int) $this->pdo->getSetting('maxpartsprocessed') : 3; // Maximum RAR files to check for a password before stopping. $this->_maximumRarPasswordChecks = $this->pdo->getSetting('passchkattempts') != '' ? (int) $this->pdo->getSetting('passchkattempts') : 1; $this->_maximumRarPasswordChecks = $this->_maximumRarPasswordChecks < 1 ? 1 : $this->_maximumRarPasswordChecks; // Maximum size of releases in GB. $this->_maxSize = (string) ($this->pdo->getSetting('maxsizetopostprocess') != '') ? $this->pdo->getSetting('maxsizetopostprocess') : 100; $this->_maxSize = $this->_maxSize === 0 ? '' : 'AND r.size < ' . $this->_maxSize * 1073741824; // Minimum size of releases in MB. $this->_minSize = (string) ($this->pdo->getSetting('minsizetopostprocess') != '') ? $this->pdo->getSetting('minsizetopostprocess') : 1; $this->_minSize = $this->_minSize === 0 ? '' : 'AND r.size > ' . $this->_minSize * 1048576; // Use the alternate NNTP provider for downloading Message-ID's ? $this->_alternateNNTP = $this->pdo->getSetting('alternate_nntp') == 1 ? true : false; $this->_ffMPEGDuration = $this->pdo->getSetting('ffmpeg_duration') != '' ? (int) $this->pdo->getSetting('ffmpeg_duration') : 5; $this->_addPAR2Files = $this->pdo->getSetting('addpar2') === '0' ? false : true; $this->_processSample = $this->pdo->getSetting('ffmpegpath') == '' ? false : true; $this->_processVideo = $this->pdo->getSetting('processvideos') == 0 ? false : true; $this->_processJPGSample = $this->pdo->getSetting('processjpg') == 0 ? false : true; $this->_processAudioSample = $this->pdo->getSetting('processaudiosample') == 0 ? false : true; $this->_processMediaInfo = $this->pdo->getSetting('mediainfopath') == '' ? false : true; $this->_processAudioInfo = $this->_processMediaInfo; $this->_processPasswords = ($this->pdo->getSetting('checkpasswordedrar') == 0 ? false : true) && ($this->pdo->getSetting('unrarpath') == '' ? false : true); $this->_audioSavePath = nZEDb_COVERS . 'audiosample' . DS; $this->_audioFileRegex = '\\.(AAC|AIFF|APE|AC3|ASF|DTS|FLAC|MKA|MKS|MP2|MP3|RA|OGG|OGM|W64|WAV|WMA)'; $this->_ignoreBookRegex = '/\\b(epub|lit|mobi|pdf|sipdf|html)\\b.*\\.rar(?!.{20,})/i'; $this->_supportFileRegex = '/\\.(vol\\d{1,3}\\+\\d{1,3}|par2|srs|sfv|nzb'; $this->_videoFileRegex = '\\.(AVI|F4V|IFO|M1V|M2V|M4V|MKV|MOV|MP4|MPEG|MPG|MPGV|MPV|OGV|QT|RM|RMVB|TS|VOB|WMV)'; }
<?php require_once dirname(__FILE__) . '/../../../www/config.php'; use nzedb\ColorCLI; use nzedb\Tmux; use nzedb\db\Settings; use nzedb\utility\Utility; $pdo = new Settings(); $DIR = nZEDb_MISC; $smarty = new Smarty(); $dbname = DB_NAME; $cli = new ColorCLI(); if (isset($argv[1]) && ($argv[1] == "true" || $argv[1] == "safe")) { $restart = (new Tmux())->stopIfRunning(); system("cd {$DIR} && git pull"); if (Utility::hasCommand("php5")) { $PHP = "php5"; } else { $PHP = "php"; } echo $cli->header("Patching database - {$dbname}."); $safe = $argv[1] === "safe" ? true : false; system("{$PHP} " . nZEDb_ROOT . 'cli' . DS . "update_db.php true {$safe}"); // Remove folders from smarty. $cleared = $smarty->clearCompiledTemplate(); if ($cleared) { echo $cli->header("The smarty template cache has been cleaned for you"); } else { echo $cli->header("You should clear your smarty template cache at: " . SMARTY_DIR . "templates_c"); } if ($restart) {
<?php require_once dirname(__FILE__) . '/../../../www/config.php'; echo (new ColorCLI())->warning("This file is deprecated and will be removed in a future version.\nUse 'php cli/update_db.php 1' instead"); system((\nzedb\utility\Utility::hasCommand("php5") ? 'php5 ' : 'php ') . nZEDb_ROOT . 'cli' . DS . "update_db.php true" . (isset($argv[1]) && $argv[1] === "safe" ? ' safe' : ''));
<?php require_once dirname(__FILE__) . '/../../../www/config.php'; use nzedb\db\Settings; $pdo = new Settings(); $DIR = nZEDb_MISC; $smarty = new Smarty(); $dbname = DB_NAME; $cli = new ColorCLI(); if (isset($argv[1]) && ($argv[1] == "true" || $argv[1] == "safe")) { $restart = (new Tmux())->isRunning(); system("cd {$DIR} && git pull"); if (\nzedb\utility\Utility::hasCommand("php5")) { $PHP = "php5"; } else { $PHP = "php"; } echo $cli->header("Patching database - {$dbname}."); $safe = $argv[1] === "safe" ? true : false; system("{$PHP} " . nZEDb_ROOT . 'cli' . DS . "update_db.php true {$safe}"); // Remove folders from smarty. $cleared = $smarty->clearCompiledTemplate(); if ($cleared) { echo $cli->header("The smarty template cache has been cleaned for you"); } else { echo $cli->header("You should clear your smarty template cache at: " . SMARTY_DIR . "templates_c"); } if ($restart) { echo $cli->header("Starting tmux scripts."); $pdo->queryExec("UPDATE tmux SET value = '1' WHERE setting = 'RUNNING'"); }