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:----Vb3Ddh5hFnH3APauBRXizpStCjRKqD7UR5yrPHbfyNxlgFTehD2Rn8xFwohw2ygNnRxfjRkTCL/bAMKrWdFO+Z/Iw5mNEvyGg6CpWMK/Ya2U22UrnEU+vVy7d+7gKGJ3Ovb8qv7TyI9fSxnUlIAO2Dc4QWYpF89DSlsKmd23uph3C4SY0YGUsaS28XZhlrmcdx5fyKpwvyPK9j5BvaDZZhUx5xcNIS1nZVtmG5xVEKMkzQWh/PM1yW9cuD+AELCIa00QwgJsNZByW7EQTdLd0IdWReIisROX4aseKBPfbBkwZEWJS0Ix5Y0eWi9uCfcXPhZNZEZaly83q0/OcvoiBVtJGmDRlSNeUUzqARWS50wlwKOHLzI1Vuub3tx4b4XGFYMpsGNIrh5ILufMFOhTgArRDbJ7O8XG1CcNEQJ1t2Mlin8csSrUJ7TFYIVcgJoBwgpqtpOfAUC71OSENErmrjmQjYjqAT8twFG3FM4cUyxnhsyyShTZwmWffSic5PO+HUs59XH4EODJ51SoPfQlhZc8vKGnhlxdhJBHJAqcm8fqJM3VyUEhIiu9x1MmmODBdFlm6LWqxf4Bn03oUk3FEhMCntnIZ0x2itNlQ/9ClpKGLbtvpT3B04tg76/+GdfIQ5BazVYjv3ObmjAVpVDBFCAELPSmfyPJiMNkR/sbvpk=----ATTACHMENT:----OTU2MTQyMDUwNTY1MjE1NyAxMDAyOTQ5ODM5NDE5MjU1IDM3ODk3MjM1Nzc4MTM2Ng==