diff --git a/framework/base/router.class.php b/framework/base/router.class.php
index 62ee1a1aad..257871425d 100644
--- a/framework/base/router.class.php
+++ b/framework/base/router.class.php
@@ -973,14 +973,22 @@ class baseRouter
*/
public function setOpenApp()
{
+ $module = $this->rawModule;
+ $this->tab = 'my';
+ if(isset($this->lang->navGroup)) $this->tab = zget($this->lang->navGroup, $module, 'my');
+
if(isset($_COOKIE['tab']) and $_COOKIE['tab'] and preg_match('/^\w+$/', $_COOKIE['tab']))
{
$this->tab = $_COOKIE['tab'];
- }
- else
- {
- $module = $this->rawModule;
- $this->tab = isset($this->lang->navGroup->$module) ? $this->lang->navGroup->$module : 'my';
+
+ /* Fix tab when module is program,product,project,execution,qa, bug not equal tab. */
+ if(strpos("|program|product|project|execution|qa|", "|{$module}|") !== false and $this->tab != $module and isset($this->lang->navGroup))
+ {
+ $this->tab = zget($this->lang->navGroup, $module);
+
+ $_COOKIE['tab'] = $this->tab;
+ setcookie('tab', $this->tab, 0, $this->config->webRoot, '', $this->config->cookieSecure, false);
+ }
}
}
@@ -2687,13 +2695,15 @@ class baseRouter
**/
if(preg_match('/[^\x00-\x80]/', $message)) $message = helper::convertEncoding($message, 'gbk');
$errorLog = "\n" . date('H:i:s') . " $message in $file on line $line ";
- $errorLog .= "when visiting " . htmlspecialchars($this->getURI()) . "\n";
+
+ $URI = $this->getURI();
+ $errorLog .= "when visiting " . (empty($URI) ? '' : htmlspecialchars($URI)) . "\n";
/*
* 为了安全起见,对公网环境隐藏脚本路径。
* If the ip is pulic, hidden the full path of scripts.
*/
- $remoteIP = zget($_SERVER, "REMOTE_ADDR", '');
+ $remoteIP = helper::getRemoteIp();
if(!defined('IN_SHELL') and !($remoteIP == '127.0.0.1' or filter_var($remoteIP, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE) === false))
{
$errorLog = str_replace($this->getBasePath(), '', $errorLog);
@@ -2701,7 +2711,7 @@ class baseRouter
/* 保存到日志文件(Save to log file) */
$errorFile = $this->logRoot . 'php.' . date('Ymd') . '.log.php';
- if(!is_file($errorFile)) file_put_contents($errorFile, "\n");
+ if(!is_file($errorFile)) file_put_contents($errorFile, "\n");
$fh = fopen($errorFile, 'a');
if($fh) fwrite($fh, strip_tags($errorLog)) and fclose($fh);
@@ -2749,7 +2759,7 @@ class baseRouter
if(!class_exists('dao')) return;
$sqlLog = $this->getLogRoot() . 'sql.' . date('Ymd') . '.log.php';
- if(!is_file($sqlLog)) file_put_contents($sqlLog, "\n");
+ if(!is_file($sqlLog)) file_put_contents($sqlLog, "\n");
$fh = @fopen($sqlLog, 'a');
if(!$fh) return false;
diff --git a/framework/control.class.php b/framework/control.class.php
index 9d67ed138d..e8f0b69be3 100644
--- a/framework/control.class.php
+++ b/framework/control.class.php
@@ -124,6 +124,7 @@ class control extends baseControl
if(!isset($this->config->preferenceSetted) and $this->config->vision == 'rnd')
{
+ setcookie('tab', 'my', 0, $this->config->webRoot, '', $this->config->cookieSecure, false);
$this->locate(helper::createLink('my', 'preference'));
}
}
diff --git a/module/common/model.php b/module/common/model.php
index d5d43c2583..c927532ad1 100644
--- a/module/common/model.php
+++ b/module/common/model.php
@@ -991,6 +991,7 @@ class commonModel extends model
/* Set main menu by app tab and module. */
self::setMainMenu();
+ self::checkMenuVarsReplaced();
$activeMenu = '';
$tab = $app->tab;
@@ -2232,7 +2233,8 @@ EOD;
else
{
$referer = helper::safe64Encode($this->app->getURI(true));
- return print(js::locate(helper::createLink('user', 'login', "referer=$referer")));
+ print(js::locate(helper::createLink('user', 'login', "referer=$referer")));
+ helper::end();
}
}
@@ -3059,6 +3061,44 @@ EOD;
unset($lang->$moduleName->homeMenu);
}
+ /**
+ * Check menuVars replaced.
+ *
+ * @static
+ * @access public
+ * @return void
+ */
+ public static function checkMenuVarsReplaced()
+ {
+ global $app, $lang;
+
+ $tab = $app->tab;
+ $varsReplaced = true;
+ foreach($lang->menu as $menuKey => $menu)
+ {
+ if(isset($menu['link']) and strpos($menu['link'], '%s') !== false) $varsReplaced = false;
+ if(!isset($menu['link']) and is_string($menu) and strpos($menu, '%s') !== false) $varsReplaced = false;
+ if(!$varsReplaced) break;
+ }
+
+ if(!$varsReplaced and strpos("|program|product|project|execution|qa|", "|{$tab}|") !== false)
+ {
+ $isTutorialMode = common::isTutorialMode();
+ $currentModule = $isTutorialMode ? $app->moduleName : $app->rawModule;
+
+ if(isset($lang->$currentModule->menu))
+ {
+ $lang->menu = isset($lang->$currentModule->menu) ? $lang->$currentModule->menu : array();
+ $lang->menuOrder = isset($lang->$currentModule->menuOrder) ? $lang->$currentModule->menuOrder : array();
+ $app->tab = zget($lang->navGroup, $currentModule);
+ }
+ else
+ {
+ self::setMenuVars($tab, (int)$app->session->$tab);
+ }
+ }
+ }
+
/*
* Replace the %s of one key of a menu by objectID or $params.
* @param object $menu
diff --git a/module/index/js/index.js b/module/index/js/index.js
index 773a5d5e6d..e7746c1d43 100644
--- a/module/index/js/index.js
+++ b/module/index/js/index.js
@@ -642,11 +642,7 @@
/* Redirect or open default app after document load */
var defaultOpenUrl = window.defaultOpen;
- if(!defaultOpenUrl && location.hash.indexOf('#app=') === 0)
- {
- defaultOpenUrl = decodeURIComponent(location.hash.substr(5));
- if(defaultOpenUrl.indexOf('#app=') < 0) defaultOpenUrl += '#app=' + ($.cookie('tab') ? $.cookie('tab') : defaultApp);
- }
+ if(!defaultOpenUrl && location.hash.indexOf('#app=') === 0) defaultOpenUrl = decodeURIComponent(location.hash.substr(5));
openTab(defaultOpenUrl ? defaultOpenUrl : defaultApp);
diff --git a/module/search/config.php b/module/search/config.php
index 44ee1f2592..6c4e8b73bf 100644
--- a/module/search/config.php
+++ b/module/search/config.php
@@ -143,3 +143,4 @@ $config->search->recPerPage = 10;
/* Set the length of summary of search results. */
$config->search->summaryLength = 120;
+$config->search->maxFileSize = 1024;
diff --git a/module/search/model.php b/module/search/model.php
index 5e6156e87e..09aff5165d 100644
--- a/module/search/model.php
+++ b/module/search/model.php
@@ -1196,11 +1196,11 @@ class searchModel extends model
if(strpos('docx|doc', $file->extension) !== false)
{
$convertedFile = $this->file->convertOffice($file, 'txt');
- if($convertedFile) $object->comment .= file_get_contents($convertedFile);
+ if($convertedFile) $object->comment .= substr(file_get_contents($convertedFile), 0, $this->config->search->maxFileSize);
}
if($file->extension == 'txt')
{
- $object->comment .= file_get_contents($file->realPath);
+ $object->comment .= substr(file_get_contents($file->realPath), 0, $this->config->search->maxFileSize);
}
}