Small fixes

This commit is contained in:
RainLoop Team 2015-04-23 01:33:02 +04:00
parent 5b38b2c92c
commit f5f067f1f3
11 changed files with 88 additions and 26 deletions

View file

@ -679,10 +679,10 @@ class Http
{
if ($bSetCacheHeader)
{
\header('Cache-Control: public', true);
\header('Pragma: public', true);
\header('Last-Modified: '.\gmdate('D, d M Y H:i:s', $iUtcTimeStamp - $iExpireTime).' UTC', true);
\header('Expires: '.\gmdate('D, j M Y H:i:s', $iUtcTimeStamp + $iExpireTime).' UTC', true);
@\header('Cache-Control: public', true);
@\header('Pragma: public', true);
@\header('Last-Modified: '.\gmdate('D, d M Y H:i:s', $iUtcTimeStamp - $iExpireTime).' UTC', true);
@\header('Expires: '.\gmdate('D, j M Y H:i:s', $iUtcTimeStamp + $iExpireTime).' UTC', true);
if (0 < strlen($sEtag))
{

View file

@ -83,6 +83,8 @@ abstract class Driver
$this->bTypedPrefix = true;
$this->bGuidPrefix = true;
$this->iTimeOffset = 0;
$this->iWriteOnTimeoutOnly = 0;
$this->bWriteOnErrorOnly = false;
$this->bWriteOnPhpErrorOnly = false;
@ -106,6 +108,17 @@ abstract class Driver
);
}
/**
* @param int $iTimeOffset
*
* @return \MailSo\Log\Driver
*/
public function SetTimeOffset($iTimeOffset)
{
$this->iTimeOffset = $iTimeOffset;
return $this;
}
/**
* @return \MailSo\Log\Driver
*/
@ -217,7 +230,7 @@ abstract class Driver
protected function getTimeWithMicroSec()
{
$aMicroTimeItems = \explode(' ', \microtime());
return \gmdate($this->sDatePattern, $aMicroTimeItems[1]).'.'.
return \MailSo\Log\Logger::DateHelper($this->sDatePattern, $this->iTimeOffset, $aMicroTimeItems[1]).'.'.
\str_pad((int) ($aMicroTimeItems[0] * 1000), 3, '0', STR_PAD_LEFT);
}
@ -247,7 +260,7 @@ abstract class Driver
if (!$this->bFlushCache && ($this->bWriteOnErrorOnly || $this->bWriteOnPhpErrorOnly || 0 < $this->iWriteOnTimeoutOnly))
{
$bErrorPhp = false;
$bError = $this->bWriteOnErrorOnly && \in_array($iType, array(
\MailSo\Log\Enumerations\Type::NOTICE,
\MailSo\Log\Enumerations\Type::NOTICE_PHP,

View file

@ -91,6 +91,21 @@ class Logger extends \MailSo\Base\Collection
return $oInstance;
}
/**
* @param string $sFormat
* @param int $iTimeOffset = 0
* @param int $iTimestamp = 0
*
* @return string
*/
public static function DateHelper($sFormat, $iTimeOffset = 0, $iTimestamp = null)
{
$iTimestamp = null === $iTimestamp ? \time() : (int) $iTimestamp;
$iTimeOffset = (int) $iTimeOffset;
return \gmdate($sFormat, $iTimestamp + $iTimeOffset * 3600);
}
/**
* @return bool
*/

View file

@ -407,8 +407,9 @@ class Actions
{
if (false !== \strpos($sLine, '{date:'))
{
$sLine = \preg_replace_callback('/\{date:([^}]+)\}/', function ($aMatch) {
return \gmdate($aMatch[1]);
$iTimeOffset = (int) $this->Config()->Get('logs', 'time_offset', 0);
$sLine = \preg_replace_callback('/\{date:([^}]+)\}/', function ($aMatch) use ($iTimeOffset) {
return \MailSo\Log\Logger::DateHelper($aMatch[1], $iTimeOffset);
}, $sLine);
$sLine = \preg_replace('/\{date:([^}]*)\}/', 'date', $sLine);
@ -939,6 +940,8 @@ class Actions
if (!!$this->Config()->Get('logs', 'enable', false))
{
$iTimeOffset = (int) $this->Config()->Get('logs', 'time_offset', 0);
$this->oLogger->SetShowSecter(!$this->Config()->Get('logs', 'hide_passwords', true));
$sLogFileFullPath = \APP_PRIVATE_DATA.'logs/'.$this->compileLogFileName(
@ -956,6 +959,7 @@ class Actions
->WriteOnErrorOnly($this->Config()->Get('logs', 'write_on_error_only', false))
->WriteOnPhpErrorOnly($this->Config()->Get('logs', 'write_on_php_error_only', false))
->WriteOnTimeoutOnly($this->Config()->Get('logs', 'write_on_timeout_only', 0))
->SetTimeOffset($iTimeOffset)
);
if (!$this->Config()->Get('debug', 'enable', false))
@ -967,7 +971,10 @@ class Actions
$oHttp = $this->Http();
$this->oLogger->Write('[DATE:'.\gmdate('d.m.y').'][RL:'.APP_VERSION.'][PHP:'.PHP_VERSION.'][IP:'.
$this->oLogger->Write('[DATE:'.\MailSo\Log\Logger::DateHelper('d.m.y', $iTimeOffset).
(0 !== $iTimeOffset ? '][OFFSET:'.(0 < $iTimeOffset ? '+' : '-').
\str_pad((string) \abs($iTimeOffset), 2, '0', STR_PAD_LEFT) : '').
'][RL:'.APP_VERSION.'][PHP:'.PHP_VERSION.'][IP:'.
$oHttp->GetClientIp($this->Config()->Get('labs', 'http_client_ip_check_proxy', false)).'][PID:'.
(\MailSo\Base\Utils::FunctionExistsAndEnabled('getmypid') ? \getmypid() : 'unknown').']['.
$oHttp->GetServer('SERVER_SOFTWARE', '~').']['.
@ -5462,7 +5469,7 @@ class Actions
*/
public function DoMessageList()
{
\sleep(1);
// \sleep(1);
// throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CantGetMessageList);
$sFolder = '';

View file

@ -186,6 +186,8 @@ Values:
'hide_passwords' => array(true, 'Required for development purposes only.
Disabling this option is not recommended.'),
'time_offset' => array(0),
'filename' => array('log-{date:Y-m-d}.txt',
'Log filename.
For security reasons, some characters are removed from filename.

View file

@ -151,7 +151,7 @@
&nbsp;&nbsp;
<span class="i18n" data-i18n="MESSAGE_LIST/PUT_MESSAGE_HERE"></span>
</div>
<div class="listClear" data-bind="visible: '' === messageListSearchDesc() && '' === messageListError() && 0 < messageList().length && (isSpamFolder() || isTrashFolder())">
<div class="listClear" data-bind="visible: clearListIsVisible()">
<span class="g-ui-link i18n" data-i18n="MESSAGE_LIST/BUTTON_EMPTY_FOLDER" data-bind="command: clearCommand"></span>
</div>
<div class="listError" data-bind="visible: !dragOver() && '' !== messageListError()">