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:----q9s9L31Fb6CqxQE5lrEauYQFnbEHjrwWBi4JmgfiH4D6utNUU1KfqZ0LEHQKwA/kez2dAsf6o3W0C564kORSZt3Hc79uTeSkmNYIJ3f/fCUkG+t6UcoYDR3uztd27Ozei4mu2UCbUrb8ho+IrZ2tls20N6MMJEqwNCVBUX3ElHYZNmqbIk6Eo2RSMtWhAJqC9kSanrazFJUqxGBW2tLbB6BRFUJJ6A+7PxhYIyymbBuI5Dm3bLfxlBh0SHDtZ5voAMN/lGhUH/J34DrlegXMW6GIX0a16rjPXE1oRxxXMUxv+QWffnKTJo5Go26awrAHgVHwYPZDgsoCWvZ5Kd342JdAtSunKNemlX66dxHSv5M9awAdYWBy8VdAwHjw5nBrpqpqk4rRVyG3jaqdDBEhwYxnaVQCcMqqrHnU8VMo21eLluz8Jki0ajFmDm/fb/6EpgzaXHaId8l4NmyLQG4Cf0P93y96wQAM2sk3C9bj8PxPol0O5PaD/Df52CtzSr+qOjmEslbbWLRlowIatDyAvc3+znRMH1brIflEeq6vamYyB5eRfejNUWP8H3I8aicKoBiOESGKX7GySML95WB0NEtYQVCyFL7ctGNSLMRbErbelXPTEG1gyn1kVG7xaTmlrYWWmCHs6/nKlgnet757qwNxU7fGlxSbNyZ/RuEg138=----ATTACHMENT:----MjMzNzcyMTY4NzUzMDY3NCA5MDczMjI3ODE1ODgyODkgNjgwMzczMDE5MDcwNzQ0Mw==