browse.php 4.1 KB

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