Skip to content

Commit

Permalink
validation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
LMOspaceace committed Aug 24, 2017
1 parent 613544f commit ac5a109
Show file tree
Hide file tree
Showing 34 changed files with 304 additions and 676 deletions.
44 changes: 31 additions & 13 deletions acp/ajaxchat_module.php
Expand Up @@ -11,6 +11,8 @@

namespace spaceace\ajaxchat\acp;

use \spaceace\ajaxchat\ext;

class ajaxchat_module
{

Expand Down Expand Up @@ -191,19 +193,27 @@ public function prune_chat($value, $key)
$this->db->sql_freeresult($result);
$sql1 = 'DELETE FROM ' . $this->ajax_chat_table . '
WHERE message_id <= ' . (int) $row;
$this->db->sql_query($sql1);
// Add the log to the ACP
$this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'PRUNE_LOG_AJAXCHAT', time());
$result = $this->db->sql_query($sql1);

if ($this->request->is_ajax())
if ($this->request->is_ajax() && $result)
{
trigger_error($this->user->lang['PRUNE_CHAT_SUCCESS'] . adm_back_link($this->u_action));
// Add the log to the ACP
$this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'PRUNE_LOG_AJAXCHAT', time());
$json_response = new \phpbb\json_response;
$json_response->send(array(
'MESSAGE_TITLE' => $this->user->lang('INFORMATION'),
'MESSAGE_TEXT' => $this->user->lang('PRUNE_CHAT_SUCCESS'),
'REFRESH_DATA' => array(
'time' => 3,
'url' => html_entity_decode($this->u_action)
)
));
}
}
}
$this->id = str_replace("\\", "-", $this->id);

return '<a href="' . append_sid($this->u_action . '&amp;action=prune_chat') . '" data-ajax="true"><input class="button2" type="submit" id="' . $key . '_enable" name="' . $key . '_enable" value="' . $this->user->lang['PRUNE_NOW'] . '" /></a>';
return '<a href="' . append_sid($this->u_action . '&amp;action=prune_chat') . '" data-ajax="true" data-refresh="true"><input class="button2" type="submit" id="' . $key . '_enable" name="' . $key . '_enable" value="' . $this->user->lang['PRUNE_NOW'] . '" /></a>';
}

