| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- <?php
- /*
- FusionPBX
- Version: MPL 1.1
- The contents of this file are subject to the Mozilla Public License Version
- 1.1 (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
- Software distributed under the License is distributed on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- for the specific language governing rights and limitations under the
- License.
- The Original Code is FusionPBX
- The Initial Developer of the Original Code is
- Mark J Crane <[email protected]>
- Portions created by the Initial Developer are Copyright (C) 2008-2012
- the Initial Developer. All Rights Reserved.
- Contributor(s):
- Mark J Crane <[email protected]>
- James Rose <[email protected]>
- */
- include "root.php";
- require_once "resources/require.php";
- require_once "resources/check_auth.php";
- if (permission_exists('exec_command_line') || permission_exists('exec_php_command') || permission_exists('exec_switch')) {
- //access granted
- }
- else {
- echo "access denied";
- exit;
- }
- //add multi-lingual support
- require_once "app_languages.php";
- foreach($text as $key => $value) {
- $text[$key] = $value[$_SESSION['domain']['language']['code']];
- }
- //get the html values and set them as variables
- if (count($_POST)>0) {
- $shell_cmd = trim($_POST["shell_cmd"]);
- $php_cmd = trim($_POST["php_cmd"]);
- $switch_cmd = trim($_POST["switch_cmd"]);
- }
- //show the header
- require_once "resources/header.php";
- //edit area
- echo " <script language=\"javascript\" type=\"text/javascript\" src=\"".PROJECT_PATH."/resources/edit_area/edit_area_full.js\"></script>\n";
- echo " <script language=\"Javascript\" type=\"text/javascript\">\n";
- echo " // initialisation //load,\n";
- echo " editAreaLoader.init({\n";
- echo " id: \"shell_cmd\" // id of the textarea to transform //, |, help\n";
- echo " ,start_highlight: false\n";
- echo " ,display: \"later\"\n";
- echo " ,font_size: \"8\"\n";
- echo " ,allow_toggle: true\n";
- echo " ,language: \"en\"\n";
- echo " ,syntax: \"html\"\n";
- echo " ,toolbar: \"search, go_to_line,|, fullscreen, |, undo, redo, |, select_font, |, syntax_selection, |, change_smooth_selection, highlight, reset_highlight, |, help\" //new_document,\n";
- echo " ,plugins: \"charmap\"\n";
- echo " ,charmap_default: \"arrows\"\n";
- echo " });\n";
- echo "\n";
- echo " editAreaLoader.init({\n";
- echo " id: \"php_cmd\" // id of the textarea to transform //, |, help\n";
- echo " ,start_highlight: false\n";
- echo " ,display: \"later\"\n";
- echo " ,font_size: \"8\"\n";
- echo " ,allow_toggle: true\n";
- echo " ,language: \"en\"\n";
- echo " ,syntax: \"php\"\n";
- echo " ,toolbar: \"search, go_to_line,|, fullscreen, |, undo, redo, |, select_font, |, syntax_selection, |, change_smooth_selection, highlight, reset_highlight, |, help\" //new_document,\n";
- echo " ,plugins: \"charmap\"\n";
- echo " ,charmap_default: \"arrows\"\n";
- echo " });\n";
- echo "\n";
- echo " editAreaLoader.init({\n";
- echo " id: \"switch_cmd\" // id of the textarea to transform //, |, help\n";
- echo " ,start_highlight: false\n";
- echo " ,display: \"later\"\n";
- echo " ,font_size: \"8\"\n";
- echo " ,allow_toggle: true\n";
- echo " ,language: \"en\"\n";
- echo " ,syntax: \"php\"\n";
- echo " ,toolbar: \"search, go_to_line,|, fullscreen, |, undo, redo, |, select_font, |, syntax_selection, |, change_smooth_selection, highlight, reset_highlight, |, help\" //new_document,\n";
- echo " ,plugins: \"charmap\"\n";
- echo " ,charmap_default: \"arrows\"\n";
- echo " });\n";
- echo " </script>";
- //show the header
- echo "<div align='center'>";
- echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
- echo "<tr>\n";
- echo "<td colspan='2' align='left' nowrap=\"nowrap\"><b>".$text['label-execute']."</b></td>\n";
- echo "</tr>\n";
- echo "<tr>\n";
- echo " <td align=\"left\" colspan='2'>\n";
- echo " ".$text['description-execute']."\n";
- echo " <br />\n";
- echo " <br />\n";
- echo " </td>\n";
- echo "</tr>\n";
- //show the result
- if (count($_POST)>0) {
- echo " <tr>\n";
- echo " <td colspan='2' align=\"left\">\n";
- //shell_cmd
- if (strlen($shell_cmd) > 0 && permission_exists('exec_command_line')) {
- echo "<b>$shell_cmd</b>\n";
- echo "<!--\n";
- $shell_result = shell_exec($shell_cmd);
- echo "-->\n";
- echo "<pre>";
- echo htmlentities($shell_result);
- echo "</pre>\n";
- }
- //php_cmd
- if (strlen($php_cmd) > 0 && permission_exists('exec_php_command')) {
- //echo "<b></b>\n";
- echo "<pre>";
- $php_result = eval($php_cmd);
- echo htmlentities($php_result);
- echo "</pre>\n";
- }
- //fs cmd
- if (strlen($switch_cmd) > 0 && permission_exists('exec_switch')) {
- echo "<b>$switch_cmd</b>\n";
- echo "<pre>";
- $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
- if ($fp) {
- $switch_result = event_socket_request($fp, 'api '.$switch_cmd);
- //$switch_result = eval($switch_cmd);
- echo htmlentities($switch_result);
- }
- echo "</pre>\n";
- }
- echo " <br />\n";
- echo " </td>\n";
- echo " </tr>";
- }
- //html form
- echo "<form method='post' name='frm' action=''>\n";
- if (permission_exists('exec_command_line')) {
- echo "<tr>\n";
- echo "<td class='vncell' valign='top' align='left' nowrap>\n";
- echo " ".$text['label-shell'].":\n";
- echo "</td>\n";
- echo "<td class='vtable' align='left'>\n";
- echo " <textarea name='shell_cmd' id='shell_cmd' rows='2' class='txt' wrap='off'>$shell_cmd</textarea\n";
- echo " <br />\n";
- echo " ".$text['description-shell']."\n";
- echo "</td>\n";
- echo "</tr>\n";
- }
- if (permission_exists('exec_php_command')) {
- echo "<tr>\n";
- echo "<td class='vncell' valign='top' align='left' nowrap>\n";
- echo " ".$text['label-php'].":\n";
- echo "</td>\n";
- echo "<td class='vtable' align='left'>\n";
- echo " <textarea name='php_cmd' id='php_cmd' rows='7' class='txt' wrap='off'>$php_cmd</textarea\n";
- echo " <br />\n";
- echo " ".$text['description-php']."</a>\n";
- echo "</td>\n";
- echo "</tr>\n";
- }
- if (permission_exists('exec_switch')) {
- echo "<tr>\n";
- echo "<td class='vncell' valign='top' align='left' nowrap>\n";
- echo " ".$text['label-switch'].":\n";
- echo "</td>\n";
- echo "<td class='vtable' align='left'>\n";
- echo " <textarea name='switch_cmd' id='switch_cmd' rows='2' class='txt' wrap='off'>$switch_cmd</textarea\n";
- echo " <br />\n";
- echo " ".$text['description-switch']."\n";
- echo "</td>\n";
- echo "</tr>\n";
- }
- echo " <tr>\n";
- echo " <td colspan='2' align='right'>\n";
- echo " <input type='submit' name='submit' class='btn' value='".$text['button-execute']."'>\n";
- echo " </td>\n";
- echo " </tr>";
- echo "</form>";
- echo "</table>";
- echo "</div>";
- //show the footer
- require_once "resources/footer.php";
- ?>
|