PageRenderTime 50ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/sc7731_u-boot/tools/bddb/donew.php

https://gitlab.com/envieidoc/sprd_project
PHP | 230 lines | 186 code | 40 blank | 4 comment | 36 complexity | fade37318d71da1954295d8665166ea4 MD5 | raw file
  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 - Board Registration Results");
  9. if (isset($_REQUEST['serno'])) {
  10. $serno=$_REQUEST['serno'];
  11. die("serial number must not be set ($serno) when Creating!");
  12. }
  13. $query="update boards set";
  14. list($y, $m, $d) = split("-", $date);
  15. if (!checkdate($m, $d, $y) || $y < 1999)
  16. die("date is invalid (input '$date', yyyy-mm-dd '$y-$m-$d')");
  17. $query.=" date='$date'";
  18. if ($batch != '') {
  19. if (strlen($batch) > 32)
  20. die("batch field too long (>32)");
  21. $query.=", batch='$batch'";
  22. }
  23. if (!in_array($type, $type_vals))
  24. die("Invalid type ($type) specified");
  25. $query.=", type='$type'";
  26. if (($rev = intval($rev)) <= 0 || $rev > 255)
  27. die("Revision number is invalid ($rev)");
  28. $query.=sprintf(", rev=%d", $rev);
  29. $query.=gather_enum_multi_query("sdram", 4);
  30. $query.=gather_enum_multi_query("flash", 4);
  31. $query.=gather_enum_multi_query("zbt", 16);
  32. $query.=gather_enum_multi_query("xlxtyp", 4);
  33. $nxlx = count_enum_multi("xlxtyp", 4);
  34. $query.=gather_enum_multi_query("xlxspd", 4);
  35. if (count_enum_multi("xlxspd", 4) != $nxlx)
  36. die("number of xilinx speeds not same as number of types");
  37. $query.=gather_enum_multi_query("xlxtmp", 4);
  38. if (count_enum_multi("xlxtmp", 4) != $nxlx)
  39. die("number of xilinx temps. not same as number of types");
  40. $query.=gather_enum_multi_query("xlxgrd", 4);
  41. if (count_enum_multi("xlxgrd", 4) != $nxlx)
  42. die("number of xilinx grades not same as number of types");
  43. if ($cputyp == '') {
  44. if ($cpuspd != '')
  45. die("can't specify cpu speed if there is no cpu");
  46. if ($cpmspd != '')
  47. die("can't specify cpm speed if there is no cpu");
  48. if ($busspd != '')
  49. die("can't specify bus speed if there is no cpu");
  50. }
  51. else {
  52. $query.=", cputyp='$cputyp'";
  53. if ($cpuspd == '')
  54. die("must specify cpu speed if cpu type is defined");
  55. $query.=", cpuspd='$cpuspd'";
  56. if ($cpmspd == '')
  57. die("must specify cpm speed if cpu type is defined");
  58. $query.=", cpmspd='$cpmspd'";
  59. if ($busspd == '')
  60. die("must specify bus speed if cpu type is defined");
  61. $query.=", busspd='$busspd'";
  62. }
  63. if (($hschin = intval($hschin)) < 0 || $hschin > 4)
  64. die("Invalid number of hs input chans ($hschin)");
  65. if (($hschout = intval($hschout)) < 0 || $hschout > 4)
  66. die("Invalid number of hs output chans ($hschout)");
  67. if ($hstype == '') {
  68. if ($hschin != 0)
  69. die("number of high-speed input channels must be zero"
  70. . " if high-speed chip is not present");
  71. if ($hschout != 0)
  72. die("number of high-speed output channels must be zero"
  73. . " if high-speed chip is not present");
  74. }
  75. else
  76. $query.=", hstype='$hstype'";
  77. $query.=", hschin='$hschin'";
  78. $query.=", hschout='$hschout'";
  79. // echo "final query = '$query'<br>\n";
  80. $quant = intval($quant);
  81. if ($quant <= 0) $quant = 1;
  82. $sernos = array();
  83. if ($geneths)
  84. $ethaddrs = array();
  85. $sqlerr = '';
  86. while ($quant-- > 0) {
  87. mysql_query("insert into boards (serno) values (null)");
  88. if (mysql_errno()) {
  89. $sqlerr = mysql_error();
  90. break;
  91. }
  92. $serno = mysql_insert_id();
  93. if (!$serno) {
  94. $sqlerr = "couldn't allocate new serial number";
  95. break;
  96. }
  97. mysql_query($query . " where serno=$serno");
  98. if (mysql_errno()) {
  99. $sqlerr = mysql_error();
  100. break;
  101. }
  102. array_push($sernos, $serno);
  103. if ($geneths) {
  104. $ethaddr = gen_eth_addr($serno);
  105. mysql_query("update boards set ethaddr='$ethaddr'" .
  106. " where serno=$serno");
  107. if (mysql_errno()) {
  108. $sqlerr = mysql_error();
  109. array_push($ethaddrs,
  110. "<font color=#ff0000><b>" .
  111. "db save fail" .
  112. "</b></font>");
  113. break;
  114. }
  115. array_push($ethaddrs, $ethaddr);
  116. }
  117. }
  118. $nsernos = count($sernos);
  119. if ($nsernos > 0) {
  120. write_eeprom_cfg_file();
  121. echo "<font size=+2>\n";
  122. echo "\t<p>\n";
  123. echo "\t\tThe following board serial numbers were"
  124. . " successfully allocated";
  125. if ($numerrs > 0)
  126. echo " (but with $numerrs cfg file error" .
  127. ($numerrs > 1 ? "s" : "") . ")";
  128. echo ":\n";
  129. echo "\t</p>\n";
  130. echo "</font>\n";
  131. echo "<table align=center width=\"100%\">\n";
  132. echo "<tr>\n";
  133. echo "\t<th>Serial Number</th>\n";
  134. if ($numerrs > 0)
  135. echo "\t<th>Cfg File Errs</th>\n";
  136. if ($geneths)
  137. echo "\t<th>Ethernet Address</th>\n";
  138. echo "</tr>\n";
  139. for ($i = 0; $i < $nsernos; $i++) {
  140. $serno = sprintf("%010d", $sernos[$i]);
  141. echo "<tr>\n";
  142. echo "\t<td align=center><font size=+2>" .
  143. "<b>$serno</b></font></td>\n";
  144. if ($numerrs > 0) {
  145. if (($errstr = $cfgerrs[$i]) == '')
  146. $errstr = '&nbsp;';
  147. echo "\t<td align=center>" .
  148. "<font size=+2 color=#ff0000><b>" .
  149. $errstr .
  150. "</b></font></td>\n";
  151. }
  152. if ($geneths) {
  153. echo "\t<td align=center>" .
  154. "<font size=+2 color=#00ff00><b>" .
  155. $ethaddrs[$i] .
  156. "</b></font></td>\n";
  157. }
  158. echo "</tr>\n";
  159. }
  160. echo "</table>\n";
  161. }
  162. if ($sqlerr != '') {
  163. echo "\t<font size=+4>\n";
  164. echo "\t\t<p>\n";
  165. echo "\t\t\tThe following SQL error was encountered:\n";
  166. echo "\t\t</p>\n";
  167. echo "\t\t<center>\n";
  168. printf("\t\t\t<b>%s</b>\n", $sqlerr);
  169. echo "\t\t</center>\n";
  170. echo "\t</font>\n";
  171. }
  172. ?>
  173. <p>
  174. <table align=center width="100%">
  175. <tr>
  176. <td align=center><a href="browse.php">Go to Browse</a></td>
  177. <td align=center><a href="index.php">Back to Start</a></td>
  178. </tr>
  179. </table>
  180. <?php
  181. pg_foot();
  182. ?>