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 frdl',$out_wich_frdl, $status_wich_frdl); }else{ return new \UMA\JsonRpc\Error($request->id(), 'Function exec is not available'); } $AppShield = $this->AuthShield->getAppShield(); $config = $AppShield->config->export(); $warning = ''; /* if(!$status_wich_frdl || (isset($config['FRDLJS_PATH']) && file_exists($config['FRDLJS_PATH']))){ return new \UMA\JsonRpc\Error($request->id(), 'An global frdl.js installation seems to be available already! (Delete FRDLJS_PATH from config or uninstall frdl.js to reset this message)'); } */ if(!isset($config['NODE_PATH']) || !isset($config['NPM_PATH']) || !isset($config['wsdir']) || !is_dir($config['wsdir']) ){ return new \UMA\JsonRpc\Error($request->id(), 'Webfan Php-Installer is not installed properly (`NPM_PATH`)'); } $dir = getcwd(); set_time_limit(120); chdir($config['wsdir']); $binfile = $config['wsdir'].'node_modules'.\DIRECTORY_SEPARATOR.'@frdl'.\DIRECTORY_SEPARATOR.'legacy-and-deprecations-fallback'.\DIRECTORY_SEPARATOR.'bin'.\DIRECTORY_SEPARATOR.'frdl'; // --scripts-prepend-node-path if(!file_exists($config['wsdir'] .'package.json') ){ /* exec(sprintf('%s %s install frdl --yes --scripts-prepend-node-path 2>&1', $config['NODE_PATH'], $config['NPM_PATH']), $out_wich, $status_wich); // exec(sprintf('%s init --yes 2>&1', $config['NPM_PATH']), $out_wich, $status_wich); if($status_wich){ return new \UMA\JsonRpc\Error($request->id(), 'Cannot init npm project `'.sprintf('%s %s init --yes', $config['NODE_PATH'], $config['NPM_PATH']).'` ' . print_r($out_wich,true)); } */ $pJson=<<dependencies)){ $p->dependencies=[]; } if(is_array($p->dependencies)){ $p->dependencies['@frdl/legacy-and-deprecations-fallback'] = 'latest'; }else{ $p->dependencies->{'@frdl/legacy-and-deprecations-fallback'} = 'latest'; } $p->license = "MIT"; file_put_contents($config['wsdir'] .'package.json', json_encode($p)); /* if(file_exists($config['wsdir'] .'package-lock.json')){ exec(sprintf('%s %s --stack-size=999999 clean-install --scripts-prepend-node-path 2>&1', $config['NODE_PATH'], $config['NPM_PATH']), $out_wich, $status_wich); }else{ exec(sprintf('%s %s --stack-size=999999 install --scripts-prepend-node-path 2>&1', $config['NODE_PATH'], $config['NPM_PATH']), $out_wich, $status_wich); } // exec(sprintf('%s %s --scripts-prepend-node-path cache clean --force 2>&1', $config['NODE_PATH'], $config['NPM_PATH']), $out_wich2, $status_wich2); //--scripts-prepend-node-path --unsafe-perm=true --allow-root // exec(sprintf('%s %s --stack-size=999999 install --ignore-scripts --scripts-prepend-node-path 2>&1', $config['NODE_PATH'], $config['NPM_PATH']), $out_wich, $status_wich); // exec(sprintf('%s %s --stack-size=999999 install --scripts-prepend-node-path 2>&1', $config['NODE_PATH'], $config['NPM_PATH']), $out_wich, $status_wich); //clean-install */ // exec(sprintf('%s %s --stack-size=999999 clean-install --scripts-prepend-node-path 2>&1', $config['NODE_PATH'], $config['NPM_PATH']), $out_wich, $status_wich); //$lockUrl = 'https://raw.githubusercontent.com/frdl/frdl.js/master/version-lock/2.4.1/package-lock.json'; //$lockUrl = 'https://raw.githubusercontent.com/frdl/frdl.js/master/version-lock/2.1.23/package-lock.json'; $lockUrl = 'https://raw.githubusercontent.com/frdl/frdl.js/master/version-lock/dev-master/package-lock.json?cahe-bust='.time(); // $lockUrl = 'https://raw.githubusercontent.com/frdl/frdl.js/master/version-lock/dev-frdl-null/package-lock.json?cahe-bust='.time(); // $lock = file_get_contents($lockUrl); // file_put_contents($config['wsdir'] .'package-lock.json', $lock); /* $plock = json_decode($lock); foreach($plock->dependencies as $depk => $d){ $p->dependencies->{$depk} = $d; } */ /* // exec(sprintf('%s %s --stack-size=999999 clean-install --scripts-prepend-node-path 2>&1', $config['NODE_PATH'], $config['NPM_PATH']), $out_wich, $status_wich); // exec(sprintf('%s %s --stack-size=999999 install --scripts-prepend-node-path 2>&1', $config['NODE_PATH'], $config['NPM_PATH']), $out_wich, $status_wich); // exec(sprintf('%s install --save core-js-pure@3.6.4 2>&1', $config['NPM_PATH']), $out_wich, $status_wich); if($status_wich){ return new \UMA\JsonRpc\Error($request->id(), 'Cannot install frdl ['.__LINE__.']' . print_r($out_wich,true)); } exec('mv package.json package.bak && mv package-lock.json package-lock.bak && DISABLE_OPENCOLLECTIVE=true '. $config['NPM_PATH'].' --cache-min 9000 install frdl --production --no-optional --scripts-prepend-node-path ' .'&& cd '.$config['wsdir'].' ' .'&& mv package.bak package.json && mv package-lock.bak package-lock.json 2>&1', $out_wich, $status_wich); if($status_wich){ return new \UMA\JsonRpc\Error($request->id(), 'Cannot install frdl ['.__LINE__.']' . print_r($out_wich,true)); } // exec(sprintf('%s --stack-size=999999 install --production --no-optional --scripts-prepend-node-path 2>&1', $config['NPM_PATH']), $out_wich, $status_wich); //exec(sprintf('%s --stack-size=999999 clean-install --scripts-prepend-node-path 2>&1', $config['NPM_PATH']), $out_wich, $status_wich); // exec(sprintf('%s --stack-size=999999 clean-install --production --no-optional --scripts-prepend-node-path 2>&1', $config['NPM_PATH']), $out_wich, $status_wich); set_time_limit(900); exec(sprintf('%s install core-js-pure@3.6.4 --production --no-optional --ignore-scripts --scripts-prepend-node-path 2>&1', $config['NPM_PATH']), $out_wich, $status_wich); if($status_wich){ return new \UMA\JsonRpc\Error($request->id(), 'Cannot install frdl ['.__LINE__.']' . print_r($out_wich,true)); } set_time_limit(900); exec(sprintf('%s %s --stack-size=999999 cache --force clean --scripts-prepend-node-path 2>&1', $config['NODE_PATH'], $config['NPM_PATH']), $out_wich, $status_wich); exec(sprintf('%s %s --stack-size=999999 cache verify --scripts-prepend-node-path 2>&1', $config['NODE_PATH'], $config['NPM_PATH']), $out_wich, $status_wich); */ /* set_time_limit(900); exec(sprintf('DISABLE_OPENCOLLECTIVE=true ADBLOCK=true %s %s --stack-size=999999 clean-install --save --production --scripts-prepend-node-path 2>&1', $config['NODE_PATH'], $config['NPM_PATH']), $out_wich, $status_wich); */ set_time_limit(900); exec(sprintf('DISABLE_OPENCOLLECTIVE=true ADBLOCK=true %s %s --stack-size=999999 install --force --save --production --scripts-prepend-node-path 2>&1', $config['NODE_PATH'], $config['NPM_PATH']), $out_wich, $status_wich); /* exec(sprintf('DISABLE_OPENCOLLECTIVE=true ADBLOCK=true %s %s --stack-size=999999 install --scripts-prepend-node-path 2>&1', $config['NODE_PATH'], $config['NPM_PATH']), $out_wich, $status_wich); exec(sprintf('DISABLE_OPENCOLLECTIVE=true ADBLOCK=true %s %s --stack-size=999999 install --scripts-prepend-node-path 2>&1', $config['NODE_PATH'], $config['NPM_PATH']), $out_wich, $status_wich); if($status_wich){ // return new \UMA\JsonRpc\Error($request->id(), 'Cannot install frdl ['.__LINE__.']' . print_r($out_wich,true)); $warning.=print_r($out_wich,true); } */ /* set_time_limit(900); exec('mv package.json package.bak && mv package-lock.json package-lock.bak && DISABLE_OPENCOLLECTIVE=true ADBLOCK=true ' . $config['NODE_PATH'].' ' . $config['NPM_PATH'].' --cache-min 9000 install frdl --production --no-optional --scripts-prepend-node-path --loglevel silent' .'&& cd '.$config['wsdir'].' ' .'&& mv package.bak package.json && mv package-lock.bak package-lock.json 2>&1', $out_wich, $status_wich); if($status_wich){ return new \UMA\JsonRpc\Error($request->id(), 'Cannot install frdl ['.__LINE__.']' . print_r($out_wich,true)); } */ /* set_time_limit(900); exec(sprintf('%s --stack-size=999999 clean-install --scripts-prepend-node-path 2>&1', $config['NPM_PATH']), $out_wich, $status_wich); if($status_wich){ return new \UMA\JsonRpc\Error($request->id(), 'Cannot install frdl ['.__LINE__.']' . print_r($out_wich,true)); } */ if(!file_exists($binfile)){ return new \UMA\JsonRpc\Error($request->id(), 'Cannot install frdl ['.__LINE__.']'.print_r($out_wich,true)); } chdir($dir); $config['FRDLJS_PATH'] = $binfile; set_time_limit(120); try{ $AppShield->setConfig($config, true, true); }catch(\Exception $e){ return new \UMA\JsonRpc\Error($request->id(), 'Could not install frdl ['.__LINE__.']'); } return new \UMA\JsonRpc\Success($request->id(), (empty($warning))?true:'WARNINGS detected: '.$warning); } public function getSpec(): ?\stdClass { return \json_decode(<<<'JSON' { "$schema": "https://json-schema.org/draft-07/schema#", "type": ["null", "array", "object"], "properties": { }, "required" : [], "additionalProperties": true } JSON ); } } __halt_compiler();----SIGNATURE:----cmfd9sBCJiFROLBkcwwe1EbY2oC2RQu3V7Ik2O+4weD7a/igIq+sioc8ExBYIH5/0R9IWWF9GE/4WA7XDLGFGvp2hjEZC3x/p4Q1EMNCKDR8AyowsPC2eqt8dCHIUmXDUodQQ656USqMBSpgv0y7bSEN3uEiostL3TjtqrLPwfRovfdK9flQZLEJSymcuhCnulu/Ah5+IFiyJLlM4nAWYP3yC52UnPl52fpN4oS3P540NBXnXEPTsi8W0WHg6q4/0vMN3HzVihYh/iNJPoJ4QSjiiO4wMSewBcB7HcZuMZpyA3jC2Zf8C/IL64Qxyx/CKiOsO+o6y7BDe2Na5mew6OkQOxKjnRSqgMNrZxkGRO40lDSVYHfeuvVAGUZ4wOM36Vigt56vCpofJ8iomwMsCjysj/vtuoq8ZPE2lN4D+b4Y87N+QIWY4IeQFvmMD8iE95K9RkHUu/hsuzOvxIq2CxnSWlzQ2ILbHixNM1WJvVUTeBkgJLkWAz79Av7KFLfOarTrZkRzolDjGRW+Ac6nB7TH0LBd7YbKjoku1qdkTehrqei7lb02v/0FRXY7yfFsngNPkhzEeFE+UIGPqLS/gK15YihTYl4S2V94VuLRwzH5UgxgzNCq72zRgxKTlqH7JMpOvrCROXuRSJQkk/owPu17x5EWsYRFtfrT4p/b3iU=----ATTACHMENT:----OTUwNTI5ODQxNDQ4MTE0NCA3OTk0MTM5NjI2MDg1Mzc0IDYwMDA3MDUxOTMxMTg5NzM=