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