[ Index ] |
|
Code source de Joomla 1.0.13 |
1 <?php 2 /** 3 * PHP HTTP Tools is a library for working with the http protocol 4 * HTTPExceptions is an HTTP Exceptions class 5 * @package php-http-tools 6 * @copyright (C) 2004 John Heinstein. All rights reserved 7 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 8 * @author John Heinstein <johnkarl@nbnet.nb.ca> 9 * @link http://www.engageinteractive.com/php_http_tools/ PHP HTTP Tools Home Page 10 * PHP HTTP Tools are Free Software 11 **/ 12 13 /** socket connection error */ 14 define('HTTP_SOCKET_CONNECTION_ERR', 1); 15 /** http transport error */ 16 define('HTTP_TRANSPORT_ERR', 2); 17 18 //HTTPExceptions Error Modes 19 /** continue on error */ 20 define('HTTP_ONERROR_CONTINUE', 1); 21 /** die on error */ 22 define('HTTP_ONERROR_DIE', 2); 23 24 /** 25 * @global object Reference to custom error handler for HTTP Exception class 26 */ 27 $GLOBALS['HTTP_Exception_errorHandler'] = null; 28 /** 29 * @global int Error mode; specifies whether to die on error or simply return 30 */ 31 //$GLOBALS['HTTP_Exception_mode'] = HTTP_ONERROR_RETURN; 32 // fixes bug identified here: sarahk.pcpropertymanager.com/blog/using-domit-rss/225/ 33 $GLOBALS['HTTP_Exception_mode'] = 1; 34 /** 35 * @global string Log file for errors 36 */ 37 $GLOBALS['HTTP_Exception_log'] = null; 38 39 /** 40 * An HTTP Exceptions class (not yet implemented) 41 * 42 * @package php-http-tools 43 * @author John Heinstein <johnkarl@nbnet.nb.ca> 44 */ 45 class HTTPExceptions { 46 function raiseException($errorNum, $errorString) { 47 //die('HTTP Exception: ' . $errorNum . "\n " . $errorString); 48 49 if ($GLOBALS['HTTP_Exception_errorHandler'] != null) { 50 call_user_func($GLOBALS['HTTP_Exception_errorHandler'], $errorNum, $errorString); 51 } 52 else { 53 $errorMessageText = $errorNum . ' ' . $errorString; 54 $errorMessage = 'Error: ' . $errorMessageText; 55 56 if ((!isset($GLOBALS['HTTP_ERROR_FORMATTING_HTML'])) || 57 ($GLOBALS['HTTP_ERROR_FORMATTING_HTML'] == true)) { 58 $errorMessage = "<p><pre>" . $errorMessage . "</pre></p>"; 59 } 60 61 //log error to file 62 if ((isset($GLOBALS['HTTP_Exception_log'])) && 63 ($GLOBALS['HTTP_Exception_log'] != null)) { 64 require_once (PHP_HTTP_TOOLS_INCLUDE_PATH . 'php_file_utilities.php'); 65 $logItem = "\n" . date('Y-m-d H:i:s') . ' HTTP Error ' . $errorMessageText; 66 php_file_utilities::putDataToFile($GLOBALS['HTTP_Exception_log'], 67 $logItem, 'a'); 68 } 69 70 switch ($GLOBALS['HTTP_Exception_mode']) { 71 case HTTP_ONERROR_CONTINUE: 72 return; 73 break; 74 75 case HTTP_ONERROR_DIE: 76 die($errorMessage); 77 break; 78 } 79 } 80 } //raiseException 81 82 /** 83 * custom handler for HTTP errors 84 * @param object A reference to the custom error handler 85 */ 86 function setErrorHandler($method) { 87 $GLOBALS['HTTP_Exception_errorHandler'] =& $method; 88 } //setErrorHandler 89 90 /** 91 * Set error mode 92 * @param int The HTTP error mode 93 */ 94 function setErrorMode($mode) { 95 $GLOBALS['HTTP_Exception_mode'] = $mode; 96 } //setErrorMode 97 98 /** 99 * Set error mode 100 * @param boolean True if errors should be logged 101 * @param string Absolute or relative path to log file 102 */ 103 function setErrorLog($doLogErrors, $logfile) { 104 if ($doLogErrors) { 105 $GLOBALS['HTTP_Exception_log'] = $logfile; 106 } 107 else { 108 $GLOBALS['HTTP_Exception_log'] = null; 109 } 110 } //setErrorLog 111 } //HTTPExceptions 112 113 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Wed Nov 21 14:43:32 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |