-
Notifications
You must be signed in to change notification settings - Fork 1
/
stats-get.php
21 lines (20 loc) · 963 Bytes
/
stats-get.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
require_once 'basics.php';
$site_id=intval($_REQUEST['site_id']);
$sql='select id,group_id,hide,name,last_seen,importance'
.', (select clicks28 from data where keyword_id=keywords.id and cdate=last_seen and data_type=0 limit 1) as clicks28'
.', (select impressions28 from data where keyword_id=keywords.id and cdate=last_seen and data_type=0 limit 1) as impressions28'
.', (select position28 from data where keyword_id=keywords.id and cdate=last_seen and data_type=0 limit 1) as position28'
.' from keywords where site_id='.$site_id.' and last_seen>date_add(date(now()), interval -28 day) order by importance desc';
$keywords=dbAll($sql);
$sql='select id, name, last_impression, clicks, impressions, position, importance'
.' from groups where site_id='.$site_id.' order by importance desc';
$groups=dbAll($sql);
if ($groups===false) {
$groups=[];
}
header('Content-type: text/json');
echo json_encode([
'keywords'=>$keywords,
'groups'=>$groups
]);