Allow to use any browser for chat

There are too many browsers in the world thus we cannot really say
is the current browser is fully supported or not. Give a chance to
all browsers.
This commit is contained in:
Dmitriy Simushev 2014-12-29 15:39:13 +00:00
parent 9cd082b878
commit 132ca02cdf
4 changed files with 0 additions and 135 deletions

View File

@ -90,107 +90,6 @@ function get_user_name($user_name, $addr, $id)
);
}
/**
* Check if browser support ajax requests
*
* @param array $browser_id name of browser
* @param array $ver browser version
* @param array $user_agent user agent of browser
*
* @return bool true on ajax support and false if ajax is not supported
*/
function is_ajax_browser($browser_id, $ver, $user_agent)
{
if ($browser_id == "opera") {
return $ver >= 8.02;
}
if ($browser_id == "safari") {
return $ver >= 125;
}
if ($browser_id == "msie") {
return $ver >= 5.5 && !strstr($user_agent, "powerpc");
}
if ($browser_id == "netscape") {
return $ver >= 7.1;
}
if ($browser_id == "mozilla") {
return $ver >= 1.4;
}
if ($browser_id == "firefox") {
return $ver >= 1.0;
}
if ($browser_id == "chrome") {
return true;
}
return false;
}
/**
* Check if browser support ajax requests
*
* @param array $browser_id Code name of browser
* @param array $ver Browser version
* @param array $user_agent User Agent of browser
*
* @return bool true on ajax support and false if ajax is not supported
*/
function get_remote_level($user_agent)
{
$known_agents = get_known_user_agents();
$user_agent = strtolower($user_agent);
foreach ($known_agents as $agent) {
if (strstr($user_agent, $agent)) {
if (preg_match("/" . $agent . "[\\s\/]?(\\d+(\\.\\d+)?)/", $user_agent, $matches)) {
$ver = $matches[1];
if (is_ajax_browser($agent, $ver, $user_agent)) {
return "ajaxed";
} else {
return "old";
}
}
}
}
return "ajaxed";
}
/**
* Returns a list of supported browsers.
*
* @return array List of supported browsers names.
*/
function get_supported_browsers()
{
return array(
'Internet Explorer 5.5+',
'Firefox 1.0+',
'Opera 8.0+',
'Mozilla 1.4+',
'Netscape 7.1+',
'Safari 1.2+',
);
}
/**
* Returns a list of known user agents code names.
*
* @return array List of known user agents
*/
function get_known_user_agents()
{
return array(
"opera",
"msie",
"chrome",
"safari",
"firefox",
"netscape",
"mozilla",
);
}
/**
* Prepare logo data
*

View File

@ -95,12 +95,6 @@ class OperatorChatController extends AbstractController
$operator = $this->getOperator();
$thread_id = $request->attributes->getInt('thread_id');
// Check operator's browser level because old browsers aren't supported.
$remote_level = get_remote_level($request->headers->get('User-Agent'));
if ($remote_level != 'ajaxed') {
return $this->showErrors(array(getlocal('Old browser is used, please update it')));
}
// Check if the thread can be loaded.
$thread = Thread::load($thread_id);
if (!$thread || !isset($thread->lastToken)) {

View File

@ -89,15 +89,6 @@ class UserChatController extends AbstractController
return $ssl_redirect;
}
// Do not support old browsers at all
if (get_remote_level($request->headers->get('User-Agent')) == 'old') {
// Create page array
$page = setup_logo();
$page['supportedBrowsers'] = get_supported_browsers();
return $this->render('nochat', $page);
}
// Initialize client side application
$this->getAssetManager()->attachJs('js/compiled/chat_app.js');

View File

@ -1,19 +0,0 @@
{{#extends "_layout"}}
{{#override "pageTitle"}}{{l10n "Error"}}{{/override}}
{{#override "buttons"}}
<a href="javascript:window.close();" title="{{l10n 'Close...'}}">
<img class="tpl-image image-close-window" src="{{asset "@CurrentStyle/images/free.gif"}}" alt="{{l10n 'Close...'}}" />
</a>
{{/override}}
{{#override "message"}}<p>{{l10n "Your web browser is not fully supported. \nPlease, use one of the following web browsers:"}}</p>{{/override}}
{{#override "content"}}
<ul>
{{#each supportedBrowsers}}
<li>{{this}}</li>
{{/each}}
</ul>
{{/override}}
{{/extends}}