From a8be1e9649e0b1b3e4c039cb717f42dff49311d7 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Thu, 6 Nov 2014 09:06:34 +0000 Subject: [PATCH 1/6] * fix bug and adjust code. --- lib/dao/dao.class.php | 3 +- lib/zdb/zdb.class.php | 61 ++++++++++++----------------------- module/common/lang/en.php | 2 +- module/common/lang/zh-cn.php | 2 +- module/file/lang/en.php | 4 +-- module/file/lang/zh-cn.php | 4 +-- module/search/model.php | 2 +- module/upgrade/lang/en.php | 1 + module/upgrade/lang/zh-cn.php | 13 ++++---- 9 files changed, 37 insertions(+), 55 deletions(-) diff --git a/lib/dao/dao.class.php b/lib/dao/dao.class.php index ad120989d0..20868b6395 100755 --- a/lib/dao/dao.class.php +++ b/lib/dao/dao.class.php @@ -1050,8 +1050,7 @@ class dao $errorCode = $errorInfo[1]; $errorMsg = $errorInfo[2]; $message = $exception->getMessage(); - if(strpos($this->repairCode, "|$errorCode|") !== false or - ($errorCode == '1016' and strpos($errorMsg, 'errno: 145') !== false)) + if(strpos($this->repairCode, "|$errorCode|") !== false or ($errorCode == '1016' and strpos($errorMsg, 'errno: 145') !== false)) { $message .= ' ' . $this->lang->repairTable; } diff --git a/lib/zdb/zdb.class.php b/lib/zdb/zdb.class.php index 54f10aec46..c327420b83 100644 --- a/lib/zdb/zdb.class.php +++ b/lib/zdb/zdb.class.php @@ -83,12 +83,29 @@ class zdb /* Create sql code. */ $backupSql = "DROP TABLE IF EXISTS `$table`;\n"; $backupSql .= $this->getSchemaSQL($table); - $backupSql .= $this->getDataSQL($table); - - /* Write sql code. */ fwrite($fp, $backupSql); + + $rows = $this->dbh->query("select * from `$table`"); + while($row = $rows->fetch(PDO::FETCH_ASSOC)) + { + /* Create key sql for insert. */ + $keys = array_keys($row); + $keys = array_map('addslashes', $keys); + $keys = join('`,`', $keys); + $keys = "`" . $keys . "`"; + + /* Create a value sql. */ + $value = array_values($row); + $value = array_map('addslashes', $value); + $value = join("','", $value); + $value = "'" . $value . "'"; + $sql = "INSERT INTO `$table`($keys) VALUES (" . $value . ");\n"; + + /* Write sql code. */ + fwrite($fp, $sql); + } } - fclose ($fp); + fclose($fp); return $return; } @@ -114,40 +131,4 @@ class zdb $createSql = $this->dbh->query("show create table `$table`")->fetch(PDO::FETCH_ASSOC); return $createSql['Create Table'] . ";\n"; } - - /** - * Get data SQL. - * - * @param string $table - * @access public - * @return string - */ - public function getDataSQL($table) - { - $rows = $this->dbh->query("select * from `$table`")->fetchAll(PDO::FETCH_ASSOC); - $sql = ''; - if(!empty($rows)) - { - /* Create key sql for insert. */ - $keys = array_keys(current($rows)); - $keys = array_map('addslashes', $keys); - $keys = join('`,`', $keys); - $keys = "`" . $keys . "`"; - - /* Create all value sql. */ - $values = array(); - foreach($rows as $row) - { - $value = array_values($row); - $value = array_map('addslashes', $value); - $value = join("','", $value); - $value = "'" . $value . "'"; - - $values[] = "($value)"; - } - - $sql .= "INSERT INTO `$table`($keys) VALUES" . join(',', $values) . ";\n"; - } - return $sql; - } } diff --git a/module/common/lang/en.php b/module/common/lang/en.php index 97e1774c4f..e774453873 100644 --- a/module/common/lang/en.php +++ b/module/common/lang/en.php @@ -62,7 +62,7 @@ $lang->files = 'Files '; $lang->pasteText = 'Paste text'; $lang->uploadImages = 'Upload images '; $lang->timeout = 'Timed out, please check the network, or retry!'; -$lang->repairTable = 'The table may be damaged, you can perform bin/checkdb on the command line to try to repair!'; +$lang->repairTable = 'The table may be damaged, please repair by phpmyadmin or myisamchk!'; $lang->duplicate = '%s has the same title'; $lang->unfold = '+'; $lang->fold = '-'; diff --git a/module/common/lang/zh-cn.php b/module/common/lang/zh-cn.php index 09b8df3aca..b695ee2ff3 100644 --- a/module/common/lang/zh-cn.php +++ b/module/common/lang/zh-cn.php @@ -62,7 +62,7 @@ $lang->files = '附件 '; $lang->pasteText = '粘贴文本 '; $lang->uploadImages = '多图上传 '; $lang->timeout = '连接超时,请检查网络环境,或重试!'; -$lang->repairTable = '数据库表可能损坏,需要修复,可以在命令行执行bin目录下的checkdb尝试修复!'; +$lang->repairTable = '数据库表可能损坏,请用phpmyadmin或myisamchk检查修复。'; $lang->duplicate = '已有相同标题的%s'; $lang->unfold = '+'; $lang->fold = '-'; diff --git a/module/file/lang/en.php b/module/file/lang/en.php index 15d762d919..649a9eb74d 100644 --- a/module/file/lang/en.php +++ b/module/file/lang/en.php @@ -28,6 +28,6 @@ $lang->file->errorFileUpload = " Failed to upload files, file size may exceed t $lang->file->errorSuffix = 'Compressed packet format error, can only upload zip!'; $lang->file->errorExtract = 'Decompression failure! The file may have been damaged'; $lang->file->uploadImagesExplain = <<1. Upload file to contain pictures of zip compressed package, the program will take the file name as a title, as content with pictures, generating a record.

