Skip to content

Commit

Permalink
Merge pull request #2704 from hoaquynhtim99/develop
Browse files Browse the repository at this point in the history
Update NukeViet 5
  • Loading branch information
hoaquynhtim99 committed Aug 5, 2018
2 parents 7a35852 + f7de30e commit 1fe3725
Show file tree
Hide file tree
Showing 22 changed files with 154 additions and 102 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -24,6 +24,7 @@
/src/install/default.php
/src/composer.lock
/src/includes/composer.lock
/src/log.log

composer.lock
#vendor test ignore
Expand Down
2 changes: 1 addition & 1 deletion src/admin/siteinfo/logs.php
Expand Up @@ -80,7 +80,7 @@

if (! empty($data_search['to'])) {
if (preg_match('/^([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})$/', $data_search['to'], $match)) {
$to = mktime(0, 0, 0, $match[2], $match[1], $match[3]);
$to = mktime(23, 59, 59, $match[2], $match[1], $match[3]);
$array_where[] = 'log_time <= ' . $to;
$base_url .= '&amp;to=' . $data_search['to'];
}
Expand Down
5 changes: 3 additions & 2 deletions src/includes/ini.php
Expand Up @@ -18,7 +18,8 @@

$iniSaveTime = 0;
$ini_list = ini_get_all(null, false);
$config_ini_file = NV_ROOTDIR . '/' . NV_DATADIR . '/config_ini.' . preg_replace('/[^a-zA-Z0-9\.\_]/', '', $server_name) . '.php';
$ini_server = in_array($server_name, $global_config['my_domains']) ? $server_name : $global_config['my_domains'][0];
$config_ini_file = NV_ROOTDIR . '/' . NV_DATADIR . '/config_ini.' . preg_replace('/[^a-zA-Z0-9\.\_]/', '', $ini_server) . '.php';
@include_once $config_ini_file;
if ($iniSaveTime + 86400 < NV_CURRENTTIME) {
$content_config = "<?php" . "\n\n";
Expand Down Expand Up @@ -266,4 +267,4 @@
$content_config .= "\n";
$content_config .= "\$iniSaveTime = " . NV_CURRENTTIME . ";";
@file_put_contents($config_ini_file, $content_config, LOCK_EX);
}
}
16 changes: 10 additions & 6 deletions src/includes/mainfile.php
Expand Up @@ -57,6 +57,14 @@
}

require NV_ROOTDIR . '/' . NV_DATADIR . '/config_global.php';

if (empty($global_config['my_domains'])) {
$global_config['my_domains'] = [NV_SERVER_NAME];
} else {
$global_config['my_domains'] = array_map('trim', explode(',', $global_config['my_domains']));
$global_config['my_domains'] = array_map('strtolower', $global_config['my_domains']);
}

require NV_ROOTDIR . '/includes/ini.php';

require NV_ROOTDIR . '/includes/xtemplate.class.php';
Expand Down Expand Up @@ -160,10 +168,9 @@
}
unset($_parea, $_plugin, $pdata, $priority, $module_name, $_phook, $pdatahook);

