-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
170 lines (159 loc) · 7.61 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
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
<?php
session_start();
require_once './inc/setup.inc.php';
// Include Google API init file
require_once _APP_PATH . 'inc/gAuth.inc.php';
// How many days to list until today
$days = 7;
$UHID = filter_input(INPUT_GET, 'uh', FILTER_SANITIZE_NUMBER_INT);
//Set Access Token to make Request
if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
$gClient->setAccessToken($_SESSION['access_token']);
$userData = $objOAuthService->userinfo->get();
} else {
header('Location: ' . _WEB_ADDR . 'gauth.php');
}
try {
if (!empty($userData)) {
require_once _APP_PATH . 'classes/myPDOConn.Class.php';
require_once _APP_PATH . 'classes/Authentication.Class.php';
require_once _APP_PATH . 'classes/UserLog.Class.php';
$pdoConn = \ninthday\niceToolbar\myPDOConn::getInstance('xmindPDOConnConfig.inc.php');
$objUserAuth = new \ninthday\niceToolbar\Authentication($pdoConn);
if (!$objUserAuth->isExistandActived($userData)) {
header('Location: ' . _WEB_ADDR . 'gauth.php');
}
if (!$objUserAuth->isInstalled($userData)) {
header('Location: ' . _WEB_ADDR . 'ins_intro.php');
}
$userID = $objUserAuth->getUserID($userData);
$objUserlog = new \ninthday\XMind\UserLog($pdoConn);
$date_list = $objUserlog->getDateList($days);
$model_list = $objUserlog->getUserModelByUID($userID);
// Default UserHardwareID
if (empty($UHID)) {
$UHID = $model_list[0]['UHID'];
}
$model_name = '';
$android_version = '';
foreach ($model_list as $model) {
if ($model['UHID'] == $UHID) {
$model_name = $model['Model'];
$android_version = $model['AndroidVersion'];
}
}
} else {
header('Location: ' . _WEB_ADDR . 'gauth.php');
}
} catch (Exception $exc) {
echo $exc->getMessage();
}
?>
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html lang="zh-Hant">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="Ninthday (jeffy@ninthday.info)">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title><?php echo _WEB_NAME; ?></title>
<link rel="shortcut icon" type="image/png" href="imgs/xmind-v1.png">
<link rel="stylesheet" href="https://storage.googleapis.com/code.getmdl.io/1.0.4/material.cyan-pink.min.css">
<script src="https://storage.googleapis.com/code.getmdl.io/1.0.4/material.min.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="style/xmind.css">
</head>
<body>
<?php
// put your code here
?>
<!-- Accent-colored raised button with ripple -->
<div class="xmind-layout-transparent mdl-layout mdl-js-layout">
<header class="mdl-layout__header mdl-layout__header--transparent">
<div class="mdl-layout__header-row">
<!-- Title -->
<span class="mdl-layout-title"><img class="xmind-logo-image" src="imgs/xmind-weblogo.png">XMind Userlog</span>
<!-- Add spacer, to align navigation to the right -->
<div class="mdl-layout-spacer"></div>
<!-- Navigation -->
<nav class="mdl-navigation">
<a class="mdl-navigation__link" href="">About</a>
<a class="mdl-navigation__link" href="gauth.php?logout">Logout</a>
</nav>
</div>
</header>
<div class="mdl-layout__drawer xmind-drawer">
<span class="mdl-layout-title"><img class="circle-image-small" src="<?php echo $userData->picture; ?>"></span>
<nav class="mdl-navigation">
<?php
foreach ($model_list as $model) {
echo '<a class="mdl-navigation__link model-list" href="?uh=' . $model['UHID'] . '"><i class="material-icons">smartphone</i> '
. $model['Model'] . '<br>' . str_replace(' SDK', '', $model['AndroidVersion'])
. '<br>App: v.' . $model['AppVersion'] . '</a>';
}
?>
<a class="mdl-navigation__link" href="ins_intro.php">Install</a>
<a class="mdl-navigation__link" href="gauth.php?logout">Logout</a>
</nav>
</div>
<main class="mdl-layout__content">
<div class="xmind-content__posts mdl-grid">
<?php
foreach ($date_list as $assign_date) {
$i = 1;
$receive = 0;
$day_userlog = $objUserlog->getUserLogByDate($userID, $UHID, $assign_date);
?>
<div class="mdl-card user-upload-log mdl-cell mdl-cell--12-col mdl-shadow--2dp">
<div class="mdl-card__title">
<h2 class="mdl-card__title-text"><?php echo $assign_date; ?></h2>
</div>
<div class="mdl-card__supporting-text">
<?php echo '<strong>Model</strong>: ' . $model_name . ' [ ' . $android_version . ' ]'; ?>
</div>
<table class="mdl-data-table mdl-js-data-table mdl-color-text--grey-600 xmind-full-width">
<thead>
<tr>
<th>#</th>
<th>Log ID</th>
<th class="mdl-data-table__cell--non-numeric">Upload Time</th>
<th>Receive</th>
</tr>
</thead>
<tbody>
<?php
foreach ($day_userlog as $row) {
echo '<tr>';
echo '<td>' . $i . '</td>';
echo '<td>' . $row['logID'] . '</td>';
echo '<td class="mdl-data-table__cell--non-numeric">' . $row['saveTime'] . '</td>';
echo '<td>' . $row['receiveCount'] . '</td>';
echo '</tr>';
$i++;
$receive += $row['receiveCount'];
}
?>
</tbody>
</table>
<div class="mdl-card__actions mdl-card--border">
<a class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect">
<?php echo 'Total times: ' . strval($i - 1) . ' , Receive probes: ' . number_format($receive); ?>
</a>
</div>
</div>
<?php
}
?>
</div>
</main>
</div>
</body>
</html>
<?php
unset($pdoConn);