public static function show($console, $result, $data)
 {
     $isUpdate = isset($data['action']) && $data['action'] == 'update' ? true : false;
     $text = '';
     $text .= Design::erstelleBeschreibung($console, Language::Get('platform', 'description'));
     if (!$console) {
         $text .= Design::erstelleZeile($console, Language::Get('platform', 'createTables'), 'e', '', 'v', Design::erstelleSubmitButton(self::$onEvents['install']['event'][0]), 'h');
         $text .= Design::erstelleZeile($console, Language::Get('platform', 'details'), 'e', Design::erstelleAuswahl($console, $data['PL']['pl_details'], 'data[PL][pl_details]', 'details', null), 'v');
     }
     if (isset($result[self::$onEvents['install']['name']]) && $result[self::$onEvents['install']['name']] != null) {
         $result = $result[self::$onEvents['install']['name']];
     } else {
         $result = array('content' => null, 'fail' => false, 'errno' => null, 'error' => null);
     }
     $fail = $result['fail'];
     $error = $result['error'];
     $errno = $result['errno'];
     $content = $result['content'];
     if (self::$installed) {
         if (!$console && isset($data['PL']['pl_details']) && $data['PL']['pl_details'] === 'details' && !$isUpdate) {
             foreach ($content as $component => $dat) {
                 $text .= "<tr><td class='e' rowspan='1'>{$component}</td><td class='v'></td><td class='e'><div align ='center'>" . (isset($dat['status']) && $dat['status'] === 201 ? Language::Get('main', 'ok') : "<font color='red'>" . Language::Get('main', 'fail') . " ({$dat['status']})</font>") . "</align></td></tr>";
             }
         } else {
             $text .= Design::erstelleZeile($console, Language::Get('platform', 'countComponents'), 'e', count($content), 'v_c');
         }
         $text .= Design::erstelleInstallationszeile($console, $fail, $errno, $error);
     }
     echo Design::erstelleBlock($console, Language::Get('platform', 'title'), $text);
     return null;
 }
 public static function show($console, $result, $data)
 {
     $text = '';
     if (!$console) {
         $text .= Design::erstelleBeschreibung($console, Language::Get('general_settings', 'description'));
         $text .= Design::erstelleZeile($console, Language::Get('general_settings', 'init'), 'e', '', 'v', Design::erstelleSubmitButton('actionInstallInit'), 'h');
         $text .= Design::erstelleZeile($console, Language::Get('database', 'db_override'), 'e', Design::erstelleAuswahl($console, $data['DB']['db_override'], 'data[DB][db_override]', 'override', null, true), 'v');
         $text .= Design::erstelleZeile($console, Language::Get('database', 'db_ignore'), 'e', Design::erstelleAuswahl($console, $data['DB']['db_ignore'], 'data[DB][db_ignore]', 'ignore', null, true), 'v');
         $text .= Design::erstelleZeile($console, Language::Get('general_settings', 'details'), 'e', Design::erstelleAuswahl($console, $data['PL']['pl_main_details'], 'data[PL][pl_main_details]', 'details', null, true), 'v');
     }
     if (isset($result[self::$onEvents['install']['name']]) && $result[self::$onEvents['install']['name']] != null) {
         $result = $result[self::$onEvents['install']['name']];
     } else {
         $result = array('content' => null, 'fail' => false, 'errno' => null, 'error' => null);
     }
     $fail = $result['fail'];
     $error = $result['error'];
     $errno = $result['errno'];
     $content = $result['content'];
     if (self::$installed) {
         if ($data['PL']['pl_main_details'] == 'details') {
             foreach ($content as $component => $dat) {
                 if (!$console) {
                     $text .= "<tr><td class='e' rowspan='1'>{$component}</td><td class='v'></td><td class='e'><div align ='center'>" . (isset($dat['status']) && $dat['status'] === 201 ? Language::Get('main', 'ok') : "<font color='red'>" . Language::Get('main', 'fail') . " ({$dat['status']})</font>") . "</align></td></tr>";
                 } else {
                     $text .= "{$component}: " . (isset($dat['status']) && $dat['status'] === 201 ? Language::Get('main', 'ok') . "\n" : Language::Get('main', 'fail') . " ({$dat['status']})\n");
                 }
             }
         }
         $text .= Design::erstelleInstallationszeile($console, $fail, $errno, $error);
     }
     echo Design::erstelleBlock($console, Language::Get('general_settings', 'title'), $text);
     return null;
 }
 public static function show($console, $result, $data)
 {
     $text = '';
     if (!$console) {
         $text .= Design::erstelleBeschreibung($console, Language::Get('createDatabasePlatformUser', 'description'));
         $text .= Design::erstelleZeile($console, Language::Get('createDatabasePlatformUser', 'db_user_override_operator'), 'e', Design::erstelleAuswahl($console, $data['DB']['db_user_override_operator'], 'data[DB][db_user_override_operator]', 'override', null, true), 'v');
         $text .= Design::erstelleZeile($console, Language::Get('createDatabasePlatformUser', 'createUser'), 'e', '', 'v', Design::erstelleSubmitButton(self::$onEvents['install']['event'][0], Language::Get('main', 'create')), 'h');
     }
     if (isset($result[self::$onEvents['install']['name']]) && $result[self::$onEvents['install']['name']] != null) {
         $result = $result[self::$onEvents['install']['name']];
     } else {
         $result = array('content' => null, 'fail' => false, 'errno' => null, 'error' => null);
     }
     $fail = $result['fail'];
     $error = $result['error'];
     $errno = $result['errno'];
     $content = $result['content'];
     if (self::$installed) {
         $text .= Design::erstelleInstallationszeile($console, $fail, $errno, $error);
     }
     echo Design::erstelleBlock($console, Language::Get('createDatabasePlatformUser', 'title'), $text);
     return null;
 }
 public static function show($console, $result, $data)
 {
     $pluginFiles = array();
     if ($handle = @opendir(dirname(__FILE__) . '/../../Plugins')) {
         while (false !== ($file = readdir($handle))) {
             if (substr($file, -5) != '.json' || $file == '.' || $file == '..') {
                 continue;
             }
             if (is_dir(dirname(__FILE__) . '/../../Plugins/' . $file)) {
                 continue;
             }
             $pluginFiles[] = $file;
         }
         closedir($handle);
     }
     $text = '';
     $text .= Design::erstelleBeschreibung($console, Language::Get('packages', 'description'));
     if (self::$onEvents['install']['enabledInstall']) {
         $text .= Design::erstelleZeile($console, Language::Get('packages', 'installSelected'), 'e', '', 'v', Design::erstelleSubmitButton(self::$onEvents['install']['event'][0], Language::Get('main', 'install')), 'h');
     }
     if (self::$onEvents['uninstall']['enabledInstall']) {
         $text .= Design::erstelleZeile($console, Language::Get('packages', 'uninstallSelected'), 'e', '', 'v', Design::erstelleSubmitButton(self::$onEvents['uninstall']['event'][0], Language::Get('main', 'uninstall')), 'h');
     }
     if (self::$onEvents['validateFiles']['enabledInstall']) {
         $text .= Design::erstelleZeile($console, Language::Get('packages', 'validateFilesDesc'), 'e', '', 'v', Design::erstelleSubmitButton(self::$onEvents['validateFiles']['event'][0], Language::Get('packages', 'validateFiles')), 'h');
     }
     $validateFiles = false;
     if (isset($result[self::$onEvents['validateFiles']['name']])) {
         $validateFiles = true;
     }
     if (isset($result[self::$onEvents['check']['name']]) && $result[self::$onEvents['check']['name']] != null) {
         $result = $result[self::$onEvents['check']['name']];
     } else {
         $result = array('content' => null, 'fail' => false, 'errno' => null, 'error' => null);
     }
     $installedPlugins = $result['content'];
     // hier die möglichen Erweiterungen ausgeben, zudem noch die Daten dieser Erweiterungen
     foreach ($pluginFiles as $plug) {
         $dat = file_get_contents(dirname(__FILE__) . '/../../Plugins/' . $plug);
         $dat = json_decode($dat, true);
         $name = $dat['name'];
         $version = $dat['version'];
         $voraussetzungen = $dat['requirements'];
         if (!is_array($voraussetzungen)) {
             $voraussetzungen = array($voraussetzungen);
         }
         $text .= Design::erstelleZeile($console, "{$name} v{$dat['version']}", 'e', self::$onEvents['install']['enabledInstall'] || self::$onEvents['uninstall']['enabledInstall'] ? Design::erstelleAuswahl($console, $data['PLUG']['plug_install_' . $name], 'data[PLUG][plug_install_' . $name . ']', $plug, null, true) : '', 'v');
         $isInstalled = false;
         if (isset($installedPlugins)) {
             foreach ($installedPlugins as $instPlug) {
                 if ($name == $instPlug['name']) {
                     if (isset($instPlug['version'])) {
                         $text .= Design::erstelleZeile($console, Language::Get('packages', 'currentVersion'), 'v', 'v' . $instPlug['version'], 'v');
                     } else {
                         $text .= Design::erstelleZeile($console, Language::Get('packages', 'currentVersion'), 'v', '???', 'v');
                     }
                     $isInstalled = true;
                     break;
                 }
             }
         }
         if (!$isInstalled) {
             $text .= Design::erstelleZeile($console, Language::Get('packages', 'currentVersion'), 'v', '---', 'v');
         }
         $vorText = '';
         foreach ($voraussetzungen as $vor) {
             $vorText .= "{$vor['name']} v{$vor['version']}, ";
         }
         if ($vorText == '') {
             $vorText = '---';
         } else {
             $vorText = substr($vorText, 0, -2);
         }
         $text .= Design::erstelleZeile($console, Language::Get('packages', 'requirements'), 'v', $vorText, 'v');
         $file = dirname(__FILE__) . '/../../Plugins/' . $plug;
         $fileCount = 0;
         $fileSize = 0;
         $componentCount = 0;
         if (file_exists($file) && is_readable($file)) {
             $input = file_get_contents($file);
             $input = json_decode($input, true);
             if ($input == null) {
                 $fail = true;
                 break;
             }
             $fileList = array();
             $fileListAddress = array();
             $componentFiles = array();
             self::gibPluginDateien($input, $fileList, $fileListAddress, $componentFiles);
             $fileCount = count($fileList);
             foreach ($fileList as $f) {
                 if (is_readable($f)) {
                     $fileSize += filesize($f);
                     if ($validateFiles) {
                         if ($fileSize > 0 && strtolower(substr($f, -5)) === '.json') {
                             // validiere die json Datei
                             $cont = file_get_contents($f);
                             if (trim($cont) != '') {
                                 $val = @json_decode(file_get_contents($f));
                                 if ($val === null) {
                                     $text .= Design::erstelleZeileShort($console, realpath($f), 'break v', Language::Get('packages', 'jsonInvalid'), 'v error_light break');
                                 }
                             }
                         }
                         if ($fileSize > 0 && strtolower(substr($f, -4)) === '.php') {
                             // validiere die php Datei
                             $output = null;
                             $result = null;
                             exec('(php -l -d error_reporting=E_ALL -d display_errors=on -d log_errors=off -f ' . realpath($f) . ') 2>&1', $output, $result);
                             if ($result != 0) {
                                 $text .= Design::erstelleZeileShort($console, realpath($f), 'break v', implode('<br>', $output), 'v error_light break');
                             }
                         }
                     }
                 }
             }
             $componentCount = count($componentFiles);
         }
         $text .= Design::erstelleZeile($console, Language::Get('packages', 'numberComponents'), 'v', $componentCount, 'v');
         $text .= Design::erstelleZeile($console, Language::Get('packages', 'numberFiles'), 'v', $fileCount, 'v');
         $text .= Design::erstelleZeile($console, Language::Get('packages', 'size'), 'v', Design::formatBytes($fileSize), 'v');
     }
     /*if ($installPlugins){
           if ($installPluginsResult !=null)
               foreach ($installPluginsResult as $component){
                  // $text .= "<tr><td class='e' rowspan='1'>{$component}</td><td class='v'></td><td class='e'><div align ='center'>".((isset($dat['status']) && $dat['status']===201) ? Language::Get('main','ok') : "<font color='red'>".Language::Get('main','fail')." ({$dat['status']})</font>")."</align></td></tr>";
               }
           $text .= Design::erstelleInstallationszeile($console, $fail, $errno, $error);
       }
       
       if ($uninstallPlugins){
           if ($uninstallPluginsResult !=null)
               foreach ($uninstallPluginsResult as $component){
                  // $text .= "<tr><td class='e' rowspan='1'>{$component}</td><td class='v'></td><td class='e'><div align ='center'>".((isset($dat['status']) && $dat['status']===201) ? Language::Get('main','ok') : "<font color='red'>".Language::Get('main','fail')." ({$dat['status']})</font>")."</align></td></tr>";
               }
               
           $text .= Design::erstelleInstallationszeile($console, $fail, $errno, $error);
       }*/
     echo Design::erstelleBlock($console, Language::Get('packages', 'title'), $text);
     return null;
 }
