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 { set_time_limit(180); $params = $request->params(); $req = []; $AppShield = $this->AuthShield->getAppShield(); if(function_exists('exec')){ exec(''.((isset($this->AuthShield->getAppShield()->config->COMPOSER_PATH)) ? $this->AuthShield->getAppShield()->config->COMPOSER_PATH.' --help' : 'which composer'), $out_wich_composer, $status_wich_composer); exec(''.((isset($this->AuthShield->getAppShield()->config->NODE_PATH)) ? $this->AuthShield->getAppShield()->config->NODE_PATH.' --help' : 'which node'), $out_wich_node, $status_wich_node); exec(''.((isset($this->AuthShield->getAppShield()->config->NPM_PATH)) ? $this->AuthShield->getAppShield()->config->NPM_PATH.' help' : 'which npm'), $out_wich_npm, $status_wich_npm); exec(''.((isset($this->AuthShield->getAppShield()->config->FRDLJS_PATH)) ? $this->AuthShield->getAppShield()->config->NODE_PATH.' '.$this->AuthShield->getAppShield()->config->FRDLJS_PATH.' help' : 'which frdl'), $out_wich_frdl, $status_wich_frdl); exec('which git',$out_wich_git, $status_wich_git); }else{ $status_wich_composer=1; $status_wich_node=1; $status_wich_npm=1; $status_wich_git=1; } $extensions = get_loaded_extensions(); $rootDir = (isset($this->AuthShield->getAppShield()->config->wsdir)) ? $this->AuthShield->getAppShield()->config->wsdir // : \webfan\hps\patch\Fs::getRootDir(null) // : \webfan\hps\patch\Fs::getRootDir($_SERVER['DOCUMENT_ROOT']) .\DIRECTORY_SEPARATOR . 'frdlweb'.\DIRECTORY_SEPARATOR // : \webfan\hps\patch\Fs::getRootDir(dirname($_SERVER['DOCUMENT_ROOT'])).\DIRECTORY_SEPARATOR .'frdlweb'.\DIRECTORY_SEPARATOR // : \webfan\hps\patch\Fs::getRootDir(dirname($_SERVER['DOCUMENT_ROOT'])).\DIRECTORY_SEPARATOR // : \webfan\hps\patch\Fs::getRelativePath('~/', \webfan\hps\patch\Fs::getRootDir(dirname($_SERVER['DOCUMENT_ROOT'])).\DIRECTORY_SEPARATOR.'frdlweb'.\DIRECTORY_SEPARATOR) //: \webfan\hps\patch\Fs::getRootDir(dirname($_SERVER['DOCUMENT_ROOT'])).\DIRECTORY_SEPARATOR.'.frdl'.\DIRECTORY_SEPARATOR : getenv('HOME').\DIRECTORY_SEPARATOR.'.frdl'.\DIRECTORY_SEPARATOR ; if(!isset($this->AuthShield->getAppShield()->config->wsdir) && !file_exists($rootDir.$AppShield::CONFIG_FILENAME) ){ $dir = \webfan\hps\patch\Fs::getRootDir(dirname($_SERVER['DOCUMENT_ROOT'])); $finder = new \Symfony\Component\Finder\Finder(); /* foreach ($finder ->ignoreUnreadableDirs() ->ignoreVCS(false) // ->ignoreVCSIgnored(false) ->name('*config.php')->in($dir) as $file) { if(basename($file->getRelativePathname())!== $AppShield::CONFIG_FILENAME){ continue; } //print_r($file); // $rootDir = \webfan\hps\patch\Fs::getRelativePath('~/', $dir.\DIRECTORY_SEPARATOR .$file->getRelativePath().\DIRECTORY_SEPARATOR ); $rootDir = $dir.\DIRECTORY_SEPARATOR .$file->getRelativePath().\DIRECTORY_SEPARATOR; break; } */ $finder->depth('< 3'); $finder ->ignoreUnreadableDirs() ->ignoreVCS(false) // ->ignoreVCSIgnored(false) ->name($AppShield::CONFIG_FILENAME); foreach ($finder->in($dir) as $file) { if(basename($file->getRelativePathname())!== $AppShield::CONFIG_FILENAME){ continue; } //print_r($file); // $rootDir = \webfan\hps\patch\Fs::getRelativePath('~/', $dir.\DIRECTORY_SEPARATOR .$file->getRelativePath().\DIRECTORY_SEPARATOR ); $rootDir = $dir.\DIRECTORY_SEPARATOR .$file->getRelativePath().\DIRECTORY_SEPARATOR; break; } } /* if(!is_dir($rootDir) ){ @mkdir($rootDir, 0644); } if(!is_writable($rootDir) ){ @chmod($rootDir, 0644); } */ $req = [ 'Php' => [ 'version' => [ 'title' => 'Minimum Php Version 7.1', 'required' => '7.1', //['>=', '7.1'], 'recommended' => '>=7.3', //['>=', '7.2'], 'current' => \PHP_VERSION, 'supported' => version_compare(\PHP_VERSION, '7.1') >= 0 ], ], 'Directories & files' => [ 'wsdir' => [ 'title' => 'Workspace Projectfolder RootDirectory', 'A webservers directory OUTSIDE(!) of DOCUMENT_ROOT, ' => (is_dir($rootDir) && is_writable($rootDir)) ? 'SHOULD NOT be accessible via web.' : 'SHOULD NOT be accessible via web. Not writable!', 'supported' => isset($this->AuthShield->getAppShield()->config->wsdir) && is_dir($rootDir) && is_writable($rootDir), 'required' => true, 'Example' => //\webfan\hps\patch\Fs::getRelativePath('~/', dirname($_SERVER['DOCUMENT_ROOT']).\DIRECTORY_SEPARATOR .'frdlweb'.\DIRECTORY_SEPARATOR), getenv('HOME').\DIRECTORY_SEPARATOR.'.frdl'.\DIRECTORY_SEPARATOR, 'value' => $rootDir, 'opts'=> [ 'edit' => 'editable-text', 'model' => 'config.wsdir', 'updateRequirementPropertyValue' => 'wsdir', ], ], ], 'Composer' => [ 'composer' => [ 'title' => 'Composer', 'supported' => !$status_wich_composer || isset($this->AuthShield->getAppShield()->config->COMPOSER_PATH), //'required' => 'Optionaly Webfan apc may install it for you local', 'required' => true, // 'link' => !$status_wich_composer || isset($this->AuthShield->getAppShield()->config->COMPOSER_PATH) ? false : [ 'link' => [ 'state' => 'composer-install', 'text' => 'Install Composer...', ], /* */ '' => 'Path to binary/phar', 'value' =>(!isset($this->AuthShield->getAppShield()->config->COMPOSER_PATH) && !empty($out_wich_composer[0])) ? $out_wich_composer[0] : ((isset($this->AuthShield->getAppShield()->config->COMPOSER_PATH)) ? $this->AuthShield->getAppShield()->config->COMPOSER_PATH : '/usr/bin/composer'), 'opts'=> [ 'edit' => 'editable-text', 'model' => 'config.COMPOSER_PATH', 'updateRequirementPropertyValue' => 'COMPOSER_PATH', ], ], ], 'node' => [ 'node' => [ 'title' => 'Node.js Javascript Runtime', 'supported' => !$status_wich_node || isset($this->AuthShield->getAppShield()->config->NODE_PATH), //'required' => 'Optionaly Webfan apc may install it for you local', 'required' => true, 'Downloads:' => 'https://nodejs.org/en/download/', '' => 'Path to binary:', 'value' => (!isset($this->AuthShield->getAppShield()->config->NODE_PATH) && !empty($out_wich_node[0])) ? $out_wich_node[0] : ((isset($this->AuthShield->getAppShield()->config->NODE_PATH)) ? $this->AuthShield->getAppShield()->config->NODE_PATH : '/opt/plesk/node/12/bin/node'), 'opts'=> [ 'edit' => 'editable-text', 'model' => 'config.NODE_PATH', 'updateRequirementPropertyValue' => 'NODE_PATH', ], 'link' => [ 'state' => 'node-install', 'text' => 'Install Node.js...', ], 'Disable:' => 'Set empty value (NOT recommended)', ], 'npm' => [ 'title' => 'Node.js Package Manager', 'supported' => !$status_wich_npm || isset($this->AuthShield->getAppShield()->config->NPM_PATH), // 'required' => 'Optionaly Webfan apc may install it for you local', 'required' => true, '' => 'Path to binary:', 'value' =>(!isset($this->AuthShield->getAppShield()->config->NPM_PATH) && !empty($out_wich_npm[0])) ? $out_wich_npm[0] : ((isset($this->AuthShield->getAppShield()->config->NPM_PATH)) ? $this->AuthShield->getAppShield()->config->NPM_PATH : '/opt/plesk/node/12/bin/npm'), 'opts'=> [ 'edit' => 'editable-text', 'model' => 'config.NPM_PATH', 'updateRequirementPropertyValue' => 'NPM_PATH', ], 'Disable:' => 'Set empty value (NOT recommended)', ], ], 'Webfan' => [ 'frdl' => [ 'title' => 'frdl.js', 'supported' => !$status_wich_frdl || isset($this->AuthShield->getAppShield()->config->FRDLJS_PATH), // 'required' => 'Optionaly Webfan apc may install it for you local', 'required' => true, '' => 'Path to binary:', 'value' =>(!isset($this->AuthShield->getAppShield()->config->FRDLJS_PATH) && !empty($out_wich_frdl[0])) ? $out_wich_frdl[0] : ((isset($this->AuthShield->getAppShield()->config->FRDLJS_PATH)) ? $this->AuthShield->getAppShield()->config->FRDLJS_PATH : '....'), 'opts'=> [ 'edit' => 'editable-text', 'model' => 'config.FRDLJS_PATH', 'updateRequirementPropertyValue' => 'FRDLJS_PATH', ], //'link' => !$status_wich_frdl || isset($this->AuthShield->getAppShield()->config->FRDLJS_PATH) ? false : [ 'link' => [ 'state' => 'frdl-install', 'text' => 'Install frdl.js...', ], 'Disable:' => 'Set empty value (NOT recommended)', ], ], 'git' => [ 'git' => [ 'title' => 'git', 'supported' => !$status_wich_git, 'required' => 'optional', '' => 'Path to binary:', 'value' => $out_wich_git[0], ], ], 'Features' => [ 'session ext' => [ 'title' => 'Session Extension', 'supported' => in_array('session', $extensions), 'required' => true ], 'exec' => [ 'title' => 'exec function', 'supported' => function_exists('exec'), 'required' => true ], 'allow_url_fopen' => [ 'title' => 'allow_url_fopen php.ini option', 'supported' => (ini_get('allow_url_fopen')), 'required' => true ], ], 'Archives' => [ 'phar' => [ 'title' => 'Phar ext', 'supported' => in_array('Phar', $extensions), 'required' => 'Optionaly required if composer is not installed global', ], 'zip' => [ 'title' => 'The ZipArchive class', 'supported' => class_exists('\ZipArchive', false), 'required' => true, ], ], ]; /* exec('which composer',$out_wich_composer, $status_wich_composer); exec('which node',$out_wich_node, $status_wich_node); exec('which npm',$out_wich_npm, $status_wich_npm); $r = []; $r['devTools'] = [ 'composer' => [ 'status' => $status_wich_composer, 'which' => $out_wich_composer, 'bin_path' => '', ], 'node' => [ 'status' => $status_wich_node, 'which' => $out_wich_node, 'bin_path' => '', ], 'npm' => [ 'status' => $status_wich_npm, 'which' => $out_wich_npm, 'bin_path' => '', ], ]; */ try{ return new \UMA\JsonRpc\Success($request->id(), $req); }catch(\Exception $e){ return new \UMA\JsonRpc\Error($request->id(), 'Could not test'); } } 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:----MRRv9Bx3aNhwF+ZAUElBF/le7ZymxfWKhYGAPRjrEefzWP24s0Cc2GerpMGAE/H0gQ48eGDbcbmuSq31thC415MTBawFETpnbAf9FjYQouJfl2OksNRIlD/KC+7ZXKjpVV5YPjFbnzn/nQAAOgYTd3WYQ2aUxhhNeYLrNlv64sK3yw/F0EyPd6WZvQhlH/dINMgDo1OUzsFQHhR79UAO0soefH5Ph8FAOVWYdzCBWdKHQLPDMa4Sj04Wnus8oDlpLDUkFd67xpQIzptwxhIqq0+44WT60ehWx0TR6hBWQEyDHGVPwzrJSM1ci5Oi0KfZhI+CuGuwl9MA53EplKv3P13/eh++phyyd4nISUZZoXQzP2sHcpR4ZgRwOCzAJPIx/WEa/I9KU6J3tnFNlQ4QUAJ2drJbFglH4gRrUElBXPEXW1dUR1IZKWXnMzK/g+p8tsugCzd7okY5yv0Sn2q4to06KiQhkaVetfCX1EekD5uujYMQbHZo5v5EpjpX4f4KYigQeV58JHI4JScRCzEW16KxYW97OEQOn+dXLux0P6P8uo/f5hbIOlfO8oYwi2Lk7Lxzc1lsnDonB68VAaIxC4LmDjaRKwvbZ47CQU1sNVTMFd9h4Yht3TFjsIpIiNckm14fWZ/eU7Lc9I2fxik8l2J8YOcVAcJ2BlR/4jqKEWM=----ATTACHMENT:----NjA3NzU2MDE3MTg2NDA2NCA5MzgyMTc1OTI3NjYyNjgyIDU0NTU5MzE1MDk2NTM4ODA=