function BackupDatabase() { $db = new DB(); $c = new ColorCLI(); $DIR = dirname(__FILE__); if (Utility::hasCommand("php5")) { $PHP = "php5"; } else { $PHP = "php"; } //Backup based on database system if ($db->dbSystem() == "mysql") { system("{$PHP} {$DIR}mysqldump_tables.php db dump ../../"); } else { if ($db->dbSystem() == "pgsql") { exit($c->error("Currently not supported on this platform.")); } } }
/** * @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'] && NN_ECHOCLI && strtolower(PHP_SAPI) === 'cli'; $this->_echoDebug = NN_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 = []; if ($this->pdo->getSetting('unrarpath') != '') { $clients += [\ArchiveInfo::TYPE_RAR => $this->pdo->getSetting('unrarpath')]; $this->_unrarPath = $this->pdo->getSetting('unrarpath'); } if ($this->pdo->getSetting('zippath') != '') { $clients += [\ArchiveInfo::TYPE_ZIP => $this->pdo->getSetting('zippath')]; $this->_7zipPath = $this->pdo->getSetting('zippath'); } $this->_archiveInfo->setExternalClients($clients); $this->_hasGNUFile = 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 = PHP_BINARY . ' ' . __DIR__ . DS . 'ProcessAdditional.php ReleaseID: '; // 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 = $this->pdo->getSetting('maxsizetopostprocess') != '' ? (int) $this->pdo->getSetting('maxsizetopostprocess') : 100; $this->_maxSize = $this->_maxSize > 0 ? 'AND r.size < ' . $this->_maxSize * 1073741824 : ''; // Minimum size of releases in MB. $this->_minSize = $this->pdo->getSetting('minsizetopostprocess') != '' ? (int) $this->pdo->getSetting('minsizetopostprocess') : 100; $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; if (!$this->pdo->getSetting('ffmpegpath')) { $this->_processAudioSample = $this->_processThumbnails = $this->_processVideo = false; } else { $this->_processAudioSample = $this->pdo->getSetting('saveaudiopreview') == 0 ? false : true; $this->_processThumbnails = $this->pdo->getSetting('processthumbnails') == 0 ? false : true; $this->_processVideo = $this->pdo->getSetting('processvideos') == 0 ? false : true; } $this->_processJPGSample = $this->pdo->getSetting('processjpg') == 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 = NN_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|OGG|QT|RM|RMVB|TS|VOB|WMV)'; }
protected function _backupDb() { if (Utility::hasCommand("php5")) { $PHP = "php5"; } else { $PHP = "php"; } system("{$PHP} " . NN_MISC . 'testing' . DS . 'DB' . DS . $this->_DbSystem . 'dump_tables.php db dump'); $this->backedup = true; }