mirror of
https://github.com/kevachat/webapp.git
synced 2025-01-10 23:08:14 +00:00
add username features to the post module
This commit is contained in:
parent
c6fef9bb4b
commit
50760a41fd
@ -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(
|
||||
|
@ -4,7 +4,7 @@
|
||||
<output name="error" for="form-post-message">{{ error }}</output>
|
||||
{% endif %}
|
||||
<textarea name="message" id="form-post-message" placeholder="{{ 'enter your message...' | trans }}">{{ message }}</textarea>
|
||||
{% if sign == 'anon' or sign != 'ip' %}
|
||||
{% if sign == 'anon' or sign != 'username' %}
|
||||
<input type="radio" name="sign" value="anon" id="form-post-sign-anon" checked="checked" />
|
||||
{% else %}
|
||||
<input type="radio" name="sign" value="anon" id="form-post-sign-anon" />
|
||||
@ -12,14 +12,21 @@
|
||||
<label for="form-post-sign-anon">
|
||||
{{ 'anon' | trans }}
|
||||
</label>
|
||||
{% if sign == 'ip' %}
|
||||
<input type="radio" name="sign" value="ip" id="form-post-sign-ip" checked="checked" />
|
||||
{% if username %}
|
||||
{% if sign == 'username' %}
|
||||
<input type="radio" name="sign" value="username" id="form-post-sign-username" checked="checked" />
|
||||
{% else %}
|
||||
<input type="radio" name="sign" value="username" id="form-post-sign-username" />
|
||||
{% endif %}
|
||||
<label for="form-post-sign-username">
|
||||
@{{ username }}
|
||||
</label>
|
||||
|
|
||||
<a href="{{ path('user_logout') }}">{{ 'logout' | trans }}</a>
|
||||
{% else %}
|
||||
<input type="radio" name="sign" value="ip" id="form-post-sign-ip" />
|
||||
<input type="radio" name="sign" value="username" id="form-post-sign-username" disabled="disabled" />
|
||||
<a href="{{ path('user_login') }}">{{ 'login' | trans }}</a>
|
||||
{% endif %}
|
||||
<label for="form-post-sign-ip">
|
||||
@{{ ip }}
|
||||
</label>
|
||||
<button type="submit">{{ 'send' | trans }}</button>
|
||||
</form>
|
||||
{% endif %}
|
Loading…
Reference in New Issue
Block a user