Exemplo n.º 1
0
    /**
     * Send a NZB URL to NZBGet.
     *
     * @param string $guid Release identifier.
     *
     * @return bool|mixed
     *
     * @access public
     */
    public function sendURLToNZBGet($guid)
    {
        $reldata = $this->Releases->getByGuid($guid);
        $url = "{$this->serverurl}getnzb/{$guid}&i={$this->uid}&r={$this->rsstoken}";
        $header = <<<NZBGet_URL
<?xml version="1.0"?>
<methodCall>
\t<methodName>appendurl</methodName>
\t<params>
\t\t<param>
\t\t\t<value><string>{$reldata['searchname']}.nzb</string></value>
\t\t</param>
\t\t<param>
\t\t\t<value><string>{$reldata['category_name']}</string></value>
\t\t</param>
\t\t<param>
\t\t\t<value><i4>0</i4></value>
\t\t</param>
\t\t<param>
\t\t\t<value><boolean>>False</boolean></value>
\t\t</param>
\t\t<param>
\t\t\t<value>
\t\t\t\t<string>{$url}</string>
\t\t\t</value>
\t\t</param>
\t</params>
</methodCall>
NZBGet_URL;
        Utility::getUrl(['url' => $this->fullURL . 'appendurl', 'method' => 'post', 'postdata' => $header, 'verifycert' => false]);
    }
Exemplo n.º 2
0
 /**
  * Delete releases from the database.
  */
 protected function deleteReleases()
 {
     $deletedCount = 0;
     foreach ($this->result as $release) {
         if ($this->delete) {
             $this->releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage);
             if ($this->echoCLI) {
                 echo $this->pdo->log->primary('Deleting: ' . $this->method . ': ' . $release['searchname']);
             }
         } elseif ($this->echoCLI) {
             echo $this->pdo->log->primary('Would be deleting: ' . $this->method . ': ' . $release['searchname']);
         }
         $deletedCount++;
     }
     $this->deletedCount += $deletedCount;
     return true;
 }
Exemplo n.º 3
0
Arquivo: XXX.php Projeto: EeGgSs/nZEDb
 /**
  * @param array $options Echo to cli / Class instances.
  */
 public function __construct(array $options = [])
 {
     $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 = Releases::showPasswords($this->pdo);
     $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;
         }
     }
 }
Exemplo n.º 4
0
 public function getBookRange($cat, $start, $num, $orderby, $excludedcats = [])
 {
     $browseby = $this->getBrowseBy();
     if ($start === false) {
         $limit = '';
     } else {
         $limit = ' LIMIT ' . $num . ' OFFSET ' . $start;
     }
     $catsrch = '';
     if (count($cat) > 0 && $cat[0] != -1) {
         $catsrch = (new Category(['Settings' => $this->pdo]))->getCategorySearch($cat);
     }
     $maxage = '';
     if ($maxage > 0) {
         $maxage = sprintf(' AND r.postdate > NOW() - INTERVAL %d DAY ', $maxage);
     }
     $exccatlist = '';
     if (count($excludedcats) > 0) {
         $exccatlist = ' AND r.categoryid NOT IN (' . implode(',', $excludedcats) . ')';
     }
     $order = $this->getBookOrder($orderby);
     $sql = sprintf("SELECT GROUP_CONCAT(r.id ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_id, " . "GROUP_CONCAT(r.rarinnerfilecount ORDER BY r.postdate DESC SEPARATOR ',') as grp_rarinnerfilecount, " . "GROUP_CONCAT(r.haspreview ORDER BY r.postdate DESC SEPARATOR ',') AS grp_haspreview, " . "GROUP_CONCAT(r.passwordstatus ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_password, " . "GROUP_CONCAT(r.guid ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_guid, " . "GROUP_CONCAT(rn.id ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_nfoid, " . "GROUP_CONCAT(groups.name ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_grpname, " . "GROUP_CONCAT(r.searchname ORDER BY r.postdate DESC SEPARATOR '#') AS grp_release_name, " . "GROUP_CONCAT(r.postdate ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_postdate, " . "GROUP_CONCAT(r.size ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_size, " . "GROUP_CONCAT(r.totalpart ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_totalparts, " . "GROUP_CONCAT(r.comments ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_comments, " . "GROUP_CONCAT(r.grabs ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_grabs, " . "boo.*, r.bookinfoid, groups.name AS group_name, rn.id as nfoid FROM releases r " . "LEFT OUTER JOIN groups ON groups.id = r.group_id " . "LEFT OUTER JOIN release_nfos rn ON rn.releaseid = r.id " . "INNER JOIN bookinfo boo ON boo.id = r.bookinfoid " . "WHERE r.nzbstatus = 1 AND boo.cover = 1 AND boo.title != '' AND " . "r.passwordstatus %s AND %s %s %s %s " . "GROUP BY boo.id ORDER BY %s %s" . $limit, Releases::showPasswords($this->pdo), $browseby, $catsrch, $maxage, $exccatlist, $order[0], $order[1]);
     return $this->pdo->query($sql, true, nZEDb_CACHE_EXPIRY_MEDIUM);
 }
