Example #1
0
$maxwords = 50;
foreach ($results as $result) {
    if (!empty($result['review'])) {
        $words = explode(' ', $result['review']);
        if (sizeof($words) > $maxwords) {
            $newwords = array_slice($words, 0, $maxwords);
            $result['review'] = implode(' ', $newwords) . '...';
        }
    }
    $consoles[] = $result;
}
$platform = isset($_REQUEST['platform']) && !empty($_REQUEST['platform']) ? stripslashes($_REQUEST['platform']) : '';
$page->smarty->assign('platform', $platform);
$title = isset($_REQUEST['title']) && !empty($_REQUEST['title']) ? stripslashes($_REQUEST['title']) : '';
$page->smarty->assign('title', $title);
$genres = $gen->getGenres(Genres::CONSOLE_TYPE, true);
$tmpgnr = [];
foreach ($genres as $gn) {
    $tmpgnr[$gn['id']] = $gn['title'];
}
$genre = isset($_REQUEST['genre']) && array_key_exists($_REQUEST['genre'], $tmpgnr) ? $_REQUEST['genre'] : '';
$page->smarty->assign('genres', $genres);
$page->smarty->assign('genre', $genre);
$browseby_link = '&title=' . $title . '&platform=' . $platform;
$page->smarty->assign('pagertotalitems', $browsecount);
$page->smarty->assign('pageroffset', $offset);
$page->smarty->assign('pageritemsperpage', ITEMS_PER_COVER_PAGE);
$page->smarty->assign('pagerquerybase', WWW_TOP . "/console?t=" . $category . $browseby_link . "&ob=" . $orderby . "&offset=");
$page->smarty->assign('pagerquerysuffix', "#results");
$pager = $page->smarty->fetch("pager.tpl");
$page->smarty->assign('pager', $pager);
 /**
  * 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;
 }
         header('Content-type: application/json');
         echo json_encode(responseXmlToObject($content));
     }
     break;
     //
     // capabilities request
     //
 //
 // capabilities request
 //
 case "c":
     $parentcatlist = $category->getForMenu();
     $page->smarty->assign('parentcatlist', $parentcatlist);
     $grps = $grp->getActive();
     $page->smarty->assign('grps', $grps);
     $genres = $gen->getGenres('', true);
     $page->smarty->assign('genres', $genres);
     header("Content-type: text/xml");
     $output = $page->smarty->fetch('apicaps.tpl');
     if ($outputtype == "xml") {
         header("Content-type: text/xml");
         echo $output;
     } else {
         header('Content-type: application/json');
         echo json_encode(responseXmlToObject($output));
     }
     break;
     //
     // register request
     //
 //
Example #4
0
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;
}
Example #5
0
 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;
 }
Example #6
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 = 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;
    }
Example #7
0
    $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']));
            $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"]);
            header("Location:" . WWW_TOP . "/music-list.php");
            die;
            break;
        case 'view':
        default:
            $page->title = "Music Edit";
            $page->smarty->assign('music', $mus);
            $page->smarty->assign('genres', $gen->getGenres(Genres::MUSIC_TYPE));
            break;
    }
}
$page->content = $page->smarty->fetch('music-edit.tpl');
$page->render();
Example #8
0
 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;
 }
Example #9
0
    $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;
            break;
        case 'view':
        default:
            $page->title = "Console Edit";
            $page->smarty->assign('console', $con);
            $page->smarty->assign('genres', $gen->getGenres(Genres::CONSOLE_TYPE));
            break;
    }
}
$page->content = $page->smarty->fetch('console-edit.tpl');
$page->render();
Example #10
0
 /**
  * @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;
 }
Example #11
0
 /**
  * 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;
 }
Example #12
0
$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) {
    //$result['genre'] = $music->makeFieldLinks($result, 'genre');
    $musics[] = $result;
}
$artist = isset($_REQUEST['artist']) && !empty($_REQUEST['artist']) ? stripslashes($_REQUEST['artist']) : '';
$page->smarty->assign('artist', $artist);
$title = isset($_REQUEST['title']) && !empty($_REQUEST['title']) ? stripslashes($_REQUEST['title']) : '';
$page->smarty->assign('title', $title);
$genres = $gen->getGenres(Genres::MUSIC_TYPE, true);
$tmpgnr = array();
foreach ($genres as $gn) {
    $tmpgnr[$gn['ID']] = $gn['title'];
}
$genre = isset($_REQUEST['genre']) && array_key_exists($_REQUEST['genre'], $tmpgnr) ? $_REQUEST['genre'] : '';
$page->smarty->assign('genres', $genres);
$page->smarty->assign('genre', $genre);
$years = range(1950, date("Y") + 1);
rsort($years);
$year = isset($_REQUEST['year']) && in_array($_REQUEST['year'], $years) ? $_REQUEST['year'] : '';
$page->smarty->assign('years', $years);
$page->smarty->assign('year', $year);
$browseby_link = '&amp;title=' . $title . '&amp;artist=' . $artist . '&amp;genre=' . $genre . '&amp;year=' . $year;
$page->smarty->assign('pagertotalitems', $browsecount);
$page->smarty->assign('pageroffset', $offset);
Example #13
0
    $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;
        case 'view':
        default:
            $page->title = "Game Edit";
            $page->smarty->assign('game', $game);
            $page->smarty->assign('genres', $gen->getGenres(\Genres::GAME_TYPE));
            break;
    }
}
$page->content = $page->smarty->fetch('game-edit.tpl');
$page->render();
Example #14
0
    if (!empty($result['review'])) {
        // remove "Overview" from start of review if present
        if (0 === strpos($result['review'], 'Overview')) {
            $result['review'] = substr($result['review'], 8);
        }
        $words = explode(' ', $result['review']);
        if (sizeof($words) > $maxwords) {
            $newwords = array_slice($words, 0, $maxwords);
            $result['review'] = implode(' ', $newwords) . '...';
        }
    }
    $games2[] = $result;
}
$title = isset($_REQUEST['title']) && !empty($_REQUEST['title']) ? stripslashes($_REQUEST['title']) : '';
$page->smarty->assign('title', $title);
$genres = $gen->getGenres(Genres::GAME_TYPE, true);
$tmpgnr = array();
foreach ($genres as $gn) {
    $tmpgnr[$gn['id']] = $gn['title'];
}
$years = range(1903, date("Y") + 1);
rsort($years);
$year = isset($_REQUEST['year']) && in_array($_REQUEST['year'], $years) ? $_REQUEST['year'] : '';
$page->smarty->assign('years', $years);
$page->smarty->assign('year', $year);
$genre = isset($_REQUEST['genre']) && array_key_exists($_REQUEST['genre'], $tmpgnr) ? $_REQUEST['genre'] : '';
$page->smarty->assign('genres', $genres);
$page->smarty->assign('genre', $genre);
$browseby_link = '&amp;title=' . $title . '&amp;year=' . $year;
$page->smarty->assign('pagertotalitems', $browsecount);
$page->smarty->assign('pageroffset', $offset);