Пример #1
0
    /**
     * @param             $title
     * @param             $year
     * @param object|null $amazdata
     *
     * @return bool
     */
    public function updateMusicInfo($title, $year, $amazdata = null)
    {
        $gen = new Genres(['Settings' => $this->pdo]);
        $ri = new ReleaseImage($this->pdo);
        $titlepercent = 0;
        $mus = [];
        if ($title != '') {
            $amaz = $this->fetchAmazonProperties($title);
        } else {
            if ($amazdata != null) {
                $amaz = $amazdata;
            } else {
                $amaz = false;
            }
        }
        if (!$amaz) {
            return false;
        }
        if (isset($amaz->Items->Item->ItemAttributes->Title)) {
            $mus['title'] = (string) $amaz->Items->Item->ItemAttributes->Title;
            if (empty($mus['title'])) {
                return false;
            }
        } else {
            return false;
        }
        // Load genres.
        $defaultGenres = $gen->getGenres(Genres::MUSIC_TYPE);
        $genreassoc = [];
        foreach ($defaultGenres as $dg) {
            $genreassoc[$dg['id']] = strtolower($dg['title']);
        }
        // Get album properties.
        $mus['coverurl'] = (string) $amaz->Items->Item->LargeImage->URL;
        if ($mus['coverurl'] != "") {
            $mus['cover'] = 1;
        } else {
            $mus['cover'] = 0;
        }
        $mus['asin'] = (string) $amaz->Items->Item->ASIN;
        $mus['url'] = (string) $amaz->Items->Item->DetailPageURL;
        $mus['url'] = str_replace("%26tag%3Dws", "%26tag%3Dopensourceins%2D21", $mus['url']);
        $mus['salesrank'] = (string) $amaz->Items->Item->SalesRank;
        if ($mus['salesrank'] == "") {
            $mus['salesrank'] = 'null';
        }
        $mus['artist'] = (string) $amaz->Items->Item->ItemAttributes->Artist;
        if (empty($mus['artist'])) {
            $mus['artist'] = (string) $amaz->Items->Item->ItemAttributes->Creator;
            if (empty($mus['artist'])) {
                $mus['artist'] = "";
            }
        }
        $mus['publisher'] = (string) $amaz->Items->Item->ItemAttributes->Publisher;
        $mus['releasedate'] = $this->pdo->escapeString((string) $amaz->Items->Item->ItemAttributes->ReleaseDate);
        if ($mus['releasedate'] == "''") {
            $mus['releasedate'] = 'null';
        }
        $mus['review'] = "";
        if (isset($amaz->Items->Item->EditorialReviews)) {
            $mus['review'] = trim(strip_tags((string) $amaz->Items->Item->EditorialReviews->EditorialReview->Content));
        }
        $mus['year'] = $year;
        if ($mus['year'] == "") {
            $mus['year'] = $mus['releasedate'] != 'null' ? substr($mus['releasedate'], 1, 4) : date("Y");
        }
        $mus['tracks'] = "";
        if (isset($amaz->Items->Item->Tracks)) {
            $tmpTracks = (array) $amaz->Items->Item->Tracks->Disc;
            $tracks = $tmpTracks['Track'];
            $mus['tracks'] = is_array($tracks) && !empty($tracks) ? implode('|', $tracks) : '';
        }
        similar_text($mus['artist'] . " " . $mus['title'], $title, $titlepercent);
        if ($titlepercent < 60) {
            return false;
        }
        $genreKey = -1;
        $genreName = '';
        if (isset($amaz->Items->Item->BrowseNodes)) {
            // Had issues getting this out of the browsenodes obj.
            // Workaround is to get the xml and load that into its own obj.
            $amazGenresXml = $amaz->Items->Item->BrowseNodes->asXml();
            $amazGenresObj = simplexml_load_string($amazGenresXml);
            $amazGenres = $amazGenresObj->xpath("//BrowseNodeId");
            foreach ($amazGenres as $amazGenre) {
                $currNode = trim($amazGenre[0]);
                if (empty($genreName)) {
                    $genreMatch = $this->matchBrowseNode($currNode);
                    if ($genreMatch !== false) {
                        $genreName = $genreMatch;
                        break;
                    }
                }
            }
            if (in_array(strtolower($genreName), $genreassoc)) {
                $genreKey = array_search(strtolower($genreName), $genreassoc);
            } else {
                $genreKey = $this->pdo->queryInsert(sprintf("\n\t\t\t\t\t\t\t\t\t\tINSERT INTO genres (title, type)\n\t\t\t\t\t\t\t\t\t\tVALUES (%s, %d)", $this->pdo->escapeString($genreName), Genres::MUSIC_TYPE));
            }
        }
        $mus['musicgenre'] = $genreName;
        $mus['musicgenreid'] = $genreKey;
        $check = $this->pdo->queryOneRow(sprintf('
				SELECT id
				FROM musicinfo
				WHERE asin = %s', $this->pdo->escapeString($mus['asin'])));
        if ($check === false) {
            $musicId = $this->pdo->queryInsert(sprintf("\n\t\t\t\t\tINSERT INTO musicinfo\n\t\t\t\t\t\t(title, asin, url, salesrank, artist, publisher,\n\t\t\t\t\t\treleasedate, review, year, genre_id, tracks, cover, createddate, updateddate)\n\t\t\t\t\tVALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, now(), now())", $this->pdo->escapeString($mus['title']), $this->pdo->escapeString($mus['asin']), $this->pdo->escapeString($mus['url']), $mus['salesrank'], $this->pdo->escapeString($mus['artist']), $this->pdo->escapeString($mus['publisher']), $mus['releasedate'], $this->pdo->escapeString($mus['review']), $this->pdo->escapeString($mus['year']), $mus['musicgenreid'] == -1 ? "null" : $mus['musicgenreid'], $this->pdo->escapeString($mus['tracks']), $mus['cover']));
        } else {
            $musicId = $check['id'];
            $this->pdo->queryExec(sprintf('
					UPDATE musicinfo
					SET title = %s, asin = %s, url = %s, salesrank = %s, artist = %s,
						publisher = %s, releasedate = %s, review = %s, year = %s, genre_id = %s, tracks = %s, cover = %s,
						updateddate = NOW()
					WHERE id = %d', $this->pdo->escapeString($mus['title']), $this->pdo->escapeString($mus['asin']), $this->pdo->escapeString($mus['url']), $mus['salesrank'], $this->pdo->escapeString($mus['artist']), $this->pdo->escapeString($mus['publisher']), $mus['releasedate'], $this->pdo->escapeString($mus['review']), $this->pdo->escapeString($mus['year']), $mus['musicgenreid'] == -1 ? "null" : $mus['musicgenreid'], $this->pdo->escapeString($mus['tracks']), $mus['cover'], $musicId));
        }
        if ($musicId) {
            if ($this->echooutput) {
                $this->pdo->log->doEcho($this->pdo->log->header("\nAdded/updated album: ") . $this->pdo->log->alternateOver("   Artist: ") . $this->pdo->log->primary($mus['artist']) . $this->pdo->log->alternateOver("   Title:  ") . $this->pdo->log->primary($mus['title']) . $this->pdo->log->alternateOver("   Year:   ") . $this->pdo->log->primary($mus['year']));
            }
            $mus['cover'] = $ri->saveImage($musicId, $mus['coverurl'], $this->imgSavePath, 250, 250);
        } else {
            if ($this->echooutput) {
                if ($mus["artist"] == "") {
                    $artist = "";
                } else {
                    $artist = "Artist: " . $mus['artist'] . ", Album: ";
                }
                $this->pdo->log->doEcho($this->pdo->log->headerOver("Nothing to update: ") . $this->pdo->log->primary($artist . $mus['title'] . " (" . $mus['year'] . ")"));
            }
        }
        return $musicId;
    }
Пример #2
0
    /**
     * Process each game, updating game information from Giantbomb
     *
     * @param $gameInfo
     *
     * @return bool
     */
    public function updateGamesInfo($gameInfo)
    {
        $gen = new Genres(['Settings' => $this->pdo]);
        $ri = new ReleaseImage($this->pdo);
        $con = [];
        // Process Steam first before giantbomb
        // Steam has more details
        $this->_gameResults = [];
        $this->_getGame = new Steam();
        $this->_classUsed = "steam";
        $this->_getGame->cookie = $this->cookie;
        $this->_getGame->searchTerm = $gameInfo['title'];
        if ($this->_getGame->search() !== false) {
            $this->_gameResults = $this->_getGame->getAll();
        }
        if (count($this->_gameResults) < 1) {
            $this->_getGame = new Desura();
            $this->_classUsed = "desura";
            $this->_getGame->cookie = $this->cookie;
            $this->_getGame->searchTerm = $gameInfo['title'];
            if ($this->_getGame->search() !== false) {
                $this->_gameResults = $this->_getGame->getAll();
            }
        }
        if (count($this->_gameResults) < 1) {
            $this->_getGame = new Greenlight();
            $this->_classUsed = "gl";
            $this->_getGame->cookie = $this->cookie;
            $this->_getGame->searchTerm = $gameInfo['title'];
            if ($this->_getGame->search() !== false) {
                $this->_gameResults = $this->_getGame->getAll();
            }
        }
        if (count($this->_gameResults) < 1) {
            $this->_gameResults = (array) $this->fetchGiantBombID($gameInfo['title']);
            if ($this->maxHitRequest === true) {
                return false;
            }
        }
        if (empty($this->_gameResults['title'])) {
            return false;
        }
        if (!is_array($this->_gameResults)) {
            return false;
        }
        if (count($this->_gameResults) > 1) {
            $genreName = '';
            switch ($this->_classUsed) {
                case "desura":
                    if (isset($this->_gameResults['cover'])) {
                        $con['coverurl'] = (string) $this->_gameResults['cover'];
                    }
                    if (isset($this->_gameResults['backdrop'])) {
                        $con['backdropurl'] = (string) $this->_gameResults['backdrop'];
                    }
                    $con['title'] = (string) $this->_gameResults['title'];
                    $con['asin'] = $this->_gameResults['desuragameid'];
                    $con['url'] = (string) $this->_gameResults['directurl'];
                    if (isset($this->_gameResults['gamedetails']['Publisher'])) {
                        $con['publisher'] = (string) $this->_gameResults['gamedetails']['Publisher'];
                    } else {
                        $con['publisher'] = "Unknown";
                    }
                    if (isset($this->_gameResults['rating'])) {
                        $con['esrb'] = (string) $this->_gameResults['rating'];
                    } else {
                        $con['esrb'] = "Not Rated";
                    }
                    if (isset($this->_gameResults['description'])) {
                        $con['review'] = trim(strip_tags((string) $this->_gameResults['description']));
                    }
                    if (isset($this->_gameResults['trailer'])) {
                        $con['trailer'] = (string) $this->_gameResults['trailer'];
                    }
                    if (isset($this->_gameResults['gamedetails']['Genre'])) {
                        $genres = (string) $this->_gameResults['gamedetails']['Genre'];
                        $genreName = $this->_matchGenre($genres);
                    }
                    break;
                case "gb":
                    $con['coverurl'] = (string) $this->_gameResults['image']['super_url'];
                    $con['title'] = (string) $this->_gameResults['name'];
                    $con['asin'] = $this->_gameID;
                    $con['url'] = (string) $this->_gameResults['site_detail_url'];
                    if (is_array($this->_gameResults['publishers'])) {
                        while (list($key) = each($this->_gameResults['publishers'])) {
                            if ($key == 0) {
                                $con['publisher'] = (string) $this->_gameResults['publishers'][$key]['name'];
                            }
                        }
                    } else {
                        $con['publisher'] = "Unknown";
                    }
                    if (is_array($this->_gameResults['original_game_rating'])) {
                        $con['esrb'] = (string) $this->_gameResults['original_game_rating'][0]['name'];
                    } else {
                        $con['esrb'] = (string) $this->_gameResults['original_game_rating']['name'];
                    }
                    $con['releasedate'] = (string) $this->_gameResults['original_release_date'];
                    if (isset($this->_gameResults['description'])) {
                        $con['review'] = trim(strip_tags((string) $this->_gameResults['description']));
                    }
                    if (isset($this->_gameResults['genres'][0]['name'])) {
                        $genres = (string) $this->_gameResults['genres'][0]['name'];
                        $genreName = $this->_matchGenre($genres);
                    }
                    break;
                case "gl":
                    if (isset($this->_gameResults['cover'])) {
                        $con['coverurl'] = (string) $this->_gameResults['cover'];
                    }
                    if (isset($this->_gameResults['backdrop'])) {
                        $con['backdropurl'] = (string) $this->_gameResults['backdrop'];
                    }
                    $con['title'] = (string) $this->_gameResults['title'];
                    $con['asin'] = $this->_gameResults['greenlightgameid'];
                    $con['url'] = (string) $this->_gameResults['directurl'];
                    $con['publisher'] = "Unknown";
                    $con['esrb'] = "Not Rated";
                    if (isset($this->_gameResults['description'])) {
                        $con['review'] = trim(strip_tags((string) $this->_gameResults['description']));
                    }
                    if (isset($this->_gameResults['trailer'])) {
                        $con['trailer'] = (string) $this->_gameResults['trailer'];
                    }
                    if (isset($this->_gameResults['gamedetails']['Genre'])) {
                        $genres = (string) $this->_gameResults['gamedetails']['Genre'];
                        $genreName = $this->_matchGenre($genres);
                    }
                    break;
                case "steam":
                    if (isset($this->_gameResults['cover'])) {
                        $con['coverurl'] = (string) $this->_gameResults['cover'];
                    }
                    if (isset($this->_gameResults['backdrop'])) {
                        $con['backdropurl'] = (string) $this->_gameResults['backdrop'];
                    }
                    $con['title'] = (string) $this->_gameResults['title'];
                    $con['asin'] = $this->_gameResults['steamgameid'];
                    $con['url'] = (string) $this->_gameResults['directurl'];
                    if (isset($this->_gameResults['gamedetails']['Publisher'])) {
                        $con['publisher'] = (string) $this->_gameResults['gamedetails']['Publisher'];
                    } else {
                        $con['publisher'] = "Unknown";
                    }
                    if (isset($this->_gameResults['rating'])) {
                        $con['esrb'] = (string) $this->_gameResults['rating'];
                    } else {
                        $con['esrb'] = "Not Rated";
                    }
                    if (!empty($this->_gameResults['gamedetails']['Release Date'])) {
                        $dateReleased = $this->_gameResults['gamedetails']['Release Date'];
                        if (!preg_match('#^\\s*(?P<month>\\w+)\\s+(?P<day>\\d{1,2}),?\\s+(?P<year>\\d{4})\\s*$#', $dateReleased)) {
                            if (preg_match('#^\\s*(?P<month>\\w+)\\s+(?P<year>\\d{4})\\s*$#', $dateReleased, $matches)) {
                                $dateReleased = "{$matches['month']} 1, {$matches['year']}";
                            }
                        }
                        $date = \DateTime::createFromFormat('M/j/Y', $dateReleased);
                        if ($date instanceof \DateTime) {
                            $con['releasedate'] = (string) $date->format('Y-m-d');
                        }
                    }
                    if (isset($this->_gameResults['description'])) {
                        $con['review'] = trim(strip_tags((string) $this->_gameResults['description']));
                    }
                    if (isset($this->_gameResults['trailer'])) {
                        $con['trailer'] = (string) $this->_gameResults['trailer'];
                    }
                    if (isset($this->_gameResults['gamedetails']['Genre'])) {
                        $genres = (string) $this->_gameResults['gamedetails']['Genre'];
                        $genreName = $this->_matchGenre($genres);
                    }
                    break;
                default:
                    return false;
            }
        } else {
            return false;
        }
        // Load genres.
        $defaultGenres = $gen->getGenres(Genres::GAME_TYPE);
        $genreassoc = [];
        foreach ($defaultGenres as $dg) {
            $genreassoc[$dg['id']] = strtolower($dg['title']);
        }
        // Prepare database values.
        if (isset($con['coverurl'])) {
            $con['cover'] = 1;
        } else {
            $con['cover'] = 0;
        }
        if (isset($con['backdropurl'])) {
            $con['backdrop'] = 1;
        } else {
            $con['backdrop'] = 0;
        }
        if (!isset($con['trailer'])) {
            $con['trailer'] = 0;
        }
        if (empty($con['title'])) {
            $con['title'] = $gameInfo['title'];
        }
        if (!isset($con['releasedate'])) {
            $con['releasedate'] = "";
        }
        if ($con['releasedate'] == "''") {
            $con['releasedate'] = "";
        }
        if (!isset($con['review'])) {
            $con['review'] = 'No Review';
        }
        $con['classused'] = $this->_classUsed;
        if (empty($genreName)) {
            $genreName = 'Unknown';
        }
        if (in_array(strtolower($genreName), $genreassoc)) {
            $genreKey = array_search(strtolower($genreName), $genreassoc);
        } else {
            $genreKey = $this->pdo->queryInsert(sprintf("\n\t\t\t\t\tINSERT INTO genres (title, type)\n\t\t\t\t\tVALUES (%s, %d)", $this->pdo->escapeString($genreName), Genres::GAME_TYPE));
        }
        $con['gamesgenre'] = $genreName;
        $con['gamesgenreID'] = $genreKey;
        $check = $this->pdo->queryOneRow(sprintf('
				SELECT id
				FROM gamesinfo
				WHERE asin = %s', $this->pdo->escapeString($con['asin'])));
        if ($check === false) {
            $gamesId = $this->pdo->queryInsert(sprintf("\n\t\t\t\t\tINSERT INTO gamesinfo\n\t\t\t\t\t\t(title, asin, url, publisher, genre_id, esrb, releasedate, review, cover, backdrop, trailer, classused, createddate, updateddate)\n\t\t\t\t\tVALUES (%s, %s, %s, %s, %s, %s, %s, %s, %d, %d, %s, %s, NOW(), NOW())", $this->pdo->escapeString($con['title']), $this->pdo->escapeString($con['asin']), $this->pdo->escapeString($con['url']), $this->pdo->escapeString($con['publisher']), $con['gamesgenreID'] == -1 ? "null" : $con['gamesgenreID'], $this->pdo->escapeString($con['esrb']), $con['releasedate'] != "" ? $this->pdo->escapeString($con['releasedate']) : "null", $this->pdo->escapeString(substr($con['review'], 0, 3000)), $con['cover'], $con['backdrop'], $this->pdo->escapeString($con['trailer']), $this->pdo->escapeString($con['classused'])));
        } else {
            $gamesId = $check['id'];
            $this->pdo->queryExec(sprintf('
					UPDATE gamesinfo
					SET
						title = %s, asin = %s, url = %s, publisher = %s, genre_id = %s,
						esrb = %s, releasedate = %s, review = %s, cover = %d, backdrop = %d, trailer = %s, classused = %s, updateddate = NOW()
					WHERE id = %d', $this->pdo->escapeString($con['title']), $this->pdo->escapeString($con['asin']), $this->pdo->escapeString($con['url']), $this->pdo->escapeString($con['publisher']), $con['gamesgenreID'] == -1 ? "null" : $con['gamesgenreID'], $this->pdo->escapeString($con['esrb']), $con['releasedate'] != "" ? $this->pdo->escapeString($con['releasedate']) : "null", $this->pdo->escapeString(substr($con['review'], 0, 3000)), $con['cover'], $con['backdrop'], $this->pdo->escapeString($con['trailer']), $this->pdo->escapeString($con['classused']), $gamesId));
        }
        if ($gamesId) {
            if ($this->echoOutput) {
                $this->pdo->log->doEcho($this->pdo->log->header("Added/updated game from " . $this->_classUsed . ": ") . $this->pdo->log->alternateOver("   Title:    ") . $this->pdo->log->primary($con['title']));
            }
            if ($con['cover'] === 1) {
                $con['cover'] = $ri->saveImage($gamesId, $con['coverurl'], $this->imgSavePath, 250, 250);
            }
            if ($con['backdrop'] === 1) {
                $con['backdrop'] = $ri->saveImage($gamesId . '-backdrop', $con['backdropurl'], $this->imgSavePath, 1920, 1024);
            }
        } else {
            if ($this->echoOutput) {
                $this->pdo->log->doEcho($this->pdo->log->headerOver("Nothing to update: ") . $this->pdo->log->primary($con['title'] . ' (PC)'));
            }
        }
        return $gamesId;
    }
Пример #3
0
<?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']) : '';
Пример #4
0
<?php

require_once './config.php';
use nzedb\Genres;
$page = new AdminPage();
$genres = new Genres(['Settings' => $page->settings]);
$page->title = "Music Genres";
$activeOnly = isset($_REQUEST['activeonly']);
$count = $genres->getCount(Genres::MUSIC_TYPE, $activeOnly);
$offset = isset($_REQUEST["offset"]) ? $_REQUEST["offset"] : 0;
$page->smarty->assign('pagertotalitems', $count);
$page->smarty->assign('pageroffset', $offset);
$page->smarty->assign('pageritemsperpage', ITEMS_PER_PAGE);
if ($activeOnly) {
    $activeOnlySearch = "activeonly=1&amp;";
} else {
    $activeOnlySearch = "";
}
$page->smarty->assign('pagerquerybase', WWW_TOP . "/musicgenre-list.php?" . $activeOnlySearch . "offset=");
$pager = $page->smarty->fetch('pager.tpl');
$page->smarty->assign('pager', $pager);
$genrelist = $genres->getRange($offset, ITEMS_PER_PAGE, Genres::MUSIC_TYPE, $activeOnly);
$page->smarty->assign('genrelist', $genrelist);
$page->content = $page->smarty->fetch('musicgenre-list.tpl');
$page->render();
Пример #5
0
<?php

require_once './config.php';
if (!isset($_GET['id'])) {
    header('Location: ' . WWW_TOP . '/musicgenre-list.php');
    exit;
}
use nzedb\Genres;
$page = new AdminPage();
$genres = new Genres(['Settings' => $page->settings]);
$genre = ['id' => '', 'title' => '', 'disabled' => ''];
switch (isset($_REQUEST['action']) ? $_REQUEST['action'] : 'view') {
    case 'submit':
        $ret = $genres->update($_POST["id"], $_POST["disabled"]);
        header("Location:" . WWW_TOP . "/musicgenre-list.php");
        break;
    case 'view':
    default:
        if (isset($_GET["id"])) {
            $page->title = "Music Genre Edit";
            $genre = $genres->getByID($_GET["id"]);
        }
        break;
}
$page->smarty->assign('genre', $genre);
$page->smarty->assign('status_ids', [Genres::STATUS_ENABLED, Genres::STATUS_DISABLED]);
$page->smarty->assign('status_names', ['No', 'Yes']);
$page->content = $page->smarty->fetch('musicgenre-edit.tpl');
$page->render();
Пример #6
0
 /**
  * @return array
  */
 protected function _loadGenres()
 {
     $gen = new Genres(['Settings' => $this->pdo]);
     $defaultGenres = $gen->getGenres(Genres::CONSOLE_TYPE);
     $genreassoc = [];
     foreach ($defaultGenres as $dg) {
         $genreassoc[$dg['id']] = strtolower($dg['title']);
     }
     return $genreassoc;
 }
Пример #7
0
<?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"]);
Пример #8
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)));
            }
        }
    }
Пример #9
0
<?php

use nzedb\Category;
use nzedb\Console;
use nzedb\Genres;
use nzedb\DnzbFailures;
if (!$page->users->isLoggedIn()) {
    $page->show403();
}
$console = new Console(['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_GAME);
$ctmp = array();
foreach ($concats as $ccat) {
    $ctmp[$ccat['id']] = $ccat;
}
$category = Category::CAT_PARENT_GAME;
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);
$browsecount = $console->getConsoleCount($catarray, -1, $page->userdata["categoryexclusions"]);
$offset = isset($_REQUEST["offset"]) && ctype_digit($_REQUEST['offset']) ? $_REQUEST["offset"] : 0;
$ordering = $console->getConsoleOrdering();
$orderby = isset($_REQUEST["ob"]) && in_array($_REQUEST['ob'], $ordering) ? $_REQUEST["ob"] : '';
$results = $consoles = array();
Пример #10
0
<?php

require_once './config.php';
use nzedb\Genres;
use nzedb\Music;
$page = new AdminPage();
$music = new Music(['Settings' => $page->settings]);
$gen = new Genres(['Settings' => $page->settings]);
$id = 0;
// Set the current action.
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'view';
if (isset($_REQUEST["id"])) {
    $id = $_REQUEST["id"];
    $mus = $music->getMusicInfo($id);
    if (!$mus) {
        $page->show404();
    }
    switch ($action) {
        case 'submit':
            $coverLoc = nZEDb_COVERS . "music/" . $id . '.jpg';
            if ($_FILES['cover']['size'] > 0) {
                $tmpName = $_FILES['cover']['tmp_name'];
                $file_info = getimagesize($tmpName);
                if (!empty($file_info)) {
                    move_uploaded_file($_FILES['cover']['tmp_name'], $coverLoc);
                }
            }
            $_POST['cover'] = file_exists($coverLoc) ? 1 : 0;
            $_POST['salesrank'] = empty($_POST['salesrank']) || !ctype_digit($_POST['salesrank']) ? "null" : $_POST['salesrank'];
            $_POST['releasedate'] = empty($_POST['releasedate']) || !strtotime($_POST['releasedate']) ? $mus['releasedate'] : date("Y-m-d H:i:s", strtotime($_POST['releasedate']));
            $music->update($id, $_POST["title"], $_POST['asin'], $_POST['url'], $_POST["salesrank"], $_POST["artist"], $_POST["publisher"], $_POST["releasedate"], $_POST["year"], $_POST["tracks"], $_POST["cover"], $_POST["genre"]);
Пример #11
0
<?php

require_once './config.php';
use nzedb\Genres;
$page = new AdminPage();
$genres = new Genres(['Settings' => $page->settings]);
$page->title = "Music Genres";
$activeOnly = isset($_REQUEST['activeonly']);
$offset = isset($_REQUEST["offset"]) ? $_REQUEST["offset"] : 0;
$page->smarty->assign(['genrelist' => $genres->getRange($offset, ITEMS_PER_PAGE, Genres::MUSIC_TYPE, $activeOnly), 'pagertotalitems' => $genres->getCount(Genres::MUSIC_TYPE, $activeOnly), 'pageroffset' => $offset, 'pageritemsperpage' => ITEMS_PER_PAGE, 'pagerquerysuffix' => '', 'pagerquerybase' => WWW_TOP . "/musicgenre-list.php?" . ($activeOnly ? "activeonly=1&amp;" : '') . "offset="]);
$page->smarty->assign('pager', $page->smarty->fetch('pager.tpl'));
$page->content = $page->smarty->fetch('musicgenre-list.tpl');
$page->render();
Пример #12
0
<?php

require_once './config.php';
use nzedb\Console;
use nzedb\Genres;
$page = new AdminPage();
$console = new Console(['Settings' => $page->settings]);
$gen = new Genres(['Settings' => $page->settings]);
$id = 0;
// Set the current action.
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'view';
if (isset($_REQUEST["id"])) {
    $id = $_REQUEST["id"];
    $con = $console->getConsoleInfo($id);
    if (!$con) {
        $page->show404();
    }
    switch ($action) {
        case 'submit':
            $coverLoc = nZEDb_COVERS . "console/" . $id . '.jpg';
            if ($_FILES['cover']['size'] > 0) {
                $tmpName = $_FILES['cover']['tmp_name'];
                $file_info = getimagesize($tmpName);
                if (!empty($file_info)) {
                    move_uploaded_file($_FILES['cover']['tmp_name'], $coverLoc);
                }
            }
            $_POST['cover'] = file_exists($coverLoc) ? 1 : 0;
            $_POST['salesrank'] = empty($_POST['salesrank']) || !ctype_digit($_POST['salesrank']) ? "null" : $_POST['salesrank'];
            $_POST['releasedate'] = empty($_POST['releasedate']) || !strtotime($_POST['releasedate']) ? $con['releasedate'] : date("Y-m-d H:i:s", strtotime($_POST['releasedate']));
            $console->update($id, $_POST["title"], $_POST['asin'], $_POST['url'], $_POST["salesrank"], $_POST["platform"], $_POST["publisher"], $_POST["releasedate"], $_POST["esrb"], $_POST["cover"], $_POST["genre"]);
Пример #13
0
<?php

require_once './config.php';
use nzedb\Category;
use nzedb\Genres;
use nzedb\XXX;
$page = new AdminPage();
$xxxmovie = new XXX(['Settings' => $page->settings]);
$gen = new Genres(['Settings' => $page->settings]);
$id = 0;
// Set the current action.
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'view';
if (isset($_REQUEST["id"])) {
    $id = $_REQUEST["id"];
    $xxx = $xxxmovie->getXXXInfo($id);
    if (!$xxx) {
        $page->show404();
    }
    switch ($action) {
        case 'submit':
            $coverLoc = nZEDb_COVERS . "xxx/" . $id . '-cover.jpg';
            $backdropLoc = nZEDb_COVERS . "xxx/" . $id . '-backdrop.jpg';
            if ($_FILES['cover']['size'] > 0) {
                $tmpName = $_FILES['cover']['tmp_name'];
                $file_info = getimagesize($tmpName);
                if (!empty($file_info)) {
                    move_uploaded_file($_FILES['cover']['tmp_name'], $coverLoc);
                }
            }
            if ($_FILES['backdrop']['size'] > 0) {
                $tmpName = $_FILES['backdrop']['tmp_name'];