Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Curriculum-Request
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tim Steiner
Curriculum-Request
Commits
7c38fbea
Commit
7c38fbea
authored
16 years ago
by
Tim Steiner
Browse files
Options
Downloads
Patches
Plain Diff
Set up exception handling.
parent
d62bf7f8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
application/modules/default/controllers/ErrorController.php
+57
-8
57 additions, 8 deletions
application/modules/default/controllers/ErrorController.php
application/modules/default/views/scripts/error/error.phtml
+9
-1
9 additions, 1 deletion
application/modules/default/views/scripts/error/error.phtml
with
66 additions
and
9 deletions
application/modules/default/controllers/ErrorController.php
+
57
−
8
View file @
7c38fbea
...
@@ -2,20 +2,69 @@
...
@@ -2,20 +2,69 @@
/**
/**
* ErrorController
* ErrorController
*
*
* @author
* @author
* @version
* @version
*/
*/
require_once
'Zend/Controller/Action.php'
;
require_once
'Zend/Controller/Action.php'
;
class
ErrorController
extends
Unl
_Controller_Action
{
class
ErrorController
extends
App
_Controller_Action
{
/**
* The default action - show the home page
protected
$_exceptions
;
*/
public
function
errorAction
()
{
public
function
errorAction
()
{
$exceptions
=
$this
->
getResponse
()
->
getException
();
$this
->
_exceptions
=
$this
->
getResponse
()
->
getException
();
throw
$exceptions
[
0
];
if
(
$_SERVER
[
'REMOTE_ADDR'
]
==
'129.93.39.17'
)
{
header
(
'Content-type: text/plain'
);
print_r
(
$this
->
_exceptions
);
exit
;
}
$this
->
_sendEmail
(
'tsteiner2@unl.edu'
);
$this
->
view
->
exceptions
=
$this
->
_exceptions
;
}
}
protected
function
_sendEmail
(
$address
,
$moreAddresses
=
'...'
)
{
$mail
=
new
Zend_Mail
(
'utf-8'
);
$mail
->
setFrom
(
'php@'
.
$_SERVER
[
'SERVER_NAME'
],
$_SERVER
[
'SERVER_NAME'
]);
$mail
->
setSubject
(
'Exception Report'
);
foreach
(
func_get_args
()
as
$address
)
{
if
(
is_array
(
$address
))
{
$mail
->
addTo
(
$address
[
0
],
$address
[
1
]);
}
else
{
$mail
->
addTo
(
$address
);
}
}
$date
=
date
(
'Y-m-d'
);
$time
=
date
(
'H:i'
);
$body
=
"The following exception occured on
$date
at
$time
.
\n\n
"
.
print_r
(
$this
->
_exceptions
,
true
)
.
"
\n
Request URI: "
.
$_SERVER
[
'REQUEST_URI'
]
.
"
\n
"
.
"User Agent: "
.
$_SERVER
[
'HTTP_USER_AGENT'
]
.
"
\n
"
.
"User IP Address :"
.
$_SERVER
[
'REMOTE_ADDR'
]
.
"
\n
"
;
if
(
count
(
$_GET
)
>
0
)
{
$body
.
=
"
\n
GET variables:
\n
"
.
print_r
(
$_GET
,
true
);
}
if
(
count
(
$_POST
)
>
0
)
{
$body
.
=
"
\n
POST variables:
\n
"
.
print_r
(
$_POST
,
true
);
}
/*
if(session_id() && ($_SESSION) > 0) {
$body .= "\nSESSION variables: \n"
. print_r($_SESSION, true);
}
*/
$mail
->
setBodyText
(
$body
);
$mail
->
send
();
}
}
}
This diff is collapsed.
Click to expand it.
application/modules/default/views/scripts/error/error.phtml
+
9
−
1
View file @
7c38fbea
<h1>
Error
</h1>
<h1>
Unfortunately an unexpected error has occured.
</h1>
\ No newline at end of file
<h2>
Details have been mailed to the administrator for analysis.
</h2>
<p>
The error message was: "
<?php
echo
$this
->
exceptions
[
0
]
->
getMessage
();
?>
"
</p>
<p>
We appologize for the inconvience.
Please use the back button to return to your previous location
</p>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment