diff --git a/data/index.php b/data/index.php index 0f0c4d4..6fbe5c1 100644 --- a/data/index.php +++ b/data/index.php @@ -96,51 +96,54 @@ $handle = fopen($filename, "r"); $data = fread($handle, filesize($filename)); - // Get EXIF data - $exif = exif_read_data($handle); - if (is_array($exif) && array_key_exists('Model', $exif)) { - // Read software string in 3DS screenshots - // Read software string in 3DS screenshots - if ($exif['Model'] === 'Nintendo 3DS') { - // All the regions from the titlelist - // GB = EUR/PAL - // KR AND TW are Korea and Taiwan - // filenames are titlelist_$region.json - // files from hax0kartik/3dsdb(values retrived from eshop directly) - - /* - EACH GAME IN THE JSON IS MADE LIKE THIS: - { - "Name": "Shovel Software Insurance Claim", - "UID": "50010000049535", - "TitleID": "000400000F715C00", - "Version": "N/A", - "Size": "25.7 MB [206 blocks]", - "Product Code": "KTR-N-CF6P", - "Publisher": "Batafurai" - }, - - BUNCH OF STUFF FOR RATING BUT IT ISN'T WHAT WE SEARCH.(only need names and title id) - - the title id is in the attributes of so we have to access via the ->attributes()->id thing. - */ - - $regions = ["GB", "JP", "KR", "TW", "US"]; - // Match ID with game title if possible - $id = strtoupper($exif['Software']); - foreach($regions as $region) { // FOR EACH REGION!! - $json=json_decode(file_get_contents('titlelist/list_'.$region.'.json')); - foreach($json as $game) { - if ($game->TitleID == '000400000'.$id.'00') { - // Update software name + // Only read EXIF data from JPEG images + if ($img['type'] === 'image/jpeg') { + // Get EXIF data + $exif = exif_read_data($handle); + if (is_array($exif) && array_key_exists('Model', $exif)) { + // Read software string in 3DS screenshots + // Read software string in 3DS screenshots + if ($exif['Model'] === 'Nintendo 3DS') { + // All the regions from the titlelist + // GB = EUR/PAL + // KR AND TW are Korea and Taiwan + // filenames are titlelist_$region.json + // files from hax0kartik/3dsdb(values retrived from eshop directly) + /* + EACH GAME IN THE JSON IS MADE LIKE THIS: + { + "Name": "Shovel Software Insurance Claim", + "UID": "50010000049535", + "TitleID": "000400000F715C00", + "Version": "N/A", + "Size": "25.7 MB [206 blocks]", + "Product Code": "KTR-N-CF6P", + "Publisher": "Batafurai" + }, + + BUNCH OF STUFF FOR RATING BUT IT ISN'T WHAT WE SEARCH.(only need names and title id) + + the title id is in the attributes of <title> so we have to access via the ->attributes()->id thing. + */ + + $regions = ["GB", "JP", "KR", "TW", "US"]; + // Match ID with game title if possible + $id = strtoupper($exif['Software']); + foreach($regions as $region) { // FOR EACH REGION!! + $json=json_decode(file_get_contents('titlelist/list_'.$region.'.json')); + foreach($json as $game) { + if ($game->TitleID == '000400000'.$id.'00') { + // Update software name + - $software = str_replace("\u2122", "", $game->Name); - break 2; // in order to break fully of 2 foreachs. + $software = str_replace("\u2122", "", $game->Name); + break 2; // in order to break fully of 2 foreachs. + } } } } - } + } } // Set up image upload with selected service