* code for task #2470.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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:<strong>%s</strong>.";
|
||||
$lang->misc->copyright = "© 2009-2015 <a href='http://www.cnezsoft.com' target='_blank'>Nature EasySoft Network Tecnology Co.ltd, QingDao, China</a> 4006-8899-23 <a href='mailto:co@zentao.net'>co@zentao.net</a>";
|
||||
$lang->misc->mobile = "Mobile access";
|
||||
$lang->misc->noGDLib = "Please visit:<strong>%s</strong>.";
|
||||
$lang->misc->copyright = "© 2009-2015 <a href='http://www.cnezsoft.com' target='_blank'>Nature EasySoft Network Tecnology Co.ltd, QingDao, China</a> 4006-8899-23 <a href='mailto:co@zentao.net'>co@zentao.net</a>";
|
||||
$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";
|
||||
|
||||
@@ -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 = "请用手机浏览器访问:<strong>%s</strong>";
|
||||
$lang->misc->copyright = "© 2009 - 2015 <a href='http://www.cnezsoft.com' target='_blank'>青岛易软天创网络科技有限公司</a> 电话:4006-8899-23 Email:<a href='mailto:co@zentao.net'>co@zentao.net</a> QQ:1492153927";
|
||||
$lang->misc->mobile = "手机访问";
|
||||
$lang->misc->noGDLib = "请用手机浏览器访问:<strong>%s</strong>";
|
||||
$lang->misc->copyright = "© 2009 - 2015 <a href='http://www.cnezsoft.com' target='_blank'>青岛易软天创网络科技有限公司</a> 电话:4006-8899-23 Email:<a href='mailto:co@zentao.net'>co@zentao.net</a> QQ:1492153927";
|
||||
$lang->misc->checkTable = "检查修复数据表";
|
||||
$lang->misc->needRepair = "修复表";
|
||||
$lang->misc->repairTable = "数据库表可以因为断电原因损坏,需要检查修复!!";
|
||||
$lang->misc->tableName = "表名";
|
||||
$lang->misc->tableStatus = "状态";
|
||||
|
||||
@@ -17,4 +17,29 @@ class miscModel extends model
|
||||
{
|
||||
return 'hello world from hello()<br />';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* The reset view file of user module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
|
||||
* @license ZPL (http://zpl.pub/page/zplv12.html)
|
||||
* @author Yidong Wang <yidong@cnezsoft.com>
|
||||
* @package user
|
||||
* @version $Id$
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/view/header.lite.html.php';?>
|
||||
<div class='alert alert-info'><strong><?php echo $lang->misc->repairTable;?></strong></div>
|
||||
<div class='container mw-700px'>
|
||||
<?php if($status == 'createFile'):?>
|
||||
<div class='panel-body'>
|
||||
<?php printf($lang->user->noticeResetFile, $this->session->checkFileName);?>
|
||||
</div>
|
||||
<p><?php echo html::a(inlink('checkTable'), $this->lang->refresh, '', "class='btn'")?></p>
|
||||
<?php elseif($status == 'check'):?>
|
||||
<div class='panel'>
|
||||
<table class='table table-form'>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php echo $lang->misc->tableName?></th>
|
||||
<th><?php echo $lang->misc->tableStatus?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php $needRepair = false;?>
|
||||
<?php foreach($tables as $tableName => $tableStatus):?>
|
||||
<?php if($tableStatus != 'ok') $needRepair = true;?>
|
||||
<tr>
|
||||
<td><?php echo $tableName;?></td>
|
||||
<td><span style='color:<?php echo $tableStatus == 'ok' ? 'green' : 'red'?>'><?php echo $tableStatus;?></span></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<?php endforeach;?>
|
||||
<?php if($needRepair):?>
|
||||
<tfoot>
|
||||
<tr><td class='text-center' colspan='2'><?php echo html::a(inlink('checkTable', "type=repair"), $lang->misc->needRepair, '', "class='btn btn-primary'")?></td></tr>
|
||||
</tfoot>
|
||||
<?php endif;?>
|
||||
</table>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
</div>
|
||||
<?php include '../../common/view/footer.lite.html.php';?>
|
||||
|
||||
Reference in New Issue
Block a user