[ Index ] |
|
Code source de PHPonTrax 2.6.6-svn |
1 <?php 2 /** 3 * (PHP 5) 4 * 5 * @package PHPonTrax 6 * @version $Id:$ 7 * @copyright (c) 2005 John Peterson 8 * 9 * Permission is hereby granted, free of charge, to any person obtaining 10 * a copy of this software and associated documentation files (the 11 * "Software"), to deal in the Software without restriction, including 12 * without limitation the rights to use, copy, modify, merge, publish, 13 * distribute, sublicense, and/or sell copies of the Software, and to 14 * permit persons to whom the Software is furnished to do so, subject to 15 * the following conditions: 16 * 17 * The above copyright notice and this permission notice shall be 18 * included in all copies or substantial portions of the Software. 19 * 20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 */ 28 29 @ob_end_clean(); 30 error_reporting(E_ALL); 31 set_time_limit(0); 32 33 require_once ("php_shell/shell.php"); 34 35 /** 36 * default error-handler 37 * 38 * Instead of printing the NOTICE or WARNING from php we wan't the turn non-FATAL 39 * messages into exceptions and handle them in our own way. 40 * 41 * you can set your own error-handler by createing a function named 42 * __shell_error_handler 43 * 44 * @param integer $errno Error-Number 45 * @param string $errstr Error-Message 46 * @param string $errfile Filename where the error was raised 47 * @param interger $errline Line-Number in the File 48 * @param mixed $errctx ... 49 */ 50 function __shell_default_error_handler($errno, $errstr, $errfile, $errline, $errctx) { 51 ## ... what is this errno again ? 52 if ($errno == 2048) return; 53 54 throw new Exception(sprintf("%s:%d\r\n%s", $errfile, $errline, $errstr)); 55 } 56 57 set_error_handler("__shell_default_error_handler"); 58 59 $__shell = new PHP_Shell(); 60 61 $f = <<<EOF 62 >> use '?' to open the inline help 63 EOF; 64 65 printf($f, 66 $__shell->getVersion(), 67 $__shell->hasReadline() ? ', with readline() support' : ''); 68 unset($f); 69 70 print $__shell->getColour("default"); 71 while($__shell->input()) { 72 try { 73 if ($__shell->parse() == 0) { 74 ## we have a full command, execute it 75 76 if ($__shell->isAutoloadEnabled() && !function_exists('__autoload')) { 77 /** 78 * default autoloader 79 * 80 * If a class doesn't exist try to load it by guessing the filename 81 * class PHP_Shell should be located in PHP/Shell.php. 82 * 83 * you can set your own autoloader by defining __autoload() before including 84 * this file 85 * 86 * @param string $classname name of the class 87 */ 88 89 function __autoload($classname) { 90 include str_replace('_', '/', $classname).'.php'; 91 } 92 } 93 94 $__shell_retval = eval($__shell->getCode()); 95 if (isset($__shell_retval)) { 96 print $__shell->getColour("value"); 97 98 if (function_exists("__shell_print_var")) { 99 __shell_print_var($__shell_retval, $__shell->getVerbose()); 100 } else { 101 var_export($__shell_retval); 102 } 103 } 104 ## cleanup the variable namespace 105 unset($__shell_retval); 106 $__shell->resetCode(); 107 } 108 } catch(Exception $__shell_exception) { 109 print $__shell->getColour("exception"); 110 print $__shell_exception->getMessage(); 111 112 $__shell->resetCode(); 113 114 ## cleanup the variable namespace 115 unset($__shell_exception); 116 } 117 print $__shell->getColour("default"); 118 } 119 120 print $__shell->getColour("reset"); 121 122 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 20:04:38 2007 | par Balluche grâce à PHPXref 0.7 |