예제 #1
0
파일: Page.php 프로젝트: kaibosh/nZEDb
 public function __construct()
 {
     parent::__construct();
     $role = Users::ROLE_GUEST;
     if ($this->userdata != null) {
         $role = $this->userdata["role"];
     }
     $content = new Contents(['Settings' => $this->settings]);
     $menu = new Menu($this->settings);
     $this->smarty->assign('menulist', $menu->get($role, $this->serverurl));
     $this->smarty->assign('usefulcontentlist', $content->getForMenuByTypeAndRole(Contents::TYPEUSEFUL, $role));
     $this->smarty->assign('articlecontentlist', $content->getForMenuByTypeAndRole(Contents::TYPEARTICLE, $role));
     $this->smarty->assign('main_menu', $this->smarty->fetch('mainmenu.tpl'));
     $this->smarty->assign('useful_menu', $this->smarty->fetch('usefullinksmenu.tpl'));
     $this->smarty->assign('article_menu', $this->smarty->fetch('articlesmenu.tpl'));
     $category = new Category(['Settings' => $content->pdo]);
     if ($this->userdata != null) {
         $parentcatlist = $category->getForMenu($this->userdata["categoryexclusions"]);
     } else {
         $parentcatlist = $category->getForMenu();
     }
     // Add in system types to console categories to make the boot strap drop down list less long.
     $consoleCatList = [];
     foreach ($parentcatlist as $parent) {
         if ($parent['title'] === 'Console') {
             foreach ($parent['subcatlist'] as $consoleCat) {
                 if (preg_match('/^XBOX/i', $consoleCat['title'])) {
                     $consoleCatList['Microsoft'][] = $consoleCat;
                 } else {
                     if (preg_match('/^([3N]DS|N?GC)$|^WII/i', $consoleCat['title'])) {
                         $consoleCatList['Nintendo'][] = $consoleCat;
                     } else {
                         if (preg_match('/PS[\\dXP ]/i', $consoleCat['title'])) {
                             $consoleCatList['Sony'][] = $consoleCat;
                         } else {
                             $consoleCatList['Other'][] = $consoleCat;
                         }
                     }
                 }
             }
             break;
         }
     }
     $this->smarty->assign('consolecatlist', $consoleCatList);
     $this->smarty->assign('parentcatlist', $parentcatlist);
     $searchStr = '';
     if ($this->page == 'search' && isset($_REQUEST["id"])) {
         $searchStr = (string) $_REQUEST["id"];
     }
     $this->smarty->assign('header_menu_search', $searchStr);
     if (isset($_REQUEST["t"])) {
         $this->smarty->assign('header_menu_cat', $_REQUEST["t"]);
     } else {
         $this->smarty->assign('header_menu_cat', '');
     }
     $header_menu = $this->smarty->fetch('headermenu.tpl');
     $this->smarty->assign('header_menu', $header_menu);
 }
