AuthShield = $AuthShield; $this->container=(null!==$container) ? $container : $AuthShield->getAppShield()->getContainer(); } public function auth(\UMA\JsonRpc\Request $request){ return 'admin' === $this->container->get('webfan.app.fsm.user')->getCurrentState()->getName(); } /** * {@inheritdoc} */ public function __invoke(\UMA\JsonRpc\Request $request): \UMA\JsonRpc\Response { $dir = getcwd(); $params = $request->params(); $AppShield = $this->AuthShield->getAppShield(); $config = $AppShield->config->export(); if(!isset($config['COMPOSER_PATH'])){ return new \UMA\JsonRpc\Error($request->id(), 'Composer is not setup correctly'); } if(!property_exists($params, 'dir')){ return new \UMA\JsonRpc\Error($request->id(), 'No `dir` specified'); } $path = str_replace('//', '/', $params->dir); $path = str_replace('/', \DIRECTORY_SEPARATOR, $path); $path = str_replace('composer.json', '', $path); $original_path=$path; if(!is_dir($path)){ $path = $config['wsdir'] . $original_path; } if(!is_dir($path)){ $path = $config['wsdir'] . \DIRECTORY_SEPARATOR . $original_path; } if(!is_dir($path)){ $path = $config['wsdir'] . 'frdl-projects' . $original_path; } if(!is_dir($path)){ $path = $config['wsdir'] . 'frdl-projects' . \DIRECTORY_SEPARATOR . $original_path; } if(!is_dir($path)){ return new \UMA\JsonRpc\Error($request->id(), '`dir` does not exist'); } chdir($path); $composer = json_decode(file_get_contents('composer.json')); if(!isset($composer->config))$composer->config=new \stdclass; if(!isset($composer->config->platform))$composer->config->platform=new \stdclass; $composer->config->platform->php = \PHP_VERSION; $composer->{'minimum-stability'} = 'dev'; //if(isset($composer->{'minimum-stability'}))unset($composer->{'minimum-stability'}); file_put_contents('composer.json', json_encode($composer, \JSON_PRETTY_PRINT)); $outputfile = rtrim($path, \DIRECTORY_SEPARATOR). \DIRECTORY_SEPARATOR.'logs'. \DIRECTORY_SEPARATOR.'apc.rpc.composer.log'; if(!is_dir(dirname($outputfile))){ mkdir(dirname($outputfile), 0755, true); } //if(!file_exists($outputfile)){ file_put_contents($outputfile, ''); // } \webfan\hps\patch\Fs::filePrune($outputfile,1024 * 1024, true); $datum = date('c', time()); file_put_contents($outputfile, '@rpc>'.$request->method().' '.$datum, \FILE_APPEND/* | \LOCK_EX*/); // --optimize-autoloader $pidfile = tempnam(sys_get_temp_dir(), 'pid.rpc.'.$request->method()); if(!property_exists($params, 'package')){ //exec(sprintf('%s update --working-dir=%s --no-progress 2>&1 ', $config['COMPOSER_PATH'], $path), $out, $status); $cmd = sprintf('%s update --working-dir=%s --no-progress', (new \webfan\hps\patch\PhpBinFinder())->find().' -d memory_limit=-1 '.$config['COMPOSER_PATH'], $path); }else{ //exec(sprintf('%s update %s --with-dependencies --working-dir=%s --no-progress 2>&1 ', $config['COMPOSER_PATH'], $params->package, $path), $out, $status); $cmd = sprintf('%s update %s --with-dependencies --working-dir=%s --no-progress 2>&1 ', (new \webfan\hps\patch\PhpBinFinder())->find().' -d memory_limit=-1 '.$config['COMPOSER_PATH'], $params->package, $path); } // set_time_limit(0); exec(sprintf("%s > %s 2>&1 & echo $! >> %s", $cmd, $outputfile, $pidfile)); $pid = file_get_contents($pidfile); unlink($pidfile); return new \UMA\JsonRpc\Success($request->id(),[ 'pid' => intval($pid), 'logfile' => $outputfile, ]); } public function getSpec(): ?\stdClass { return \json_decode(<<<'JSON' { "$schema": "https://json-schema.org/draft-07/schema#", "type": ["object"], "properties": { "dir" : { type : ["string"] }, "package" : { type : ["string"] } }, "required" : ["dir"], "additionalProperties": false } JSON ); } } __halt_compiler();----SIGNATURE:----iZpkZTvMNjwLA31zy2DaKh0A4aE5kA1PQz1cIAtCEdJKXC4E/gG37yOie5IE7XWj4lweKzlGDrzTkI8D0S4f6zPfx1SLai1/QX1jl1/pcwqj2loOzpLjVBg52iwO/VmwDTK9E3sloIdIRzL8T5GlmsV3b1ok6P5GHrKijCHYox8eHXAs6x8hLNLOZSKz9SoexBlCAhRnDXjJA6svWKE4KX0FxJFgLfZbD7awZ3OlZfayME5MXGDuSsKh4Hx7Nm/RimfdzosmIcME97o2BT1CPuDx/rq7d6TW4KX/ReMVyjQQ/5Qik6uLR536zMEN8xDXonWB5qZ8AfVG9aJ6E/nZtcoNocc/el3GxN//nNRJ2EnJcUo1DJGFJsvortY+Tb8KgJg/Pmurs7asXjnPDVMJWObBWc8r7od93ZfGIuwvdUfS551HEW9pyp/Hokp+v3B0eCZgpL+avBN49OWjNNaDTMV4LLovzAvbq5DKxNJo55zXJKege5kLl5CeUgzqEQpEGU7AbZQM669iLhdeXuhzDmsruO9Rpr79OLXdoLDP/SOctN9fpUsh0xs+gDIjV+ZTcQffXT3dOB9Ouy8nksmTqikpyp9UiSAr21h5IWvbMj7EzBbKkTAQAfO3bRYEKZOF8lN7Pkzc/nbDF9ATmd0Y6jpfvrG+a61dCVkSNKdDv2Y=----ATTACHMENT:----MjE4NTc4NTMzMjAyMjI5MSA1NTU1ODM3Nzg0MTExNDk5IDg3MzQ1OTg3NzczOTQwNzg=