mirror of
https://github.com/Mibew/mibew.git
synced 2025-03-03 18:38:31 +03:00
Add controller's action for user's track
This commit is contained in:
parent
ae1b1dfbb1
commit
00e7f3eb40
@ -585,7 +585,7 @@ function setup_chatview_for_operator(Thread $thread, $operator)
|
|||||||
$visitor = track_get_visitor_by_thread_id($thread->id);
|
$visitor = track_get_visitor_by_thread_id($thread->id);
|
||||||
$tracked_link_params = array("visitor" => "" . $visitor['visitorid']);
|
$tracked_link_params = array("visitor" => "" . $visitor['visitorid']);
|
||||||
$data['chat']['links']['tracked'] = add_params(
|
$data['chat']['links']['tracked'] = add_params(
|
||||||
MIBEW_WEB_ROOT . "/operator/tracked.php",
|
MIBEW_WEB_ROOT . "/operator/history/user-track",
|
||||||
$tracked_link_params
|
$tracked_link_params
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,9 @@
|
|||||||
namespace Mibew\Controller;
|
namespace Mibew\Controller;
|
||||||
|
|
||||||
use Mibew\Database;
|
use Mibew\Database;
|
||||||
|
use Mibew\Http\Exception\BadRequestException;
|
||||||
use Mibew\Thread;
|
use Mibew\Thread;
|
||||||
|
use Mibew\Settings;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -269,4 +271,56 @@ class HistoryController extends AbstractController
|
|||||||
|
|
||||||
return $this->render('history_user', $page);
|
return $this->render('history_user', $page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate content for "history_user_track" route.
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @return string Rendered page content
|
||||||
|
*/
|
||||||
|
public function userTrackAction(Request $request)
|
||||||
|
{
|
||||||
|
setlocale(LC_TIME, getstring('time.locale'));
|
||||||
|
|
||||||
|
if (Settings::get('enabletracking') == '0') {
|
||||||
|
throw new BadRequestException('Tracking is disabled.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->query->has('thread')) {
|
||||||
|
$thread_id = $request->query->get('thread');
|
||||||
|
if (!preg_match("/^\d{1,8}$/", $thread_id)) {
|
||||||
|
throw new BadRequestException('Wrong thread ID.');
|
||||||
|
}
|
||||||
|
$visitor = track_get_visitor_by_thread_id($thread_id);
|
||||||
|
if (!$visitor) {
|
||||||
|
throw new BadRequestException('Wrong thread.');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$visitor_id = $request->query->get('visitor');
|
||||||
|
if (!preg_match("/^\d{1,8}$/", $visitor_id)) {
|
||||||
|
throw new BadRequestException('Wrong visitor ID.');
|
||||||
|
}
|
||||||
|
$visitor = track_get_visitor_by_id($visitor_id);
|
||||||
|
if (!$visitor) {
|
||||||
|
throw new BadRequestException('Wrong visitor.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = track_get_path($visitor);
|
||||||
|
|
||||||
|
$page['entry'] = htmlspecialchars($visitor['entry']);
|
||||||
|
$page['history'] = array();
|
||||||
|
ksort($path);
|
||||||
|
foreach ($path as $k => $v) {
|
||||||
|
$page['history'][] = array(
|
||||||
|
'date' => date_to_text($k),
|
||||||
|
'link' => htmlspecialchars($v),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$page['title'] = getlocal('tracked.path');
|
||||||
|
$page['show_small_login'] = false;
|
||||||
|
|
||||||
|
return $this->render('tracked', $page);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,12 @@ history_user:
|
|||||||
requirements:
|
requirements:
|
||||||
user_id: .{0,63}
|
user_id: .{0,63}
|
||||||
|
|
||||||
|
history_user_track:
|
||||||
|
path: /operator/history/user-track
|
||||||
|
defaults:
|
||||||
|
_controller: Mibew\Controller\HistoryController::userTrackAction
|
||||||
|
_access_check: Mibew\AccessControl\Check\LoggedInCheck
|
||||||
|
|
||||||
password_recovery:
|
password_recovery:
|
||||||
path: /operator/password-recovery
|
path: /operator/password-recovery
|
||||||
defaults:
|
defaults:
|
||||||
|
@ -1,66 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* Copyright 2005-2014 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Import namespaces and classes of the core
|
|
||||||
use Mibew\Settings;
|
|
||||||
use Mibew\Style\PageStyle;
|
|
||||||
|
|
||||||
// Initialize libraries
|
|
||||||
require_once(dirname(dirname(__FILE__)) . '/libs/init.php');
|
|
||||||
|
|
||||||
$operator = check_login();
|
|
||||||
|
|
||||||
setlocale(LC_TIME, getstring("time.locale"));
|
|
||||||
|
|
||||||
if (Settings::get('enabletracking') == "0") {
|
|
||||||
die("Tracking disabled!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($_GET['thread'])) {
|
|
||||||
$thread_id = verify_param("thread", "/^\d{1,8}$/");
|
|
||||||
} else {
|
|
||||||
$visitor_id = verify_param("visitor", "/^\d{1,8}$/");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($thread_id)) {
|
|
||||||
$visitor = track_get_visitor_by_thread_id($thread_id);
|
|
||||||
if (!$visitor) {
|
|
||||||
die("Wrong thread!");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$visitor = track_get_visitor_by_id($visitor_id);
|
|
||||||
if (!$visitor) {
|
|
||||||
die("Wrong visitor!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$path = track_get_path($visitor);
|
|
||||||
|
|
||||||
$page['entry'] = htmlspecialchars($visitor['entry']);
|
|
||||||
$page['history'] = array();
|
|
||||||
ksort($path);
|
|
||||||
foreach ($path as $k => $v) {
|
|
||||||
$page['history'][] = array(
|
|
||||||
'date' => date_to_text($k),
|
|
||||||
'link' => htmlspecialchars($v),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$page['title'] = getlocal("tracked.path");
|
|
||||||
$page['show_small_login'] = false;
|
|
||||||
|
|
||||||
$page_style = new PageStyle(PageStyle::getCurrentStyle());
|
|
||||||
$page_style->render('tracked', $page);
|
|
@ -98,7 +98,7 @@
|
|||||||
|
|
||||||
agentLink: "{{mibewRoot}}/operator/agent.php",
|
agentLink: "{{mibewRoot}}/operator/agent.php",
|
||||||
geoLink: "{{geoLink}}",
|
geoLink: "{{geoLink}}",
|
||||||
trackedLink: "{{mibewRoot}}/operator/tracked.php",
|
trackedLink: "{{mibewRoot}}/operator/history/user-track",
|
||||||
banLink: "{{mibewRoot}}/operator/ban.php",
|
banLink: "{{mibewRoot}}/operator/ban.php",
|
||||||
inviteLink: "{{mibewRoot}}/operator/invite.php",
|
inviteLink: "{{mibewRoot}}/operator/invite.php",
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user