Skip to content

Commit f8dd3cd

Browse files
committed
Update Error Document
1 parent be9c7aa commit f8dd3cd

File tree

12 files changed

+185
-20
lines changed

12 files changed

+185
-20
lines changed

.htaccess

+12-11
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@
44
AddDefaultCharset UTF-8
55
</Files>
66

7-
<Files .htaccess>
8-
order allow,deny
9-
deny from all
10-
</Files>
7+
RedirectMatch 404 ^.*\/(config|mainfile)\.php(.*)$
118

12-
<Files config.php>
13-
order allow,deny
14-
deny from all
15-
</Files>
9+
ErrorDocument 400 /error.php?code=400
10+
ErrorDocument 403 /error.php?code=403
11+
ErrorDocument 404 /error.php?code=404
12+
ErrorDocument 405 /error.php?code=405
13+
ErrorDocument 408 /error.php?code=408
14+
ErrorDocument 500 /error.php?code=500
15+
ErrorDocument 502 /error.php?code=502
16+
ErrorDocument 504 /error.php?code=504
1617

1718
<IfModule mod_deflate.c>
1819
<FilesMatch "\.(css|js|xml|ttf)$">
@@ -46,7 +47,7 @@
4647

4748
<IfModule mod_rewrite.c>
4849
RewriteEngine On
49-
#RewriteBase /nukeviet/
50+
#RewriteBase /
5051
RewriteCond %{REQUEST_FILENAME} /robots.txt$ [NC]
5152
RewriteRule ^ robots.php?action=%{HTTP_HOST} [L]
5253
RewriteRule ^(.*?)sitemap\.xml$ index.php?nv=SitemapIndex [L]
@@ -56,8 +57,8 @@ RewriteCond %{REQUEST_FILENAME} !-f
5657
RewriteCond %{REQUEST_FILENAME} !-d
5758
RewriteRule (.*)(\/|\.html)$ index.php
5859
RewriteRule (.*)tag\/([^?]+)$ index.php
59-
RewriteRule ^([a-zA-Z0-9-\/]+)\/([a-zA-Z0-9-]+)$ /nukeviet/$1/$2/ [L,R=301]
60-
RewriteRule ^([a-zA-Z0-9-]+)$ /nukeviet/$1/ [L,R=301]
60+
RewriteRule ^([a-zA-Z0-9-\/]+)\/([a-zA-Z0-9-]+)$ /$1/$2/ [L,R=301]
61+
RewriteRule ^([a-zA-Z0-9-]+)$ /$1/ [L,R=301]
6162
</IfModule>
6263

6364
#nukeviet_rewrite_end

assets/.htaccess

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<Files ~ "\.(php|php3|php4|php5|phtml|shtml|inc|asp|aspx|pl|py|jsp|asp|sh|cgi)$">
2-
deny from all
2+
RedirectMatch 404 ^.*$
33
</Files>

data/.htaccess

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<Files ~ "\.(php|php3|php4|php5|phtml|shtml|inc|asp|aspx|pl|py|jsp|asp|sh|cgi)$">
2-
deny from all
2+
RedirectMatch 404 ^.*$
33
</Files>