Exemplo n.º 5
0
        $uid = $res['id'];
        $catExclusions = $page->users->getCategoryExclusion($uid);
        $maxRequests = $res['apirequests'];
    }
}
$page->smarty->assign('uid', $uid);
$page->smarty->assign('rsstoken', $apiKey);
// Record user access to the api, if its been called by a user (i.e. capabilities request do not require a user to be logged in or key provided).
if ($uid != '') {
    $page->users->updateApiAccessed($uid);
    $apiRequests = $page->users->getApiRequests($uid);
    if ($apiRequests > $maxRequests) {
        showApiError(500, 'Request limit reached (' . $apiRequests . '/' . $maxRequests . ')');
    }
}
$releases = new Releases(['Settings' => $page->settings]);
$page->smarty->assign('extended', isset($_GET['extended']) && $_GET['extended'] == 1 ? '1' : '0');
$page->smarty->assign('del', isset($_GET['del']) && $_GET['del'] == 1 ? '1' : '0');
// Output is either json or xml.
$outputXML = isset($_GET['o']) && $_GET['o'] == 'json' ? false : true;
switch ($function) {
    // Search releases.
    case 's':
        verifyEmptyParameter('q');
        $maxAge = maxAge();
        $page->users->addApiRequest($uid, $_SERVER['REQUEST_URI']);
        $categoryID = categoryID();
        $limit = limit();
        $offset = offset();
        if (isset($_GET['q'])) {
            $relData = $releases->search($_GET['q'], -1, -1, -1, -1, -1, 0, 0, -1, -1, $offset, $limit, '', $maxAge, $catExclusions, "basic", $categoryID);
Exemplo n.º 6
0
 /**
  * @param       $cat
  * @param       $start
  * @param       $num
  * @param       $orderby
  * @param array $excludedcats
  *
  * @return array
  */
 public function getMusicRange($cat, $start, $num, $orderby, array $excludedcats = [])
 {
     $browseby = $this->getBrowseBy();
     $catsrch = '';
     if (count($cat) > 0 && $cat[0] != -1) {
         $catsrch = (new Category(['Settings' => $this->pdo]))->getCategorySearch($cat);
     }
     $exccatlist = "";
     if (count($excludedcats) > 0) {
         $exccatlist = " AND r.categoryid NOT IN (" . implode(",", $excludedcats) . ")";
     }
     $order = $this->getMusicOrder($orderby);
     $music = $this->pdo->queryCalc(sprintf("\n\t\t\t\tSELECT SQL_CALC_FOUND_ROWS\n\t\t\t\t\tm.id,\n\t\t\t\t\tGROUP_CONCAT(r.id ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_id\n\t\t\t\tFROM musicinfo m\n\t\t\t\tLEFT JOIN releases r ON r.musicinfoid = m.id\n\t\t\t\tWHERE r.nzbstatus = 1\n\t\t\t\tAND m.title != ''\n\t\t\t\tAND m.cover = 1\n\t\t\t\tAND r.passwordstatus %s\n\t\t\t\tAND %s %s %s\n\t\t\t\tGROUP BY m.id\n\t\t\t\tORDER BY %s %s %s", Releases::showPasswords($this->pdo), $browseby, $catsrch, $exccatlist, $order[0], $order[1], $start === false ? '' : ' LIMIT ' . $num . ' OFFSET ' . $start), true, nZEDb_CACHE_EXPIRY_MEDIUM);
     $musicIDs = $releaseIDs = false;
     if (is_array($music['result'])) {
         foreach ($music['result'] as $mus => $id) {
             $musicIDs[] = $id['id'];
             $releaseIDs[] = $id['grp_release_id'];
         }
     }
     $sql = sprintf("\n\t\t\tSELECT\n\t\t\t\tGROUP_CONCAT(r.id ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_id,\n\t\t\t\tGROUP_CONCAT(r.rarinnerfilecount ORDER BY r.postdate DESC SEPARATOR ',') as grp_rarinnerfilecount,\n\t\t\t\tGROUP_CONCAT(r.haspreview ORDER BY r.postdate DESC SEPARATOR ',') AS grp_haspreview,\n\t\t\t\tGROUP_CONCAT(r.passwordstatus ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_password,\n\t\t\t\tGROUP_CONCAT(r.guid ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_guid,\n\t\t\t\tGROUP_CONCAT(rn.releaseid ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_nfoid,\n\t\t\t\tGROUP_CONCAT(g.name ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_grpname,\n\t\t\t\tGROUP_CONCAT(r.searchname ORDER BY r.postdate DESC SEPARATOR '#') AS grp_release_name,\n\t\t\t\tGROUP_CONCAT(r.postdate ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_postdate,\n\t\t\t\tGROUP_CONCAT(r.size ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_size,\n\t\t\t\tGROUP_CONCAT(r.totalpart ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_totalparts,\n\t\t\t\tGROUP_CONCAT(r.comments ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_comments,\n\t\t\t\tGROUP_CONCAT(r.grabs ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_grabs,\n\t\t\t\tGROUP_CONCAT(df.failed ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_failed,\n\t\t\t\tm.*,\n\t\t\t\tr.musicinfoid, r.haspreview,\n\t\t\t\tg.name AS group_name,\n\t\t\t\trn.releaseid AS nfoid\n\t\t\tFROM releases r\n\t\t\tLEFT OUTER JOIN groups g ON g.id = r.group_id\n\t\t\tLEFT OUTER JOIN release_nfos rn ON rn.releaseid = r.id\n\t\t\tLEFT OUTER JOIN dnzb_failures df ON df.release_id = r.id\n\t\t\tINNER JOIN musicinfo m ON m.id = r.musicinfoid\n\t\t\tWHERE m.id IN (%s)\n\t\t\tAND r.id IN (%s)\n\t\t\tAND %s\n\t\t\tGROUP BY m.id\n\t\t\tORDER BY %s %s", is_array($musicIDs) ? implode(',', $musicIDs) : -1, is_array($releaseIDs) ? implode(',', $releaseIDs) : -1, $catsrch, $order[0], $order[1]);
     $return = $this->pdo->query($sql, true, nZEDb_CACHE_EXPIRY_MEDIUM);
     if (!empty($return)) {
         $return[0]['_totalcount'] = isset($music['total']) ? $music['total'] : 0;
     }
     return $return;
 }
Exemplo n.º 7
0
<?php

require_once './config.php';
use nzedb\Category;
use nzedb\Releases;
$page = new AdminPage(true);
$releases = new Releases(['Settings' => $page->settings]);
$category = new Category(['Settings' => $page->settings]);
$id = 0;
// Set the current action.
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'view';
$from = isset($_REQUEST['from']) ? $_REQUEST['from'] : WWW_TOP . "/release-list.php";
switch ($action) {
    case 'submit':
        $releases->update($_POST["id"], $_POST["name"], $_POST["searchname"], $_POST["fromname"], $_POST["category"], $_POST["totalpart"], $_POST["grabs"], $_POST["size"], $_POST["postdate"], $_POST["adddate"], $_POST["videos_id"], $_POST["tv_episodes_id"], $_POST["imdbid"], $_POST["anidbid"]);
        header("Location:" . $from);
        break;
    case 'view':
    default:
        if (isset($_GET["id"])) {
            $page->title = "Release Edit";
            $id = $_GET["id"];
            $release = $releases->getByID($id);
            $page->smarty->assign('release', $release);
        }
        break;
}
$page->smarty->assign('from', $from);
$page->smarty->assign('yesno_ids', [1, 0]);
$page->smarty->assign('yesno_names', ['Yes', 'No']);
$page->smarty->assign('catlist', $category->getForSelect(false));
Exemplo n.º 8
0
<?php

use nzedb\Releases;
if (!$page->users->isLoggedIn()) {
    $page->show403();
}
if (!isset($_REQUEST["id"])) {
    $page->show404();
}
$r = new Releases(['Settings' => $page->settings]);
$rel = $r->getByGuid($_REQUEST["id"]);
if (!$rel) {
    print "No release info found";
} else {
    print "<table>\n";
    print "<tr><th>Title:</th><td>" . htmlentities($rel["searchname"], ENT_QUOTES) . "</td></tr>\n";
    if (isset($rel["category_name"]) && $rel["category_name"] != "") {
        print "<tr><th>Cat:</th><td>" . htmlentities($rel["category_name"], ENT_QUOTES) . "</td></tr>\n";
    }
    print "<tr><th>Group:</th><td>" . htmlentities($rel["group_name"], ENT_QUOTES) . "</td></tr>\n";
    if (isset($rel["size"])) {
        if (preg_match('/\\d+/', $rel["size"], $size)) {
        }
        if ($size[0] > 0) {
            print "<tr><th>Size:</th><td>" . htmlentities(floor($rel["size"] / 1024 / 1024), ENT_QUOTES) . " MB</td></tr>\n";
        }
    }
    print "<tr><th>Posted:</th><td>" . htmlentities($rel["postdate"], ENT_QUOTES) . "</td></tr>\n";
    print "</table>";
}
Exemplo n.º 9
0
}
// Check download limit on user role.
$requests = $page->users->getDownloadRequests($uid);
if ($requests > $maxDownloads) {
    header("X-DNZB-RCode: 503");
    header("X-DNZB-RText: User has exceeded maximum downloads for the day!");
    $page->show503();
}
if (!isset($_GET['id'])) {
    header("X-DNZB-RCode: 400");
    header("X-DNZB-RText: Bad request! (parameter id is required)");
    $page->show403();
}
// Remove any suffixed id with .nzb which is added to help weblogging programs see nzb traffic.
$_GET['id'] = str_ireplace('.nzb', '', $_GET['id']);
$rel = new Releases(['Settings' => $page->settings]);
// User requested a zip of guid,guid,guid releases.
if (isset($_GET["zip"]) && $_GET["zip"] == "1") {
    $guids = explode(",", $_GET["id"]);
    if ($requests['num'] + sizeof($guids) > $maxDownloads) {
        header("X-DNZB-RCode: 503");
        header("X-DNZB-RText: User has exceeded maximum downloads for the day!");
        $page->show503();
    }
    $zip = $rel->getZipped($guids);
    if (strlen($zip) > 0) {
        $page->users->incrementGrabs($uid, count($guids));
        foreach ($guids as $guid) {
            $rel->updateGrab($guid);
            $page->users->addDownloadRequest($uid);
            if (isset($_GET["del"]) && $_GET["del"] == 1) {
Exemplo n.º 10
0
<?php

require_once dirname(__FILE__) . '/../../../www/config.php';
use nzedb\ConsoleTools;
use nzedb\NZB;
use nzedb\ReleaseImage;
use nzedb\Releases;
use nzedb\db\Settings;
use nzedb\utility\Utility;
$pdo = new Settings();
if (isset($argv[1]) && ($argv[1] === "true" || $argv[1] === "delete")) {
    $releases = new Releases(['Settings' => $pdo]);
    $nzb = new NZB($pdo);
    $releaseImage = new ReleaseImage($pdo);
    $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]);
    $timestart = time();
    $checked = $deleted = 0;
    $couldbe = $argv[1] === "true" ? $couldbe = "could be " : "were ";
    echo $pdo->log->header('Getting List of nzbs to check against db.');
    $dirItr = new \RecursiveDirectoryIterator($pdo->getSetting('nzbpath'));
    $itr = new \RecursiveIteratorIterator($dirItr, \RecursiveIteratorIterator::LEAVES_ONLY);
    foreach ($itr as $filePath) {
        if (is_file($filePath) && preg_match('/([a-f-0-9]+)\\.nzb\\.gz/', $filePath, $guid)) {
            $nzbfile = Utility::unzipGzipFile($filePath);
            if ($nzbfile) {
                $nzbfile = @simplexml_load_string($nzbfile);
            }
            if ($nzbfile) {
                $res = $pdo->queryOneRow(sprintf("SELECT id, guid FROM releases WHERE guid = %s", $pdo->escapeString(stristr($filePath->getFilename(), '.nzb.gz', true))));
                if ($res === false) {
                    if ($argv[1] === "delete") {
Exemplo n.º 11
0
<?php

require_once './config.php';
use nzedb\Logging;
use nzedb\Releases;
$page = new AdminPage();
$releases = new Releases(['Settings' => $page->settings]);
$logging = new Logging(['Settings' => $page->settings]);
if ($page->settings->getSetting('loggingopt') == '0') {
    $loggingon = '0';
} else {
    $loggingon = '1';
}
$page->smarty->assign('loggingon', $loggingon);
$page->title = 'Site Stats';
$topgrabs = $page->users->getTopGrabbers();
$page->smarty->assign('topgrabs', $topgrabs);
$topdownloads = $releases->getTopDownloads();
$page->smarty->assign('topdownloads', $topdownloads);
$topcomments = $releases->getTopComments();
$page->smarty->assign('topcomments', $topcomments);
$recent = $releases->getRecentlyAdded();
$page->smarty->assign('recent', $recent);
if ($loggingon == '1') {
    $toplogincombined = $logging->getTopCombined();
    $page->smarty->assign('toplogincombined', $toplogincombined);
    $toploginips = $logging->getTopIPs();
    $page->smarty->assign('toploginips', $toploginips);
}
$page->content = $page->smarty->fetch('site-stats.tpl');
$page->render();
Exemplo n.º 12
0
<?php

use nzedb\Category;
use nzedb\Releases;
$page = new AdminPage(true);
$releases = new Releases(['Settings' => $page->settings]);
$category = new Category(['Settings' => $page->settings]);
// Set the current action.
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
$id = isset($_REQUEST['id']) && is_array($_REQUEST['id']) ? $_REQUEST['id'] : '';
$page->smarty->assign('action', $action);
$page->smarty->assign('idArr', $id);
switch ($action) {
    case 'doedit':
    case 'edit':
        $success = false;
        if ($action == 'doedit') {
            $upd = $releases->updatemulti($_REQUEST["id"], $_REQUEST["category"], $_REQUEST["grabs"], $_REQUEST["rageid"], $_REQUEST["season"], $_REQUEST['imdbid']);
            if ($upd !== false) {
                $success = true;
            } else {
            }
        }
        $page->smarty->assign('success', $success);
        $page->smarty->assign('from', isset($_REQUEST['from']) ? $_REQUEST['from'] : '');
        $page->smarty->assign('catlist', $category->getForSelect());
        $page->content = $page->smarty->fetch('ajax_release-edit.tpl');
        echo $page->content;
        break;
    case 'dodelete':
        $is_guid = true;
Exemplo n.º 13
0
function create_guids($live, $delete = false)
{
    $pdo = new Settings();
    $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]);
    $timestart = TIME();
    $relcount = $deleted = $total = 0;
    $relrecs = false;
    if ($live == "true") {
        $relrecs = $pdo->queryDirect(sprintf("SELECT id, guid FROM releases WHERE nzbstatus = 1 AND nzb_guid IS NULL ORDER BY id DESC"));
    } else {
        if ($live == "limited") {
            $relrecs = $pdo->queryDirect(sprintf("SELECT id, guid FROM releases WHERE nzbstatus = 1 AND nzb_guid IS NULL ORDER BY id DESC LIMIT 10000"));
        }
    }
    if ($relrecs) {
        $total = $relrecs->rowCount();
    }
    if ($total > 0) {
        echo $pdo->log->header("Creating nzb_guids for " . number_format($total) . " releases.");
        $releases = new Releases(['Settings' => $pdo]);
        $nzb = new NZB($pdo);
        $releaseImage = new ReleaseImage($pdo);
        $reccnt = 0;
        if ($relrecs instanceof \Traversable) {
            foreach ($relrecs as $relrec) {
                $reccnt++;
                $nzbpath = $nzb->NZBPath($relrec['guid']);
                if ($nzbpath !== false) {
                    $nzbfile = Utility::unzipGzipFile($nzbpath);
                    if ($nzbfile) {
                        $nzbfile = @simplexml_load_string($nzbfile);
                    }
                    if (!$nzbfile) {
                        if (isset($delete) && $delete == 'delete') {
                            //echo "\n".$nzb->NZBPath($relrec['guid'])." is not a valid xml, deleting release.\n";
                            $releases->deleteSingle(['g' => $relrec['guid'], 'i' => $relrec['id']], $nzb, $releaseImage);
                            $deleted++;
                        }
                        continue;
                    }
                    $binary_names = array();
                    foreach ($nzbfile->file as $file) {
                        $binary_names[] = $file["subject"];
                    }
                    if (count($binary_names) == 0) {
                        if (isset($delete) && $delete == 'delete') {
                            //echo "\n".$nzb->NZBPath($relrec['guid'])." has no binaries, deleting release.\n";
                            $releases->deleteSingle(['g' => $relrec['guid'], 'i' => $relrec['id']], $nzb, $releaseImage);
                            $deleted++;
                        }
                        continue;
                    }
                    asort($binary_names);
                    foreach ($nzbfile->file as $file) {
                        if ($file["subject"] == $binary_names[0]) {
                            $segment = $file->segments->segment;
                            $nzb_guid = md5($segment);
                            $pdo->queryExec("UPDATE releases set nzb_guid = " . $pdo->escapestring($nzb_guid) . " WHERE id = " . $relrec["id"]);
                            $relcount++;
                            $consoletools->overWritePrimary("Created: [" . $deleted . "] " . $consoletools->percentString($reccnt, $total) . " Time:" . $consoletools->convertTimer(TIME() - $timestart));
                            break;
                        }
                    }
                } else {
                    if (isset($delete) && $delete == 'delete') {
                        //echo $pdo->log->primary($nzb->NZBPath($relrec['guid']) . " does not have an nzb, deleting.");
                        $releases->deleteSingle(['g' => $relrec['guid'], 'i' => $relrec['id']], $nzb, $releaseImage);
                    }
                }
            }
        }
        if ($relcount > 0) {
            echo "\n";
        }
        echo $pdo->log->header("Updated " . $relcount . " release(s). This script ran for " . $consoletools->convertTime(TIME() - $timestart));
    } else {
        echo $pdo->log->info('Query time: ' . $consoletools->convertTime(TIME() - $timestart));
        exit($pdo->log->info("No releases are missing the guid."));
    }
}
Exemplo n.º 14
0
<?php

use nzedb\Category;
use nzedb\Releases;
use nzedb\Videos;
use nzedb\UserSeries;
if (!$page->users->isLoggedIn()) {
    $page->show403();
}
$releases = new Releases(['Settings' => $page->settings]);
$tvshow = new Videos(['Settings' => $page->settings]);
$cat = new Category(['Settings' => $page->settings]);
$us = new UserSeries(['Settings' => $page->settings]);
if (isset($_GET["id"]) && ctype_digit($_GET['id'])) {
    $category = -1;
    if (isset($_REQUEST["t"]) && ctype_digit($_REQUEST["t"])) {
        $category = $_REQUEST["t"];
    }
    $catarray = array();
    $catarray[] = $category;
    $rel = $releases->searchShows(['id' => $_GET["id"]], '', '', '', 0, 1000, '', $catarray, -1);
    $show = $tvshow->getByVideoID($_GET['id']);
    if (!$show) {
        $page->smarty->assign("nodata", "No video information for this series.");
    } elseif (!$rel) {
        $page->smarty->assign("nodata", "No releases for this series.");
    } else {
        $myshows = $us->getShow($page->users->currentUserId(), $show['id']);
        // Sort releases by season, episode, date posted.
        $series = $episode = $posted = array();
        foreach ($rel as $rlk => $rlv) {
Exemplo n.º 15
0
<?php

use nzedb\Category;
use nzedb\Releases;
use nzedb\TvRage;
use nzedb\UserSeries;
if (!$page->users->isLoggedIn()) {
    $page->show403();
}
$releases = new Releases(['Settings' => $page->settings]);
$tvrage = new TvRage(['Settings' => $page->settings]);
$cat = new Category(['Settings' => $page->settings]);
$us = new UserSeries(['Settings' => $page->settings]);
if (isset($_GET["id"]) && ctype_digit($_GET['id'])) {
    $category = -1;
    if (isset($_REQUEST["t"]) && ctype_digit($_REQUEST["t"])) {
        $category = $_REQUEST["t"];
    }
    $catarray = array();
    $catarray[] = $category;
    $rel = $releases->searchbyRageId($_GET["id"], '', '', 0, 1000, "", $catarray, -1);
    $rage = $tvrage->getByRageID($_GET['id']);
    if (!$rage) {
        $page->smarty->assign("nodata", "No tvrage information for this series.");
    } elseif (!$rel) {
        $page->smarty->assign("nodata", "No releases for this series.");
    } else {
        $myshows = $us->getShow($page->users->currentUserId(), $rage[0]['rageid']);
        // Sort releases by season, episode, date posted.
        $season = $episode = $posted = array();
        foreach ($rel as $rlk => $rlv) {
Exemplo n.º 16
0
    /**
     * Delete releases using admin settings.
     * This deletes releases, regardless of group.
     *
     * @void
     * @access public
     */
    public function deleteReleases()
    {
        $startTime = time();
        $category = new Category(['Settings' => $this->pdo]);
        $genres = new Genres(['Settings' => $this->pdo]);
        $passwordDeleted = $duplicateDeleted = $retentionDeleted = $completionDeleted = $disabledCategoryDeleted = 0;
        $disabledGenreDeleted = $miscRetentionDeleted = $miscHashedDeleted = $categoryMinSizeDeleted = 0;
        // Delete old releases and finished collections.
        if ($this->echoCLI) {
            $this->pdo->log->doEcho($this->pdo->log->header("Process Releases -> Delete old releases and passworded releases."));
        }
        // Releases past retention.
        if ($this->pdo->getSetting('releaseretentiondays') != 0) {
            $releases = $this->pdo->queryDirect(sprintf('SELECT SQL_NO_CACHE id, guid FROM releases WHERE postdate < (NOW() - INTERVAL %d DAY)', $this->pdo->getSetting('releaseretentiondays')));
            if ($releases instanceof \Traversable) {
                foreach ($releases as $release) {
                    $this->releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage);
                    $retentionDeleted++;
                }
            }
        }
        // Passworded releases.
        if ($this->pdo->getSetting('deletepasswordedrelease') == 1) {
            $releases = $this->pdo->queryDirect(sprintf('SELECT SQL_NO_CACHE id, guid FROM releases WHERE passwordstatus = %d', Releases::PASSWD_RAR));
            if ($releases instanceof \Traversable) {
                foreach ($releases as $release) {
                    $this->releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage);
                    $passwordDeleted++;
                }
            }
        }
        // Possibly passworded releases.
        if ($this->pdo->getSetting('deletepossiblerelease') == 1) {
            $releases = $this->pdo->queryDirect(sprintf('SELECT SQL_NO_CACHE id, guid FROM releases WHERE passwordstatus = %d', Releases::PASSWD_POTENTIAL));
            if ($releases instanceof \Traversable) {
                foreach ($releases as $release) {
                    $this->releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage);
                    $passwordDeleted++;
                }
            }
        }
        if ($this->crossPostTime != 0) {
            // Crossposted releases.
            do {
                $releases = $this->pdo->queryDirect(sprintf('SELECT SQL_NO_CACHE id, guid FROM releases WHERE adddate > (NOW() - INTERVAL %d HOUR) GROUP BY name HAVING COUNT(name) > 1', $this->crossPostTime));
                $total = 0;
                if ($releases && $releases->rowCount()) {
                    $total = $releases->rowCount();
                    foreach ($releases as $release) {
                        $this->releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage);
                        $duplicateDeleted++;
                    }
                }
            } while ($total > 0);
        }
        if ($this->completion > 0) {
            $releases = $this->pdo->queryDirect(sprintf('SELECT SQL_NO_CACHE id, guid FROM releases WHERE completion < %d AND completion > 0', $this->completion));
            if ($releases instanceof \Traversable) {
                foreach ($releases as $release) {
                    $this->releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage);
                    $completionDeleted++;
                }
            }
        }
        // Disabled categories.
        $disabledCategories = $category->getDisabledIDs();
        if (count($disabledCategories) > 0) {
            foreach ($disabledCategories as $disabledCategory) {
                $releases = $this->pdo->queryDirect(sprintf('SELECT SQL_NO_CACHE id, guid FROM releases WHERE categoryid = %d', $disabledCategory['id']));
                if ($releases instanceof \Traversable) {
                    foreach ($releases as $release) {
                        $disabledCategoryDeleted++;
                        $this->releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage);
                    }
                }
            }
        }
        // Delete smaller than category minimum sizes.
        $categories = $this->pdo->queryDirect('
			SELECT SQL_NO_CACHE c.id AS id,
			CASE WHEN c.minsize = 0 THEN cp.minsize ELSE c.minsize END AS minsize
			FROM category c
			INNER JOIN category cp ON cp.id = c.parentid
			WHERE c.parentid IS NOT NULL');
        if ($categories instanceof \Traversable) {
            foreach ($categories as $category) {
                if ($category['minsize'] > 0) {
                    $releases = $this->pdo->queryDirect(sprintf('
							SELECT SQL_NO_CACHE r.id, r.guid
							FROM releases r
							WHERE r.categoryid = %d
							AND r.size < %d LIMIT 1000', $category['id'], $category['minsize']));
                    if ($releases instanceof \Traversable) {
                        foreach ($releases as $release) {
                            $this->releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage);
                            $categoryMinSizeDeleted++;
                        }
                    }
                }
            }
        }
        // Disabled music genres.
        $genrelist = $genres->getDisabledIDs();
        if (count($genrelist) > 0) {
            foreach ($genrelist as $genre) {
                $releases = $this->pdo->queryDirect(sprintf('
						SELECT SQL_NO_CACHE id, guid
						FROM releases
						INNER JOIN (SELECT id AS mid FROM musicinfo WHERE musicinfo.genre_id = %d) mi
						ON musicinfoid = mid', $genre['id']));
                if ($releases instanceof \Traversable) {
                    foreach ($releases as $release) {
                        $disabledGenreDeleted++;
                        $this->releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage);
                    }
                }
            }
        }
        // Misc other.
        if ($this->pdo->getSetting('miscotherretentionhours') > 0) {
            $releases = $this->pdo->queryDirect(sprintf('
					SELECT SQL_NO_CACHE id, guid
					FROM releases
					WHERE categoryid = %d
					AND adddate <= NOW() - INTERVAL %d HOUR', Category::CAT_OTHER_MISC, $this->pdo->getSetting('miscotherretentionhours')));
            if ($releases instanceof \Traversable) {
                foreach ($releases as $release) {
                    $this->releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage);
                    $miscRetentionDeleted++;
                }
            }
        }
        // Misc hashed.
        if ($this->pdo->getSetting('mischashedretentionhours') > 0) {
            $releases = $this->pdo->queryDirect(sprintf('
					SELECT SQL_NO_CACHE id, guid
					FROM releases
					WHERE categoryid = %d
					AND adddate <= NOW() - INTERVAL %d HOUR', Category::CAT_OTHER_HASHED, $this->pdo->getSetting('mischashedretentionhours')));
            if ($releases instanceof \Traversable) {
                foreach ($releases as $release) {
                    $this->releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage);
                    $miscHashedDeleted++;
                }
            }
        }
        if ($this->echoCLI) {
            $this->pdo->log->doEcho($this->pdo->log->primary('Removed releases: ' . number_format($retentionDeleted) . ' past retention, ' . number_format($passwordDeleted) . ' passworded, ' . number_format($duplicateDeleted) . ' crossposted, ' . number_format($disabledCategoryDeleted) . ' from disabled categories, ' . number_format($categoryMinSizeDeleted) . ' smaller than category settings, ' . number_format($disabledGenreDeleted) . ' from disabled music genres, ' . number_format($miscRetentionDeleted) . ' from misc->other' . number_format($miscHashedDeleted) . ' from misc->hashed' . ($this->completion > 0 ? ', ' . number_format($completionDeleted) . ' under ' . $this->completion . '% completion.' : '.')));
            $totalDeleted = $retentionDeleted + $passwordDeleted + $duplicateDeleted + $disabledCategoryDeleted + $disabledGenreDeleted + $miscRetentionDeleted + $miscHashedDeleted + $completionDeleted + $categoryMinSizeDeleted;
            if ($totalDeleted > 0) {
                $this->pdo->log->doEcho($this->pdo->log->primary("Removed " . number_format($totalDeleted) . ' releases in ' . $this->consoleTools->convertTime(time() - $startTime)));
            }
        }
    }
Exemplo n.º 17
0
<?php

use nzedb\NZB;
use nzedb\Releases;
use nzedb\utility\Utility;
if (!$page->users->isLoggedIn()) {
    $page->show403();
}
if (isset($_GET["id"])) {
    $releases = new Releases(['Settings' => $page->settings]);
    $rel = $releases->getByGuid($_GET["id"]);
    if (!$rel) {
        $page->show404();
    }
    $nzb = new NZB($page->settings);
    $nzbpath = $nzb->getNZBPath($_GET["id"]);
    if (!file_exists($nzbpath)) {
        $page->show404();
    }
    $nzbfile = Utility::unzipGzipFile($nzbpath);
    $ret = $nzb->nzbFileList($nzbfile);
    $offset = isset($_REQUEST["offset"]) && ctype_digit($_REQUEST['offset']) ? $_REQUEST["offset"] : 0;
    $page->smarty->assign('pagertotalitems', sizeof($ret));
    $page->smarty->assign('pageroffset', $offset);
    $page->smarty->assign('pageritemsperpage', ITEMS_PER_PAGE);
    $page->smarty->assign('pagerquerybase', WWW_TOP . "/filelist/" . $_GET["id"] . "/&amp;offset=");
    $page->smarty->assign('pagerquerysuffix', "#results");
    $pager = $page->smarty->fetch("pager.tpl");
    $page->smarty->assign('pager', $pager);
    $page->smarty->assign('rel', $rel);
    $page->smarty->assign('files', array_slice($ret, $offset, ITEMS_PER_PAGE));
Exemplo n.º 18
0
use nzedb\Games;
use nzedb\Movie;
use nzedb\Music;
use nzedb\PreDb;
use nzedb\ReleaseComments;
use nzedb\ReleaseExtra;
use nzedb\ReleaseFiles;
use nzedb\Releases;
use nzedb\Videos;
use nzedb\XXX;
use nzedb\DnzbFailures;
if (!$page->users->isLoggedIn()) {
    $page->show403();
}
if (isset($_GET['id'])) {
    $releases = new Releases(['Settings' => $page->settings]);
    $data = $releases->getByGuid($_GET['id']);
    if (!$data) {
        $page->show404();
    }
    $rc = new ReleaseComments($page->settings);
    $fail = new DnzbFailures(['Settings' => $page->settings]);
    if ($page->isPostBack()) {
        $rc->addComment($data['id'], $_POST['txtAddComment'], $page->users->currentUserId(), $_SERVER['REMOTE_ADDR']);
    }
    $criteria = $mov = $xxx = '';
    if ($data['videos_id'] != 0) {
        $showInfo = (new Videos(['Settings' => $page->settings]))->getByVideoID($data['videos_id']);
        if (count($showInfo) > 0) {
            $criteria = ['title' => '', 'summary' => '', 'countries_id' => '', 'image' => '', 'id' => ''];
            $done = 1;
Exemplo n.º 19
0
 /**
  * Export to user specified folder.
  *
  * @param array $params
  *
  * @return bool
  *
  * @access public
  */
 public function beginExport($params)
 {
     $gzip = false;
     if ($params[4] === true) {
         $gzip = true;
     }
     $fromDate = $toDate = '';
     $path = $params[0];
     // Check if the path ends with dir separator.
     if (substr($path, -1) !== DS) {
         $path .= DS;
     }
     // Check if it's a directory.
     if (!is_dir($path)) {
         $this->echoOut('Folder does not exist: ' . $path);
         return $this->returnValue();
     }
     // Check if we can write to it.
     if (!is_writable($path)) {
         $this->echoOut('Folder is not writable: ' . $path);
         return $this->returnValue();
     }
     // Check if the from date is the proper format.
     if (isset($params[1]) && $params[1] !== '') {
         if (!$this->checkDate($params[1])) {
             return $this->returnValue();
         }
         $fromDate = $params[1];
     }
     // Check if the to date is the proper format.
     if (isset($params[2]) && $params[2] !== '') {
         if (!$this->checkDate($params[2])) {
             return $this->returnValue();
         }
         $toDate = $params[2];
     }
     // Check if the group_id exists.
     if (isset($params[3]) && $params[3] !== 0) {
         if (!is_numeric($params[3])) {
             $this->echoOut('The group ID is not a number: ' . $params[3]);
             return $this->returnValue();
         }
         $groups = $this->pdo->query('SELECT id, name FROM groups WHERE id = ' . $params[3]);
         if (count($groups) === 0) {
             $this->echoOut('The group ID is not in the DB: ' . $params[3]);
             return $this->returnValue();
         }
     } else {
         $groups = $this->pdo->query('SELECT id, name FROM groups');
     }
     $exported = 0;
     // Loop over groups to take less RAM.
     foreach ($groups as $group) {
         $currentExport = 0;
         // Get all the releases based on the parameters.
         $releases = $this->releases->getForExport($fromDate, $toDate, $group['id']);
         $totalFound = count($releases);
         if ($totalFound === 0) {
             if ($this->echoCLI) {
                 echo 'No releases found to export for group: ' . $group['name'] . PHP_EOL;
             }
             continue;
         }
         if ($this->echoCLI) {
             echo 'Found ' . $totalFound . ' releases to export for group: ' . $group['name'] . PHP_EOL;
         }
         // Create a path to store the new NZB files.
         $currentPath = $path . $this->safeFilename($group['name']) . DS;
         if (!is_dir($currentPath)) {
             mkdir($currentPath);
         }
         foreach ($releases as $release) {
             // Get path to the NZB file.
             $nzbFile = $this->nzb->NZBPath($release["guid"]);
             // Check if it exists.
             if ($nzbFile === false) {
                 if ($this->echoCLI) {
                     echo 'Unable to find NZB for release with GUID: ' . $release['guid'];
                 }
                 continue;
             }
             // Create path to current file.
             $currentFile = $currentPath . $this->safeFilename($release['searchname']);
             // Check if the user wants them in gzip, copy it if so.
             if ($gzip) {
                 if (!copy($nzbFile, $currentFile . '.nzb.gz')) {
                     if ($this->echoCLI) {
                         echo 'Unable to export NZB with GUID: ' . $release['guid'];
                     }
                     continue;
                 }
                 // If not, decompress it and create a file to store it in.
             } else {
                 $nzbContents = Utility::unzipGzipFile($nzbFile);
                 if (!$nzbContents) {
                     if ($this->echoCLI) {
                         echo 'Unable to export NZB with GUID: ' . $release['guid'];
                     }
                     continue;
                 }
                 $fh = fopen($currentFile . '.nzb', 'w');
                 fwrite($fh, $nzbContents);
                 fclose($fh);
             }
             $currentExport++;
             if ($this->echoCLI && $currentExport % 10 === 0) {
                 echo 'Exported ' . $currentExport . ' of ' . $totalFound . ' nzbs for group: ' . $group['name'] . "\r";
             }
         }
         if ($this->echoCLI && $currentExport > 0) {
             echo 'Exported ' . $currentExport . ' of ' . $totalFound . ' nzbs for group: ' . $group['name'] . PHP_EOL;
         }
         $exported += $currentExport;
     }
     if ($exported > 0) {
         $this->echoOut('Exported total of ' . $exported . ' NZB files to ' . $path);
     }
     return $this->returnValue();
 }
Exemplo n.º 20
0
 public function getConsoleRange($cat, $start, $num, $orderby, $excludedcats = [])
 {
     $browseby = $this->getBrowseBy();
     if ($start === false) {
         $limit = "";
     } else {
         $limit = " LIMIT " . $num . " OFFSET " . $start;
     }
     $catsrch = '';
     if (count($cat) > 0 && $cat[0] != -1) {
         $catsrch = (new Category(['Settings' => $this->pdo]))->getCategorySearch($cat);
     }
     $exccatlist = "";
     if (count($excludedcats) > 0) {
         $exccatlist = " AND r.categoryid NOT IN (" . implode(",", $excludedcats) . ")";
     }
     $order = $this->getConsoleOrder($orderby);
     return $this->pdo->query(sprintf("SELECT GROUP_CONCAT(r.id ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_id, " . "GROUP_CONCAT(r.rarinnerfilecount ORDER BY r.postdate DESC SEPARATOR ',') as grp_rarinnerfilecount, " . "GROUP_CONCAT(r.haspreview ORDER BY r.postdate DESC SEPARATOR ',') AS grp_haspreview, " . "GROUP_CONCAT(r.passwordstatus ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_password, " . "GROUP_CONCAT(r.guid ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_guid, " . "GROUP_CONCAT(rn.id ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_nfoid, " . "GROUP_CONCAT(groups.name ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_grpname, " . "GROUP_CONCAT(r.searchname ORDER BY r.postdate DESC SEPARATOR '#') AS grp_release_name, " . "GROUP_CONCAT(r.postdate ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_postdate, " . "GROUP_CONCAT(r.size ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_size, " . "GROUP_CONCAT(r.totalpart ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_totalparts, " . "GROUP_CONCAT(r.comments ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_comments, " . "GROUP_CONCAT(r.grabs ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_grabs, " . "con.*, r.consoleinfoid, groups.name AS group_name, genres.title as genre, rn.id as nfoid FROM releases r " . "LEFT OUTER JOIN groups ON groups.id = r.group_id " . "LEFT OUTER JOIN release_nfos rn ON rn.releaseid = r.id " . "INNER JOIN consoleinfo con ON con.id = r.consoleinfoid " . "INNER JOIN genres ON con.genre_id = genres.id " . "WHERE r.nzbstatus = 1 AND con.title != '' AND " . "r.passwordstatus %s AND %s %s %s " . "GROUP BY con.id ORDER BY %s %s" . $limit, Releases::showPasswords($this->pdo), $browseby, $catsrch, $exccatlist, $order[0], $order[1]), true, nZEDb_CACHE_EXPIRY_MEDIUM);
 }
Exemplo n.º 21
0
 /**
  * Purge a single group or all groups.
  *
  * @param int|string|bool $id The group ID. If false, purge all groups.
  */
 public function purge($id = false)
 {
     if ($id === false) {
         $this->resetall();
     } else {
         $this->reset($id);
     }
     $releaseArray = $this->pdo->queryDirect(sprintf("SELECT id, guid FROM releases %s", $id === false ? '' : 'WHERE group_id = ' . $id));
     if ($releaseArray instanceof \Traversable) {
         $releases = new Releases(['Settings' => $this->pdo, 'Groups' => $this]);
         $nzb = new NZB($this->pdo);
         $releaseImage = new ReleaseImage($this->pdo);
         foreach ($releaseArray as $release) {
             $releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $nzb, $releaseImage);
         }
     }
 }
Exemplo n.º 22
0
use nzedb\NZB;
use nzedb\ReleaseCleaning;
use nzedb\Releases;
use nzedb\db\Settings;
$pdo = new Settings();
if (!isset($argv[1])) {
    exit($pdo->log->error("\nYou must supply a path as the first argument. Two additional, optional arguments can also be used.\n\n" . "php {$argv['0']} /path/to/import true 1000            ...: To import using the filename as release searchname, limited to 1000\n" . "php {$argv['0']} /path/to/import false                ...: To import using the subject as release searchname\n"));
}
$consoleTools = new ConsoleTools(['ColorCLI' => $pdo->log]);
$binaries = new Binaries(['Settings' => $pdo]);
$crosspostt = $pdo->getSetting('crossposttime');
$crosspostt = !empty($crosspostt) ? $crosspostt : 2;
$releasecleaning = new ReleaseCleaning($pdo);
$categorize = new Categorize(['Settings' => $pdo]);
$nzb = new NZB($pdo);
$releases = new Releases(['Settings' => $pdo]);
$nzbsperhour = $nzbSkipped = $maxtoprocess = 0;
if (isset($argv[2]) && is_numeric($argv[2])) {
    exit($pdo->log->error("\nTo use a max number to process, it must be the third argument. \nTo run:\nphp nzb-import.php /path [true, false] 1000\n"));
}
if (!isset($argv[2])) {
    $pieces = explode("   ", $argv[1]);
    $usenzbname = isset($pieces[1]) && $pieces[1] == 'true' ? true : false;
    $path = $pieces[0];
} else {
    $path = $argv[1];
    $usenzbname = isset($argv[2]) && $argv[2] == 'true' ? true : false;
}
if (isset($argv[3]) && is_numeric($argv[3])) {
    $maxtoprocess = $argv[3];
}
Exemplo n.º 23
0
<?php

use nzedb\Category;
use nzedb\Releases;
use nzedb\db\Settings;
$category = new Category(['Settings' => $page->settings]);
$releases = new Releases(['Settings' => $page->settings]);
// If no content id provided then show user the rss selection page.
if (!isset($_GET["t"]) && !isset($_GET["rage"]) && !isset($_GET["anidb"])) {
    // User has to either be logged in, or using rsskey.
    if (!$page->users->isLoggedIn()) {
        if ($page->settings->getSetting('registerstatus') != Settings::REGISTER_STATUS_API_ONLY) {
            header('X-nZEDb: ERROR: You must be logged in or provide a valid User ID and API key!');
            $page->show403();
        } else {
            header("Location: " . $page->settings->getSetting('code'));
        }
    }
    $page->title = "Rss Feeds";
    $page->meta_title = "Rss Nzb Feeds";
    $page->meta_keywords = "view,nzb,description,details,rss,atom";
    $page->meta_description = "View available Rss Nzb feeds.";
    $page->smarty->assign(['categorylist' => $category->get(true, $page->userdata["categoryexclusions"]), 'parentcategorylist' => $category->getForMenu($page->userdata["categoryexclusions"])]);
    $page->content = $page->smarty->fetch('rssdesc.tpl');
    $page->render();
} else {
    $rssToken = $uid = -1;
    // User requested a feed, ensure either logged in or passing a valid token.
    if ($page->users->isLoggedIn()) {
        $uid = $page->userdata["id"];
        $rssToken = $page->userdata["rsstoken"];
Exemplo n.º 24
0
 /**
  * Get movies for RSS.
  *
  * @param int   $limit
  * @param int   $userID
  * @param array $excludedCats
  *
  * @return array
  */
 public function getMyMoviesRss($limit, $userID = 0, $excludedCats = [])
 {
     return $this->pdo->query(sprintf("\n\t\t\t\tSELECT r.*, mi.title AS releasetitle, g.name AS group_name,\n\t\t\t\t\tCONCAT(cp.title, '-', c.title) AS category_name,\n\t\t\t\t\t%s AS category_ids,\n\t\t\t\t\tCOALESCE(cp.id,0) AS parentCategoryid\n\t\t\t\tFROM releases r\n\t\t\t\tINNER JOIN category c ON c.id = r.categoryid\n\t\t\t\tINNER JOIN category cp ON cp.id = c.parentid\n\t\t\t\tINNER JOIN groups g ON g.id = r.group_id\n\t\t\t\tLEFT OUTER JOIN movieinfo mi ON mi.imdbid = r.imdbid\n\t\t\t\tWHERE %s %s\n\t\t\t\tAND r.nzbstatus = %d\n\t\t\t\tAND r.categoryid BETWEEN 2000 AND 2999\n\t\t\t\tAND r.passwordstatus %s\n\t\t\t\tORDER BY postdate DESC %s", $this->releases->getConcatenatedCategoryIDs(), $this->releases->uSQL($this->pdo->query(sprintf('SELECT imdbid, categoryid FROM user_movies WHERE user_id = %d', $userID), true), 'imdbid'), count($excludedCats) ? ' AND r.categoryid NOT IN (' . implode(',', $excludedCats) . ')' : '', NZB::NZB_ADDED, $this->releases->showPasswords, ' LIMIT ' . ($limit > 100 ? 100 : $limit) . ' OFFSET 0'), true, nZEDb_CACHE_EXPIRY_MEDIUM);
 }
Exemplo n.º 25
0
<?php

use nzedb\Category;
use nzedb\Contents;
use nzedb\Releases;
if (!$page->users->isLoggedIn()) {
    $page->show403();
}
$releases = new Releases(['Settings' => $page->settings]);
$contents = new Contents(['Settings' => $page->settings]);
$category = new Category(['Settings' => $page->settings]);
$error = false;
// Array with all the possible poster wall types.
$startTypes = ['Books', 'Console', 'Movies', 'XXX', 'Audio', 'PC', 'TV'];
// Array that will contain the poster wall types (the above array minus whatever they have disabled in admin).
$types = [];
// Get the names of all enabled parent categories.
$categories = $category->getEnabledParentNames();
// Loop through our possible ones and check if they are in the enabled categories.
if (count($categories) > 0) {
    foreach ($categories as $pType) {
        if (in_array($pType['title'], $startTypes)) {
            $types[] = $pType['title'];
        }
    }
} else {
    $error = "No categories are enabled!";
}
if (count($types) === 0) {
    $error = 'No categories enabled for the new poster wall. Possible choices are: ' . implode(', ', $startTypes) . '.';
}
Exemplo n.º 26
0
            $catExclusions = $page->users->getCategoryExclusion($uid);
            $maxRequests = $res['apirequests'];
        }
    }
}
$page->smarty->assign('uid', $uid);
$page->smarty->assign('rsstoken', $apiKey);
// Record user access to the api, if its been called by a user (i.e. capabilities request do not require a user to be logged in or key provided).
if ($uid != '') {
    $page->users->updateApiAccessed($uid);
    $apiRequests = $page->users->getApiRequests($uid);
    if ($apiRequests > $maxRequests) {
        showApiError(500, 'Request limit reached (' . $apiRequests . '/' . $maxRequests . ')');
    }
}
$releases = new Releases(['Settings' => $page->settings]);
$page->smarty->assign('extended', isset($_GET['extended']) && $_GET['extended'] == 1 ? '1' : '0');
$page->smarty->assign('del', isset($_GET['del']) && $_GET['del'] == 1 ? '1' : '0');
// Output is either json or xml.
$outputXML = isset($_GET['o']) && $_GET['o'] == 'json' ? false : true;
switch ($function) {
    // Search releases.
    case 's':
        verifyEmptyParameter('q');
        $maxAge = maxAge();
        $page->users->addApiRequest($uid, $_SERVER['REQUEST_URI']);
        $categoryID = categoryID();
        $limit = limit();
        $offset = offset();
        if (isset($_GET['q'])) {
            $relData = $releases->search($_GET['q'], -1, -1, -1, -1, -1, -1, 0, 0, -1, -1, $offset, $limit, '', $maxAge, $catExclusions, "basic", $categoryID);
Exemplo n.º 27
0
 /**
  * @param array $options Class instances / Echo to CLI.
  */
 public function __construct(array $options = [])
 {
     $defaults = ['Echo' => false, 'Logger' => null, 'ReleaseImage' => null, 'Settings' => null, 'TMDb' => 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->imdbLanguage = $this->pdo->getSetting('imdblanguage') != '' ? (string) $this->pdo->getSetting('imdblanguage') : 'en';
     $this->tmdb = $options['TMDb'] instanceof \TMDb ? $options['TMDb'] : new \TMDb($this->pdo->getSetting('tmdbkey'), $this->imdbLanguage);
     $this->fanartapikey = $this->pdo->getSetting('fanarttvkey');
     $this->imdburl = $this->pdo->getSetting('imdburl') == 0 ? false : true;
     $this->movieqty = $this->pdo->getSetting('maximdbprocessed') != '' ? $this->pdo->getSetting('maximdbprocessed') : 100;
     $this->searchEngines = true;
     $this->showPasswords = Releases::showPasswords($this->pdo);
     $this->debug = nZEDb_DEBUG;
     $this->echooutput = $options['Echo'] && nZEDb_ECHOCLI && $this->pdo->cli;
     $this->imgSavePath = nZEDb_COVERS . 'movies' . DS;
     $this->service = '';
     $this->catWhere = 'AND categoryid BETWEEN 2000 AND 2999 ';
     if (nZEDb_DEBUG || nZEDb_LOGGING) {
         $this->debug = true;
         try {
             $this->debugging = new Logger();
         } catch (LoggerException $error) {
             $this->_debug = false;
         }
     }
 }
Exemplo n.º 28
0
         $page->smarty->assign('cat_ids', array_keys($categories));
         $page->smarty->assign('cat_names', $categories);
         $page->smarty->assign('cat_selected', explode('|', $show['categoryid']));
         $page->smarty->assign('video', $videoId);
         $page->smarty->assign('show', $show);
         $page->content = $page->smarty->fetch('myshows-add.tpl');
         $page->render();
     }
     break;
 case 'browse':
     $page->title = "Browse My Shows";
     $page->meta_title = "My Shows";
     $page->meta_keywords = "search,add,to,cart,nzb,description,details";
     $page->meta_description = "Browse Your Shows";
     $shows = $us->getShows($page->users->currentUserId());
     $releases = new Releases(['Settings' => $page->settings]);
     $browsecount = $releases->getShowsCount($shows, -1, $page->userdata["categoryexclusions"]);
     $offset = isset($_REQUEST["offset"]) && ctype_digit($_REQUEST['offset']) ? $_REQUEST["offset"] : 0;
     $ordering = $releases->getBrowseOrdering();
     $orderby = isset($_REQUEST["ob"]) && in_array($_REQUEST['ob'], $ordering) ? $_REQUEST["ob"] : '';
     $results = array();
     $results = $releases->getShowsRange($shows, $offset, ITEMS_PER_PAGE, $orderby, -1, $page->userdata["categoryexclusions"]);
     $page->smarty->assign('pagertotalitems', $browsecount);
     $page->smarty->assign('pageroffset', $offset);
     $page->smarty->assign('pageritemsperpage', ITEMS_PER_PAGE);
     $page->smarty->assign('pagerquerybase', WWW_TOP . "/myshows/browse?ob=" . $orderby . "&amp;offset=");
     $page->smarty->assign('pagerquerysuffix', "#results");
     $page->smarty->assign('covgroup', '');
     $pager = $page->smarty->fetch("pager.tpl");
     $page->smarty->assign('pager', $pager);
     foreach ($ordering as $ordertype) {
Exemplo n.º 29
0
<?php

require_once dirname(__FILE__) . '/../../../www/config.php';
use nzedb\ConsoleTools;
use nzedb\NZB;
use nzedb\ReleaseImage;
use nzedb\Releases;
use nzedb\db\Settings;
$pdo = new Settings();
if ($argc < 3 || !isset($argv[1]) || isset($argv[1]) && !is_numeric($argv[1])) {
    exit($pdo->log->error("\nIncorrect argument suppplied. This script will delete all duplicate releases matching on name, fromname, group_id and size.\n" . "Unfortunately, I can not guarantee which copy will be deleted.\n\n" . "php remove_exact_dupes.php 10 exact             ...: To delete all duplicates added within the last 10 hours.\n" . "php remove_exact_dupes.php 10 near              ...: To delete all duplicates with size variation of 1% and added within the last 10 hours.\n" . "php remove_exact_dupes.php 0 exact              ...: To delete all duplicates.\n" . "php remove_exact_dupes.php 0 near               ...: To delete all duplicates with size variation of 1%.\n" . "php remove_exact_dupes.php 10 exact dupes/      ...: To delete all duplicates added within the last 10 hours and save a copy of the nzb to dupes folder.\n"));
}
$crosspostt = $argv[1];
$releases = new Releases(['Settings' => $pdo]);
$count = $total = $all = 0;
$nzb = new NZB($pdo);
$ri = new ReleaseImage($pdo);
$consoleTools = new ConsoleTools(['ColorCLI' => $pdo->log]);
$size = ' size ';
if ($argv[2] === 'near') {
    $size = ' size between (size *.99) AND (size * 1.01) ';
}
if ($crosspostt != 0) {
    $query = sprintf('SELECT max(id) AS id, id AS idx, guid FROM releases WHERE adddate > (NOW() - INTERVAL %d HOUR) GROUP BY name, fromname, group_id,' . $size . 'HAVING COUNT(*) > 1', $crosspostt);
} else {
    $query = sprintf('SELECT max(id) AS id, id AS idx, guid FROM releases GROUP BY name, fromname, group_id,' . $size . 'HAVING COUNT(*) > 1');
}
do {
    $resrel = $pdo->queryDirect($query);
    if ($resrel instanceof \Traversable) {
        $total = $resrel->rowCount();
Exemplo n.º 30
0
<?php

require_once './config.php';
use nzedb\NZBExport;
use nzedb\Releases;
use nzedb\utility\Misc;
if (Misc::isCLI()) {
    exit('This script is only for exporting from the web, use the script in misc/testing' . PHP_EOL);
}
$page = new AdminPage();
$rel = new Releases(['Settings' => $page->settings]);
$folder = $group = $fromDate = $toDate = $gzip = $output = '';
if ($page->isPostBack()) {
    $folder = $_POST["folder"];
    $fromDate = isset($_POST["postfrom"]) ? $_POST["postfrom"] : '';
    $toDate = isset($_POST["postto"]) ? $_POST["postto"] : '';
    $group = $_POST["group"];
    $gzip = $_POST["gzip"];
    if ($folder != '') {
        $output = (new NZBExport(['Browser' => true, 'Settings' => $page->settings, 'Releases' => $rel]))->beginExport([$folder, $fromDate, $toDate, $_POST["group"] === '-1' ? 0 : (int) $_POST["group"], $_POST["gzip"] === '1' ? true : false]);
    } else {
        $output = 'Error, a path is required!';
    }
} else {
    $fromDate = $rel->getEarliestUsenetPostDate();
    $toDate = $rel->getLatestUsenetPostDate();
}
$page->title = "Export Nzbs";
$page->smarty->assign(['output' => $output, 'folder' => $folder, 'fromdate' => $fromDate, 'todate' => $toDate, 'group' => $group, 'gzip' => $gzip, 'gziplist' => [1 => 'True', 0 => 'False'], 'grouplist' => $rel->getReleasedGroupsForSelect(true)]);
$page->content = $page->smarty->fetch('nzb-export.tpl');
$page->render();