PageRenderTime 33ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/list.php

http://showslow.googlecode.com/
PHP | 162 lines | 142 code | 20 blank | 0 comment | 37 complexity | da8fa29af8ecfe4b74313892a20b6320 MD5 | raw file
  1. <?php
  2. require_once(dirname(__FILE__).'/global.php');
  3. if (!array_key_exists('id', $_GET) || !array_key_exists($_GET['id'], $customLists)) {
  4. header('HTTP/1.0 404 No list found');
  5. ?><html>
  6. <head>
  7. <title>404 No list found</title>
  8. </head>
  9. <body>
  10. <h1>404 No list found</h1>
  11. <p>List with such ID is not defined</p>
  12. </body></html>
  13. <?php
  14. exit;
  15. }
  16. $list_items = $customLists[$_GET['id']]['urls'];
  17. $list = '';
  18. $first = true;
  19. foreach ($list_items as $url) {
  20. if ($first) {
  21. $first = false;
  22. } else {
  23. $list .= ', ';
  24. }
  25. $list .= "'".mysql_real_escape_string($url)."'";
  26. }
  27. $query = sprintf("SELECT url, last_update,
  28. yslow2.o as o,
  29. pagespeed.o as ps_o,
  30. dynatrace.rank as dt_o
  31. FROM urls
  32. LEFT JOIN yslow2 ON urls.yslow2_last_id = yslow2.id
  33. LEFT JOIN pagespeed ON urls.pagespeed_last_id = pagespeed.id
  34. LEFT JOIN dynatrace ON urls.dynatrace_last_id = dynatrace.id
  35. WHERE urls.url IN (%s)", $list);
  36. $result = mysql_query($query);
  37. if (!$result) {
  38. error_log(mysql_error());
  39. }
  40. $yslow = false;
  41. $pagespeed = false;
  42. $dynatrace = false;
  43. $rows = array();
  44. while ($row = mysql_fetch_assoc($result)) {
  45. $rows[$row['url']] = $row;
  46. if (!$yslow && !is_null($row['o'])) {
  47. $yslow = true;
  48. }
  49. if (!$pagespeed && !is_null($row['ps_o'])) {
  50. $pagespeed = true;
  51. }
  52. if (!$dynatrace && !is_null($row['dt_o'])) {
  53. $dynatrace = true;
  54. }
  55. }
  56. $TITLE = $customLists[$_GET['id']]['title'];
  57. $SECTION = 'custom_list_'.$_GET['id'];
  58. require_once(dirname(__FILE__).'/header.php');
  59. ?>
  60. <h1 style="margin-bottom: 0"><?php echo htmlentities($customLists[$_GET['id']]['title'])?></h1>
  61. <p style="margin-top: 0.2em"><?php echo $customLists[$_GET['id']]['description'] ?></p>
  62. <?php if (!is_null($addThisProfile)) {?>
  63. <!-- AddThis Button BEGIN -->
  64. <div class="addthis_toolbox addthis_default_style" style="margin-right: 10px;">
  65. <a href="http://www.addthis.com/bookmark.php?v=250&amp;username=<?php echo urlencode($addThisProfile)?>" class="addthis_button_compact">Share</a>
  66. <span class="addthis_separator">|</span>
  67. <a class="addthis_button_twitter"></a>
  68. <a class="addthis_button_facebook"></a>
  69. <a class="addthis_button_google"></a>
  70. <a class="addthis_button_delicious"></a>
  71. <a class="addthis_button_stumbleupon"></a>
  72. <a class="addthis_button_reddit"></a>
  73. <span class="addthis_separator">|</span>
  74. <a class="addthis_button_favorites"></a>
  75. <a class="addthis_button_print"></a>
  76. <a class="addthis_button_email"></a>
  77. </div>
  78. <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=<?php echo urlencode($addThisProfile)?>"></script>
  79. <!-- AddThis Button END -->
  80. <?php } ?>
  81. <?php
  82. if (count($rows) && ($yslow || $pagespeed || $dynatrace))
  83. {
  84. ?>
  85. <table border="0" style="margin-top: 1em">
  86. <tr style="font-size: smaller; font-weight: bold">
  87. <td style="text-align: left; padding-right: 0.7em">Timestamp</td>
  88. <?php if ($yslow) { ?><th colspan="2">YSlow grade</th><?php } ?>
  89. <?php if ($pagespeed) { ?><th colspan="2">Page Speed score</th><?php } ?>
  90. <?php if ($dynatrace) { ?><th colspan="2">dynaTrace rank</th><?php } ?>
  91. <td style="padding-left: 1em">URL</td>
  92. </tr>
  93. <?php
  94. foreach ($list_items as $url) {
  95. if (!array_key_exists($url, $rows)) {
  96. continue;
  97. }
  98. $row = $rows[$url];
  99. if (is_null($row) || (is_null($row['o']) && is_null($row['ps_o']) && is_null($row['dt_o']))) {
  100. continue;
  101. }
  102. ?><tr>
  103. <?php if ($row['last_update']) { ?>
  104. <td style="text-align: right; padding-right: 1em"><a title="Time of last check for this URL" href="details/?url=<?php echo urlencode($row['url']); ?>"><?php echo htmlentities($row['last_update']); ?></a></td>
  105. <?php if (!$yslow) {?>
  106. <?php }else if (is_null($row['o'])) {?>
  107. <td class="score" style="color: silver" title="No data collected">no data</td>
  108. <td><div class="gbox" title="No data collected"><div class="bar"/></div></td>
  109. <?php }else{?>
  110. <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>
  111. <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>
  112. <?php }?>
  113. <?php if (!$pagespeed) {?>
  114. <?php }else if (is_null($row['ps_o'])) {?>
  115. <td class="score" style="color: silver" title="No data collected">no data</td>
  116. <td><div class="gbox" title="No data collected"><div class="bar"/></div></td>
  117. <?php }else{?>
  118. <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>
  119. <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>
  120. <?php }?>
  121. <?php if (!$dynatrace) {?>
  122. <?php }else if (is_null($row['dt_o'])) {?>
  123. <td class="score" style="color: silver" title="No data collected">no data</td>
  124. <td><div class="gbox" title="No data collected"><div class="bar"/></div></td>
  125. <?php }else{?>
  126. <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>
  127. <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>
  128. <?php }?>
  129. <td style="padding-left: 1em; overflow: hidden; white-space: nowrap;"><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>
  130. <?php } else { ?>
  131. <td style="text-align: right; padding-right: 1em"><i title="added to the testing queue">queued</i></td>
  132. <td colspan="4"/>
  133. <td style="padding-left: 1em; overflow: hidden; white-space: nowrap;"><i title="Time of last check for this URL"><?php echo htmlentities(substr($row['url'], 0, 100))?><?php if (strlen($row['url']) > 100) { ?>...<?php } ?></i></td>
  134. <?php } ?>
  135. </tr><?php
  136. }
  137. mysql_free_result($result);
  138. ?>
  139. </table>
  140. <?php
  141. }
  142. require_once(dirname(__FILE__).'/footer.php');