$domains = explode(',', $global_config['my_domains']);
if (!in_array(NV_SERVER_NAME, $domains)) {
if (!in_array(NV_SERVER_NAME, $global_config['my_domains'])) {
$global_config['site_logo'] = NV_ASSETS_DIR . '/images/logo.png';
$global_config['site_url'] = NV_SERVER_PROTOCOL . '://' . $domains[0] . NV_SERVER_PORT;
$global_config['site_url'] = NV_SERVER_PROTOCOL . '://' . $global_config['my_domains'][0] . NV_SERVER_PORT;
nv_info_die($nv_Lang->get('error_404_title'), $nv_Lang->get('error_404_title'), $nv_Lang->get('error_404_content'), 400, '', '', '', '');
}
// Ket noi Cache
Expand All @@ -187,9 +194,6 @@
// vd: http://mydomain1.com/ten_thu_muc_chua_site
$global_config['site_url'] = $nv_Request->site_url;

// vd: array( 'mydomain1.com', 'mydomain2.com' )
$global_config['my_domains'] = $nv_Request->my_domains;

// vd: D:/AppServ/www/ten_thu_muc_chua_site/sess/
$sys_info['sessionpath'] = $nv_Request->session_save_path;

Expand Down
15 changes: 2 additions & 13 deletions src/includes/vendor/vinades/nukeviet/Core/Request.php
Expand Up @@ -25,7 +25,6 @@ class Request
public $server_protocol;
public $server_port;
public $my_current_domain;
public $my_domains;
public $headerstatus;
public $session_save_path;
public $cookie_path;
Expand Down Expand Up @@ -123,7 +122,7 @@ public function __construct($config, $ip)
if (extension_loaded('filter') and filter_id(ini_get('filter.default')) !== FILTER_UNSAFE_RAW) {
$this->is_filter = true;
}
$this->Initialize($config['my_domains']);
$this->Initialize();
$this->get_cookie_save_path();

$_ssl_https = (isset($config['ssl_https'])) ? $config['ssl_https'] : 0;
Expand Down Expand Up @@ -228,10 +227,9 @@ private function fixQuery(&$var, $mode)
/**
* Request::Initialize()
*
* @param mixed $my_domains
* @return
*/
private function Initialize($my_domains)
private function Initialize()
{
if (sizeof($_GET)) {
$array_keys = array_keys($_GET);
Expand Down Expand Up @@ -329,15 +327,6 @@ private function Initialize($my_domains)
}

$this->headerstatus = (substr(php_sapi_name(), 0, 3) == 'cgi') ? 'Status:' : $_SERVER['SERVER_PROTOCOL'];
$domains = array();
if (empty($my_domains)) {
$domains = ( array )$this->server_name;
} else {
$domains = array_map('trim', explode(',', $my_domains));
$domains = array_map('strtolower', $domains);
}
$this->my_domains = array_unique($domains);

$this->site_url = $this->my_current_domain . $this->base_siteurl;
$this->referer = $this->get_Env(array( 'HTTP_REFERER', 'Referer' ));
if (!empty($this->referer)) {
Expand Down
4 changes: 1 addition & 3 deletions src/install/mainfile.php
Expand Up @@ -60,7 +60,7 @@
require NV_ROOTDIR . '/includes/xtemplate.class.php';
require_once realpath(NV_ROOTDIR . '/install/config.php');

$global_config['my_domains'] = $_SERVER['SERVER_NAME'];
$global_config['my_domains'] = [$_SERVER['SERVER_NAME']];

// Xac dinh cac tags cho phep
$global_config['allowed_html_tags'] = array_map('trim', explode(',', NV_ALLOWED_HTML_TAGS));
Expand Down Expand Up @@ -147,8 +147,6 @@
//vd: .mydomain1.com
$global_config['site_url'] = $nv_Request->site_url;
//vd: http://mydomain1.com/ten_thu_muc_chua_site
$global_config['my_domains'] = $nv_Request->my_domains;
//vd: "mydomain1.com,mydomain2.com"

$sys_info['sessionpath'] = $nv_Request->session_save_path;
//vd: D:/AppServ/www/ten_thu_muc_chua_site/sess/
Expand Down
2 changes: 0 additions & 2 deletions src/modules/Banners/admin/add_banner.php
Expand Up @@ -115,8 +115,6 @@
$error = $nv_Lang->getModule('plan_not_selected');
} elseif (!empty($error_assign_user)) {
$error = $error_assign_user;
} elseif (!empty($click_url) and !nv_is_url($click_url)) {
$error = $nv_Lang->getModule('click_url_invalid');
} elseif (!is_uploaded_file($_FILES['banner']['tmp_name']) and $array_require_image[0]['require_image'] == 1) {
$error = $nv_Lang->getModule('file_upload_empty');
} else {
Expand Down
2 changes: 0 additions & 2 deletions src/modules/Banners/admin/edit_banner.php
Expand Up @@ -117,8 +117,6 @@
$error = $nv_Lang->getModule('plan_not_selected');
} elseif (!empty($error_assign_user)) {
$error = $error_assign_user;
} elseif (!empty($click_url) and !nv_is_url($click_url)) {
$error = $nv_Lang->getModule('click_url_invalid');
} elseif (!is_uploaded_file($_FILES['banner']['tmp_name']) && $array_require_image[0]['require_image'] == 1 && empty($file_name)) {
$error = $nv_Lang->getModule('file_upload_empty');
} else {
Expand Down
1 change: 0 additions & 1 deletion src/modules/Banners/language/en.php
Expand Up @@ -48,7 +48,6 @@
$lang_module['addads_block_lang_zz'] = 'Other';
$lang_module['title_empty'] = 'Title is empty';
$lang_module['plan_not_selected'] = 'You must select plan';
$lang_module['click_url_invalid'] = 'Invalid URL';
$lang_module['file_upload_empty'] = 'Empty image';
$lang_module['upload_blocked'] = 'Upload image and flash fail for this plan. Please contact the site administrator.';
$lang_module['addads_require_login'] = 'Only registed member can use this feature';
Expand Down
1 change: 0 additions & 1 deletion src/modules/Banners/language/fr.php
Expand Up @@ -49,7 +49,6 @@
$lang_module['title_empty'] = 'Erreur: manque de titre';
$lang_module['plan_not_selected'] = 'Veuillez sélectionner le block pour cette publicité';
$lang_module['plan_wrong_selected'] = 'Bloquer les annonces que vous n\'existe pas';
$lang_module['click_url_invalid'] = 'Lien invalide';
$lang_module['file_upload_empty'] = 'Erreur: manque d\'image';
$lang_module['upload_blocked'] = 'Le transfert de fichier flash est interdit par le système, donc vous ne pouvez pas ajouter les publicités. Vérifiez la configuration du site ou l\'autorisation des fichiers transférés.';
$lang_module['addads_require_login'] = 'Cette fonctinonalité est réservée uniquement aux utilisateurs enregistrées';
Expand Down
1 change: 0 additions & 1 deletion src/modules/Banners/language/vi.php
Expand Up @@ -49,7 +49,6 @@
$lang_module['title_empty'] = 'Tiêu đề chưa được khai báo';
$lang_module['plan_not_selected'] = 'Bạn chưa chọn Khối cho quảng cáo';
$lang_module['plan_wrong_selected'] = 'Khối cho quảng cáo bạn chọn không tồn tại';
$lang_module['click_url_invalid'] = 'URL khi click vào quảng cáo không hợp lệ';
$lang_module['file_upload_empty'] = 'Hình quảng cáo chưa được xác định';
$lang_module['upload_blocked'] = 'Việc tải lên các file hình ảnh và flash ở khối quảng cáo này đã bị cấm bởi hệ thống, vì vậy bạn không thể thêm quảng cáo. Hãy liên hệ với quản trị site về điều này';
$lang_module['addads_require_login'] = 'Chức năng này chỉ dành cho khách hàng đã đăng ký';
Expand Down
4 changes: 2 additions & 2 deletions src/modules/Comment/comment.php
Expand Up @@ -39,7 +39,7 @@ function nv_comment_data($module, $area, $id, $allowed, $page, $sortcomm, $base_
$num_items = $db_slave->query($db_slave->sql())->fetchColumn();
if ($num_items) {
$emailcomm = $module_config[$module]['emailcomm'];
$db_slave->select('a.cid, a.pid, a.content, a.attach, a.post_time, a.post_name, a.post_email, a.likes, a.dislikes, b.userid, b.email, b.first_name, b.last_name, b.photo, b.view_mail')->limit($per_page_comment)->offset(($page - 1) * $per_page_comment);
$db_slave->select('a.cid, a.pid, a.content, a.attach, a.post_time, a.post_name, a.post_email, a.likes, a.dislikes, b.userid, b.username, b.email, b.first_name, b.last_name, b.photo, b.view_mail')->limit($per_page_comment)->offset(($page - 1) * $per_page_comment);

if ($sortcomm == 1) {
$db_slave->order('a.cid ASC');
Expand Down Expand Up @@ -411,7 +411,7 @@ function nv_comment_module_data($module, $comment_array, $is_delete)
}

if (! empty($comment_array_i['userid'])) {
$comment_array_i['post_name'] = nv_show_name_user($comment_array_i['first_name'], $comment_array_i['last_name']);
$comment_array_i['post_name'] = nv_show_name_user($comment_array_i['first_name'], $comment_array_i['last_name'], $comment_array_i['username']);
}

if (!empty($module_config[$module]['allowautolink'])) {
Expand Down
22 changes: 22 additions & 0 deletions src/modules/EmailTemplates/language/en.php
@@ -0,0 +1,22 @@
<?php

/**
* @Project NUKEVIET 4.x
* @Author VINADES.,JSC <contact@vinades.vn>
* @Copyright (C) 2018 VINADES.,JSC. All rights reserved
* @Language Tiếng Việt
* @License CC BY-SA (http://creativecommons.org/licenses/by-sa/4.0/)
* @Createdate Mar 04, 2010, 08:22:00 AM
*/

if (!defined('NV_MAINFILE')) {
die('Stop!!!');
}

$lang_translator['author'] = 'VINADES.,JSC <contact@vinades.vn>';
$lang_translator['createdate'] = '04/03/2010, 15:22';
$lang_translator['copyright'] = '@Copyright (C) 2012 VINADES.,JSC. All rights reserved';
$lang_translator['info'] = '';
$lang_translator['langtype'] = 'lang_module';

//$lang_module['add_time'] = 'Thời gian đăng';
22 changes: 22 additions & 0 deletions src/modules/EmailTemplates/language/fr.php
@@ -0,0 +1,22 @@
<?php

/**
* @Project NUKEVIET 4.x
* @Author VINADES.,JSC <contact@vinades.vn>
* @Copyright (C) 2018 VINADES.,JSC. All rights reserved
* @Language Tiếng Việt
* @License CC BY-SA (http://creativecommons.org/licenses/by-sa/4.0/)
* @Createdate Mar 04, 2010, 08:22:00 AM
*/

if (!defined('NV_MAINFILE')) {
die('Stop!!!');
}

$lang_translator['author'] = 'VINADES.,JSC <contact@vinades.vn>';
$lang_translator['createdate'] = '04/03/2010, 15:22';
$lang_translator['copyright'] = '@Copyright (C) 2012 VINADES.,JSC. All rights reserved';
$lang_translator['info'] = '';
$lang_translator['langtype'] = 'lang_module';

//$lang_module['add_time'] = 'Thời gian đăng';
96 changes: 48 additions & 48 deletions src/modules/News/funcs/detail.php
Expand Up @@ -28,45 +28,45 @@
nv_redirect_location($news_contents['sourcetext']);
}

if ($nv_Request->isset_request('download', 'get')) {
$fileid = $nv_Request->get_int('id', 'get', 0);
if ($nv_Request->isset_request('download', 'get')) {
$fileid = $nv_Request->get_int('id', 'get', 0);

$news_contents['files'] = explode(',', $news_contents['files']);
$news_contents['files'] = explode(',', $news_contents['files']);

if (!isset($news_contents['files'][$fileid])) {
nv_redirect_location(NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name, true);
}
if (!isset($news_contents['files'][$fileid])) {
nv_redirect_location(NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name, true);
}

if (!file_exists(NV_UPLOADS_REAL_DIR . '/' . $module_upload . '/' . $news_contents['files'][$fileid])) {
nv_redirect_location(NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name, true);
}
if (!file_exists(NV_UPLOADS_REAL_DIR . '/' . $module_upload . '/' . $news_contents['files'][$fileid])) {
nv_redirect_location(NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name, true);
}

$file_info = pathinfo(NV_UPLOADS_REAL_DIR . '/' . $module_upload . '/' . $news_contents['files'][$fileid]);
$download = new NukeViet\Files\Download(NV_UPLOADS_REAL_DIR . '/' . $module_upload . '/' . $news_contents['files'][$fileid], $file_info['dirname'], $file_info['basename'], true);
$download->download_file();
exit();
}
$file_info = pathinfo(NV_UPLOADS_REAL_DIR . '/' . $module_upload . '/' . $news_contents['files'][$fileid]);
$download = new NukeViet\Files\Download(NV_UPLOADS_REAL_DIR . '/' . $module_upload . '/' . $news_contents['files'][$fileid], $file_info['dirname'], $file_info['basename'], true);
$download->download_file();
exit();
}

if ($nv_Request->isset_request('pdf', 'get')) {
$fileid = $nv_Request->get_int('id', 'get', 0);
if ($nv_Request->isset_request('pdf', 'get')) {
$fileid = $nv_Request->get_int('id', 'get', 0);

$news_contents['files'] = explode(',', $news_contents['files']);
$news_contents['files'] = explode(',', $news_contents['files']);

if (!isset($news_contents['files'][$fileid])) {
nv_info_die($nv_Lang->getGlobal('error_404_title'), $nv_Lang->getGlobal('error_404_title'), $nv_Lang->getGlobal('error_404_content'), 404);
}
if (!isset($news_contents['files'][$fileid])) {
nv_info_die($nv_Lang->getGlobal('error_404_title'), $nv_Lang->getGlobal('error_404_title'), $nv_Lang->getGlobal('error_404_content'), 404);
}

if (!file_exists(NV_UPLOADS_REAL_DIR . '/' . $module_upload . '/' . $news_contents['files'][$fileid])) {
nv_info_die($nv_Lang->getGlobal('error_404_title'), $nv_Lang->getGlobal('error_404_title'), $nv_Lang->getGlobal('error_404_content'), 404);
}
if (!file_exists(NV_UPLOADS_REAL_DIR . '/' . $module_upload . '/' . $news_contents['files'][$fileid])) {
nv_info_die($nv_Lang->getGlobal('error_404_title'), $nv_Lang->getGlobal('error_404_title'), $nv_Lang->getGlobal('error_404_content'), 404);
}

$file_url = nv_url_rewrite(NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $global_array_cat[$news_contents['catid']]['alias'] . '/' . $news_contents['alias'] . '-' . $news_contents['id'] . $global_config['rewrite_exturl'], true) . '?download=1&id=' . $fileid;
$file_url = nv_url_rewrite(NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $global_array_cat[$news_contents['catid']]['alias'] . '/' . $news_contents['alias'] . '-' . $news_contents['id'] . $global_config['rewrite_exturl'], true) . '?download=1&id=' . $fileid;

$contents = nv_theme_viewpdf($file_url);
nv_htmlOutput($contents);
}
$contents = nv_theme_viewpdf($file_url);
nv_htmlOutput($contents);
}

$base_url_rewrite = nv_url_rewrite(NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $global_array_cat[$news_contents['catid']]['alias'] . '/' . $news_contents['alias'] . '-' . $news_contents['id'] . $global_config['rewrite_exturl'], true);
$base_url_rewrite = nv_url_rewrite(NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $global_array_cat[$news_contents['catid']]['alias'] . '/' . $news_contents['alias'] . '-' . $news_contents['id'] . $global_config['rewrite_exturl'], true);
if ($_SERVER['REQUEST_URI'] == $base_url_rewrite) {
$canonicalUrl = NV_MAIN_DOMAIN . $base_url_rewrite;
} elseif (NV_MAIN_DOMAIN . $_SERVER['REQUEST_URI'] != $base_url_rewrite) {
Expand Down Expand Up @@ -136,26 +136,26 @@
$meta_property['og:image'] = NV_MY_DOMAIN . NV_BASE_SITEURL . $show_no_image;
}

// File download
if (!empty($news_contents['files'])) {
$news_contents['files'] = explode(',', $news_contents['files']);
$files = $news_contents['files'];
$news_contents['files'] = array();

foreach ($files as $id => $file) {
$file_title = (!preg_match("/^http*/", $file)) ? basename($file) : $nv_Lang->getModule('click_to_download');
$news_contents['files'][] = array(
'title' => $file_title,
'key' => md5($id . $file_title),
'ext' => nv_getextension($file_title),
'titledown' => $nv_Lang->getModule('download') . ' ' . (count($files) > 1 ? $id + 1 : ''),
'src' => NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_upload . '/' . $file,
'url' => (!preg_match("/^http*/", $file)) ? $base_url_rewrite . '?download=1&amp;id=' . $id : $file,
'urlpdf' => $base_url_rewrite . '?pdf=1&amp;id=' . $id,
'urldoc' => (preg_match("/^http*/", $file)) ? $file : 'https://docs.google.com/viewer?embedded=true&url=' . NV_MY_DOMAIN . '/' . NV_UPLOADS_DIR . '/' . $module_upload . '/' . $file
);
}
}
// File download
if (!empty($news_contents['files'])) {
$news_contents['files'] = explode(',', $news_contents['files']);
$files = $news_contents['files'];
$news_contents['files'] = array();

foreach ($files as $file_id => $file) {
$file_title = (!preg_match("/^http*/", $file)) ? basename($file) : $nv_Lang->getModule('click_to_download');
$news_contents['files'][] = array(
'title' => $file_title,
'key' => md5($file_id . $file_title),
'ext' => nv_getextension($file_title),
'titledown' => $nv_Lang->getModule('download') . ' ' . (count($files) > 1 ? $file_id + 1 : ''),
'src' => NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_upload . '/' . $file,
'url' => (!preg_match("/^http*/", $file)) ? $base_url_rewrite . '?download=1&amp;id=' . $file_id : $file,
'urlpdf' => $base_url_rewrite . '?pdf=1&amp;id=' . $file_id,
'urldoc' => (preg_match("/^http*/", $file)) ? $file : 'https://docs.google.com/viewer?embedded=true&url=' . NV_MY_DOMAIN . '/' . NV_UPLOADS_DIR . '/' . $module_upload . '/' . $file
);
}
}

$publtime = intval($news_contents['publtime']);
$meta_property['og:type'] = 'article';
Expand Down

0 comments on commit 1fe3725

Please sign in to comment.