Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
bg-az-counter
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
azbyka_bg
bg-az-counter
Commits
65d5e99f
Commit
65d5e99f
authored
Apr 16, 2019
by
Vadim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Version 2.5.1
Запрет
wss://stat.azbyka.ru/updates
при пустом path (отсутствие счетчиков на странице).
parent
286844ec
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
45 deletions
+49
-45
bg_az-counter.php
bg_az-counter.php
+2
-2
counter.js
js/counter.js
+47
-43
No files found.
bg_az-counter.php
View file @
65d5e99f
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
Plugin Name: Bg Az-Counter
Plugin Name: Bg Az-Counter
Plugin URI: https://bogaiskov.ru
Plugin URI: https://bogaiskov.ru
Description: Подсчет количества посещений страниц на базе stat.azbyka.ru
Description: Подсчет количества посещений страниц на базе stat.azbyka.ru
Version: 2.5
Version: 2.5
.1
Author: VBog
Author: VBog
Author URI: https://bogaiskov.ru
Author URI: https://bogaiskov.ru
License: GPL2
License: GPL2
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
if
(
!
defined
(
'ABSPATH'
)
)
{
if
(
!
defined
(
'ABSPATH'
)
)
{
die
(
'Sorry, you are not allowed to access this page directly.'
);
die
(
'Sorry, you are not allowed to access this page directly.'
);
}
}
define
(
'BG_COUNTER_VERSION'
,
'2.
4.33
'
);
define
(
'BG_COUNTER_VERSION'
,
'2.
5.1
'
);
define
(
'BG_COUNTER_LOG'
,
dirname
(
__FILE__
)
.
'/bg_counter.log'
);
define
(
'BG_COUNTER_LOG'
,
dirname
(
__FILE__
)
.
'/bg_counter.log'
);
define
(
'BG_COUNTER_STAT_COUNTERS'
,
'https://stat.azbyka.ru/counters'
);
define
(
'BG_COUNTER_STAT_COUNTERS'
,
'https://stat.azbyka.ru/counters'
);
...
...
js/counter.js
View file @
65d5e99f
...
@@ -62,53 +62,57 @@ jQuery( document ).ready(function() {
...
@@ -62,53 +62,57 @@ jQuery( document ).ready(function() {
data
[
i
]
=
path
;
data
[
i
]
=
path
;
i
++
;
i
++
;
});
});
var
json
=
JSON
.
stringify
(
data
);
if
(
data
.
length
)
{
var
request
=
bg_counter
.
updatesocket
+
(
bg_counter
.
updatetime
?(
'?time='
+
bg_counter
.
updatetime
):
''
);
var
json
=
JSON
.
stringify
(
data
);
// Создаем сокет
var
request
=
bg_counter
.
updatesocket
+
(
bg_counter
.
updatetime
?(
'?time='
+
bg_counter
.
updatetime
):
''
);
var
updatesocket
=
new
ReconnectingWebSocket
(
request
);
// Создаем сокет
// Отправляем данные, как только сокет будет подключен
var
updatesocket
=
new
ReconnectingWebSocket
(
request
);
updatesocket
.
onopen
=
function
()
{
// Отправляем данные, как только сокет будет подключен
if
(
bg_counter
.
debug
)
console
.
log
(
" Соединение установлено: "
+
request
);
updatesocket
.
onopen
=
function
()
{
updatesocket
.
send
(
json
);
if
(
bg_counter
.
debug
)
{
};
console
.
log
(
" Соединение установлено: "
+
request
);
// Слушаем сокет
console
.
log
(
" Path ("
+
i
+
"): "
+
json
);
updatesocket
.
onmessage
=
function
(
e
)
{
if
(
bg_counter
.
debug
)
console
.
log
(
" Пришло сообщение: "
+
e
.
data
);
var
online
=
JSON
.
parse
(
e
.
data
);
jQuery
(
'span.bg-az-counter'
).
each
(
function
()
{
var
el
=
jQuery
(
this
);
var
type
=
el
.
attr
(
'data-type'
);
var
id
=
el
.
attr
(
'data-ID'
);
var
project
=
el
.
attr
(
'data-project'
);
if
(
project
==
""
)
path
=
"/"
;
else
{
if
(
project
==
undefined
)
project
=
bg_counter
.
project
;
else
project
=
'/project/'
+
project
;
if
(
!
type
||
!
id
)
var
path
=
project
;
else
var
path
=
project
+
"/"
+
type
+
"/"
+
id
;
}
}
for
(
var
key
in
online
)
{
updatesocket
.
send
(
json
);
if
(
path
==
key
)
{
el
.
find
(
'span.bg-az-counter-now'
).
text
(
addDelimiter
(
online
[
key
]));
}
}
});
};
// Обработка ошибок
if
(
bg_counter
.
debug
)
{
updatesocket
.
onerror
=
function
(
error
)
{
console
.
log
(
"Ошибка "
+
error
.
message
);
};
};
updatesocket
.
onclose
=
function
(
event
)
{
// Слушаем сокет
if
(
event
.
wasClean
)
{
updatesocket
.
onmessage
=
function
(
e
)
{
console
.
log
(
'Соединение закрыто чисто: '
+
request
);
if
(
bg_counter
.
debug
)
console
.
log
(
" Пришло сообщение: "
+
e
.
data
);
}
else
{
var
online
=
JSON
.
parse
(
e
.
data
);
console
.
log
(
'Обрыв соединения: '
+
request
);
jQuery
(
'span.bg-az-counter'
).
each
(
function
()
{
}
var
el
=
jQuery
(
this
);
console
.
log
(
'Код: '
+
event
.
code
+
' причина: '
+
event
.
reason
);
var
type
=
el
.
attr
(
'data-type'
);
var
id
=
el
.
attr
(
'data-ID'
);
var
project
=
el
.
attr
(
'data-project'
);
if
(
project
==
""
)
path
=
"/"
;
else
{
if
(
project
==
undefined
)
project
=
bg_counter
.
project
;
else
project
=
'/project/'
+
project
;
if
(
!
type
||
!
id
)
var
path
=
project
;
else
var
path
=
project
+
"/"
+
type
+
"/"
+
id
;
}
for
(
var
key
in
online
)
{
if
(
path
==
key
)
{
el
.
find
(
'span.bg-az-counter-now'
).
text
(
addDelimiter
(
online
[
key
]));
}
}
});
};
};
// Обработка ошибок
if
(
bg_counter
.
debug
)
{
updatesocket
.
onerror
=
function
(
error
)
{
console
.
log
(
"Ошибка "
+
error
.
message
);
};
updatesocket
.
onclose
=
function
(
event
)
{
if
(
event
.
wasClean
)
{
console
.
log
(
'Соединение закрыто чисто: '
+
request
);
}
else
{
console
.
log
(
'Обрыв соединения: '
+
request
);
}
console
.
log
(
'Код: '
+
event
.
code
+
' причина: '
+
event
.
reason
);
};
}
}
}
});
});
/*********************************************************************************
/*********************************************************************************
POST /counters/<path>
POST /counters/<path>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment