diff --git a/lib/zfile/zfile.class.php b/lib/zfile/zfile.class.php
index 38c39850b8..9ff65e0fb9 100644
--- a/lib/zfile/zfile.class.php
+++ b/lib/zfile/zfile.class.php
@@ -192,4 +192,40 @@ class zfile
{
return rename($from, $to);
}
+
+ /**
+ * Get file size.
+ *
+ * @param string $file
+ * @access public
+ * @return int
+ */
+ public function getFileSize($file)
+ {
+ return abs(filesize($file));
+ }
+
+ /**
+ * Get directory size.
+ *
+ * @param string $dir
+ * @access public
+ * @return int
+ */
+ public function getDirSize($dir)
+ {
+ $size = 0;
+ foreach(glob("$dir/*") as $file)
+ {
+ if(is_dir($file))
+ {
+ $size += $this->getDirSize($file);
+ }
+ else
+ {
+ $size += $this->getFileSize($file);
+ }
+ }
+ return $size;
+ }
}
diff --git a/module/backup/control.php b/module/backup/control.php
index a6460f7caa..7f8bd75900 100644
--- a/module/backup/control.php
+++ b/module/backup/control.php
@@ -21,7 +21,7 @@ class backup extends control
{
parent::__construct($moduleName, $methodName);
- $this->backupPath = empty($this->config->backup->settingDir) ? $this->app->getTmpRoot() . 'backup/' : $this->config->backup->settingDir;
+ $this->backupPath = empty($this->config->backup->settingDir) ? $this->app->getTmpRoot() . 'backup' . DS : $this->config->backup->settingDir;
if(!is_dir($this->backupPath))
{
if(!mkdir($this->backupPath, 0777, true)) $this->view->error = sprintf($this->lang->backup->error->noWritable, dirname($this->backupPath));
@@ -127,7 +127,7 @@ class backup extends control
$backFileName = $this->backupPath . $fileName . '.file';
if(!$nozip) $backFileName .= '.zip';
- if(!$nosafe) $backFileName .= '.php';
+ if(!$nozip and !$nosafe) $backFileName .= '.php';
$result = $this->backup->backFile($backFileName);
if(!$result->result)
@@ -146,7 +146,7 @@ class backup extends control
$backFileName = $this->backupPath . $fileName . '.code';
if(!$nozip) $backFileName .= '.zip';
- if(!$nosafe) $backFileName .= '.php';
+ if(!$nozip and !$nosafe) $backFileName .= '.php';
$result = $this->backup->backCode($backFileName);
if(!$result->result)
@@ -353,8 +353,11 @@ class backup extends control
if(isset($data->setting)) $setting = $data->setting;
$this->loadModel('setting')->setItem('system.backup.setting', $setting);
- $settingDir = $data->settingDir;
- if($data->settingDir == $this->app->getTmpRoot() . 'backup/') $settingDir = '';
+ $settingDir = rtrim($data->settingDir, DS) . DS;
+ if(!is_dir($settingDir) and mkdir($settingDir, 0777, true)) die(js::alert($this->lang->backup->error->noCreateDir));
+ if(!is_writable($settingDir)) die(js::alert($this->lang->backup->error->noWritable));
+
+ if($data->settingDir == $this->app->getTmpRoot() . 'backup' . DS) $settingDir = '';
$this->setting->setItem('system.backup.settingDir', $settingDir);
die(js::reload('parent.parent'));
diff --git a/module/backup/lang/en.php b/module/backup/lang/en.php
index efac67a838..6c4262e134 100644
--- a/module/backup/lang/en.php
+++ b/module/backup/lang/en.php
@@ -12,9 +12,11 @@ $lang->backup->time = 'Date';
$lang->backup->files = 'Files';
$lang->backup->size = 'Size';
-$lang->backup->setting = 'Setting';
+$lang->backup->setting = 'Setting';
+$lang->backup->settingDir = 'Backup Directory';
$lang->backup->settingList['nofile'] = 'Not backup file and code.';
-$lang->backup->settingList['nozip'] = 'Only copy file';
+$lang->backup->settingList['nozip'] = 'Only copy file, Uncompressed';
+$lang->backup->settingList['nosafe'] = 'No need to prevent downloading PHP file header.';
$lang->backup->waitting = ' In Progress. Please wait...';
$lang->backup->confirmDelete = 'Do you want to delete the backup?';
@@ -27,6 +29,7 @@ $lang->backup->success->backup = 'Done!';
$lang->backup->success->restore = 'Restored!';
$lang->backup->error = new stdclass();
+$lang->backup->error->noCreateDir = 'Directory is not exists, and can not create it';
$lang->backup->error->noWritable = "%s is not writable! Please check the privilege, or backup cannot be done.";
$lang->backup->error->noDelete = "%s cannot be deleted. Please modify the privilege or manually delete it.";
$lang->backup->error->restoreSQL = "Database library restoration failed. Error %s.";
diff --git a/module/backup/lang/zh-cn.php b/module/backup/lang/zh-cn.php
index 73d1f89ddb..cd7932cd71 100644
--- a/module/backup/lang/zh-cn.php
+++ b/module/backup/lang/zh-cn.php
@@ -16,8 +16,8 @@ $lang->backup->size = '大小';
$lang->backup->setting = '设置';
$lang->backup->settingDir = '备份目录';
$lang->backup->settingList['nofile'] = '不备份附件和代码';
-$lang->backup->settingList['nozip'] = '只拷贝文件';
-$lang->backup->settingList['nosafe'] = '不需要防下载设置';
+$lang->backup->settingList['nozip'] = '只拷贝文件,不压缩';
+$lang->backup->settingList['nosafe'] = '不需要防下载PHP文件头';
$lang->backup->waitting = '正在进行中,请稍候...';
$lang->backup->progressSQL = '
SQL备份中,已备份%s
'; @@ -33,6 +33,7 @@ $lang->backup->success->backup = '备份成功!'; $lang->backup->success->restore = '还原成功!'; $lang->backup->error = new stdclass(); +$lang->backup->error->noCreateDir = '备份目录不存在,也无法创建该目录'; $lang->backup->error->noWritable = "%s 不可写!请检查该目录权限,否则无法备份。";
$lang->backup->error->noDelete = "文件 %s 无法删除,修改权限或手工删除。";
$lang->backup->error->restoreSQL = "数据库还原失败,错误:%s";
diff --git a/module/backup/model.php b/module/backup/model.php
index 613a908896..3a99b051f4 100644
--- a/module/backup/model.php
+++ b/module/backup/model.php
@@ -186,7 +186,7 @@ class backupModel extends model
public function addFileHeader($fileName)
{
$firstline = false;
- $die = "\n";
+ $die = "\n";
$fileSize = filesize($fileName);
$fh = fopen($fileName, 'c+');
@@ -229,7 +229,7 @@ class backupModel extends model
public function removeFileHeader($fileName)
{
$firstline = false;
- $die = "\n";
+ $die = "\n";
$fileSize = filesize($fileName);
$fh = fopen($fileName, 'c+');
@@ -270,18 +270,8 @@ class backupModel extends model
*/
public function getDirSize($dir)
{
- $size = 0;
- foreach(glob("$dir/*") as $file)
- {
- if(is_dir($file))
- {
- $size += $this->getDirSize($file);
- }
- else
- {
- $size += abs(filesize($file));
- }
- }
- return $size;
+ $zfile = $this->app->loadClass('zfile');
+ if(!is_dir($dir)) return $zfile->getFileSize($dir);
+ return $zfile->getDirSize($dir);
}
}
diff --git a/module/common/view/pastetext.html.php b/module/common/view/pastetext.html.php
index 70bf23ecb4..8a34f24345 100644
--- a/module/common/view/pastetext.html.php
+++ b/module/common/view/pastetext.html.php
@@ -28,7 +28,7 @@ $(function()
var lastIndex = parseInt($formTbody.find('tr:last > td:first').text());
var $newRow = $(rowTpl.replace(/%s/g, lastIndex + 1));
$newRow.find('.chosen').chosen();
- $newRow.find('.iframe').modalTrigger({iframe:true});;
+ $newRow.find('.iframe').modalTrigger({iframe:true});
$newRow.find('[data-provide="colorpicker-later"]').colorPicker();
$newRow.datepickerAll();
$formTbody.append($newRow);
diff --git a/module/doc/control.php b/module/doc/control.php
index 22ae79100f..92b9bcac0a 100644
--- a/module/doc/control.php
+++ b/module/doc/control.php
@@ -387,22 +387,6 @@ class doc extends control
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('doc', 'view', "docID=$docID")));
}
- $libs = $this->doc->getLibs();
- foreach($libs as $id => $libName)
- {
- $lib = $this->doc->getLibById($id);
- if($lib->project != 0)
- {
- $project = $this->loadModel('project')->getByID($lib->project);
- $libs[$id] = $project->name . '/' . $libName;
- }
- if($lib->product != 0)
- {
- $product = $this->loadModel('product')->getByID($lib->product);
- $libs[$id] = $product->name . '/' . $libName;
- }
- }
-
/* Get doc and set menu. */
$doc = $this->doc->getById($docID);
$libID = $doc->lib;
@@ -420,7 +404,7 @@ class doc extends control
$this->view->doc = $doc;
$this->view->moduleOptionMenu = $this->tree->getOptionMenu($libID, 'doc', $startModuleID = 0);
$this->view->type = $type;
- $this->view->libs = $libs;
+ $this->view->libs = $this->doc->getCompleteLibName();
$this->view->groups = $this->loadModel('group')->getPairs();
$this->view->users = $this->user->getPairs('noletter', $doc->users);
$this->display();
diff --git a/module/doc/model.php b/module/doc/model.php
index a571687f67..4f5ff54510 100644
--- a/module/doc/model.php
+++ b/module/doc/model.php
@@ -1523,4 +1523,24 @@ class docModel extends model
return $actions;
}
+
+ public function getCompleteLibName()
+ {
+ $libPairs = array();
+ $products = $this->loadModel('product')->getPairs();
+ $projects = $this->loadModel('project')->getPairs();
+ $stmt = $this->dao->select('id,project,product,name')->from(TABLE_DOCLIB)->where('deleted')->eq(0)->query();
+
+ while($lib = $stmt->fetch())
+ {
+ if($this->checkPrivLib($lib))
+ {
+ if($lib->product != 0) $lib->name = zget($products, $lib->product) . '/' . $lib->name;
+ if($lib->project != 0) $lib->name = zget($projects, $lib->project) . '/' . $lib->name;
+ $libPairs[$lib->id] = $lib->name;
+ }
+ }
+
+ return $libPairs;
+ }
}
diff --git a/module/doc/view/view.html.php b/module/doc/view/view.html.php
index 7bee092a44..98931f105f 100644
--- a/module/doc/view/view.html.php
+++ b/module/doc/view/view.html.php
@@ -123,6 +123,7 @@
+ fetch('file', 'printFiles', array('files' => $doc->files, 'fieldset' => 'true'));?>