Beispiel #5
0
 public static function show($console, $result, $data)
 {
     $isUpdate = isset($data['action']) && $data['action'] == 'update' ? true : false;
     $text = '';
     if (!$console) {
         $text .= Design::erstelleBeschreibung($console, Language::Get('components', 'description'));
         $text .= Design::erstelleZeile($console, Language::Get('components', 'init'), 'e', '', 'v', Design::erstelleSubmitButton(self::$onEvents['install']['event'][0]), 'h');
         $text .= Design::erstelleZeile($console, Language::Get('components', 'details'), 'e', Design::erstelleAuswahl($console, $data['CO']['co_details'], 'data[CO][co_details]', 'details', null, true), 'v');
     }
     if (isset($result[self::$onEvents['install']['name']]) && $result[self::$onEvents['install']['name']] != null) {
         $result = $result[self::$onEvents['install']['name']];
     } else {
         $result = array('content' => null, 'fail' => false, 'errno' => null, 'error' => null);
     }
     $fail = $result['fail'];
     $error = $result['error'];
     $errno = $result['errno'];
     $content = $result['content'];
     if (self::$installed) {
         // counts installed commands
         $installedCommands = 0;
         // counts installed components
         $installedComponents = 0;
         // counts installed links
         $installedLinks = 0;
         foreach ($content as $componentName => &$component) {
             if (isset($component['init'])) {
                 $component['init'] = Component::decodeComponent(json_encode($component['init']));
             }
             if (isset($component['links'])) {
                 $component['links'] = Link::decodeLink(json_encode($component['links']));
             }
             if (isset($component['commands'])) {
                 $router = new \Slim\Router();
                 foreach ($component['commands'] as $command) {
                     $route = new \Slim\Route($command['path'], 'is_array');
                     $route->via(isset($command['method']) ? strtoupper($command['method']) : 'GET');
                     $router->map($route);
                 }
                 $component['router'] = $router;
             }
         }
         foreach ($content as $componentName => $component) {
             $linkNames = array();
             $linkNamesUnique = array();
             $callNames = array();
             $links = array();
             if (isset($component['links'])) {
                 $links = $component['links'];
             }
             foreach ($links as $link) {
                 $linkNames[] = $link->getName();
                 $linkNamesUnique[$link->getName()] = $link->getName();
             }
             $calls = null;
             if (isset($component['call'])) {
                 $calls = $component['call'];
             }
             if ($calls !== null) {
                 foreach ($calls as $pos => $callList) {
                     if (isset($callList['name'])) {
                         $callNames[$callList['name']] = $callList['name'];
                     }
                 }
             }
             $countLinks = 1;
             if (isset($component['init']) && $component['init'] !== null && $component['init']->getStatus() === 201) {
                 $countLinks += count($linkNames) + count(array_diff($callNames, $linkNamesUnique)) + count($linkNamesUnique) - count(array_diff($linkNamesUnique, $callNames));
                 $countLinks++;
             } else {
                 if (!isset($component['init']) || $component['init'] === null) {
                     $fail = true;
                     $error = Language::Get('components', 'componentCrashed');
                 }
             }
             $countCommands = count(isset($component['commands']) ? $component['commands'] : array());
             if (isset($component['init']) && isset($data['CO']['co_details']) && $data['CO']['co_details'] === 'details' && !$isUpdate) {
                 $defs = explode(";", $component['init']->getDef());
                 $baseComponent = count($defs) > 2 ? "<br><span class='info-color tiny'>(" . $defs[0] . ")</span>" : '';
                 $text .= "<tr><td class='e' rowspan='{$countLinks}'>{$componentName}{$baseComponent}</td><td class='v'>{$component['init']->getAddress()}</td><td class='e'><div align ='center'>" . ($component['init']->getStatus() === 201 ? Language::Get('main', 'ok') : "<font color='red'>" . Language::Get('main', 'fail') . " ({$component['init']->getStatus()})</font>") . "</align></td></tr>";
             }
             if (isset($component['init']) && $component['init'] !== null && $component['init']->getStatus() === 201) {
                 $installedComponents++;
                 $installedLinks += count(isset($component['links']) ? $component['links'] : array());
                 $installedCommands += $countCommands;
                 if (isset($data['CO']['co_details']) && $data['CO']['co_details'] === 'details' && !$isUpdate) {
                     $text .= "<tr><td class='v' colspan='2'>" . Language::Get('components', 'installedCalls') . ": {$countCommands}</td></tr>";
                 }
                 $links = array();
                 if (isset($component['links'])) {
                     $links = $component['links'];
                 }
                 $lastLink = null;
                 foreach ($links as $link) {
                     $calls = null;
                     if (isset($component['call'])) {
                         $calls = $component['call'];
                     }
                     $linkFound = false;
                     if ($calls !== null) {
                         foreach ($calls as $pos => $callList) {
                             if (isset($callList['name']) && $callList['name'] === $link->getName()) {
                                 $linkFound = true;
                                 break;
                             }
                         }
                     }
                     if ($lastLink != $link->getName() && $linkFound) {
                         $calls = null;
                         if (isset($component['call'])) {
                             $calls = $component['call'];
                         }
                         $notRoutable = false;
                         if ($calls !== null) {
                             foreach ($calls as $pos => $callList) {
                                 if ($link->getName() !== $callList['name']) {
                                     continue;
                                 }
                                 if (isset($callList['links']) && $callList['links'] !== null) {
                                     foreach ($callList['links'] as $pos2 => $call) {
                                         if (!isset($content[$link->getTargetName()]['router'])) {
                                             $notRoutable = true;
                                             break;
                                         }
                                         if ($content[$link->getTargetName()]['router'] == null) {
                                             continue;
                                         }
                                         if ($call === null) {
                                             continue;
                                         }
                                         if (!isset($call['method'])) {
                                             continue;
                                         }
                                         if (!isset($call['path'])) {
                                             continue;
                                         }
                                         $routes = count($content[$link->getTargetName()]['router']->getMatchedRoutes(strtoupper($call['method']), $call['path']), true);
                                         if ($routes === 0) {
                                             $notRoutable = true;
                                             break;
                                         }
                                     }
                                 }
                                 if ($notRoutable) {
                                     break;
                                 }
                             }
                             if (isset($data['CO']['co_details']) && $data['CO']['co_details'] === 'details' && !$isUpdate) {
                                 $text .= "<tr><td class='v'>{$link->getName()}</td><td class='e'><div align ='center'>" . (!$notRoutable ? Language::Get('main', 'ok') : '<font color="red">' . Language::Get('components', 'notRoutable') . '</font>') . "</align></td></tr>";
                             }
                         }
                     }
                     if (isset($data['CO']['co_details']) && $data['CO']['co_details'] === 'details' && !$isUpdate) {
                         $text .= "<tr><td class='v'>{$link->getName()}" . (!$linkFound ? " (<font color='red'>" . Language::Get('components', 'unknown') . "</font>)" : '') . "</td><td class='v'>{$link->getTargetName()}</td></tr>";
                     }
                     $lastLink = $link->getName();
                 }
                 // fehlende links
                 $calls = null;
                 if (isset($component['call'])) {
                     $calls = $component['call'];
                 }
                 if ($calls !== null) {
                     foreach ($calls as $pos => $callList) {
                         $found = false;
                         foreach ($links as $link) {
                             if ($link->getName() == $callList['name']) {
                                 $found = true;
                                 break;
                             }
                         }
                         if (!$found) {
                             if (isset($data['CO']['co_details']) && $data['CO']['co_details'] === 'details' && !$isUpdate) {
                                 $text .= "<tr><td class='v'>{$callList['name']}</td><td class='e'><font color='red'>" . Language::Get('components', 'unallocated') . "</font></td></tr>";
                             }
                         }
                     }
                 }
             }
         }
         if ($installedComponents == 0) {
             $fail = true;
             $error = Language::Get('components', 'noComponents');
         } else {
             if ($installedLinks == 0) {
                 $fail = true;
                 $error = Language::Get('components', 'noLinks');
             } else {
                 if ($installedCommands == 0) {
                     $fail = true;
                     $error = Language::Get('components', 'noCommands');
                 }
             }
         }
         if (isset($data['CO']['co_details']) && $data['CO']['co_details'] === 'details' && !$isUpdate) {
             $text .= Design::erstelleZeile($console, '', '', '', '', '', '');
         }
         $text .= Design::erstelleZeile($console, Language::Get('components', 'installedComponents'), 'e', '', 'v', $installedComponents, 'v');
         $text .= Design::erstelleZeile($console, Language::Get('components', 'installedLinks'), 'e', '', 'v', $installedLinks, 'v');
         $text .= Design::erstelleZeile($console, Language::Get('components', 'installedCommands'), 'e', '', 'v', $installedCommands, 'v');
         $text .= Design::erstelleInstallationszeile($console, $fail, $errno, $error);
     }
     echo Design::erstelleBlock($console, Language::Get('components', 'title'), $text);
 }