ecshop后台恢复备份未选择时删除备份文件提示删除成功错误问题修复
日期:2013-11-11
ECSHOP后台“恢复备份”页面里面操作时有个bug,未选择文件删除时提示“删除成功”。
添加判断语句避免此问题,修复方法如下:
一、打开/admin/database.php文件,搜索如下代码:
二、打开/languages/zh_cn/admin/database.php文件,添加语言项
添加判断语句避免此问题,修复方法如下:
一、打开/admin/database.php文件,搜索如下代码:
/* 删除备份 */
if ($_REQUEST['act'] == 'remove')
{
/* 权限判断 */
admin_priv('db_backup');
if (isset($_POST['file']))
{
$m_file = array(); //多卷文件
$s_file = array(); //单卷文件
$path = ROOT_PATH . DATA_DIR . '/sqldata/';
foreach ($_POST['file'] AS $file)
{
if (preg_match('/_[0-9]+\.sql$/', $file))
{
$m_file[] = substr($file, 0, strrpos($file, '_'));
}
else
{
$s_file[] = $file;
}
}
if ($m_file)
{
$m_file = array_unique ($m_file);
/* 获取文件列表 */
$real_file = array();
$folder = opendir($path);
while ($file = readdir($folder))
{
if ( preg_match('/_[0-9]+\.sql$/', $file) && is_file($path . $file))
{
$real_file[] = $file;
}
}
foreach ($real_file AS $file)
{
$short_file = substr($file, 0, strrpos($file, '_'));
if (in_array($short_file, $m_file))
{
@unlink($path . $file);
}
}
}
if ($s_file)
{
foreach ($s_file AS $file)
{
@unlink($path . $file);
}
}
}
sys_msg($_LANG['remove_success'] , 0, array(array('text'=>$_LANG['restore'], 'href'=>'database.php?act=restore')));
}
修改为如下代码:
/* 删除备份 */
if ($_REQUEST['act'] == 'remove')
{
/* 权限判断 */
admin_priv('db_backup');
if (isset($_POST['file']))
{
$m_file = array(); //多卷文件
$s_file = array(); //单卷文件
$path = ROOT_PATH . DATA_DIR . '/sqldata/';
foreach ($_POST['file'] AS $file)
{
if (preg_match('/_[0-9]+\.sql$/', $file))
{
$m_file[] = substr($file, 0, strrpos($file, '_'));
}
else
{
$s_file[] = $file;
}
}
if ($m_file)
{
$m_file = array_unique ($m_file);
/* 获取文件列表 */
$real_file = array();
$folder = opendir($path);
while ($file = readdir($folder))
{
if ( preg_match('/_[0-9]+\.sql$/', $file) && is_file($path . $file))
{
$real_file[] = $file;
}
}
foreach ($real_file AS $file)
{
$short_file = substr($file, 0, strrpos($file, '_'));
if (in_array($short_file, $m_file))
{
@unlink($path . $file);
}
}
sys_msg($_LANG['remove_success'] , 0, array(array('text'=>$_LANG['restore'], 'href'=>'database.php?act=restore')));
}
if ($s_file)
{
foreach ($s_file AS $file)
{
@unlink($path . $file);
}
sys_msg($_LANG['remove_success'] , 0, array(array('text'=>$_LANG['restore'], 'href'=>'database.php?act=restore')));
}
}
else
{
sys_msg($_LANG['select_empty'], 1);
}
}
二、打开/languages/zh_cn/admin/database.php文件,添加语言项
$_LANG['select_empty'] = '请选择文件!';
本文原创地址:https://ecshopok.com/article-118.html
版权所有 © 转载时必须以链接形式注明出处!
觉得本文对您有用,想收藏下来!方法很简单:请点击-〉
我们一直坚持白天工作、晚上熬夜更新资源,付出了巨大的精力和时间,其中的辛酸难以言述。
下一篇:ECSHOP程序安装过程遇到数据库那段过不去失败date_default_timezone_get()问题 上一篇:ECSHOP后台地区列表台湾备份数据包


暂无评论,来发表一个吧