예제 #2
0
function reCategorize($argv)
{
    global $pdo;
    $where = '';
    $othercats = Category::getCategoryOthersGroup();
    $update = true;
    if (isset($argv[1]) && is_numeric($argv[1])) {
        $where = ' AND group_id = ' . $argv[1];
    } else {
        if (isset($argv[1]) && preg_match('/\\([\\d, ]+\\)/', $argv[1])) {
            $where = ' AND group_id IN ' . $argv[1];
        } else {
            if (isset($argv[1]) && $argv[1] === 'misc') {
                $where = sprintf(' AND categoryid IN (%s)', $othercats);
            }
        }
    }
    if (isset($argv[2]) && $argv[2] === 'test') {
        $update = false;
    }
    if (isset($argv[1]) && (is_numeric($argv[1]) || preg_match('/\\([\\d, ]+\\)/', $argv[1]))) {
        echo $pdo->log->header("Categorizing all releases in {$argv[1]} using searchname. This can take a while, be patient.");
    } else {
        if (isset($argv[1]) && $argv[1] == "misc") {
            echo $pdo->log->header("Categorizing all releases in misc categories using searchname. This can take a while, be patient.");
        } else {
            echo $pdo->log->header("Categorizing all releases using searchname. This can take a while, be patient.");
        }
    }
    $timestart = TIME();
    if (isset($argv[1]) && (is_numeric($argv[1]) || preg_match('/\\([\\d, ]+\\)/', $argv[1])) || $argv[1] === 'misc') {
        $chgcount = categorizeRelease(str_replace(" AND", "WHERE", $where), $update, true);
    } else {
        $chgcount = categorizeRelease('', $update, true);
    }
    $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]);
    $time = $consoletools->convertTime(TIME() - $timestart);
    if ($update === true) {
        echo $pdo->log->header("Finished re-categorizing " . number_format($chgcount) . " releases in " . $time . " , using the searchname.\n");
    } else {
        echo $pdo->log->header("Finished re-categorizing in " . $time . " , using the searchname.\n" . "This would have changed " . number_format($chgcount) . " releases but no updates were done.\n");
    }
}
예제 #3
0
파일: Releases.php 프로젝트: sebst3r/nZEDb
 /**
  * Creates part of a query for searches requiring the categoryID's.
  *
  * @param array $categories
  *
  * @return string
  */
 public function categorySQL($categories)
 {
     $sql = '';
     if (count($categories) > 0 && $categories[0] != -1) {
         $Category = new Category(['Settings' => $this->pdo]);
         $sql = ' AND (';
         foreach ($categories as $category) {
             if ($category != -1) {
                 if ($Category->isParent($category)) {
                     $children = $Category->getChildren($category);
                     $childList = '-99';
                     foreach ($children as $child) {
                         $childList .= ', ' . $child['id'];
                     }
                     if ($childList != '-99') {
                         $sql .= ' r.categoryid IN (' . $childList . ') OR ';
                     }
                 } else {
                     $sql .= sprintf(' r.categoryid = %d OR ', $category);
                 }
             }
         }
         $sql .= '1=2 )';
     }
     return $sql;
 }
예제 #4
0
파일: music.php 프로젝트: EeGgSs/nZEDb
<?php

