目錄 1.目標圖 2.項目簡介 3.目錄結構 4.建立MySQL表 5.實現過程 5.1 index.php 5.2 data.php 5.2 method.php 5.3 case.php 5.4 main.js 5.5 css/style.css 5.6 img\icon01.png 5.7 j ...
目錄
1.目標圖
2.項目簡介
這個聊天室本來是本人網站下的一個小功能,但是由於伺服器到期,於是把它分享出來供大家參考。
如果要完成這個項目您需要已配置好的PHP+MySQL環境,我使用的是本地搭建的內網伺服器,但建議使用已配置好的專業伺服器,這樣可能會更簡單。
要在本地配置伺服器可以參看下麵這篇文章:
3.目錄結構
請在您的伺服器根目錄下創建如下目錄結構:
/根目錄
/css
-style.css
/img
-icon01.png
/js
-jquery.min.js
/根目錄
-case.php
-data.php
-index.php
-main.js
-method.php
4.建立MySQL表
create table `chatnote` (
`cn_id` int (10),
`cn_name` varchar (150),
`cn_icon` varchar (765),
`cn_text` varchar (765),
`cn_time` varchar (72)
);
5.實現過程
5.1 index.php
這是聊天室的主頁面:
<?php
ini_set('session.cookie_httponly', 1);
session_start();
if (isset($_SESSION['cn_name'])) {
$size="none";
$_val=$_SESSION['cn_name'];
}else{
$size="block";
$_val="請設定昵稱";
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>彭_Yu-線上聊天室</title>
<link type="text/css" href="./css/style.css" rel="stylesheet" />
<script src="./js/jquery.min.js"></script>
<style>
body{
margin: 0px;
height: 100%;
background: #ccc;
background-attachment: fixed;
background-size:cover;
cursor: url(js/p1.ico),auto;
}
body,td,th {
font-family: "Helvetica Neue";
}
</style>
</head>
<body>
<div class="box">
<div class="box-title">
<h3>彭_Yu-線上聊天室</h3>
</div>
<div class="box-case">
<div class="case-box">
<div class="case-left">
<div class="case-msg">
<i class="horn"></i></div>
</div>
</div>
<div class="case-box">
<div class="case-right"> </div>
</div>
<div class="case-box">
<div class="case-right">
<div class="case-msg2">
<i class="horn2"></i></div>
</div>
</div>
</div>
<div class="box-inpu">
<textarea class="box-text" style= "resize:none" name="text"></textarea>
<div class="butt">
<button id="send">發送</button>
<button id="Nickname">設定昵稱</button>
</div>
</div>
<div class="box-tips" style="display:<?php echo $size;?>;">
<div class="tips-tit">
設置昵稱
</div>
<input class="ni" type="text" name="" value="<?php echo $_val;?>">
<button class="nide">保存昵稱</button>
</div>
</div>
<script type="text/javascript">
var upok = '設置成功';
var upps = '昵稱不能為空!';
</script>
Copyright©2021-2022 版權所有:彭_Yu
</script>
</canvas>
</body>
</html>
5.2 data.php
這是資料庫連接文件,資料庫信息需要改成你的資料庫信息:
<?php
$host= "localhost";//資料庫連接地址
$username = "root";//資料庫賬號
$password = "root123456";//資料庫密碼
$dbname = "pengxiazai";//資料庫名
try{
$conn = new PDO("mysql:host=$host;dbname=$dbname","$username","$password");
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$conn->exec('set names utf8');
}
catch(PDOException $e){
die("資料庫連接失敗".$e->getMessage());
}
5.2 method.php
這個文件用於向伺服器發送表單:
<?php
ini_set('session.cookie_httponly', 1);
session_start();
$Get_time = time();
if (isset($_POST['name'])&&isset($_POST['text'])&&isset($_POST['state'])) {
$_name = $_POST['name'];
$_text = $_POST['text'];
$_icon = 'img/icon01.png';
if ($_text!='') {
include "data.php";
$sql = "INSERT INTO chatnote (cn_name,cn_icon,cn_text,cn_time) VALUES ('".$_name."', '".$_icon."','".$_text."','".$Get_time."')";
$conn->exec($sql);
$conn = null;
echo 'ok';
}
}
if (isset($_POST['name'])&&isset($_POST['state'])) {
$_SESSION['cn_name'] = $_POST['name'];
echo 'ok';
}
5.3 case.php
這個文件用於操作資料庫:
<?php
ini_set('session.cookie_httponly', 1);
session_start();
include "data.php";
date_default_timezone_set('PRC');
$sql = "SELECT * FROM chatnote";
$stmt = $conn->prepare($sql);
$stmt->execute(array());
$_data = "";
$me = $_SESSION['cn_name'];
$i=0;
while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
if ($row['cn_name']==$me) {
$_data .= '
<div class="case-box">
<span class="case-time">'.date("Y-m-d H:i:s",$row['cn_time']).'</span>
<div class="case-right">
<img src="'.htmlentities($row['cn_icon']).'" />
<span class="case-name2">'.htmlentities($row['cn_name']).'</span>
<div class="case-msg2">
<i class="horn2"></i>
'.htmlentities($row['cn_text']).'
</div>
</div>
</div>';
}else{
$_data .= '
<div class="case-box">
<span class="case-time">'.date("Y-m-d H:i:s",$row['cn_time']).'</span>
<div class="case-left">
<img src="'.htmlentities($row['cn_icon']).'" />
<span class="case-name">'.htmlentities($row['cn_name']).'</span>
<div class="case-msg">
<i class="horn"></i>
'.htmlentities($row['cn_text']).'
</div>
</div>
</div>';
}
}
$_data .= '<div class="case-top"></div>';
echo $_data;
$conn = null;
5.4 main.js
頁面通用js文件:
查看代碼-由於代碼過長已摺疊
(function(){
var KasperskyLab = {SIGNATURE:"7D8B79A2-8974-4D7B-A76A-F4F29624C06BrybkdR7SHpQjkrd7RdE_eafXe2RFDchmt48e_sgv66w2sicuToIKurG7iojSolvzNHjHt5mSZXdL7gAobQnafg",PREFIX:"http://me.kis.v2.scr.kaspersky-labs.com/",INJECT_ID:"FD126C42-EBFA-4E12-B309-BB3FDD723AC1",RESOURCE_ID:"E3E8934C-235A-4B0E-825A-35A08381A191",IsWebExtension: function(){return false;}}; var KasperskyLab = (function (context) {
function GetClass(obj) {
if (typeof obj === "undefined")
return "undefined";
if (obj === null)
return "null";
return Object.prototype.toString.call(obj)
.match(/^\[object\s(.*)\]$/)[1];
}
var exports = {}, undef;
function ObjectToJson(object) {
if (object === null || object == Infinity || object == -Infinity || object === undef)
return "null";
var className = GetClass(object);
if (className == "Boolean") {
return "" + object;
} else if (className == "Number") {
return window.isNaN(object) ? "null" : "" + object;
} else if (className == "String") {
var escapedStr = "" + object;
return "\"" + escapedStr.replace(/\\/g, "\\\\").replace(/\"/g, "\\\"") + "\"";
}
if (typeof object == "object") {
if (!ObjectToJson.check) ObjectToJson.check = [];
for (var i=0, chkLen=ObjectToJson.check.length ; i<chkLen ; ++i) {
if (ObjectToJson.check[i] === object) {
throw new TypeError();
}
}
ObjectToJson.check.push(object);
var str = '';
if (className == "Array" || className == "Array Iterator") {
for (var index = 0, length = object.length; index < length; ++index) {
str += ObjectToJson(object[index]) + ',';
}
ObjectToJson.check.pop();
return "["+str.slice(0,-1)+"]";
} else {
for (var property in object) {
if (object.hasOwnProperty(property)) {
str += '"' + property + '":' + ObjectToJson(object[property]) + ',';
}
}
ObjectToJson.check.pop();
return "{"+str.slice(0,-1)+"}";
}
}
return undef;
}
exports.stringify = function (source) {
return ObjectToJson(source);
};
var parser = {
source : null,
grammar : /^[\x20\t\n\r]*(?:([,:\[\]{}]|true|false|null)|(-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)|"((?:[^\r\n\t\\\"]|\\(?:["\\\/trnfb]|u[0-9a-fA-F]{4}))*)")/,
ThrowError : function() {
throw new SyntaxError('JSON syntax error');
},
NextToken : function(token) {
this.source = token.input.slice(token[0].length);
return this.grammar.exec(this.source);
},
ParseArray : function(){
var token = this.grammar.exec(this.source),
parseItem = token && token[1] != ']',
result = [];
for(;;token = this.NextToken(token)) {
if (!token)
this.ThrowError();
if (parseItem) {
result.push(this.ParseValue(token));
token = this.grammar.exec(this.source);
} else {
if (token[1]) {
if (token[1] == ']') {
break;
} else if (token[1] != ',') {
this.ThrowError();
}
} else {
this.ThrowError();
}
}
parseItem = !parseItem;
}
return result;
},
ParseObject : function(){
var propertyName, parseProperty = true, result = {};
for(var token = this.grammar.exec(this.source);;token = this.NextToken(token)) {
if (!token)
this.ThrowError();
if (parseProperty) {
if (token[1] && token[1] == '}') {
break;
} else if (token[1] || token[2] || !token[3]) {
this.ThrowError();
}
propertyName = token[3];
token = this.NextToken(token);
if (!token || !token[1] || token[1] != ':')
this.ThrowError();
parseProperty = false;
} else {
if (!propertyName)
this.ThrowError();
result[ propertyName ] = this.ParseValue(token);
token = this.NextToken(this.grammar.exec(this.source));
if (token[1]) {
if (token[1] == '}') {
break;
} else if (token[1] != ',') {
this.ThrowError();
}
} else {
this.ThrowError();
}
propertyName = undef;
parseProperty = true;
}
}
return result;
},
ParseValue : function(token){
if (token[1]) {
switch (token[1]){
case '[' :
this.source = this.source.slice(token[0].length);
return this.ParseArray();
case '{' :
this.source = this.source.slice(token[0].length);
return this.ParseObject();
case 'true' :
return true;
case 'false' :
return false;
case 'null' :
return null;
default:
this.ThrowError();
}
} else if (token[2]) {
return +token[2];
}
return token[3].replace(/\\(?:u(.{4})|(["\\\/'bfnrt]))/g, function(substr, utfCode, esc){
if(utfCode)
{
return String.fromCharCode(parseInt(utfCode, 16));
}
else
{
switch(esc) {
case 'b': return '\b';
case 'f': return '\f';
case 'n': return '\n';
case 'r': return '\r';
case 't': return '\t';
default:
return esc;
}
}
});
},
Parse : function(str) {
if ('String' != GetClass(str))
throw new TypeError();
this.source = str;
var token = this.grammar.exec(this.source);
if (!token)
this.ThrowError();
return this.ParseValue(token);
}
};
exports.parse = function (source) {
return parser.Parse(source);
};
context['JSONStringify'] = exports.stringify;
context['JSONParse'] = exports.parse;
return context;
}).call(this, KasperskyLab || {});
var KasperskyLab = (function ( ns) {
ns.FunctionBind = Function.prototype.bind;
ns.MaxRequestDelay = 2000;
ns.Log = function(message)
{
try
{
if (!message)
return;
if (window.plugin && window.plugin.log)
window.plugin.log(message);
}
catch(e)
{}
};
ns.SessionLog = function()
{};
ns.SessionError = function()
{};
ns.GetDomainName = function()
{
return document.location.hostname;
}
function GetHostAndPort(url)
{
var hostBeginPos = url.indexOf('//');
if (hostBeginPos == -1)
{
url = document.baseURI || '';
hostBeginPos = url.indexOf('//');
if (hostBeginPos == -1)
return '';
}
hostBeginPos += 2;
var hostEndPos = url.indexOf('/', hostBeginPos);
if (hostEndPos == -1)
hostEndPos = url.length;
var originParts = url.substring(0, hostEndPos).split('@');
var origin = originParts.length > 1 ? originParts[1] : originParts[0];
return origin[0] === "/" ? document.location.protocol + origin : origin;
}
ns.IsCorsRequest = function(url, initiator)
{
url = typeof(url) != 'string' ? url.toString() : url;
var urlOrigin = GetHostAndPort(url);
var initiatorOrigin = GetHostAndPort(initiator);
return !!urlOrigin && !!initiatorOrigin && urlOrigin != initiatorOrigin;
}
var originalWindowOpen = window.open;
ns.WindowOpen = function(url)
{
if (typeof(originalWindowOpen) === "function")
originalWindowOpen.call(window, url);
else
originalWindowOpen(url);
}
ns.EncodeURI = encodeURI;
ns.GetResourceSrc = function(resourceName)
{
return ns.GetBaseUrl() + ns.RESOURCE_ID + resourceName;
};
ns.IsRelativeTransport = function()
{
return ns.PREFIX == "/";
}
ns.GetBaseUrl = function()
{
if (!ns.IsRelativeTransport())
return ns.PREFIX;
return document.location.protocol + "//" + document.location.host + "/";
};
ns.AddEventListener = function(element, name, func)
{
if ("addEventListener" in element)
element.addEventListener(name,
function(e)
{
try
{
func(e || window.event);
}
catch (e)
{
ns.SessionError(e);
}
}, true);
else
element.attachEvent("on" + name,
function(e)
{
try
{
func.call(element, e || window.event);
}
catch (e)
{
ns.SessionError(e);
}
});
};
ns.AddRemovableEventListener = function ( element, name, func) {
if (element.addEventListener)
element.addEventListener(name, func, true);
else
element.attachEvent('on' + name, func);
};
ns.RunModule = function(func, timeout)
{
if (document.readyState === "loading")
{
if (timeout)
ns.SetTimeout(func, timeout);
if (document.addEventListener)
ns.AddEventListener(document, "DOMContentLoaded", func);
ns.AddEventListener(document, "load", func);
}
else
{
try
{
func();
}
catch (e)
{
ns.SessionError(e);
}
}
};
ns.RemoveEventListener = function ( element, name, func) {
if (element.removeEventListener)
element.removeEventListener(name, func, true);
else
element.detachEvent('on' + name, func);
};
ns.SetTimeout = function(func, timeout)
{
return setTimeout(
function()
{
try
{
func();
}
catch (e)
{
ns.SessionError(e);
}
}, timeout);
}
ns.SetInterval = function(func, interval)
{
return setInterval(
function()
{
try
{
func();
}
catch (e)
{
ns.SessionError(e);
}
}, interval);
}
function InsertStyleRule( style, rule) {
if (style.styleSheet)
{
style.styleSheet.cssText += rule + '\n';
}
else
{
style.appendChild(document.createTextNode(rule));
ns.SetTimeout(
function()
{
if (!style.sheet)
return;
var rules = style.sheet.cssRules || style.sheet.rules;
if (rules && rules.length === 0)
style.sheet.insertRule(rule);
}, 500);
}
}
ns.AddStyles = function (rules)
{
return ns.AddDocumentStyles(document, rules);
}
ns.AddDocumentStyles = function(document, rules)
{
if (typeof rules !== 'object' || rules.constructor !== Array) {
return;
}
var styles = [];
for (var i = 0, len = rules.length; i < len; )
{
var style = document.createElement('style');
style.type = 'text/css';
style.setAttribute('nonce', ns.ContentSecurityPolicyNonceAttribute);
for (var n = 0; n < 4 && i < len; ++n, ++i)
{
var rule = rules[i];
if (document.querySelectorAll)
{
InsertStyleRule(style, rule);
}
else
{
var styleBegin = rule.lastIndexOf('{');
if (styleBegin == -1)
continue;
var styleText = rule.substr(styleBegin);
var selectors = rule.substr(0, styleBegin).split(',');
if (style.styleSheet)
{
var cssText = '';
for (var j = 0; j != selectors.length; ++j)
cssText += selectors[j] + styleText + '\n';
style.styleSheet.cssText += cssText;
}
else
{
for (var j = 0; j != selectors.length; ++j)
style.appendChild(document.createTextNode(selectors[j] + styleText));
}
}
}
if (document.head)
document.head.appendChild(style);
else
document.getElementsByTagName('head')[0].appendChild(style);
styles.push(style);
}
return styles;
};
ns.AddCssLink = function(document, href, loadCallback, errorCallback)
{
var link = document.createElement("link");
link.type = "text/css";
link.rel = "stylesheet";
link.href = href;
if (loadCallback)
{
ns.AddEventListener(link, "load", function()
{
try
{
link && link.sheet && link.sheet.cssText;
loadCallback();
}
catch(e)
{
if (errorCallback)
errorCallback();
}
});
}
if (errorCallback)
{
ns.AddEventListener(link, "error",
function()
{
errorCallback();
ns.SessionError("failed load resource: " + href);
});
}
if (document.head)
document.head.appendChild(link);
else
document.getElementsByTagName("head")[0].appendChild(link);
}
ns.GetCurrentTime = function () {
return new Date().getTime();
};
ns.GetPageScroll = function()
{
return {
left: (document.documentElement && document.documentElement.scrollLeft) || document.body.scrollLeft,
top: (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop
};
};
ns.GetPageHeight = function()
{
return document.documentElement.clientHeight || document.body.clientHeight;
};
ns.GetPageWidth = function()
{
return document.documentElement.clientWidth || document.body.clientWidth;
};
ns.IsDefined = function (variable)
{
return "undefined" !== typeof(variable);
};
ns.StopProcessingEvent = function(evt)
{
if (evt.preventDefault)
evt.preventDefault();
else
evt.returnValue = false;
if (evt.stopPropagation)
evt.stopPropagation();
if (ns.IsDefined(evt.cancelBubble))
evt.cancelBubble = true;
}
ns.AddIframeDoctype = function(element)
{
var frameDocument = element.contentDocument || element.contentWindow.document;
if (document.implementation && document.implementation.createDocumentType)
{
var newDoctype = document.implementation.createDocumentType('html', '', '');
if (frameDocument.childNodes.length)
frameDocument.insertBefore(newDoctype, frameDocument.childNodes[0]);
else
frameDocument.appendChild(newDoctype);
}
else
{
frameDocument.write("<!DOCTYPE html>");
frameDocument.close();
}
}
function IsElementNode(node)
{
return node.nodeType === 1;
}
function IsNodeContainsElementWithTag(node, observeTag)
{
return observeTag == "*" || (IsElementNode(node) && (node.tagName.toLowerCase() === observeTag || node.getElementsByTagName(observeTag).length > 0));
}
function MutationChangeObserver(observeTag)
{
var m_observer;
var m_callback;
var m_functionCheckInteresting = observeTag ? function(node){return IsNodeContainsElementWithTag(node, observeTag);} : IsElementNode;
function ProcessNodeList(nodeList)
{
for (var i = 0; i < nodeList.length; ++i)
{
if (m_functionCheckInteresting(nodeList[i]))
return true;
}
return false;
}
function ProcessDomChange(records)
{
if (!m_callback)
return;
for (var i = 0; i < records.length; ++i)
{
var record = records[i];
if ((record.addedNodes.length && ProcessNodeList(record.addedNodes)) ||
(record.removedNodes.length && ProcessNodeList(record.removedNodes)))
{
m_callback();
return;
}
}
}
this.Start = function(callback)
{
m_callback = callback;
m_observer = new MutationObserver(ProcessDomChange);
m_observer.observe(document, { childList: true, subtree: true });
};
this.Stop = function()
{
m_observer.disconnect();
m_callback = null;
};
}
function DomEventsChangeObserver(observeTag)
{
var m_callback;
var m_functionCheckInteresting = observeTag ? function(node){return IsNodeContainsElementWithTag(node, observeTag);} : IsElementNode;
function ProcessEvent(event)
{
if (!m_callback)
return;
if (m_functionCheckInteresting(event.target))
m_callback();
}
this.Start = function(callback)
{
ns.AddRemovableEventListener(window, "DOMNodeInserted", ProcessEvent);
ns.AddRemovableEventListener(window, "DOMNodeRemoved", ProcessEvent);
m_callback = callback;
}
this.Stop = function()
{
ns.RemoveEventListener(window, "DOMNodeInserted", ProcessEvent);
ns.RemoveEventListener(window, "DOMNodeRemoved", ProcessEvent);
m_callback = null;
}
}
function TimeoutChangeObserver(observeTag)
{
var m_interval;
var m_callback;
var m_tagCount;
var m_attribute = 'klot_' + ns.GetCurrentTime();
function IsChangesOccure(nodeList)
{
for (var i = 0; i < nodeList.length; ++i)
if (!nodeList[i][m_attribute])
return true;
return false;
}
function FillTagInfo(nodeList)
{
m_tagCount = nodeList.length;
for (var i = 0; i < m_tagCount; ++i)
nodeList[i][m_attribute] = true;
}
function TimeoutProcess()
{
if (!m_callback)
return;
var nodeList = observeTag ? document.getElementsByTagName(observeTag) : document.getElementsByTagName("*");
if (nodeList.length !== m_tagCount || IsChangesOccure(nodeList))
{
FillTagInfo(nodeList);
m_callback();
}
}
this.Start = function(callback)
{
m_callback = callback;
FillTagInfo(document.getElementsByTagName(observeTag));
m_interval = ns.SetInterval(TimeoutProcess, 10 * 1000);
if (document.readyState !== "complete")
ns.AddEventListener(window, "load", TimeoutProcess);
}
this.Stop = function()
{
clearInterval(m_interval);
m_callback = null;
}
}
ns.GetDomChangeObserver = function(observeTag)
{
var observeTagLowerCase = observeTag ? observeTag.toLowerCase() : observeTag;
if (window.MutationObserver && document.documentMode !== 11)
return new MutationChangeObserver(observeTagLowerCase);
if (window.addEventListener)
return new DomEventsChangeObserver(observeTagLowerCase);
return new TimeoutChangeObserver(observeTagLowerCase);
}
ns.StartLocationHref = document.location.href;
return ns;
}) (KasperskyLab || {});
(function (ns) {
function md5cycle(x, k) {
var a = x[0],
b = x[1],
c = x[2],
d = x[3];
a = ff(a, b, c, d, k[0], 7, -680876936);
d = ff(d, a, b, c, k[1], 12, -389564586);
c = ff(c, d, a, b, k[2], 17, 606105819);
b = ff(b, c, d, a, k[3], 22, -1044525330);
a = ff(a, b, c, d, k[4], 7, -176418897);
d = ff(d, a, b, c, k[5], 12, 1200080426);
c = ff(c, d, a, b, k[6], 17, -1473231341);
b = ff(b, c, d, a, k[7], 22, -45705983);
a = ff(a, b, c, d, k[8], 7, 1770035416);
d = ff(d, a, b, c, k[9], 12, -1958414417);
c = ff(c, d, a, b, k[10], 17, -42063);
b = ff(b, c, d, a, k[11], 22, -1990404162);
a = ff(a, b, c, d, k[12], 7, 1804603682);
d = ff(d, a, b, c, k[13], 12, -40341101);
c = ff(c, d, a, b, k[14], 17, -1502002290);
b = ff(b, c, d, a, k[15], 22, 1236535329);
a = gg(a, b, c, d, k[1], 5, -165796510);
d = gg(d, a, b, c, k[6], 9, -1069501632);
c = gg(c, d, a, b, k[11], 14, 643717713);
b = gg(b, c, d, a, k[0], 20, -373897302);
a = gg(a, b, c, d, k[5], 5, -701558691);
d = gg(d, a, b, c, k[10], 9, 38016083);
c = gg(c, d, a, b, k[15], 14, -660478335);
b = gg(b, c, d, a, k[4], 20, -405537848);
a = gg(a, b, c, d, k[9], 5, 568446438);
d = gg(d, a, b, c, k[14], 9, -1019803690);
c = gg(c, d, a, b, k[3], 14, -187363961);
b = gg(b, c, d, a, k[8], 20, 1163531501);
a = gg(a, b, c, d, k[13], 5, -1444681467);
d = gg(d, a, b, c, k[2], 9, -51403784);
c = gg(c, d, a, b, k[7], 14, 1735328473);
b = gg(b, c, d, a, k[12], 20, -1926607734);
a = hh(a, b, c, d, k[5], 4, -378558);
d = hh(d, a, b, c, k[8], 11, -2022574463);
c = hh(c, d, a, b, k[11], 16, 1839030562);
b = hh(b, c, d, a, k[14], 23, -35309556);
a = hh(a, b, c, d, k[1], 4, -1530992060);
d = hh(d, a, b, c, k[4], 11, 1272893353);
c = hh(c, d, a, b, k[7], 16, -155497632);
b = hh(b, c, d, a, k[10], 23, -1094730640);
a = hh(a, b, c, d, k[13], 4, 681279174);
d = hh(d, a, b, c, k[0], 11, -358537222);
c = hh(c, d, a, b, k[3], 16, -722521979);
b = hh(b, c, d, a, k[6], 23, 76029189);
a = hh(a, b, c, d, k[9], 4, -640364487);
d = hh(d, a, b, c, k[12], 11, -421815835);
c = hh(c, d, a, b, k[15], 16, 530742520);
b = hh(b, c, d, a, k[2], 23, -995338651);
a = ii(a, b, c, d, k[0], 6, -198630844);
d = ii(d, a, b, c, k[7], 10, 1126891415);
c = ii(c, d, a, b, k[14], 15, -1416354905);
b = ii(b, c, d, a, k[5], 21, -57434055);
a = ii(a, b, c, d, k[12], 6, 1700485571);
d = ii(d, a, b, c, k[3], 10, -1894986606);
c = ii(c, d, a, b, k[10], 15, -1051523);
b = ii(b, c, d, a, k[1], 21, -2054922799);
a = ii(a, b, c, d, k[8], 6, 1873313359);
d = ii(d, a, b, c, k[15], 10, -30611744);
c = ii(c, d, a, b, k[6], 15, -1560198380);
b = ii(b, c, d, a, k[13], 21, 1309151649);
a = ii(a, b, c, d, k[4], 6, -145523070);
d = ii(d, a, b, c, k[11], 10, -1120210379);
c = ii(c, d, a, b, k[2], 15, 718787259);
b = ii(b, c, d, a, k[9], 21, -343485551);
x[0] = add32(a, x[0]);
x[1] = add32(b, x[1]);
x[2] = add32(c, x[2]);
x[3] = add32(d, x[3]);
}
function cmn(q, a, b, x, s, t) {
a = add32(add32(a, q), add32(x, t));
return add32((a << s) | (a >>> (32 - s)), b);
}
function ff(a, b, c, d, x, s, t) {
return cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function gg(a, b, c, d, x, s, t) {
return cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function hh(a, b, c, d, x, s, t) {
return cmn(b^c^d, a, b, x, s, t);
}
function ii(a, b, c, d, x, s, t) {
return cmn(c^(b | (~d)), a, b, x, s, t);
}
function md51(s) {
var n = s.length,
state = [1732584193, -271733879, -1732584194, 271733878],
i;
for (i = 64; i <= s.length; i += 64) {
md5cycle(state, md5blk(s.substring(i - 64, i)));
}
s = s.substring(i - 64);
var tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
for (i = 0; i < s.length; i++)
tail[i >> 2] |= s.charCodeAt(i) << ((i % 4) << 3);
tail[i >> 2] |= 0x80 << ((i % 4) << 3);
if (i > 55) {
md5cycle(state, tail);
for (i = 0; i < 16; i++)
tail[i] = 0;
}
tail[14] = n * 8;
md5cycle(state, tail);
return state;
}
function md5blk(s) {
var md5blks = [],
i;
for (i = 0; i < 64; i += 4) {
md5blks[i >> 2] = s.charCodeAt(i) +
(s.charCodeAt(i + 1) << 8) +
(s.charCodeAt(i + 2) << 16) +
(s.charCodeAt(i + 3) << 24);
}
return md5blks;
}
var hex_chr = '0123456789abcdef'.split('');
function rhex(n) {
var s = '',
j = 0;
for (; j < 4; j++)
s += hex_chr[(n >> (j * 8 + 4)) & 0x0F]+hex_chr[(n >> (j * 8)) & 0x0F];
return s;
}
function hex(x) {
for (var i = 0; i < x.length; i++)
x[i] = rhex(x[i]);
return x.join('');
}
ns.md5 = function (s) {
return hex(md51(s));
};
function add32(a, b) {
return (a + b) & 0xFFFFFFFF;
}
if (ns.md5('hello') != '5d41402abc4b2a76b9719d911017c592') {
add32 = function(x, y) {
var lsw = (x & 0xFFFF) + (y & 0xFFFF),
msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
}
})(KasperskyLab || {});
var KasperskyLab = (function ( ns) {
ns.NMSTransportSupported = false;
return ns;
}) (KasperskyLab || {});
var KasperskyLab = (function (ns)
{
ns.AjaxTransportSupported = true;
var ajaxRequestProvider = (function ()
{
var oldOpen = window.XMLHttpRequest && window.XMLHttpRequest.prototype.open;
var oldSend = window.XMLHttpRequest && window.XMLHttpRequest.prototype.send;
var oldXHR = window.XMLHttpRequest;
var oldXDR = window.XDomainRequest;
return {
GetAsyncRequest: function ()
{
var xmlhttp = oldXDR ? new oldXDR() : new oldXHR();
if (!oldXDR) {
xmlhttp.open = oldOpen;
xmlhttp.send = oldSend;
}
xmlhttp.onprogress = function(){};
return xmlhttp;
},
GetSyncRequest: function ()
{
var xmlhttp = new oldXHR();
xmlhttp.open = oldOpen;
xmlhttp.send = oldSend;
xmlhttp.onprogress = function(){};
return xmlhttp;
}
};
})();
var restoreSessionCallback = function(){};
var PingPongCallReceiver = function(caller)
{
var m_caller = caller;
var m_isProductConnected = false;
var m_pingWaitResponse = false;
var m_requestDelay = ns.MaxRequestDelay;
var m_requestTimer = null;
var m_callCallback = function(){};
var m_errorCallback = function(){};
var m_updateCallback = function(){};
function SendRequest()
{
try
{
m_caller.Call(
"from",
null,
null,
true,
function(result, parameters, method)
{
m_pingWaitResponse = false;
m_isProductConnected = true;
if (parameters === "undefined" || method === "undefined")
{
m_errorCallback('AJAX pong is not received. Product is deactivated');
return;
}
if (method)
{
ns.SetTimeout(function () { SendRequest(); }, 0);
m_callCallback(method, parameters);
}
},
function(error)
{
m_pingWaitResponse = false;
m_isProductConnected = false;
restoreSessionCallback();
m_errorCallback(error);
});
m_pingWaitResponse = true;
}
catch (e)
{
m_errorCallback('Ajax send ping exception: ' + (e.message || e));
}
}
function Ping()
{
try
{
if (m_pingWaitResponse)
{
m_requestTimer = ns.SetTimeout(Ping, 100);
return;
}
m_requestDelay = m_updateCallback();
SendRequest();
m_requestTimer = ns.SetTimeout(Ping, m_requestDelay);
}
catch (e)
{
m_errorCallback('Send ping request: ' + (e.message || e));
}
}
this.StartReceive = function(callCallback, errorCallback, updateCallback)
{
m_isProductConnected = true;
m_callCallback = callCallback;
m_errorCallback = errorCallback;
m_updateCallback = updateCallback;
m_requestDelay = m_updateCallback();
m_requestTimer = ns.SetTimeout(Ping, m_requestDelay);
};
this.ForceReceive = function()
{
clearTimeout(m_requestTimer);
m_requestTimer = ns.SetTimeout(Ping, 0);
}
this.StopReceive = function()
{
clearTimeout(m_requestTimer);
m_requestTimer = null;
m_callCallback = function(){};
m_errorCallback = function(){};
m_updateCallback = function(){};
};
this.IsStarted = function()
{
return m_requestTimer !== null;
}
this.IsProductConnected = function()
{
return m_isProductConnected;
};
};
var LongPoolingReceiver = function(caller)
{
var m_caller = caller;
var m_isProductConnected = false;
var m_isStarted = false;
var m_callCallback = function(){};
var m_errorCallback = function(){};
function SendRequest()
{
try
{
m_isProductConnected = true;
m_caller.Call(
"longpooling",
null,
null,
true,
OnResponse,
function(error)
{
m_isProductConnected = false;
restoreSessionCallback();
m_errorCallback(error);
},
true);
}
catch (e)
{
ns.SessionError(e, "ajax");
m_errorCallback("Ajax send ping exception: " + (e.message || e));
}
}
function OnResponse(result, parameters, method)
{
if (!ns.IsDefined(parameters) || !ns.IsDefined(method))
{
m_errorCallback('AJAX pong is not received. Product is deactivated');
return;
}
ns.SetTimeout(function () { SendRequest(); }, 0);
if (method)
m_callCallback(method, parameters);
}
this.StartReceive = function(callCallback, errorCallback)
{
m_isStarted = true;
m_callCallback = callCallback;
m_errorCallback = errorCallback;
SendRequest();
};
this.ForceReceive = function(){}
this.StopReceive = function()
{
m_isStarted = false;
m_callCallback = function(){};
m_errorCallback = function(){};
};
this.IsStarted = function()
{
return m_isStarted;
}
this.IsProductConnected = function()
{
return m_isProductConnected;
};
};
ns.AjaxCaller = function()
{
var m_path = ns.GetBaseUrl() + ns.SIGNATURE;
var m_longPooling;
var m_longPoolingRequest;
function NoCacheParameter()
{
return "&nocache=" + Math.floor((1 + Math.random()) * 0x10000).toString(16);
}
function GetEncodedPluginsParameter(injectors)
{
return (injectors) ? "&plugins=" + encodeURIComponent(injectors) : "";
}
function PrepareRequestObject(command, commandAttribute, isPost, isAsync)
{
var request = isAsync ? ajaxRequestProvider.GetAsyncRequest() : ajaxRequestProvider.GetSyncRequest();
if (request)
{
var urlPath = m_path + "/" + command;
if (commandAttribute)
urlPath += "/" + commandAttribute;
if (isPost)
{
request.open("POST", urlPath);
}
else