| [ PHPXref.com ] | [ Generated: Sun Jul 20 19:53:34 2008 ] | [ phpRemoteShell 0.5.1 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * Copyright (C) 2005-2006 4 * Emmanuel Saracco <esaracco@users.labs.libre-entreprise.org> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, 19 * Boston, MA 02111-1307, USA. 20 */ 21 22 /* Main configuration array */ 23 $config = array (); 24 25 /* //////////////////// BEGIN "CUSTOMIZE ME" SECTION \\\\\\\\\\\\\\\\\\\ */ 26 27 /* Authentication */ 28 define ('CHECK_AUTH', false); 29 define ('AUTH_USER', '!!change_me!!'); 30 define ('AUTH_PASSWORD', '!!change_me!!'); 31 32 /* Downloads management */ 33 $config['download'] = array ( 34 'application' => 'tar -cf - %s | gzip -c > %s', 35 'extension' => 'tar.gz', 36 'mime-type' => 'application/x-gtar' 37 ); 38 /* Remote informations */ 39 $config['rinfos'] = array ( 40 'System' => 'uname -a', 41 'Ids' => 'id', 42 'Shell' => 'echo $SHELL', 43 'Environment' => 'env', 44 'Apache' => 'apache -v', 45 'Apache2' => 'apache2 -v', 46 'Web server' => 'httpd -v', 47 'Web server 2' => 'http2d -v', 48 'Perl' => 'perl --version', 49 'Shell PHP' => 'php --version', 50 'MySQL' => 'mysql --version', 51 'PostgreSQL' => 'psql --version' 52 ); 53 54 /* //////////////////// END "CUSTOMIZE ME" SECTION \\\\\\\\\\\\\\\\\\\\ */ 55 56 /* Uniq index */ 57 $_uniq_code = 1; 58 59 /* Try to deactivate PHP magic quotes */ 60 ini_set ('magic_quotes_gpc', '0'); 61 62 /* Cookie */ 63 define ('COOKIE_NAME', 'prs'); 64 65 /* Application macros */ 66 define ('SHELL_APP_NAME', 'phpRemoteShell'); 67 define ('SHELL_APP_VERSION', '0.5.1'); 68 define ('POPUP_DEFAULT_Y', 90); 69 define ('POPUP_DEFAULT_X', 250); 70 71 /* Shell history macros */ 72 define ('SHELL_EXECUTE', $_uniq_code++); 73 define ('SHELL_HISTORY_EXECUTE', $_uniq_code++); 74 define ('SHELL_HISTORY_DELETE', $_uniq_code++); 75 76 /* Shell aliases macros */ 77 define ('SHELL_ALIASES_ADD', $_uniq_code++); 78 define ('SHELL_ALIASES_DELETE', $_uniq_code++); 79 80 /* Shell environment PATH macros */ 81 define ('SHELL_ENVPATH_ADD', $_uniq_code++); 82 define ('SHELL_ENVPATH_DELETE', $_uniq_code++); 83 84 /* Edit profiles macros */ 85 define ('EDIT_PROFILES_MAX', 5); 86 define ('EDIT_PROFILES_SAVE', $_uniq_code++); 87 define ('EDIT_PROFILES_LOAD', $_uniq_code++); 88 define ('EDIT_PROFILES_UPDATE', $_uniq_code++); 89 define ('EDIT_PROFILES_DELETE', $_uniq_code++); 90 91 /* Application notebooks macros */ 92 define ('SHELL_TYPE_SHELL', $_uniq_code++); 93 define ('SHELL_TYPE_PHP_CODE', $_uniq_code++); 94 define ('SHELL_TYPE_ABOUT', $_uniq_code++); 95 define ('SHELL_TYPE_REMOTE_INFOS', $_uniq_code++); 96 define ('SHELL_TYPE_FILE_BROWSER', $_uniq_code++); 97 98 /* Action menu */ 99 define ('ACTION_MENU_DELETE', $_uniq_code++); 100 define ('ACTION_MENU_DOWNLOAD', $_uniq_code++); 101 define ('ACTION_MENU_UPLOAD', $_uniq_code++); 102 103 /* Main menu */ 104 $config['main_menu'] = array ( 105 array ( 106 'label' => 'Edit', 107 'smenu' => array ( 108 array ( 109 'label' => 'Profiles', 110 'value' => 'profiles' 111 ) 112 ) 113 ), 114 array ( 115 'label' => "Remote information", 116 'value' => SHELL_TYPE_REMOTE_INFOS 117 ), 118 array ( 119 'label' => "Shell", 120 'value' => SHELL_TYPE_SHELL, 121 'smenu' => array ( 122 array ( 123 'label' => 'Command aliases', 124 'value' => 'aliases' 125 ), 126 array ( 127 'label' => 'Environment PATH', 128 'value' => 'envpath' 129 ) 130 ) 131 ), 132 array ( 133 'label' => "PHP code", 134 'value' => SHELL_TYPE_PHP_CODE, 135 /* Old version of PHP accept just one parameter for the 136 * "highlight_string" function. */ 137 'smenu' => (@highlight_string ('dum', true)) ? array ( 138 array ( 139 'label' => 'Highlight code', 140 'value' => 'highlight' 141 ) 142 ) : null 143 ), 144 array ( 145 'label' => "File browser", 146 'value' => SHELL_TYPE_FILE_BROWSER, 147 'smenu' => array ( 148 array ( 149 'label' => 'Initial path', 150 'value' => 'initpath' 151 ) 152 ) 153 ), 154 array ( 155 'label' => "About", 156 'value' => SHELL_TYPE_ABOUT 157 ) 158 ); 159 160 /* Main class */ 161 class PhpRemoteShell 162 { 163 var $vars = array (); 164 var $sav_vars = array (); 165 var $config = array (); 166 167 function PhpRemoteShell ($config) 168 { 169 $this->check_auth (CHECK_AUTH); 170 171 $this->config = $config; 172 173 $this->get_all_values (); 174 175 $this->action (); 176 } 177 178 function get_all_values () 179 { 180 foreach (array ( 181 'display_type', 182 'show_hide_aliases', 183 'show_hide_envpath', 184 'show_hide_initpath', 185 'show_hide_highlight', 186 'show_hide_profiles', 187 'profile_current', 188 'profiles_index', 189 'profile_name', 190 'profiles_box_x', 191 'profiles_box_y', 192 'command', 193 'command_current', 194 'env_current_path', 195 'phpcode_current', 196 'history_index', 197 'envpath_index', 198 'action_requested', 199 'action_type', 200 'action_result', 201 'dir_current', 202 'file_current_rights', 203 'is_nav', 204 'alias_name', 205 'alias_value', 206 'envpath_value', 207 'file_browser_initpath', 208 'aliases_box_x', 209 'aliases_box_y', 210 'envpath_box_x', 211 'envpath_box_y', 212 'initpath_box_x', 213 'initpath_box_y', 214 'highlight_box_x', 215 'highlight_box_y', 216 'command_current_output' 217 218 ) as $var) 219 if (!isset ($this->vars[$var])) 220 $this->vars[$var] = $this->utf8_decode ($this->_get_http_var ($var)); 221 222 if (!isset ($this->vars['history'])) 223 { 224 if ($tmp = $this->_get_http_var ('history')) 225 $this->vars['history'] = (array) $this->form_unserialize ($tmp); 226 else 227 $this->vars['history'] = array (); 228 } 229 230 if (!isset ($this->vars['aliases'])) 231 { 232 if ($tmp = $this->_get_http_var ('aliases')) 233 $this->vars['aliases'] = (array) $this->form_unserialize ($tmp); 234 else 235 $this->vars['aliases'] = array (); 236 } 237 238 if (!isset ($this->vars['envpath'])) 239 { 240 if ($tmp = $this->_get_http_var ('envpath')) 241 $this->vars['envpath'] = (array) $this->form_unserialize ($tmp); 242 else 243 $this->vars['envpath'] = array (); 244 } 245 246 if (!isset ($this->vars['profiles'])) 247 { 248 if ($tmp = $this->_get_http_var ('profiles')) 249 $this->vars['profiles'] = (array) $this->form_unserialize ($tmp); 250 else 251 $this->vars['profiles'] = array (); 252 } 253 254 if (!isset ($this->vars['choice'])) 255 { 256 if ($ref1 =& $this->_get_http_var ('choice')) 257 $this->vars['choice'] =& $ref1; 258 } 259 260 if (!isset ($this->vars['www_user'])) 261 { 262 list ($this->vars['www_user'], $this->vars['www_group']) = 263 $this->get_www_user_infos (); 264 } 265 266 $this->_normalize_envpath (); 267 $this->_normalize_aliases (); 268 $this->_normalize_initpath (); 269 $this->_normalize_profiles (); 270 $this->_normalize_dir_current (); 271 $this->_normalize_profile_name (); 272 273 $this->_normalize_box_pos ('aliases'); 274 $this->_normalize_box_pos ('envpath'); 275 $this->_normalize_box_pos ('initpath'); 276 $this->_normalize_box_pos ('profiles'); 277 $this->_normalize_box_pos ('highlight'); 278 } 279 280 function check_safe_mode () 281 { 282 return ini_get ('safe_mode'); 283 } 284 285 function check_auth ($check) 286 { 287 if (!$check) return; 288 289 if ( 290 !isset ($_SERVER['PHP_AUTH_USER']) || 291 $_SERVER['PHP_AUTH_USER'] != AUTH_USER || 292 !isset ($_SERVER['PHP_AUTH_PW']) || 293 $_SERVER['PHP_AUTH_PW'] != AUTH_PASSWORD) 294 { 295 header ('HTTP/1.1 401 Authorization Required'); 296 header ('Date: ' . gmdate ('D, d M Y H:i:s') . ' GMT'); 297 header ('WWW-Authenticate: Basic realm="PRS"'); 298 header ('Connection: close'); 299 header ('Content-Type: text/html; charset=iso-8859-1'); 300 301 if ($_SERVER['PHP_AUTH_USER'] != AUTH_USER || 302 $_SERVER['PHP_AUTH_PW'] != AUTH_PASSWORD) exit (1); 303 } 304 } 305 306 function get_www_user_infos () 307 { 308 $this->_save_user_inputs (); 309 310 $this->_reset_user_inputs (); 311 $this->vars['command_current'] = "id -un"; 312 $this->command_current_execute (); 313 $user = $this->vars['command_current_output']; 314 315 $this->_reset_user_inputs (); 316 $this->vars['command_current'] = "id -gn"; 317 $this->command_current_execute (); 318 $group = $this->vars['command_current_output']; 319 320 $this->_restore_user_inputs (); 321 322 return array (trim ($user), trim ($group)); 323 } 324 325 function setCookie ($key, $value) 326 { 327 $cookie = ''; 328 329 if (!empty ($value)) 330 $cookie = base64_encode (serialize ($value)); 331 332 setcookie ($key, $cookie, mktime (0, 0, 0, 1, 1, 2035), '/'); 333 } 334 335 function getCookie ($key) 336 { 337 if (!isset ($_COOKIE[$key]) || empty ($_COOKIE[$key])) 338 return ''; 339 340 $cookie = $_COOKIE[$key]; 341 $cookie = unserialize (base64_decode ($cookie)); 342 343 return $cookie; 344 } 345 346 function array_clean_for_cookie ($arr) 347 { 348 foreach ($arr as $k => $v) 349 { 350 if ( 351 empty ($v) || 352 strpos ($k, 'profile') !== false || 353 $k == 'action_requested' || 354 $k == 'www_group' || 355 $k == 'www_user') 356 unset ($arr[$k]); 357 elseif (is_array ($v)) 358 { 359 if (!count ($v)) 360 unset ($arr[$k]); 361 else 362 $this->array_clean_for_cookie ($arr[$k]); 363 } 364 } 365 366 return $arr; 367 } 368 369 function save_profile ($name) 370 { 371 $value = $this->array_clean_for_cookie ($this->vars); 372 $this->setCookie (COOKIE_NAME . "_$name", $value); 373 } 374 375 function update_profile ($name) 376 { 377 $this->save_profile ($name); 378 } 379 380 function delete_profile ($name) 381 { 382 $this->setCookie (COOKIE_NAME . "_$name", ''); 383 } 384 385 function load_profile ($name) 386 { 387 $vars_sav = $this->vars; 388 389 $value = $this->getCookie (COOKIE_NAME . "_$name"); 390 if (is_array ($value)) 391 $this->vars = $value; 392 393 $this->vars['profiles'] = $this->get_profiles (); 394 foreach ($vars_sav as $k => $v) 395 if (strpos ($k, 'profile') !== false) 396 $this->vars[$k] = $v; 397 398 $this->get_all_values (); 399 } 400 401 function get_profiles () 402 { 403 $profiles = array (); 404 405 foreach ($_COOKIE as $k => $v) 406 if (strpos ($k, COOKIE_NAME . '_') !== false) 407 { 408 $k = substr ($k, 4, strlen ($k) - 3); 409 $profiles[$k] = $k; 410 } 411 412 return $profiles; 413 } 414 415 function form_serialize ($val) 416 { 417 return base64_encode (serialize ($val)); 418 } 419 420 function form_unserialize ($val) 421 { 422 return unserialize (base64_decode ($val)); 423 } 424 425 function form_get_serialize ($name) 426 { 427 return $this->form_serialize ($this->vars[$name]); 428 } 429 430 function get_show_hide ($name) 431 { 432 if ( 433 $this->vars["show_hide_$name"] != 'hidden' && 434 $this->vars["show_hide_$name"] != 'visible' 435 ) 436 $this->vars["show_hide_$name"] = 'hidden'; 437 438 return $this->vars["show_hide_$name"]; 439 } 440 441 function get_display_type () 442 { 443 return $this->vars['display_type']; 444 } 445 446 function get_profile_current () 447 { 448 return $this->vars['profile_current']; 449 } 450 451 function get_command_current () 452 { 453 return $this->vars['command_current']; 454 } 455 456 function get_phpcode_current () 457 { 458 if (!$this->phpcode_current_exists ()) return ''; 459 460 if (!preg_match ("/;$/", $this->vars['phpcode_current'])) 461 $this->vars['phpcode_current'] .= ';'; 462 463 return $this->vars['phpcode_current']; 464 } 465 466 function history_exists () 467 { 468 return ( 469 is_array ($this->vars['history']) && 470 count ($this->vars['history']) > 0 471 ); 472 } 473 474 function command_current_exists () 475 { 476 return ($this->vars['command_current'] != ''); 477 } 478 479 function phpcode_current_exists () 480 { 481 return ($this->vars['phpcode_current'] != ''); 482 } 483 484 function cmd_replace_aliases ($cmd) 485 { 486 if (preg_match_all ('/\$([a-z,_,0-9]+)/', $cmd, $matches)) 487 { 488 foreach ($matches[1] as $alias) 489 { 490 if (isset ($this->vars['aliases'][$alias])) 491 $cmd = preg_replace ("/\\$$alias/", 492 $this->vars['aliases'][$alias], $cmd); 493 } 494 } 495 496 return $cmd; 497 } 498 499 function action () 500 { 501 $this->vars['command_current'] = ''; 502 503 sort ($this->vars['history']); 504 sort ($this->vars['envpath']); 505 sort ($this->vars['profiles']); 506 507 switch ($this->vars['action_requested']) 508 { 509 /* SHELL */ 510 511 /* History */ 512 513 case SHELL_EXECUTE: 514 515 $this->vars['command_current'] = $this->vars['command']; 516 break; 517 518 case SHELL_HISTORY_EXECUTE: 519 520 $this->vars['command_current'] = 521 $this->vars['history'][$this->vars['history_index']]; 522 break; 523 524 case SHELL_HISTORY_DELETE: 525 526 unset ($this->vars['history'][$this->vars['history_index']]); 527 break; 528 529 /* Aliases */ 530 531 case SHELL_ALIASES_ADD: 532 533 $name = trim ($this->vars['alias_name']); 534 $value = trim ($this->vars['alias_value']); 535 536 if (!empty ($name) && !empty ($value)) 537 $this->vars['aliases'][$name] = $value; 538 break; 539 540 case SHELL_ALIASES_DELETE: 541 542 unset ($this->vars['aliases'][$this->vars['alias_name']]); 543 break; 544 545 /* Environment PATH */ 546 547 case SHELL_ENVPATH_ADD: 548 $value = trim ($this->vars['envpath_value']); 549 550 if (!empty ($value) && !in_array ($value, $this->vars['envpath'])) 551 array_push ($this->vars['envpath'], $value); 552 break; 553 554 case SHELL_ENVPATH_DELETE: 555 unset ($this->vars['envpath'][$this->vars['envpath_index']]); 556 break; 557 558 /* EDIT */ 559 560 /* Profile */ 561 562 case EDIT_PROFILES_SAVE: 563 $name = trim ($this->vars['profile_name']); 564 565 if (strlen ($name) && !in_array ($name, $this->vars['profiles'])) 566 { 567 array_push ($this->vars['profiles'], $name); 568 $this->vars['profile_current'] = $name; 569 570 $this->save_profile ($name); 571 } 572 break; 573 574 case EDIT_PROFILES_UPDATE: 575 $this->update_profile ( 576 $this->vars['profiles'][$this->vars['profiles_index']]); 577 break; 578 579 case EDIT_PROFILES_LOAD: 580 $this->load_profile ( 581 $this->vars['profiles'][$this->vars['profiles_index']]); 582 break; 583 584 case EDIT_PROFILES_DELETE: 585 $name = $this->vars['profiles'][$this->vars['profiles_index']]; 586 587 unset ($this->vars['profiles'][$this->vars['profiles_index']]); 588 589 $this->delete_profile ($name); 590 591 if ($this->vars['profile_current'] == $name) 592 $this->vars['profile_current'] = ''; 593 break; 594 } 595 596 if ($this->command_current_exists ()) 597 { 598 $this->vars['command_current'] = 599 $this->cmd_replace_aliases ($this->vars['command_current']); 600 601 if (!in_array ($this->vars['command_current'], $this->vars['history'])) 602 array_push ($this->vars['history'], $this->vars['command_current']); 603 } 604 605 if ($this->vars['is_nav'] != 1 && $this->vars['action_type'] != '') 606 { 607 if (isset ($this->vars['choice']) && count ($this->vars['choice'])) 608 { 609 switch ($this->vars['action_type']) 610 { 611 case ACTION_MENU_DELETE: 612 613 $this->vars['action_result'] = 614 $this->_delete_files ($this->vars['choice']); 615 break; 616 617 case ACTION_MENU_DOWNLOAD: 618 619 $this->vars['action_result'] = 620 $this->_download_files ($this->vars['choice']); 621 } 622 } 623 elseif ($this->vars['action_type'] == ACTION_MENU_UPLOAD) 624 $this->vars['action_result'] = $this->_upload_file (); 625 } 626 627 sort ($this->vars['profiles']); 628 sort ($this->vars['envpath']); 629 sort ($this->vars['history']); 630 } 631 632 function get_action_result_html () 633 { 634 return "<p>" . $this->vars['action_result'] . "</p>"; 635 } 636 637 function _upload_file () 638 { 639 if (!isset ($_FILES) || !$_FILES["upload_file"]["tmp_name"]) return; 640 641 $src = $_FILES["upload_file"]["tmp_name"]; 642 $dest = $this->vars['dir_current'] . "/" . $_FILES["upload_file"]["name"]; 643 644 move_uploaded_file ($src, $dest); 645 } 646 647 function _download_files (&$files) 648 { 649 $output = ''; 650 651 $output = " 652 <table> 653 <tr><th colspan=2 class='caption'>Result</th></tr> 654 <tr class='header'><th>Action</th><th>Message</th></tr> 655 "; 656 657 $src = ''; 658 $dst = 659 "/tmp/.prs-tmp-" . rand () . '.' . 660 $this->config['download']['extension']; 661 662 foreach ($files as $f) 663 $src .= "$f "; 664 665 $cmd = sprintf ($this->config['download']['application'], 666 "$src 2> /dev/null ", "$dst 2> /dev/null"); 667 668 $this->_save_user_inputs (); 669 $this->_reset_user_inputs (); 670 $this->vars['command_current'] = $cmd; 671 $this->command_current_execute (); 672 $this->_restore_user_inputs (); 673 674 $this->_send_file ($dst, true); 675 676 return $output; 677 } 678 679 function _send_file ($file, $delete_after) 680 { 681 header ('Content-Type: ' . $this->config['download']['mime-type']); 682 header ('Content-Length: ' . filesize ($file)); 683 header ('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT'); 684 685 if (strstr ($_SERVER['HTTP_USER_AGENT'], 'MSIE')) 686 { 687 header ('Content-Disposition: inline; filename="prs_download.' . 688 $this->config['download']['extension'] . '"'); 689 header ('Cache-Control: must-revalidate, post-check=0, pre-check=0'); 690 header ('Pragma: public'); 691 } 692 else 693 { 694 header ('Content-Disposition: attachment; filename="prs_download.' . 695 $this->config['download']['extension'] . '"'); 696 header ('Pragma: no-cache'); 697 } 698 699 $h = fopen ($file, 'r'); 700 while ($data = fread ($h, 8192)) 701 print $data; 702 fclose ($h); 703 704 if ($delete_after) 705 unlink ($file); 706 707 exit (0); 708 } 709 710 function _delete_files (&$files) 711 { 712 $output = ''; 713 714 $output = " 715 <table> 716 <tr><th colspan=2 class='caption'>Result</th></tr> 717 <tr class='header'><th>Action</th><th>Message</th></tr> 718 "; 719 720 $this->_save_user_inputs (); 721 $row_color = ''; 722 foreach ($files as $file) 723 { 724 $row_color = ($row_color == 'odd') ? 'even' : 'odd'; 725 $output .= "<tr class='$row_color'>"; 726 $output .= "<td class='label'>Deleting $file:</td>"; 727 $this->_reset_user_inputs (); 728 $this->vars['command_current'] = 'rm -vrf ' . 729 escapeshellarg ($file); 730 $this->command_current_execute (); 731 $output .= "<td class='value'>" . 732 $this->vars['command_current_output'] . "</td>"; 733 $output .= "</tr>"; 734 } 735 $this->_restore_user_inputs (); 736 737 $output .= "</table>"; 738 739 if (!is_file ($this->vars['dir_current']) && 740 !is_dir ($this->vars['dir_current'])) 741 $this->vars['dir_current'] = dirname ($this->vars['dir_current']); 742 743 return $output; 744 } 745 746 function _save_user_inputs () 747 { 748 $this->sav_vars = base64_encode (serialize ($this->vars)); 749 } 750 751 function _restore_user_inputs () 752 { 753 $this->vars = unserialize (base64_decode ($this->sav_vars)); 754 } 755 756 function _reset_user_inputs () 757 { 758 $this->vars['command_current'] = ''; 759 $this->vars['command_current_output'] = ''; 760 } 761 762 function get_menu_html () 763 { 764 $output = ''; 765 766 $output = "<table class='menu'><tr>"; 767 $i = 0; 768 foreach ($this->config['main_menu'] as $m) 769 { 770 $smenu = ($i++) . '_' . 'smenu'; 771 772 if (isset ($m['value']) && $m['value']) 773 $output .= sprintf (" 774 <td><div class=\"menu\" %s 775 onMouseOut=\"%s\" 776 onMouseOver=\"this.style.cursor = 'default'; 777 this.style.color='yellow';menu_show('$smenu')\" 778 onClick=\"document.forms[0].display_type.value='%s'; 779 document.forms[0].action_requested.value=''; 780 document.forms[0].action_type.value=''; 781 document.forms[0].dir_current.value=''; 782 _submit()\">%s</div>", 783 (($this->vars['display_type'] == $m['value']) ? 784 ' style="color: yellow" ' : ''), 785 (($this->vars['display_type'] == $m['value']) ? 786 '' : "this.style.color='cornflowerblue'"), 787 $m['value'], 788 $m['label'] 789 ); 790 else 791 $output .= sprintf (" 792 <td><div class=\"menu\" 793 onMouseOver=\"this.style.cursor = 'default'; 794 menu_show('$smenu')\">%s</div>", 795 $m['label'] 796 ); 797 798 if (isset ($m['smenu']) && is_array ($m['smenu'])) 799 { 800 $output .= " 801 <div id=\"$smenu\" class=\"smenu\" 802 style=\"visibility: hidden;position: absolute;\" 803 onMouseOver=\"menu_show('$smenu')\" 804 onMouseOut=\"menu_hide('$smenu')\"> 805 "; 806 807 foreach ($m['smenu'] as $sm) 808 { 809 $output .= " 810 <table><tr><td><input onClick=\"show_hide('" . $sm['value'] . 811 "', " . $sm['value'] . "_cb);\" type=\"checkbox\" name=\"" . 812 $sm['value'] . "_cb\"" . 813 (($this->get_show_hide ($sm['value']) == 'hidden') ? 814 '' : ' checked') . "></td> 815 <td nowrap><a href=\"javascript:show_hide('" . $sm['value'] . 816 "', document.forms[0]." . $sm['value'] . "_cb);\">" . 817 $sm['label'] . "</a></td></tr></table>"; 818 } 819 820 $output .= "</div>"; 821 } 822 823 $output .= "</td>"; 824 } 825 826 $output .= "</tr></table>"; 827 return $output; 828 } 829 830 function get_safe_mode_alert_html ($type = 'all') 831 { 832 $output = " 833 PHP <b>safe_mode</b> is <font color=\"red\"><b>activated</b></font>. 834 <br /> 835 "; 836 837 switch ($type) 838 { 839 case 'all': $output .= "This feature has been disabled.";break; 840 case 'some': $output .= "Some operations will certainly fail.";break; 841 } 842 843 return $output; 844 } 845 846 function get_remote_infos_html () 847 { 848 $infos = array (); 849 850 $this->_save_user_inputs (); 851 foreach ($this->config['rinfos'] as $k => $v) 852 { 853 $this->_reset_user_inputs (); 854 $this->vars['command_current'] = $v; 855 $this->command_current_execute (); 856 if ($this->vars['command_current_output'] != '' && 857 /* FIXME */ 858 !strstr ($this->vars['command_current_output'], 'not found') && 859 !strstr ($this->vars['command_current_output'], 'such file')) 860 $infos[$k] = $this->vars['command_current_output']; 861 } 862 $this->_restore_user_inputs (); 863 864 $output = " 865 <table> 866 <tr><th colspan=2 class='caption'>Some remote information</th></tr> 867 <tr class='header'><th>Name</th><th>Value</th></tr> 868 "; 869 870 foreach ($infos as $k => $v) 871 { 872 $output .= "<tr><td class='label'>$k</td><td>"; 873 $v = chop ($v); 874 if (strchr ($v, "\n")) 875 { 876 $infos1 = explode ("\n", $v); 877 $output .= "<table>"; 878 foreach ($infos1 as $v1) 879 { 880 if (strchr ($v1, '=')) 881 { 882 list ($k2, $v2) = explode ('=', $v1); 883 $output .= "<tr><td class='label'>$k2</td><td>$v2</td></tr>"; 884 } 885 elseif ($v1) 886 $output .= "<tr><td>$v1</td></tr>"; 887 } 888 $output .= "</table>"; 889 } 890 else 891 $output .= "$v</td>"; 892 893 $output .= "</tr>"; 894 } 895 $output .= "</table>"; 896 897 return $output; 898 } 899 900 function get_dir_current () 901 { 902 return $this->vars['dir_current']; 903 } 904 905 function get_file_current_rights () 906 { 907 return $this->vars['file_current_rights']; 908 } 909 910 function _get_browse_path () 911 { 912 $path = ''; 913 $output = ''; 914 915 $p = $this->vars['dir_current']; 916 917 for ($i = 0; $i < strlen ($p); $i++) 918 { 919 if ($p[$i] != '/') 920 { 921 $path .= $p[$i]; 922 $name .= $p[$i]; 923 } 924 else 925 { 926 $output .= ($path) ? 927 " <input type='button' class='file_browser_path' 928 onClick=\"action_type.value='';" . 929 "dir_current.value='$path';_submit()\" value=\"$name\" />" : 930 " <input type='button' class='file_browser_path' 931 onClick=\"action_type.value='';" . 932 "dir_current.value='/';_submit()\" value=\"/\" />"; 933 $path .= '/'; 934 $name = ''; 935 } 936 } 937 938 return $output; 939 } 940 941 function get_file_data_from_line ($line) 942 { 943 $arr = preg_split ("/\s+/", $line, 9); 944 945 /* Not a valid data */ 946 if (count ($arr) <= 3) return null; 947 948 /* For the moment we do not manage devices */ 949 if ($this->_is_device ($arr[0])) return null; 950 951 /* A problem with env PATH? */ 952 if (!isset ($arr[5])) return null; 953 954 /* To fix a problem with some system 'ls' output */ 955 if (preg_match ("/^([0-9]{4}.[0-9]{2}).([0-9]{2})$/", 956 $arr[5], $matches)) 957 { 958 $arr[8] = $arr[7]; 959 $arr[7] = $arr[6]; 960 $arr[5] = $matches[1]; 961 $arr[6] = $matches[2]; 962 } 963 964 return $arr; 965 } 966 967 function _normalize_profile_name () 968 { 969 $name = $this->vars['profile_name']; 970 $name = preg_replace ('#[\=,\,,\s,\013,\014]#', '_', $name); 971 $this->vars['profile_name'] = $name; 972 } 973 974 function _normalize_box_pos ($name) 975 { 976 if (!$this->vars[$name . '_box_x'] && !$this->vars[$name . '_box_y']) 977 { 978 $this->vars[$name . '_box_x'] = POPUP_DEFAULT_X . 'px'; 979 $this->vars[$name . '_box_y'] = POPUP_DEFAULT_Y . 'px'; 980 } 981 } 982 983 function _normalize_envpath () 984 { 985 /* Default env PATH */ 986 if (count ($this->vars['envpath']) == 0) 987 $this->vars['envpath'] = array ( 988 '/bin', 989 '/sbin', 990 '/usr/bin', 991 '/usr/sbin', 992 '/usr/local/bin', 993 '/usr/local/sbin' 994 ); 995 } 996 997 function _normalize_profiles () 998 { 999 if (count ($this->vars['profiles']) == 0) 1000 $this->vars['profiles'] = $this->get_profiles (); 1001 } 1002 1003 function _normalize_aliases () 1004 { 1005 /* Default aliases */ 1006 if (count ($this->vars['aliases']) == 0) 1007 $this->vars['aliases'] = array ( 1008 'ls' => 'ls -al', 1009 ); 1010 } 1011 1012 function _normalize_dir_current () 1013 { 1014 $path = trim ($this->vars['dir_current']); 1015 1016 if (empty ($path)) 1017 $path = $this->vars['file_browser_initpath']; 1018 1019 $path = preg_replace ("/^\/\.\.$/", '', $path); 1020 1021 if (preg_match ("/^(.*)\/[^\/]+\/\.\.$/", $path, $sub)) 1022 $path = $sub[1]; 1023 1024 $path = preg_replace ("/\/\.$/", '', $path); 1025 1026 $this->vars['dir_current'] = $path; 1027 } 1028 1029 function _normalize_initpath () 1030 { 1031 $path = trim ($this->vars['file_browser_initpath']); 1032 1033 if (!ereg ('\/$', $path)) $path .= '/'; 1034 if (!ereg ('^\/', $path)) $path = "/$path"; 1035 $path = ereg_replace ('[\/\/]+', '/', $path); 1036 1037 if (strpos ($path, '.') !== false || !is_dir ($path)) 1038 $path = '/'; 1039 1040 $this->vars['file_browser_initpath'] = $path; 1041 } 1042 1043 function get_file_browser_initpath () 1044 { 1045 return $this->vars['file_browser_initpath']; 1046 } 1047 1048 function get_browse_dir () 1049 { 1050 $can_write = true; 1051 $can_write_some = false; 1052 $can_read = true; 1053 $can_upload = null; 1054 1055 /* If link come from a symlink name */ 1056 if (preg_match ("/^(.*?)\s+\-\>\s+(.*?)$/", 1057 $this->vars['dir_current'], $matches)) 1058 { 1059 $symlink = $matches[1]; 1060 $reallink = $matches[2]; 1061 $dir = dirname ($symlink); 1062 if ($dir == '/' || $reallink[0] == '/') 1063 $dir = ''; 1064 1065 $newfile = "$dir/$reallink"; 1066 $newfile = ereg_replace ('/+', '/', $newfile); 1067 1068 /* Retreive new file rights */ 1069 $this->_save_user_inputs (); 1070 $this->_reset_user_inputs (); 1071 $this->vars['command_current'] = 'ls -l ' . escapeshellarg ($newfile); 1072 $this->command_current_execute (); 1073 $tmp = $this->vars['command_current_output']; 1074 $this->_restore_user_inputs (); 1075 $this->vars['dir_current'] = $newfile; 1076 1077 $arr = $this->get_file_data_from_line ($tmp); 1078 $this->vars['file_current_rights'] = "$arr[2],$arr[3],$arr[0]"; 1079 } 1080 1081 if (is_file ($this->vars['dir_current'])) 1082 { 1083 $arr = explode (',', $this->vars['file_current_rights']); 1084 $can_write = $this->_can_write_file ($arr[0], $arr[1], $arr[2]); 1085 $can_write_some = $can_write; 1086 $can_read = $this->_can_read_file ($arr[0], $arr[1], $arr[2]); 1087 printf ("<p>%s</p>", $this->_get_browse_path ()); 1088 1089 $dir = $this->vars['dir_current']; 1090 $this->_save_user_inputs (); 1091 $this->_reset_user_inputs (); 1092 $this->vars['command_current'] = 'file ' . escapeshellarg ($dir); 1093 $this->command_current_execute (); 1094 $tmp = $this->vars['command_current_output']; 1095 $this->_restore_user_inputs (); 1096 1097 if (!preg_match ("/(text|ASCII|PHP|HTML|perl)/", $tmp)) 1098 { 1099 printf (" 1100 <input type='hidden' name='choice[]' value=\"%s\" /> 1101 <span class='title_file'>%s</span> 1102 <p>%s</p> 1103 <pre>%s</pre>", 1104 $this->htmlentities ($this->vars['dir_current']), 1105 basename ($dir), 1106 (strstr ($tmp, " empty")) ? 1107 "This is a empty file:" : 1108 "You can not view this file content:", 1109 $tmp 1110 ); 1111 } 1112 else 1113 { 1114 $this->vars['command_current'] = 'cat ' . 1115 escapeshellarg ($this->vars['dir_current']); 1116 $this->command_current_execute (); 1117 1118 $toolong = false; 1119 if (strlen ($this->vars['command_current_output']) > 5000) 1120 { 1121 $toolong = true; 1122 $this->vars['command_current_output'] = 1123 substr ($this->vars['command_current_output'], 0, 5000) . 1124 "\n[...]"; 1125 } 1126 1127 printf (" 1128 %s 1129 <input type='hidden' name='choice[]' value=\"%s\" /> 1130 <pre>%s</pre><pre>%s</pre>", 1131 ($toolong) ? 1132 "File too long to be displayed entirely (max. 5000 chars)." : '', 1133 $this->vars['dir_current'], 1134 $this->htmlentities ($this->vars['dir_current']), 1135 $this->htmlentities ($this->vars['command_current_output']) 1136 ); 1137 } 1138 } 1139 else 1140 { 1141 if (!preg_match ("/\/$/", $this->vars['dir_current'])) 1142 $this->vars['dir_current'] .= '/'; 1143 if (!preg_match ("/^\//", $this->vars['dir_current'])) 1144 $this->vars['dir_current'] = '/' . $this->vars['dir_current']; 1145 1146 printf ("<p>%s</p>", $this->_get_browse_path ()); 1147 1148 $this->vars['command_current'] = 'ls -al ' . 1149 escapeshellarg ($this->vars['dir_current']); 1150 $this->vars['command_current_output'] = ''; 1151 $this->command_current_execute (); 1152 1153 print '<table class="file_browser">'; 1154 print " 1155 <th> </th> 1156 <th colspan=2>Rights</th> 1157 <th>User</th> 1158 <th>Group</th> 1159 <th>Size</th> 1160 <th>Month</th> 1161 <th>Day</th> 1162 <th>Time</th> 1163 <th>Name</th> 1164 "; 1165 1166 $row_color = ''; 1167 foreach (explode ("\n", $this->vars['command_current_output']) as $l) 1168 { 1169 $arr = $this->get_file_data_from_line ($l); 1170 if (!$arr || !isset ($arr[8])) continue; 1171 1172 if ($can_upload == null && $arr[8] == ".") 1173 $can_upload = $this->_can_write_file ($arr[2], $arr[3], $arr[0]); 1174 1175 if (!empty ($arr[8])) 1176 { 1177 if ($this->_can_write_file ($arr[2], $arr[3], $arr[0]) && 1178 !$this->_is_symlink ($arr[0]) && !$this->_is_socket ($arr[0])) 1179 { 1180 $class_color = 'rights_write'; 1181 if (!$can_write_some) 1182 $can_write_some = true; 1183 } 1184 else if ($this->_can_read_file ($arr[2], $arr[3], $arr[0])) 1185 $class_color = 'rights_read'; 1186 else 1187 $class_color = 'rights_bad'; 1188 1189 $file_path = $this->vars['dir_current'] . $arr[8]; 1190 $file_path = addslashes ($file_path); 1191 1192 $value = ($this->_is_directory ($arr[0])) ? "[$arr[8]]/" : $arr[8]; 1193 $row_color = ($row_color == 'odd') ? 'even' : 'odd'; 1194 print "<tr class='$row_color'><td width='1%'>"; 1195 if ($class_color != 'rights_bad' && 1196 $arr[8] != '.' && $arr[8] != '..') 1197 print " 1198 <input type=\"checkbox\" name=\"choice[]\" 1199 value=\"" . addslashes ($this->htmlentities ($file_path)) . 1200 "\" />"; 1201 else 1202 print ' '; 1203 1204 print " 1205 </td> 1206 <td width='1%' class='$class_color'> </td> 1207 <td width='9%'>$arr[0]</td> 1208 <td width='10%'>$arr[2]</td> 1209 <td width='10%'>$arr[3]</td> 1210 <td width='5%'>$arr[4]</td> 1211 <td width='5%'>$arr[5]</td> 1212 <td width='5%'>$arr[6]</td> 1213 <td width='5%'>$arr[7]</td> 1214 <td width='40%' class='name'>"; 1215 1216 if ($class_color != "rights_bad" && !$this->_is_socket ($arr[0])) 1217 print " 1218 <input type='button' class='file_browser' 1219 onClick=\"is_nav.value=1;" . 1220 "file_current_rights.value='" . 1221 "$arr[2],$arr[3],$arr[0]" . 1222 "';dir_current.value='" . 1223 addslashes ($this->htmlentities ($file_path)) . "';_submit()\" 1224 value=\"" . 1225 addslashes ($this->htmlentities ($value)) . "\" /></td></tr>"; 1226 else 1227 print $this->htmlentities ($value); 1228 } 1229 } 1230 print '</table>'; 1231 } 1232 1233 print " 1234 <p><table class='file_browser_menu'><tr> 1235 <td><input " . 1236 (($can_read) ? "" : " class=\"disabled\" disabled") . 1237 " type='button' onClick=\"dir_current.value='" . 1238 addslashes ($this->htmlentities ($this->vars['dir_current'])) . 1239 "';action_type.value='" . ACTION_MENU_DOWNLOAD . 1240 "';_submit();\" value='Download' /></td>"; 1241 1242 if (!is_file ($this->vars['dir_current'])) 1243 { 1244 print " 1245 <td> 1246 <input type='file' name='upload_file' " . 1247 (($can_upload) ? "" : " class=\"disabled\" disabled") . "><br /> 1248 <input " . (($can_upload) ? 1249 "" : " class=\"disabled\" disabled ") . " type='button' 1250 onClick=\"dir_current.value='" . 1251 addslashes ($this->htmlentities ($this->vars['dir_current'])) . 1252 "';action_type.value='" . ACTION_MENU_UPLOAD . 1253 "';_submit();\" value='Upload' /></td>"; 1254 } 1255 1256 print " 1257 <td><input " . (($can_write_some) ? 1258 '' : " class=\"disabled\" disabled") . 1259 " type='button' 1260 onClick=\"dir_current.value='" . 1261 addslashes ($this->htmlentities ($this->vars['dir_current'])) . 1262 "';action_type.value='" . ACTION_MENU_DELETE . 1263 "';_submit();\" value='Delete' /></td>"; 1264 1265 print "</tr></table></p>"; 1266 } 1267 1268 function _is_symlink ($rights) 1269 { 1270 return ($rights{0} == 'l'); 1271 } 1272 1273 function _is_socket ($rights) 1274 { 1275 return ($rights{0} == 's'); 1276 } 1277 1278 function _can_write_file ($user, $group, $rights) 1279 { 1280 return ( 1281 $rights && ( 1282 /* write for all */ 1283 ($rights[8] == 'w' && $rights[9] != 't') || 1284 /* write for group */ 1285 ($rights[5] == 'w' && $this->vars['www_group'] == $group) || 1286 /* write for owner */ 1287 ($rights[2] == 'w' && $this->vars['www_user'] == $user)) 1288 ); 1289 } 1290 1291 function _can_read_file ($user, $group, $rights) 1292 { 1293 return ( 1294 $rights && ( 1295 /* read for all */ 1296 ($rights[7] == 'r') || 1297 /* read for group */ 1298 ($rights[4] == 'r' && $this->vars['www_group'] == $group) || 1299 /* read for owner */ 1300 ($rights[1] == 'r' && $this->vars['www_user'] == $user)) 1301 ); 1302 } 1303 1304 function _is_directory ($rights) 1305 { 1306 return ($rights && $rights[0] == 'd'); 1307 } 1308 1309 function _is_device ($rights) 1310 { 1311 return ($rights && ($rights[0] == 'b' || $rights[0] == 'c')); 1312 } 1313 1314 function get_envpath () 1315 { 1316 return implode (':', $this->vars['envpath']); 1317 } 1318 1319 function command_current_execute () 1320 { 1321 $path_old = getenv ('PATH'); 1322 $path_new = $this->get_envpath (); 1323 1324 if ($path_new) 1325 putenv ("PATH=$path_new"); 1326 1327 $fd = popen ($this->vars['command_current'] . " 2>&1", "r"); 1328 while (!feof($fd)) 1329 $this->vars['command_current_output'] .= fread ($fd, 1024); 1330 pclose ($fd); 1331 1332 putenv ("PATH=$path_new"); 1333 } 1334 1335 function get_command_current_output () 1336 { 1337 return $this->vars['command_current_output']; 1338 } 1339 1340 function get_box_posX ($name) 1341 { 1342 return $this->vars[$name . '_box_x']; 1343 } 1344 1345 function get_box_posY ($name) 1346 { 1347 return $this->vars[$name . '_box_y']; 1348 } 1349 1350 function get_history_html () 1351 { 1352 $output = " 1353 <table> 1354 <tr><th colspan=3 class='caption'>History</th></tr> 1355 <tr class='header'><th colspan=2>Command</th><th>Action</th></tr> 1356 "; 1357 $i = 0; 1358 foreach ($this->vars['history'] as $row) 1359 { 1360 $output .= " 1361 <tr> 1362 <td class='num'>" . ($i + 1) . "</td> 1363 <td nowrap>" . $this->htmlentities ($row) . "</td> 1364 <td nowrap> 1365 <input type='button' title=\"Execute\" value='E' 1366 onClick=\"history_index.value=$i;action_requested.value='" . 1367 SHELL_HISTORY_EXECUTE . "';_submit()\" /> 1368 <input type='button' title=\"Select\" value='S' 1369 onClick=\"command.value='" . 1370 addslashes ($this->htmlentities ($row)) . "'\" /> 1371 <input type='button' title=\"Delete\" value='D' 1372 onClick=\"history_index.value=$i;action_requested.value='" . 1373 SHELL_HISTORY_DELETE ."';_submit()\" /> 1374 </td> 1375 </tr> 1376 "; 1377 $i++; 1378 } 1379 $output .= "</table>"; 1380 1381 return $output; 1382 } 1383 1384 function get_envpath_html () 1385 { 1386 $output = " 1387 <div id=\"envpath_box\" class=\"box\" 1388 onClick=\"this.style.zIndex=++zIndex;\" 1389 style=\"top: " . $this->get_box_posY ('envpath') . 1390 ";left: " . $this->get_box_posX ('envpath') . ";visibility: " . 1391 $this->get_show_hide ('envpath') . " ;\"> 1392 <table> 1393 <tr><th colspan=2 1394 onMouseOver=\"this.style.cursor='move';\" 1395 onMouseDown=\"drag_begin('envpath_box')\" 1396 onMouseUp=\"drag_end()\" 1397 class='caption'>Environment PATH</th> 1398 <th class=\"win_close\" 1399 onClick=\"show_hide('envpath', forms[0].envpath_cb)\">X</th></tr> 1400 <tr class='header'><th colspan=2>Directory</th><th>Action</th></tr> 1401 <tr><td colspan=2><input type='text' name='envpath_value' value=\"\" /> 1402 </td> 1403 <td> 1404 <input type='button' value='Add' 1405 onClick=\"action_requested.value='" . SHELL_ENVPATH_ADD . 1406 "';_submit()\" /> 1407 </td></tr> 1408 "; 1409 $i = 0; 1410 foreach ($this->vars['envpath'] as $row) 1411 { 1412 $output .= " 1413 <tr> 1414 <td class='num'>" . ($i + 1) . "</td> 1415 <td nowrap>" . $this->htmlentities ($row) . "</td> 1416 <td nowrap> 1417 <input type='button' value='Delete' 1418 onClick=\"envpath_index.value=$i; 1419 action_requested.value='" . 1420 SHELL_ENVPATH_DELETE 1421 ."';_submit()\" /> 1422 </td> 1423 </tr> 1424 "; 1425 $i++; 1426 } 1427 $output .= "</table></div>"; 1428 1429 return $output; 1430 } 1431 1432 function get_file_browser_initpath_html () 1433 { 1434 $output = " 1435 <div id=\"initpath_box\" class=\"box\" 1436 onClick=\"this.style.zIndex=++zIndex;\" 1437 style=\"top: " . $this->get_box_posY ('initpath') . 1438 ";left: " . $this->get_box_posX ('initpath') . ";visibility: " . 1439 $this->get_show_hide ('initpath') . " ;\"> 1440 <table> 1441 <tr> 1442 <th 1443 onMouseOver=\"this.style.cursor='move'\" 1444 onMouseDown=\"drag_begin('initpath_box')\" 1445 onMouseUp=\"drag_end()\" 1446 class='caption'>Initial Path</th> 1447 <th class=\"win_close\" 1448 onClick=\"show_hide('initpath', forms[0].initpath_cb)\">X</th> 1449 </tr> 1450 <tr class='header'><th>Path</th><th>Action</th> 1451 </tr> 1452 <tr><td><input type='text' name='initpath_value' value=\"" . 1453 $this->htmlentities ($this->get_file_browser_initpath ()) . 1454 "\" /></td> 1455 <td> 1456 <input type='button' value='Update' 1457 onClick=\"dir_current.value='" . 1458 addslashes ($this->htmlentities ($this->vars['dir_current'])) . 1459 "';file_browser_initpath.value=initpath_value.value;_submit()\" /> 1460 </td></tr> 1461 "; 1462 $output .= " 1463 </table> 1464 </div>"; 1465 1466 return $output; 1467 } 1468 1469 function get_highlight_html () 1470 { 1471 $output = " 1472 <div id=\"highlight_box\" class=\"box\" 1473 onClick=\"this.style.zIndex=++zIndex;\" 1474 style=\"top: " . $this->get_box_posY ('highlight') . 1475 ";left: " . $this->get_box_posX ('highlight') . ";visibility: " . 1476 $this->get_show_hide ('highlight') . " ;\"> 1477 <table> 1478 <tr> 1479 <th 1480 onMouseOver=\"this.style.cursor='move'\" 1481 onMouseDown=\"drag_begin('highlight_box')\" 1482 onMouseUp=\"drag_end()\" 1483 class='caption'>PHP Code highlight</th> 1484 <th class=\"win_close\" 1485 onClick=\"show_hide('highlight', forms[0].highlight_cb)\">X</th></tr> 1486 <tr><td colspan=2> 1487 " . 1488 @highlight_string ("<?\n" . $this->get_phpcode_current () . "\n?>", 1489 true) . " 1490 </td></tr></table></div>"; 1491 1492 return $output; 1493 } 1494 1495 function get_profiles_html () 1496 { 1497 $output = " 1498 <div id=\"profiles_box\" class=\"box\" 1499 onClick=\"this.style.zIndex=++zIndex;\" 1500 style=\"top: " . $this->get_box_posY ('profiles') . 1501 ";left: " . $this->get_box_posX ('profiles') . ";visibility: " . 1502 $this->get_show_hide ('profiles') . " ;\"> 1503 <table> 1504 <tr><th 1505 onMouseOver=\"this.style.cursor='move'\" 1506 onMouseDown=\"drag_begin('profiles_box')\" 1507 onMouseUp=\"drag_end()\" 1508 colspan=2 class='caption'>Profiles management</th> 1509 <th class=\"win_close\" 1510 onClick=\"show_hide('profiles', forms[0].profiles_cb)\">X</th></tr> 1511 <tr class='header'><th colspan=2>Name</th><th>Action</th></tr> 1512 "; 1513 1514 if (count ($this->vars['profiles']) < EDIT_PROFILES_MAX) 1515 $output .= " 1516 <tr><td colspan=2> 1517 <input type='text' maxlength=\"50\" name='profile_name' value=\"\" /> 1518 </td> 1519 <td colspan=2> 1520 <input type='button' value='Save' 1521 onClick=\"action_requested.value='" . EDIT_PROFILES_SAVE . 1522 "';_submit()\" /> 1523 </td></tr> 1524 "; 1525 1526 $i = 0; 1527 foreach ($this->vars['profiles'] as $name) 1528 { 1529 $output .= " 1530 <tr> 1531 <td class='num'>" . ($i + 1) . "</td> 1532 <td>" . $this->htmlentities ($name) . "</td> 1533 <td nowrap> 1534 <input type='button' title=\"Load\" value='L' 1535 onClick=\"profiles_index.value=$i;profile_current.value='" . 1536 addslashes ($this->htmlentities ($name)). 1537 "';action_requested.value='" . 1538 EDIT_PROFILES_LOAD ."';_submit()\" /> 1539 1540 <input type='button' 1541 title=\"Update/Replace with current\" value='U' 1542 onClick=\"profiles_index.value=$i;action_requested.value='" . 1543 EDIT_PROFILES_UPDATE ."';_submit()\" /> 1544 1545 <input type='button' title=\"Delete\" value='D' 1546 onClick=\"profiles_index.value=$i;action_requested.value='" . 1547 EDIT_PROFILES_DELETE ."';_submit()\" /> 1548 </td> 1549 </tr> 1550 "; 1551 $i++; 1552 } 1553 $output .= " 1554 </table> 1555 </div>"; 1556 1557 return $output; 1558 } 1559 1560 function get_aliases_html () 1561 { 1562 $output = " 1563 <div id=\"aliases_box\" class=\"box\" 1564 onClick=\"this.style.zIndex=++zIndex;\" 1565 style=\"top: " . $this->get_box_posY ('aliases') . 1566 ";left: " . $this->get_box_posX ('aliases') . ";visibility: " . 1567 $this->get_show_hide ('aliases') . " ;\"> 1568 <table> 1569 <tr><th 1570 onMouseOver=\"this.style.cursor='move'\" 1571 onMouseDown=\"drag_begin('aliases_box')\" 1572 onMouseUp=\"drag_end()\" 1573 colspan=3 class='caption'>Aliases</th> 1574 <th class=\"win_close\" 1575 onClick=\"show_hide('aliases', forms[0].aliases_cb)\">X</th></tr> 1576 <tr class='header'><th colspan=2>Name</th><th>Value</th><th>Action</th> 1577 </tr> 1578 <tr><td colspan=2><input size=5 type='text' 1579 name='alias_name' value=\"\" /></td> 1580 <td><input type='text' name='alias_value' value=\"\" /></td> 1581 <td> 1582 <input type='button' value='Add' 1583 onClick=\"action_requested.value='" . SHELL_ALIASES_ADD . 1584 "';_submit()\" /> 1585 </td></tr> 1586 "; 1587 $i = 0; 1588 foreach ($this->vars['aliases'] as $name => $value) 1589 { 1590 $output .= " 1591 <tr> 1592 <td class='num'>" . ($i + 1) . "</td> 1593 <td><b>\$" . $this->htmlentities ($name) . "</b></td> 1594 <td>" . $this->htmlentities ($value) . "</td> 1595 <td> 1596 <input type='button' value='Delete' 1597 onClick=\"alias_name.value='" . 1598 addslashes ($this->htmlentities ($name)) . 1599 "';action_requested.value='" . 1600 SHELL_ALIASES_DELETE ."';_submit()\" /> 1601 </td> 1602 </tr> 1603 "; 1604 $i++; 1605 } 1606 $output .= " 1607 </table> 1608 </div>"; 1609 1610 return $output; 1611 } 1612 1613 function _get_http_var ($name) 1614 { 1615 $tmp = ''; 1616 1617 if (isset ($_POST[$name])) 1618 $tmp = $_POST[$name]; 1619 1620 return $tmp; 1621 } 1622 1623 function _fix_magic_quotes ($str) 1624 { 1625 return (ini_get ('magic_quotes_gpc') == 1) ? 1626 stripslashes ($str) : $str; 1627 } 1628 1629 function utf8_decode ($str) 1630 { 1631 if (preg_match ( 1632 '%^(?: 1633 [\x09\x0A\x0D\x20-\x7E] # ASCII 1634 | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte 1635 | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs 1636 | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte 1637 | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates 1638 | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3 1639 | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15 1640 | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 1641 )*$%xs', $str)) 1642 $str = utf8_decode ($str); 1643 1644 return $str; 1645 } 1646 1647 function htmlentities ($str) 1648 { 1649 $str = $this->utf8_decode ($str); 1650 1651 return htmlentities ($this->_fix_magic_quotes ($str)); 1652 } 1653 1654 function done () {} 1655 } 1656 1657 $prs = new PhpRemoteShell ($config); 1658 if ($prs->command_current_exists ()) 1659 $prs->command_current_execute (); 1660 ?> 1661 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 1662 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 1663 <html> 1664 <head> 1665 <title><?=SHELL_APP_NAME?> - <?=SHELL_APP_VERSION?></title> 1666 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 1667 <style> 1668 body { 1669 font-family: Verdana, Arial, Helvetica, sans-serif; 1670 font-size: 10px; 1671 } 1672 input, textarea { 1673 border: 1px black solid; 1674 background: #98B2D7; 1675 color: black; 1676 font-family: Verdana, Arial, Helvetica, sans-serif; 1677 font-size: 10px; 1678 } 1679 input.menu_selected { 1680 background: white; 1681 } 1682 input.file_browser_path { 1683 padding: 3px; 1684 border: 1px black solid; 1685 } 1686 input.file_browser { 1687 padding: 0px; 1688 border: none; 1689 text-align: left; 1690 } 1691 a { 1692 color: black; 1693 } 1694 a:hover { 1695 color: cornflowerblue; 1696 } 1697 table.menu { 1698 background: cornflowerblue; 1699 } 1700 .menu { 1701 border: 1px yellow solid; 1702 color: cornflowerblue; 1703 background: black; 1704 padding: 2px; 1705 } 1706 .title_file { 1707 font-weight: bold; 1708 font-size: 12px; 1709 } 1710 .smenu { 1711 border: 1px yellow solid; 1712 color: cornflowerblue; 1713 background: black; 1714 border-collapse: collapse; 1715 } 1716 .smenu a { 1717 color: cornflowerblue; 1718 text-decoration: none; 1719 } 1720 .smenu a:hover { 1721 color: yellow; 1722 } 1723 .smenu input:hover { 1724 color: white; 1725 } 1726 div#title { 1727 background: cornflowerblue; 1728 border: 1px black solid; 1729 padding: 5px; 1730 text-align: center; 1731 font-weight: bold; 1732 font-size: 12px; 1733 } 1734 div#title #app_name { 1735 color: white; 1736 } 1737 div#phpcode_output_title { 1738 text-align: center; 1739 font-weight: bold; 1740 font-size: 12px; 1741 } 1742 div#phpcode_output { 1743 background: #004594; 1744 border: 1px cornflowerblue solid; 1745 padding: 5px; 1746 color: white; 1747 } 1748 table { 1749 border: 1px black solid; 1750 } 1751 th { 1752 background: cornflowerblue; 1753 color: white; 1754 vertical-align: top; 1755 border: 1px black solid; 1756 } 1757 th.caption { 1758 background: black; 1759 color: cornflowerblue; 1760 vertical-align: top; 1761 border: 2px cornflowerblue solid; 1762 text-align: center; 1763 } 1764 th.win_close { 1765 text-align: right; 1766 background: black; 1767 color: orange; 1768 border: 1px orange solid; 1769 } 1770 table.action_result { 1771 border: 1px black solid; 1772 border-collapse: collapse; 1773 text-align: center; 1774 } 1775 table.action_result th { 1776 background: cornflowerblue; 1777 color: white; 1778 vertical-align: top; 1779 } 1780 table.file_browser { 1781 width: 90%; 1782 border: 1px black solid; 1783 border-collapse: collapse; 1784 text-align: center; 1785 } 1786 table.file_browser_legend { 1787 width: 1%; 1788 border: 1px black solid; 1789 border-collapse: collapse; 1790 text-align: left; 1791 } 1792 table.file_browser_menu { 1793 background: cornflowerblue; 1794 } 1795 table.file_browser th { 1796 background: cornflowerblue; 1797 color: white; 1798 vertical-align: top; 1799 } 1800 tr.odd { 1801 background: #004594; 1802 color: white; 1803 } 1804 tr.even { 1805 background: cornflowerblue; 1806 } 1807 table.file_browser_legend td.rights_read { 1808 background: green; 1809 border: 1px black solid; 1810 } 1811 table.file_browser_legend td.rights_write { 1812 background: blue; 1813 border: 1px black solid; 1814 } 1815 table.file_browser_legend td.rights_bad { 1816 background: red; 1817 border: 1px black solid; 1818 } 1819 table.file_browser td.rights_read { 1820 background: green; 1821 border: 1px black solid; 1822 } 1823 table.file_browser td.rights_write { 1824 background: blue; 1825 border: 1px black solid; 1826 } 1827 table.file_browser td.rights_bad { 1828 background: red; 1829 border: 1px black solid; 1830 } 1831 table.file_browser td.name { 1832 text-align: left; 1833 } 1834 tr.header { 1835 background: cornflowerblue; 1836 color: white; 1837 } 1838 td { 1839 vertical-align: top; 1840 } 1841 td.label { 1842 background: cornflowerblue; 1843 font-weight: bold; 1844 vertical-align: top; 1845 } 1846 td.num { 1847 background: black; 1848 color: orange; 1849 border: 1px cornflowerblue solid; 1850 font-weight: bold; 1851 vertical-align: middle; 1852 text-align: center; 1853 width: 20px; 1854 } 1855 pre { 1856 font-family: monospace, courier; 1857 background: #004594; 1858 color: white; 1859 border: 1px cornflowerblue solid; 1860 padding: 5px; 1861 } 1862 .box { 1863 background: white; 1864 top: <?=POPUP_DEFAULT_Y?>px; 1865 left: <?=POPUP_DEFAULT_X?>px; 1866 position: absolute; 1867 overflow: auto; 1868 visibility: visible; 1869 z-index: 1; 1870 } 1871 div#profile_title { 1872 text-align: right; 1873 border: 1px cornflowerblue solid; 1874 padding: 1px; 1875 } 1876 .disabled { 1877 background: #94AED6; 1878 color: #CEDFFF; 1879 } 1880 </style> 1881 <!--[if IE]> 1882 <style> 1883 pre { 1884 font-family: courier; 1885 background: #004594; 1886 color: white; 1887 border: 1px cornflowerblue solid; 1888 padding: 5px; 1889 } 1890 code { 1891 font-family: courier; 1892 } 1893 </style> 1894 <![endif]--> 1895 <script language="javascript"> 1896 var zIndex = 1; 1897 var dragging = false; 1898 var xOffs = 0; 1899 var yOffs = 0; 1900 var mouseX = 0; 1901 var mouseY = 0; 1902 var currentPopup = null; 1903 var currentMenu = null; 1904 var is_ie = (navigator.appName.indexOf ("Microsoft") >= 0); 1905 1906 addEvent (document, 'mousemove', _mouseMove); 1907 1908 function _submit () 1909 { 1910 var item = null; 1911 var f = document.forms[0]; 1912 1913 item = document.getElementById ('aliases_box'); 1914 f.aliases_box_x.value = item.style.left; 1915 f.aliases_box_y.value = item.style.top; 1916 1917 item = document.getElementById ('profiles_box'); 1918 f.profiles_box_x.value = item.style.left; 1919 f.profiles_box_y.value = item.style.top; 1920 1921 item = document.getElementById ('envpath_box'); 1922 f.envpath_box_x.value = item.style.left; 1923 f.envpath_box_y.value = item.style.top; 1924 1925 item = document.getElementById ('initpath_box'); 1926 f.initpath_box_x.value = item.style.left; 1927 f.initpath_box_y.value = item.style.top; 1928 1929 item = document.getElementById ('highlight_box'); 1930 f.highlight_box_x.value = item.style.left; 1931 f.highlight_box_y.value = item.style.top; 1932 1933 f.submit (); 1934 } 1935 1936 function reset_pos (name) 1937 { 1938 item = document.getElementById (name + '_box'); 1939 item.style.left = '<?=POPUP_DEFAULT_X?>px'; 1940 item.style.top = '<?=POPUP_DEFAULT_Y?>px'; 1941 } 1942 1943 function addEvent (el, evname, func) 1944 { 1945 if (el.attachEvent) 1946 el.attachEvent ("on" + evname, func); 1947 else if (el.addEventListener) 1948 { 1949 el.addEventListener (evname, func, true); 1950 } 1951 else 1952 el["on" + evname] = func; 1953 } 1954 1955 function removeEvent (el, evname, func) 1956 { 1957 if (el.detachEvent) 1958 el.detachEvent ("on" + evname, func); 1959 else if (el.removeEventListener) 1960 el.removeEventListener (evname, func, true); 1961 else 1962 el["on" + evname] = null; 1963 } 1964 1965 function _mouseMove (e) 1966 { 1967 if (dragging) return; 1968 1969 if (document.layers) 1970 { 1971 mouseX = e.x; 1972 mouseY = e.y; 1973 } 1974 else if (document.all) 1975 { 1976 mouseX = event.clientX; 1977 mouseY = event.clientY; 1978 } 1979 else if (document.getElementById) 1980 { 1981 mouseX = e.clientX; 1982 mouseY = e.clientY; 1983 } 1984 } 1985 1986 function drag_begin (id) 1987 { 1988 var posX = 0; 1989 var posY = 0; 1990 var item = null; 1991 1992 currentPopup = id; 1993 1994 item = document.getElementById (id); 1995 1996 if (is_ie) 1997 { 1998 posX = mouseX + document.body.scrollLeft; 1999 posY = mouseY + document.body.scrollTop; 2000 } 2001 else 2002 { 2003 posX = mouseX + window.scrollX; 2004 posY = mouseY + window.scrollY; 2005 } 2006 2007 xOffs = posX - parseInt (item.style.left); 2008 yOffs = posY - parseInt (item.style.top); 2009 2010 addEvent (document, 'mousemove', drag_box); 2011 2012 item.style.cursor = 'move'; 2013 2014 dragging = true; 2015 } 2016 2017 function drag_end () 2018 { 2019 var item = null; 2020 2021 if (!dragging) return; 2022 dragging = false; 2023 2024 item = document.getElementById(currentPopup); 2025 removeEvent (document, 'mousemove', drag_box); 2026 item.style.cursor = 'default'; 2027 2028 currentPopup = null; 2029 } 2030 2031 function drag_box (e) 2032 { 2033 var item = document.getElementById (currentPopup); 2034 2035 if (is_ie) 2036 { 2037 item.style.left = 2038 (window.event.clientX + document.body.scrollLeft - xOffs) + 'px'; 2039 item.style.top = 2040 (window.event.clientY + document.body.scrollTop - yOffs) + 'px'; 2041 } 2042 else 2043 { 2044 item.style.left = (e.pageX - xOffs) + 'px'; 2045 item.style.top = (e.pageY - yOffs) + 'px'; 2046 } 2047 } 2048 2049 function menu_show (name) 2050 { 2051 var item = null; 2052 2053 if ( !(item = document.getElementById (name)) ) 2054 return; 2055 2056 menu_hide (currentMenu); 2057 currentMenu = name; 2058 2059 item.style.visibility = 'visible'; 2060 } 2061 2062 function menu_hide (name) 2063 { 2064 var item = null; 2065 2066 if ( !(item = document.getElementById (name)) ) 2067 return; 2068 2069 item.style.visibility = 'hidden'; 2070 } 2071 2072 function show_hide (id, i) 2073 { 2074 var item = null; 2075 var state = null; 2076 2077 if ( !(item = document.getElementById (id + '_box')) ) 2078 return; 2079 2080 state = item.style.visibility; 2081 2082 if (state == 'hidden') 2083 { 2084 item.style.zIndex = ++zIndex; 2085 item.style.visibility = 'visible'; 2086 eval ("document.forms[0].show_hide_" + id + ".value = 'visible'"); 2087 i.checked = true; 2088 } 2089 else 2090 { 2091 item.style.visibility = 'hidden'; 2092 eval ("document.forms[0].show_hide_" + id + ".value = 'hidden'"); 2093 i.checked = false; 2094 reset_pos (id); 2095 } 2096 } 2097 </script> 2098 </head> 2099 <body onClick="drag_end()"> 2100 2101 <div id="title"> 2102 Welcome to <span id="app_name"><?=SHELL_APP_NAME?></span> 2103 <?=SHELL_APP_VERSION?> 2104 </div> 2105 <br /> 2106 <div id="profile_title"> 2107 Current profile: <b><?=($prs->get_profile_current ()) ? $prs->htmlentities ($prs->get_profile_current ()) : 'None'?></b> 2108 </div> 2109 2110 <p> 2111 <form method="post" action="<?=$_SERVER['PHP_SELF']?>" 2112 enctype="multipart/form-data"> 2113 <input type="hidden" name="show_hide_aliases" 2114 value="<?=$prs->htmlentities ($prs->get_show_hide ('aliases'))?>" /> 2115 <input type="hidden" name="show_hide_profiles" 2116 value="<?=$prs->htmlentities ($prs->get_show_hide ('profiles'))?>" /> 2117 <input type="hidden" name="show_hide_envpath" 2118 value="<?=$prs->htmlentities ($prs->get_show_hide ('envpath'))?>" /> 2119 <input type="hidden" name="show_hide_initpath" 2120 value="<?=$prs->htmlentities ($prs->get_show_hide ('initpath'))?>" /> 2121 <input type="hidden" name="show_hide_highlight" 2122 value="<?=$prs->htmlentities ($prs->get_show_hide ('highlight'))?>" /> 2123 <input type="hidden" name="is_nav" value="0" /> 2124 <input type="hidden" name="action_type" value="" /> 2125 <input type="hidden" name="display_type" 2126 value="<?=$prs->htmlentities ($prs->get_display_type ())?>" /> 2127 <input type="hidden" name="history_index" value="" /> 2128 <input type="hidden" name="profiles_index" value="" /> 2129 <input type="hidden" name="envpath_index" value="" /> 2130 <input type="hidden" name="dir_current" 2131 value="<?=$prs->htmlentities ($prs->get_dir_current ())?>" /> 2132 <input type="hidden" name="profile_current" 2133 value="<?=$prs->htmlentities ($prs->get_profile_current ())?>" /> 2134 <input type="hidden" name="file_current_rights" 2135 value="<?=$prs->htmlentities ($prs->get_file_current_rights ())?>" /> 2136 <input type="hidden" name="file_browser_initpath" 2137 value="<?=$prs->htmlentities ($prs->get_file_browser_initpath ())?>" /> 2138 <input type="hidden" name="action_requested" value="" /> 2139 <input type="hidden" name="history" 2140 value="<?=$prs->htmlentities ($prs->form_get_serialize ('history'))?>" /> 2141 <input type="hidden" name="aliases" 2142 value="<?=$prs->htmlentities ($prs->form_get_serialize ('aliases'))?>" /> 2143 <input type="hidden" name="profiles" 2144 value="<?=$prs->htmlentities ($prs->form_get_serialize ('profiles'))?>" /> 2145 <input type="hidden" name="envpath" 2146 value="<?=$prs->htmlentities ($prs->form_get_serialize ('envpath'))?>" /> 2147 <input type="hidden" name="envpath_box_x" 2148 value="<?=$prs->htmlentities ($prs->get_box_posX ('envpath'))?>" /> 2149 <input type="hidden" name="envpath_box_y" 2150 value="<?=$prs->htmlentities ($prs->get_box_posY ('envpath'))?>" /> 2151 <input type="hidden" name="initpath_box_x" 2152 value="<?=$prs->htmlentities ($prs->get_box_posX ('initpath'))?>" /> 2153 <input type="hidden" name="initpath_box_y" 2154 value="<?=$prs->htmlentities ($prs->get_box_posY ('initpath'))?>" /> 2155 <input type="hidden" name="highlight_box_x" 2156 value="<?=$prs->htmlentities ($prs->get_box_posX ('highlight'))?>" /> 2157 <input type="hidden" name="highlight_box_y" 2158 value="<?=$prs->htmlentities ($prs->get_box_posY ('highlight'))?>" /> 2159 <input type="hidden" name="aliases_box_x" 2160 value="<?=$prs->htmlentities ($prs->get_box_posX ('aliases'))?>" /> 2161 <input type="hidden" name="aliases_box_y" 2162 value="<?=$prs->htmlentities ($prs->get_box_posY ('aliases'))?>" /> 2163 <input type="hidden" name="profiles_box_x" 2164 value="<?=$prs->htmlentities ($prs->get_box_posX ('profiles'))?>" /> 2165 <input type="hidden" name="profiles_box_y" 2166 value="<?=$prs->htmlentities ($prs->get_box_posY ('profiles'))?>" /> 2167 <?php 2168 2169 /* Main menu */ 2170 print $prs->get_menu_html (); 2171 2172 if ($tmp = $prs->get_action_result_html ()) 2173 print $tmp; 2174 2175 switch ($prs->get_display_type ()) 2176 { 2177 /* 2178 * NOTEBOOK: Remote informations 2179 */ 2180 case SHELL_TYPE_REMOTE_INFOS: 2181 if ($prs->check_safe_mode ()) 2182 printf ("<p>%s</p>", $prs->get_safe_mode_alert_html ('all')); 2183 else 2184 printf ("<p>%s</p>", $prs->get_remote_infos_html ()); 2185 break; 2186 2187 /* 2188 * NOTEBOOK: Shell code 2189 */ 2190 case SHELL_TYPE_SHELL: 2191 if ($prs->check_safe_mode ()) 2192 printf ("<p>%s</p>", $prs->get_safe_mode_alert_html ('all')); 2193 else 2194 { 2195 printf (" 2196 <p> 2197 New shell command to execute: 2198 <p> 2199 <input type='text' name='command' value=\"%s\" /> 2200 </p> 2201 </p> 2202 <p><input type='button' onClick=\" 2203 action_requested.value='" . SHELL_EXECUTE . "'; 2204 _submit()\" value='Execute' /></p>", 2205 $prs->htmlentities ($prs->get_command_current ()) 2206 ); 2207 2208 /* Commands History table */ 2209 if ($prs->history_exists ()) 2210 printf ("<td>%s</td>", $prs->get_history_html ()); 2211 2212 /* Last executed command */ 2213 if ($prs->command_current_exists ()) 2214 printf ("<p>Last executed command: <p><pre>%s</pre></p></p>", 2215 $prs->htmlentities ($prs->get_command_current ())); 2216 2217 /* Output of the last command */ 2218 if ($prs->command_current_exists ()) 2219 printf ("<p>Output: <p><pre>%s</pre></p></p>", 2220 $prs->htmlentities ($prs->get_command_current_output ())); 2221 } 2222 break; 2223 2224 /* 2225 * NOTEBOOK: PHP code execution 2226 */ 2227 case SHELL_TYPE_PHP_CODE: 2228 2229 if ($prs->check_safe_mode ()) 2230 printf ("<p>%s</p>", $prs->get_safe_mode_alert_html ('some')); 2231 2232 printf (" 2233 <p> 2234 New PHP code to execute: 2235 <p><input type='button' onClick=\"_submit()\" value='Execute' /></p> 2236 <p> 2237 <textarea name='phpcode_current' cols='80' rows='10'>%s</textarea> 2238 </p> 2239 </p> 2240 <p><input type='button' onClick=\"_submit()\" value='Execute' /></p>", 2241 $prs->htmlentities ($prs->get_phpcode_current ()) 2242 ); 2243 if ($prs->phpcode_current_exists ()) 2244 { 2245 print " 2246 <div id=\"phpcode_output_title\">PHP Result:</div> 2247 <p><div id=\"phpcode_output\">"; 2248 if (@eval ($prs->_fix_magic_quotes ( 2249 $prs->get_phpcode_current ())) === false) 2250 print "A error occured while executing PHP code."; 2251 print "</div></p>"; 2252 } 2253 break; 2254 2255 /* 2256 * NOTEBOOK: File browser 2257 */ 2258 case SHELL_TYPE_FILE_BROWSER: 2259 if ($prs->check_safe_mode ()) 2260 printf ("<p>%s</p>", $prs->get_safe_mode_alert_html ('all')); 2261 else 2262 { 2263 print " 2264 <p> 2265 <table class='file_browser_legend' align='left'> 2266 <tr><th class='caption' colspan='6'>Legend</th></tr> 2267 <tr> 2268 <td width='2%' class='rights_write'> </td> 2269 <td>Read/write</td> 2270 <td width='2%' class='rights_read'> </td> 2271 <td>Read</td> 2272 <td width='2%' class='rights_bad'> </td> 2273 <td>Nothing</td> 2274 </tr> 2275 </table> 2276 </p> 2277 "; 2278 print "<br /><br /><br /><p>"; 2279 $prs->get_browse_dir (); 2280 print "</p>"; 2281 } 2282 break; 2283 2284 /* 2285 * NOTEBOOK: About 2286 */ 2287 //case SHELL_TYPE_ABOUT: 2288 default: ; 2289 print 2290 '<a href="http://phpremoteshell.labs.libre-entreprise.org/" 2291 target="_BLANK">Project Homepage</a><p />' . 2292 '<pre>' . 2293 $prs->htmlentities (' 2294 /* 2295 * Copyright (C) 2005-2006 2296 * Emmanuel Saracco <esaracco@users.labs.libre-entreprise.org>; 2297 * 2298 * This program is free software; you can redistribute it and/or modify 2299 * it under the terms of the GNU General Public License as published by 2300 * the Free Software Foundation; either version 2 of the License, or 2301 * (at your option) any later version. 2302 * 2303 * This program is distributed in the hope that it will be useful, 2304 * but WITHOUT ANY WARRANTY; without even the implied warranty of 2305 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 2306 * GNU General Public License for more details. 2307 * 2308 * You should have received a copy of the GNU General Public License 2309 * along with this program; if not, write to the Free Software 2310 * Foundation, Inc., 59 Temple Place, Suite 330, 2311 * Boston, MA 02111-1307, USA. 2312 */ 2313 ') . 2314 '</pre>'; 2315 break; 2316 } 2317 2318 /* Aliases table */ 2319 print $prs->get_aliases_html (); 2320 2321 /* Profiles table */ 2322 print $prs->get_profiles_html (); 2323 2324 /* Env PATH table */ 2325 print $prs->get_envpath_html (); 2326 2327 /* File browser initial path */ 2328 print $prs->get_file_browser_initpath_html (); 2329 2330 /* PHP code highlight */ 2331 print $prs->get_highlight_html (); 2332 ?> 2333 </form> 2334 </p> 2335 2336 </body> 2337 </html> 2338 <?php 2339 $prs->done (); 2340 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |