95 lines
1.5 KiB
PHP
95 lines
1.5 KiB
PHP
<?php
|
|
function update_rifs()
|
|
{
|
|
$npsTime = filemtime("NpsPsm.tsv");
|
|
|
|
|
|
if(time() > $npsTime + 86400)
|
|
{
|
|
rename("NpsPsm.tsv","nps-backup/NpsPsm_".strval($npsTime).".tsv");
|
|
file_put_contents("NpsPsm.tsv", file_get_contents("http://nopaystation.com/tsv/PSM_GAMES.tsv"));
|
|
}
|
|
}
|
|
update_rifs();
|
|
|
|
if($_SERVER['HTTP_HOST'] !== "psmreborn.com")
|
|
{
|
|
die("Invalid request!");
|
|
}
|
|
|
|
function getTitle(string $game)
|
|
{
|
|
$xml = simplexml_load_file('gameinfo/' . $game . "/app.xml", 'SimpleXMLElement', LIBXML_NOENT);
|
|
$title = $xml->name->localized_item[0]->attributes()->value;
|
|
unset($xml);
|
|
return $title;
|
|
}
|
|
|
|
function getPlayableList()
|
|
{
|
|
$playable_list = (array)null;
|
|
$delimiter = "\t";
|
|
$fp = fopen("NpsPsm.tsv", 'r');
|
|
while (!feof($fp))
|
|
{
|
|
$line = fgets($fp, 2048);
|
|
$data = str_getcsv($line, $delimiter);
|
|
$playable = 0;
|
|
if($data[4] != "MISSING")
|
|
{
|
|
$playable = 1;
|
|
}
|
|
$playable_list[$data[0]] = $playable;
|
|
|
|
|
|
}
|
|
fclose($fp);
|
|
return $playable_list;
|
|
}
|
|
|
|
|
|
|
|
function getZRIF(string $titleid)
|
|
{
|
|
$delimiter = "\t";
|
|
|
|
$fp = fopen("NpsPsm.tsv", 'r');
|
|
|
|
while ( !feof($fp) )
|
|
{
|
|
$line = fgets($fp, 2048);
|
|
|
|
$data = str_getcsv($line, $delimiter);
|
|
|
|
if($data[0] == $titleid)
|
|
{
|
|
return($data[4]);
|
|
}
|
|
}
|
|
|
|
fclose($fp);
|
|
}
|
|
|
|
function getPKG(string $titleid)
|
|
{
|
|
$delimiter = "\t";
|
|
|
|
$fp = fopen("NpsPsm.tsv", 'r');
|
|
|
|
while ( !feof($fp) )
|
|
{
|
|
$line = fgets($fp, 2048);
|
|
|
|
$data = str_getcsv($line, $delimiter);
|
|
|
|
if($data[0] == $titleid)
|
|
{
|
|
return($data[3]);
|
|
}
|
|
}
|
|
|
|
fclose($fp);
|
|
}
|
|
|
|
?>
|