~ubuntu-branches/ubuntu/saucy/horde3/saucy

« back to all changes in this revision

Viewing changes to admin/cmdshell.php

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2005-05-04 23:08:08 UTC
  • Revision ID: james.westby@ubuntu.com-20050504230808-p4hf3hk28o3v7wir
Tags: upstream-3.0.4
ImportĀ upstreamĀ versionĀ 3.0.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/**
 
3
 * $Horde: horde/admin/cmdshell.php,v 1.9.10.1 2005/01/03 12:25:29 jan Exp $
 
4
 *
 
5
 * Copyright 1999-2005 Chuck Hagenbuch <chuck@horde.org>
 
6
 *
 
7
 * See the enclosed file COPYING for license information (LGPL). If you
 
8
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 
9
 */
 
10
 
 
11
define('HORDE_BASE', dirname(__FILE__) . '/..');
 
12
require_once HORDE_BASE . '/lib/base.php';
 
13
require_once 'Horde/Menu.php';
 
14
require_once 'Horde/Help.php';
 
15
 
 
16
if (!Auth::isAdmin()) {
 
17
    Horde::fatal('Forbidden.', __FILE__, __LINE__);
 
18
}
 
19
 
 
20
$title = _("Command Shell");
 
21
require HORDE_TEMPLATES . '/common-header.inc';
 
22
require HORDE_TEMPLATES . '/admin/common-header.inc';
 
23
 
 
24
if ($command = trim(Util::getFormData('cmd'))) {
 
25
    echo '<div class="header">' . _("Command") . ':</div><br />';
 
26
    echo '<table cellpadding="4" border="0"><tr><td class="text"><code>' . nl2br(htmlspecialchars($command)) . '</code></td></tr></table>';
 
27
 
 
28
    echo '<br /><div class="header">' . _("Results") . ':</div><br />';
 
29
    echo '<table cellpadding="4" border="0"><tr><td class="text"><pre>';
 
30
 
 
31
    $cmds = explode("\n", $command);
 
32
    foreach ($cmds as $cmd) {
 
33
        $cmd = trim($cmd);
 
34
        if (strlen($cmd)) {
 
35
            unset($results);
 
36
            flush();
 
37
            echo htmlspecialchars(shell_exec($cmd));
 
38
        }
 
39
    }
 
40
 
 
41
    echo '</pre></td></tr></table><br />';
 
42
}
 
43
?>
 
44
 
 
45
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">
 
46
<?php Util::pformInput() ?>
 
47
<textarea class="fixed" name="cmd" rows="10" cols="60">
 
48
<?php if (!empty($command)) echo htmlspecialchars($command) ?></textarea>
 
49
<br />
 
50
<input type="submit" class="button" value="<?php echo _("Execute") ?>">
 
51
<?php echo Help::link('admin', 'admin-cmdshell') ?>
 
52
 
 
53
</form>
 
54
<?php
 
55
 
 
56
require HORDE_TEMPLATES . '/common-footer.inc';