-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathanalytics.php
160 lines (145 loc) · 5.14 KB
/
analytics.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
/****************************************************************************************
* LiveZilla analytics.php
*
* Copyright 2018 LiveZilla GmbH
* All rights reserved.
* LiveZilla is a registered trademark.
*
* Improper changes to this file may cause critical errors.
***************************************************************************************/
define("IN_LIVEZILLA",true);
if(!defined("LIVEZILLA_PATH"))
define("LIVEZILLA_PATH","./");
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Access-Control-Allow-Origin: *");
require(LIVEZILLA_PATH . "_definitions/definitions.inc.php");
require(LIVEZILLA_PATH . "_lib/functions.global.inc.php");
require(LIVEZILLA_PATH . "_lib/objects.countries.inc.php");
require(LIVEZILLA_PATH . "_lib/objects.languages.inc.php");
require(LIVEZILLA_PATH . "_lib/objects.stats.inc.php");
require(LIVEZILLA_PATH . "_definitions/definitions.dynamic.inc.php");
require(LIVEZILLA_PATH . "_definitions/definitions.protocol.inc.php");
require(LIVEZILLA_PATH . "_lib/objects.analytics.inc.php");
if(isset($_POST["request"])){
if(isset($_POST["unit"])){
$P_UNIT = intval($_POST["unit"]);
$P_FROM = array(
"year" => intval($_POST["year"]),
"month" => intval($_POST["month"]),
"day" => intval($_POST["day"])
);
$P_TO = array(
"year" => intval($_POST["toyear"]),
"month" => intval($_POST["tomonth"]),
"day" => intval($_POST["today"])
);
ADI::SetPostData($P_UNIT, $P_FROM, $P_TO);
}
$knownRequests = array(
'preInit' => function(){
return ADI::GetPreInitData();
},
'overview' => function(){
return ADI::GetOverview();
},
'chats' => function(){
return ADI::GetChats();
},
'chatNumbers' => function(){
return ADI::GetChatNumbers();
},
'chatsBar' => function(){
return ADI::GetChatsBar();
},
'chatTags' => function(){
return ADI::GetTags(0);
},
'tickets' => function(){
return ADI::GetTickets();
},
'ticketNumbers' => function(){
return ADI::GetTicketNumbers();
},
'ticketsBar' => function(){
return ADI::GetTicketsBar();
},
'ticketTags' => function(){
return ADI::GetTags(1);
},
'availability' => function(){
return ADI::GetAvailabilitiesBar();
},
'visitors' => function(){
return ADI::GetVisitors();
},
'visitorNumbers' => function(){
return ADI::GetVisitorNumbers();
},
'TOPsVisitors' => function(){
return ADI::GetTOPsVisitors();
},
'TOPsPages' => function(){
return ADI::GetTOPsPages();
},
'TOPsKnowledgeBase' => function(){
return ADI::GetTOPsKnowledgeBase();
},
'goalsDayNumbers' => function(){
return ADI::GetGoalsDayNumbers();
},
'events' => function(){
return ADI::GetGoalStats();
},
'eventsBar' => function(){
return ADI::GetEventsBar();
},
'goalsBar' => function(){
return ADI::GetGoalsBar();
},
'feedbacksDayNumbers' => function(){
return ADI::GetFeedbacksDayNumbers();
},
'feedbacks' => function(){
return ADI::GetFeedbacks();
},
'feedbacksBar' => function(){
return ADI::GetFeedbacksBar();
}
);
if(!isset($knownRequests[$_POST["request"]]))
{
exit('error unknown request');
}
else
{
$res = $knownRequests[$_POST["request"]]();
exit(json_encode($res));
}
}
if(isset($_GET["token"]) && isset($_GET["from"]) && isset($_GET["to"]))
{
$tokens = array_map(function($row){return $row['token'];},ADI::GetData("SELECT `token` FROM `" . DB_PREFIX . DATABASE_OPERATORS . "`;"));
if(!in_array($_GET["token"], $tokens))
exit('Invalid Link (ERROR 444286492)');
$fromUnixTimestamp = intval($_GET["from"]);
$toUnixTimestamp = intval($_GET["to"]);
if( $fromUnixTimestamp > $toUnixTimestamp)
exit('Invalid Date Range (ERROR 4411864921)');
$html = IOStruct::GetFile(PATH_TEMPLATES . "analytics.tpl");
$html = str_replace("<!--acid-->","?acid=" . md5(time()),$html);
$html = str_replace("<!--from-->",intval($_GET["from"]),$html);
$html = str_replace("<!--to-->",intval($_GET["to"]),$html);
$feedbackCriteria = ADI::GetFeedbackCriteria();
$feedbackCriteriaTranslation = '';
foreach($feedbackCriteria as $index => $row)
{
$feedbackCriteriaTranslation = $feedbackCriteriaTranslation . $row[0] . ": '" . $row[2] ."'" . ", ";
}
$feedbackCriteriaTranslation = substr($feedbackCriteriaTranslation, 0, -1);
$html = str_replace("<!--feedback_criteria-->",$feedbackCriteriaTranslation,$html);
$html = Server::Replace($html, true, true, true, true, false);
exit($html);
}