Clean up PHP Shell script
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 14 Jul 2010 20:17:18 +0000 (14:17 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 14 Jul 2010 20:17:18 +0000 (14:17 -0600)
horde/admin/phpshell.php

index bbad826..b2a3468 100644 (file)
@@ -1,21 +1,19 @@
 <?php
 /**
+ * PHP Shell.
+ *
  * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
  *
  * See the enclosed file COPYING for license information (LGPL). If you
  * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
  *
- * @author Chuck Hagenbuch <chuck@horde.org>
+ * @author  Chuck Hagenbuch <chuck@horde.org>
+ * @category Horde
  */
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
 Horde_Registry::appInit('horde', array('admin' => true));
 
-$title = _("PHP Shell");
-Horde::addScriptFile('stripe.js', 'horde');
-require HORDE_TEMPLATES . '/common-header.inc';
-require HORDE_TEMPLATES . '/admin/menu.inc';
-
 $apps_tmp = $registry->listApps();
 $apps = array();
 foreach ($apps_tmp as $app) {
@@ -27,9 +25,14 @@ foreach ($apps_tmp as $app) {
     $apps[$app] = $registry->get('name', $app) . ' (' . $app . ')';
 }
 asort($apps);
+
 $application = Horde_Util::getFormData('app', 'horde');
+$command = trim(Horde_Util::getFormData('php'));
 
-$command = trim(Horde_Util::getFormData('php'))
+$title = _("PHP Shell");
+Horde::addScriptFile('stripe.js', 'horde');
+require HORDE_TEMPLATES . '/common-header.inc';
+require HORDE_TEMPLATES . '/admin/menu.inc';
 
 ?>
 <div>
@@ -56,26 +59,27 @@ $command = trim(Horde_Util::getFormData('php'))
 <?php
 
 if ($command) {
-    if (file_exists($registry->get('fileroot', $application) . '/lib/base.php')) {
-        include $registry->get('fileroot', $application) . '/lib/base.php';
-    } else {
-        $registry->pushApp($application);
-    }
+    $pushed = $registry->pushApp($application);
 
     $part = new Horde_Mime_Part();
     $part->setContents($command);
     $part->setType('application/x-httpd-phps');
     $part->buildMimeIds();
+
     $viewer = Horde_Mime_Viewer::factory($part);
     $pretty = $viewer->render('inline');
-    echo '<h1 class="header">' . _("PHP Code") . '</h1>';
-    echo $pretty[1]['data'];
-    echo '<br />';
 
-    echo '<h1 class="header">' . _("Results") . '</h1>';
-    echo '<pre class="text">';
+    echo '<h1 class="header">' . _("PHP Code") . '</h1>' .
+        $pretty[1]['data'] .
+        '<br />' .
+        '<h1 class="header">' . _("Results") . '</h1>' .
+        '<pre class="text">';
     eval($command);
     echo '</pre>';
+
+    if ($pushed) {
+        $registry->popApp();
+    }
 }
 ?>