error.php

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
<?php
2+
3+
/**
4+
* @Project NUKEVIET 4.x
5+
* @Author VINADES.,JSC ([email protected])
6+
* @Copyright (C) 2017 VINADES.,JSC. All rights reserved
7+
* @License GNU/GPL version 2 or any later version
8+
* @Createdate Jul 2, 2017 2:06:56 PM
9+
*/
10+
11+
define('NV_SYSTEM', true);
12+
13+
// Xac dinh thu muc goc cua site
14+
define('NV_ROOTDIR', pathinfo(str_replace(DIRECTORY_SEPARATOR, '/', __file__), PATHINFO_DIRNAME));
15+
16+
require NV_ROOTDIR . '/includes/mainfile.php';
17+
18+
// Xac dinh kieu giao dien mac dinh
19+
$global_config['current_theme_type'] = $nv_Request->get_string('nv' . NV_LANG_DATA . 'themever', 'cookie', '');
20+
if (!in_array($global_config['current_theme_type'], $global_config['array_theme_type'])) {
21+
$global_config['current_theme_type'] = '';
22+
$nv_Request->set_Cookie('nv' . NV_LANG_DATA . 'themever', '', NV_LIVE_COOKIE_TIME);
23+
}
24+
25+
// Xac dinh giao dien chung
26+
$is_mobile = false;
27+
$theme_type = '';
28+
$_theme_mobile = $global_config['mobile_theme'];
29+
if ((($client_info['is_mobile'] and (empty($global_config['current_theme_type']) or empty($global_config['switch_mobi_des']))) or ($global_config['current_theme_type'] == 'm' and !empty($global_config['switch_mobi_des']))) and !empty($_theme_mobile) and file_exists(NV_ROOTDIR . '/themes/' . $_theme_mobile . '/theme.php')) {
30+
$site_theme = $_theme_mobile;
31+
$is_mobile = true;
32+
$theme_type = 'm';
33+
} else {
34+
if (empty($global_config['current_theme_type']) and ($client_info['is_mobile'] or empty($_theme_mobile))) {
35+
$global_config['current_theme_type'] = 'r';
36+
}
37+
38+
$_theme = $global_config['site_theme'];
39+
if (!empty($_theme) and file_exists(NV_ROOTDIR . '/themes/' . $_theme . '/theme.php')) {
40+
$site_theme = $_theme;
41+
$theme_type = $global_config['current_theme_type'];
42+
} elseif (file_exists(NV_ROOTDIR . '/themes/default/theme.php')) {
43+
$site_theme = 'default';
44+
$theme_type = $global_config['current_theme_type'];
45+
} else {
46+
trigger_error('Error! Does not exist themes default', 256);
47+
}
48+
}
49+
50+
// Xac lap lai giao kieu giao dien hien tai
51+
if ($theme_type != $global_config['current_theme_type']) {
52+
$global_config['current_theme_type'] = $theme_type;
53+
$nv_Request->set_Cookie('nv' . NV_LANG_DATA . 'themever', $theme_type, NV_LIVE_COOKIE_TIME);
54+
}
55+
unset($theme_type);
56+
57+
// Doc file cau hinh giao dien
58+
$themeConfig = nv_object2array(simplexml_load_file(NV_ROOTDIR . '/themes/' . $site_theme . '/config.ini'));
59+
if (isset($themeConfig['positions']['position']['name'])) {
60+
$themeConfig['positions']['position'] = array(
61+
$themeConfig['positions']['position']
62+
);
63+
}
64+
require NV_ROOTDIR . '/themes/' . $site_theme . '/theme.php';
65+
66+
// Ket noi ngon ngu theo theme
67+
if (file_exists(NV_ROOTDIR . '/themes/' . $site_theme . '/language/' . NV_LANG_INTERFACE . '.php')) {
68+
require NV_ROOTDIR . '/themes/' . $site_theme . '/language/' . NV_LANG_INTERFACE . '.php';
69+
} elseif (file_exists(NV_ROOTDIR . '/themes/' . $site_theme . '/language/en.php')) {
70+
require NV_ROOTDIR . '/themes/' . $site_theme . '/language/en.php';
71+
}
72+
73+
$error_code = $nv_Request->get_int('code', 'get', 404);
74+
75+
$title = isset($lang_global['error_' . $error_code . '_title']) ? $lang_global['error_' . $error_code . '_title'] : 'Error Code: ' . $error_code;
76+
77+
if (isset($lang_global['error_' . $error_code . '_content'])) {
78+
$content = $lang_global['error_' . $error_code . '_content'];
79+
} else {
80+
switch ($error_code) {
81+
case 400:
82+
$content = 'Bad Request';
83+
break;
84+
case 403:
85+
$content = 'Forbidden';
86+
break;
87+
case 404:
88+
$content = 'Not Found';
89+
break;
90+
case 405:
91+
$content = 'Method Not Allowed';
92+
break;
93+
case 408:
94+
$content = 'Request Time-out';
95+
break;
96+
case 500:
97+
$content = 'Internal Server Error';
98+
break;
99+
case 502:
100+
$content = 'Bad Gateway';
101+
break;
102+
case 504:
103+
$content = 'Gateway Time-out';
104+
break;
105+
default:
106+
$content = 'Error code: ' . $error_code;
107+
break;
108+
}
109+
}
110+
111+
if (function_exists('nv_error_theme')) {
112+
nv_error_theme($title, $content, $error_code);
113+
} else {
114+
nv_info_die($title, $title, $content, $error_code);
115+
}

includes/.htaccess

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
deny from all
1+
RedirectMatch 404 ^.*$

