| [ Index ] |
PHP Cross Reference of Crawler |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * File to output the Crawler's current progress to the browser 4 * 5 * @package Crawler 6 */ 7 ?> 8 <html> 9 <head> 10 <style> 11 body {margin:0; padding: 0;} 12 .form-row {clear:both; width: 100%; padding: 10 0 10 0px; float:left;} 13 .form-label {float:left; width: 60%; text-align: right; padding-right: 10%; font-weight: bold;} 14 .form-field {float:left; width: 30%; } 15 #percent { font-size:50pt; font-weight:bold; text-align:center;} 16 .column {width:33.3%; float:left;} 17 h2 {text-align: center; border-bottom: 1px solid #ccc;} 18 h1 {text-align: center;} 19 table {text-align:right; margin-left:auto; margin-right: auto;} 20 .num-clicks, .codes, .filetypes {font-weight:bold; text-align:center;} 21 th {border-bottom: 1px solid #ccc; font-size:10pt; padding-left: 5px; padding-right: 5px; text-align:center;} 22 .clear {clear:both; border-bottom: 1px solid #ccc; width:100%; padding-top:20px;} 23 </style> 24 <body> 25 <h1>Crawler Statistics</h1> 26 <?php 27 /** 28 * Grab necessary files 29 */ 30 include ('config.php'); 31 include ('includes/functions.php'); 32 include ('includes/mysql_functions.php'); 33 34 /** 35 * Calculate number of crawled and Uncralwed pages 36 * 37 * NOTE TO SELF: This errors out when the crawler finishes 38 * 39 */ 40 $data = mysql_query('SELECT crawled, COUNT(crawled) AS NumOccurrences FROM urls GROUP BY crawled'); 41 $uncrawled = mysql_result($data,0,1); 42 $crawled = mysql_result($data,1,1); 43 $total = $crawled+$uncrawled; 44 $percent = 100 * $crawled / $total; 45 46 ?> 47 <div class='clear'> </div> 48 <div class='column'> 49 50 <h2>Pages Crawled</h2> 51 52 <?php 53 54 while ($row = mysql_fetch_array($data, MYSQL_ASSOC)) {\ 55 printf("Value: %s Count: %s\r\n", $row["crawled"], $row["NumOccurrences"]); 56 $num_crawled[$row["crawled"]] = $row["NumOccurrences"]; 57 } 58 ?> 59 <div class='form-row'> 60 <div class='form-label'> 61 Crawled: 62 </div> 63 <div class='form-field'> 64 <?php echo number_format($crawled); ?> 65 </div> 66 </div> 67 <div class='form-row'> 68 <div class='form-label'> 69 Indexed, but not yet crawled: 70 </div> 71 <div class='form-field'> 72 <?php echo number_format($uncrawled); ?> 73 </div> 74 </div> 75 <div class='form-row'> 76 <div class='form-label'> 77 Total: 78 </div> 79 <div class='form-field'> 80 <?php echo number_format($total); ?> 81 </div> 82 </div> 83 </div> 84 <div class='column'> 85 86 <h2>Estimated Percent Complete</h2> 87 <div id='percent'> 88 <?php echo number_format($percent,2); ?>% 89 </div> 90 </div> 91 92 <div class='column'> 93 94 <h2>Pages Indexed</h2> 95 <table> 96 <tr> 97 <th># of Clicks</th> 98 <th>Count</th> 99 <th>Cumulative Count</th> 100 </tr> 101 <?php 102 $sql = 'SELECT clicks, COUNT(clicks) AS NumOccurrences FROM urls GROUP BY clicks HAVING ( COUNT(clicks) > 0 )'; 103 $clicks = mysql_array(mysql_query($sql)); 104 $cumulative = 0; 105 foreach ($clicks as $click) { $cumulative += $click['NumOccurrences']; ?> 106 <tr> 107 <td class='num-clicks'><?php echo $click['clicks']; ?></td> 108 <td><?php echo number_format($click['NumOccurrences']); ?></td> 109 <td><?php echo number_format($cumulative); ?></td> 110 </tr> 111 <?php } ?> 112 </table> 113 </div> 114 <div class='clear'> </div> 115 116 <div class='column'> 117 <h2>Response Codes</h2> 118 </html> 119 <?php 120 $sql = 'SELECT http_code, COUNT(http_code) AS NumOccurrences FROM urls GROUP BY http_code HAVING ( COUNT(http_code) > 0 )'; 121 $codes = mysql_array(mysql_query($sql)); 122 ?> 123 <table> 124 <tr> 125 <th>Response Code</th> 126 <th>Count</th> 127 </tr> 128 <?php foreach ($codes as $code) { ?> 129 <tr> 130 <td class='codes'> 131 <?php echo $code['http_code']; ?> 132 </td> 133 <td> 134 <?php echo number_format($code['NumOccurrences']); ?> 135 </td> 136 </tr> 137 <?php } ?> 138 </table> 139 </div> 140 141 142 <div class='column'> 143 <h2>Filetypes</h2> 144 </html> 145 <?php 146 $sql = 'SELECT type, COUNT(type) AS NumOccurrences FROM urls GROUP BY type HAVING ( COUNT(type) > 0 ) ORDER BY NumOccurrences DESC'; 147 $types = mysql_array(mysql_query($sql)); 148 ?> 149 <table> 150 <tr> 151 <th>Filetype</th> 152 <th>Count</th> 153 </tr> 154 <?php foreach ($types as $type) { ?> 155 <tr> 156 <td class='fieltype'> 157 <?php echo $type['type']; ?> 158 </td> 159 <td> 160 <?php echo number_format($type['NumOccurrences']); ?> 161 </td> 162 </tr> 163 <?php } ?> 164 </table> 165 </div> 166 167 <div class='column'> 168 <h2>File Sizes</h2> 169 </html> 170 <?php 171 $sql = 'SELECT MAX(size) as max, AVG(size) as avg FROM urls'; 172 $sizes = mysql_row_array(mysql_query($sql)); 173 174 175 ?> 176 <div class='form-row'> 177 <div class='form-label'> 178 Largest File: 179 </div> 180 <div class='form-field'> 181 <?php echo file_size($sizes['max']); ?> 182 </div> 183 </div> 184 <div class='form-row'> 185 <div class='form-label'> 186 Average File Size: 187 </div> 188 <div class='form-field'> 189 <?php echo file_size($sizes['avg']); ?> 190 </div> 191 </div> 192 </div> 193 194 <div class='clear'> </div> 195 <?php 196 $sql = "SELECT title, url FROM urls WHERE crawled = '1' ORDER BY ID DESC LIMIT 1"; 197 $last = mysql_row_array(mysql_query($sql)); 198 ?> 199 <center><b>Last Page Crawled: </b><?php echo $last['title']; ?> (<?php echo $last['url'];?>) </center> 200 </body>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Jun 3 17:10:09 2010 | Cross-referenced by PHPXref 0.7 |