use nzedb\Category;
use nzedb\Genres;
use nzedb\Music;
if (!$page->users->isLoggedIn()) {
    $page->show403();
}
$music = new Music(['Settings' => $page->settings]);
$cat = new Category(['Settings' => $page->settings]);
$gen = new Genres(['Settings' => $page->settings]);
$musiccats = $cat->getChildren(Category::CAT_PARENT_MUSIC);
$mtmp = array();
foreach ($musiccats as $mcat) {
    $mtmp[$mcat['id']] = $mcat;
}
$category = Category::CAT_PARENT_MUSIC;
if (isset($_REQUEST['t']) && array_key_exists($_REQUEST['t'], $mtmp)) {
    $category = $_REQUEST['t'] + 0;
}
$catarray = array();
$catarray[] = $category;
$page->smarty->assign('catlist', $mtmp);
$page->smarty->assign('category', $category);
$browsecount = $music->getMusicCount($catarray, -1, $page->userdata['categoryexclusions']);
$offset = isset($_REQUEST['offset']) && ctype_digit($_REQUEST['offset']) ? $_REQUEST['offset'] : 0;
$ordering = $music->getMusicOrdering();
$orderby = isset($_REQUEST['ob']) && in_array($_REQUEST['ob'], $ordering) ? $_REQUEST['ob'] : '';
$results = $musics = array();
$results = $music->getMusicRange($catarray, $offset, ITEMS_PER_COVER_PAGE, $orderby, $page->userdata['categoryexclusions']);
$artist = isset($_REQUEST['artist']) && !empty($_REQUEST['artist']) ? stripslashes($_REQUEST['artist']) : '';
예제 #5
0
파일: PreDb.php 프로젝트: zetas/nZEDb
 /**
  * Matches the hashes within the predb table to release files and subjects (names) which are hashed.
  *
  * @param $time
  * @param $echo
  * @param $cats
  * @param $namestatus
  * @param $show
  *
  * @return int
  */
 public function parseTitles($time, $echo, $cats, $namestatus, $show)
 {
     $namefixer = new NameFixer(['Echo' => $this->echooutput, 'ConsoleTools' => $this->pdo->log, 'Settings' => $this->pdo]);
     $consoletools = new ConsoleTools(['ColorCLI' => $this->pdo->log]);
     $othercats = Category::getCategoryOthersGroup();
     $updated = $checked = 0;
     $tq = '';
     if ($time == 1) {
         $tq = 'AND r.adddate > (NOW() - INTERVAL 3 HOUR) ORDER BY rf.releaseid, rf.size DESC';
     }
     $ct = '';
     if ($cats == 1) {
         $ct = sprintf('AND r.categoryid IN (%s)', $othercats);
     }
     if ($this->echooutput) {
         $te = '';
         if ($time == 1) {
             $te = ' in the past 3 hours';
         }
         echo $this->pdo->log->header('Fixing search names' . $te . " using the predb hash.");
     }
     $regex = "AND (r.ishashed = 1 OR rf.ishashed = 1)";
     if ($cats === 3) {
         $query = sprintf('SELECT r.id AS releaseid, r.name, r.searchname, r.categoryid, r.group_id, ' . 'dehashstatus, rf.name AS filename FROM releases r ' . 'LEFT OUTER JOIN release_files rf ON r.id = rf.releaseid ' . 'WHERE nzbstatus = 1 AND dehashstatus BETWEEN -6 AND 0 AND preid = 0 %s', $regex);
     } else {
         $query = sprintf('SELECT r.id AS releaseid, r.name, r.searchname, r.categoryid, r.group_id, ' . 'dehashstatus, rf.name AS filename FROM releases r ' . 'LEFT OUTER JOIN release_files rf ON r.id = rf.releaseid ' . 'WHERE nzbstatus = 1 AND isrenamed = 0 AND dehashstatus BETWEEN -6 AND 0 %s %s %s', $regex, $ct, $tq);
     }
     $res = $this->pdo->queryDirect($query);
     $total = $res->rowCount();
     echo $this->pdo->log->primary(number_format($total) . " releases to process.");
     if ($res instanceof \Traversable) {
         foreach ($res as $row) {
             if (preg_match('/[a-fA-F0-9]{32,40}/i', $row['name'], $matches)) {
                 $updated = $updated + $namefixer->matchPredbHash($matches[0], $row, $echo, $namestatus, $this->echooutput, $show);
             } else {
                 if (preg_match('/[a-fA-F0-9]{32,40}/i', $row['filename'], $matches)) {
                     $updated = $updated + $namefixer->matchPredbHash($matches[0], $row, $echo, $namestatus, $this->echooutput, $show);
                 }
             }
             if ($show === 2) {
                 $consoletools->overWritePrimary("Renamed Releases: [" . number_format($updated) . "] " . $consoletools->percentString(++$checked, $total));
             }
         }
     }
     if ($echo == 1) {
         echo $this->pdo->log->header("\n" . $updated . " releases have had their names changed out of: " . number_format($checked) . " files.");
     } else {
         echo $this->pdo->log->header("\n" . $updated . " releases could have their names changed. " . number_format($checked) . " files were checked.");
     }
     return $updated;
 }
