Skip to content

Commit

Permalink
Merge pull request #3547 from hoaquynhtim99/nukeviet4.6
Browse files Browse the repository at this point in the history
Fix class http php 8.2
  • Loading branch information
anhtunguyen committed Jan 17, 2023
2 parents c86485f + 22fbfb8 commit b31bcb3
Show file tree
Hide file tree
Showing 20 changed files with 80 additions and 79 deletions.
1 change: 1 addition & 0 deletions admin/upload/folderlist.php
Expand Up @@ -133,6 +133,7 @@ function viewdirtree($dir, $currentpath)
$xtpl->assign('ROTATE_FILE', (isset($check_allow_upload_dir['rotate_file']) and $check_allow_upload_dir['rotate_file'] === true) ? 1 : 0);
$xtpl->assign('DELETE_FILE', (isset($check_allow_upload_dir['delete_file']) and $check_allow_upload_dir['delete_file'] === true) ? 1 : 0);
$xtpl->assign('MOVE_FILE', (isset($check_allow_upload_dir['move_file']) and $check_allow_upload_dir['move_file'] === true) ? 1 : 0);
$xtpl->assign('OVER_CAPACITY', (isset($check_allow_upload_dir['over_capacity']) and $check_allow_upload_dir['over_capacity'] === true) ? 1 : 0);

if (empty($content)) {
$content = '<li class="hide">&nbsp;</li>';
Expand Down
5 changes: 5 additions & 0 deletions admin/upload/functions.php
Expand Up @@ -159,6 +159,11 @@ function nv_check_allow_upload_dir($dir)
$level['auto_logo'] = true;
}

if (!empty($global_config['over_capacity']) and !defined('NV_IS_GODADMIN')) {
unset($level['create_file'], $level['recreatethumb'], $level['upload_file'], $level['create_dir']);
$level['over_capacity'] = true;
}

return $level;
}

Expand Down
4 changes: 3 additions & 1 deletion admin/upload/upload.php
Expand Up @@ -30,7 +30,9 @@
$upload_info = [];
$is_remote_upload = false;

