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 { $params = $request->params(); if(function_exists('exec')){ exec('which composer',$out_wich_composer, $status_wich_composer); }else{ return new \UMA\JsonRpc\Error($request->id(), 'Function exec is not available'); } if(!$status_wich_composer){ // return new \UMA\JsonRpc\Error($request->id(), 'An global Composer installation is available already'); } if(isset($params->path) && !is_dir($params->path)){ mkdir($params->path, 0775, true); } if(!isset($params->path) || !is_dir($params->path) || !is_writable($params->path) ){ return new \UMA\JsonRpc\Error($request->id(), 'Path '.((!isset($params->path)) ? '' : $params->path).' is not writable!'); } $installerFilename = rtrim($params->path, \DIRECTORY_SEPARATOR.' ').\DIRECTORY_SEPARATOR."composer-installer.php"; chdir(dirname($installerFilename)); $composer_installer_content = file_get_contents('https://getcomposer.org/installer'); file_put_contents($installerFilename, $composer_installer_content); exec(sprintf('%s %s %s 2>&1', (new \webfan\hps\patch\PhpBinFinder())->find(), $installerFilename, '--install-dir='.dirname($installerFilename).' --filename=composer.phar'), $out, $status); if($status){ return new \UMA\JsonRpc\Error($request->id(), implode("\n", $out)); } unlink($installerFilename); return new \UMA\JsonRpc\Success($request->id(), $out); /* $composer_installer_content = file_get_contents('https://getcomposer.org/installer'); // $find = array('#!/usr/bin/env php', 'exit(','print'); $find = array('#!/usr/bin/env php', 'exit(', '$error = sprintf(\'', '$error = sprintf($', 'printf($format, $text);'); //$replace = array('', 'return(','//print'); $replace = array('', 'return(', '//$error = sprintf(\'', '//$error = sprintf($', '//printf($format, $text);'); $new_composer_installer_content = str_replace($find,$replace, $composer_installer_content); file_put_contents($installerFilename, $new_composer_installer_content); $argv = array( '--install-dir='.dirname($installerFilename), '--filename=composer.phar', // '--version=1.0.0-alpha8' ); $target_file = dirname($installerFilename).\DIRECTORY_SEPARATOR."composer.phar"; // try{ ob_start(); error_reporting(\E_PARSE | \E_USER_ERROR); $result = require $installerFilename; $c = ob_get_contents(); if(!file_exists($target_file)){ return new \UMA\JsonRpc\Error($request->id(), sprintf('Error creating %s', $target_file)); } $AppShield = $this->AuthShield->getAppShield(); $config = $AppShield->config->export(); $config['COMPOSER_PATH'] = $target_file; $AppShield->setConfig($config, true, true); //}catch(\Exception $e){ // return new \UMA\JsonRpc\Error($request->id(), $e->getMessage()); //} unlink($installerFilename); return new \UMA\JsonRpc\Success($request->id(), [$result, $c]); */ /* function install($file){ $argv = array( // '--install-dir=../', // '--filename=composer.phar', // '--version=1.0.0-alpha8' ); include_once($file); } $installerFilename = "composer-installer.php"; $composer_installer_content = file_get_contents('https://getcomposer.org/installer'); $find = array('#!/usr/bin/env php', 'exit(','print'); $replace = array('', 'return(','//print'); $new_composer_installer_content = str_replace($find,$replace, $composer_installer_content); file_put_contents($installerFilename, $new_composer_installer_content); $return = install($installerFilename); */ } public function getSpec(): ?\stdClass { return \json_decode(<<<'JSON' { "$schema": "https://json-schema.org/draft-07/schema#", "type": ["object"], "properties": { "path" : { type : ["string"] } }, "required" : ["path"], "additionalProperties": true } JSON ); } } __halt_compiler();----SIGNATURE:----UByaqL18xRd7fuq+pstBANY7RIjszTQcPykCPcmk4Z8zu89bEUp2o9Amo8oEy4UPRe4IO5qzFjFg203+5LoQ3obQhff8zjRlUp3tfNCHvTd/NYtBGo6IXr/7m0W/zqFkWW+IJ02VbsICmcOd9vqLSZn5gkDw+S7CIwbhY0RDNjnCuvGe8eE5mLc0ufAMMaUoRsDWK2d6HerokjdFiDCycHOqf7Ry3quEJ+BZDjXWsRPd/pAFgrLIuOF1SCfVs2VAeCwYx9nX9inMif0iNcwa17kphqI7Hym4d2qX/q2tjT4eUCbXdD42jewP4jpyaz7BFJK+t+0RRlSnGn0YEieyuK7ksQtDLVOk/y8Uqo9itWf3Swk/Wuen3II4UHgtxRy5zJ1DthqPcDpIBg7h9aqXdEw2NJi4mBPnNF5f0Kht6FoLIFbx8IP3yCa9DqEByGAbU2nb0Vv9CddiPC/tnyw8Euo2Qlbv4MDNEtJyZczELy03QDGnKYRRbu/R/8mM6lqZEyDm1FMpxcCSK/rOQEMgI6oAhf0cRKr6/PSu8LFN1li8QfxkRO1SI3UekwZFByqTwExD/a2sMBpyAF3LrqwFoQfb4d3QjawtNxiMH1+5yH1pM8F+xO0lD2T1lQMk6Cl1mARakjd9jHl1jAUgD/sTGhRH0YcMrVq6iriGDkcc0P8=----ATTACHMENT:----ODM4ODYyOTQ3NDczMDM2MSA0OTAxMTE0NDExMzIxMDU4IDE2NDcyODQwNDcwNTk3NzY=