-
Notifications
You must be signed in to change notification settings - Fork 14
/
index.php
37 lines (33 loc) · 1.1 KB
/
index.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
<?php
session_start();
//Vars
require_once('./include/setting_oj.inc.php');
//Prepares
$sql=$pdo->prepare(
"SELECT COUNT(*) , COUNT(1) , DATE(in_date) submit_time , result
FROM solution
WHERE in_date > DATE_ADD(NOW() , INTERVAL -7 DAY)
GROUP BY submit_time, result
ORDER BY in_date"
);
$sql->execute();
$weekyResult=$sql->fetchAll(PDO::FETCH_ASSOC);
$tableResult = null;
foreach($weekyResult as $row) {
$submit_time = $row['submit_time'];
$tableResult[$submit_time]['date'] = $submit_time;
if(!isset($tableResult[$submit_time]['count'])) $tableResult[$submit_time]['count'] = 0;
if(!isset($tableResult[$submit_time]['4'])) $tableResult[$submit_time]['4'] = 0;
if(!isset($tableResult[$submit_time]['6'])) $tableResult[$submit_time]['6'] = 0;
else {
$tableResult[$submit_time]['count'] += $row['COUNT(*)'];
}
$tableResult[$submit_time][$row['result']] = $row['COUNT(*)'];
}
if (isset($_GET['night'])) {
$expireData = intval($_GET['night']) == 1 ? time()+4*7*24*3600 : time()-61;
setcookie("night","true",$expireData);
}
//Page Includes
require("./pages/index.php");
?>