|
@@ -39,6 +39,10 @@ class Index extends Frontend
|
|
|
$days = (int)(Config::get('mproc.session_days') ?: 7);
|
|
$days = (int)(Config::get('mproc.session_days') ?: 7);
|
|
|
$days = max(1, min(30, $days));
|
|
$days = max(1, min(30, $days));
|
|
|
$this->mprocTtlSeconds = $days * 86400;
|
|
$this->mprocTtlSeconds = $days * 86400;
|
|
|
|
|
+ if (PHP_VERSION_ID >= 70300) {
|
|
|
|
|
+ ini_set('session.cookie_lifetime', (string)$this->mprocTtlSeconds);
|
|
|
|
|
+ ini_set('session.gc_maxlifetime', (string)$this->mprocTtlSeconds);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -401,28 +405,80 @@ class Index extends Frontend
|
|
|
return $s;
|
|
return $s;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ protected function mprocRememberFocusEid(int $focusEid): void
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($focusEid > 0) {
|
|
|
|
|
+ Session::set('mproc_focus_eid', $focusEid);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ protected function mprocPullSessionFocusEid(): int
|
|
|
|
|
+ {
|
|
|
|
|
+ $fe = (int)Session::get('mproc_focus_eid', 0);
|
|
|
|
|
+ if ($fe > 0) {
|
|
|
|
|
+ Session::delete('mproc_focus_eid');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return $fe;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
- * 从请求中读取短信/邮件直达明细 ID(兼容 query、pathinfo、REQUEST_URI)
|
|
|
|
|
|
|
+ * 从 URI/query 中解析 focus_eid(兼容邮件客户端把 &focus_eid 拼进上一参数值的情况)
|
|
|
|
|
+ */
|
|
|
|
|
+ protected function mprocParseFocusEidFromUriString(string $uri): int
|
|
|
|
|
+ {
|
|
|
|
|
+ if ($uri === '' || stripos($uri, 'focus_eid') === false) {
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (preg_match('/(?:[?&;]|%26)(?:amp;)*focus_eid=(\d+)/i', $uri, $m)) {
|
|
|
|
|
+ return (int)$m[1];
|
|
|
|
|
+ }
|
|
|
|
|
+ $query = parse_url($uri, PHP_URL_QUERY);
|
|
|
|
|
+ if (!is_string($query) || $query === '') {
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ $q = [];
|
|
|
|
|
+ parse_str($query, $q);
|
|
|
|
|
+ if (!is_array($q)) {
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (isset($q['focus_eid'])) {
|
|
|
|
|
+ $fe = (int)$q['focus_eid'];
|
|
|
|
|
+ if ($fe > 0) {
|
|
|
|
|
+ return $fe;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ foreach ($q as $k => $v) {
|
|
|
|
|
+ $blob = (is_string($k) ? $k : '') . '=' . (is_scalar($v) ? (string)$v : '');
|
|
|
|
|
+ if (preg_match('/(?:^|[?&;]|%26)(?:amp;)*focus_eid=(\d+)/i', $blob, $m2)) {
|
|
|
|
|
+ return (int)$m2[1];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 从请求中读取短信/邮件直达明细 ID(兼容 query、pathinfo、REQUEST_URI、登录回跳 Session)
|
|
|
*/
|
|
*/
|
|
|
protected function mprocReadFocusEidFromRequest(): int
|
|
protected function mprocReadFocusEidFromRequest(): int
|
|
|
{
|
|
{
|
|
|
$fe = (int)$this->request->param('focus_eid', 0);
|
|
$fe = (int)$this->request->param('focus_eid', 0);
|
|
|
if ($fe > 0) {
|
|
if ($fe > 0) {
|
|
|
|
|
+ $this->mprocRememberFocusEid($fe);
|
|
|
|
|
+
|
|
|
return $fe;
|
|
return $fe;
|
|
|
}
|
|
}
|
|
|
$uri = isset($_SERVER['REQUEST_URI']) ? (string)$_SERVER['REQUEST_URI'] : '';
|
|
$uri = isset($_SERVER['REQUEST_URI']) ? (string)$_SERVER['REQUEST_URI'] : '';
|
|
|
- if ($uri !== '' && stripos($uri, 'focus_eid') !== false) {
|
|
|
|
|
- $query = parse_url($uri, PHP_URL_QUERY);
|
|
|
|
|
- if (is_string($query) && $query !== '') {
|
|
|
|
|
- $q = [];
|
|
|
|
|
- parse_str($query, $q);
|
|
|
|
|
- if (is_array($q)) {
|
|
|
|
|
- $fe = (int)($q['focus_eid'] ?? 0);
|
|
|
|
|
- if ($fe > 0) {
|
|
|
|
|
- return $fe;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ $fe = $this->mprocParseFocusEidFromUriString($uri);
|
|
|
|
|
+ if ($fe > 0) {
|
|
|
|
|
+ $this->mprocRememberFocusEid($fe);
|
|
|
|
|
+
|
|
|
|
|
+ return $fe;
|
|
|
|
|
+ }
|
|
|
|
|
+ $fe = (int)Session::get('mproc_focus_eid', 0);
|
|
|
|
|
+ if ($fe > 0) {
|
|
|
|
|
+ return $fe;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
@@ -475,11 +531,19 @@ class Index extends Frontend
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
$allowed = [];
|
|
$allowed = [];
|
|
|
|
|
+ $fe = 0;
|
|
|
if (isset($q['focus_eid'])) {
|
|
if (isset($q['focus_eid'])) {
|
|
|
$fe = (int)$q['focus_eid'];
|
|
$fe = (int)$q['focus_eid'];
|
|
|
- if ($fe > 0) {
|
|
|
|
|
- $allowed['focus_eid'] = $fe;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($fe <= 0) {
|
|
|
|
|
+ $fe = $this->mprocParseFocusEidFromUriString($raw);
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($fe <= 0) {
|
|
|
|
|
+ $fe = (int)Session::get('mproc_focus_eid', 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($fe > 0) {
|
|
|
|
|
+ $allowed['focus_eid'] = $fe;
|
|
|
|
|
+ $this->mprocRememberFocusEid($fe);
|
|
|
}
|
|
}
|
|
|
$mt = isset($q['main_tab']) ? trim((string)$q['main_tab']) : '';
|
|
$mt = isset($q['main_tab']) ? trim((string)$q['main_tab']) : '';
|
|
|
if ($mt === 'me' || $mt === 'orders') {
|
|
if ($mt === 'me' || $mt === 'orders') {
|
|
@@ -497,6 +561,21 @@ class Index extends Frontend
|
|
|
}
|
|
}
|
|
|
$base = rtrim($this->request->root(true), '/');
|
|
$base = rtrim($this->request->root(true), '/');
|
|
|
$path = '/index/index/index';
|
|
$path = '/index/index/index';
|
|
|
|
|
+ if (isset($allowed['focus_eid']) && (int)$allowed['focus_eid'] > 0 && !isset($allowed['q'])) {
|
|
|
|
|
+ $fe = (int)$allowed['focus_eid'];
|
|
|
|
|
+ if (!isset($allowed['tab']) && (!isset($allowed['main_tab']) || $allowed['main_tab'] === 'orders')) {
|
|
|
|
|
+ return $base . $path . '?focus_eid=' . $fe . '#mproc_fe=' . $fe;
|
|
|
|
|
+ }
|
|
|
|
|
+ $ordered = ['focus_eid' => $fe];
|
|
|
|
|
+ if (isset($allowed['tab'])) {
|
|
|
|
|
+ $ordered['tab'] = $allowed['tab'];
|
|
|
|
|
+ }
|
|
|
|
|
+ if (isset($allowed['main_tab'])) {
|
|
|
|
|
+ $ordered['main_tab'] = $allowed['main_tab'];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return $base . $path . '?' . http_build_query($ordered, '', '&', PHP_QUERY_RFC3986) . '#mproc_fe=' . $fe;
|
|
|
|
|
+ }
|
|
|
$qs = $allowed !== [] ? ('?' . http_build_query($allowed, '', '&', PHP_QUERY_RFC3986)) : '';
|
|
$qs = $allowed !== [] ? ('?' . http_build_query($allowed, '', '&', PHP_QUERY_RFC3986)) : '';
|
|
|
|
|
|
|
|
return $base . $path . $qs;
|
|
return $base . $path . $qs;
|
|
@@ -1572,8 +1651,15 @@ class Index extends Frontend
|
|
|
{
|
|
{
|
|
|
$user = $this->mprocGetUser();
|
|
$user = $this->mprocGetUser();
|
|
|
if (!$user) {
|
|
if (!$user) {
|
|
|
|
|
+ $pendingFocus = $this->mprocReadFocusEidFromRequest();
|
|
|
|
|
+ if ($pendingFocus > 0) {
|
|
|
|
|
+ $this->mprocRememberFocusEid($pendingFocus);
|
|
|
|
|
+ }
|
|
|
$uri = isset($_SERVER['REQUEST_URI']) ? (string)$_SERVER['REQUEST_URI'] : '';
|
|
$uri = isset($_SERVER['REQUEST_URI']) ? (string)$_SERVER['REQUEST_URI'] : '';
|
|
|
$safe = $this->mprocSanitizeRedirectUrl($uri);
|
|
$safe = $this->mprocSanitizeRedirectUrl($uri);
|
|
|
|
|
+ if ($safe !== '' && $pendingFocus > 0 && stripos($safe, 'focus_eid') === false) {
|
|
|
|
|
+ $safe .= (strpos($safe, '?') !== false ? '&' : '?') . 'focus_eid=' . $pendingFocus;
|
|
|
|
|
+ }
|
|
|
if ($safe !== '') {
|
|
if ($safe !== '') {
|
|
|
Session::set('mproc_intended_url', $safe);
|
|
Session::set('mproc_intended_url', $safe);
|
|
|
}
|
|
}
|
|
@@ -1647,6 +1733,8 @@ class Index extends Frontend
|
|
|
$cid = (int)($user['customer_id'] ?? $user['customer_user_id'] ?? 0);
|
|
$cid = (int)($user['customer_id'] ?? $user['customer_user_id'] ?? 0);
|
|
|
$this->view->assign('mprocCanChangePwd', empty($user['is_admin']) && $cid > 0 ? 1 : 0);
|
|
$this->view->assign('mprocCanChangePwd', empty($user['is_admin']) && $cid > 0 ? 1 : 0);
|
|
|
$this->view->assign('mprocFocusEid', $mprocFocusEid);
|
|
$this->view->assign('mprocFocusEid', $mprocFocusEid);
|
|
|
|
|
+ $this->view->assign('mprocBootstrapToken', trim((string)($user['token'] ?? '')));
|
|
|
|
|
+ $this->view->assign('mprocBootstrapKeepDays', max(1, (int)round($this->mprocTtlSeconds / 86400)));
|
|
|
|
|
|
|
|
if ($mainTab === 'me') {
|
|
if ($mainTab === 'me') {
|
|
|
$this->view->assign('rows', []);
|
|
$this->view->assign('rows', []);
|