* code for bug #21655.

This commit is contained in:
王怡栋
2022-04-15 11:20:28 +08:00
parent 90f8ad4b90
commit b9ebcd6944
6 changed files with 65 additions and 17 deletions
+19 -9
View File
@@ -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 <strong>$file</strong> on line <strong>$line</strong> ";
$errorLog .= "when visiting <strong>" . htmlspecialchars($this->getURI()) . "</strong>\n";
$URI = $this->getURI();
$errorLog .= "when visiting <strong>" . (empty($URI) ? '' : htmlspecialchars($URI)) . "</strong>\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, "<?php\n die();\n?>\n");
if(!is_file($errorFile)) file_put_contents($errorFile, "<?php\n die();\n?" . ">\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, "<?php\n die();\n?>\n");
if(!is_file($sqlLog)) file_put_contents($sqlLog, "<?php\n die();\n?" . ">\n");
$fh = @fopen($sqlLog, 'a');
if(!$fh) return false;
+1
View File
@@ -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'));
}
}
+41 -1
View File
@@ -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
+1 -5
View File
@@ -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);
+1
View File
@@ -143,3 +143,4 @@ $config->search->recPerPage = 10;
/* Set the length of summary of search results. */
$config->search->summaryLength = 120;
$config->search->maxFileSize = 1024;
+2 -2
View File
@@ -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);
}
}