-

2. if the file name at the beginning contains 'digital+underline', generation of title will they ignore, for example: '01_test', the title is 'test'.

+

1. Upload file to contain pictures of zip package, the program will take the file name as a title, as content with pictures

+

2. The file name at the beginning contains 'digital+underline', generation of title will they ignore.

EOD; diff --git a/module/file/lang/zh-cn.php b/module/file/lang/zh-cn.php index a967b8931d..42f0db46c8 100644 --- a/module/file/lang/zh-cn.php +++ b/module/file/lang/zh-cn.php @@ -28,6 +28,6 @@ $lang->file->errorFileUpload = " 文件上传失败,文件大小可能超出 $lang->file->errorSuffix = '压缩包格式错误,只能上传zip压缩包!'; $lang->file->errorExtract = '解压缩失败!可能文件已经损坏'; $lang->file->uploadImagesExplain = <<1、上传文件为包含图片的zip压缩包,程序会以文件名作为标题,以图片作为内容,生成一条记录。以方便创建。

-

2、如果文件名开头含有 数字+下划线,生成的标题会将他们忽略,例如:01_测试,生成的标题名是“测试”。

+

1、上传文件为包含图片的zip压缩包,程序会以文件名作为标题,以图片作为内容。

+

2、如果文件名可以开头含有 数字+下划线,以方便排序,程序会将他们忽略。

EOD; diff --git a/module/search/model.php b/module/search/model.php index dbcc83c825..52ea95c7ec 100644 --- a/module/search/model.php +++ b/module/search/model.php @@ -221,6 +221,7 @@ class searchModel extends model { $query = $this->dao->findByID($queryID)->from(TABLE_USERQUERY)->fetch(); if(!$query) return false; + /* Decode html encode. */ $query->form = htmlspecialchars_decode($query->form, ENT_QUOTES); $query->sql = htmlspecialchars_decode($query->sql, ENT_QUOTES); @@ -247,7 +248,6 @@ class searchModel extends model ->add('account', $this->app->user->account) ->add('form', serialize($this->session->$formVar)) ->add('sql', $sql) - ->skipSpecial('form,sql') ->get(); $this->dao->insert(TABLE_USERQUERY)->data($query)->autoCheck()->check('title', 'notempty')->exec(); } diff --git a/module/upgrade/lang/en.php b/module/upgrade/lang/en.php index fb425916f9..90e55d7977 100644 --- a/module/upgrade/lang/en.php +++ b/module/upgrade/lang/en.php @@ -24,6 +24,7 @@ EOT; + $lang->upgrade->setStatusFile = "

For security reason, we will check file %s
But this file doesn't exist or out of date. You can use the flowing command to create(update)it
For linux:touch %s;
diff --git a/module/upgrade/lang/zh-cn.php b/module/upgrade/lang/zh-cn.php index 99292b96ae..fd2bfa8c02 100644 --- a/module/upgrade/lang/zh-cn.php +++ b/module/upgrade/lang/zh-cn.php @@ -16,13 +16,14 @@ $lang->upgrade->success = '升级成功'; $lang->upgrade->tohome = '返回首页'; $lang->upgrade->warnning= '警告'; $lang->upgrade->warnningContent = << -备份方法:
-1. 可以通过phpMyAdmin进行备份。
-2. 使用mysql命令行的工具。
- # mysqldump -u username -p dbname > filename
- 要将上面红色的部分分别替换成对应的用户名和禅道系统的数据库名。
+

