PageRenderTime 92ms CodeModel.GetById 70ms app.highlight 8ms RepoModel.GetById 12ms app.codeStats 0ms

/index.php

http://showslow.googlecode.com/
PHP | 102 lines | 86 code | 16 blank | 0 comment | 22 complexity | 861afbf46451fe683f5c66840cd5feb1 MD5 | raw file
  1<?php 
  2require_once(dirname(__FILE__).'/global.php');
  3require_once(dirname(__FILE__).'/users/users.php');
  4
  5$SECTION = 'home';
  6require_once(dirname(__FILE__).'/header.php');
  7
  8echo $ShowSlowIntro;
  9?>
 10<hr size="1"/>
 11<div style="width: 100%; overflow: hidden">
 12<?php 
 13$query = sprintf("SELECT url, last_update,
 14		yslow2.o as o,
 15		pagespeed.o as ps_o,
 16		dynatrace.rank as dt_o
 17	FROM urls
 18		LEFT JOIN yslow2 ON urls.yslow2_last_id = yslow2.id
 19		LEFT JOIN pagespeed ON urls.pagespeed_last_id = pagespeed.id
 20		LEFT JOIN dynatrace ON urls.dynatrace_last_id = dynatrace.id
 21	WHERE last_update IS NOT NULL ORDER BY urls.last_update DESC LIMIT 100");
 22$result = mysql_query($query);
 23
 24if (!$result) {
 25	error_log(mysql_error());
 26}
 27
 28$yslow = false;
 29$pagespeed = false;
 30$dynatrace = false;
 31
 32$rows = array();
 33while ($row = mysql_fetch_assoc($result)) {
 34	$rows[] = $row;
 35
 36	if (!$yslow && !is_null($row['o'])) {
 37		$yslow = true;
 38	}
 39	if (!$pagespeed && !is_null($row['ps_o'])) {
 40		$pagespeed = true;
 41	}
 42	if (!$dynatrace && !is_null($row['dt_o'])) {
 43		$dynatrace = true;
 44	}
 45}
 46
 47if ($yslow || $pagespeed || $dynatrace) {
 48
 49?><table>
 50<tr><th>Timestamp</th>
 51<?php if ($yslow) { ?><th colspan="2">YSlow grade</th><?php } ?>
 52<?php if ($pagespeed) { ?><th colspan="2">Page Speed score</th><?php } ?>
 53<?php if ($dynatrace) { ?><th colspan="2">dynaTrace rank</th><?php } ?>
 54<th style="padding-left:10px; text-align: left">URL</th>
 55</tr><?php
 56
 57foreach ($rows as $row) {
 58	?><tr>
 59		<td><?php echo htmlentities($row['last_update'])?></td>
 60
 61	<?php if (!$yslow) {?>
 62	<?php }else if (is_null($row['o'])) {?>
 63		<td class="score" style="color: silver" title="No data collected">no data</td>
 64		<td><div class="gbox" title="No data collected"><div class="bar"/></div></td>
 65	<?php }else{?>
 66		<td class="score" title="Current YSlow grade: <?php echo prettyScore($row['o'])?> (<?php echo $row['o']?>)"><?php echo prettyScore($row['o'])?> (<?php echo $row['o']?>)</td>
 67		<td title="Current YSlow grade: <?php echo prettyScore($row['o'])?> (<?php echo $row['o']?>)"><div class="gbox"><div style="width: <?php echo $row['o']+1?>px" class="bar c<?php echo scoreColorStep($row['o'])?>"/></div></td>
 68	<?php }?>
 69
 70	<?php if (!$pagespeed) {?>
 71	<?php }else if (is_null($row['ps_o'])) {?>
 72		<td class="score" style="color: silver" title="No data collected">no data</td>
 73		<td><div class="gbox" title="No data collected"><div class="bar"/></div></td>
 74	<?php }else{?>
 75		<td class="score" title="Current Page Speed score: <?php echo prettyScore($row['ps_o'])?> (<?php echo $row['ps_o']?>)"><?php echo prettyScore($row['ps_o'])?> (<?php echo $row['ps_o']?>)</td>
 76		<td title="Current Page Speed score: <?php echo prettyScore($row['ps_o'])?> (<?php echo $row['ps_o']?>)"><div class="gbox"><div style="width: <?php echo $row['ps_o']+1?>px" class="bar c<?php echo scoreColorStep($row['ps_o'])?>"/></div></td>
 77	<?php }?>
 78
 79	<?php if (!$dynatrace) {?>
 80	<?php }else if (is_null($row['dt_o'])) {?>
 81		<td class="score" style="color: silver" title="No data collected">no data</td>
 82		<td><div class="gbox" title="No data collected"><div class="bar"/></div></td>
 83	<?php }else{?>
 84		<td class="score" title="Current dynaTrace score: <?php echo prettyScore($row['dt_o'])?> (<?php echo $row['dt_o']?>)"><?php echo prettyScore($row['dt_o'])?> (<?php echo $row['dt_o']?>)</td>
 85		<td title="Current dynaTrace score: <?php echo prettyScore($row['dt_o'])?> (<?php echo $row['dt_o']?>)"><div class="gbox"><div style="width: <?php echo $row['dt_o']+1?>px" class="bar c<?php echo scoreColorStep($row['dt_o'])?>"/></div></td>
 86	<?php }?>
 87
 88	<td class="url"><a href="details/?url=<?php echo urlencode($row['url'])?>"><?php echo htmlentities(substr($row['url'], 0, 100))?><?php if (strlen($row['url']) > 100) { ?>...<?php } ?></a></td>
 89	</tr><?php 
 90}
 91
 92mysql_free_result($result);
 93?>
 94</table>
 95
 96<?php } else { ?>
 97<p>No data is gathered yet</p>
 98<?php }?>
 99
100</div>
101<?php
102require_once(dirname(__FILE__).'/footer.php');