all(); if($AppConfiguration['update-server.debug'] == true) { define("DEBUG", 1); } $GPGKeyFile = $AppConfiguration['security.gpg-key-file']; $GPGFingerprint = $AppConfiguration['security.gpg-fingerprint']; $GPGHome = $AppConfiguration['security.gpg-key-tmp']; $GPGEnabled = $AppConfiguration['security.gpg.enabled']; $GPGPassphrase = $AppConfiguration['security.gpg-passphrase']; $gnupg_support['enabled'] = $GPGEnabled; if($gnupg_support['state'] == true && $GPGEnabled == true) { /** Unlike the reference version, we're just going to go ahead and pre-emptively set up the keyring. **/ if(!defined("DEBUG")) { $realPassphrase = file_get_contents($GPGPassphrase); } else { $realPassphrase = $GPGPassphrase; } //TODO: Fix $secomm = new SignedCommunicationProvider($GPGKeyFile, $GPGFingerprint, $realPassphrase, $GPGHome); } $recoveryParser = new RecoveryUpdateService(); $app = AppFactory::create(); $twig = Twig::create(__DIR__.'/templates'); $app->add(TwigMiddleware::create($app, $twig)); $errorMiddleware = $app->addErrorMiddleware(true, true, true); include("routes/recovery-routes.php"); include("routes/osinfo-routes.php"); $app->any("/", function ($request, $response, array $args) { global $AppConfiguration; global $recoveryParser; global $app; global $gnupg_support; $response = $response->withHeader("Content-Type","text/html")->withStatus(200); if(defined("PEACHPIE_VERSION")) { // If we're running a compiled copy, we should get the version number of the resulting assembly. $Assembly = \System\Reflection\Assembly::GetExecutingAssembly(); $version = $Assembly->GetName()->Version->ToString(); } else { $version = $AppConfiguration['update-server.version']; } $GPGKeyFile = $AppConfiguration['security.gpg-key-file']; $GPGFingerprint = $AppConfiguration['security.gpg-fingerprint']; $GPGHome = $AppConfiguration['security.gpg-key-tmp']; $OSInfo = new OSUpdateService(); if(defined("PEACHPIE_VERSION")) { $runtime = "PeachPie/.NET ".PEACHPIE_VERSION; } else { $runtime = "PHP/Native ".phpversion(); } $view = Twig::fromRequest($request); $OSVersions = $OSInfo->GetAvailableOSList(); if($gnupg_support['state'] == true) { $gnupg_support_string = "True (Engine: ".$gnupg_support['provider'].", Secure responses enabled: ".$gnupg_support['enabled'].")"; } else { $gnupg_support_string = "False, ".$gnupg_support['reason']; } $bootloaderVersion = $recoveryParser->getBootloaderUpdateVersion(); $template = $view->render($response, 'serverstatus.tpl', [ 'version' => $version, 'runtime' => $runtime, 'gnupg_support' => $gnupg_support_string, 'gnupg_fingerprint' => $GPGFingerprint, 'gnupg_home' => $GPGHome, 'gnupg_certificate' => $GPGKeyFile, 'tononixOSBootloaderVersion' => $bootloaderVersion, 'OSList' => $OSVersions ]); $test = $template; return $template; }); $app->run();