doedit.php 5.1 KB

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