Browse Source

Initial import

master
Chris Smith 14 years ago
commit
6589753e1e
20 changed files with 4858 additions and 0 deletions
  1. 1
    0
      .gitignore
  2. 36
    0
      content.php
  3. 23
    0
      event.php
  4. 167
    0
      index.php
  5. BIN
      res/dmdirc.ico
  6. BIN
      res/lastfm.ico
  7. 4221
    0
      res/prototype.js
  8. BIN
      res/svn.ico
  9. BIN
      res/transport.ico
  10. BIN
      res/weight.png
  11. BIN
      res/wiki.ico
  12. 9
    0
      source.php
  13. 79
    0
      sources/audioscrobber.php
  14. 54
    0
      sources/dmdircissues.php
  15. 48
    0
      sources/dmdircsvn.php
  16. 45
    0
      sources/svn.php
  17. 88
    0
      sources/transport.php
  18. 24
    0
      sources/weight.php
  19. 28
    0
      sources/wiki.php
  20. 35
    0
      tracker.php

+ 1
- 0
.gitignore View File

@@ -0,0 +1 @@
1
+/cache/*

+ 36
- 0
content.php View File

@@ -0,0 +1,36 @@
1
+<?PHP
2
+
3
+$period = isset($_POST['period']) ? $_POST['period'] : 'week';
4
+
5
+define('MIN_TIME', strtotime('-1 ' . $period));
6
+define('MAX_TIME', time());
7
+
8
+if (!empty($_POST)) {
9
+	$_FILTER = $_POST;
10
+}
11
+
12
+require_once('tracker.php');
13
+
14
+$lastdate = '';
15
+
16
+foreach ($_EVENTS as $event) {
17
+        $date = date('l, F \t\h\e j<\s\u\p>S</\s\u\p>, Y', $event['event']->getTime());
18
+
19
+        if ($date != $lastdate) {
20
+                if ($lastdate != '') {
21
+                        echo '</ul>';
22
+                }
23
+
24
+                echo '<h2>', $date, '</h2><ul>';
25
+                $lastdate = $date;
26
+        }
27
+
28
+        echo '<li class="', get_class($event['source']), '">', $event['event']->getData();
29
+}
30
+
31
+if ($lastdate == '') {
32
+ echo '<h2>Error</h2>';
33
+ echo '<p>No events matching that filter/time period</p>';
34
+}
35
+
36
+?>

+ 23
- 0
event.php View File

@@ -0,0 +1,23 @@
1
+<?PHP
2
+
3
+class Event {
4
+
5
+	private $data;
6
+	private $time;
7
+
8
+	public function __construct($time, $data) {
9
+		$this->time = $time;
10
+		$this->data = $data;
11
+	}
12
+
13
+	public function getTime() {
14
+		return $this->time;
15
+	}
16
+
17
+	public function getData() {
18
+		return $this->data;
19
+	}
20
+
21
+}
22
+
23
+?>

+ 167
- 0
index.php View File

@@ -0,0 +1,167 @@
1
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
+<html>
3
+ <head>
4
+  <title>Chris tracking</title>
5
+  <script src="res/prototype.js" type="text/javascript"></script>
6
+  <script type="text/javascript">
7
+   function doFilter() {
8
+    var params = new Hash();
9
+    params.set('dummy', 'true');
10
+    params.set('period', document.getElementById('period').value);
11
+
12
+    var elements = document.getElementsByTagName('input');
13
+    for (var i = 0; i < elements.length; i++) {
14
+     var element = elements[i];
15
+     if (element.type == 'checkbox' && element.checked) {
16
+      params.set(element.id, 'true');
17
+     }
18
+    }
19
+
20
+    params.set('sort', document.getElementById('sort').value);
21
+
22
+    new Ajax.Updater('content', 'content.php', {parameters:params});
23
+    return false;
24
+   }
25
+
26
+   Ajax.Responders.register({
27
+    onCreate: function(request) {
28
+     document.getElementById('loading').style.display = 'block';
29
+    },
30
+    onComplete: function(request) {
31
+     document.getElementById('loading').style.display = 'none';
32
+    }
33
+   });
34
+  </script>
35
+  <style type="text/css">
36
+   li.WikiSource { list-style-image: url('res/wiki.ico'); }
37
+   li.SvnSource, li.DMDircSvnSource { list-style-image: url('res/svn.ico'); }
38
+   li.WeightSource { list-style-image: url('res/weight.png'); }
39
+   li.TransportSource { list-style-image: url('res/transport.ico'); }
40
+   li.AudioscrobblerSource { list-style-image: url('res/lastfm.ico'); }
41
+   li.AudioscrobblerSource li { list-style-image: none; list-style-type: decimal; }
42
+   li.DMDircIssuesSource { list-style-image: url('res/dmdirc.ico'); }
43
+   li { margin-bottom: 6px; }
44
+   li ul li { margin-bottom: 2px; }
45
+   #content {
46
+    position: absolute;
47
+    top: 20px;
48
+    right: 250px;
49
+    left: 20px;
50
+    bottom: 20px;
51
+    overflow: auto;
52
+    border: 1px solid #aaa;
53
+    padding: 10px;
54
+   }
55
+
56
+   #right {
57
+    position: absolute;
58
+    top: 20px;
59
+    right: 20px;
60
+    width: 210px;
61
+   }
62
+
63
+   #filter, #timespan, #sortbox {
64
+    border: 1px solid #aaa;
65
+    padding: 10px;
66
+    margin-bottom: 20px;
67
+   }
68
+
69
+   input[type="checkbox"] {
70
+    margin-right: 10px;
71
+   }
72
+
73
+   h2 {
74
+    margin: 0px;
75
+   }
76
+
77
+   select {
78
+    width: 100%;
79
+    margin-top: 10px;
80
+   }
81
+
82
+   #loading {
83
+    position: absolute;
84
+    top: 50%;
85
+    left: 50%;
86
+    width: 100px;
87
+    padding: 5px;
88
+    margin-top: -0.75em;
89
+    margin-left: -50px;
90
+    background-color: #900;
91
+    color: white;
92
+    text-align: center;
93
+    border: 0px;
94
+    z-index: 100;
95
+   }
96
+  </style>
97
+ </head>
98
+ <body>
99
+  <div id="loading" style="display: none;">
100
+   Loading...
101
+  </div>
102
+  <div id="content">
103
+<?PHP require_once('content.php'); ?>
104
+  </div>
105
+  <div id="right">
106
+   <form action="/tracker/" method="POST" onsubmit="return doFilter();">
107
+    <input type="hidden" name="dummy" value="true">
108
+  <div id="filter">
109
+   <h2>Filter</h2>
110
+    <ul id="filterlist">
111
+<?PHP
112
+
113
+foreach ($_SOURCES as $source) {
114
+	$name = get_class($source);
115
+        $nicename = preg_replace('/([a-z])([A-Z])/', '\1 \2', substr($name, 0, -6));
116
+	$checked = '';
117
+
118
+	if (empty($_POST) || isset($_POST[$name])) {
119
+		$checked = ' checked="checked"';
120
+	}
121
+
122
+	echo '<li class="', $name,' "><label><input type="checkbox" id="', $name, '" name="', $name, '"', $checked, '>';
123
+	echo $nicename, '</label>';
124
+}
125
+
126
+?>
127
+    </ul>
128
+  </div>
129
+  <div id="timespan">
130
+   <h2>Timespan</h2>
131
+   <select id="period" name="period">
132
+<?PHP
133
+
134
+ foreach (array('day', 'week', 'month', 'year') as $timespan) {
135
+  echo '<option value="', $timespan, '"';
136
+  if ((isset($_POST['timespan']) && $_POST['timespan'] == $timespan)
137
+   || (!isset($_POST['timespan']) && $timespan == 'week')) {
138
+   echo ' selected="selected"';
139
+  }
140
+  echo '>', ucfirst($timespan), '</option>';
141
+ }
142
+
143
+?>
144
+   </select>
145
+  </div>
146
+  <div id="sortbox">
147
+   <h2>Sort order</h2>
148
+   <select name="sort" id="sort">
149
+<?PHP
150
+
151
+ foreach (array('forwards', 'backwards') as $timespan) {
152
+  echo '<option value="', $timespan, '"';
153
+  if ((isset($_POST['sort']) && $_POST['sort'] == $timespan)
154
+   || (!isset($_POST['sort']) && $timespan == 'backwards')) {
155
+   echo ' selected="selected"';
156
+  }
157
+  echo '>', ucfirst($timespan), '</option>';
158
+ }
159
+
160
+?>
161
+   </select>
162
+  </div>
163
+    <input type="submit" value="Apply" id="filterbutton">
164
+   </form>
165
+  </div>
166
+ </body>
167
+</html>

BIN
res/dmdirc.ico View File


BIN
res/lastfm.ico View File


+ 4221
- 0
res/prototype.js
File diff suppressed because it is too large
View File


BIN
res/svn.ico View File


BIN
res/transport.ico View File


BIN
res/weight.png View File


BIN
res/wiki.ico View File


+ 9
- 0
source.php View File

@@ -0,0 +1,9 @@
1
+<?PHP
2
+
3
+interface source {
4
+
5
+	public function getData();
6
+
7
+}
8
+
9
+?>

+ 79
- 0
sources/audioscrobber.php View File

@@ -0,0 +1,79 @@
1
+<?PHP
2
+
3
+class AudioscrobblerSource implements Source {
4
+
5
+	private $data = array('last' => 0, 'data' => array());
6
+
7
+	public function __construct() {
8
+		$cache = dirname(dirname(__FILE__)) . '/cache/lastfm.dat';
9
+
10
+		if (file_exists($cache)) {
11
+			$this->data = unserialize(file_get_contents($cache));
12
+                        if (filemtime($cache) > strtotime('-1 day')) { return; }
13
+		}
14
+
15
+		$data = file_get_contents('http://ws.audioscrobbler.com/1.0/user/MD87/weeklychartlist.xml');
16
+		$data = new SimpleXMLElement($data);
17
+		$mtime = $data['last'];
18
+
19
+		foreach($data->chart as $chart) {
20
+			$from = (int) $chart['from'];
21
+			$to = (int) $chart['to'];
22
+
23
+			if ($to > $this->data['last']) {
24
+				$mtime = $to;
25
+
26
+				$newdata = "http://ws.audioscrobbler.com/1.0/user/MD87/weeklytrackchart.xml?from=$from&to=$to";
27
+				echo "Retrieving $newdata<br>"; flush();
28
+				$newdata = new SimpleXMLElement(file_get_contents($newdata));
29
+				$top = array();
30
+				foreach ($newdata->track as $track) {
31
+					$title = (String) $track->name;
32
+					$artist = (String) $track->artist;
33
+					$link = (String) $track->url;
34
+					$count = (int) $track->playcount;
35
+					$message  = '<li><a href="' . $link. '">' . $title .'</a> by ';
36
+					$message .= $artist . ' (' . $count . ' play';
37
+					$message .= ($count == 1 ? '' : 's') . ')';
38
+					$top[] = $message;
39
+					if (count($top) == 5) { break; }
40
+				}
41
+
42
+				$message = 'Top tracks this week: <ul>' . implode(', ', $top) . '</ul>';
43
+				$this->data['data'][] = new Event(strtotime('23:59:59', $to), $message);
44
+
45
+                                $newdata = "http://ws.audioscrobbler.com/1.0/user/MD87/weeklyartistchart.xml?from=$from&to=$to";
46
+                                echo "Retrieving $newdata<br>"; flush();
47
+                                $newdata = new SimpleXMLElement(file_get_contents($newdata));
48
+                                $top = array();
49
+                                foreach ($newdata->artist as $track) {
50
+                                        $artist = (String) $track->name;
51
+                                        $link = (String) $track->url;
52
+					$count = (int) $track->playcount;
53
+                                        $message  = '<li><a href="' . $link. '">' . $artist.'</a> ';
54
+                                        $message .= ' (' . $count . ' play';
55
+                                        $message .= ($count == 1 ? '' : 's') . ')';
56
+                                        $top[] = $message;
57
+                                        if (count($top) == 3) { break; }
58
+                                }
59
+
60
+                                $message = 'Top artists this week: <ul>' . implode(', ', $top) . '</ul>';
61
+                                $this->data['data'][] = new Event(strtotime('23:59:59', $to), $message);
62
+
63
+			}
64
+		}
65
+
66
+		$this->data['last'] = $mtime;
67
+
68
+		file_put_contents($cache, serialize($this->data));
69
+	}
70
+
71
+	public function getData() {
72
+		return $this->data['data'];
73
+	}
74
+
75
+}
76
+
77
+$_SOURCES[] =& new AudioscrobblerSource();
78
+
79
+?>

+ 54
- 0
sources/dmdircissues.php View File

@@ -0,0 +1,54 @@
1
+<?PHP
2
+
3
+                chdir('/home/dmdirc/www/bugs/');
4
+                require_once('core.php');
5
+
6
+
7
+class DMDircIssuesSource implements Source {
8
+
9
+	private $data = array();
10
+
11
+	public function __construct() {
12
+		mysql_connect('localhost', '', '');
13
+		mysql_select_db('');
14
+
15
+
16
+		$sql = 'SELECT UNIX_TIMESTAMP(date_modified) AS ts, field_name, old_value, new_value, type, bug_id FROM mantis_bug_history_table INNER JOIN mantis_user_table ON mantis_bug_history_table.user_id = mantis_user_table.id WHERE mantis_user_table.username = \'MD87\' AND date_modified > FROM_UNIXTIME(' . MIN_TIME . ')';
17
+
18
+		$res = mysql_query($sql);
19
+
20
+		while ($row = mysql_fetch_assoc($res)) {
21
+                        $info = history_localize_item($row['field_name'], $row['type'], $row['old_value'], $row['new_value']);
22
+
23
+                        $desc = $info['note'] . (!empty($info['change']) ? ': ' . $info['change'] : '');
24
+
25
+			if ($desc == 'Checkin') { $ctime = $row['ts']; continue; }
26
+
27
+			if ($desc == 'New Issue') { $ntime = $row['ts']; } else if ($ntime == $row['ts']) { continue; }
28
+
29
+			if ($row['ts'] == $ctime) { continue; }
30
+
31
+			$link = '<a href="http://bugs.dmdirc.com/view.php?id=' . $row['bug_id'];
32
+                        $link .= '">' . $row['bug_id'] . '</a>';
33
+
34
+			if ($desc == 'New Issue') {
35
+				$message = 'Created DMDirc issue ' . $link;
36
+			} else if (substr($desc, 0, 6) == 'Note A') {
37
+				$message = 'Added note to DMDirc issue ' . $link;
38
+			} else {
39
+				continue;
40
+				$message  = 'Altered DMDirc issue ' . $link . ' (' . htmlentities($desc) . ')';
41
+			}
42
+
43
+			$this->data[] = new Event($row['ts'], $message); 
44
+		}
45
+	}
46
+
47
+	public function getData() {
48
+		return $this->data;
49
+	}
50
+}
51
+
52
+$_SOURCES[] =& new DMDircIssuesSource();
53
+
54
+?>

+ 48
- 0
sources/dmdircsvn.php View File

@@ -0,0 +1,48 @@
1
+<?PHP
2
+
3
+class DMDircSvnSource implements Source {
4
+
5
+	private $data;
6
+
7
+	public function __construct() {
8
+		$cache = dirname(dirname(__FILE__)) . '/cache/dmdircsvn.dat';
9
+
10
+		if (file_exists($cache)) {
11
+			$this->data = unserialize(file_get_contents($cache));
12
+		} else {
13
+			$this->data = array('data' => array(), 'processed' => 0);
14
+		}
15
+
16
+		$repo = '/home/dmdirc/repo';
17
+		$name = 'DMDirc'; 
18
+		$titl = '<strong>' . $name . '</strong>';
19
+
20
+		$revs = count(glob($repo . '/db/revs/*'));
21
+		$done = max(1, (int) $this->data['processed']);
22
+
23
+		for ($i = $done; $i < $revs; $i++) {
24
+			$auth = trim(`svnlook author $repo -r $i`);
25
+
26
+			if ($auth == 'chris87') {
27
+				$date = strtotime(substr(`svnlook date $repo -r $i`, 0, 19));
28
+				$revh = '<strong>' . $i . '</strong>';
29
+				$mesg = '<code>' . htmlentities(trim(`svnlook log $repo -r $i`)) . '</code>';
30
+				$mesg = 'Committed revision ' . $revh . ' to ' . $titl . ' with log message ' . $mesg;
31
+				$this->data['data'][] = new Event($date, $mesg);
32
+			}
33
+		}
34
+
35
+		$this->data['processed'] = $revs;
36
+
37
+		file_put_contents($cache, serialize($this->data));
38
+		unset($this->data['processed']);
39
+	}
40
+
41
+	public function getData() {
42
+		return $this->data['data'];
43
+	}
44
+}
45
+
46
+$_SOURCES[] =& new DMDircSvnSource();
47
+
48
+?>

+ 45
- 0
sources/svn.php View File

@@ -0,0 +1,45 @@
1
+<?PHP
2
+
3
+class SvnSource implements Source {
4
+
5
+	private $data;
6
+
7
+	public function __construct() {
8
+		$cache = dirname(dirname(__FILE__)) . '/cache/svn.dat';
9
+
10
+		if (file_exists($cache)) {
11
+			$this->data = unserialize(file_get_contents($cache));
12
+		} else {
13
+			$this->data = array('data' => array(), 'processed' => array());
14
+		}
15
+
16
+		foreach (glob('/home/chris/svn/*') as $repo) {
17
+			$name = basename($repo);
18
+			$titl = '<strong>' . $name . '</strong>';
19
+
20
+			$revs = count(glob($repo . '/db/revs/*'));
21
+			$done = max(1, (int) $this->data['processed'][$name]);
22
+
23
+			for ($i = $done; $i < $revs; $i++) {
24
+                                $date = strtotime(substr(`svnlook date $repo -r $i`, 0, 19));
25
+				$revh = '<strong>' . $i . '</strong>';
26
+				$mesg = '<code>' . htmlentities(trim(`svnlook log $repo -r $i`)) . '</code>';
27
+				$mesg = 'Committed revision ' . $revh . ' to ' . $titl . ' with log message ' . $mesg;
28
+				$this->data['data'][] = new Event($date, $mesg);
29
+			}
30
+
31
+			$this->data['processed'][$name] = $revs;
32
+		}
33
+
34
+		file_put_contents($cache, serialize($this->data));
35
+		unset($this->data['processed']);
36
+	}
37
+
38
+	public function getData() {
39
+		return $this->data['data'];
40
+	}
41
+}
42
+
43
+$_SOURCES[] =& new SvnSource();
44
+
45
+?>

+ 88
- 0
sources/transport.php View File

@@ -0,0 +1,88 @@
1
+<?PHP
2
+
3
+class TransportSource implements Source {
4
+
5
+	private $data = array('last' => 0, 'data' => array());
6
+
7
+	public function __construct() {
8
+		$cache = dirname(dirname(__FILE__)) . '/cache/transport.dat';
9
+
10
+		if (file_exists($cache)) {
11
+			$this->data = unserialize(file_get_contents($cache));
12
+                        if (filemtime($cache) > strtotime('-1 day')) { return; }
13
+		}
14
+
15
+		$url = 'https://oyster.tfl.gov.uk/oyster/security_check';
16
+		$fields = 'j_username=&j_password=';
17
+		$info = $this->do_post_request($url, $fields);
18
+
19
+		foreach ($info['data']['wrapper_data'] as $header) {
20
+			if (substr($header, 0, 11) == 'Set-Cookie:') {
21
+				$cookie = preg_replace('/^Set-Cookie: (.*?); Path.*$/', '\1', $header);
22
+				break;
23
+			}
24
+		}
25
+
26
+		$url = 'https://oyster.tfl.gov.uk/oyster/ppvStatement.do';
27
+		$fields = '';
28
+		$headers = 'Cookie: ' . $cookie;
29
+		$info = $this->do_post_request($url, $fields, $headers, 'GET');
30
+                $info = $this->do_post_request($url, $fields, $headers, 'GET');
31
+		preg_match('/<table class="journeyhistory">.*?<tr>.*?<\/tr>(.*?)<\/table>/is', $info['response'], $m);
32
+		preg_match_all('/<tr>(.*?)<\/tr>/is', $m[0], $m2);
33
+		$mtime = $this->data['last'];
34
+
35
+	  	foreach ($m2[1] as $match) {	
36
+			preg_match_all('/<td.*?>(.*?)<\/td>/is', $match, $m3);
37
+
38
+			if (trim($m3[1][0]) != '&nbsp;') {
39
+				$date = explode('/', trim($m3[1][0]));
40
+				$date = $date[1] . '/' . $date[0] . '/' . $date[2];
41
+				$date = strtotime($date);
42
+			}
43
+
44
+			$time = strtotime($m3[1][1], $date);
45
+			$mtime = max($mtime, $time);
46
+
47
+			if ($time > $this->data['last']) {
48
+				$station = trim($m3[1][2]);
49
+				$enter = 'Entry' == trim($m3[1][3]);
50
+				$message = $enter ? 'Entered <strong>' : 'Departed <strong>';
51
+				$message .= $station . ' Station</strong>';
52
+				$this->data['data'][] = new Event($time, $message);
53
+			}
54
+		}
55
+
56
+		$this->data['last'] = $mtime;
57
+
58
+		file_put_contents($cache, serialize($this->data));
59
+	}
60
+
61
+	public function getData() {
62
+		return $this->data['data'];
63
+	}
64
+
65
+	private function do_post_request($url, $data, $optional_headers = null, $method = 'POST') {
66
+ 	     $params = array('http' => array(
67
+        	          'method' => $method,
68
+                	  'content' => $data
69
+	               ));
70
+	     if ($optional_headers !== null) {
71
+        	$params['http']['header'] = $optional_headers;
72
+	     }
73
+	     $ctx = stream_context_create($params);
74
+	     $fp = @fopen($url, 'rb', false, $ctx);
75
+	     if (!$fp) {
76
+	        throw new Exception("Problem with $url, $php_errormsg");
77
+	     }
78
+	     $response = @stream_get_contents($fp);
79
+	     if ($response === false) {
80
+	        throw new Exception("Problem reading data from $url, $php_errormsg");
81
+	     }
82
+	     return array('response' => $response, 'data' => stream_get_meta_data($fp));
83
+	}
84
+}
85
+
86
+$_SOURCES[] =& new TransportSource();
87
+
88
+?>

+ 24
- 0
sources/weight.php View File

@@ -0,0 +1,24 @@
1
+<?PHP
2
+
3
+class WeightSource implements Source {
4
+
5
+	private $data = array();
6
+
7
+	public function __construct() {
8
+		require_once('/home/chris/websites/apps.md87.co.uk/weight/data.php');
9
+		foreach ($data as $wk => $weight) {
10
+			$time = strtotime('+' . $wk . ' weeks', 1190588400);
11
+			$message = 'Recorded my <a href="http://apps.md87.co.uk/weight/">weight</a> as <strong>';
12
+			$message .= $weight . 'kg</strong>';
13
+			$this->data[] = new Event($time, $message);
14
+		}
15
+	}
16
+
17
+	public function getData() {
18
+		return $this->data;
19
+	}
20
+}
21
+
22
+$_SOURCES[] =& new WeightSource();
23
+
24
+?>

+ 28
- 0
sources/wiki.php View File

@@ -0,0 +1,28 @@
1
+<?PHP
2
+
3
+class WikiSource implements Source {
4
+
5
+	private $data = array();
6
+
7
+	public function __construct() {
8
+		mysql_connect('localhost', '', '');
9
+		mysql_select_db('');
10
+
11
+		$sql = 'SELECT tag AS page, UNIX_TIMESTAMP(time) AS ts FROM wikka_pages WHERE user = \'ChrisSmith\'';
12
+		$res = mysql_query($sql);
13
+
14
+		while ($row = mysql_fetch_assoc($res)) {
15
+			$message  = 'Edited the <a href="http://wiki.MD87.co.uk/' . $row['page'];
16
+			$message .= '">' . $row['page'] . '</a> page on my wiki';
17
+			$this->data[] = new Event($row['ts'], $message); 
18
+		}
19
+	}
20
+
21
+	public function getData() {
22
+		return $this->data;
23
+	}
24
+}
25
+
26
+$_SOURCES[] =& new WikiSource();
27
+
28
+?>

+ 35
- 0
tracker.php View File

@@ -0,0 +1,35 @@
1
+<?PHP
2
+
3
+require_once('event.php');
4
+require_once('source.php');
5
+
6
+if (!is_dir(dirname(__FILE__) . '/cache')) {
7
+	mkdir(dirname(__FILE__) . '/cache');
8
+}
9
+
10
+$_SOURCES = array();
11
+
12
+foreach (glob('sources/*.php') as $source) {
13
+	set_time_limit(60);
14
+	require_once($source);
15
+}
16
+
17
+$_EVENTS = array();
18
+
19
+foreach ($_SOURCES as $source) {
20
+	if (!isset($_FILTER) || $_FILTER[get_class($source)]) {
21
+		foreach ($source->getData() as $event) {
22
+			if ($event->getTime() > MIN_TIME && $event->getTime() < MAX_TIME) {
23
+				$_EVENTS[] = array('source' => $source, 'event' => $event);
24
+			}
25
+		}
26
+	}
27
+}
28
+
29
+function sortEvents($a, $b) {
30
+	return ($_POST['sort'] == 'forwards' ? 1 : -1) * ($a['event']->getTime() - $b['event']->getTime());
31
+}
32
+
33
+usort($_EVENTS, 'sortEvents');
34
+
35
+?>

Loading…
Cancel
Save