wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 1 | <?php // php pages made with phpMyBuilder <http://kyber.dk/phpMyBuilder> ?> |
| 2 | <?php |
| 3 | // (C) Copyright 2001 |
Wolfgang Denk | b3b0fd5 | 2005-08-12 23:20:59 +0200 | [diff] [blame] | 4 | // Murray Jensen <Murray.Jensen@csiro.au> |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 5 | // CSIRO Manufacturing Science and Technology, Preston Lab |
| 6 | |
| 7 | // list page (hymod_bddb / boards) |
| 8 | |
| 9 | require("defs.php"); |
| 10 | |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 11 | $serno=isset($_REQUEST['serno'])?$_REQUEST['serno']:''; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 12 | |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 13 | $verbose=isset($_REQUEST['verbose'])?intval($_REQUEST['verbose']):0; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 14 | |
| 15 | pg_head("$bddb_label - Browse database" . ($verbose?" (verbose)":"")); |
| 16 | ?> |
| 17 | <p></p> |
| 18 | <?php |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 19 | $limit=isset($_REQUEST['limit'])?abs(intval($_REQUEST['limit'])):20; |
| 20 | $offset=isset($_REQUEST['offset'])?abs(intval($_REQUEST['offset'])):0; |
| 21 | |
| 22 | if ($serno == '') { |
| 23 | |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 24 | $lr=mysql_query("select count(*) as n from boards"); |
| 25 | $lrow=mysql_fetch_array($lr); |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 26 | |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 27 | if($lrow['n']>$limit){ |
| 28 | $preoffset=max(0,$offset-$limit); |
| 29 | $postoffset=$offset+$limit; |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 30 | echo "<table width=\"100%\">\n<tr>\n"; |
| 31 | printf("<td align=left><%sa href=\"%s?submit=Browse&offset=%d&verbose=%d\"><img border=0 alt=\"<\" src=\"/icons/left.gif\"></a></td>\n", $offset>0?"":"no", $PHP_SELF, $preoffset, $verbose); |
| 32 | printf("<td align=right><%sa href=\"%s?submit=Browse&offset=%d&verbose=%d\"><img border=0 alt=\">\" src=\"/icons/right.gif\"></a></td>\n", $postoffset<$lrow['n']?"":"no", $PHP_SELF, $postoffset, $offset); |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 33 | echo "</tr>\n</table>\n"; |
| 34 | } |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 35 | |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 36 | mysql_free_result($lr); |
| 37 | } |
| 38 | ?> |
| 39 | <table align=center border=1 cellpadding=10> |
| 40 | <tr> |
| 41 | <th></th> |
| 42 | <th>serno / edit</th> |
| 43 | <th>ethaddr</th> |
| 44 | <th>date</th> |
| 45 | <th>batch</th> |
| 46 | <th>type</th> |
| 47 | <th>rev</th> |
| 48 | <th>location</th> |
| 49 | <?php |
| 50 | if ($verbose) { |
| 51 | echo "<th>comments</th>\n"; |
| 52 | echo "<th>sdram</th>\n"; |
| 53 | echo "<th>flash</th>\n"; |
| 54 | echo "<th>zbt</th>\n"; |
| 55 | echo "<th>xlxtyp</th>\n"; |
| 56 | echo "<th>xlxspd</th>\n"; |
| 57 | echo "<th>xlxtmp</th>\n"; |
| 58 | echo "<th>xlxgrd</th>\n"; |
| 59 | echo "<th>cputyp</th>\n"; |
| 60 | echo "<th>cpuspd</th>\n"; |
| 61 | echo "<th>cpmspd</th>\n"; |
| 62 | echo "<th>busspd</th>\n"; |
| 63 | echo "<th>hstype</th>\n"; |
| 64 | echo "<th>hschin</th>\n"; |
| 65 | echo "<th>hschout</th>\n"; |
| 66 | } |
| 67 | ?> |
| 68 | </tr> |
| 69 | <?php |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 70 | $query = "select * from boards"; |
| 71 | if ($serno != '') { |
| 72 | $pre = " where "; |
| 73 | foreach (preg_split("/[\s,]+/", $serno) as $s) { |
| 74 | if (preg_match('/^[0-9]+$/',$s)) |
| 75 | $query .= $pre . "serno=" . $s; |
| 76 | else if (preg_match('/^([0-9]+)-([0-9]+)$/',$s,$m)) { |
| 77 | $m1 = intval($m[1]); $m2 = intval($m[2]); |
| 78 | if ($m2 <= $m1) |
| 79 | die("bad serial number range ($s)"); |
| 80 | $query .= $pre . "(serno>=$m[1] and serno<=$m[2])"; |
| 81 | } |
| 82 | else |
| 83 | die("illegal serial number ($s)"); |
| 84 | $pre = " or "; |
| 85 | } |
| 86 | } |
| 87 | $query .= " order by serno"; |
| 88 | if ($serno == '') |
| 89 | $query .= " limit $offset,$limit"; |
| 90 | |
| 91 | $r = mysql_query($query); |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 92 | |
| 93 | function print_cell($str) { |
| 94 | if ($str == '') |
| 95 | $str = ' '; |
| 96 | echo "\t<td>$str</td>\n"; |
| 97 | } |
| 98 | |
| 99 | while($row=mysql_fetch_array($r)){ |
| 100 | foreach ($columns as $key) { |
| 101 | if (!key_in_array($key, $row)) |
| 102 | $row[$key] = ''; |
| 103 | } |
| 104 | |
| 105 | echo "<tr>\n"; |
| 106 | print_cell("<a href=\"brlog.php?serno=$row[serno]\">Log</a>"); |
| 107 | print_cell("<a href=\"edit.php?serno=$row[serno]\">$row[serno]</a>"); |
| 108 | print_cell($row['ethaddr']); |
| 109 | print_cell($row['date']); |
| 110 | print_cell($row['batch']); |
| 111 | print_cell($row['type']); |
| 112 | print_cell($row['rev']); |
| 113 | print_cell($row['location']); |
| 114 | if ($verbose) { |
| 115 | print_cell("<pre>\n" . urldecode($row['comments']) . |
| 116 | "\n\t</pre>"); |
| 117 | print_cell(gather_enum_multi_print("sdram", 4, $row)); |
| 118 | print_cell(gather_enum_multi_print("flash", 4, $row)); |
| 119 | print_cell(gather_enum_multi_print("zbt", 16, $row)); |
| 120 | print_cell(gather_enum_multi_print("xlxtyp", 4, $row)); |
| 121 | print_cell(gather_enum_multi_print("xlxspd", 4, $row)); |
| 122 | print_cell(gather_enum_multi_print("xlxtmp", 4, $row)); |
| 123 | print_cell(gather_enum_multi_print("xlxgrd", 4, $row)); |
| 124 | print_cell($row['cputyp']); |
| 125 | print_cell($row['cpuspd']); |
| 126 | print_cell($row['cpmspd']); |
| 127 | print_cell($row['busspd']); |
| 128 | print_cell($row['hstype']); |
| 129 | print_cell($row['hschin']); |
| 130 | print_cell($row['hschout']); |
| 131 | } |
| 132 | echo "</tr>\n"; |
| 133 | } |
| 134 | ?> |
| 135 | </table> |
| 136 | <p></p> |
| 137 | <table width="100%"> |
| 138 | <tr> |
| 139 | <td align=center><?php |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 140 | printf("<a href=\"%s?submit=Browse&offset=%d&verbose=%d%s\">%s Listing</a>\n", $PHP_SELF, $offset, $verbose?0:1, $serno!=''?"&serno=$serno":'', $verbose?"Terse":"Verbose"); |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 141 | ?></td> |
| 142 | <td align=center><a href="index.php">Back to Start</a></td> |
| 143 | </tr> |
| 144 | </table> |
| 145 | <?php |
| 146 | pg_foot(); |
| 147 | ?> |