diff --git a/src/Controller/ModuleController.php b/src/Controller/ModuleController.php index 0df09a3..86ec63a 100644 --- a/src/Controller/ModuleController.php +++ b/src/Controller/ModuleController.php @@ -129,6 +129,25 @@ class ModuleController extends AbstractController Request $request ): Response { + // Check user session exist + $username = false; + + if (!empty($request->cookies->get('KEVACHAT_SESSION')) && preg_match('/[A-z0-9]{32}/', $request->cookies->get('KEVACHAT_SESSION'))) + { + // Connect memcached + $memcached = new \Memcached(); + $memcached->addServer( + $this->getParameter('app.memcached.host'), + $this->getParameter('app.memcached.port') + ); + + // Check username exist for this session + if ($value = $memcached->get($request->cookies->get('KEVACHAT_SESSION'))) + { + $username = $value; + } + } + // Format quoted message if (preg_match('/^[A-z0-9]{64}$/', $request->get('txid'))) { @@ -168,8 +187,7 @@ class ModuleController extends AbstractController 'sign' => $request->get('sign'), 'error' => $request->get('error'), 'message' => $message, - 'ip' => $request->getClientIp(), - + 'username' => $username, 'enabled' => ( !in_array( diff --git a/templates/default/module/post.html.twig b/templates/default/module/post.html.twig index 34f2f39..e8ee2ee 100644 --- a/templates/default/module/post.html.twig +++ b/templates/default/module/post.html.twig @@ -4,7 +4,7 @@ {{ error }} {% endif %} - {% if sign == 'anon' or sign != 'ip' %} + {% if sign == 'anon' or sign != 'username' %} {% else %} @@ -12,14 +12,21 @@ - {% if sign == 'ip' %} - + {% if username %} + {% if sign == 'username' %} + + {% else %} + + {% endif %} + + | + {{ 'logout' | trans }} {% else %} - + + {{ 'login' | trans }} {% endif %} - {% endif %} \ No newline at end of file