blob: 13fbb694790f7a775d1a7acaaf270d05c6df4d66 [file] [log] [blame]
wdenkfe8c2802002-11-03 00:38:21 +00001<?php // php pages made with phpMyBuilder <http://kyber.dk/phpMyBuilder> ?>
2<?php
3 // (C) Copyright 2001
Wolfgang Denk2c9dfca2005-08-12 23:20:59 +02004 // Murray Jensen <Murray.Jensen@csiro.au>
wdenkfe8c2802002-11-03 00:38:21 +00005 // CSIRO Manufacturing Science and Technology, Preston Lab
6
7 // doedit page (hymod_bddb / boards)
8
9 require("defs.php");
10
11 pg_head("$bddb_label - Edit Board Results");
12
Wolfgang Denk804ecb12005-08-12 23:27:18 +020013 if (!isset($_REQUEST['serno']) || $_REQUEST['serno'] == '')
wdenkfe8c2802002-11-03 00:38:21 +000014 die("the board serial number was not specified");
Wolfgang Denk804ecb12005-08-12 23:27:18 +020015 $serno=intval($_REQUEST['serno']);
wdenkfe8c2802002-11-03 00:38:21 +000016
17 $query="update boards set";
18
Wolfgang Denk804ecb12005-08-12 23:27:18 +020019 if (isset($_REQUEST['ethaddr'])) {
20 $ethaddr=$_REQUEST['ethaddr'];
wdenkfe8c2802002-11-03 00:38:21 +000021 if (!eth_addr_is_valid($ethaddr))
22 die("ethaddr is invalid ('$ethaddr')");
23 $query.=" ethaddr='$ethaddr',";
24 }
25
Wolfgang Denk804ecb12005-08-12 23:27:18 +020026 if (isset($_REQUEST['date'])) {
27 $date=$_REQUEST['date'];
wdenkfe8c2802002-11-03 00:38:21 +000028 list($y, $m, $d) = split("-", $date);
29 if (!checkdate($m, $d, $y) || $y < 1999)
30 die("date is invalid (input '$date', " .
31 "yyyy-mm-dd '$y-$m-$d')");
32 $query.=" date='$date'";
33 }
34
Wolfgang Denk804ecb12005-08-12 23:27:18 +020035 if (isset($_REQUEST['batch'])) {
36 $batch=$_REQUEST['batch'];
wdenkfe8c2802002-11-03 00:38:21 +000037 if (strlen($batch) > 32)
38 die("batch field too long (>32)");
39 $query.=", batch='$batch'";
40 }
41
Wolfgang Denk804ecb12005-08-12 23:27:18 +020042 if (isset($_REQUEST['type'])) {
43 $type=$_REQUEST['type'];
wdenkfe8c2802002-11-03 00:38:21 +000044 if (!in_array($type, $type_vals))
45 die("Invalid type ($type) specified");
46 $query.=", type='$type'";
47 }
48
Wolfgang Denk804ecb12005-08-12 23:27:18 +020049 if (isset($_REQUEST['rev'])) {
50 $rev=$_REQUEST['rev'];
wdenkfe8c2802002-11-03 00:38:21 +000051 if (($rev = intval($rev)) <= 0 || $rev > 255)
52 die("Revision number is invalid ($rev)");
53 $query.=sprintf(", rev=%d", $rev);
54 }
55
Wolfgang Denk804ecb12005-08-12 23:27:18 +020056 if (isset($_REQUEST['location'])) {
57 $location=$_REQUEST['location'];
wdenkfe8c2802002-11-03 00:38:21 +000058 if (strlen($location) > 64)
59 die("location field too long (>64)");
60 $query.=", location='$location'";
61 }
62
Wolfgang Denk804ecb12005-08-12 23:27:18 +020063 if (isset($_REQUEST['comments']))
64 $comments=$_REQUEST['comments'];
wdenkfe8c2802002-11-03 00:38:21 +000065 $query.=", comments='" . rawurlencode($comments) . "'";
66
67 $query.=gather_enum_multi_query("sdram", 4);
68
69 $query.=gather_enum_multi_query("flash", 4);
70
71 $query.=gather_enum_multi_query("zbt", 16);
72
73 $query.=gather_enum_multi_query("xlxtyp", 4);
74 $nxlx = count_enum_multi("xlxtyp", 4);
75
76 $query.=gather_enum_multi_query("xlxspd", 4);
77 if (count_enum_multi("xlxspd", 4) != $nxlx)
78 die("number of xilinx speeds not same as number of types");
79
80 $query.=gather_enum_multi_query("xlxtmp", 4);
81 if (count_enum_multi("xlxtmp", 4) != $nxlx)
82 die("number of xilinx temps. not same as number of types");
83
84 $query.=gather_enum_multi_query("xlxgrd", 4);
85 if (count_enum_multi("xlxgrd", 4) != $nxlx)
86 die("number of xilinx grades not same as number of types");
87
Wolfgang Denk804ecb12005-08-12 23:27:18 +020088 if (isset($_REQUEST['cputyp'])) {
89 $cputyp=$_REQUEST['cputyp'];
wdenkfe8c2802002-11-03 00:38:21 +000090 $query.=", cputyp='$cputyp'";
Wolfgang Denk804ecb12005-08-12 23:27:18 +020091 if (!isset($_REQUEST['cpuspd']) || $_REQUEST['cpuspd'] == '')
wdenkfe8c2802002-11-03 00:38:21 +000092 die("must specify cpu speed if cpu type is defined");
Wolfgang Denk804ecb12005-08-12 23:27:18 +020093 $cpuspd=$_REQUEST['cpuspd'];
wdenkfe8c2802002-11-03 00:38:21 +000094 $query.=", cpuspd='$cpuspd'";
Wolfgang Denk804ecb12005-08-12 23:27:18 +020095 if (!isset($_REQUEST['cpmspd']) || $_REQUEST['cpmspd'] == '')
wdenkfe8c2802002-11-03 00:38:21 +000096 die("must specify cpm speed if cpu type is defined");
Wolfgang Denk804ecb12005-08-12 23:27:18 +020097 $cpmspd=$_REQUEST['cpmspd'];
wdenkfe8c2802002-11-03 00:38:21 +000098 $query.=", cpmspd='$cpmspd'";
Wolfgang Denk804ecb12005-08-12 23:27:18 +020099 if (!isset($_REQUEST['busspd']) || $_REQUEST['busspd'] == '')
wdenkfe8c2802002-11-03 00:38:21 +0000100 die("must specify bus speed if cpu type is defined");
Wolfgang Denk804ecb12005-08-12 23:27:18 +0200101 $busspd=$_REQUEST['busspd'];
wdenkfe8c2802002-11-03 00:38:21 +0000102 $query.=", busspd='$busspd'";
103 }
104 else {
Wolfgang Denk804ecb12005-08-12 23:27:18 +0200105 if (isset($_REQUEST['cpuspd']))
wdenkfe8c2802002-11-03 00:38:21 +0000106 die("can't specify cpu speed if there is no cpu");
Wolfgang Denk804ecb12005-08-12 23:27:18 +0200107 if (isset($_REQUEST['cpmspd']))
wdenkfe8c2802002-11-03 00:38:21 +0000108 die("can't specify cpm speed if there is no cpu");
Wolfgang Denk804ecb12005-08-12 23:27:18 +0200109 if (isset($_REQUEST['busspd']))
wdenkfe8c2802002-11-03 00:38:21 +0000110 die("can't specify bus speed if there is no cpu");
111 }
112
Wolfgang Denk804ecb12005-08-12 23:27:18 +0200113 if (isset($_REQUEST['hschin'])) {
114 $hschin=$_REQUEST['hschin'];
wdenkfe8c2802002-11-03 00:38:21 +0000115 if (($hschin = intval($hschin)) < 0 || $hschin > 4)
116 die("Invalid number of hs input chans ($hschin)");
117 }
118 else
119 $hschin = 0;
Wolfgang Denk804ecb12005-08-12 23:27:18 +0200120 if (isset($_REQUEST['hschout'])) {
121 $hschout=$_REQUEST['hschout'];
wdenkfe8c2802002-11-03 00:38:21 +0000122 if (($hschout = intval($hschout)) < 0 || $hschout > 4)
123 die("Invalid number of hs output chans ($hschout)");
124 }
125 else
126 $hschout = 0;
Wolfgang Denk804ecb12005-08-12 23:27:18 +0200127 if (isset($_REQUEST['hstype'])) {
128 $hstype=$_REQUEST['hstype'];
wdenkfe8c2802002-11-03 00:38:21 +0000129 $query.=", hstype='$hstype'";
Wolfgang Denk804ecb12005-08-12 23:27:18 +0200130 }
wdenkfe8c2802002-11-03 00:38:21 +0000131 else {
Wolfgang Denk804ecb12005-08-12 23:27:18 +0200132 if ($_REQUEST['hschin'] != 0)
wdenkfe8c2802002-11-03 00:38:21 +0000133 die("number of high-speed input channels must be zero"
134 . " if high-speed chip is not present");
Wolfgang Denk804ecb12005-08-12 23:27:18 +0200135 if ($_REQUEST['hschout'] != 0)
wdenkfe8c2802002-11-03 00:38:21 +0000136 die("number of high-speed output channels must be zero"
137 . " if high-speed chip is not present");
138 }
139 $query.=", hschin='$hschin'";
140 $query.=", hschout='$hschout'";
141
142 $query.=" where serno=$serno";
143
144 mysql_query($query);
145 if(mysql_errno()) {
146 $errstr = mysql_error();
147 echo "\t<font size=+4>\n";
148 echo "\t\t<p>\n";
149 echo "\t\t\tThe following error was encountered:\n";
150 echo "\t\t</p>\n";
151 echo "\t\t<center>\n";
152 printf("\t\t\t<b>%s</b>\n", $errstr);
153 echo "\t\t</center>\n";
154 echo "\t</font>\n";
155 }
156 else {
157 $sernos = array($serno);
158 $nsernos = 1;
159
160 write_eeprom_cfg_file();
161
162 echo "\t<font size=+2>\n";
163 echo "\t\t<p>\n";
164 echo "\t\t\tThe board with serial number <b>$serno</b> was"
165 . " successfully updated";
166 if ($numerrs > 0) {
167 $errstr = $cfgerrs[0];
168 echo "<br>\n\t\t\t";
169 echo "(but the cfg file update failed: $errstr)";
170 }
171 echo "\n";
172 echo "\t\t</p>\n";
173 echo "\t</font>\n";
174 }
175
176?>
177<p>
178<table align=center width="100%">
179<tr>
180 <td align=center><a href="browse.php">Back to Browse</a></td>
181 <td align=center><a href="index.php">Back to Start</a></td>
182</tr>
183</table>
184<?php
185 pg_foot();
186?>