PageRenderTime 41ms CodeModel.GetById 20ms app.highlight 2ms RepoModel.GetById 18ms app.codeStats 0ms

/monitor.php

http://showslow.googlecode.com/
PHP | 43 lines | 30 code | 12 blank | 1 comment | 6 complexity | 066892c0d404bb5b2f474a17337e5a2c MD5 | raw file
 1<?php
 2require_once(dirname(__FILE__).'/global.php');
 3
 4header('Content-type: text/plain');
 5
 6// whatever to display all URLs or only new ones, just recently added
 7$new = false;
 8
 9if (array_key_exists('new', $_GET)) {
10	$new = true;
11}
12
13if ($new) {
14	$query = "SELECT DISTINCT url FROM urls INNER JOIN user_urls on user_urls.url_id = urls.id WHERE DATE_ADD(added, INTERVAL %d HOUR) > NOW()";
15	foreach ($all_metrics as $provider_name => $provider) {
16		$query .= " AND ".$provider['table'].'_last_id IS NULL';
17	}
18	$query = sprintf($query, $monitoringPeriod);
19} else {
20	$query = "SELECT DISTINCT url FROM urls INNER JOIN user_urls on user_urls.url_id = urls.id";
21}
22
23$result = mysql_query($query);
24
25if (!$result) {
26	error_log(mysql_error());
27}
28
29$urls = array();
30
31while ($row = mysql_fetch_assoc($result)) {
32	$url = validateURL($row['url'], false);
33
34	if (is_null($url)) {
35		continue;
36	}
37
38	$urls[] = $url;
39}
40mysql_free_result($result);
41
42echo implode("\n", $urls);
43