collectDataUrl(self::URI . 'xml.php'); } protected function collectDataUrl($dataUrl){ $xml = getContents($dataUrl) or returnServerError('Could not request URL: ' . $dataUrl); $limit = 0; foreach(array_reverse(explode('', $xml)) as $element) { if($limit >= 5) { break; } if(strpos($element, '') === false) { continue; } $releasename = extractFromDelimiters($element, '', ''); if(empty($releasename)) { continue; } $id = extractFromDelimiters($element, '', ''); $name = extractFromDelimiters($element, '', ''); $publisher = extractFromDelimiters($element, '', ''); $region = extractFromDelimiters($element, '', ''); $group = extractFromDelimiters($element, '', ''); $imagesize = extractFromDelimiters($element, '', ''); $serial = extractFromDelimiters($element, '', ''); $titleid = extractFromDelimiters($element, '', ''); $imgcrc = extractFromDelimiters($element, '', ''); $filename = extractFromDelimiters($element, '', ''); $trimmedsize = extractFromDelimiters($element, '', ''); $firmware = extractFromDelimiters($element, '', ''); $type = extractFromDelimiters($element, '', ''); $card = extractFromDelimiters($element, '', ''); //Retrieve cover art and short desc from IGN? $ignResult = false; $ignDescription = ''; $ignLink = ''; $ignDate = time(); $ignCoverArt = ''; $ignSearchUrl = 'https://www.ign.com/search?q=' . urlencode($name); if($ignResult = getSimpleHTMLDOMCached($ignSearchUrl)) { $ignCoverArt = $ignResult->find('div.search-item-media', 0); $ignDesc = $ignResult->find('div.search-item-description', 0); $ignLink = $ignResult->find('div.search-item-sub-title', 0); $ignDate = $ignResult->find('span.publish-date', 0); if (is_object($ignCoverArt)) $ignCoverArt = $ignCoverArt->find('img', 0); if (is_object($ignLink)) $ignLink = $ignLink->find('a', 1); if (is_object($ignDate)) $ignDate = strtotime(trim($ignDate->plaintext)); if (is_object($ignCoverArt) && is_object($ignDesc) && is_object($ignLink)) { $ignDescription = '
' . $ignDesc->plaintext . ' More at IGN
'; } } //Main section : Release description from 3DS database $releaseDescription = '

Release Details

Release ID: ' . $id . '
Game Name: ' . $name . '
Publisher: ' . $publisher . '
Region: ' . $region . '
Group: ' . $group . '
Image size: ' . (intval($imagesize) / 8) . 'MB
Serial: ' . $serial . '
Title ID: ' . $titleid . '
Image CRC: ' . $imgcrc . '
File Name: ' . $filename . '
Release Name: ' . $releasename . '
Trimmed size: ' . intval(intval($trimmedsize) / 1048576) . 'MB
Firmware: ' . $firmware . '
Type: ' . $this->typeToString($type) . '
Card: ' . $this->cardToString($card) . '
'; //Build search links section to facilitate release search using search engines $releaseNameEncoded = urlencode(str_replace(' ', '+', $releasename)); $searchLinkGoogle = 'https://google.com/?q=' . $releaseNameEncoded; $searchLinkDuckDuckGo = 'https://duckduckgo.com/?q=' . $releaseNameEncoded; $searchLinkQwant = 'https://lite.qwant.com/?q=' . $releaseNameEncoded . '&t=web'; $releaseSearchLinks = '

Search this release

'; //Build and add final item with the above three sections $item = array(); $item['title'] = $name; $item['author'] = $publisher; $item['timestamp'] = $ignDate; $item['enclosures'] = array($ignCoverArt); $item['uri'] = empty($ignLink) ? $searchLinkDuckDuckGo : $ignLink; $item['content'] = $ignDescription . $releaseDescription . $releaseSearchLinks; $this->items[] = $item; $limit++; } } private function typeToString($type){ switch($type) { case 1: return 'Card Game'; case 4: return 'eShop'; default: return '??? (' . $type . ')'; } } private function cardToString($card){ switch($card) { case 1: return 'Regular (CARD1)'; case 2: return 'NAND (CARD2)'; default: return '??? (' . $card . ')'; } } }