<?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) {
$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>
<?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();
+ }
}
?>