-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhome.php
208 lines (185 loc) · 6.17 KB
/
home.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<?php
/**
* Created by PhpStorm.
* User: Radon
* Date: 09.12.2018
* Time: 14:02
*/
session_start();
/*level protection*/
if (!empty($_SESSION['log']) && $_SESSION['log'] == 'logged') {
if( !($_SESSION['level'] == 'admin' || $_SESSION['level'] == 'root') ){
header("refresh:0 url=error.php");die();
}
}else{
header("refresh:0 url=index.php");
die();
}
include_once 'mysqlConnector.php';
/*news*/
$dataNews = $mysqli->query("SELECT * FROM $base.news");
$dataAllUsersRegion = $mysqli->query("SELECT * FROM $base.user WHERE `level` = 'user'");
$dataAllUsersRegDate = $mysqli->query("SELECT * FROM $base.user WHERE `level` = 'user'");
?>
<!DOCTYPE html>
<html lang="en">
<?php include_once 'header.php'?>
<script type="text/javascript" src="js/Moment.js"></script>
<script type="text/javascript" src="js/Chart.js"></script>
<script type="text/javascript" src="js/utils.js"></script>
<body>
<div class="bodyContent">
<?php include_once 'topmenu.php'?>
<?php include_once 'leftmenu.php'?>
<div class="main">
<!--mini elements of stats-->
<?php include_once 'cards.php'?>
<!--blocks for news-->
<div class="block" >
<div class="blockContent">
<?
// $arrRegDate = [];
// $arrRegDate = ['a' => 1 , 'c' => 1 ];
// $arrRegDate += ['d' => 1 , 'a' => 2 ];
// $arrRegDate = ['d' => 1 , 'a' => 2 ];
// echo print_r($arrRegDate);
//
// while ($rowRegDate = $dataAllUsersRegDate ->fetch_assoc()){
//
// }
// $date = date_create('2018-01-07 22:26:30');
// echo "<br>";
// echo date_format($date, 'Y m d');
?>
</div>
</div>
<?php
$rowNews = [];
while($rowNewsx = $dataNews ->fetch_assoc()){
array_push($rowNews,$rowNewsx);
}
$rowNews=array_reverse($rowNews); /*teskari massiv*/
foreach($rowNews as $rowx){?>
<div class="block">
<div class="blockTitle" id="softAnim">
<div style="font-size: small"><?echo $rowx["createdtime"]?></div><?echo $rowx["title"]?>
</div>
<div class="blockContent">
<?echo $rowx["content"]?>
</div>
</div>
<?php }?> <!--end news-->
<!--stats charts-->
<div class="block" style="width: 50%;">
<div class="blockTitle">
Viloyatlar bo`yicha
</div>
<div class="blockContent" >
<canvas id="ChartByRegion" width="400" height="321"></canvas>
</div>
</div>
<div class="block" style="width: 50%;">
<div class="blockTitle">
Ro`yhatdan o`tgan userlar soni bo`yicha (TEST)
</div>
<div class="blockContent" >
<canvas id="ChartByRegDate" width="400" height="321"></canvas>
</div>
</div>
<!--end charts-->
</div>
</div>
</body>
<script type="text/javascript" src="js/chart1.js"></script>
<script>
/*add data for charts*/
<?php
$arrChartByRegDate = [];
$arrRegion = [
"Navoiy" => 0,
"Toshkent" => 0,
"Andijon" => 0,
"Namangan" => 0,
"Buxoro" => 0,
"Jizzax" => 0,
"Samarqand" => 0,
"Surxondaryo" => 0,
"Qashqadaryo" => 0,
"Sirdaryo" => 0,
"Xorazm" => 0,
"Farg`ona" => 0,
"Qoraqalpog`iston" => 0
];
while ($rowUser = $dataAllUsersRegion ->fetch_assoc()){
$arrRegion[$rowUser['region']]++;
}?>
<?php foreach ( $arrRegion as $key => $value) {?>
addData(ChartByRegion,'<?echo $key?>',<?echo $value?>);
<?php }?>
</script>
<script>
function randomNumber(min, max) {
return Math.random() * (max - min) + min;
}
function randomBar(date, lastClose) {
var open = randomNumber(lastClose * 0.95, lastClose * 1.05);
var close = randomNumber(open * 0.95, open * 1.05);
return {
t: date.valueOf(),
y: close
};
}
var dateFormat = 'MMMM DD YYYY';
var date = moment('<? echo date("Y m d")?>', dateFormat);
var data = [randomBar(date, 30)];
var labels = [date];
while (data.length < 7) {
date = date.clone().add(1, 'd');
if (date.isoWeekday() <= 5) {
data.push(randomBar(date, data[data.length - 1].y));
labels.push(date);
}
}
var ctx = document.getElementById('ChartByRegDate').getContext('2d');
var color = Chart.helpers.color;
var cfg = {
type: 'bar',
data: {
labels: labels,
datasets: [{
label: 'Oxirgi haftada',
backgroundColor: color(window.chartColors.red).alpha(0.5).rgbString(),
borderColor: window.chartColors.red,
data: data,
type: 'bar',
pointRadius: 0,
fill: false,
lineTension: 0,
borderWidth: 2
}]
},
options: {
scales: {
xAxes: [{
type: 'time',
distribution: 'series',
ticks: {
source: 'labels'
}
}],
yAxes: [{
scaleLabel: {
display: true,
labelString: 'Closing price ($)'
}
}]
}
}
};
var chart = new Chart(ctx, cfg);
</script>
<script src="js/animatedBG.js" type="text/javascript"></script>
<script>
startSoftAnim();
</script>
</html>