-
Notifications
You must be signed in to change notification settings - Fork 2
/
summary.php
72 lines (57 loc) · 1.91 KB
/
summary.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
<?
session_start();
require_once("vendor/init.php");
require_once("vendor/sloph/summary.php");
$headers = apache_request_headers();
$ct = $headers["Accept"];
$acceptheaders = new AcceptHeader($ct);
$base = "https://rhiaro.co.uk";
$summary_uri = "https://rhiaro.co.uk/summary";
$graph = new EasyRdf_Graph($summary_uri);
$graph->addType($summary_uri, "as:Article");
$graph->add($summary_uri, "as:name", "Summary");
$graph->add($summary_uri, "as:summary", "Aggregation of various logs between two dates.");
$now = new DateTime();
if(isset($_GET['from'])){
$from = new DateTime($_GET['from']);
}else{
$from = new DateTime("7 days ago");
}
if(isset($_GET['to'])){
$to = new DateTime($_GET['to']);
}else{
$to = $now;
}
$posts = get_posts($ep, $from->format(DATE_ATOM), $to->format(DATE_ATOM));
$tags = get_tags($ep);
$locations = get_locations($ep);
$places = get_places($ep);
$locations = $locations->toRdfPhp();
$checkins = aggregate_checkins($posts, $from, $to, $locations);
$acquires = aggregate_acquires($posts, $from, $to, $tags);
$consumes = aggregate_consumes($posts, $from, $to, $tags);
$writing = aggregate_writing($posts, $from, $to, $tags);
$socials = aggregate_socials($posts, $from, $to);
$travel = aggregate_travel($posts, $from, $to);
$total = $checkins['total'] + $acquires['total'] + $consumes['total'] + $writing['total'] + $socials['total'];
$result = conneg($acceptheaders, $graph);
$header = $result['header'];
$content = $result['content'];
try {
if(gettype($content) == "string"){
header($header);
echo $content;
}else{
$resource = $graph->resource($summary_uri);
if(!$resource->get('view:stylesheet')){
$resource->addLiteral('view:stylesheet', "views/".get_style($resource).".css");
}
$g = $resource->getGraph();
$resource = $g->toRdfPhp();
$includes = array('listing_summary.php');
include 'views/page_template.php';
}
}catch(Exception $e){
var_dump($e);
}
?>