Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 187 lines (161 sloc) 5.474 kb
d07f25e @MightyGorgon git-svn-id: http://svn.assembla.com/svn/icy_phoenix/ip/trunk@29 e0e46c49...
authored
1 <?php
2 /**
3 *
4 * @package Icy Phoenix
5 * @version $Id$
6 * @copyright (c) 2008 Icy Phoenix
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
8 *
9 */
10
11 // CTracker_Ignore: File checked by human
12 define('MG_KILL_CTRACK', true);
841b23a @MightyGorgon New beta candidate... with many many changes and new features respect to...
authored
13 define('IN_ICYPHOENIX', true);
06ce0f8 @MightyGorgon Brand new version...
authored
14 if (!defined('IP_ROOT_PATH')) define('IP_ROOT_PATH', './');
15 if (!defined('PHP_EXT')) define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
16 include(IP_ROOT_PATH . 'common.' . PHP_EXT);
d07f25e @MightyGorgon git-svn-id: http://svn.assembla.com/svn/icy_phoenix/ip/trunk@29 e0e46c49...
authored
17
18 // Start session management
19 $userdata = session_pagestart($user_ip);
20 init_userprefs($userdata);
21 // End session management
22
23 // Errors Configuration Flags
24
25 // N = no email / Y = email
26 $email = array (
27 '000' => 'N',
28 '400' => 'N',
29 '401' => 'N',
30 '403' => 'N',
31 '404' => 'N',
32 '500' => 'N'
33 );
34
35 // N = no log file / Y = log file
36 $log = array (
37 '000' => 'Y',
38 '400' => 'Y',
39 '401' => 'Y',
40 '403' => 'Y',
41 '404' => 'Y',
42 '500' => 'Y'
43 );
44
45 // Errors description
46
47 /*
48 $subject = array (
49 '000' => 'Unknown Error',
50 '400' => 'Error 400',
51 '401' => 'Not Authorized',
52 '403' => 'Errore 403',
53 '404' => 'File not found',
54 '500' => 'Configuration Error'
55 );
56 */
57 $subject = array (
58 '000' => $lang['Errors_000'],
59 '400' => $lang['Errors_400'],
60 '401' => $lang['Errors_401'],
61 '403' => $lang['Errors_403'],
62 '404' => $lang['Errors_404'],
63 '500' => $lang['Errors_500']
64 );
65
66
67 //$result = $QUERY_STRING;
68 if (isset($_GET['code']))
69 {
70 $result = intval($_GET['code']);
71 }
72
73 switch($result)
74 {
75 case 400:
76 $error_msg = $lang['Errors_400_Full'];
77 break;
78 case 401:
79 $error_msg = $lang['Errors_401_Full'];
80 break;
81 case 403:
82 $error_msg = $lang['Errors_403_Full'];
83 break;
84 case 404:
85 $error_msg = $lang['Errors_404_Full'];
86 break;
87 case 500:
88 $error_msg = $lang['Errors_500_Full'];
89 break;
90 default:
91 $result = '000';
92 $error_msg = $lang['Errors_000_Full'];
93 }
94
95 // Error notification details
96 $server_url = create_server_url();
97
98 $notification_email = $board_config['board_email'];
99 $sitename = $board_config['sitename'];
100 $datecode = date('Ymd');
101 $logs_path = !empty($board_config['logs_path']) ? $board_config['logs_path'] : 'logs';
102 $errors_log = $logs_path . '/errors_' . $datecode . '.txt';
103 //$errors_log = 'logs/errors.txt';
104
105 if (($board_config['write_errors_log'] == true) && ($log[$result] == 'Y'))
106 {
107 errors_notification('L', $result, $sitename, $subject, $errors_log, $notification_email);
108 }
109
110 if ($email[$result] == 'Y')
111 {
112 errors_notification('M', $result, $sitename, $subject, $errors_log, $notification_email);
113 }
114
115 // Start output of page
9dea0d4 @MightyGorgon New Icy Phoenix structure.
authored
116 $page_title = $lang['Error'];
d07f25e @MightyGorgon git-svn-id: http://svn.assembla.com/svn/icy_phoenix/ip/trunk@29 e0e46c49...
authored
117 $meta_description = '';
118 $meta_keywords = '';
119 $board_config['thumbnail_lightbox'] = false;
120 $board_config['ajax_features'] = false;
06ce0f8 @MightyGorgon Brand new version...
authored
121 include(IP_ROOT_PATH . 'includes/page_header.' . PHP_EXT);
d07f25e @MightyGorgon git-svn-id: http://svn.assembla.com/svn/icy_phoenix/ip/trunk@29 e0e46c49...
authored
122
123 $template->set_filenames(array('body' => 'errors_body.tpl'));
124
125 $template->assign_vars(array(
126 'ERROR_MESSAGE' => $error_msg
127 )
128 );
129
130 $template->pparse('body');
131
06ce0f8 @MightyGorgon Brand new version...
authored
132 include(IP_ROOT_PATH . 'includes/page_tail.' . PHP_EXT);
d07f25e @MightyGorgon git-svn-id: http://svn.assembla.com/svn/icy_phoenix/ip/trunk@29 e0e46c49...
authored
133
134
135 function errors_notification($action, $result, $sitename, $subject, $errors_log, $notification_email)
136 {
137 global $REQUEST_URI, $REMOTE_ADDR, $HTTP_USER_AGENT, $REDIRECT_ERROR_NOTES, $SERVER_NAME, $HTTP_REFERER;
138 global $lang;
139
140 $remote_address = (!empty($_SERVER['REMOTE_ADDR'])) ? $_SERVER['REMOTE_ADDR'] : ((!empty($_ENV['REMOTE_ADDR'])) ? $_ENV['REMOTE_ADDR'] : getenv('REMOTE_ADDR'));
141 $user_agent = (!empty($_SERVER['HTTP_USER_AGENT']) ? trim($_SERVER['HTTP_USER_AGENT']) : (!empty($_ENV['HTTP_USER_AGENT']) ? trim($_ENV['HTTP_USER_AGENT']) : trim(getenv('HTTP_USER_AGENT'))));
142 $referer = (!empty($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : getenv('HTTP_REFERER');
143 //$referer = ($referer == '') ? $HTTP_REFERER : $HTTP_REFERER;
144 $referer = ($referer == '') ? $HTTP_REFERER : $referer;
145 $referer = preg_replace('/sid=[A-Za-z0-9]{32}/', '', $referer);
146 $script_name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI');
147 $server_name = (!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME');
148
149 $date = date('Y/m/d - H:i:s');
150
151 if ( ($action == 'L') || ($action == 'LM') )
152 {
153 $message = '[' . $date . ']';
154 $message .= ' [URL: ' . $script_name . ' ]';
155 $message .= ' [REF: ' . $referer . ' ]';
156 $message .= ' [IP: ' . $remote_address . ']';
157 $message .= ' [Client: ' . $user_agent . ']';
158 $message .= "\n";
159 $fp = fopen ($errors_log, "a+");
160 fwrite($fp, $message);
161 fclose($fp);
162 }
163
164 if ( ($action == 'M') || ($action == 'LM') )
165 {
166 $message_full = "
167 ==============================================================================
168 ------------------------------------------------------------------------------
169 ==============================================================================
170 Site: $sitename ($server_name)
171 Error Code: $result $subject[$result]
172 Date: $date
173 URL: $referer
174 IP Address: $remote_address
175 Browser: $user_agent
176 ==============================================================================
177 ------------------------------------------------------------------------------
178 ==============================================================================
179 ";
180 $message = $lang['Errors_Email_Body'];
181 $subject_prefix = $lang['Errors_Email_Subject'];
182 $email_from_prefix = $lang['Errors_Email_Addrress_Prefix'];
183 mail($notification_email, '[ ' . $subject_prefix . $subject[$result] . ' ]', $message, 'From: ' . $email_from_prefix . @$server_name . "\r\n" . 'X-Mailer: PHP/' . phpversion());
184 }
185 }
186
187 ?>
Something went wrong with that request. Please try again.