1 <?php // php pages made with phpMyBuilder <http://kyber.dk/phpMyBuilder> ?>
4 // Murray Jensen <Murray.Jensen@csiro.au>
5 // CSIRO Manufacturing Science and Technology, Preston Lab
7 // doedit page (hymod_bddb / boards)
11 pg_head("$bddb_label - Board Registration Results");
13 if (isset($_REQUEST['serno'])) {
14 $serno=$_REQUEST['serno'];
15 die("serial number must not be set ($serno) when Creating!");
18 $query="update boards set";
20 list($y, $m, $d) = split("-", $date);
21 if (!checkdate($m, $d, $y) || $y < 1999)
22 die("date is invalid (input '$date', yyyy-mm-dd '$y-$m-$d')");
23 $query.=" date='$date'";
26 if (strlen($batch) > 32)
27 die("batch field too long (>32)");
28 $query.=", batch='$batch'";
31 if (!in_array($type, $type_vals))
32 die("Invalid type ($type) specified");
33 $query.=", type='$type'";
35 if (($rev = intval($rev)) <= 0 || $rev > 255)
36 die("Revision number is invalid ($rev)");
37 $query.=sprintf(", rev=%d", $rev);
39 $query.=gather_enum_multi_query("sdram", 4);
41 $query.=gather_enum_multi_query("flash", 4);
43 $query.=gather_enum_multi_query("zbt", 16);
45 $query.=gather_enum_multi_query("xlxtyp", 4);
46 $nxlx = count_enum_multi("xlxtyp", 4);
48 $query.=gather_enum_multi_query("xlxspd", 4);
49 if (count_enum_multi("xlxspd", 4) != $nxlx)
50 die("number of xilinx speeds not same as number of types");
52 $query.=gather_enum_multi_query("xlxtmp", 4);
53 if (count_enum_multi("xlxtmp", 4) != $nxlx)
54 die("number of xilinx temps. not same as number of types");
56 $query.=gather_enum_multi_query("xlxgrd", 4);
57 if (count_enum_multi("xlxgrd", 4) != $nxlx)
58 die("number of xilinx grades not same as number of types");
62 die("can't specify cpu speed if there is no cpu");
64 die("can't specify cpm speed if there is no cpu");
66 die("can't specify bus speed if there is no cpu");
69 $query.=", cputyp='$cputyp'";
71 die("must specify cpu speed if cpu type is defined");
72 $query.=", cpuspd='$cpuspd'";
74 die("must specify cpm speed if cpu type is defined");
75 $query.=", cpmspd='$cpmspd'";
77 die("must specify bus speed if cpu type is defined");
78 $query.=", busspd='$busspd'";
81 if (($hschin = intval($hschin)) < 0 || $hschin > 4)
82 die("Invalid number of hs input chans ($hschin)");
83 if (($hschout = intval($hschout)) < 0 || $hschout > 4)
84 die("Invalid number of hs output chans ($hschout)");
87 die("number of high-speed input channels must be zero"
88 . " if high-speed chip is not present");
90 die("number of high-speed output channels must be zero"
91 . " if high-speed chip is not present");
94 $query.=", hstype='$hstype'";
95 $query.=", hschin='$hschin'";
96 $query.=", hschout='$hschout'";
98 // echo "final query = '$query'<br>\n";
100 $quant = intval($quant);
101 if ($quant <= 0) $quant = 1;
109 while ($quant-- > 0) {
111 mysql_query("insert into boards (serno) values (null)");
113 $sqlerr = mysql_error();
117 $serno = mysql_insert_id();
119 $sqlerr = "couldn't allocate new serial number";
123 mysql_query($query . " where serno=$serno");
125 $sqlerr = mysql_error();
129 array_push($sernos, $serno);
133 $ethaddr = gen_eth_addr($serno);
135 mysql_query("update boards set ethaddr='$ethaddr'" .
136 " where serno=$serno");
138 $sqlerr = mysql_error();
140 array_push($ethaddrs,
141 "<font color=#ff0000><b>" .
147 array_push($ethaddrs, $ethaddr);
151 $nsernos = count($sernos);
155 write_eeprom_cfg_file();
157 echo "<font size=+2>\n";
159 echo "\t\tThe following board serial numbers were"
160 . " successfully allocated";
162 echo " (but with $numerrs cfg file error" .
163 ($numerrs > 1 ? "s" : "") . ")";
169 echo "<table align=center width=\"100%\">\n";
171 echo "\t<th>Serial Number</th>\n";
173 echo "\t<th>Cfg File Errs</th>\n";
175 echo "\t<th>Ethernet Address</th>\n";
178 for ($i = 0; $i < $nsernos; $i++) {
180 $serno = sprintf("%010d", $sernos[$i]);
184 echo "\t<td align=center><font size=+2>" .
185 "<b>$serno</b></font></td>\n";
188 if (($errstr = $cfgerrs[$i]) == '')
190 echo "\t<td align=center>" .
191 "<font size=+2 color=#ff0000><b>" .
193 "</b></font></td>\n";
197 echo "\t<td align=center>" .
198 "<font size=+2 color=#00ff00><b>" .
200 "</b></font></td>\n";
210 echo "\t<font size=+4>\n";
212 echo "\t\t\tThe following SQL error was encountered:\n";
214 echo "\t\t<center>\n";
215 printf("\t\t\t<b>%s</b>\n", $sqlerr);
216 echo "\t\t</center>\n";
222 <table align=center width="100%">
224 <td align=center><a href="browse.php">Go to Browse</a></td>
225 <td align=center><a href="index.php">Back to Start</a></td>