예제 #6
0
파일: api.php 프로젝트: advhamstrong/nZEDb
     if (!isset($_GET['id'])) {
         showApiError(200, 'Missing parameter (id is required for downloading an NZB)');
     }
     $page->users->addApiRequest($uid, $_SERVER['REQUEST_URI']);
     $data = $releases->getByGuid($_GET['id']);
     $relData = [];
     if ($data) {
         $relData[] = $data;
     }
     printOutput($relData, $outputXML, $page, offset());
     break;
     // Capabilities request.
 // Capabilities request.
 case 'c':
     //get categories
     $category = new Category(['Settings' => $page->settings]);
     $cats = $category->getForMenu();
     //insert cats into template variable
     $page->smarty->assign('parentcatlist', $cats);
     if ($outputXML) {
         //use apicaps.tpl if xml is requested
         $response = $page->smarty->fetch('apicaps.tpl');
         header('Content-type: text/xml');
         header('Content-Length: ' . strlen($response));
         echo $response;
     } else {
         //otherwise construct array of capabilities and categories
         //get capabilities
         $caps = (new Capabilities(['Settings' => $page->settings]))->getForMenu();
         $caps['categories'] = $cats;
         //use json_encode
예제 #7
0
파일: movies.php 프로젝트: kaibosh/nZEDb
<?php

use nzedb\Category;
use nzedb\Movie;
use nzedb\DnzbFailures;
if (!$page->users->isLoggedIn()) {
    $page->show403();
}
$movie = new Movie(['Settings' => $page->settings]);
$cat = new Category(['Settings' => $page->settings]);
$fail = new DnzbFailures(['Settings' => $page->settings]);
$moviecats = $cat->getChildren(Category::CAT_PARENT_MOVIE);
$mtmp = [];
foreach ($moviecats as $mcat) {
    $mtmp[$mcat['id']] = $mcat;
}
$category = Category::CAT_PARENT_MOVIE;
if (isset($_REQUEST['t']) && array_key_exists($_REQUEST['t'], $mtmp)) {
    $category = $_REQUEST['t'] + 0;
}
$user = $page->users->getById($page->users->currentUserId());
$cpapi = $user['cp_api'];
$cpurl = $user['cp_url'];
$page->smarty->assign('cpapi', $cpapi);
$page->smarty->assign('cpurl', $cpurl);
$catarray = [];
$catarray[] = $category;
$page->smarty->assign('catlist', $mtmp);
$page->smarty->assign('category', $category);
$browsecount = $movie->getMovieCount($catarray, -1, $page->userdata['categoryexclusions']);
$offset = isset($_REQUEST['offset']) && ctype_digit($_REQUEST['offset']) ? $_REQUEST["offset"] : 0;
예제 #8
0
파일: NameFixer.php 프로젝트: zetas/nZEDb
    /**
     * Update the release with the new information.
     *
     * @param array   $release
     * @param string  $name
     * @param string  $method
     * @param boolean $echo
     * @param string  $type
     * @param int     $nameStatus
     * @param int     $show
     * @param int     $preId
     */
    public function updateRelease($release, $name, $method, $echo, $type, $nameStatus, $show, $preId = 0)
    {
        if ($this->relid !== $release['releaseid']) {
            $releaseCleaning = new ReleaseCleaning($this->pdo);
            $newName = $releaseCleaning->fixerCleaner($name);
            if (strtolower($newName) != strtolower($release["searchname"])) {
                $this->matched = true;
                $this->relid = $release["releaseid"];
                $determinedCategory = $this->category->determineCategory($release['group_id'], $newName);
                if ($type === "PAR2, ") {
                    $newName = ucwords($newName);
                    if (preg_match('/(.+?)\\.[a-z0-9]{2,3}(PAR2)?$/i', $name, $match)) {
                        $newName = $match[1];
                    }
                }
                $this->fixed++;
                $newName = explode("\\", $newName);
                $newName = preg_replace(['/^[-=_\\.:\\s]+/', '/[-=_\\.:\\s]+$/'], '', $newName[0]);
                if ($this->echooutput === true && $show === 1) {
                    $groupName = $this->_groups->getByNameByID($release['group_id']);
                    $oldCatName = $this->category->getNameByID($release['categoryid']);
                    $newCatName = $this->category->getNameByID($determinedCategory);
                    if ($type === "PAR2, ") {
                        echo PHP_EOL;
                    }
                    echo $this->pdo->log->headerOver("\nNew name:  ") . $this->pdo->log->primary(substr($newName, 0, 255)) . $this->pdo->log->headerOver("Old name:  ") . $this->pdo->log->primary($release["searchname"]) . $this->pdo->log->headerOver("Use name:  ") . $this->pdo->log->primary($release["name"]) . $this->pdo->log->headerOver("New cat:   ") . $this->pdo->log->primary($newCatName) . $this->pdo->log->headerOver("Old cat:   ") . $this->pdo->log->primary($oldCatName) . $this->pdo->log->headerOver("Group:     ") . $this->pdo->log->primary($groupName) . $this->pdo->log->headerOver("Method:    ") . $this->pdo->log->primary($type . $method) . $this->pdo->log->headerOver("ReleaseID: ") . $this->pdo->log->primary($release["releaseid"]);
                    if (isset($release['filename']) && $release['filename'] != "") {
                        echo $this->pdo->log->headerOver("Filename:  ") . $this->pdo->log->primary($release["filename"]);
                    }
                    if ($type !== "PAR2, ") {
                        echo "\n";
                    }
                }
                $newTitle = $this->pdo->escapeString(substr($newName, 0, 255));
                if ($echo == true) {
                    if ($nameStatus == 1) {
                        $status = '';
                        switch ($type) {
                            case "NFO, ":
                                $status = "isrenamed = 1, iscategorized = 1, proc_nfo = 1,";
                                break;
                            case "PAR2, ":
                                $status = "isrenamed = 1, iscategorized = 1, proc_par2 = 1,";
                                break;
                            case "Filenames, ":
                            case "file matched source: ":
                                $status = "isrenamed = 1, iscategorized = 1, proc_files = 1,";
                                break;
                            case "SHA1, ":
                            case "MD5, ":
                                $status = "isrenamed = 1, iscategorized = 1, dehashstatus = 1,";
                                break;
                            case "PreDB FT Exact, ":
                                $status = "isrenamed = 1, iscategorized = 1,";
                                break;
                            case "sorter ":
                                $status = "isrenamed = 1, iscategorized = 1, proc_sorter = 1,";
                                break;
                        }
                        $this->pdo->queryExec(sprintf('
								UPDATE releases
								SET videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfoid = NULL,
									consoleinfoid = NULL, bookinfoid = NULL, anidbid = NULL, preid = %d,
									searchname = %s, %s categoryid = %d
								WHERE id = %d', $preId, $newTitle, $status, $determinedCategory, $release['releaseid']));
                        $this->sphinx->updateRelease($release['releaseid'], $this->pdo);
                    } else {
                        $newTitle = $this->pdo->escapeString(substr($newName, 0, 255));
                        $this->pdo->queryExec(sprintf('
								UPDATE releases
								SET videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfoid = NULL,
									consoleinfoid = NULL, bookinfoid = NULL, anidbid = NULL, preid = %d,
									searchname = %s, iscategorized = 1, categoryid = %d
								WHERE id = %d', $preId, $newTitle, $determinedCategory, $release['releaseid']));
                        $this->sphinx->updateRelease($release['releaseid'], $this->pdo);
                    }
                }
            }
        }
        $this->done = true;
    }
예제 #9
0
파일: series.php 프로젝트: EeGgSs/nZEDb
<?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) {
예제 #10
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)));
            }
        }
    }
