doedit.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. // doedit page (hymod_bddb / boards)
  7. require("defs.php");
  8. pg_head("$bddb_label - Edit Board Results");
  9. if ($serno == 0)
  10. die("the board serial number was not specified");
  11. $query="update boards set";
  12. if (isset($ethaddr)) {
  13. if (!eth_addr_is_valid($ethaddr))
  14. die("ethaddr is invalid ('$ethaddr')");
  15. $query.=" ethaddr='$ethaddr',";
  16. }
  17. if (isset($date)) {
  18. list($y, $m, $d) = split("-", $date);
  19. if (!checkdate($m, $d, $y) || $y < 1999)
  20. die("date is invalid (input '$date', " .
  21. "yyyy-mm-dd '$y-$m-$d')");
  22. $query.=" date='$date'";
  23. }
  24. if (isset($batch)) {
  25. if (strlen($batch) > 32)
  26. die("batch field too long (>32)");
  27. $query.=", batch='$batch'";
  28. }
  29. if (isset($type)) {
  30. if (!in_array($type, $type_vals))
  31. die("Invalid type ($type) specified");
  32. $query.=", type='$type'";
  33. }
  34. if (isset($rev)) {
  35. if (($rev = intval($rev)) <= 0 || $rev > 255)
  36. die("Revision number is invalid ($rev)");
  37. $query.=sprintf(", rev=%d", $rev);
  38. }
  39. if (isset($location)) {
  40. if (strlen($location) > 64)
  41. die("location field too long (>64)");
  42. $query.=", location='$location'";
  43. }
  44. if (isset($comments))
  45. $query.=", comments='" . rawurlencode($comments) . "'";
  46. $query.=gather_enum_multi_query("sdram", 4);
  47. $query.=gather_enum_multi_query("flash", 4);
  48. $query.=gather_enum_multi_query("zbt", 16);
  49. $query.=gather_enum_multi_query("xlxtyp", 4);
  50. $nxlx = count_enum_multi("xlxtyp", 4);
  51. $query.=gather_enum_multi_query("xlxspd", 4);
  52. if (count_enum_multi("xlxspd", 4) != $nxlx)
  53. die("number of xilinx speeds not same as number of types");
  54. $query.=gather_enum_multi_query("xlxtmp", 4);
  55. if (count_enum_multi("xlxtmp", 4) != $nxlx)
  56. die("number of xilinx temps. not same as number of types");
  57. $query.=gather_enum_multi_query("xlxgrd", 4);
  58. if (count_enum_multi("xlxgrd", 4) != $nxlx)
  59. die("number of xilinx grades not same as number of types");
  60. if (isset($cputyp)) {
  61. $query.=", cputyp='$cputyp'";
  62. if ($cpuspd == '')
  63. die("must specify cpu speed if cpu type is defined");
  64. $query.=", cpuspd='$cpuspd'";
  65. if ($cpmspd == '')
  66. die("must specify cpm speed if cpu type is defined");
  67. $query.=", cpmspd='$cpmspd'";
  68. if ($busspd == '')
  69. die("must specify bus speed if cpu type is defined");
  70. $query.=", busspd='$busspd'";
  71. }
  72. else {
  73. if (isset($cpuspd))
  74. die("can't specify cpu speed if there is no cpu");
  75. if (isset($cpmspd))
  76. die("can't specify cpm speed if there is no cpu");
  77. if (isset($busspd))
  78. die("can't specify bus speed if there is no cpu");
  79. }
  80. if (isset($hschin)) {
  81. if (($hschin = intval($hschin)) < 0 || $hschin > 4)
  82. die("Invalid number of hs input chans ($hschin)");
  83. }
  84. else
  85. $hschin = 0;
  86. if (isset($hschout)) {
  87. if (($hschout = intval($hschout)) < 0 || $hschout > 4)
  88. die("Invalid number of hs output chans ($hschout)");
  89. }
  90. else
  91. $hschout = 0;
  92. if (isset($hstype))
  93. $query.=", hstype='$hstype'";
  94. else {
  95. if ($hschin != 0)
  96. die("number of high-speed input channels must be zero"
  97. . " if high-speed chip is not present");
  98. if ($hschout != 0)
  99. die("number of high-speed output channels must be zero"
  100. . " if high-speed chip is not present");
  101. }
  102. $query.=", hschin='$hschin'";
  103. $query.=", hschout='$hschout'";
  104. $query.=" where serno=$serno";
  105. mysql_query($query);
  106. if(mysql_errno()) {
  107. $errstr = mysql_error();
  108. echo "\t<font size=+4>\n";
  109. echo "\t\t<p>\n";
  110. echo "\t\t\tThe following error was encountered:\n";
  111. echo "\t\t</p>\n";
  112. echo "\t\t<center>\n";
  113. printf("\t\t\t<b>%s</b>\n", $errstr);
  114. echo "\t\t</center>\n";
  115. echo "\t</font>\n";
  116. }
  117. else {
  118. $sernos = array($serno);
  119. $nsernos = 1;
  120. write_eeprom_cfg_file();
  121. echo "\t<font size=+2>\n";
  122. echo "\t\t<p>\n";
  123. echo "\t\t\tThe board with serial number <b>$serno</b> was"
  124. . " successfully updated";
  125. if ($numerrs > 0) {
  126. $errstr = $cfgerrs[0];
  127. echo "<br>\n\t\t\t";
  128. echo "(but the cfg file update failed: $errstr)";
  129. }
  130. echo "\n";
  131. echo "\t\t</p>\n";
  132. echo "\t</font>\n";
  133. }
  134. ?>
  135. <p>
  136. <table align=center width="100%">
  137. <tr>
  138. <td align=center><a href="browse.php">Back to Browse</a></td>
  139. <td align=center><a href="index.php">Back to Start</a></td>
  140. </tr>
  141. </table>
  142. <?php
  143. pg_foot();
  144. ?>