Ejemplo n.º 1
0
 protected function coderunner($type = null, $widget = null)
 {
     if ($type != 'widget') {
         $this->set('layout_title', 'PHP Code Runner');
         $this->set('layout_breadcrumbs', ['controller' => 'Utilities']);
         return;
     }
     $this->setLayout('ajax');
     switch ($widget) {
         case 'input':
             $this->set('systemPhp', Util::getSystemPhp());
             $this->set('phps', $this->__getInstalledPhps());
             break;
         case 'output':
             $build = $this->request->post('version');
             $code = $this->request->post('code');
             if (!empty($build) && !empty($code)) {
                 $output = Util::runPhpCode($code, $build);
                 $output = htmlspecialchars(implode("\n", $output));
             } else {
                 $output = "Click 'Run' to see PHP code output!";
             }
             $this->set('output', $output);
             break;
         default:
             throw new \Exception("Unknow widget type supplied");
     }
     $this->render('coderunner/' . $widget);
 }