diff --git a/module/misc/control.php b/module/misc/control.php
index b2ccc682ad..555c42e54f 100644
--- a/module/misc/control.php
+++ b/module/misc/control.php
@@ -152,4 +152,38 @@ class misc extends control
$this->app->loadClass('qrcode');
QRcode::png($loginAPI . $session, false, 4, 9);
}
+
+ /**
+ * Check and repair database table.
+ *
+ * @param string $type
+ * @access public
+ * @return void
+ */
+ public function checkTable($type = 'check')
+ {
+ if($type != 'check' and $type != 'repair') die();
+ if(!isset($_SESSION['checkFileName']))
+ {
+ $checkFileName = $this->app->getBasePath() . 'www' . DS . uniqid('repair_') . '.txt';
+ $this->session->set('checkFileName', $checkFileName);
+ }
+
+ $checkFileName = $this->session->checkFileName;
+ $this->view->title = $this->lang->misc->checkTable;
+
+ $status = '';
+ if(!file_exists($checkFileName) or (time() - filemtime($checkFileName)) > 60 * 10) $status = 'createFile';
+
+ if($status == 'createFile')
+ {
+ $this->app->loadLang('user');
+ $this->view->status = $status;
+ die($this->display());
+ }
+
+ $this->view->tables = $this->misc->getTableAndStatus($type);
+ $this->view->status = 'check';
+ $this->display();
+ }
}
diff --git a/module/misc/lang/en.php b/module/misc/lang/en.php
index 8aa937090a..65c7caca9d 100644
--- a/module/misc/lang/en.php
+++ b/module/misc/lang/en.php
@@ -51,6 +51,11 @@ $lang->misc->zentao->service['install'] = 'Install service';
$lang->misc->zentao->service['fixissue'] = 'Issue support';
$lang->misc->zentao->service['servicemore']= 'More...';
-$lang->misc->mobile = "Mobile access";
-$lang->misc->noGDLib = "Please visit:%s.";
-$lang->misc->copyright = "© 2009-2015 Nature EasySoft Network Tecnology Co.ltd, QingDao, China 4006-8899-23 co@zentao.net";
+$lang->misc->mobile = "Mobile access";
+$lang->misc->noGDLib = "Please visit:%s.";
+$lang->misc->copyright = "© 2009-2015 Nature EasySoft Network Tecnology Co.ltd, QingDao, China 4006-8899-23 co@zentao.net";
+$lang->misc->checkTable = "Check and repair table";
+$lang->misc->needRepair = "Repair Table";
+$lang->misc->repairTable = "The database table can cause of damage because of power failure, need to check and repair!!";
+$lang->misc->tableName = "Table name";
+$lang->misc->tableStatus = "Table status";
diff --git a/module/misc/lang/zh-cn.php b/module/misc/lang/zh-cn.php
index 4c9a203571..1b2a9c5660 100644
--- a/module/misc/lang/zh-cn.php
+++ b/module/misc/lang/zh-cn.php
@@ -51,6 +51,11 @@ $lang->misc->zentao->service['install'] = '禅道安装服务';
$lang->misc->zentao->service['fixissue'] = '禅道问题解决';
$lang->misc->zentao->service['servicemore']= '更多服务...';
-$lang->misc->mobile = "手机访问";
-$lang->misc->noGDLib = "请用手机浏览器访问:%s";
-$lang->misc->copyright = "© 2009 - 2015 青岛易软天创网络科技有限公司 电话:4006-8899-23 Email:co@zentao.net QQ:1492153927";
+$lang->misc->mobile = "手机访问";
+$lang->misc->noGDLib = "请用手机浏览器访问:%s";
+$lang->misc->copyright = "© 2009 - 2015 青岛易软天创网络科技有限公司 电话:4006-8899-23 Email:co@zentao.net QQ:1492153927";
+$lang->misc->checkTable = "检查修复数据表";
+$lang->misc->needRepair = "修复表";
+$lang->misc->repairTable = "数据库表可以因为断电原因损坏,需要检查修复!!";
+$lang->misc->tableName = "表名";
+$lang->misc->tableStatus = "状态";
diff --git a/module/misc/model.php b/module/misc/model.php
index 74aaad49c8..ec1e10c213 100644
--- a/module/misc/model.php
+++ b/module/misc/model.php
@@ -17,4 +17,29 @@ class miscModel extends model
{
return 'hello world from hello()
';
}
+
+ /**
+ * Get table and status.
+ *
+ * @param string $type
+ * @access public
+ * @return array|false
+ */
+ public function getTableAndStatus($type = 'check')
+ {
+ if($type != 'check' and $type != 'repair') return false;
+ $tables = array();
+ $stmt = $this->dao->query("show full tables");
+ while($table = $stmt->fetch(PDO::FETCH_ASSOC))
+ {
+ $tableName = $table["Tables_in_{$this->config->db->name}"];
+ $tableType = strtolower($table['Table_type']);
+ if($tableType == 'base table')
+ {
+ $tableStatus = $this->dao->query("$type table $tableName")->fetch();
+ $tables[$tableName] = strtolower($tableStatus->Msg_text);
+ }
+ }
+ return $tables;
+ }
}
diff --git a/module/misc/view/checktable.html.php b/module/misc/view/checktable.html.php
new file mode 100644
index 0000000000..5d57c9e77c
--- /dev/null
+++ b/module/misc/view/checktable.html.php
@@ -0,0 +1,50 @@
+
+ * @package user
+ * @version $Id$
+ * @link http://www.zentao.net
+ */
+?>
+
+
lang->refresh, '', "class='btn'")?>
+ +| misc->tableName?> | +misc->tableStatus?> | +
|---|---|
| + | '> | +
| misc->needRepair, '', "class='btn btn-primary'")?> | |