forked from electricg/Google-Analytics-Report
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
executable file
·131 lines (124 loc) · 4.01 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
<?php
$default_date = mktime(0, 0, 0, date('n') - 1, 1, date('Y'));
$dm = date('n', $default_date);
$dy = date('Y', $default_date);
$m = array('','January','February','March','April','May','June','July','August','September','October','November','December');
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Google Analytics for PureResponse</title>
<link rel="stylesheet" href="css/style.css">
<script src="js/jquery-1.7.1.min.js"></script>
</head>
<body>
<h1>Google Analytics for PureResponse</h1>
<form id="form" method="post" action="do.php">
<fieldset>
<legend>Date</legend>
<div>
<label>Month
<select name="month" id="month">
<?php
for ($i = 1; $i <= 12; $i++) {
?>
<option value="<?php echo $i ?>" <?php echo ($i == $dm ? 'selected="selected"' : '') ?>><?php echo $m[$i] ?></option>
<?php
}
?>
</select>
</label>
</div>
<div>
<label>Year
<select name="year" id="year">
<?php
for ($i = 2010; $i <= $dy; $i++) {
?>
<option value="<?php echo $i ?>" <?php echo ($i == $dy ? 'selected="selected"' : '') ?>><?php echo $i ?></option>
<?php
}
?>
</select>
</label>
</div>
</fieldset>
<fieldset>
<legend>Import statistics</legend>
<div>
<ul>
<li><label><input type="checkbox" name="imp_stat" value="access_time">Access Time <span class="msg"></span></label></li>
<li><label><input type="checkbox" name="imp_stat" value="browser_os">Browser / OS<span class="msg"></span></label></li>
<li><label><input type="checkbox" name="imp_stat" value="countries">Countries<span class="msg"></span></label></li>
<li><label><input type="checkbox" name="imp_stat" value="help_page">Help Pages<span class="msg"></span></label> (available only from February 2012)</li>
<li><label><input type="checkbox" name="imp_stat" value="screen_res">Screen Resolution<span class="msg"></span></label></li>
</ul>
</div>
<div>
<input type="button" name="import" id="import" value="import">
</div>
</fieldset>
<fieldset>
<legend>Create Report</legend>
<div>
<ul>
<li><label><input type="radio" name="report" value="access_time"> Access Time</label></li>
<li><label><input type="radio" name="report" value="browser">Browser</label></li>
<li><label><input type="radio" name="report" value="os">OS</label></li>
<li><label><input type="radio" name="report" value="countries">Countries</label></li>
<li><label><input type="radio" name="report" value="help_page">Help Pages</label> (available only from February 2012)</li>
<li><label><input type="radio" name="report" value="screen_res">Screen Resolution</label></li>
</ul>
</div>
<div>
<input type="submit" name="create" id="create" value="create">
</div>
</fieldset>
</form>
<script type="text/javascript">
$(document).ready(function() {
var $form = $('#form'),
$import = $('#import'),
$create = $('#create'),
_page = 'do.php',
_loadingC = 'loading',
_errorC = 'error',
_successC = 'success';
//$form.submit(function(e) {
// e.preventDefault();
//})
// Import statistics
$import.click(function() {
$('input[name="imp_stat"]:checked').each(function() {
var $this = $(this),
$msg = $this.siblings('.msg');
$msg.removeClass(_successC + ' ' + _errorC).addClass(_loadingC).html('Loading...');
$.ajax({
type: 'POST',
url: _page,
dataType: 'html',
success: function(data) {
if (data == '1') {
$msg.removeClass(_loadingC).addClass(_successC).html('OK');
}
else {
$msg.removeClass(_loadingC).addClass(_errorC).html(data);
}
},
error: function() {
$msg.removeClass(_loadingC).addClass(_errorC).html('An error occured trying to fetch the data');
},
data: 'import=' + $this.val() +
'&year=' + $('#year').val() +
'&month=' + $('#month').val()
});
});
})
//$create.click(function() {
//
//})
});
</script>
</body>
</html>