public function create() { if (empty($_POST)) { $this->loadModel("Genres"); $genres = Genres::find(); $this->toView(compact('genres')); $this->render("create"); } else { $this->loadModel('Animes'); $this->loadModel('AnimesGenres'); $anime = new Animes(); $anime->id = null; $anime->title = $_POST['nom']; $anime->rate = intval($_POST['note']); $anime->description = $_POST['desc']; $anime->img = basename($_FILES['img']['name']); if (!move_uploaded_file($_FILES["img"]["tmp_name"], ROOT . 'views/assets/img/' . basename($_FILES['img']['name']))) { die('erreur lors de l\'upload du fichier'); } $anime_id = $anime->create(); foreach ($_POST['genres'] as $genre_id) { $animeGenre = new AnimesGenres(); $animeGenre->id = null; $animeGenre->animes_id = $anime_id; $animeGenre->genres_id = $genre_id; $animeGenre->create(); } header('Location: ' . URI . 'index/'); } }
function updateMusicInfo($artist, $album, $year) { $db = new DB(); $gen = new Genres(); $music = new Music(); $mus = array(); $amaz = $music->fetchAmazonProperties($artist . " - " . $album); if (!$amaz) { return false; } //load genres $defaultGenres = $gen->getGenres(Genres::MUSIC_TYPE); $genreassoc = array(); foreach ($defaultGenres as $dg) { $genreassoc[$dg['ID']] = strtolower($dg['title']); } // // get album properties // $mus['coverurl'] = (string) $amaz->Items->Item->MediumImage->URL; if ($mus['coverurl'] != "") { $mus['cover'] = 1; } else { $mus['cover'] = 0; } $mus['title'] = (string) $amaz->Items->Item->ItemAttributes->Title; if (empty($mus['title'])) { $mus['title'] = $album; } $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'] = $artist; } $mus['publisher'] = (string) $amaz->Items->Item->ItemAttributes->Publisher; $mus['releasedate'] = $db->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['releasedate'] != 'null') { $mus['year'] = substr($mus['releasedate'], 1, 4); } $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) : ''; } $genreKey = -1; $genreName = ''; $amazGenres = (array) $amaz->Items->Item->BrowseNodes; foreach ($amazGenres as $amazGenre) { foreach ($amazGenre as $ag) { $tmpGenre = strtolower((string) $ag->Name); if (!empty($tmpGenre)) { if (in_array($tmpGenre, $genreassoc)) { $genreKey = array_search($tmpGenre, $genreassoc); $genreName = $tmpGenre; break; } else { //we got a genre but its not stored in our genre table $genreName = (string) $ag->Name; $genreKey = 'new genre to be added'; //$genreKey = $db->queryInsert(sprintf("INSERT INTO genres (`title`, `type`) VALUES (%s, %d)", $db->escapeString($genreName), Genres::MUSIC_TYPE)); break; } } } } $mus['musicgenre'] = $genreName; $mus['musicgenreID'] = $genreKey; $mus['amaz'] = $amaz->Items->Item; return $mus; }
/** * 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 id, guid FROM releases WHERE postdate < (NOW() - INTERVAL %d DAY)', $this->pdo->getSetting('releaseretentiondays'))); if ($releases instanceof \Traversable) { foreach ($releases as $release) { $this->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 id, guid FROM releases WHERE passwordstatus = %d', \Releases::PASSWD_RAR)); if ($releases instanceof \Traversable) { foreach ($releases as $release) { $this->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 id, guid FROM releases WHERE passwordstatus = %d', \Releases::PASSWD_POTENTIAL)); if ($releases instanceof \Traversable) { foreach ($releases as $release) { $this->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 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->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 id, guid FROM releases WHERE completion < %d AND completion > 0', $this->completion)); if ($releases instanceof \Traversable) { foreach ($releases as $release) { $this->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 id, guid FROM releases WHERE categoryid = %d', $disabledCategory['id'])); if ($releases instanceof \Traversable) { foreach ($releases as $release) { $disabledCategoryDeleted++; $this->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage); } } } } // Delete smaller than category minimum sizes. $categories = $this->pdo->queryDirect(' SELECT c.id AS id, CASE WHEN c.minsizetoformrelease = 0 THEN cp.minsizetoformrelease ELSE c.minsizetoformrelease 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 r.id, r.guid FROM releases r WHERE r.categoryid = %d AND r.size < %d', $category['id'], $category['minsize'])); if ($releases instanceof \Traversable) { foreach ($releases as $release) { $this->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 id, guid FROM releases INNER JOIN (SELECT id AS mid FROM musicinfo WHERE musicinfo.genreID = %d) mi ON musicinfoid = mid', $genre['id'])); if ($releases instanceof \Traversable) { foreach ($releases as $release) { $disabledGenreDeleted++; $this->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 id, guid FROM releases WHERE categoryid = %d AND adddate <= NOW() - INTERVAL %d HOUR', \Category::CAT_MISC_OTHER, $this->pdo->getSetting('miscotherretentionhours'))); if ($releases instanceof \Traversable) { foreach ($releases as $release) { $this->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 id, guid FROM releases WHERE categoryid = %d AND adddate <= NOW() - INTERVAL %d HOUR', \Category::CAT_MISC_HASHED, $this->pdo->getSetting('mischashedretentionhours'))); if ($releases instanceof \Traversable) { foreach ($releases as $release) { $this->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))); } } }
<?php require_once "config.php"; require_once WWW_DIR . "/lib/adminpage.php"; require_once WWW_DIR . "/lib/music.php"; require_once WWW_DIR . "/lib/genres.php"; $page = new AdminPage(); $music = new Music(); $gen = new Genres(); $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 = WWW_DIR . "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']));
<p> <?php echo $errorsMovie[0]['trailerUrl']; ?> </p> <?php } ?> </p> <p> <label for = "genre">Genre</label> <?php require '../classes/genres.php'; $genres = new Genres(); $allGenresArray = $genres->getAllGenres(); ?> <?php foreach ($allGenresArray as $genreArray) { ?> <?php $checked = in_array($genreArray->id, $checkedGenres) ? 'checked="checked"' : ''; ?> <input type="checkbox" <?php echo $checked; ?> name="genre[<?php echo $genreArray->id; ?>
<?php if (!$page->users->isLoggedIn()) { $page->show403(); } $games = new Games(['Settings' => $page->settings]); $cat = new Category(['Settings' => $page->settings]); $gen = new Genres(['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); $browsecount = $games->getGamesCount($catarray, -1, $page->userdata["categoryexclusions"]); $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"]); $maxwords = 50; foreach ($results as $result) { if (!empty($result['review'])) { // remove "Overview" from start of review if present
/** * Show the form for editing a comicbook series * GET /content/{title}/edit * * @param string $title * @return Response */ public function edit($title) { //Instance of Comicbook model $comic = new Comicbooks(); //Set variables $data['book_title'] = $title; $book_id = $comic->series($title)->select('comicdb_books.id as id')->first(); $data['id'] = $book_id; //If book exists, get the issue information and fill the form with it if (!is_null($book_id)) { $data['book_info'] = $comic->series($title)->select('comicdb_books.id as id', 'book_name', 'publisher_name', 'book_description')->distinct()->get(); $data['selected_genres'] = $comic->series($title)->select('comicdb_genre.id', 'genre_name')->distinct()->get(); $data['book_characters'] = $comic->bookcharacters($title)->select('character_name')->distinct()->get(); $data['book_genres'] = Genres::lists('genre_name', 'id'); $this->layout->content = View::make('editseries', $data); } else { return Redirect::to('editseries')->with('postMsg', 'These are not the comics you are looking for.')->withErrors($validator)->withInput(); } }
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; }
<?php require_once "config.php"; $page = new AdminPage(); $console = new Console(); $gen = new Genres(); $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 = WWW_DIR . "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"]); header("Location:" . WWW_TOP . "/console-list.php"); die;
/** * Check whether a title is available at Amazon and store its metadata. */ public function updateConsoleInfo($gameInfo) { $gen = new Genres(); $ri = new ReleaseImage(); $con = []; $amaz = $this->fetchAmazonProperties($gameInfo['title'], $gameInfo['node']); if (!$amaz) { return false; } //load genres $defaultGenres = $gen->getGenres(Genres::CONSOLE_TYPE); $genreassoc = []; foreach ($defaultGenres as $dg) { $genreassoc[$dg['id']] = strtolower($dg['title']); } // // get game properties // $con['coverurl'] = (string) $amaz->Items->Item->LargeImage->URL; if ($con['coverurl'] != "") { $con['cover'] = 1; } else { $con['cover'] = 0; } $con['title'] = (string) $amaz->Items->Item->ItemAttributes->Title; if (empty($con['title'])) { $con['title'] = $gameInfo['title']; } $con['platform'] = (string) $amaz->Items->Item->ItemAttributes->Platform; if (empty($con['platform'])) { $con['platform'] = $gameInfo['platform']; } //Beginning of Recheck Code //This is to verify the result back from amazon was at least somewhat related to what was intended. //Some of the Platforms don't match Amazon's exactly. This code is needed to facilitate rechecking. if (preg_match('/^X360$/i', $gameInfo['platform'])) { $gameInfo['platform'] = str_replace('X360', 'Xbox 360', $gameInfo['platform']); // baseline single quote } if (preg_match('/^XBOX360$/i', $gameInfo['platform'])) { $gameInfo['platform'] = str_replace('XBOX360', 'Xbox 360', $gameInfo['platform']); // baseline single quote } if (preg_match('/^NDS$/i', $gameInfo['platform'])) { $gameInfo['platform'] = str_replace('NDS', 'Nintendo DS', $gameInfo['platform']); // baseline single quote } if (preg_match('/^PS3$/i', $gameInfo['platform'])) { $gameInfo['platform'] = str_replace('PS3', 'PlayStation 3', $gameInfo['platform']); // baseline single quote } if (preg_match('/^PSP$/i', $gameInfo['platform'])) { $gameInfo['platform'] = str_replace('PSP', 'Sony PSP', $gameInfo['platform']); // baseline single quote } if (preg_match('/^Wii$/i', $gameInfo['platform'])) { $gameInfo['platform'] = str_replace('Wii', 'Nintendo Wii', $gameInfo['platform']); // baseline single quote $gameInfo['platform'] = str_replace('WII', 'Nintendo Wii', $gameInfo['platform']); // baseline single quote } if (preg_match('/^N64$/i', $gameInfo['platform'])) { $gameInfo['platform'] = str_replace('N64', 'Nintendo 64', $gameInfo['platform']); // baseline single quote } if (preg_match('/^NES$/i', $gameInfo['platform'])) { $gameInfo['platform'] = str_replace('NES', 'Nintendo NES', $gameInfo['platform']); // baseline single quote } if (preg_match('/Super/i', $con['platform'])) { $con['platform'] = str_replace('Super Nintendo', 'SNES', $con['platform']); // baseline single quote $con['platform'] = str_replace('Nintendo Super NES', 'SNES', $con['platform']); // baseline single quote } //Remove Online Game Code So Titles Match Properly. if (preg_match('/\\[Online Game Code\\]/i', $con['title'])) { $con['title'] = str_replace(' [Online Game Code]', '', $con['title']); // baseline single quote } //Basically the XBLA names contain crap, this is to reduce the title down far enough to be usable if (preg_match('/xbla/i', $gameInfo['platform'])) { $gameInfo['title'] = substr($gameInfo['title'], 0, 10); $con['substr'] = $gameInfo['title']; } //This actual compares the two strings and outputs a percentage value. $titlepercent = ''; $platformpercent = ''; similar_text(strtolower($gameInfo['title']), strtolower($con['title']), $titlepercent); similar_text(strtolower($gameInfo['platform']), strtolower($con['platform']), $platformpercent); //Since Wii Ware games and XBLA have inconsistent original platforms, as long as title is 50% its ok. if (preg_match('/(wiiware|xbla)/i', $gameInfo['platform'])) { if ($titlepercent >= 50) { $platformpercent = 100; } } //If the release is DLC matching sucks, so assume anything over 50% is legit. if (isset($gameInfo['dlc']) && $gameInfo['dlc'] == 1) { if ($titlepercent >= 50) { $titlepercent = 100; $platformpercent = 100; } } //Show the Percentages //echo("Matched: Title Percentage: $titlepercent%"); //echo("Matched: Platform Percentage: $platformpercent%"); //If the Title is less than 80% Platform must be 100% unless it is XBLA if ($titlepercent < 70) { if ($platformpercent != 100) { return false; } } //If title is less than 80% then its most likely not a match if ($titlepercent < 70) { return false; } //Platform must equal 100% if ($platformpercent != 100) { return false; } $con['asin'] = (string) $amaz->Items->Item->ASIN; $con['url'] = (string) $amaz->Items->Item->DetailPageURL; $con['salesrank'] = (string) $amaz->Items->Item->SalesRank; if ($con['salesrank'] == "") { $con['salesrank'] = 'null'; } $con['publisher'] = (string) $amaz->Items->Item->ItemAttributes->Publisher; $con['esrb'] = (string) $amaz->Items->Item->ItemAttributes->ESRBAgeRating; $con['releasedate'] = $this->pdo->escapeString((string) $amaz->Items->Item->ItemAttributes->ReleaseDate); if ($con['releasedate'] == "''") { $con['releasedate'] = 'null'; } $con['review'] = ""; if (isset($amaz->Items->Item->EditorialReviews)) { $con['review'] = trim(strip_tags((string) $amaz->Items->Item->EditorialReviews->EditorialReview->Content)); } $genreKey = -1; $genreName = ''; if (isset($amaz->Items->Item->BrowseNodes) || isset($amaz->Items->Item->ItemAttributes->Genre)) { 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("//Name"); foreach ($amazGenres as $amazGenre) { $currName = trim($amazGenre[0]); if (empty($genreName)) { $genreMatch = $this->matchBrowseNode($currName); if ($genreMatch !== false) { $genreName = $genreMatch; break; } } } } if (empty($genreName) && isset($amaz->Items->Item->ItemAttributes->Genre)) { $tmpGenre = (string) $amaz->Items->Item->ItemAttributes->Genre; $tmpGenre = str_replace('-', ' ', $tmpGenre); $tmpGenre = explode(' ', $tmpGenre); foreach ($tmpGenre as $tg) { $genreMatch = $this->matchBrowseNode(ucwords($tg)); if ($genreMatch !== false) { $genreName = $genreMatch; break; } } } } if (empty($genreName)) { $genreName = 'Unknown'; } if (in_array(strtolower($genreName), $genreassoc)) { $genreKey = array_search(strtolower($genreName), $genreassoc); } else { $genreKey = $this->pdo->queryInsert(sprintf("INSERT INTO genres (`title`, `type`) VALUES (%s, %d)", $this->pdo->escapeString($genreName), Genres::CONSOLE_TYPE)); } $con['consolegenre'] = $genreName; $con['consolegenreID'] = $genreKey; $query = sprintf("\n\t\tINSERT INTO consoleinfo (`title`, `asin`, `url`, `salesrank`, `platform`, `publisher`, `genreid`, `esrb`, `releasedate`, `review`, `cover`, `createddate`, `updateddate`)\n\t\tVALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, now(), now())\n\t\t\tON DUPLICATE KEY UPDATE `title` = %s, `asin` = %s, `url` = %s, `salesrank` = %s, `platform` = %s, `publisher` = %s, `genreid` = %s, `esrb` = %s, `releasedate` = %s, `review` = %s, `cover` = %d, createddate = now(), updateddate = now()", $this->pdo->escapeString($con['title']), $this->pdo->escapeString($con['asin']), $this->pdo->escapeString($con['url']), $con['salesrank'], $this->pdo->escapeString($con['platform']), $this->pdo->escapeString($con['publisher']), $con['consolegenreID'] == -1 ? "null" : $con['consolegenreID'], $this->pdo->escapeString($con['esrb']), $con['releasedate'], $this->pdo->escapeString($con['review']), $con['cover'], $this->pdo->escapeString($con['title']), $this->pdo->escapeString($con['asin']), $this->pdo->escapeString($con['url']), $con['salesrank'], $this->pdo->escapeString($con['platform']), $this->pdo->escapeString($con['publisher']), $con['consolegenreID'] == -1 ? "null" : $con['consolegenreID'], $this->pdo->escapeString($con['esrb']), $con['releasedate'], $this->pdo->escapeString($con['review']), $con['cover']); $consoleId = $this->pdo->queryInsert($query); if ($consoleId) { $con['cover'] = $ri->saveImage($consoleId, $con['coverurl'], $this->imgSavePath, 250, 250); } return $consoleId; }
/** * @param $title * @param $year * @param 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("INSERT INTO musicinfo (title, asin, url, salesrank, artist, publisher, " . "releasedate, review, year, genreID, tracks, cover, createddate, updateddate) VALUES " . "(%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, genreID = %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->primaryOver($artist . $mus['title'] . " (" . $mus['year'] . ")")); } } return $musicId; }
<?php require_once WWW_DIR . "/lib/music.php"; require_once WWW_DIR . "/lib/category.php"; require_once WWW_DIR . "/lib/genres.php"; $music = new Music(); $cat = new Category(); $gen = new Genres(); if (!$users->isLoggedIn()) { $page->show403(); } $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_PAGE, $orderby, -1, $page->userdata["categoryexclusions"]); foreach ($results as $result) {
<?php require_once "config.php"; $page = new AdminPage(); $games = new Games(['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"]; $game = $games->getGamesInfo($id); if (!$game) { $page->show404(); } switch ($action) { case 'submit': $coverLoc = NN_COVERS . "games/" . $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['releasedate'] = empty($_POST['releasedate']) || !strtotime($_POST['releasedate']) ? $game['releasedate'] : date("Y-m-d H:i:s", strtotime($_POST['releasedate'])); $games->update($id, $_POST["title"], $_POST['asin'], $_POST['url'], $_POST["publisher"], $_POST["releasedate"], $_POST["esrb"], $_POST["cover"], $_POST['trailerurl'], $_POST["genre"]); header("Location:" . WWW_TOP . "/game-list.php"); die; break;
public function getGenres($genre) { $data['genre_name'] = $genre; //Get Genre list from database $genre_list = Genres::lists('genre_name'); //Check and see if Genre is in Genre list. If it doesn't, redirect to error page if (!in_array($genre, $genre_list)) { return Redirect::to('error'); } else { //Get Genre information $data['genre_cover'] = Comicbooks::genres($genre)->select('cover_image')->orderBy('comicdb_books.created_at', 'desc')->distinct()->get(); $data['genre_works'] = Comicbooks::genres($genre)->select('book_name')->orderBy('comicdb_books.created_at', 'desc')->distinct()->get(); } $this->layout->content = View::make('genre', $data); }
public function updateMusicInfo($artist, $album, $year) { $db = new DB(); $gen = new Genres(); $ri = new ReleaseImage(); $mus = array(); $amaz = $this->fetchAmazonProperties($artist . " - " . $album); if (!$amaz) { return false; } //load genres $defaultGenres = $gen->getGenres(Genres::MUSIC_TYPE); $genreassoc = array(); foreach ($defaultGenres as $dg) { $genreassoc[$dg['ID']] = strtolower($dg['title']); } // // get album properties // $mus['coverurl'] = (string) $amaz->Items->Item->MediumImage->URL; if ($mus['coverurl'] != "") { $mus['cover'] = 1; } else { $mus['cover'] = 0; } $mus['title'] = (string) $amaz->Items->Item->ItemAttributes->Title; if (empty($mus['title'])) { $mus['title'] = $album; } $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'] = $artist; } $mus['publisher'] = (string) $amaz->Items->Item->ItemAttributes->Publisher; $mus['releasedate'] = $db->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) : ''; } //This is to verify the result back from amazon was at least somewhat related to what was intended. //If you are debugging releases comment out the following code to show all info $match = similar_text($artist, $mus['artist'], $artistpercent); //echo("Matched: Artist Percentage: $artistpercent%"); $match = similar_text($album, $mus['title'], $albumpercent); //echo("Matched: Album Percentage: $albumpercent%"); //If the artist is Various Artists, assume artist is 100% if (preg_match('/various/i', $artist)) { $artistpercent = '100'; } //If the Artist is less than 80% album must be 100% if ($artistpercent < '80') { if ($albumpercent != '100') { return false; } } //If the album is ever under 30%, it's probably not a match. if ($albumpercent < '30') { return false; } //This is the end of the recheck code. Comment out to this point to show all info. $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 = $db->queryInsert(sprintf("INSERT INTO genres (`title`, `type`) VALUES (%s, %d)", $db->escapeString($genreName), Genres::MUSIC_TYPE)); } } $mus['musicgenre'] = $genreName; $mus['musicgenreID'] = $genreKey; $query = sprintf("\n\t\tINSERT INTO musicinfo (`title`, `asin`, `url`, `salesrank`, `artist`, `publisher`, `releasedate`, `review`, `year`, `genreID`, `tracks`, `cover`, `createddate`, `updateddate`)\n\t\tVALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, now(), now())\n\t\t\tON DUPLICATE KEY UPDATE `title` = %s, `asin` = %s, `url` = %s, `salesrank` = %s, `artist` = %s, `publisher` = %s, `releasedate` = %s, `review` = %s, `year` = %s, `genreID` = %s, `tracks` = %s, `cover` = %d, createddate = now(), updateddate = now()", $db->escapeString($mus['title']), $db->escapeString($mus['asin']), $db->escapeString($mus['url']), $mus['salesrank'], $db->escapeString($mus['artist']), $db->escapeString($mus['publisher']), $mus['releasedate'], $db->escapeString($mus['review']), $db->escapeString($mus['year']), $mus['musicgenreID'] == -1 ? "null" : $mus['musicgenreID'], $db->escapeString($mus['tracks']), $mus['cover'], $db->escapeString($mus['title']), $db->escapeString($mus['asin']), $db->escapeString($mus['url']), $mus['salesrank'], $db->escapeString($mus['artist']), $db->escapeString($mus['publisher']), $mus['releasedate'], $db->escapeString($mus['review']), $db->escapeString($mus['year']), $mus['musicgenreID'] == -1 ? "null" : $mus['musicgenreID'], $db->escapeString($mus['tracks']), $mus['cover']); $musicId = $db->queryInsert($query); if ($musicId) { if ($this->echooutput) { echo "added/updated album: " . $mus['title'] . " (" . $mus['year'] . ")\n"; } $mus['cover'] = $ri->saveImage($musicId, $mus['coverurl'], $this->imgSavePath, 250, 250); } else { if ($this->echooutput) { echo "nothing to update: " . $mus['title'] . " (" . $mus['year'] . ")\n"; } } return $musicId; }
/** * 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 = array(); // 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 = array(); 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: ") . $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; }
/** * Process all releases tagged as musicinfoID -2 to attempt to retrieve properties from mediainfo xml. */ public function processMusicReleaseFromMediaInfo() { $db = new DB(); $res = $db->query("SELECT r.searchname, ref.releaseID, ref.mediainfo FROM releaseextrafull ref INNER JOIN releases r ON r.ID = ref.releaseID WHERE r.musicinfoID = -2"); $rescount = sizeof($res); if ($rescount > 0) { if ($this->echooutput) { echo "MusicPr : Processing " . $rescount . " audio releases via mediainfo\n"; } //load genres $gen = new Genres(); $defaultGenres = $gen->getGenres(Genres::MUSIC_TYPE); $genreassoc = array(); foreach ($defaultGenres as $dg) { $genreassoc[$dg['ID']] = strtolower($dg['title']); } foreach ($res as $rel) { $albumId = -3; $mi = null; $mi = @simplexml_load_string($rel["mediainfo"]); if ($mi != null) { $artist = (string) $mi->File->track[0]->Performer; $album = (string) $mi->File->track[0]->Album; $year = (string) $mi->File->track[0]->Recorded_date; $genre = (string) $mi->File->track[0]->Genre; $publisher = (string) $mi->File->track[0]->Publisher; $albumCheck = $this->getMusicInfoByName($artist, $album); if ($albumCheck === false) { // // insert new musicinfo // $genreKey = -1; if ($genre != "") { $genreKey = $gen->getOrAddGenreKey($genre, $genreassoc); } $albumId = $this->addUpdateMusicInfo($album, "", "", "null", $artist, $publisher, "null", "", $year, $genreKey, "", 0); } else { $albumId = $albumCheck["ID"]; } } $sql = sprintf("update releases set musicinfoID = %d where ID = %d", $albumId, $rel["releaseID"]); $db->exec($sql); } } return true; }
<?php require_once './config.php'; $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&"; } 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(Genres::MUSIC_TYPE, $activeOnly, $offset, ITEMS_PER_PAGE); $page->smarty->assign('genrelist', $genrelist); $page->content = $page->smarty->fetch('musicgenre-list.tpl'); $page->render();
<?php require_once WWW_DIR . "/lib/releases.php"; require_once WWW_DIR . "/lib/category.php"; require_once WWW_DIR . "/lib/groups.php"; require_once WWW_DIR . "/lib/genres.php"; require_once WWW_DIR . "/lib/nzb.php"; require_once WWW_DIR . "/lib/movie.php"; require_once WWW_DIR . "/lib/util.php"; $releases = new Releases(); $rc = new ReleaseComments(); $gen = new Genres(); $category = new Category(); $grp = new Groups(); $nzb = new NZB(); $movie = new Movie(); if ($page->site->apienabled != 1) { showApiError(910); } // // api functions // $function = "s"; if (isset($_GET["t"])) { if ($_GET["t"] == "details" || $_GET["t"] == "d") { $function = "d"; } elseif ($_GET["t"] == "comments" || $_GET["t"] == "comm") { $function = "co"; } elseif ($_GET["t"] == "commentadd" || $_GET["t"] == "commadd") { $function = "ca"; } elseif ($_GET["t"] == "get" || $_GET["t"] == "g") {
private function getGenresFromBid($bid) { //все класы жанров, что привязаны к индификатору книги $book_genre = BookGenre::model()->with('books')->findAllByAttributes(array('bid' => $bid)); $gids = array(); foreach ($book_genre as $class) { $gids[] = $class->gid; } $genres = Genres::model()->findAllByAttributes(array('gid' => $gids)); //формирую красивый масив для результата функции $result = array(); if (!empty($genres)) { foreach ($genres as $genre) { $result['name'][] = $genre->name; } } return $result; }
<?php if (!$page->users->isLoggedIn()) { $page->show403(); } $console = new Konsole(['Settings' => $page->settings]); $cat = new Category(['Settings' => $page->settings]); $gen = new Genres(['Settings' => $page->settings]); $concats = $cat->getChildren(Category::CAT_PARENT_GAME); $ctmp = []; 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 = []; $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 = []; $results = $console->getConsoleRange($catarray, $offset, ITEMS_PER_COVER_PAGE, $orderby, $page->userdata["categoryexclusions"]); $maxwords = 50; foreach ($results as $result) { if (!empty($result['review'])) { $words = explode(' ', $result['review']);
<?php require_once './config.php'; $page = new AdminPage(); $genres = new Genres(['Settings' => $page->settings]); $id = 0; // Set the current action. $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'view'; switch ($action) { 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"; $id = $_GET["id"]; $genre = $genres->getByID($id); $page->smarty->assign('genre', $genre); } break; } $page->smarty->assign('status_ids', array(Genres::STATUS_ENABLED, Genres::STATUS_DISABLED)); $page->smarty->assign('status_names', array('No', 'Yes')); $page->content = $page->smarty->fetch('musicgenre-edit.tpl'); $page->render();