includes/core/theme_functions.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,14 @@ function nv_info_die($page_title = '', $info_title, $info_content, $error_code =
9595
{
9696
global $lang_global, $global_config;
9797

98-
http_response_code($error_code); // only (PHP 5 >= 5.4.0, PHP 7)
98+
http_response_code($error_code);
9999

100100
if (empty($page_title)) {
101101
$page_title = $global_config['site_description'];
102102
}
103103

104104
// Get theme
105105
$template = '';
106-
107106
if (defined('NV_ADMIN') and isset($global_config['admin_theme']) and file_exists(NV_ROOTDIR . '/themes/' . $global_config['admin_theme'] . '/system/info_die.tpl')) {
108107
$tpl_path = NV_ROOTDIR . '/themes/' . $global_config['admin_theme'] . '/system';
109108
$template = $global_config['admin_theme'];

modules/.htaccess

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<Files ~ "\.(php|ini|tpl|php|php3|php4|php5|phtml|shtml|inc|asp|aspx|pl|py|jsp|asp|sh|cgi)$">
2-
deny from all
2+
RedirectMatch 404 ^.*$
33
</Files>

themes/.htaccess

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<Files ~ "\.(php|ini|tpl|php3|php4|php5|phtml|shtml|inc|asp|aspx|pl|py|jsp|asp|sh|cgi)$">
2-
deny from all
2+
RedirectMatch 404 ^.*$
33
</Files>

themes/default/theme.php

+25
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212
die('Stop!!!');
1313
}
1414

15+
/**
16+
* nv_mailHTML()
17+
*
18+
* @param string $title
19+
* @param string $content
20+
* @param string $footer
21+
*/
1522
function nv_mailHTML($title, $content, $footer='')
1623
{
1724
global $global_config, $lang_global;
@@ -26,6 +33,12 @@ function nv_mailHTML($title, $content, $footer='')
2633
return $xtpl->text('main');
2734
}
2835

36+
/**
37+
* nv_site_theme()
38+
*
39+
* @param string $contents
40+
* @param bool $full
41+
*/
2942
function nv_site_theme($contents, $full = true)
3043
{
3144
global $home, $array_mod_title, $lang_global, $global_config, $site_mods, $module_name, $module_info, $op_file, $mod_title, $my_head, $my_footer, $client_info, $module_config, $op;
@@ -283,3 +296,15 @@ function nv_site_theme($contents, $full = true)
283296

284297
return $sitecontent;
285298
}
299+
300+
/**
301+
* nv_error_theme()
302+
*
303+
* @param string $title
304+
* @param string $content
305+
* @param integer $code
306+
*/
307+
function nv_error_theme($title, $content, $code)
308+
{
309+
nv_info_die($title, $title, $content, $code);
310+
}

themes/mobile_default/theme.php

+25
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212
die('Stop!!!');
1313
}
1414

15+
/**
16+
* nv_mailHTML()
17+
*
18+
* @param string $title
19+
* @param string $content
20+
* @param string $footer
21+
*/
1522
function nv_mailHTML($title, $content, $footer='')
1623
{
1724
global $global_config, $lang_global;
@@ -26,6 +33,12 @@ function nv_mailHTML($title, $content, $footer='')
2633
return $xtpl->text('main');
2734
}
2835

36+
/**
37+
* nv_site_theme()
38+
*
39+
* @param string $contents
40+
* @param bool $full
41+
*/
2942
function nv_site_theme($contents, $full = true)
3043
{
3144
global $home, $array_mod_title, $lang_global, $language_array, $global_config, $site_mods, $module_name, $module_info, $op_file, $mod_title, $my_head, $my_footer, $client_info, $module_config, $op, $drag_block;
@@ -250,3 +263,15 @@ function nv_site_theme($contents, $full = true)
250263

251264
return $sitecontent;
252265
}
266+
267+
/**
268+
* nv_error_theme()
269+
*
270+
* @param string $title
271+
* @param string $content
272+
* @param integer $code
273+
*/
274+
function nv_error_theme($title, $content, $code)
275+
{
276+
nv_info_die($title, $title, $content, $code);
277+
}

uploads/.htaccess

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<Files ~ "\.(php|php3|php4|php5|phtml|shtml|inc|asp|aspx|pl|py|jsp|asp|sh|cgi)$">
2-
deny from all
2+
RedirectMatch 404 ^.*$
33
</Files>

vendor/.htaccess

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
deny from all
1+
RedirectMatch 404 ^.*$

0 commit comments

Comments
 (0)