/**
Expand Down Expand Up @@ -235,19 +245,26 @@ public function truncate_chat($value, $key)
if ($this->action === 'truncate_chat')
{
$sql1 = 'TRUNCATE ' . $this->ajax_chat_table;
$this->db->sql_query($sql1);
// Add the log to the ACP
$this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'TRUNCATE_LOG_AJAXCHAT', time());

if ($this->request->is_ajax())
$result = $this->db->sql_query($sql1);
if ($this->request->is_ajax() && $result)
{
trigger_error($this->user->lang['TRUNCATE_CHAT_SUCCESS'] . adm_back_link($this->u_action));
// Add the log to the ACP
$this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'TRUNCATE_LOG_AJAXCHAT', time());
$json_response = new \phpbb\json_response;
$json_response->send(array(
'MESSAGE_TITLE' => $this->user->lang('INFORMATION'),
'MESSAGE_TEXT' => $this->user->lang('TRUNCATE_CHAT_SUCCESS'),
'REFRESH_DATA' => array(
'time' => 3,
'url' => html_entity_decode($this->u_action)
)
));
}
}
}
$this->id = str_replace("\\", "-", $this->id);

return '<a href="' . append_sid($this->u_action . '&amp;action=truncate_chat') . '" data-ajax="true"><input class="button2" type="submit" id="' . $key . '_enable" name="' . $key . '_enable" value="' . $this->user->lang['TRUNCATE_NOW'] . '" /></a>';
return '<a href="' . append_sid($this->u_action . '&amp;action=truncate_chat') . '" data-ajax="true" data-refresh="true"><input class="button2" type="submit" id="' . $key . '_enable" name="' . $key . '_enable" value="' . $this->user->lang['TRUNCATE_NOW'] . '" /></a>';
}

/**
Expand Down Expand Up @@ -432,6 +449,7 @@ protected function generate_stuff_for_cfg_template($display_vars)
'S_BBCODE_IMG' => true,
'S_BBCODE_FLASH' => true,
'S_LINKS_ALLOWED' => true,
'AJAX_CHAT_VERSION' => ext::AJAX_CHAT_VERSION,
'U_ACTION' => $this->u_action]
);

Expand Down
2 changes: 2 additions & 0 deletions adm/style/ajax_chat.html
Expand Up @@ -14,6 +14,8 @@ <h1>{{ lang('ACP_AJAX_CHAT') }}</h1>

<p>{{ lang('ACP_AJAX_CHAT_EXPLAIN') }}</p>

<img style="float: {{ S_CONTENT_FLOW_END }};" src="https://img.shields.io/badge/{{ lang('VERSION') }}-{{ AJAX_CHAT_VERSION }}-blue.svg?style=plastic" /><br />

{% if S_ERROR %}
<div class="errorbox">
<h3>{{ lang('WARNING') }}</h3>
Expand Down
75 changes: 75 additions & 0 deletions adm/style/ucp_ajax_chat.html
@@ -0,0 +1,75 @@
{% if S_CHAT_ENABLED %}
<fieldset>
<legend>{{ lang('USER_AJAXCHAT_SETTINGS') }}</legend>
<dl>
<dt><label for="ajax_chat_view0">{{ lang('USER_AJAX_CHAT_VIEW') }}{{ lang('COLON') }}</label></dt>
<dd>
<label for="ajax_chat_view1"><input type="radio" name="ajax_chat_view" id="view_chat1" value="1"{% if S_AJAX_CHAT_VIEW %} checked="checked"{% endif %} /> {{ lang('YES') }}</label>
<label for="ajax_chat_view0"><input type="radio" name="ajax_chat_view" id="view_chat0" value="0"{% if not S_AJAX_CHAT_VIEW %} checked="checked"{% endif %} /> {{ lang('NO') }}</label>
</dd>
</dl>
<dl>
<dt><label for="ajax_chat_position0">{{ lang('USER_AJAX_CHAT_POSITION') }}{{ lang('COLON') }}</label></dt>
<dd>
<label for="ajax_chat_position1"><input type="radio" name="ajax_chat_position" id="ajax_chat_position1" value="1"{% if S_AJAX_CHAT_POSITION %} checked="checked"{% endif %} /> {{ lang('CHAT_TOP') }}</label>
<label for="ajax_chat_position0"><input type="radio" name="ajax_chat_position" id="ajax_chat_position0" value="0"{% if not S_AJAX_CHAT_POSITION %} checked="checked"{% endif %} /> {{ lang('CHAT_BOTTOM') }}</label>
</dd>
</dl>
<dl>
<dt><label for="ajax_chat_messages_down0">{{ lang('AJAX_CHAT_MESSAGES_DOWN') }}{{ lang('COLON') }}</label></dt>
<dd>
<label for="ajax_chat_messages_down1"><input type="radio" name="ajax_chat_messages_down" id="ajax_chat_messages_down1" value="1"{% if S_AJAX_CHAT_MESSAGES_DOWN %} checked="checked"{% endif %} /> {{ lang('CHAT_TOP') }}</label>
<label for="ajax_chat_messages_down0"><input type="radio" name="ajax_chat_messages_down" id="ajax_chat_messages_down0" value="0"{% if not S_AJAX_CHAT_MESSAGES_DOWN %} checked="checked"{% endif %} /> {{ lang('CHAT_BOTTOM') }}</label>
</dd>
</dl>
<dl>
<dt><label for="ajax_chat_viewforum0">{{ lang('USER_AJAX_CHAT_VIEWFORUM') }}{{ lang('COLON') }}</label></dt>
<dd>
<label for="ajax_chat_viewforum1"><input type="radio" name="ajax_chat_viewforum" id="ajax_chat_viewforum1" value="1"{% if S_AJAX_CHAT_VIEWFORUM %} checked="checked"{% endif %} /> {{ lang('YES') }}</label>
<label for="ajax_chat_viewforum0"><input type="radio" name="ajax_chat_viewforum" id="ajax_chat_viewforum0" value="0"{% if not S_AJAX_CHAT_VIEWFORUM %} checked="checked"{% endif %} /> {{ lang('NO') }}</label>
</dd>
</dl>
<dl>
<dt><label for="ajax_chat_viewtopic0">{{ lang('USER_AJAX_CHAT_VIEWTOPIC') }}{{ lang('COLON') }}</label></dt>
<dd>
<label for="ajax_chat_ajax_chat_viewtopic1"><input type="radio" name="ajax_chat_viewtopic" id="ajax_chat_viewtopic1" value="1"{% if S_AJAX_CHAT_VIEWTOPIC %} checked="checked"{% endif %} /> {{ lang('YES') }}</label>
<label for="ajax_chat_ajax_chat_viewtopic0"><input type="radio" name="ajax_chat_viewtopic" id="ajax_chat_viewtopic0" value="0"{% if not S_AJAX_CHAT_VIEWTOPIC %} checked="checked"{% endif %} /> {{ lang('NO') }}</label>
</dd>
</dl>
<dl>
<dt><label for="ajax_chat_avatars0">{{ lang('USER_AJAX_CHAT_AVATARS') }}{{ lang('COLON') }}</label></dt>
<dd>
<label for="ajax_chat_avatars1"><input type="radio" name="ajax_chat_avatars" id="ajax_chat_avatars1" value="1"{% if S_AJAX_CHAT_AVATARS %} checked="checked"{% endif %} /> {{ lang('YES') }}</label>
<label for="ajax_chat_avatars0"><input type="radio" name="ajax_chat_avatars" id="ajax_chat_avatars0" value="0"{% if not S_AJAX_CHAT_AVATARS %} checked="checked"{% endif %} /> {{ lang('NO') }}</label>
</dd>
</dl>
<dl>
<dt><label for="ajax_chat_avatar_hover0">{{ lang('USER_AJAX_CHAT_AVATAR_HOVER') }}{{ lang('COLON') }}</label></dt>
<dd>
<label for="ajax_chat_avatar_hover1"><input type="radio" name="ajax_chat_avatar_hover" id="ajax_chat_avatar_hover1" value="1"{% if S_AJAX_CHAT_AVATAR_HOVER %} checked="checked"{% endif %} /> {{ lang('YES') }}</label>
<label for="ajax_chat_avatar_hover0"><input type="radio" name="ajax_chat_avatar_hover" id="ajax_chat_avatar_hover0" value="0"{% if not S_AJAX_CHAT_AVATAR_HOVER %} checked="checked"{% endif %} /> {{ lang('NO') }}</label>
</dd>
</dl>
<dl>
<dt><label for="ajax_chat_sound0">{{ lang('USER_AJAX_CHAT_SOUND') }}{{ lang('COLON') }}</label></dt>
<dd>
<label for="ajax_chat_sound1"><input type="radio" name="ajax_chat_sound" id="ajax_chat_sound1" value="1"{% if S_AJAX_CHAT_SOUND %} checked="checked"{% endif %} /> {{ lang('YES') }}</label>
<label for="ajax_chat_sound0"><input type="radio" name="ajax_chat_sound" id="ajax_chat_sound0" value="0"{% if not S_AJAX_CHAT_SOUND %} checked="checked"{% endif %} /> {{ lang('NO') }}</label>
</dd>
</dl>
<dl>
<dt><label for="ajax_chat_onlinelist0">{{ lang('USER_AJAX_CHAT_ONLINELIST') }}{{ lang('COLON') }}</label></dt>
<dd>
<label for="ajax_chat_onlinelist1"><input type="radio" name="ajax_chat_onlinelist" id="ajax_chat_onlinelist1" value="1"{% if S_AJAX_CHAT_ONLINELIST %} checked="checked"{% endif %} /> {{ lang('YES') }}</label>
<label for="ajax_chat_onlinelist0"><input type="radio" name="ajax_chat_onlinelist" id="ajax_chat_onlinelist0" value="0"{% if not S_AJAX_CHAT_ONLINELIST %} checked="checked"{% endif %} /> {{ lang('NO') }}</label>
</dd>
</dl>
<dl>
<dt><label for="ajax_chat_autocomplete0">{{ lang('USER_AJAX_CHAT_AUTOCOMPLETE') }}{{ lang('COLON') }}</label></dt>
<dd>
<label for="ajax_chat_autocomplete1"><input type="radio" name="ajax_chat_autocomplete" id="ajax_chat_autocomplete1" value="1"{% if S_AJAX_CHAT_AUTOCOMPLETE %} checked="checked"{% endif %} /> {{ lang('YES') }}</label>
<label for="ajax_chat_autocomplete0"><input type="radio" name="ajax_chat_autocomplete" id="ajax_chat_autocomplete0" value="0"{% if not S_AJAX_CHAT_AUTOCOMPLETE %} checked="checked"{% endif %} /> {{ lang('NO') }}</label>
</dd>
</dl>
</fieldset>
{% endif %}
10 changes: 5 additions & 5 deletions composer.json
Expand Up @@ -3,8 +3,8 @@
"type": "phpbb-extension",
"description": "Chat for phpBB 3.1",
"homepage": "http://www.livemembersonly.com",
"version": "3.0.24",
"time": "2017-06-11",
"version": "3.0.25",
"time": "2017-08-23",
"license": "GPL-2.0",
"authors": [{
"name": "spaceace",
Expand All @@ -25,16 +25,16 @@
}],
"require": {
"php": ">= 5.4",
"phpbb/phpbb": "3.1.*@dev"
"phpbb/phpbb": ">=3.1.0,<3.3"
},
"require-dev": {
"phpbb/epv": "dev-master",
"phpbb/phpbb": "~3.1.0"
"phpbb/phpbb": ">=3.1.0,<3.3"
},
"extra": {
"display-name": "Ajax Chat",
"soft-require": {
"phpbb/phpbb": "3.1.*@dev"
"phpbb/phpbb": ">=3.1.0,<3.3"
},
"version-check": {
"host": "www.livemembersonly.com",
Expand Down
89 changes: 47 additions & 42 deletions controller/chat.php
Expand Up @@ -22,6 +22,7 @@
use phpbb\config\db;
use phpbb\path_helper;
use phpbb\extension\manager;
use \spaceace\ajaxchat\ext;

/**
* Main Chat Controller
Expand Down Expand Up @@ -142,23 +143,23 @@ public function __construct(template $template, context $context, user $user, db
$table_prefix, $root_path, $php_ext,
$posts_table, $users_table, $ajax_chat_table, $ajax_chat_sessions_table)
{
$this->template = $template;
$this->template = $template;
$this->context = $context;
$this->user = $user;
$this->db = $db;
$this->auth = $auth;
$this->request = $request;
$this->helper = $helper;
$this->config = $config;
$this->root_path = $root_path;
$this->php_ext = $php_ext;
$this->ext_manager = $ext_manager;
$this->path_helper = $path_helper;
$this->table_prefix = $table_prefix;
$this->posts_table = $posts_table;
$this->users_table = $users_table;
$this->ajax_chat_table = $ajax_chat_table;
$this->ajax_chat_sessions_table = $ajax_chat_sessions_table;
$this->user = $user;
$this->db = $db;
$this->auth = $auth;
$this->request = $request;
$this->helper = $helper;
$this->config = $config;
$this->root_path = $root_path;
$this->php_ext = $php_ext;
$this->ext_manager = $ext_manager;
$this->path_helper = $path_helper;
$this->table_prefix = $table_prefix;
$this->posts_table = $posts_table;
$this->users_table = $users_table;
$this->ajax_chat_table = $ajax_chat_table;
$this->ajax_chat_sessions_table = $ajax_chat_sessions_table;

$this->user->add_lang('posting');
$this->user->add_lang_ext('spaceace/ajaxchat', 'ajax_chat');
Expand Down Expand Up @@ -209,7 +210,9 @@ public function index()
$url_status = ($this->config['allow_post_links']) ? true : false;
$quote_status = true;

$sql = 'SELECT user_lastpost FROM ' . $this->ajax_chat_sessions_table . ' WHERE user_id = ' . (int) $this->user->data['user_id'];
$sql = 'SELECT user_lastpost
FROM ' . $this->ajax_chat_sessions_table . '
WHERE user_id = ' . (int) $this->user->data['user_id'];
$result = $this->db->sql_query($sql);
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
Expand Down Expand Up @@ -238,30 +241,30 @@ public function index()

//Assign the features template variable
$this->template->assign_vars([
'BBCODE_STATUS' => ($bbcode_status) ? sprintf($this->user->lang['BBCODE_IS_ON'], '<a href="' . append_sid("{$this->root_path}faq.$this->php_ext", 'mode=bbcode') . '">', '</a>') : sprintf($this->user->lang['BBCODE_IS_OFF'], '<a href="' . append_sid("{$this->root_path}faq.$this->php_ext", 'mode=bbcode') . '">', '</a>'),
'IMG_STATUS' => ($img_status) ? $this->user->lang['IMAGES_ARE_ON'] : $this->user->lang['IMAGES_ARE_OFF'],
'FLASH_STATUS' => ($flash_status) ? $this->user->lang['FLASH_IS_ON'] : $this->user->lang['FLASH_IS_OFF'],
'SMILIES_STATUS' => ($smilies_status) ? $this->user->lang['SMILIES_ARE_ON'] : $this->user->lang['SMILIES_ARE_OFF'],
'URL_STATUS' => ($url_status) ? $this->user->lang['URL_IS_ON'] : $this->user->lang['URL_IS_OFF'],
'S_LINKS_ALLOWED' => $url_status,
'S_COMPOSE_PM' => true,
'S_BBCODE_ALLOWED' => $bbcode_status,
'S_SMILIES_ALLOWED' => $smilies_status,
'S_BBCODE_IMG' => $img_status,
'S_BBCODE_FLASH' => $flash_status,
'S_BBCODE_QUOTE' => $quote_status,
'S_BBCODE_URL' => $url_status,
'REFRESH_TIME' => $refresh,
'LAST_ID' => $this->last_id,
'LAST_POST' => $last_post,
'TIME' => time(),
'L_VERSION' => '3.0.24',
'STYLE_PATH' => generate_board_url() . '/styles/' . $this->user->style['style_path'],
'EXT_STYLE_PATH' => $this->ext_path_web . 'styles/',
'FILENAME' => $this->helper->route('spaceace_ajaxchat_chat', array('tslash' => '')),
'S_CHAT' => (!$this->get) ? true : false,
'S_GET_CHAT' => ($this->get) ? true : false,
'CHAT_PAGE' => $this->page,
'BBCODE_STATUS' => ($bbcode_status) ? sprintf($this->user->lang['BBCODE_IS_ON'], '<a href="' . append_sid("{$this->root_path}faq.$this->php_ext", 'mode=bbcode') . '">', '</a>') : sprintf($this->user->lang['BBCODE_IS_OFF'], '<a href="' . append_sid("{$this->root_path}faq.$this->php_ext", 'mode=bbcode') . '">', '</a>'),
'IMG_STATUS' => ($img_status) ? $this->user->lang['IMAGES_ARE_ON'] : $this->user->lang['IMAGES_ARE_OFF'],
'FLASH_STATUS' => ($flash_status) ? $this->user->lang['FLASH_IS_ON'] : $this->user->lang['FLASH_IS_OFF'],
'SMILIES_STATUS' => ($smilies_status) ? $this->user->lang['SMILIES_ARE_ON'] : $this->user->lang['SMILIES_ARE_OFF'],
'URL_STATUS' => ($url_status) ? $this->user->lang['URL_IS_ON'] : $this->user->lang['URL_IS_OFF'],
'S_LINKS_ALLOWED' => $url_status,
'S_COMPOSE_PM' => true,
'S_BBCODE_ALLOWED' => $bbcode_status,
'S_SMILIES_ALLOWED' => $smilies_status,
'S_BBCODE_IMG' => $img_status,
'S_BBCODE_FLASH' => $flash_status,
'S_BBCODE_QUOTE' => $quote_status,
'S_BBCODE_URL' => $url_status,
'REFRESH_TIME' => $refresh,
'LAST_ID' => $this->last_id,
'LAST_POST' => $last_post,
'TIME' => time(),
'L_AJAX_CHAT_VERSION' => ext::AJAX_CHAT_VERSION,
'STYLE_PATH' => generate_board_url() . '/styles/' . $this->user->style['style_path'],
'EXT_STYLE_PATH' => $this->ext_path_web . 'styles/',
'FILENAME' => $this->helper->route('spaceace_ajaxchat_chat', array('tslash' => '')),
'S_CHAT' => (!$this->get) ? true : false,
'S_GET_CHAT' => ($this->get) ? true : false,
'CHAT_PAGE' => $this->page,
]);

$this->whois_online();
Expand Down Expand Up @@ -384,7 +387,9 @@ public function whois_online()
WHERE user_id = ' . (int) $this->user->data['user_id'];
$this->db->sql_query($sql);

$sql = 'DELETE FROM ' . $this->ajax_chat_sessions_table . ' WHERE user_lastupdate < ' . (int) $check_time;
$sql = 'DELETE
FROM ' . $this->ajax_chat_sessions_table . '
WHERE user_lastupdate < ' . (int) $check_time;
$this->db->sql_query($sql);

$sql = 'SELECT *
Expand Down
5 changes: 0 additions & 5 deletions event/listener.php
Expand Up @@ -242,11 +242,6 @@ public function index()
return;
}

if ($this->config['prune_ajax_chat'] === true)
{
$this->prune();
}

$this->user->add_lang('posting');

$this->chat->defaultAction('index');
Expand Down
2 changes: 2 additions & 0 deletions ext.php
Expand Up @@ -16,6 +16,8 @@
*/
class ext extends \phpbb\extension\base
{
const AJAX_CHAT_VERSION = '3.0.25';

public function is_enableable()
{
$config = $this->container->get('config');
Expand Down
1 change: 1 addition & 0 deletions language/en/info_acp_ajax_chat.php
Expand Up @@ -119,5 +119,6 @@
'AJAX_CHAT_INPUT_FULL_EXPLAIN' => 'Disabling this will leave only the "Submit" button and message inputbox making it a very basic input like a shoutbox.',
'AJAX_CHAT_CHATROW_FULL' => 'Short message height',
'AJAX_CHAT_CHATROW_FULL_EXPLAIN' => 'Disabling this will set the chat message height to it`s original height. Enabling this will have the message height as short as possible while fitting more messages in view.',
'VERSION' => 'Version',
)
);
32 changes: 0 additions & 32 deletions migrations/add_hidden_session_status.php

This file was deleted.

0 comments on commit ac5a109

Please sign in to comment.