add pkg2zip

This commit is contained in:
olebeck 2024-05-02 13:20:26 +02:00
parent 1a9fda817b
commit 41b7efe9f3
5 changed files with 61 additions and 22 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "php_pkg"]
path = php_pkg
url = https://silica.codes/olebeck/php_pkg

View File

@ -29,7 +29,7 @@ function update_rifs()
}
}
update_rifs();
/*
if(strcmp($_SERVER['HTTP_HOST'],"psmreborn.com") !== 0)
{
if(strcmp($_SERVER['HTTP_HOST'],"psm.cbps.xyz") !== 0)
@ -38,6 +38,7 @@ if(strcmp($_SERVER['HTTP_HOST'],"psmreborn.com") !== 0)
die("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n<html><head>\r\n<title>403 Forbidden</title>\r\n</head><body>\r\n<h1>Forbidden</h1>\r\n<p>You don't have permission to access this resource.</p>\r\n<hr>\r\n<address>Apache/2.4.41 (Ubuntu) Server at ".$_SERVER['HTTP_HOST']." Port 80</address>\r\n</body></html>");
}
}
*/
function printGenreList(SimpleXMLElement $xml)
{

View File

@ -3,6 +3,17 @@ include("header.php");
?>
<?php
function getZRifKey($zrif) {
$rif_dict = zlib_decode(base64_decode("eNpjYBgFo2AU0AsYAIElGt8MRJiDCAsw3xhEmIAIU4N4AwNdRxcXZ3+/EJCAkW6Ac7C7ARwYgviuQAaIdoPSzlDaBUo7QmknIM3ACIZM78+u7kx3VWYEAGJ9HV0="));
$ctx = inflate_init(ZLIB_ENCODING_DEFLATE, array(
"dictionary" => $rif_dict,
"window" => 10,
));
$rifz = base64_decode($zrif);
$rif = inflate_add($ctx, $rifz);
return bin2hex(substr($rif, 0x120, 0x10));
}
function getSdkVersion(SimpleXMLElement $xml)
{
if(isset($xml->attributes()->sdk_version)) {
@ -66,9 +77,6 @@ include("header.php");
$zrifinfo = getZRIF($game);
$zrifPendingInfo = getPendingZRIF($game);
$pkgSony = getPKG($game);
$simulatorZip = "decrypted-files/".$game.".zip";
$verXML = simplexml_load_file('gameinfo/' . $game . "/version.xml", 'SimpleXMLElement', LIBXML_NOENT);
$latestVersion = (string)($verXML->appVersion);
$pkgReborn = "/pkg/".$game."_00/".$latestVersion."/".$game."_00.pkg";
@ -77,6 +85,13 @@ include("header.php");
$description = $metadataXML->localizedMetadataList->children();
$screenshot = $metadataXML->screenShotList->screenShot;
$isplayable = "";
$rifKey = null;
if($zrifinfo != "MISSING") {
$rifKey = getZRifKey($zrifinfo);
}
$simulatorZip = '/pkg2zip.php?id='.$game.'&ver='.$latestVersion.'&key='.$rifKey;
if($zrifinfo == "MISSING" && $zrifPendingInfo == "MISSING")
{
@ -132,24 +147,16 @@ include("header.php");
<a href="<?php echo $pkgReborn ?>" class="nostyle">PKG (PSMReborn Server)</a>
</div>
<?php
if($zrifinfo == "MISSING"){
?><div class="button-disabled" id="fake-rif">NoPsmDrm License</div>
<?php
} else {
?><div class="button-enabled" id="fake-rif" onclick="convert2('<?php echo $zrifinfo ?>')">
<a class="nostyle" onclick="convert2('<?php echo $zrifinfo ?>')">NoPsmDrm License</a>
</div>
<?php } ?>
<?php
if(file_exists($simulatorZip)) {
?><div class="button-enabled" onclick="open_url('<?php echo $simulatorZip ?>')">
<a href="<?php echo $simulatorZip ?>" class="nostyle">Decrypted Files (For Simulator)</a>
</div>
<?php
} else {
?><div class="button-disabled">Decrypted Files (For Simulator)</div>
<?php if($zrifinfo == "MISSING"){ ?>
<div class="button-disabled" id="fake-rif">NoPsmDrm License</div>
<div class="button-disabled">Decrypted Files (For Simulator)</div>
<?php } else { ?>
<div class="button-enabled" id="fake-rif" onclick="convert2('<?php echo $zrifinfo ?>')">
<a class="nostyle" onclick="convert2('<?php echo $zrifinfo ?>')">NoPsmDrm License</a>
</div>
<div class="button-enabled" onclick="open_url('<?php echo $simulatorZip ?>')">
<a href="<?php echo $simulatorZip ?>" class="nostyle">Decrypted Files (For Simulator)</a>
</div>
<?php } ?>
<select onchange="pkg_change_version()" class="version-select"><?php

1
php_pkg Submodule

@ -0,0 +1 @@
Subproject commit cadfc7808df02db07334c9dd8b92ea22b39d482f

27
pkg2zip.php Normal file
View File

@ -0,0 +1,27 @@
<?php
require_once "php_pkg/pkg2zip.php";
function addPsmFiles($zip) {
$zip->AddDirectory("Documents");
$zip->AddDirectory("System");
$zip->AddDirectory("Temp");
$zip->AddFileFromString("RunInSimulator.bat", '"%SCE_PSM_SDK%\target\win32\psm.exe" "%CD%\Application\app.exe"');
}
if(!(isset($_GET["id"]) && isset($_GET["ver"]) && isset($_GET["key"]))) {
echo("missing parameters");
die();
}
$id = str_replace("/", "", $_GET["id"]);
$ver = str_replace("/", "", $_GET["ver"]);
$key = hex2bin($_GET["key"]);
$f = fopen('./pkg/'.$id.'_00/'.$ver.'/'.$id.'_00.pkg', 'rb');
if(!$f) {
echo("cant find pkg");
die();
}
pkg2zip($f, $id, $key, 'addPsmFiles');
fclose($f);