升级有危险,请先备份数据库,以防万一。

+
+1. 可以通过phpMyAdmin进行备份。
+2. 使用mysql命令行的工具。
+   $> mysqldump -u username -p dbname > filename 
+   要将上面红色的部分分别替换成对应的用户名和禅道系统的数据库名。
    比如: mysqldump -u root -p zentao >zentao.bak
+
EOT; $lang->upgrade->setStatusFile = '

升级之前请先执行下面的命令:

    From 22dc72f7397c91e780710a1bb9da64acb8f5eee4 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Thu, 6 Nov 2014 09:16:27 +0000 Subject: [PATCH 2/6] * sort upload images. --- module/bug/control.php | 4 +++- module/story/control.php | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index 06e2a9df25..3362367200 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -390,7 +390,9 @@ class bug extends control if(is_dir($extractPath)) { $titles = array(); - foreach(glob($extractPath . '/*') as $fileName) + $files = glob($extractPath . '/*'); + sort($files); + foreach($files as $fileName) { $fileName = basename($fileName); $titles[$fileName] = preg_replace('/^\d+_/', '', pathinfo($fileName, PATHINFO_FILENAME)); diff --git a/module/story/control.php b/module/story/control.php index 3bde39b232..3c4e4556eb 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -229,7 +229,9 @@ class story extends control if(is_dir($extractPath)) { $titles = array(); - foreach(glob($extractPath . '/*') as $fileName) + $files = glob($extractPath . '/*'); + sort($files); + foreach($files as $fileName) { $fileName = basename($fileName); $titles[$fileName] = preg_replace('/^\d+_/', '', pathinfo($fileName, PATHINFO_FILENAME)); From 8d6ed5676fbfe448f82881cc371f43d5e7b7012e Mon Sep 17 00:00:00 2001 From: ChuJilu Date: Thu, 6 Nov 2014 17:23:13 +0800 Subject: [PATCH 3/6] * fix task #2106. --- module/project/js/task.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/project/js/task.js b/module/project/js/task.js index c65a0dd4ec..d01f31c2d2 100644 --- a/module/project/js/task.js +++ b/module/project/js/task.js @@ -4,7 +4,7 @@ $(function() if(browseType == 'bysearch') ajaxGetSearchForm(); - $('.assign-menu').click(function(e) + $('.assign-search').click(function(e) { e.stopPropagation(); return false; From 96341b35c3f2ff74e8075244725ee2810ffda72b Mon Sep 17 00:00:00 2001 From: wangyidong Date: Thu, 6 Nov 2014 09:36:04 +0000 Subject: [PATCH 4/6] * fix file size. --- module/file/view/buildform.html.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/module/file/view/buildform.html.php b/module/file/view/buildform.html.php index 489b79caf1..0bff28681d 100644 --- a/module/file/view/buildform.html.php +++ b/module/file/view/buildform.html.php @@ -52,7 +52,11 @@ function checkSize(obj) var sizeType = {'K': 1024, 'M': 1024 * 1024, 'G': 1024 * 1024 * 1024}; var unit = maxUploadInfo.replace(/\d+/, ''); var maxUploadSize = maxUploadInfo.replace(unit,'') * sizeType[unit]; - var fileSize = $(obj)[0].files[0].size; + var fileSize = 0; + $(obj).parents('#fileform').find(':file').each(function() + { + if($(this).val()) fileSize += $(this)[0].files[0].size; + }) if(fileSize > maxUploadSize) alert('file->errorFileSize?>'); } } From 460bc7864f0ab03be9749a5c43bf5714dccad9a6 Mon Sep 17 00:00:00 2001 From: ChuJilu Date: Thu, 6 Nov 2014 18:06:38 +0800 Subject: [PATCH 5/6] * fix task #2109 --- module/file/view/printfiles.html.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/module/file/view/printfiles.html.php b/module/file/view/printfiles.html.php index 1158c890de..3396699f25 100644 --- a/module/file/view/printfiles.html.php +++ b/module/file/view/printfiles.html.php @@ -2,7 +2,7 @@ $sessionString = $config->requestType == 'PATH_INFO' ? '?' : '&'; $sessionString .= session_name() . '=' . session_id(); ?> - +