The official website for the open-source compatibility layer fpPS4
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

before massive code rewrites, if i need to look at older code

+437 -140
+3 -1
.gitignore
··· 9 9 public_html/.htaccess 10 10 public_html/ads.txt 11 11 public_html/images/Thumbs.db 12 - public_html/images/CUSA 12 + public_html/images/CUSA 13 + public_html/images/HOMEBREW 14 + public_html/scripts/HBstore.db
+1 -1
public_html/404.php
··· 2 2 <HTML><HEAD> 3 3 <TITLE>404 :/</TITLE> 4 4 <style>@import url('https://fonts.googleapis.com/css2?family=Montserrat');</style> 5 - <link rel="icon" href="https://fpps4.net/images/fpPS4-icon.png" type="image/png"> 5 + <link rel="icon" href="https://fpps4.net/images/fpPS4Logo.png" type="image/png"> 6 6 <meta name="robots" content="noindex"> 7 7 </HEAD><BODY style="background-color: #0e141b; color: white; font-family: 'Montserrat', sans-serif; text-align: center;"> 8 8 <H1>404: Not Found :/</H1>
+11 -2
public_html/compatibility/app.js
··· 18 18 let noImagesLocked = false; 19 19 let maxValue; 20 20 21 + var urlParams = new URLSearchParams(window.location.search); 22 + var tagParam = urlParams.get('tag'); 23 + if (tagParam) { 24 + tagFilter.push(tagParam); 25 + tagElementForFilter = document.getElementById(tagParam + 'Bar'); 26 + tagParentForFilter = tagElementForFilter.parentElement; 27 + tagParentForFilter.classList.toggle('selected'); 28 + } 29 + 30 + 21 31 function setCookie(name, value) { 22 32 var date = new Date(); 23 33 date.setMonth(date.getMonth() + 1); ··· 101 111 102 112 // Page Load 103 113 document.addEventListener('DOMContentLoaded', function() { 104 - fetch('https://fpps4.net/scripts/search.php?q=&stats') 114 + fetch('https://fpps4.net/scripts/search.php?q=&stats&tag='+ tagFilter) 105 115 .then(response => response.text()) 106 116 .then(data => { 107 117 document.querySelector('#gameWrapper').innerHTML = data; ··· 190 200 // Filters 191 201 function filter() { 192 202 var ids = ['Nothing', 'Boots', 'Menus', 'Ingame', 'Playable']; 193 - 194 203 ids.forEach(id => { 195 204 element = document.getElementById(id + 'Bar'); 196 205 parent = element.parentElement;
+2 -2
public_html/compatibility/index.html
··· 8 8 <meta property="title" content="Game Compatibility List"> 9 9 <meta property="og:title" content="fpPS4 - Game Compatibility List"> 10 10 <meta property="og:description" content="These are the games that have been tested with fpPS4"> 11 - <meta property="og:image" content="https://fpps4.net/images/fpPS4-icon.png"> 11 + <meta property="og:image" content="https://fpps4.net/images/fpPS4Logo.png"> 12 12 <meta property="og:url" content="https://fpps4.net/compatibility"> 13 13 <meta name="description" content="These are the games that have been tested with fpPS4"> 14 14 <meta name="theme-color" content="#4C566A"> ··· 17 17 <meta name="robots" content="index,follow"> 18 18 <meta name="author" content="Mr. Snowy"> 19 19 <link rel="stylesheet" href="./styles.css"> 20 - <link rel="icon" href="https://fpps4.net/images/fpPS4-icon.png" type="image/png"> 20 + <link rel="icon" href="https://fpps4.net/images/fpPS4Logo.png" type="image/png"> 21 21 </head> 22 22 <style> 23 23 /* fixes page load stuff */
+1 -1
public_html/compatibility/styles.css
··· 21 21 --main0: #26272a; 22 22 --main1: #2f3134; 23 23 --hover: #393b3e; 24 - --selected: #424448; 24 + --selected: #4b4d52; 25 25 } 26 26 27 27 .lightMode {
public_html/images/NA.png

This is a binary file and will not be displayed.

public_html/images/fpPS4Logo.png

This is a binary file and will not be displayed.

public_html/images/fpPS4Logo1080.png

This is a binary file and will not be displayed.

public_html/images/fpPS4Logo512.png

This is a binary file and will not be displayed.

+100 -68
public_html/index.html
··· 1 - <!-- 2 - _ __ __ __ 3 - | | / /__ / /________ ____ ___ ___ / /_____ _ 4 - | | /| / / _ \/ / ___/ __ \/ __ `__ \/ _ \ / __/ __ \ (_) 5 - | |/ |/ / __/ / /__/ /_/ / / / / / / __/ / /_/ /_/ / _ 6 - |__/|__/\___/_/\___/\____/_/ /_/ /_/\___/ \__/\____/ (_) 7 - ____ ____ _____ __ __ 8 - / __/___ / __ \/ ___// // / 9 - / /_/ __ \/ /_/ /\__ \/ // /_ 10 - / __/ /_/ / ____/___/ /__ __/ 11 - /_/ / .___/_/ /____/ /_/ 12 - /_/ 13 - --> 14 1 <!DOCTYPE html> 15 2 <html lang="en"> 16 - <head> 17 - <meta charset="UTF-8"> 18 - <meta http-equiv="X-UA-Compatible" content="IE=edge"> 19 - <meta name="viewport" content="width=device-width, initial-scale=1"> 20 - <title>fpPS4</title> 21 - <meta name="description" content="fpPS4 is an open source PS4 compatibility layer (emulator) written with Free Pascal for Windows."> 22 - <meta name="keywords" content="fpPS4, playstation, ps4, playstation 4, emulator, windows, open source, free pascal, compatibility layer, red-prig, fpps4 github, fpps4 discord"> 23 - <meta name="robots" content="index,follow"> 24 - <meta name="author" content="Mr. Snowy"> 25 - <meta name="copyright" content="fpPS4"> 26 - <meta name="theme-color" content="#4C566A"> 27 - <meta property="og:title" content="fpPS4 - An open source PS4 compatibility layer"> 28 - <meta property="og:description" content="fpPS4 is an open source PS4 compatibility layer written with Free Pascal for Windows."> 29 - <meta property="og:image" content="https://fpps4.net/images/fpPS4-icon.png"> 30 - <meta property="og:url" content="https://fpps4.net"> 31 - <link rel="stylesheet" href="./style.css?v=01"> 32 - <link rel="stylesheet" href="./sizes.css"> 33 - <link href="https://fonts.googleapis.com/css2?family=Montserrat&display=swap" rel="stylesheet"> 34 - <link rel="icon" href="./images/fpPS4-icon.png" type="image/png"> 35 - <!-- <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5258598655913445" 36 - crossorigin="anonymous"></script> --> 37 - </head> 38 - <body> 39 - <div class="top"> 40 - <div class="top-text-container"> 41 - <h1 class="coming-soon">Work In Progress</h1> 42 - <h1 class="main-text"><span style="color: #f0e74a;">fp</span>PS4.net</h1> 43 - <p class="progress-text">The offical website for the open-source<br>compatibility layer fpPS4</p> 44 - <div class="topButtonContainer"> 45 - <a href="#learnmore" onclick="scrollToElement(event, 'learnmore')" class="button">Learn more</a> 46 - <a href="https://fpps4.net/compatibility" class="button">Compatibility</a> 47 - </div> 48 - </div> 49 - </div> 50 - <div class="bottom-container" id="learnmore"> 51 - <div class="bottom-left"> 52 - <h1 class="bottom-top-text"><span style="color: #f0e74a;">fp</span>PS4</h1> 53 - <p class="bottom-desc-text">An open-source PS4 compatibility layer (emulator) written with Free Pascal</p> 54 - <div class="buttons-container"> 55 - <a href="https://github.com/red-prig/fpPS4" target="_blank" class="button">Github</a> 56 - <a href="https://discord.gg/up9qatpX7M" target="_blank" class="button">Discord</a> 57 - </div> 58 - </div> 59 - <div class="bottom-right"> 60 - <h1 class="bottom-top-text">Special thanks to:</h1> 61 - <div class="thank-user-container"> 62 - <a href="https://github.com/red-prig" target="_blank"><b>Red-Prig</b> - For developing <span style="color: #f0e74a;">fp</span>PS4</a> 63 - <a href="https://github.com/georgemoralis" target="_blank"><b>georgemoralis</b> - For donating the domain</a> 64 - <a href="https://github.com/KimieStar" target="_blank"><b>KimieStar</b> - For helping with the website</a> 65 - <a href="https://github.com/MrSn0wy" target="_blank"><b>Mr. Snowy</b> - For making the website</a> 66 - </div> 67 - </div> 68 - </div> 69 - </body> 70 - <script src="app.js"></script> 3 + <head> 4 + <meta charset="UTF-8"> 5 + <meta http-equiv="X-UA-Compatible" content="IE=edge"> 6 + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> 7 + <title>fpPS4 - Compatibility List</title> 8 + <meta property="title" content="Game Compatibility List"> 9 + <meta property="og:title" content="fpPS4 - Game Compatibility List"> 10 + <meta property="og:description" content="These are the games that have been tested with fpPS4"> 11 + <meta property="og:image" content="https://fpps4.net/images/fpPS4Logo.png"> 12 + <meta property="og:url" content="https://fpps4.net/compatibility"> 13 + <meta name="description" content="These are the games that have been tested with fpPS4"> 14 + <meta name="theme-color" content="#4C566A"> 15 + <meta name="copyright" content="fpPS4"> 16 + <meta name="keywords" content="fpPS4, playstation, ps4, playstation 4, emulator, windows, open source, free pascal, compatibility layer, red-prig, compatibility list, compatibility, fpps4 compatibility list, fpps4 compatibility, fpps4 game compatibility"> 17 + <meta name="robots" content="index,follow"> 18 + <meta name="author" content="Mr. Snowy"> 19 + <link rel="stylesheet" href="./styles.css"> 20 + <link rel="icon" href="https://fpps4.net/images/fpPS4Logo.png" type="image/png"> 21 + </head> 22 + <style> 23 + /* fixes page load stuff */ 24 + .progressBarInfo {opacity: 0;} 25 + </style> 26 + <body> 27 + <header id="header"> 28 + <style> 29 + header { 30 + position: fixed; 31 + height: 3rem; 32 + } 33 + </style> 34 + </header> 35 + <main class="main"> 36 + <h1 class="mainText">Game Compatibility List</h1> 37 + <h3 class="smolMainText">These are the games that have been tested with <span style="color: #f0e74a;">fp</span>PS4.<br>Click on an image to view the game's GitHub issue.<br>The database is updated every 20 minutes.</h3> 38 + <div class=progressContainer> 39 + <div class="progressWrap"><span class="progressBarInfo" id="PlayableInfo"></span><span class="progressBarText">Playable</span><div class="progressBar" id="PlayableBar" style="background:#54A396;"></div></div> 40 + <div class="progressRow"> 41 + <div class="progressWrap"><span class="progressBarInfo" id="MenusInfo"></span><span class="progressBarText">Menus</span><div class="progressBar" id="MenusBar" style="background:#4288B7;"></div></div> 42 + <div class="progressWrap"><span class="progressBarInfo" id="IngameInfo"></span><span class="progressBarText">Ingame</span><div class="progressBar" id="IngameBar" style="background:#fabb44;"></div></div> 43 + </div> 44 + <div class="progressRow"> 45 + <div class="progressWrap"><span class="progressBarInfo" id="NothingInfo"></span><span class="progressBarText">Nothing</span><div class="progressBar" id="NothingBar" style="background:#1F2325;"></div></div> 46 + <div class="progressWrap"><span class="progressBarInfo" id="BootsInfo"></span><span class="progressBarText">Boots</span><div class="progressBar" id="BootsBar" style="background:#F2766E;"></div></div> 47 + </div></div> 48 + <div class="searchContainer"> 49 + <div class="searchBarContainer"> 50 + <input autocomplete="off" type="text" name="fpps4" class="searchBar" id="search" placeholder="Search TITLE / CUSA"> 51 + <input autocomplete="off" type="number" min="1" placeholder="1/1" name="fpps4" class="pageSelector" id="search2"> 52 + </div> 53 + 54 + <div class="optionButtons"> 55 + <div onclick="sortButton(this)" class="optionButton">Oldest</div> 56 + <div id="imageButton" onclick="imageButton()" class="optionButton">No Images</div> 57 + <div id="datesButton" onclick="dateButton()" class="optionButton">Dates</div> 58 + </div> 59 + </div> 60 + <div id="gameWrapper" class="gameWrapper"> 61 + <div class="gameContainer skeletonAnimation"></div> 62 + <div class="gameContainer skeletonAnimation"></div> 63 + <div class="gameContainer skeletonAnimation"></div> 64 + <div class="gameContainer skeletonAnimation"></div> 65 + <div class="gameContainer skeletonAnimation"></div> 66 + <div class="gameContainer skeletonAnimation"></div> 67 + <div class="gameContainer skeletonAnimation"></div> 68 + <div class="gameContainer skeletonAnimation"></div> 69 + <div class="gameContainer skeletonAnimation"></div> 70 + <div class="gameContainer skeletonAnimation"></div> 71 + <div class="gameContainer skeletonAnimation"></div> 72 + <div class="gameContainer skeletonAnimation"></div> 73 + <div class="gameContainer skeletonAnimation"></div> 74 + <div class="gameContainer skeletonAnimation"></div> 75 + <div class="gameContainer skeletonAnimation"></div> 76 + <div class="gameContainer skeletonAnimation"></div> 77 + <div class="gameContainer skeletonAnimation"></div> 78 + <div class="gameContainer skeletonAnimation"></div> 79 + <div class="gameContainer skeletonAnimation"></div> 80 + <div class="gameContainer skeletonAnimation"></div> 81 + <h4 class="totalTimeText">0 results in 0ms </h4> 82 + </div> 83 + <div class="pageBarContainer"> 84 + <img class="pageBarImage" id="pageBarBack" onclick="pageBarBack()" src="../images/arrow_back.svg" alt=""> 85 + <p class="pageBarButton" id="pageBarMin" onclick="pageBarMin()">1</p> 86 + <input class="pageBarSearch" id="search3" autocomplete="off" type="number" min="1" placeholder="..." name="fpps4"> 87 + <p class="pageBarButton" id="pageBarMax" onclick="pageBarMax()">1</p> 88 + <img class="pageBarImage" id="pageBarForward" onclick="pageBarForward()" src="../images/arrow_forward.svg" alt=""> 89 + </div> 90 + <h5 style="text-align: center; font-size: 0.8rem;">Trademarks and logos displayed on this website are the property of their respective owners.<br> The use of any third-party trademarks, brand names, product names, and logos is for<br> informational purposes only and does not imply endorsement or sponsorship.</h5> 91 + <br> 92 + </main> 93 + <footer id="footer"> 94 + <style> 95 + footer { 96 + height: 3.65rem; 97 + margin-top: 3rem; 98 + } 99 + </style> 100 + </footer> 101 + <script defer src="app.js"></script> 102 + </body> 71 103 </html>
+2 -2
public_html/parts/footer.html
··· 61 61 </style> 62 62 <div class="footerLeft"> 63 63 <a class="footerContent" href="https://github.com/red-prig" target="_blank"> 64 - <img class="footerImage" src="https://avatars.githubusercontent.com/u/68122101" alt="red-prig github icon"> 64 + <img class="footerImage" loading="lazy" src="https://avatars.githubusercontent.com/u/68122101" alt="red-prig github icon"> 65 65 <h3 class="footerText" >red-prig: Developer of <span style="color: #f0e74a;">fp</span>PS4</h3> 66 66 </a> 67 67 </div> ··· 69 69 <div class="footerRight"> 70 70 <a class="footerContent" href="https://github.com/MrSn0wy" target="_blank"> 71 71 <h3 class="footerText" >Website by: Mr. Snowy © 2023</h3> 72 - <img class="footerImage" src="https://avatars.githubusercontent.com/u/61592704" alt="Mr.Snowy github icon"> 72 + <img class="footerImage" loading="lazy" src="https://avatars.githubusercontent.com/u/61592704" alt="Mr.Snowy github icon"> 73 73 </a> 74 74 </div>
+4
public_html/robots.txt
··· 1 1 User-agent: * 2 2 Allow: / 3 + 4 + User-agen: GPTBot 5 + Disallow: / 6 + 3 7 Sitemap: https://fpps4.net/sitemap.xml
+116
public_html/scripts/api.php
··· 1 + <?php 2 + $serverUsername = getenv('USERNAME'); 3 + require_once "/home/{$serverUsername}/domains/fpps4.net/config/config.php"; // import config file 4 + $validSecret = API_ACCESS_SECRET; 5 + $validArgument = API_ARGUMENT_SECRET; 6 + 7 + $headers = apache_request_headers(); 8 + 9 + // foreach ($headers as $header => $value) { 10 + 11 + // if ($header === "Token") { 12 + 13 + // if ($value === $validSecret) { 14 + // die('yeey you got in !'); 15 + // } 16 + // } 17 + // } 18 + 19 + 20 + /// makes it so the api is accessible by: headers, browser query and by command line arguments :3 21 + if ((isset($_GET[$validArgument]) && $_GET[$validArgument] === $validSecret) || (isset($argv[1]) && $argv[1] === $validSecret) || isset($_SERVER['HTTP_AUTHORIZATION']) === $validSecret) { 22 + 23 + /// processing user input 24 + $cusaCodes = isset($_GET['cusa']) ? $_GET['cusa'] : ''; 25 + $homebrews = isset($_GET['homebrew']) ? $_GET['homebrew'] : ''; 26 + 27 + $cusaCodes = filter_var($cusaCodes, FILTER_SANITIZE_STRING); 28 + $homebrews = filter_var($homebrews, FILTER_SANITIZE_STRING); 29 + 30 + 31 + 32 + if ($cusaCodes || $homebrews) { 33 + 34 + /// make connection to database 35 + $host = DATABASE_HOST; 36 + $database = DATABASE_NAME; 37 + $username = DATABASE_USERNAME; 38 + $password = DATABASE_PASSWORD; 39 + 40 + try { 41 + $conn = new PDO("mysql:host=$host;dbname=$database", $username, $password); 42 + } catch (PDOException $e) { 43 + die("The server got itself into trouble, sorry for that."); 44 + } 45 + 46 + 47 + /// variables 48 + $cusacodeArray = array(); 49 + $homebrewArray = array(); 50 + $cusacode = explode(',', $cusaCodes); 51 + $homebrew = explode(',', $homebrews); 52 + 53 + /// handles cusa codes and gets status 54 + if ($cusaCodes) { 55 + foreach ($cusacode as $code) { 56 + $query = "SELECT tags FROM issues WHERE cusacode = :cusacode"; 57 + $stmt = $conn->prepare($query); 58 + $stmt->bindParam(':cusacode', $code, PDO::PARAM_STR); 59 + $stmt->execute(); 60 + $result = $stmt->fetchAll(PDO::FETCH_ASSOC); 61 + // print_r($result); // debug 62 + 63 + if ($result) { 64 + $tag = $result["0"]["tags"]; 65 + } else { 66 + $tag = "N/A"; 67 + } 68 + 69 + // echo "$tag"; // debug 70 + $cusacodeArray[] = array( 71 + "id" => $code, 72 + "tag" => $tag 73 + ); 74 + } 75 + } 76 + 77 + if ($homebrews) { 78 + foreach ($homebrew as $code) { 79 + $query = "SELECT tags FROM issues WHERE title = :homebrew"; 80 + $stmt = $conn->prepare($query); 81 + $stmt->bindParam(':homebrew', $code, PDO::PARAM_STR); 82 + $stmt->execute(); 83 + $HBresult = $stmt->fetchAll(PDO::FETCH_ASSOC); 84 + // print_r($HBresult); // debug 85 + 86 + if ($HBresult) { 87 + $tag = $HBresult["0"]["tags"]; 88 + } else { 89 + $tag = "N/A"; 90 + } 91 + 92 + $homebrewArray[] = array( 93 + "title" => $code, 94 + "tag" => $tag 95 + ); 96 + } 97 + } 98 + 99 + $data = array( 100 + "cusacode" => $cusacodeArray, 101 + "homebrew" => $homebrewArray 102 + ); 103 + 104 + /// end 105 + header('Content-Type: application/json'); 106 + $jsonData = json_encode($data); 107 + //$jsonData = json_encode($data, JSON_PRETTY_PRINT); 108 + echo $jsonData; 109 + $conn = null; //exit connection 110 + } 111 + 112 + 113 + } else { 114 + http_response_code(404); 115 + include("/home/{$serverUsername}/domains/fpps4.net/public_html/404.php"); 116 + }?>
-13
public_html/scripts/bot.php
··· 1 - <?php 2 - $serverUsername = getenv('USERNAME'); 3 - require_once "/home/{$serverUsername}/domains/fpps4.net/config/config.php"; // import config file 4 - $validSecret = BOT_ACCESS_SECRET; 5 - $validArgument = BOT_ARGUMENT_SECRET; 6 - 7 - // The secret query parameter is provided and matches the valid secret 8 - if ((isset($_GET[$validArgument]) && $_GET[$validArgument] === $validSecret) || (isset($argv[1]) && $argv[1] === $validSecret)) { 9 - echo "you got the password right, nice!"; 10 - } else { 11 - http_response_code(404); 12 - include("/home/{$serverUsername}/domains/fpps4.net/public_html/404.php"); 13 - }?>
+197 -50
public_html/scripts/issue_fetcher.php
··· 1 1 <?php 2 + error_reporting(E_ALL); 3 + ini_set('display_errors', '1'); 2 4 $serverUsername = getenv('USERNAME'); 3 5 require_once "/home/{$serverUsername}/domains/fpps4.net/config/config.php"; // import config file 4 6 $validSecret = ACCESS_SECRET; ··· 13 15 $database = DATABASE_NAME; 14 16 $githubToken = GITHUB_TOKEN; 15 17 $tmdbHash = TMDB_HASH; 18 + $homebrewUseragent = HB_USERAGENT; 16 19 17 20 try { 21 + // get homebrew db for images 22 + $header = stream_context_create(["http" => ["header" => "User-Agent: $homebrewUseragent\r\n"]]); 23 + $response = file_get_contents("https://api.pkg-zone.com/api.php?db_check_hash=true", false, $header); 24 + if ($response !== false) { 25 + $data = json_decode($response); 26 + $hash = $data->hash; 27 + $md5Hash = md5_file("/home/{$serverUsername}/domains/fpps4.net/public_html/scripts/HBstore.db"); // will give warning on first download 28 + if ($hash === $md5Hash) { 29 + echo("the db is the same! response: $hash local: $md5Hash <br>"); 30 + } else { 31 + echo("the db is diffrent! response: $hash local: $md5Hash downloading db <br>"); 32 + $fileContent = file_get_contents("https://api.pkg-zone.com/store.db", false, $header); 33 + if ($fileContent !== false) { 34 + file_put_contents("/home/{$serverUsername}/domains/fpps4.net/public_html/scripts/HBstore.db", $fileContent) !== false ? die("DB downloaded and saved successfully.<br>") : die("Error saving the downloaded DB.<br>"); 35 + } else { 36 + die("Error downloading the DB from the URL."); 37 + } 38 + } 39 + } else { 40 + echo("Error verifying hash, ignoring for now."); 41 + } 42 + 43 + $dbFile = "/home/{$serverUsername}/domains/fpps4.net/public_html/scripts/HBstore.db"; 44 + try { 45 + $homebrewDB = new PDO("sqlite:$dbFile"); 46 + echo "Connected to the database successfully! <br>"; 47 + } catch (PDOException $e) { 48 + echo "Connection failed: " . $e->getMessage() . "<br>"; 49 + } 50 + 18 51 $conn = new PDO("mysql:host=$host;dbname=$database", $username, $password); 19 52 $conn->query("DROP TABLE IF EXISTS newIssues"); 20 53 ··· 36 69 )"; 37 70 38 71 $sqlSkips = "CREATE TABLE IF NOT EXISTS GameSkips ( 39 - cusaCode VARCHAR(10) PRIMARY KEY 72 + code VARCHAR(130) PRIMARY KEY 40 73 )"; 41 74 42 75 $conn->exec($sqlOld); 43 76 $conn->exec($sqlNew); 44 77 $conn->exec($sqlSkips); 45 78 echo "Tables created successfully.<br>"; 79 + // die("Tables created successfully.<br>"); 46 80 47 81 } catch (PDOException $e) { 48 82 die("Error creating tables: " . $e->getMessage()); ··· 104 138 $cusaCode = "HOMEBREW"; 105 139 $clean_title = preg_replace('/\s-\s.*$/', '', $title); 106 140 $clean_title = trim(explode('(Homebrew)', $clean_title)[0]); 141 + $clean_title = trim(explode('Homebrew', $clean_title)[0]); 142 + //$clean_title = trim(explode('Game', $clean_title)[0]); 143 + $clean_title = rtrim($clean_title, ' '); 144 + } else if (in_array("app-system-fw505", array_column($issue['labels'], 'name'))){ 145 + $cusaCode = "SYSTEM APP"; 146 + $clean_title = preg_replace('/\s-\s.*$/', '', $title); 147 + } else if (in_array("app-ps2game", array_column($issue['labels'], 'name'))){ 148 + $cusaCode = "PS2 GAME"; 149 + $clean_title = preg_replace('/\s-\s.*$/', '', $title); 107 150 } else { 108 151 $clean_title = preg_replace('/\b' . preg_quote($cusaCode, '/') . '\b/', '', $title); 109 152 $clean_title = preg_replace('/\s+-\s+/', ' - ', $clean_title); ··· 168 211 } 169 212 170 213 // Images logic 171 - function get_image($cusaCode, $conn, $serverUsername) { 172 - global $tmdbHash; 173 - $key = hex2bin($tmdbHash); 174 - $hashme = $cusaCode . '_00'; 175 - $hash = strtoupper(hash_hmac('sha1', $hashme, $key)); 176 - $url = "https://tmdb.np.dl.playstation.net/tmdb2/{$cusaCode}_00_{$hash}/{$cusaCode}_00.json"; 214 + function get_image($cusaCode, $homebrewDB) { 215 + global $issue; 216 + global $serverUsername; 217 + global $conn; 218 + global $homebrewUseragent; 219 + //global $homebrewDB; 220 + $iconUrl = ''; 221 + $avifIconURL = ''; 222 + echo " DEBUG: $cusaCode"; 177 223 178 - $headers = get_headers($url); 179 - if ($headers !== false && strpos($headers[0], '200') !== false) { 180 - $response = file_get_contents($url); 181 - if ($response !== false) { 182 - $data = json_decode($response, true); 183 - if (isset($data['icons']) && is_array($data['icons']) && count($data['icons']) > 0) { 184 - $iconUrl = $data['icons'][0]['icon']; 185 - $httpsIconUrl = str_replace('http://', 'https://', $iconUrl); 186 - $imagick = new Imagick(); 224 + try { 225 + if (in_array("app-homebrew", array_column($issue['labels'], 'name'))) { 187 226 188 - $avifIconURL = "/home/{$serverUsername}/domains/fpps4.net/public_html/images/CUSA/{$cusaCode}.avif"; 189 - $result = null; 190 - if ($imagick->readImage($httpsIconUrl)) { 191 - $imageFormat = $imagick->getImageFormat(); 192 - if ($imageFormat == 'JPEG' || $imageFormat == 'PNG') { 193 - $imagick->setImageFormat('avif'); 194 - $imagick->setCompressionQuality(75); 195 - $imagick->setImageProperty('avif:effort', '10'); 196 - $imagick->setImageProperty('avif:speed', '8'); 197 - $imagick->thumbnailImage(128, 128, true); 198 - $imagick->setImageProperty('avif:strip', ''); 199 - // Compress and save the image 200 - if ($imagick->writeImage($avifIconURL)) { 201 - $result = $avifIconURL; 202 - } else { 203 - $result = null; 204 - } 227 + $query = "SELECT image FROM homebrews WHERE name = :name"; 228 + $statement = $homebrewDB->prepare($query); 229 + $statement->bindParam(':name', $cusaCode); 230 + $statement->execute(); 231 + $result = $statement->fetch(PDO::FETCH_ASSOC); 232 + //var_dump("image link: $result <br>"); 233 + //echo "image link: $result <br>" ; 234 + // if ($result !== false) { 235 + if (!empty($result)) { 236 + $iconUrl = $result['image']; 237 + //echo "Image link: $iconUrl<br>"; 238 + var_dump("image link: $iconUrl <br>"); 239 + $avifIconURL = "/home/{$serverUsername}/domains/fpps4.net/public_html/images/HOMEBREW/{$cusaCode}.avif"; 240 + $header = stream_context_create(["http" => ["header" => "User-Agent: $homebrewUseragent\r\n"]]); 241 + $httpsIconUrl = str_replace('http://', 'https://', $iconUrl); 242 + $imageData = file_get_contents($httpsIconUrl, false, $header); 205 243 } else { 206 - $result = null; 244 + echo "No record found for the given name.<br>"; 245 + throw new Exception(); 207 246 } 208 - } else { 209 - $result = null; 247 + // } else {throw new Exception();} 248 + } else { 249 + global $tmdbHash; 250 + $key = hex2bin($tmdbHash); 251 + $hashme = $cusaCode . '_00'; 252 + $hash = strtoupper(hash_hmac('sha1', $hashme, $key)); 253 + $url = "https://tmdb.np.dl.playstation.net/tmdb2/{$cusaCode}_00_{$hash}/{$cusaCode}_00.json"; 254 + $userAgent = 'Mozilla/5.0 (PlayStation; PlayStation 4/10.71) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Safari/605.1.15'; 255 + $PS4header = stream_context_create(["http" => ["header" => "User-Agent: $userAgent\r\n"]]); // ps4 useragent cuz im silly 256 + $headers = get_headers($url, false, $PS4header); 257 + if ($headers !== false && strpos($headers[0], '200') !== false) { 258 + $response = file_get_contents($url, false, $PS4header); 259 + if ($response !== false) { 260 + $data = json_decode($response, true); 261 + if (isset($data['icons']) && is_array($data['icons']) && count($data['icons']) > 0) { 262 + $iconUrl = $data['icons'][0]['icon']; 263 + $avifIconURL = "/home/{$serverUsername}/domains/fpps4.net/public_html/images/CUSA/{$cusaCode}.avif"; 264 + $httpsIconUrl = str_replace('http://', 'https://', $iconUrl); 265 + $imageData = file_get_contents($httpsIconUrl, false, $PS4header); 266 + } else {throw new Exception();} 267 + } else {throw new Exception();} 268 + } else {throw new Exception();} 269 + } 270 + 271 + 272 + $imagick = new Imagick(); 273 + if ($imagick->readImageBlob($imageData)) { 274 + $imageFormat = $imagick->getImageFormat(); 275 + if ($imageFormat == 'JPEG' || $imageFormat == 'PNG') { 276 + $imagick->setImageFormat('avif'); 277 + $imagick->setCompressionQuality(75); 278 + $imagick->setImageProperty('avif:effort', '10'); 279 + $imagick->setImageProperty('avif:speed', '8'); 280 + $imagick->thumbnailImage(128, 128, true); 281 + $imagick->setImageProperty('avif:strip', ''); 282 + $imagick->writeImage($avifIconURL); // save the image 210 283 } 211 - $imagick->clear(); 212 - $imagick->destroy(); 213 - return $result; 214 284 } 285 + $imagick->clear(); 286 + $imagick->destroy(); 287 + 288 + } catch (Exception $e) { 289 + echo "<p style='color: red;'>$cusaCode got an error while downloading, $e </p><br>"; 290 + $columnName = "code"; 291 + $insertQuery = "INSERT INTO GameSkips ($columnName) VALUES (:value1)"; 292 + $stmt = $conn->prepare($insertQuery); 293 + $stmt->bindParam(':value1', $cusaCode, PDO::PARAM_STR); 294 + if (!$stmt->execute()) { 295 + die("Error inserting issue: " . $stmt->errorInfo()[2]); 296 + } 215 297 } 216 - } 217 - // Write the skipped $cusaCode to the database 218 - $skippedCode = $conn->quote($cusaCode); 219 - $insertQuery = "INSERT INTO gameSkips (cusaCode) VALUES ($skippedCode)"; 220 - $conn->exec($insertQuery); 221 - return null; 222 298 } 223 299 //- Images logic 224 300 225 301 $gh_api_total = 0; 226 - $open_issues_count = get_open_issues_count($gh_api_total); 302 + $open_issues_count = get_open_issues_count(); 227 303 $total_pages = ceil($open_issues_count / 100); 228 304 $total_processed = 0; 229 305 $total_skipped = 0; ··· 231 307 $images_downloaded = 0; 232 308 $images_skiped = 0; 233 309 $homebrewProcessed = 0; 310 + $systemProcessed = 0; 311 + $ps2Processed = 0; 312 + $HB_images_downloaded = 0; 313 + $HB_images_skiped = 0; 234 314 235 315 for ($page = 1; $page <= $total_pages; $page++) { 236 316 $issues_data = get_open_issues($page); ··· 258 338 insert_issue($issue, $conn); 259 339 260 340 if (!file_exists($avifIconURL)) { // check for images 261 - $query = "SELECT cusaCode FROM GameSkips WHERE cusaCode = :cusaCode"; 341 + // ECHO "<br> DEBUG: I AM GETTING CHECKED. $cusaCode <br>"; 342 + $query = "SELECT code FROM GameSkips WHERE code = :code"; 262 343 $stmt = $conn->prepare($query); 263 - $stmt->bindParam(':cusaCode', $cusaCode, PDO::PARAM_STR); 344 + $stmt->bindParam(':code', $cusaCode, PDO::PARAM_STR); 264 345 $stmt->execute(); 346 + // ECHO "<br> DEBUG: I HAVE BEEN CHECKED. $cusaCode <br>"; 265 347 266 348 if ($stmt->rowCount() > 0) { 267 349 $images_skiped++; 268 350 continue; 351 + // ECHO "<br> DEBUG: I HAVE BEEN SKIPPED. $cusaCode <br>"; 269 352 } else { 270 - get_image($cusaCode, $conn, $serverUsername); // Download image 353 + get_image($cusaCode, $homebrewDB); // Download image 271 354 $images_downloaded++; 355 + // ECHO "<br> DEBUG: I HAVE BEEN DOWNLOADED. $cusaCode <br>"; 272 356 } 273 357 } else { 274 358 $images_skiped++; 275 359 } 276 360 361 + // HOMEBREW GAMES/APPS 277 362 } else if (in_array("app-homebrew", array_column($issue['labels'], 'name'))) { 363 + $hb_title = preg_replace('/\s-\s.*$/', '', $title); 364 + $hb_title = trim(explode('(Homebrew)', $hb_title)[0]); 365 + $hb_title = trim(explode('Homebrew', $hb_title)[0]); 366 + //$hb_title = trim(explode('Game', $hb_title)[0]); 367 + $hb_title = rtrim($hb_title, ' '); 368 + 369 + $query = "SELECT title FROM newIssues WHERE title = :title"; 370 + $stmt = $conn->prepare($query); 371 + $stmt->bindParam(':title', $hb_title, PDO::PARAM_STR); 372 + $stmt->execute(); 373 + $checkTitle = $stmt->fetchAll(PDO::FETCH_ASSOC); 374 + if (count($checkTitle) > 0) { 375 + $total_skipped++; 376 + continue; 377 + } 378 + 379 + if (!file_exists("/home/{$serverUsername}/domains/fpps4.net/public_html/images/HOMEBREW/{$hb_title}.avif")) { // check for images 380 + // $query = "SELECT cusaCode FROM GameSkips WHERE homeBrew = :homeBrew"; 381 + $query = "SELECT code FROM GameSkips WHERE code = :code"; 382 + $stmt = $conn->prepare($query); 383 + $stmt->bindParam(':code', $hb_title, PDO::PARAM_STR); 384 + $stmt->execute(); 385 + $check_result = $stmt->fetchAll(PDO::FETCH_ASSOC); 386 + 387 + if (count($check_result) > 0) { 388 + $HB_images_skiped++; 389 + // echo "$hb_title is skipped <br>"; 390 + } else { 391 + get_image($hb_title, $homebrewDB); // Download image 392 + $HB_images_downloaded++; 393 + // echo "$hb_title getting downloaded <br>"; 394 + } 395 + } else { 396 + $HB_images_skiped++; 397 + // echo "$hb_title exists <br>"; 398 + } 399 + 400 + insert_issue($issue, $conn); 401 + $total_processed++; 402 + $homebrewProcessed++; 403 + 404 + } else if (in_array("app-system-fw505", array_column($issue['labels'], 'name'))){ 278 405 $query = "SELECT title FROM newIssues WHERE title = :title"; 279 406 $stmt = $conn->prepare($query); 280 407 $stmt->bindParam(':title', $title, PDO::PARAM_STR); ··· 286 413 continue; 287 414 } 288 415 $total_processed++; 289 - $homebrewProcessed++; 416 + $systemProcessed++; 417 + insert_issue($issue, $conn); 418 + 419 + } else if (in_array("app-ps2game", array_column($issue['labels'], 'name'))){ 420 + $query = "SELECT title FROM newIssues WHERE title = :title"; 421 + $stmt = $conn->prepare($query); 422 + $stmt->bindParam(':title', $title, PDO::PARAM_STR); 423 + $stmt->execute(); 424 + $checkTitle = $stmt->fetchAll(PDO::FETCH_ASSOC); 425 + 426 + if (count($checkTitle) > 0) { 427 + $total_skipped++; 428 + continue; 429 + } 430 + $total_processed++; 431 + $ps2Processed++; 290 432 insert_issue($issue, $conn); 291 433 } else { 292 434 $CUSA_total_skipped++; 435 + //echo "<a href='https://github.com/red-prig/fpps4-game-compatibility/issues/" . $issue['number'] . "' target='_blank'>https://github.com/red-prig/fpps4-game-compatibility/issues/" . $issue['number'] . "</a><br>"; 293 436 continue; 294 437 } 295 438 } ··· 337 480 print "<br>Total issues without CUSA: " . $CUSA_total_skipped; 338 481 print "<br>Total issues processed: " . $total_processed; 339 482 print "<br>Homebrew's processed: " . $homebrewProcessed; 483 + print "<br>System Apps processed: " . $systemProcessed; 484 + print "<br>PS2 Games processed: " . $ps2Processed; 340 485 print "<br>Total duplicates: " . $total_skipped; 341 486 print "<br>Total images downloaded: " . $images_downloaded; 342 487 print "<br>Total images skipped: " . $images_skiped; 488 + print "<br>Total homebrew images downloaded: " . $HB_images_downloaded; 489 + print "<br>Total homebrew images skipped: " . $HB_images_skiped; 343 490 print "<br>Total github api requests: " . $gh_api_total; 344 491 345 492 // Fake 404 page vv