예제 #11
0
파일: myshows.php 프로젝트: kaibosh/nZEDb
     $page->smarty->assign('pager', $pager);
     foreach ($ordering as $ordertype) {
         $page->smarty->assign('orderby' . $ordertype, WWW_TOP . "/myshows/browse?ob=" . $ordertype . "&amp;offset=0");
     }
     $page->smarty->assign('lastvisit', $page->userdata['lastlogin']);
     $page->smarty->assign('results', $results);
     $page->smarty->assign('shows', true);
     $page->content = $page->smarty->fetch('browse.tpl');
     $page->render();
     break;
 default:
     $page->title = "My Shows";
     $page->meta_title = "My Shows";
     $page->meta_keywords = "search,add,to,cart,nzb,description,details";
     $page->meta_description = "Manage Your Shows";
     $cat = new Category(['Settings' => $page->settings]);
     $tmpcats = $cat->getChildren(Category::CAT_PARENT_TV);
     $categories = array();
     foreach ($tmpcats as $c) {
         $categories[$c['id']] = $c['title'];
     }
     $shows = $us->getShows($page->users->currentUserId());
     $results = array();
     foreach ($shows as $showk => $show) {
         $showcats = explode('|', $show['categoryid']);
         if (is_array($showcats) && sizeof($showcats) > 0) {
             $catarr = array();
             foreach ($showcats as $scat) {
                 if (!empty($scat)) {
                     $catarr[] = $categories[$scat];
                 }
예제 #12
0
파일: games.php 프로젝트: zetas/nZEDb
<?php

use nzedb\Category;
use nzedb\Games;
use nzedb\Genres;
use nzedb\DnzbFailures;
if (!$page->users->isLoggedIn()) {
    $page->show403();
}
$games = new Games(['Settings' => $page->settings]);
$cat = new Category(['Settings' => $page->settings]);
$gen = new Genres(['Settings' => $page->settings]);
$fail = new DnzbFailures(['Settings' => $page->settings]);
$concats = $cat->getChildren(Category::CAT_PARENT_PC);
$ctmp = array();
foreach ($concats as $ccat) {
    $ctmp[$ccat['id']] = $ccat;
}
$category = Category::CAT_PC_GAMES;
if (isset($_REQUEST["t"]) && array_key_exists($_REQUEST['t'], $ctmp)) {
    $category = $_REQUEST["t"] + 0;
}
$catarray = array();
$catarray[] = $category;
$page->smarty->assign('catlist', $ctmp);
$page->smarty->assign('category', $category);
$offset = isset($_REQUEST["offset"]) && ctype_digit($_REQUEST['offset']) ? $_REQUEST["offset"] : 0;
$ordering = $games->getGamesOrdering();
$orderby = isset($_REQUEST["ob"]) && in_array($_REQUEST['ob'], $ordering) ? $_REQUEST["ob"] : '';
$results = $games2 = array();
$results = $games->getGamesRange($catarray, $offset, ITEMS_PER_COVER_PAGE, $orderby, -1, $page->userdata["categoryexclusions"]);
<?php

/* Deletes releases in categories you have disabled here : http://localhost/admin/category-list.php */
require dirname(__FILE__) . '/../../../www/config.php';
use nzedb\Category;
use nzedb\NZB;
use nzedb\ReleaseImage;
use nzedb\Releases;
use nzedb\db\Settings;
$pdo = new Settings();
if (isset($argv[1]) && $argv[1] == "true") {
    $timestart = TIME();
    $releases = new Releases(['Settings' => $pdo]);
    $category = new Category(['Settings' => $pdo]);
    $nzb = new NZB($pdo);
    $releaseImage = new ReleaseImage($pdo);
    $catlist = $category->getDisabledIDs();
    $relsdeleted = 0;
    if (count($catlist > 0)) {
        foreach ($catlist as $cat) {
            $rels = $pdo->query(sprintf("SELECT id, guid FROM releases WHERE categoryid = %d", $cat['id']));
            if (count($rels)) {
                foreach ($rels as $rel) {
                    $relsdeleted++;
                    $releases->deleteSingle(['g' => $rel['guid'], 'i' => $rel['id']], $nzb, $releaseImage);
                }
            }
        }
    }
    $time = TIME() - $timestart;
    if ($relsdeleted > 0) {
예제 #14
0
파일: api.php 프로젝트: sebst3r/nZEDb
 case 'd':
     if (!isset($_GET['id'])) {
         showApiError(200, 'Missing parameter (id is required for downloading an NZB)');
     }
     $page->users->addApiRequest($uid, $_SERVER['REQUEST_URI']);
     $data = $releases->getByGuid($_GET['id']);
     $relData = [];
     if ($data) {
         $relData[] = $data;
     }
     printOutput($relData, $outputXML, $page, offset());
     break;
     // Capabilities request.
 // Capabilities request.
 case 'c':
     $category = new Category(['Settings' => $page->settings]);
     $page->smarty->assign('parentcatlist', $category->getForMenu());
     header('Content-type: text/xml');
     echo $page->smarty->fetch('apicaps.tpl');
     break;
     // Register request.
 // Register request.
 case 'r':
     verifyEmptyParameter('email');
     if (!in_array((int) $page->settings->getSetting('registerstatus'), [Settings::REGISTER_STATUS_OPEN, Settings::REGISTER_STATUS_API_ONLY])) {
         showApiError(104);
     }
     // Check email is valid format.
     if (!$page->users->isValidEmail($_GET['email'])) {
         showApiError(106);
     }
예제 #15
0
<?php

require_once './config.php';
use nzedb\Category;
$page = new AdminPage();
$category = new Category(['Settings' => $page->settings]);
$id = 0;
// Set the current action.
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'view';
switch ($action) {
    case 'submit':
        $ret = $category->update($_POST["id"], $_POST["status"], $_POST["description"], $_POST["disablepreview"], $_POST["minsize"]);
        header("Location:" . WWW_TOP . "/category-list.php");
        break;
    case 'view':
    default:
        if (isset($_GET["id"])) {
            $page->title = "Category Edit";
            $id = $_GET["id"];
            $cat = $category->getByID($id);
            $page->smarty->assign('category', $cat);
        }
        break;
}
$page->smarty->assign('status_ids', [Category::STATUS_ACTIVE, Category::STATUS_INACTIVE, Category::STATUS_DISABLED]);
$page->smarty->assign('status_names', ['Yes', 'No', 'Disabled']);
$page->content = $page->smarty->fetch('category-edit.tpl');
$page->render();
예제 #16
0
파일: rss.php 프로젝트: Atmos01/nZEDb
<?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"];
예제 #17
0
파일: NameFixer.php 프로젝트: zetas/nZEDb
 /**
  * @param array $options Class instances / Echo to cli.
  */
 public function __construct(array $options = [])
 {
     $defaults = ['Echo' => true, 'Categorize' => null, 'ConsoleTools' => null, 'Groups' => null, 'Misc' => null, 'Settings' => null, 'SphinxSearch' => null];
     $options += $defaults;
     $this->echooutput = $options['Echo'] && nZEDb_ECHOCLI;
     $this->relid = $this->fixed = $this->checked = 0;
     $this->pdo = $options['Settings'] instanceof Settings ? $options['Settings'] : new Settings();
     $this->othercats = Category::getCategoryOthersGroup();
     $this->timeother = sprintf(' AND rel.adddate > (NOW() - INTERVAL 6 HOUR) AND rel.categoryid IN (%s) GROUP BY rel.id ORDER BY postdate DESC', $this->othercats);
     $this->timeall = ' AND rel.adddate > (NOW() - INTERVAL 6 HOUR) GROUP BY rel.id ORDER BY postdate DESC';
     $this->fullother = sprintf(' AND rel.categoryid IN (%s) GROUP BY rel.id', $this->othercats);
     $this->fullall = '';
     $this->_fileName = '';
     $this->done = $this->matched = false;
     $this->consoletools = $options['ConsoleTools'] instanceof ConsoleTools ? $options['ConsoleTools'] : new ConsoleTools(['ColorCLI' => $this->pdo->log]);
     $this->category = $options['Categorize'] instanceof Categorize ? $options['Categorize'] : new Categorize(['Settings' => $this->pdo]);
     $this->text = $options['Misc'] instanceof Text ? $options['Misc'] : new Text();
     $this->_groups = $options['Groups'] instanceof Groups ? $options['Groups'] : new Groups(['Settings' => $this->pdo]);
     $this->sphinx = $options['SphinxSearch'] instanceof SphinxSearch ? $options['SphinxSearch'] : new SphinxSearch();
 }
예제 #18
0
파일: Users.php 프로젝트: kaibosh/nZEDb
 /**
  * Get list of category names excluded by the user.
  *
  * @param int $userID ID of the user.
  *
  * @return array
  */
 public function getCategoryExclusionNames($userID)
 {
     $data = $this->getCategoryExclusion($userID);
     $category = new Category(['Settings' => $this->pdo]);
     $categories = $category->getByIds($data);
     $ret = [];
     if ($categories !== false) {
         foreach ($categories as $cat) {
             $ret[] = $cat["title"];
         }
     }
     return $ret;
 }
예제 #19
0
파일: books.php 프로젝트: kaibosh/nZEDb
<?php

use nzedb\Books;
use nzedb\Category;
use nzedb\DnzbFailures;
if (!$page->users->isLoggedIn()) {
    $page->show403();
}
$book = new Books(['Settings' => $page->settings]);
$cat = new Category(['Settings' => $page->settings]);
$fail = new DnzbFailures(['Settings' => $page->settings]);
$boocats = $cat->getChildren(Category::CAT_PARENT_BOOKS);
$btmp = array();
foreach ($boocats as $bcat) {
    $btmp[$bcat['id']] = $bcat;
}
$category = Category::CAT_PARENT_BOOKS;
if (isset($_REQUEST["t"]) && array_key_exists($_REQUEST['t'], $btmp)) {
    $category = $_REQUEST["t"] + 0;
}
$catarray = array();
$catarray[] = $category;
$page->smarty->assign('catlist', $btmp);
$page->smarty->assign('category', $category);
$browsecount = $book->getBookCount($catarray, -1, $page->userdata["categoryexclusions"]);
$offset = isset($_REQUEST["offset"]) && ctype_digit($_REQUEST['offset']) ? $_REQUEST["offset"] : 0;
$ordering = $book->getBookOrdering();
$orderby = isset($_REQUEST["ob"]) && in_array($_REQUEST['ob'], $ordering) ? $_REQUEST["ob"] : '';
$results = $books = array();
$results = $book->getBookRange($catarray, $offset, ITEMS_PER_COVER_PAGE, $orderby, $page->userdata["categoryexclusions"]);
$maxwords = 50;
예제 #20
0
<?php

use nzedb\Category;
use nzedb\NZBGet;
use nzedb\SABnzbd;
use nzedb\Users;
if (!$page->users->isLoggedIn()) {
    $page->show403();
}
$category = new Category(['Settings' => $page->settings]);
$sab = new SABnzbd($page);
$nzbGet = new NZBGet($page);
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'view';
$userid = $page->users->currentUserId();
$data = $page->users->getById($userid);
if (!$data) {
    $page->show404();
}
$errorStr = '';
switch ($action) {
    case 'newapikey':
        $page->users->updateRssKey($userid);
        header("Location: profileedit");
        break;
    case 'clearcookies':
        $sab->unsetCookie();
        header("Location: profileedit");
        break;
    case 'submit':
        $data["email"] = $_POST['email'];
        $data["firstname"] = $_POST['firstname'];
예제 #21
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) . '.';
}
예제 #22
0
파일: rss.php 프로젝트: sebst3r/nZEDb
<?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.";
    $categorylist = $category->get(true, $page->userdata["categoryexclusions"]);
    $page->smarty->assign('categorylist', $categorylist);
    $parentcategorylist = $category->getForMenu($page->userdata["categoryexclusions"]);
    $page->smarty->assign('parentcategorylist', $parentcategorylist);
    $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.