From 0d7e7887a81282fb23d41a4d3250dc5a390bcb3a Mon Sep 17 00:00:00 2001 From: tianya Date: Tue, 4 Jul 2023 21:30:32 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E5=AF=B9FTP=E7=9A=84?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/admin/api.php | 1 - src/admin/dialog/select_images_post.php | 1 - src/admin/dialog/select_soft_post.php | 1 - src/admin/file_class.php | 2 - src/admin/friendlink_add.php | 1 - src/admin/inc/inc_archives_all.php | 2 - src/admin/inc/inc_archives_functions.php | 2 - src/admin/media_add.php | 1 - src/admin/media_edit.php | 1 - src/admin/swfupload.php | 2 - src/admin/sys_data_done.php | 1 - src/install/config.cache.inc.php | 6 -- src/install/sql-dfdata.txt | 6 -- src/install/update.txt | 9 ++- src/system/common.inc.php | 10 +-- src/system/customfields.func.php | 1 - src/system/helpers/channelunit.helper.php | 4 +- src/system/helpers/file.helper.php | 98 ++--------------------- src/system/helpers/upload.helper.php | 2 - src/system/inc/inc_fun_funAdmin.php | 4 +- src/user/api.php | 1 - src/user/inc/inc_archives_functions.php | 2 - 22 files changed, 19 insertions(+), 139 deletions(-) diff --git a/src/admin/api.php b/src/admin/api.php index 27fd2ab6..98b53995 100644 --- a/src/admin/api.php +++ b/src/admin/api.php @@ -384,7 +384,6 @@ if ($action === 'is_need_check_code') { $mdir = MyDate($cfg_addon_savetype, $nowtme); if (!is_dir($cfg_basedir.$activepath."/$mdir")) { MkdirAll($cfg_basedir.$activepath."/$mdir", $cfg_dir_purview); - CloseFtp(); } $cuserLogin = new userLogin(); $iseditor = isset($iseditor)? intval($iseditor) : 0; diff --git a/src/admin/dialog/select_images_post.php b/src/admin/dialog/select_images_post.php index 873fe8f7..6c58a0b3 100644 --- a/src/admin/dialog/select_images_post.php +++ b/src/admin/dialog/select_images_post.php @@ -42,7 +42,6 @@ if (!in_array($imgfile_type, $sparr)) { $mdir = MyDate($cfg_addon_savetype, $nowtme); if (!is_dir($cfg_basedir.$activepath."/$mdir")) { MkdirAll($cfg_basedir.$activepath."/$mdir", $cfg_dir_purview); - CloseFtp(); } $iseditor = isset($iseditor)? intval($iseditor) : 0; $filename_name = $cuserLogin->getUserID().'-'.dd2char(MyDate("ymdHis", $nowtme).mt_rand(100, 999)); diff --git a/src/admin/dialog/select_soft_post.php b/src/admin/dialog/select_soft_post.php index 9e727bbd..fe699514 100644 --- a/src/admin/dialog/select_soft_post.php +++ b/src/admin/dialog/select_soft_post.php @@ -37,7 +37,6 @@ if ($activepath == $cfg_soft_dir) { $activepath = $activepath.'/'.$newdir; if (!is_dir($cfg_basedir.$activepath)) { MkdirAll($cfg_basedir.$activepath, $cfg_dir_purview); - CloseFtp(); } } //文件名前为手工指定,后者自动处理 diff --git a/src/admin/file_class.php b/src/admin/file_class.php index 8b29c348..b70e587e 100644 --- a/src/admin/file_class.php +++ b/src/admin/file_class.php @@ -48,7 +48,6 @@ class FileManagement $dirname = $this->baseDir.$this->activeDir."/".$dirname; if (is_writable($this->baseDir.$this->activeDir)) { MkdirAll($dirname, $GLOBALS['cfg_dir_purview']); - CloseFtp(); ShowMsg("成功创建一个新目录", "file_manage_main.php?activepath=".$this->activeDir."/".$newdir); return 1; } else { @@ -79,7 +78,6 @@ class FileManagement copy($oldfile, $truepath."/$mfile"); } else { MkdirAll($truepath, $GLOBALS['cfg_dir_purview']); - CloseFtp(); copy($oldfile, $truepath."/$mfile"); } unlink($oldfile); diff --git a/src/admin/friendlink_add.php b/src/admin/friendlink_add.php index ea79d05a..aade9465 100644 --- a/src/admin/friendlink_add.php +++ b/src/admin/friendlink_add.php @@ -23,7 +23,6 @@ if ($dopost == "add") { $imgurl = $cfg_medias_dir."/flink"; if (!is_dir($cfg_basedir.$imgurl)) { MkdirAll($cfg_basedir.$imgurl, $cfg_dir_purview); - CloseFtp(); } $imgurl = $imgurl."/".$filename; $mime = get_mime_type($logoimg); diff --git a/src/admin/inc/inc_archives_all.php b/src/admin/inc/inc_archives_all.php index 10ee7b8f..b9a04773 100644 --- a/src/admin/inc/inc_archives_all.php +++ b/src/admin/inc/inc_archives_all.php @@ -152,7 +152,6 @@ function GetFieldValue($dvalue, $dtype, $aid = 0, $job = 'add', $addvar = '') $fp = fopen($GLOBALS['cfg_basedir'].$addvar, "w"); fwrite($fp, stripslashes($dvalue)); fclose($fp); - CloseFtp(); return $addvar; } else { $ipath = $GLOBALS['cfg_cmspath']."/data/textdata"; @@ -168,7 +167,6 @@ function GetFieldValue($dvalue, $dtype, $aid = 0, $job = 'add', $addvar = '') $fp = fopen($GLOBALS['cfg_basedir'].$filename, "w"); fwrite($fp, stripslashes($dvalue)); fclose($fp); - CloseFtp(); return $filename; } } else if ($dtype == "img") { diff --git a/src/admin/inc/inc_archives_functions.php b/src/admin/inc/inc_archives_functions.php index e8210a51..4c85e9e9 100644 --- a/src/admin/inc/inc_archives_functions.php +++ b/src/admin/inc/inc_archives_functions.php @@ -41,7 +41,6 @@ function GetCurContentAlbum($body, $rfurl, &$firstdd) $imgPath = $cfg_basedir.$imgUrl; if (!is_dir($imgPath.'/')) { MkdirAll($imgPath, $GLOBALS['cfg_dir_purview']); - CloseFtp(); } $milliSecond = 'co'.dd2char(MyDate('ymdHis', time())); foreach ($img_array as $key => $value) { @@ -104,7 +103,6 @@ function GetCurContent($body) $imgPath = $cfg_basedir.$imgUrl; if (!is_dir($imgPath.'/')) { MkdirAll($imgPath, $GLOBALS['cfg_dir_purview']); - CloseFtp(); } $milliSecond = MyDate('His', time()); foreach ($img_array as $key => $value) { diff --git a/src/admin/media_add.php b/src/admin/media_add.php index 328f6358..6156852b 100644 --- a/src/admin/media_add.php +++ b/src/admin/media_add.php @@ -50,7 +50,6 @@ if ($dopost == "upload") { $filename = $savePath."/".$filename; if (!is_dir($cfg_basedir.$savePath)) { MkdirAll($cfg_basedir.$savePath, 777); - CloseFtp(); } if (preg_match('#\.(php|pl|cgi|asp|aspx|jsp|php5|php4|php3|shtm|shtml)$#i', trim($newname))) { ShowMsg("文件扩展名已被系统禁止", "javascript:;"); diff --git a/src/admin/media_edit.php b/src/admin/media_edit.php index 8807ddaa..0106c5ba 100644 --- a/src/admin/media_edit.php +++ b/src/admin/media_edit.php @@ -109,7 +109,6 @@ else if ($dopost == 'save') { $oldfile_path = preg_replace("#".$oldfiles[count($oldfiles) - 1]."$#", "", $oldfile); if (!is_dir($cfg_basedir.$oldfile_path)) { MkdirAll($cfg_basedir.$oldfile_path, 777); - CloseFtp(); } $mime = get_mime_type($upfile); if (preg_match("#^unknow#", $mime)) { diff --git a/src/admin/swfupload.php b/src/admin/swfupload.php index 202cd8ff..f0102307 100644 --- a/src/admin/swfupload.php +++ b/src/admin/swfupload.php @@ -21,7 +21,6 @@ if (empty($dopost)) { $tmpdir = DEDEDATA.'/uploadtmp'; if (!is_dir($tmpdir)) { MkdirAll($tmpdir, $cfg_dir_purview); - CloseFtp(); if (!is_dir($tmpdir)) { echo "ERROR: Create {$tmpdir} dir Error! "; exit(0); @@ -75,7 +74,6 @@ if (empty($dopost)) { $filedir = $cfg_image_dir.'/'.MyDate($cfg_addon_savetype, time()); if (!is_dir(DEDEROOT.$filedir)) { MkdirAll($cfg_basedir.$filedir, $cfg_dir_purview); - CloseFtp(); } $filename = $cuserLogin->getUserID().'-'.dd2char(MyDate('ymdHis', time())); if (file_exists($cfg_basedir.$filedir.'/'.$filename.$sname)) { diff --git a/src/admin/sys_data_done.php b/src/admin/sys_data_done.php index 44742839..2206550b 100644 --- a/src/admin/sys_data_done.php +++ b/src/admin/sys_data_done.php @@ -29,7 +29,6 @@ if ($dopost == 'bak') { } if (!is_dir($bkdir)) { MkdirAll($bkdir, $cfg_dir_purview); - CloseFtp(); } //初始化使用到的变量 $tables = explode(',', $tablearr); diff --git a/src/install/config.cache.inc.php b/src/install/config.cache.inc.php index 5521d1fb..f8773f46 100755 --- a/src/install/config.cache.inc.php +++ b/src/install/config.cache.inc.php @@ -31,12 +31,6 @@ $cfg_arcsptitle = 'N'; $cfg_arcautosp = 'N'; $cfg_arcautosp_size = 5; $cfg_auot_description = 250; -$cfg_ftp_host = ''; -$cfg_ftp_port = ''; -$cfg_ftp_user = ''; -$cfg_ftp_pwd = ''; -$cfg_ftp_root = '/'; -$cfg_ftp_mkdir = 'N'; $cfg_feedback_ck = 'Y'; $cfg_list_son = 'Y'; $cfg_mb_open = 'N'; diff --git a/src/install/sql-dfdata.txt b/src/install/sql-dfdata.txt index c370c7c5..d59cd759 100755 --- a/src/install/sql-dfdata.txt +++ b/src/install/sql-dfdata.txt @@ -3962,12 +3962,6 @@ INSERT INTO `#@__sysconfig` VALUES ('1','cfg_basehost','站点网址','1','strin ('32','cfg_arcautosp','是否开启长文档自动分页','6','bool','N'), ('33','cfg_arcautosp_size','文档自动分页大小','6','number','5'), ('34','cfg_auot_description','自动摘要长度(0-255,0表示不启用)','7','number','255'), -('35','cfg_ftp_host','FTP主机','2','string',''), -('36','cfg_ftp_port','FTP端口','2','number',''), -('37','cfg_ftp_user','FTP用户名','2','string',''), -('38','cfg_ftp_pwd','FTP密码','2','string',''), -('39','cfg_ftp_root','网站根在FTP中的目录','2','string','/'), -('40','cfg_ftp_mkdir','是否强制用FTP创建目录','2','bool','N'), ('41','cfg_list_son','是否包含上级列表子类文档','6','bool','Y'), ('42','cfg_mb_open','是否开启会员功能','4','bool','N'), ('43','cfg_mb_album','是否开启会员图集功能','4','bool','Y'), diff --git a/src/install/update.txt b/src/install/update.txt index 26fcb597..4bce295d 100644 --- a/src/install/update.txt +++ b/src/install/update.txt @@ -128,4 +128,11 @@ ALTER TABLE `#@__arctype` ADD COLUMN `apienabled` tinyint UNSIGNED NULL DEFAULT ALTER TABLE `#@__member` ADD COLUMN `pmid` INT(8) UNSIGNED NULL DEFAULT 0 AFTER `user_money`; -- 6.2.11 -UPDATE `#@__channeltype` SET `useraddcon` = 'soft_add.php', `usermancon` = 'content_list.php', `usereditcon` = 'soft_edit.php' WHERE `id` = 3 \ No newline at end of file +UPDATE `#@__channeltype` SET `useraddcon` = 'soft_add.php', `usermancon` = 'content_list.php', `usereditcon` = 'soft_edit.php' WHERE `id` = 3; +DELETE FROM `#@__sysconfig` WHERE `varname` = 'cfg_ftp_mkdir'; +DELETE FROM `#@__sysconfig` WHERE `varname` = 'cfg_ftp_host'; +DELETE FROM `#@__sysconfig` WHERE `varname` = 'cfg_ftp_port'; +DELETE FROM `#@__sysconfig` WHERE `varname` = 'cfg_ftp_user'; +DELETE FROM `#@__sysconfig` WHERE `varname` = 'cfg_ftp_pwd'; +DELETE FROM `#@__sysconfig` WHERE `varname` = 'cfg_ftp_root'; +DELETE FROM `#@__sysconfig` WHERE `varname` = 'cfg_ftp_mkdir'; \ No newline at end of file diff --git a/src/system/common.inc.php b/src/system/common.inc.php index 28a92521..27bf9657 100755 --- a/src/system/common.inc.php +++ b/src/system/common.inc.php @@ -106,10 +106,6 @@ if (!isset($needFilter)) { } $registerGlobals = @ini_get("register_globals"); $isUrlOpen = @ini_get("allow_url_fopen"); -$isSafeMode = @ini_get("safe_mode"); -if (preg_match('/windows/i', @getenv('OS'))) { - $isSafeMode = false; -} //系统配置参数 if (!file_exists(DEDEDATA."/config.cache.inc.php")) { die('DedeBIZ初始化失败,确保系统正确被安装'); @@ -202,11 +198,7 @@ $cfg_soft_devteam = 'DedeBIZ'; $art_shortname = $cfg_df_ext = '.html'; $cfg_df_namerule = '{typedir}/{aid}'.$cfg_df_ext; //新建目录的权限,如果您使用别的属性,本程不保证程序能顺利在Linux或Unix系统运行 -if (isset($cfg_ftp_mkdir) && $cfg_ftp_mkdir == 'Y') { - $cfg_dir_purview = '0755'; -} else { - $cfg_dir_purview = 0755; -} +$cfg_dir_purview = 0755; //会员是否使用精简模式 $cfg_mb_lit = 'N'; //特殊全局变量 diff --git a/src/system/customfields.func.php b/src/system/customfields.func.php index f5d1ec52..4aab9950 100755 --- a/src/system/customfields.func.php +++ b/src/system/customfields.func.php @@ -218,7 +218,6 @@ function GetFieldValue($dvalue, $dtype, $aid = 0, $job = 'add', $addvar = '', $a $fp = fopen($cfg_basedir.$filename, "w"); fwrite($fp, stripslashes($dvalue)); fclose($fp); - CloseFtp(); return $filename; } else if ($dtype == 'img' || $dtype == 'imgfile') { return addslashes($dvalue); diff --git a/src/system/helpers/channelunit.helper.php b/src/system/helpers/channelunit.helper.php index ad42435d..c750e41a 100755 --- a/src/system/helpers/channelunit.helper.php +++ b/src/system/helpers/channelunit.helper.php @@ -395,8 +395,8 @@ function FormatScript($atme) * 给属性默认值 * * @param array $atts 属性 - * @param array $attlist 属性列表 - * @return string + * @param string $attlist 属性列表 + * @return void */ function FillAttsDefault(&$atts, $attlist) { diff --git a/src/system/helpers/file.helper.php b/src/system/helpers/file.helper.php index d481e1db..ffd93b67 100755 --- a/src/system/helpers/file.helper.php +++ b/src/system/helpers/file.helper.php @@ -9,81 +9,7 @@ if (!defined('DEDEINC')) exit ('dedebiz'); * @license GNU GPL v2 (https://www.dedebiz.com/license) * @link https://www.dedebiz.com */ -$g_ftpLink = false; -/** - * 使用FTP方法创建文件夹目录 - * - * @param string $truepath 真实目标地址 - * @param string $mmode 创建模式 - * @param string $isMkdir 是否创建目录 - * @return bool - */ -if (!function_exists('FtpMkdir')) { - function FtpMkdir($truepath, $mmode, $isMkdir = true) - { - global $cfg_basedir, $cfg_ftp_root, $g_ftpLink; - OpenFtp(); - $ftproot = preg_replace('/'.$cfg_ftp_root.'$/', '', $cfg_basedir); - $mdir = preg_replace('/^'.$ftproot.'/', '', $truepath); - if ($isMkdir) { - ftp_mkdir($g_ftpLink, $mdir); - } - return ftp_site($g_ftpLink, "chmod $mmode $mdir"); - } -} -/** - * 改变目录模式 - * - * @param string $truepath 真实地址 - * @param string $mmode 模式 - * @return bool - */ -if (!function_exists('FtpChmod')) { - function FtpChmod($truepath, $mmode) - { - return FtpMkdir($truepath, $mmode, false); - } -} -/** - * 打开FTP链接,打开之前确保已经设置好了FTP相关的配置信息 - * - * @return void - */ -if (!function_exists('OpenFtp')) { - function OpenFtp() - { - global $cfg_basedir, $cfg_ftp_host, $cfg_ftp_port, $cfg_ftp_user, $cfg_ftp_pwd, $cfg_ftp_root, $g_ftpLink; - if (!$g_ftpLink) { - if ($cfg_ftp_host == '') { - echo "由于您的站点的PHP配置存在限制,程序尝试用FTP进行目录操作,您必须在后台指定FTP相关的变量"; - exit(); - } - $g_ftpLink = ftp_connect($cfg_ftp_host, $cfg_ftp_port); - if (!$g_ftpLink) { - echo "连接FTP失败"; - exit(); - } - if (!ftp_login($g_ftpLink, $cfg_ftp_user, $cfg_ftp_pwd)) { - echo "登录FTP失败"; - exit(); - } - } - } -} -/** - * 关闭FTP链接 - * - * @return void - */ -if (!function_exists('CloseFtp')) { - function CloseFtp() - { - global $g_ftpLink; - if ($g_ftpLink) { - @ftp_quit($g_ftpLink); - } - } -} + /** * 创建所有目录 * @@ -94,17 +20,12 @@ if (!function_exists('CloseFtp')) { if (!function_exists('MkdirAll')) { function MkdirAll($truepath, $mmode) { - global $cfg_ftp_mkdir, $isSafeMode, $cfg_dir_purview; - if ($isSafeMode || $cfg_ftp_mkdir == 'Y') { - return FtpMkdir($truepath, $mmode); + if (!file_exists($truepath)) { + mkdir($truepath, $mmode); + chmod($truepath, $mmode); + return true; } else { - if (!file_exists($truepath)) { - mkdir($truepath, $cfg_dir_purview); - chmod($truepath, $cfg_dir_purview); - return true; - } else { - return true; - } + return true; } } } @@ -119,12 +40,7 @@ if (!function_exists('MkdirAll')) { if (!function_exists('ChmodAll')) { function ChmodAll($truepath, $mmode) { - global $cfg_ftp_mkdir, $isSafeMode; - if ($isSafeMode || $cfg_ftp_mkdir == 'Y') { - return FtpChmod($truepath, $mmode); - } else { - return chmod($truepath, '0'.$mmode); - } + return chmod($truepath, '0'.$mmode); } } /** diff --git a/src/system/helpers/upload.helper.php b/src/system/helpers/upload.helper.php index 9cbb1839..5bf14d89 100755 --- a/src/system/helpers/upload.helper.php +++ b/src/system/helpers/upload.helper.php @@ -59,7 +59,6 @@ if (!function_exists('AdminUpload')) { } if (!is_dir(DEDEROOT.$filedir)) { MkdirAll($cfg_basedir.$filedir, $cfg_dir_purview); - CloseFtp(); } $filename = $cuserLogin->getUserID().'-'.dd2char(MyDate('ymdHis', time())).$rnddd; if ($ftype == 'imagelit') $filename .= '-L'; @@ -99,7 +98,6 @@ if (!function_exists('MemberUploads')) { if (empty($userid)) $userid = 0; if (!is_dir($cfg_basedir.$cfg_user_dir."/$userid")) { MkdirAll($cfg_basedir.$cfg_user_dir."/$userid", $cfg_dir_purview); - CloseFtp(); } //有上传文件 $allAllowType = str_replace('||', '|', $cfg_imgtype.'|'.$cfg_mediatype.'|'.$cfg_mb_addontype); diff --git a/src/system/inc/inc_fun_funAdmin.php b/src/system/inc/inc_fun_funAdmin.php index b8287624..ea04cecc 100755 --- a/src/system/inc/inc_fun_funAdmin.php +++ b/src/system/inc/inc_fun_funAdmin.php @@ -82,7 +82,7 @@ function SpGetPinyin($str, $ishead = 0, $isclose = 1) */ function SpCreateDir($spath) { - global $cfg_dir_purview, $cfg_basedir, $cfg_ftp_mkdir, $isSafeMode; + global $cfg_dir_purview, $cfg_basedir; if ($spath == '') { return true; } @@ -105,12 +105,10 @@ function SpCreateDir($spath) } if (!$isok) { echo "创建或修改目录".$truepath."失败"; - CloseFtp(); return false; } } } - CloseFtp(); return true; } function jsScript($js) diff --git a/src/user/api.php b/src/user/api.php index 32e0582b..8073556f 100755 --- a/src/user/api.php +++ b/src/user/api.php @@ -157,7 +157,6 @@ if ($action === 'is_need_check_code') { } if (!is_dir($cfg_basedir.$cfg_user_dir."/{$cfg_ml->M_ID}")) { MkdirAll($cfg_basedir.$cfg_user_dir."/{$cfg_ml->M_ID}", $cfg_dir_purview); - CloseFtp(); } //头像特殊处理 $fsize = filesize($ff["tmp_name"]); diff --git a/src/user/inc/inc_archives_functions.php b/src/user/inc/inc_archives_functions.php index 07f9da80..3934dacf 100755 --- a/src/user/inc/inc_archives_functions.php +++ b/src/user/inc/inc_archives_functions.php @@ -35,7 +35,6 @@ function GetCurContentAlbum($body, $rfurl, &$firstdd) $imgPath = $cfg_basedir.$imgUrl; if (!is_dir($imgPath."/")) { MkdirAll($imgPath, $GLOBALS['cfg_dir_purview']); - CloseFtp(); } $milliSecond = MyDate("ymdHis", time()); foreach ($img_array as $key => $value) { @@ -303,7 +302,6 @@ function GetCurContent(&$body) $imgPath = $cfg_basedir.$imgUrl; if (!is_dir($imgPath."/")) { MkdirAll($imgPath, $GLOBALS['cfg_dir_purview']); - CloseFtp(); } $milliSecond = MyDate("ymdHis", time()); foreach ($img_array as $key => $value) {