/** * Collect and return various capability information for usage in API * * @return array */ public function getForMenu() { $serverroot = ''; $https = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? true : false; if (isset($_SERVER['SERVER_NAME'])) { $serverroot = ($https === true ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] != '80' && $_SERVER['SERVER_PORT'] != '443' ? ':' . $_SERVER['SERVER_PORT'] : '') . WWW_TOP . '/'; } return ['server' => ['appversion' => (new Versions())->getTagVersion(), 'version' => '0.1', 'title' => $this->pdo->getSetting('title'), 'strapline' => $this->pdo->getSetting('strapline'), 'email' => $this->pdo->getSetting('email'), 'url' => $serverroot, 'image' => $serverroot . 'themes/shared/images/logo.png'], 'limits' => ['max' => 100, 'default' => 100], 'registration' => ['available' => 'yes', 'open' => $this->pdo->getSetting('registerstatus') == 0 ? 'yes' : 'no'], 'searching' => ['search' => ['available' => 'yes', 'supportedParams' => 'q'], 'tv-search' => ['available' => 'yes', 'supportedParams' => 'q,vid,tvdbid,traktid,rid,tvmazeid,imdbid,tmdbid,season,ep'], 'movie-search' => ['available' => 'yes', 'supportedParams' => 'q,imdbid'], 'audio-search' => ['available' => 'no', 'supportedParams' => '']]]; }
/** * @param array $options Class instances / Echo to CLI. */ public function __construct(array $options = array()) { $defaults = ['Echo' => false, 'Settings' => null]; $options += $defaults; $this->pdo = $options['Settings'] instanceof Settings ? $options['Settings'] : new Settings(); $this->rageqty = $this->pdo->getSetting('maxrageprocessed') != '' ? $this->pdo->getSetting('maxrageprocessed') : 75; $this->echooutput = $options['Echo'] && nZEDb_ECHOCLI; $this->xmlEpisodeInfoUrl = "http://services.tvrage.com/myfeeds/episodeinfo.php?key=" . TvRage::APIKEY; }
/** * @param array $options Class instances / Echo to cli. */ public function __construct(array $options = array()) { $defaults = ['Echo' => false, 'Settings' => null]; $options += $defaults; $this->echooutput = $options['Echo'] && nZEDb_ECHOCLI; $this->pdo = $options['Settings'] instanceof Settings ? $options['Settings'] : new Settings(); $qty = $this->pdo->getSetting('maxanidbprocessed'); $this->aniqty = !empty($qty) ? $qty : 100; $this->status = 'NULL'; }
public function addComment($id, $text, $userid, $host) { if ($this->pdo->getSetting('storeuserips') != "1") { $host = ""; } $username = $this->pdo->queryOneRow(sprintf('SELECT username FROM users WHERE id = %d', $userid)); $username = $username === false ? 'ANON' : $username['username']; $comid = $this->pdo->queryInsert(sprintf("\n\t\t\t\tINSERT INTO release_comments (releaseid, text, user_id, createddate, host, username)\n\t\t\t\tVALUES (%d, %s, %d, NOW(), %s, %s)", $id, $this->pdo->escapeString($text), $userid, $this->pdo->escapeString($host), $this->pdo->escapeString($username))); $this->updateReleaseCommentCount($id); return $comid; }
/** * @var array $options Class instances. */ public function __construct(array $options = []) { $defaults = ['Settings' => null, 'Groups' => null]; $options += $defaults; $this->pdo = $options['Settings'] instanceof Settings ? $options['Settings'] : new Settings(); $this->groups = $options['Groups'] instanceof Groups ? $options['Groups'] : new Groups(['Settings' => $this->pdo]); $this->updategrabs = $this->pdo->getSetting('grabstatus') == '0' ? false : true; $this->passwordStatus = $this->pdo->getSetting('checkpasswordedrar') == 1 ? -1 : 0; $this->sphinxSearch = new SphinxSearch(); $this->releaseSearch = new ReleaseSearch($this->pdo, $this->sphinxSearch); }
/** * Default constructor. * * @param \nzedb\db\Settings $pdo * * @access public */ public function __construct(&$pdo = null) { $this->pdo = $pdo instanceof \nzedb\db\Settings ? $pdo : new \nzedb\db\Settings(); $this->tablePerGroup = $this->pdo->getSetting('tablepergroup') == 0 ? false : true; $nzbSplitLevel = $this->pdo->getSetting('nzbsplitlevel'); $this->nzbSplitLevel = empty($nzbSplitLevel) ? 1 : $nzbSplitLevel; $this->siteNzbPath = (string) $this->pdo->getSetting('nzbpath'); if (substr($this->siteNzbPath, -1) !== DS) { $this->siteNzbPath .= DS; } }
/** * 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 nzedb\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'] && nZEDb_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); $this->lookuppar2 = $this->pdo->getSetting('lookuppar2') == 1 ? true : false; $this->alternateNNTP = $this->pdo->getSetting('alternate_nntp') == 1 ? true : false; }
/** * Try to get media info xml from a video file. * * @param string $fileLocation * * @return bool */ protected function _getMediaInfo($fileLocation) { if (!$this->_processMediaInfo) { return false; } // Look for the video file. if (is_file($fileLocation)) { // Run media info on it. $xmlArray = Misc::runCmd($this->_killString . $this->pdo->getSetting('mediainfopath') . '" --Output=XML "' . $fileLocation . '"'); // Check if we got it. if (is_array($xmlArray)) { // Convert it to string. $xmlArray = implode("\n", $xmlArray); if (!preg_match('/<track type="(Audio|Video)">/i', $xmlArray)) { return false; } // Insert it into the DB. $this->_releaseExtra->addFull($this->_release['id'], $xmlArray); $this->_releaseExtra->addFromXml($this->_release['id'], $xmlArray); if ($this->_echoCLI) { $this->_echo('m', 'primaryOver', false); } return true; } } return false; }
/** * Constructor. * * @param array $options Class instances / echo to CLI? */ public function __construct(array $options = []) { $defaults = ['Echo' => true, 'CollectionsCleaning' => null, 'ColorCLI' => null, 'Logger' => null, 'Groups' => null, 'NNTP' => null, 'Settings' => null]; $options += $defaults; $this->_echoCLI = $options['Echo'] && nZEDb_ECHOCLI; $this->_pdo = $options['Settings'] instanceof Settings ? $options['Settings'] : new Settings(); $this->_groups = $options['Groups'] instanceof Groups ? $options['Groups'] : new Groups(['Settings' => $this->_pdo]); $this->_colorCLI = $options['ColorCLI'] instanceof ColorCLI ? $options['ColorCLI'] : new ColorCLI(); $this->_nntp = $options['NNTP'] instanceof NNTP ? $options['NNTP'] : new NNTP(['Echo' => $this->_colorCLI, 'Settings' => $this->_pdo, 'ColorCLI' => $this->_colorCLI]); $this->_collectionsCleaning = $options['CollectionsCleaning'] instanceof CollectionsCleaning ? $options['CollectionsCleaning'] : new CollectionsCleaning(['Settings' => $this->_pdo]); $this->_debug = nZEDb_DEBUG || nZEDb_LOGGING; if ($this->_debug) { try { $this->_debugging = $options['Logger'] instanceof Logger ? $options['Logger'] : new Logger(['ColorCLI' => $this->_colorCLI]); } catch (LoggerException $error) { $this->_debug = false; } } $this->messageBuffer = $this->_pdo->getSetting('maxmssgs') != '' ? $this->_pdo->getSetting('maxmssgs') : 20000; $this->_compressedHeaders = $this->_pdo->getSetting('compressedheaders') == 1 ? true : false; $this->_partRepair = $this->_pdo->getSetting('partrepair') == 0 ? false : true; $this->_newGroupScanByDays = $this->_pdo->getSetting('newgroupscanmethod') == 1 ? true : false; $this->_newGroupMessagesToScan = $this->_pdo->getSetting('newgroupmsgstoscan') != '' ? $this->_pdo->getSetting('newgroupmsgstoscan') : 50000; $this->_newGroupDaysToScan = $this->_pdo->getSetting('newgroupdaystoscan') != '' ? (int) $this->_pdo->getSetting('newgroupdaystoscan') : 3; $this->_partRepairLimit = $this->_pdo->getSetting('maxpartrepair') != '' ? (int) $this->_pdo->getSetting('maxpartrepair') : 15000; $this->_partRepairMaxTries = $this->_pdo->getSetting('partrepairmaxtries') != '' ? (int) $this->_pdo->getSetting('partrepairmaxtries') : 3; $this->_showDroppedYEncParts = $this->_pdo->getSetting('showdroppedyencparts') == 1 ? true : false; $this->_tablePerGroup = $this->_pdo->getSetting('tablepergroup') == 1 ? true : false; $this->blackList = $this->whiteList = []; }
protected function setUserPreferences() { $this->userdata = $this->users->getById($this->users->currentUserId()); $this->userdata['categoryexclusions'] = $this->users->getCategoryExclusion($this->users->currentUserId()); // Change to the user's selected theme, if they selected one, else use the admin set one. $this->theme = isset($this->userdata['style']) ? $this->userdata['style'] : 'None'; if ($this->theme == 'None') { $this->theme = $this->settings->getSetting('site.main.style'); } if (lcfirst($this->theme) === $this->theme) { // TODO add redirect to error page telling the user their theme name is invalid (after SQL patch to update current users is added). $this->theme = ucfirst($this->theme); } // Update last login every 15 mins. if (strtotime($this->userdata['now']) - 900 > strtotime($this->userdata['lastlogin'])) { $this->users->updateSiteAccessed($this->userdata['id']); } $this->smarty->assign('userdata', $this->userdata); $this->smarty->assign('loggedin', 'true'); $sab = new SABnzbd($this); $this->smarty->assign('sabintegrated', $sab->integratedBool); if ($sab->integratedBool !== false && $sab->url != '' && $sab->apikey != '') { $this->smarty->assign('sabapikeytype', $sab->apikeytype); } switch ((int) $this->userdata['role']) { case Users::ROLE_ADMIN: $this->smarty->assign('isadmin', 'true'); break; case Users::ROLE_MODERATOR: $this->smarty->assign('ismod', 'true'); } }
/** * Default constructor. * * @param array $options Class instance / echo to cli. * * @access public */ public function __construct(array $options = []) { $defaults = ['Echo' => false, 'Settings' => null]; $options += $defaults; $this->echo = $options['Echo'] && nZEDb_ECHOCLI; $this->pdo = $options['Settings'] instanceof Settings ? $options['Settings'] : new Settings(); $this->nzbs = $this->pdo->getSetting('maxnfoprocessed') != '' ? (int) $this->pdo->getSetting('maxnfoprocessed') : 100; $this->maxsize = $this->pdo->getSetting('maxsizetoprocessnfo') != '' ? (int) $this->pdo->getSetting('maxsizetoprocessnfo') : 100; $this->maxsize = $this->maxsize > 0 ? 'AND size < ' . $this->maxsize * 1073741824 : ''; $this->minsize = $this->pdo->getSetting('minsizetoprocessnfo') != '' ? (int) $this->pdo->getSetting('minsizetoprocessnfo') : 100; $this->minsize = $this->minsize > 0 ? 'AND size > ' . $this->minsize * 1048576 : ''; $this->maxRetries = (int) ($this->pdo->getSetting('maxnforetries') >= 0 ? -((int) $this->pdo->getSetting('maxnforetries') + 1) : self::NFO_UNPROC); $this->maxRetries = $this->maxRetries < -8 ? -8 : $this->maxRetries; $this->tmpPath = (string) $this->pdo->getSetting('tmpunrarpath'); if (!preg_match('/[\\/\\\\]$/', $this->tmpPath)) { $this->tmpPath .= DS; } }
/** * Retrieves supplemental anime info from the AniDB API * * @return array|bool */ private function getAniDbAPI() { $timestamp = $this->pdo->getSetting('APIs.AniDB.banned') + 90000; if ($timestamp > time()) { echo "Banned from AniDB lookups until " . date('Y-m-d H:i:s', $timestamp) . "\n"; return false; } $apiresponse = $this->getAniDbResponse(); $AniDBAPIArray = []; if (!$apiresponse) { echo "AniDB: Error getting response." . PHP_EOL; } elseif (preg_match("/\\<error\\>Banned\\<\\/error\\>/", $apiresponse)) { $this->banned = true; $this->pdo->setSetting(['APIs.AniDB.banned' => time()]); } elseif (preg_match("/\\<error\\>Anime not found\\<\\/error\\>/", $apiresponse)) { echo "AniDB : Anime not yet on site. Remove until next update.\n"; } elseif ($AniDBAPIXML = new \SimpleXMLElement($apiresponse)) { $AniDBAPIArray['similar'] = $this->processAPIResponceElement($AniDBAPIXML->similaranime, 'anime'); $AniDBAPIArray['related'] = $this->processAPIResponceElement($AniDBAPIXML->relatedanime, 'anime'); $AniDBAPIArray['creators'] = $this->processAPIResponceElement($AniDBAPIXML->creators); $AniDBAPIArray['characters'] = $this->processAPIResponceElement($AniDBAPIXML->characters); $AniDBAPIArray['categories'] = $this->processAPIResponceElement($AniDBAPIXML->categories); $episodeArray = []; if ($AniDBAPIXML->episodes && $AniDBAPIXML->episodes[0]->attributes()) { $i = 1; foreach ($AniDBAPIXML->episodes->episode as $episode) { $titleArray = []; $episodeArray[$i]['episode_id'] = (int) $episode->attributes()->id[0]; $episodeArray[$i]['episode_no'] = (int) $episode->epno; $episodeArray[$i]['airdate'] = (string) $episode->airdate; if ($AniDBAPIXML->title && $AniDBAPIXML->title[0]->attributes()) { foreach ($AniDBAPIXML->title->children() as $title) { $xmlAttribs = $title->attributes('xml', true); // only english, x-jat imploded episode titles for now if (in_array($xmlAttribs->lang, ['en', 'x-jat'])) { $titleArray[] = $title[0]; } } } $episodeArray[$i]['episode_title'] = empty($titleArray) ? '' : implode(', ', $titleArray); $i++; } } //start and end date come from AniDB API as date strings -- no manipulation needed $AniDBAPIArray['startdate'] = isset($AniDBAPIXML->startdate) ? $AniDBAPIXML->startdate : '0000-00-00'; $AniDBAPIArray['enddate'] = isset($AniDBAPIXML->enddate) ? $AniDBAPIXML->enddate : '0000-00-00'; if (isset($AniDBAPIXML->ratings->permanent)) { $AniDBAPIArray['rating'] = $AniDBAPIXML->ratings->permanent; } else { $AniDBAPIArray['rating'] = isset($AniDBAPIXML->ratings->temporary) ? $AniDBAPIXML->ratings->temporary : ($AniDBAPIArray['rating'] = ''); } $AniDBAPIArray += ['type' => isset($AniDBAPIXML->type[0]) ? (string) $AniDBAPIXML->type : '', 'description' => isset($AniDBAPIXML->description) ? (string) $AniDBAPIXML->description : '', 'picture' => isset($AniDBAPIXML->picture[0]) ? (string) $AniDBAPIXML->picture : '', 'epsarr' => $episodeArray]; return $AniDBAPIArray; } return false; }
/** * Log in a user. * * @param int $userID ID of the user. * @param string $host * @param string $remember Save the user in cookies to keep them logged in. */ public function login($userID, $host = '', $remember = '') { $_SESSION['uid'] = $userID; if ($this->pdo->getSetting('storeuserips') != 1) { $host = ''; } $this->updateSiteAccessed($userID, $host); if ($remember == 1) { $this->setCookies($userID); } }
/** * @param array $options Class instances/ echo to CLI. */ public function __construct(array $options = array()) { $defaults = ['Echo' => false, 'Settings' => null]; $options += $defaults; $this->echooutput = $options['Echo'] && nZEDb_ECHOCLI; $this->pdo = $options['Settings'] instanceof Settings ? $options['Settings'] : new Settings(); $this->pubkey = $this->pdo->getSetting('amazonpubkey'); $this->privkey = $this->pdo->getSetting('amazonprivkey'); $this->asstag = $this->pdo->getSetting('amazonassociatetag'); $this->musicqty = $this->pdo->getSetting('maxmusicprocessed') != '' ? $this->pdo->getSetting('maxmusicprocessed') : 150; $this->sleeptime = $this->pdo->getSetting('amazonsleep') != '' ? $this->pdo->getSetting('amazonsleep') : 1000; $this->imgSavePath = nZEDb_COVERS . 'music' . DS; $this->renamed = ''; if ($this->pdo->getSetting('lookupmusic') == 2) { $this->renamed = 'AND isrenamed = 1'; } }
/** * @param array $options Echo to cli / Class instances. */ public function __construct(array $options = array()) { $defaults = ['Echo' => false, 'ReleaseImage' => null, 'Settings' => null]; $options += $defaults; $this->pdo = $options['Settings'] instanceof Settings ? $options['Settings'] : new Settings(); $this->releaseImage = $options['ReleaseImage'] instanceof ReleaseImage ? $options['ReleaseImage'] : new ReleaseImage($this->pdo); $this->movieqty = $this->pdo->getSetting('maxxxxprocessed') != '' ? $this->pdo->getSetting('maxxxxprocessed') : 100; $this->showPasswords = $this->pdo->getSetting('showpasswordedrelease') != '' ? $this->pdo->getSetting('showpasswordedrelease') : 0; $this->debug = nZEDb_DEBUG; $this->echooutput = $options['Echo'] && nZEDb_ECHOCLI; $this->imgSavePath = nZEDb_COVERS . 'xxx' . DS; $this->cookie = nZEDb_TMP . 'xxx.cookie'; if (nZEDb_DEBUG || nZEDb_LOGGING) { $this->debug = true; try { $this->debugging = new \Logger(); } catch (\LoggerException $error) { $this->_debug = false; } } }
/** * @param array $options Class instances / Echo to cli. */ public function __construct(array $options = []) { $defaults = ['Echo' => false, 'Settings' => null]; $options += $defaults; $this->echooutput = $options['Echo'] && nZEDb_ECHOCLI; $this->pdo = $options['Settings'] instanceof Settings ? $options['Settings'] : new Settings(); $this->pubkey = $this->pdo->getSetting('amazonpubkey'); $this->privkey = $this->pdo->getSetting('amazonprivkey'); $this->asstag = $this->pdo->getSetting('amazonassociatetag'); $this->gameqty = $this->pdo->getSetting('maxgamesprocessed') != '' ? $this->pdo->getSetting('maxgamesprocessed') : 150; $this->sleeptime = $this->pdo->getSetting('amazonsleep') != '' ? $this->pdo->getSetting('amazonsleep') : 1000; $this->imgSavePath = nZEDb_COVERS . 'console' . DS; $this->renamed = ''; if ($this->pdo->getSetting('lookupgames') == 2) { $this->renamed = 'AND isrenamed = 1'; } //$this->cleanconsole = ($this->pdo->getSetting('lookupgames') == 2) ? 'AND isrenamed = 1' : ''; $this->catWhere = 'AND categoryid BETWEEN 1000 AND 1999 '; $this->failCache = array(); }
/** * Construct. * * @param array $options Class instances / various options. * * @access public */ public function __construct(array $options = []) { $defaults = ['Browser' => false, 'Echo' => true, 'Binaries' => null, 'Categorize' => null, 'NZB' => null, 'ReleaseCleaning' => null, 'Releases' => null, 'Settings' => null]; $options += $defaults; $this->echoCLI = !$this->browser && nZEDb_ECHOCLI && $options['Echo']; $this->pdo = $options['Settings'] instanceof Settings ? $options['Settings'] : new Settings(); $this->binaries = $options['Binaries'] instanceof Binaries ? $options['Binaries'] : new Binaries(['Settings' => $this->pdo, 'Echo' => $this->echoCLI]); $this->category = $options['Categorize'] instanceof Categorize ? $options['Categorize'] : new Categorize(['Settings' => $this->pdo]); $this->nzb = $options['NZB'] instanceof NZB ? $options['NZB'] : new NZB($this->pdo); $this->releaseCleaner = $options['ReleaseCleaning'] instanceof ReleaseCleaning ? $options['ReleaseCleaning'] : new ReleaseCleaning($this->pdo); $this->releases = $options['Releases'] instanceof Releases ? $options['Releases'] : new Releases(['settings' => $this->pdo]); $this->crossPostt = $this->pdo->getSetting('crossposttime') != '' ? $this->pdo->getSetting('crossposttime') : 2; $this->browser = $options['Browser']; $this->retVal = ''; }
/** * @param array $options Class instances / Echo to cli. */ public function __construct(array $options = []) { $defaults = ['Echo' => false, 'ColorCLI' => null, 'Settings' => null]; $options += $defaults; $this->echoOutput = $options['Echo'] && nZEDb_ECHOCLI; $this->pdo = $options['Settings'] instanceof Settings ? $options['Settings'] : new Settings(); $this->publicKey = $this->pdo->getSetting('giantbombkey'); $this->gameQty = $this->pdo->getSetting('maxgamesprocessed') != '' ? $this->pdo->getSetting('maxgamesprocessed') : 150; $this->sleepTime = $this->pdo->getSetting('amazonsleep') != '' ? $this->pdo->getSetting('amazonsleep') : 1000; $this->imgSavePath = nZEDb_COVERS . 'games' . DS; $this->renamed = ''; $this->matchPercentage = 60; $this->maxHitRequest = false; $this->cookie = nZEDb_TMP . 'xxx.cookie'; if ($this->pdo->getSetting('lookupgames') == 2) { $this->renamed = 'AND isrenamed = 1'; } //$this->cleangames = ($this->pdo->getSetting('lookupgames') == 2) ? 'AND isrenamed = 1' : ''; }
/** * Update upcoming movies. */ public function updateUpcoming() { if ($this->echooutput) { $this->pdo->log->doEcho($this->pdo->log->header('Updating movie schedule using rotten tomatoes.')); } $rt = new RottenTomato($this->pdo->getSetting('rottentomatokey')); if ($rt instanceof RottenTomato) { $this->_getRTData('boxoffice', $rt); $this->_getRTData('theaters', $rt); $this->_getRTData('opening', $rt); $this->_getRTData('upcoming', $rt); $this->_getRTData('dvd', $rt); if ($this->echooutput) { $this->pdo->log->doEcho($this->pdo->log->header("Updated successfully.")); } } else { if ($this->echooutput) { $this->pdo->log->doEcho($this->pdo->log->header("Error retrieving your RottenTomato API Key. Exiting..." . PHP_EOL)); } } }
} } break; case $pieces[0] === 'par2' && isset($guidChar) && isset($maxperrun) && is_numeric($maxperrun): $releases = $pdo->queryDirect(sprintf(' SELECT r.id AS releaseid, r.guid, r.group_id FROM releases r WHERE r.guid %s AND r.nzbstatus = 1 AND r.proc_par2 = 0 AND r.preid = 0 ORDER BY r.postdate ASC LIMIT %s', $pdo->likeString($guidChar, false, true), $maxperrun)); if ($releases instanceof \Traversable) { $nntp = new NNTP(['Settings' => $pdo]); if (($pdo->getSetting('alternate_nntp') == '1' ? $nntp->doConnect(true, true) : $nntp->doConnect()) !== true) { exit($pdo->log->error("Unable to connect to usenet.")); } $Nfo = new Nfo(['Settings' => $pdo, 'Echo' => true]); $nzbcontents = new NZBContents(['Echo' => true, 'NNTP' => $nntp, 'Nfo' => $Nfo, 'Settings' => $pdo, 'PostProcess' => new PostProcess(['Settings' => $pdo, 'Nfo' => $Nfo, 'NameFixer' => $namefixer])]); foreach ($releases as $release) { $res = $nzbcontents->checkPAR2($release['guid'], $release['releaseid'], $release['group_id'], 1, 1); if ($res === false) { echo '.'; } } } break; case $pieces[0] === 'miscsorter' && isset($guidChar) && isset($maxperrun) && is_numeric($maxperrun): $releases = $pdo->queryDirect(sprintf(' SELECT r.id AS releaseid
<?php require_once realpath(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'indexer.php'); require_once nZEDb_LIB . 'utility' . DS . 'CopyFileTree.php'; use nzedb\db\Settings; $reorg = nZEDb_MISC . 'testing' . DS . 'NZBs' . DS . 'nzb-reorg.php'; $pdo = new Settings(); $level = $pdo->getSetting('nzbsplitlevel'); $nzbpath = $pdo->getSetting('nzbpath'); if (!isset($argv[1])) { exit("WARNING: Run convert_from_newznab.php BEFORE running this script.\nUsage php copy_from_newznab.php path_to_newznab_base\n"); } else { if (isset($argv[1]) && !file_exists($argv[1])) { exit("{$argv['1']}) is an invalid path\n"); } else { $source = realpath($argv[1] . DS . 'nzbfiles'); $files = new \nzedb\utility\CopyFileTree($argv[1], $nzbpath); echo "Copying nzbs from " . $argv[1] . "\n"; $files->copy('*'); $source = realpath($argv[1] . DS . 'www' . DS . 'covers'); // NN+ path, do not change. $files = new \nzedb\utility\CopyFileTree($source, nZEDb_COVERS); echo "Copying covers from {$source}\n"; $files->copy('*'); echo "Setting nzbstatus for all releases\n"; $pdo->queryExec("UPDATE releases SET nzbstatus = 1"); system("php {$reorg} {$level} {$nzbpath}"); } }
* (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program (see LICENSE.txt in the base directory. If * not, see: * * @link <http://www.gnu.org/licenses/>. * @author niel * @copyright 2014 nZEDb */ require_once dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'indexer.php'; use nzedb\db\Settings; $pdo = new Settings(); if (!$pdo->getSetting('tablepergroup')) { exit("Tables per groups is not enabled, quitting!"); } // Doing it this way in case there are tables existing not related to the active/backfill list (i.e. I don't have a clue when these tables get deleted so I'm doing any that are there). $tables = $pdo->queryDirect("SELECT SUBSTR(TABLE_NAME, 12) AS suffix FROM information_schema.TABLES WHERE TABLE_SCHEMA = (SELECT DATABASE()) AND TABLE_NAME LIKE 'collections%' ORDER BY TABLE_NAME"); $query1 = "ALTER table collections%s add noise char(32) not null default '' after releaseid"; if ($tables instanceof \Traversable) { foreach ($tables as $table) { echo "Updating table collections{$table['suffix']}" . PHP_EOL; $pdo->queryExec(sprintf($query1, $table['suffix']), true); } echo 'All done!' . PHP_EOL; }
$sql = "SHOW table status"; $tables = $pdo->query($sql); foreach ($tables as $row) { $tbl = $row['name']; if (preg_match('/collections_\\d+/', $tbl) || preg_match('/binaries_\\d+/', $tbl) || preg_match('/parts_\\d+/', $tbl) || preg_match('/missed_parts_\\d+/', $tbl) || preg_match('/\\d+_collections/', $tbl) || preg_match('/\\d+_binaries/', $tbl) || preg_match('/\\d+_parts/', $tbl) || preg_match('/\\d+_missed_parts_\\d+/', $tbl)) { $rel = $pdo->queryDirect(sprintf('DROP TABLE %s', $tbl)); if ($rel !== false) { echo $pdo->log->primary("Dropping {$tbl} completed."); } } } (new SphinxSearch())->truncateRTIndex('releases_rt'); $pdo->optimise(false, 'full'); echo $pdo->log->header("Deleting nzbfiles subfolders."); try { $files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($pdo->getSetting('nzbpath'), \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST); foreach ($files as $file) { if (basename($file) != '.gitignore' && basename($file) != 'tmpunrar') { $todo = $file->isDir() ? 'rmdir' : 'unlink'; @$todo($file); } } } catch (UnexpectedValueException $e) { echo $pdo->log->error($e->getMessage()); } echo $pdo->log->header("Deleting all images, previews and samples that still remain."); try { $dirItr = new \RecursiveDirectoryIterator(nZEDb_COVERS); $itr = new \RecursiveIteratorIterator($dirItr, \RecursiveIteratorIterator::LEAVES_ONLY); foreach ($itr as $filePath) { if (basename($filePath) != '.gitignore' && basename($filePath) != 'no-cover.jpg' && basename($filePath) != 'no-backdrop.jpg') {
/** * Connect to usenet, return NNTP object. * * @param Settings $pdo * @param bool $alternate Use alternate NNTP provider. * * @return NNTP */ function &nntp(&$pdo, $alternate = false) { $nntp = new NNTP(['Settings' => $pdo]); if (($alternate && $pdo->getSetting('alternate_nntp') == 1 ? $nntp->doConnect(true, true) : $nntp->doConnect()) !== true) { exit("ERROR: Unable to connect to usenet." . PHP_EOL); } return $nntp; }
<?php require_once realpath(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'indexer.php'); use nzedb\db\Settings; use libs\AmazonProductAPI; // Test if your amazon keys are working. $pdo = new Settings(); $pubkey = $pdo->getSetting('amazonpubkey'); $privkey = $pdo->getSetting('amazonprivkey'); $asstag = $pdo->getSetting('amazonassociatetag'); $obj = new AmazonProductAPI($pubkey, $privkey, $asstag); $e = null; try { $result = $obj->searchProducts("Adriana Koulias The Seal", AmazonProductAPI::BOOKS, "TITLE"); } catch (Exception $e) { $result = false; } if ($result !== false) { print_r($result); exit($pdo->log->header("\nLooks like it is working alright.")); } else { print_r($e); exit($pdo->log->error("\nThere was a problem attemtping to query amazon. Maybe your keys or wrong, or you are being throttled.\n")); }
<?php require_once realpath(dirname(dirname(dirname(dirname(__DIR__)))) . DIRECTORY_SEPARATOR . 'indexer.php'); use nzedb\Tmux; use nzedb\db\Settings; use nzedb\utility\Misc; $pdo = new Settings(); $DIR = nZEDb_MISC; // Check that Db patch level is current. Also checks nZEDb.xml is valid. Misc::isPatched(); Misc::clearScreen(); $patch = $pdo->getSetting('sqlpatch'); $patch = $patch != '' ? $patch : 0; $delaytimet = $pdo->getSetting('delaytime'); $delaytimet = $delaytimet ? (int) $delaytimet : 2; $nntpproxy = $pdo->getSetting('nntpproxy'); echo "Starting Tmux...\n"; // Create a placeholder session so tmux commands do not throw server not found errors. exec('tmux new-session -ds placeholder 2>/dev/null'); // Search for NNTPProxy session that might be running from a user threaded.php run. Setup a clean environment to run in. exec("tmux list-session | grep NNTPProxy", $nntpkill); if (count($nntpkill) !== 0) { exec("tmux kill-session -t NNTPProxy"); echo $pdo->log->notice("Found NNTPProxy tmux session and killing it."); } else { exec("tmux list-session", $session); } $t = new Tmux(); $tmux = $t->get(); $tmux_session = isset($tmux->tmux_session) ? $tmux->tmux_session : 0; $seq = isset($tmux->sequential) ? $tmux->sequential : 0;
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; if ($powerline === '1') {
require_once dirname(__FILE__) . '/../../../www/config.php'; use nzedb\ConsoleTools; use nzedb\Groups; use nzedb\db\Settings; /* This script will allow you to move from single collections/binaries/parts tables to TPG without having to run reset_truncate. Please STOP all update scripts before running this script. Use the following options to run: php convert_to_tpg.php true Convert c/b/p to tpg leaving current collections/binaries/parts tables in-tact. php convert_to_tgp.php true delete Convert c/b/p to tpg and TRUNCATE current collections/binaries/parts tables. */ $debug = false; $pdo = new Settings(); $groups = new Groups(['Settings' => $pdo]); $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]); $DoPartRepair = $pdo->getSetting('partrepair') == '0' ? false : true; if (!isset($argv[1]) || $argv[1] != 'true') { exit($pdo->log->error("\nMandatory argument missing\n\n" . "This script will allow you to move from single collections/binaries/parts tables to TPG without having to run reset_truncate.\n" . "Please STOP all update scripts before running this script.\n\n" . "Use the following options to run:\n" . "php {$argv['0']} true ...: Convert c/b/p to tpg leaving current collections/binaries/parts tables in-tact.\n" . "php {$argv['0']} true delete ...: Convert c/b/p to tpg and TRUNCATE current collections/binaries/parts tables.\n")); } $clen = $pdo->queryOneRow('SELECT COUNT(*) AS total FROM collections;'); $cdone = 0; $ccount = 1; $gdone = 1; $actgroups = $groups->getActive(); $glen = count($actgroups); $newtables = $glen * 3; $begintime = time(); echo "Creating new collections, binaries, and parts tables for each active group...\n"; foreach ($actgroups as $group) { if ($groups->createNewTPGTables($group['id']) === false) { exit($pdo->log->error("There is a problem creating new parts/files tables for group {$group['name']}."));
/** * Get a string like this: * "AND r.nzbstatus = 1 AND r.nfostatus BETWEEN -8 AND -1 AND r.size < 1073741824 AND r.size > 1048576" * To use in a query. * * @param Settings $pdo * * @return string * @access public * @static */ public static function NfoQueryString(Settings &$pdo) { $maxSize = $pdo->getSetting('maxsizetoprocessnfo'); $minSize = $pdo->getSetting('minsizetoprocessnfo'); $maxRetries = (int) ($pdo->getSetting('maxnforetries') >= 0 ? -((int) $pdo->getSetting('maxnforetries') + 1) : self::NFO_UNPROC); return sprintf('AND r.nzbstatus = %d AND r.nfostatus BETWEEN %d AND %d %s %s', NZB::NZB_ADDED, $maxRetries < -8 ? -8 : $maxRetries, self::NFO_UNPROC, $maxSize != '' && $maxSize > 0 ? 'AND r.size < ' . $maxSize * 1073741824 : '', $minSize != '' && $minSize > 0 ? 'AND r.size > ' . $minSize * 1048576 : ''); }
<?php require_once realpath(dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'indexer.php'); use nzedb\ConsoleTools; use nzedb\NNTP; use nzedb\db\Settings; use nzedb\processing\ProcessReleases; $pdo = new Settings(); if (isset($argv[2]) && $argv[2] === 'true') { // Create the connection here and pass $nntp = new NNTP(['Settings' => $pdo]); if ($nntp->doConnect() !== true) { exit($pdo->log->error("Unable to connect to usenet.")); } } if ($pdo->getSetting('tablepergroup') === 1) { exit($pdo->log->error("You are using 'tablepergroup', you must use .../misc/update/nix/multiprocessing/releases.php")); } $groupName = isset($argv[3]) ? $argv[3] : ''; if (isset($argv[1]) && isset($argv[2])) { $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]); $releases = new ProcessReleases(['Settings' => $pdo, 'ConsoleTools' => $consoletools]); if ($argv[1] == 1 && $argv[2] == 'true') { $releases->processReleases(1, 1, $groupName, $nntp, true); } else { if ($argv[1] == 1 && $argv[2] == 'false') { $releases->processReleases(1, 2, $groupName, $nntp, true); } else { if ($argv[1] == 2 && $argv[2] == 'true') { $releases->processReleases(2, 1, $groupName, $nntp, true); } else {