PageRenderTime 26ms CodeModel.GetById 21ms RepoModel.GetById 1ms 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
  2. require_once(dirname(__FILE__).'/global.php');
  3. header('Content-type: text/plain');
  4. // whatever to display all URLs or only new ones, just recently added
  5. $new = false;
  6. if (array_key_exists('new', $_GET)) {
  7. $new = true;
  8. }
  9. if ($new) {
  10. $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()";
  11. foreach ($all_metrics as $provider_name => $provider) {
  12. $query .= " AND ".$provider['table'].'_last_id IS NULL';
  13. }
  14. $query = sprintf($query, $monitoringPeriod);
  15. } else {
  16. $query = "SELECT DISTINCT url FROM urls INNER JOIN user_urls on user_urls.url_id = urls.id";
  17. }
  18. $result = mysql_query($query);
  19. if (!$result) {
  20. error_log(mysql_error());
  21. }
  22. $urls = array();
  23. while ($row = mysql_fetch_assoc($result)) {
  24. $url = validateURL($row['url'], false);
  25. if (is_null($url)) {
  26. continue;
  27. }
  28. $urls[] = $url;
  29. }
  30. mysql_free_result($result);
  31. echo implode("\n", $urls);