if (!isset($check_allow_upload_dir['upload_file'])) {
if (isset($check_allow_upload_dir['over_capacity'])) {
$error = $lang_module['over_capacity'];
} elseif (!isset($check_allow_upload_dir['upload_file'])) {
$error = $lang_module['notlevel'];
} elseif (!isset($_FILES, $_FILES['upload'], $_FILES['upload']['tmp_name']) and !$nv_Request->isset_request('fileurl', 'post')) {
$error = $lang_module['uploadError1'];
Expand Down
3 changes: 2 additions & 1 deletion assets/js/upload.js
Expand Up @@ -1998,9 +1998,10 @@ var NVUPLOAD = {

// Check folder if allow upload
var isUploadAllow = $("span#upload_file").attr("title") == "1" ? true : false;
var isOverCapacity = $("span#over_capacity").attr("title") == "1" ? true : false;

if (!isUploadAllow) {
$('#upload-button-area').html('<span class="text-danger"><em class="fa fa-info">&nbsp;</em>' + LANG.notupload + '</span>');
$('#upload-button-area').html('<span class="text-danger"><em class="fa fa-info">&nbsp;</em>' + (isOverCapacity ? LANG.over_capacity : LANG.notupload) + '</span>');
} else {
NVUPLOAD.buildBtns();

Expand Down
1 change: 1 addition & 0 deletions includes/language/en/admin_upload.php
Expand Up @@ -72,6 +72,7 @@
$lang_module['folder_exists'] = 'Error! Same name already exists directory';
$lang_module['notlevel'] = 'You are not granted the right to perform this operation';
$lang_module['notupload'] = 'Not allowed to upload directory';
$lang_module['over_capacity'] = 'Over upload capacity';
$lang_module['errorInfo'] = 'Announcement';
$lang_module['selectfiletype'] = 'Display file type';
$lang_module['refresh'] = 'refresh';
Expand Down
2 changes: 2 additions & 0 deletions includes/language/en/global.php
Expand Up @@ -288,6 +288,8 @@
$lang_global['error_upload_writable'] = 'Directory %s is not writable';
$lang_global['error_upload_urlfile'] = 'The URL is not valid and cannot be loaded';
$lang_global['error_upload_url_notfound'] = 'The url was not found';
$lang_global['error_upload_over_capacity'] = 'Error: Unable to upload because the website has reached the capacity';
$lang_global['error_upload_over_capacity1'] = 'You can\'t work because the website has reached the capacity';
$lang_global['theme_type_r'] = 'Responsive';
$lang_global['theme_type_d'] = 'Desktop';
$lang_global['theme_type_m'] = 'Mobile';
Expand Down
1 change: 1 addition & 0 deletions includes/language/fr/admin_upload.php
Expand Up @@ -72,6 +72,7 @@
$lang_module['folder_exists'] = 'Erreur! Un dossier du même nom déjà existant';
$lang_module['notlevel'] = 'Vous n\'avez pas la permission de faire cette opération';
$lang_module['notupload'] = 'Envoi non autorisé';
$lang_module['over_capacity'] = 'Surcapacité de téléchargement';
$lang_module['errorInfo'] = 'Notification';
$lang_module['selectfiletype'] = 'Afficher type de fichier';
$lang_module['refresh'] = 'Rafraîchir';
Expand Down
2 changes: 2 additions & 0 deletions includes/language/fr/global.php
Expand Up @@ -289,6 +289,8 @@
$lang_global['error_upload_writable'] = 'Erreur: Dossier %s ne permis pas l\'ạout de fichier. Merci de revoir les permissions (chmod 777)';
$lang_global['error_upload_urlfile'] = 'Erreur: lien incorrect';
$lang_global['error_upload_url_notfound'] = 'Erreur: impossible de prendre le fichier depuis votre lien';
$lang_global['error_upload_over_capacity'] = 'Erreur : Impossible de télécharger car le site Web a atteint la limite de taille autorisée';
$lang_global['error_upload_over_capacity1'] = 'Vous ne pouvez pas travailler car le site Web a atteint la capacité';
$lang_global['theme_type_r'] = 'Automatique';
$lang_global['theme_type_d'] = 'Ordinateur';
$lang_global['theme_type_m'] = 'Téléphone portable';
Expand Down
1 change: 1 addition & 0 deletions includes/language/vi/admin_upload.php
Expand Up @@ -72,6 +72,7 @@
$lang_module['folder_exists'] = 'Lỗi! Đã có thư mục cùng tên tồn tại';
$lang_module['notlevel'] = 'Bạn không được cấp quyền thực hiện thao tác này';
$lang_module['notupload'] = 'Thư mục không được phép upload';
$lang_module['over_capacity'] = 'Hết dung lượng tải lên';
$lang_module['errorInfo'] = 'Thông báo';
$lang_module['selectfiletype'] = 'Hiển thị loại file';
$lang_module['refresh'] = 'Cập nhật lại';
Expand Down
2 changes: 2 additions & 0 deletions includes/language/vi/global.php
Expand Up @@ -298,6 +298,8 @@
$lang_global['error_upload_writable'] = 'Lỗi: Thư mục %s không cho phép chứa file tải lên. Có thể bạn cần CHMOD lại thư mục này ở dạng 0777';
$lang_global['error_upload_urlfile'] = 'Lỗi: URL mà bạn đưa ra không đúng';
$lang_global['error_upload_url_notfound'] = 'Lỗi: Không thể tải file từ URL mà bạn đưa ra';
$lang_global['error_upload_over_capacity'] = 'Lỗi: Không thể tải lên do website đã đạt giới hạn dung lượng cho phép';
$lang_global['error_upload_over_capacity1'] = 'Bạn không thể thao tác vì website đã đạt giới hạn dung lượng cho phép';
$lang_global['theme_type_r'] = 'Tự động';
$lang_global['theme_type_d'] = 'Máy Tính';
$lang_global['theme_type_m'] = 'Di động';
Expand Down
2 changes: 1 addition & 1 deletion includes/xtemplate.class.php
Expand Up @@ -369,7 +369,7 @@ class XTemplate
/**
* PHP 5 Constructor - Instantiate the object
*
* @param array $options Options array (was $file)
* @param string|array $options Options array (was $file)
* @param string/array $tpldir Location of template files (useful for keeping files outside web server root)
* @param array $files Filenames lookup
* @param string $mainblock Name of main block in the template
Expand Down
2 changes: 2 additions & 0 deletions install/data.php
Expand Up @@ -117,6 +117,8 @@
$sql_create_table[] = 'INSERT INTO ' . NV_CONFIG_GLOBALTABLE . " (lang, module, config_name, config_value) VALUES ('sys', 'site', 'push_refresh_time', '30')";
$sql_create_table[] = 'INSERT INTO ' . NV_CONFIG_GLOBALTABLE . " (lang, module, config_name, config_value) VALUES ('sys', 'site', 'push_max_characters', '200')";
$sql_create_table[] = 'INSERT INTO ' . NV_CONFIG_GLOBALTABLE . " (lang, module, config_name, config_value) VALUES ('sys', 'site', 'push_numrows', '10')";
$sql_create_table[] = 'INSERT INTO ' . NV_CONFIG_GLOBALTABLE . " (lang, module, config_name, config_value) VALUES ('sys', 'site', 'over_capacity', '0')";

$sql_create_table[] = 'INSERT INTO ' . NV_CONFIG_GLOBALTABLE . " (lang, module, config_name, config_value) VALUES ('sys', 'define', 'nv_gfx_num', '6')";
$sql_create_table[] = 'INSERT INTO ' . NV_CONFIG_GLOBALTABLE . " (lang, module, config_name, config_value) VALUES ('sys', 'global', 'closed_site', '0')";
$sql_create_table[] = 'INSERT INTO ' . NV_CONFIG_GLOBALTABLE . " (lang, module, config_name, config_value) VALUES ('sys', 'global', 'site_reopening_time', '0')";
Expand Down
7 changes: 7 additions & 0 deletions modules/news/admin/content.php
Expand Up @@ -72,6 +72,13 @@
nv_jsonOutput($keywords);
}

if (!empty($global_config['over_capacity']) and !defined('NV_IS_GODADMIN')) {
$contents = nv_theme_alert('', $lang_global['error_upload_over_capacity1']);
include NV_ROOTDIR . '/includes/header.php';
echo nv_admin_theme($contents);
include NV_ROOTDIR . '/includes/footer.php';
}

if (defined('NV_EDITOR')) {
require_once NV_ROOTDIR . '/' . NV_EDITORSDIR . '/' . NV_EDITOR . '/nv.php';
}
Expand Down
7 changes: 7 additions & 0 deletions modules/news/funcs/content.php
Expand Up @@ -287,6 +287,13 @@ function getPostLevel()
$page_title = $lang_module['add_content'];
}

if (!empty($global_config['over_capacity']) and !defined('NV_IS_GODADMIN')) {
$contents = nv_theme_alert('', $lang_global['error_upload_over_capacity1']);
include NV_ROOTDIR . '/includes/header.php';
echo nv_site_theme($contents);
include NV_ROOTDIR . '/includes/footer.php';
}

if (empty($post_status)) {
nv_redirect_location($base_url);
}
Expand Down
7 changes: 7 additions & 0 deletions modules/page/admin/content.php
Expand Up @@ -39,6 +39,13 @@
$action = NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&amp;' . NV_NAME_VARIABLE . '=' . $module_name . '&amp;' . NV_OP_VARIABLE . '=' . $op;
}

if (!empty($global_config['over_capacity']) and !defined('NV_IS_GODADMIN')) {
$contents = nv_theme_alert('', $lang_global['error_upload_over_capacity1']);
include NV_ROOTDIR . '/includes/header.php';
echo nv_admin_theme($contents);
include NV_ROOTDIR . '/includes/footer.php';
}

$selectthemes = (!empty($site_mods[$module_name]['theme'])) ? $site_mods[$module_name]['theme'] : $global_config['site_theme'];
$layout_array = nv_scandir(NV_ROOTDIR . '/themes/' . $selectthemes . '/layout', $global_config['check_op_layout']);
$error = '';
Expand Down
1 change: 1 addition & 0 deletions themes/admin_default/modules/upload/foldlist.tpl
Expand Up @@ -33,6 +33,7 @@
<span class="upload-hide" id="move_file" title="{MOVE_FILE}"></span>
<span class="upload-hide" id="crop_file" title="{CROP_FILE}"></span>
<span class="upload-hide" id="rotate_file" title="{ROTATE_FILE}"></span>
<span class="upload-hide" id="over_capacity" title="{OVER_CAPACITY}"></span>

<script type="text/javascript">
//<![CDATA[
Expand Down
1 change: 1 addition & 0 deletions themes/admin_default/modules/upload/main.tpl
Expand Up @@ -371,6 +371,7 @@ LANG.errorEmptyY = "{LANG.errorEmptyY}";
LANG.crop = "{LANG.crop}";
LANG.rotate = "{LANG.rotate}";
LANG.notupload = "{LANG.notupload}";
LANG.over_capacity = "{LANG.over_capacity}";
LANG.upload_file = "{LANG.upload_file}";
LANG.upload_mode = "{LANG.upload_mode}";
LANG.upload_mode_remote = "{LANG.upload_mode_remote}";
Expand Down
105 changes: 31 additions & 74 deletions vendor/vinades/nukeviet/Files/Upload.php
Expand Up @@ -38,7 +38,8 @@ class Upload
'overflowsize' => 0,
'maxwidth' => 0,
'maxheight' => 0,
'magic_path' => ''
'magic_path' => '',
'over_capacity' => 0
];
private $lang = [
'error_uploadNameEmpty' => 'Upload failed: UserFile Name is empty',
Expand All @@ -61,7 +62,8 @@ class Upload
'error_upload_forbidden' => 'Upload forbidden',
'error_upload_writable' => 'Directory %s is not writable',
'error_upload_urlfile' => 'The URL is not valid and cannot be loaded',
'error_upload_url_notfound' => 'The url was not found'
'error_upload_url_notfound' => 'The url was not found',
'error_upload_over_capacity' => 'The file cannot be uploaded because this website has exceeded the allowed capacity',
];

private $file_extension = '';
Expand Down Expand Up @@ -104,6 +106,8 @@ class Upload
*/
public function __construct($allowed_filetypes = ['any'], $forbid_extensions = ['php'], $forbid_mimes = [], $maxsize = 0, $maxwidth = 0, $maxheight = 0, $magic_path = '')
{
global $global_config;

if (!is_array($allowed_filetypes)) {
$allowed_filetypes = [
$allowed_filetypes
Expand Down Expand Up @@ -136,6 +140,9 @@ public function __construct($allowed_filetypes = ['any'], $forbid_extensions = [
$this->config['maxheight'] = (int) $maxheight;
$this->config['upload_checking_mode'] = defined('UPLOAD_CHECKING_MODE') ? UPLOAD_CHECKING_MODE : 'strong';
$this->config['magic_path'] = $magic_path;
if (!defined('NV_IS_GODADMIN')) {
$this->config['over_capacity'] = isset($global_config['over_capacity']) ? intval($global_config['over_capacity']) : 0;
}

$userAgents = [
'Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.9) Gecko/2008052906 Firefox/3.0',
Expand All @@ -161,72 +168,14 @@ public function __construct($allowed_filetypes = ['any'], $forbid_extensions = [
/**
* setLanguage()
*
* @param string $lang_upload
* @param string[] $lang_upload
*/
public function setLanguage($lang_upload)
{
if (isset($lang_upload['error_uploadNameEmpty'])) {
$this->lang['error_uploadNameEmpty'] = $lang_upload['error_uploadNameEmpty'];
}
if (isset($lang_upload['error_uploadSizeEmpty'])) {
$this->lang['error_uploadSizeEmpty'] = $lang_upload['error_uploadSizeEmpty'];
}
if (isset($lang_upload['error_upload_ini_size'])) {
$this->lang['error_upload_ini_size'] = $lang_upload['error_upload_ini_size'];
}
if (isset($lang_upload['error_upload_form_size'])) {
$this->lang['error_upload_form_size'] = $lang_upload['error_upload_form_size'];
}
if (isset($lang_upload['error_upload_partial'])) {
$this->lang['error_upload_partial'] = $lang_upload['error_upload_partial'];
}
if (isset($lang_upload['error_upload_no_file'])) {
$this->lang['error_upload_no_file'] = $lang_upload['error_upload_no_file'];
}
if (isset($lang_upload['error_upload_no_tmp_dir'])) {
$this->lang['error_upload_no_tmp_dir'] = $lang_upload['error_upload_no_tmp_dir'];
}
if (isset($lang_upload['error_upload_cant_write'])) {
$this->lang['error_upload_cant_write'] = $lang_upload['error_upload_cant_write'];
}
if (isset($lang_upload['error_upload_extension'])) {
$this->lang['error_upload_extension'] = $lang_upload['error_upload_extension'];
}
if (isset($lang_upload['error_upload_unknown'])) {
$this->lang['error_upload_unknown'] = $lang_upload['error_upload_unknown'];
}
if (isset($lang_upload['error_upload_type_not_allowed'])) {
$this->lang['error_upload_type_not_allowed'] = $lang_upload['error_upload_type_not_allowed'];
}
if (isset($lang_upload['error_upload_mime_not_recognize'])) {
$this->lang['error_upload_mime_not_recognize'] = $lang_upload['error_upload_mime_not_recognize'];
}
if (isset($lang_upload['error_upload_max_user_size'])) {
$this->lang['error_upload_max_user_size'] = $lang_upload['error_upload_max_user_size'];
}
if (isset($lang_upload['error_upload_not_image'])) {
$this->lang['error_upload_not_image'] = $lang_upload['error_upload_not_image'];
}
if (isset($lang_upload['error_upload_image_failed'])) {
$this->lang['error_upload_image_failed'] = $lang_upload['error_upload_image_failed'];
}
if (isset($lang_upload['error_upload_image_width'])) {
$this->lang['error_upload_image_width'] = $lang_upload['error_upload_image_width'];
}
if (isset($lang_upload['error_upload_image_height'])) {
$this->lang['error_upload_image_height'] = $lang_upload['error_upload_image_height'];
}
if (isset($lang_upload['error_upload_forbidden'])) {
$this->lang['error_upload_forbidden'] = $lang_upload['error_upload_forbidden'];
}
if (isset($lang_upload['error_upload_writable'])) {
$this->lang['error_upload_writable'] = $lang_upload['error_upload_writable'];
}
if (isset($lang_upload['error_upload_urlfile'])) {
$this->lang['error_upload_urlfile'] = $lang_upload['error_upload_urlfile'];
}
if (isset($lang_upload['error_upload_url_notfound'])) {
$this->lang['error_upload_url_notfound'] = $lang_upload['error_upload_url_notfound'];
foreach ($this->lang as $key => $value) {
if (isset($lang_upload[$key])) {
$this->lang[$key] = $lang_upload[$key];
}
}
}

Expand Down Expand Up @@ -343,7 +292,7 @@ private function get_mime_from_iniFile()
/**
* get_mime_from_userFile()
*
* @param string $userfile
* @param array $userfile
* @return string
*/
private function get_mime_from_userFile($userfile)
Expand All @@ -354,7 +303,7 @@ private function get_mime_from_userFile($userfile)
/**
* get_mime_finfo()
*
* @param string $userfile
* @param array $userfile
* @return string
*/
private function get_mime_finfo($userfile)
Expand Down Expand Up @@ -401,7 +350,7 @@ private function get_mime_finfo($userfile)
/**
* get_mime_exec()
*
* @param string $userfile
* @param array $userfile
* @return string
*/
private function get_mime_exec($userfile)
Expand Down Expand Up @@ -432,7 +381,7 @@ private function get_mime_exec($userfile)
/**
* get_mime_content_type()
*
* @param string $userfile
* @param array $userfile
* @return string
*/
private function get_mime_content_type($userfile)
Expand All @@ -450,7 +399,7 @@ private function get_mime_content_type($userfile)
/**
* get_mime_image()
*
* @param string $userfile
* @param array $userfile
* @return string
*/
private function get_mime_image($userfile)
Expand Down Expand Up @@ -566,7 +515,7 @@ private function mime_ign($mime)
/**
* get_mime_type()
*
* @param string $userfile
* @param array $userfile
* @return string
*/
private function get_mime_type($userfile)
Expand Down Expand Up @@ -712,10 +661,10 @@ private function checkUploadBlob($userfile)
return $this->lang['error_uploadNameEmpty'];
}
if (!isset($userfile['size']) or empty($userfile['size'])) {
return _ERROR_UPLOAD_SIZEEMPTY;
return $this->lang['error_uploadSizeEmpty'];
}
if (!isset($userfile['tmp_name']) or empty($userfile['tmp_name']) or !file_exists($userfile['tmp_name'])) {
return _ERROR_UPLOAD_SIZEEMPTY;
return $this->lang['error_uploadSizeEmpty'];
}
if (!isset($userfile['error']) or $userfile['error'] != UPLOAD_ERR_OK) {
switch ($userfile['error']) {
Expand Down Expand Up @@ -907,7 +856,7 @@ private function string_to_filename($word)
}

if (file_exists(NV_ROOTDIR . '/includes/utf8/lookup.php')) {
$utf8_lookup = false;
$utf8_lookup = [];
include NV_ROOTDIR . '/includes/utf8/lookup.php';
$word = strtr($word, $utf8_lookup['romanize']);
}
Expand Down Expand Up @@ -944,6 +893,10 @@ public function save_file($userfile, $savepath, $replace_if_exists = true, $no_c
}

$return = [];
if (!empty($this->config['over_capacity'])) {
$return['error'] = $this->lang['error_upload_over_capacity'];
return $return;
}
$return['error'] = $this->checkUploadBlob($userfile);
if (!empty($return['error'])) {
return $return;
Expand Down Expand Up @@ -1507,6 +1460,10 @@ public function save_urlfile($urlfile, $savepath, $replace_if_exists = true, $no
$return = [];
$return['error'] = '';

if (!empty($this->config['over_capacity'])) {
$return['error'] = $this->lang['error_upload_over_capacity'];
return $return;
}
$this->url_info = $this->url_get_info($urlfile);
if (empty($this->url_info) or !isset($this->url_info['scheme'])) {
$return['error'] = $this->lang['error_upload_urlfile'];
Expand Down
3 changes: 2 additions & 1 deletion vendor/vinades/nukeviet/Http/Cookie.php
Expand Up @@ -20,7 +20,8 @@
* @version 4.5.00
* @access public
*/
class Cookie
#[\AllowDynamicProperties]
class Cookie
{
/**
* Cookie name.
Expand Down

0 comments on commit b31bcb3

Please sign in to comment.