| 1 |
<?php |
<?php |
| 2 |
|
|
| 3 |
// $Id: civicrm_error.module,v 1.1.2.3 2007/07/23 22:03:20 dalin Exp $ |
// $Id: civicrm_error.module,v 1.1.2.4 2007/07/25 22:21:58 dalin Exp $ |
| 4 |
|
|
| 5 |
/** |
/** |
| 6 |
* Custom error function |
* Custom error function |
| 20 |
$output .= _civicrm_error_parse_array($civicrm_error); |
$output .= _civicrm_error_parse_array($civicrm_error); |
| 21 |
} |
} |
| 22 |
|
|
| 23 |
|
$output .= "\n\n\n\n\n***PHP ERROR***\n"; |
| 24 |
// php error details |
// php error details |
| 25 |
if (function_exists('error_get_last')) { |
if (function_exists('error_get_last')) { |
|
$output .= "\n\n\n\n\n***PHP ERROR***\n"; |
|
| 26 |
$output .= _civicrm_error_parse_array(error_get_last()); |
$output .= _civicrm_error_parse_array(error_get_last()); |
| 27 |
} |
} |
| 28 |
elseif ($php_errormsg) { |
elseif ($php_errormsg) { |
|
$output .= "\n\n\n\n\n***PHP ERROR***\n"; |
|
| 29 |
$output .= _civicrm_error_parse_array($php_errormsg); |
$output .= _civicrm_error_parse_array($php_errormsg); |
| 30 |
} |
} |
| 31 |
|
|
| 38 |
$output .= "\n\n\n\n\n***SERVER***\n"; |
$output .= "\n\n\n\n\n***SERVER***\n"; |
| 39 |
$output .= _civicrm_error_parse_array($_SERVER); |
$output .= _civicrm_error_parse_array($_SERVER); |
| 40 |
|
|
| 41 |
|
// $_SESSION |
| 42 |
|
$output .= "\n\n\n\n\n***SESSION***\n"; |
| 43 |
|
$output .= _civicrm_error_parse_array($_SESSION); |
| 44 |
|
|
| 45 |
// $_REQUEST |
// $_REQUEST |
| 46 |
$output .= "\n\n\n\n\n***REQUEST***\n"; |
$output .= "\n\n\n\n\n***REQUEST***\n"; |
| 47 |
$output .= _civicrm_error_parse_array($_REQUEST); |
$output .= _civicrm_error_parse_array($_REQUEST); |
| 65 |
* Helper function to return a pretty print of the given array |
* Helper function to return a pretty print of the given array |
| 66 |
*/ |
*/ |
| 67 |
function _civicrm_error_parse_array($array) { |
function _civicrm_error_parse_array($array) { |
| 68 |
|
// remove cc numbers |
| 69 |
|
$pattern = '/[0-9]{12}/'; |
| 70 |
|
$replace = 'xxxxxxxxxxxx'; |
| 71 |
foreach((array)$array as $key => $value) { |
foreach((array)$array as $key => $value) { |
| 72 |
if (is_array($value) || is_object($value)) { |
if (is_array($value) || is_object($value)) { |
| 73 |
$value = print_r($value, true); |
$value = print_r($value, true); |
| 74 |
} |
} |
| 75 |
$key = str_pad($key .':', 20, ' '); |
$key = str_pad($key .':', 20, ' '); |
| 76 |
$output .= $key . (string)_civicrm_error_check_length($value) ." \n"; |
$line = $key . (string)_civicrm_error_check_length($value) ." \n"; |
| 77 |
|
$output .= preg_replace($pattern, $replace, $line); |
| 78 |
|
|
| 79 |
} |
} |
| 80 |
return $output ."\n"; |
return $output ."\n"; |
| 81 |
} |
} |
| 87 |
if (is_null($item)) { |
if (is_null($item)) { |
| 88 |
return ' '; |
return ' '; |
| 89 |
} |
} |
| 90 |
if (strlen($item) > 2000) { |
if (strlen($item) > 50000) { |
| 91 |
$item = substr($item, 0, 4000) .'...'; |
$item = substr($item, 0, 50000) .'...'; |
| 92 |
} |
} |
| 93 |
return $item; |
return $item; |
| 94 |
} |
} |