wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 1 | <?php // php pages made with phpMyBuilder <http://kyber.dk/phpMyBuilder> ?> |
| 2 | <?php |
| 3 | // (C) Copyright 2001 |
Wolfgang Denk | b3b0fd5 | 2005-08-12 23:20:59 +0200 | [diff] [blame] | 4 | // Murray Jensen <Murray.Jensen@csiro.au> |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 5 | // 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 Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 13 | if (!isset($_REQUEST['serno']) || $_REQUEST['serno'] == '') |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 14 | die("the board serial number was not specified"); |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 15 | $serno=intval($_REQUEST['serno']); |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 16 | |
| 17 | $query="update boards set"; |
| 18 | |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 19 | if (isset($_REQUEST['ethaddr'])) { |
| 20 | $ethaddr=$_REQUEST['ethaddr']; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 21 | if (!eth_addr_is_valid($ethaddr)) |
| 22 | die("ethaddr is invalid ('$ethaddr')"); |
| 23 | $query.=" ethaddr='$ethaddr',"; |
| 24 | } |
| 25 | |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 26 | if (isset($_REQUEST['date'])) { |
| 27 | $date=$_REQUEST['date']; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 28 | 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 Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 35 | if (isset($_REQUEST['batch'])) { |
| 36 | $batch=$_REQUEST['batch']; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 37 | if (strlen($batch) > 32) |
| 38 | die("batch field too long (>32)"); |
| 39 | $query.=", batch='$batch'"; |
| 40 | } |
| 41 | |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 42 | if (isset($_REQUEST['type'])) { |
| 43 | $type=$_REQUEST['type']; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 44 | if (!in_array($type, $type_vals)) |
| 45 | die("Invalid type ($type) specified"); |
| 46 | $query.=", type='$type'"; |
| 47 | } |
| 48 | |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 49 | if (isset($_REQUEST['rev'])) { |
| 50 | $rev=$_REQUEST['rev']; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 51 | if (($rev = intval($rev)) <= 0 || $rev > 255) |
| 52 | die("Revision number is invalid ($rev)"); |
| 53 | $query.=sprintf(", rev=%d", $rev); |
| 54 | } |
| 55 | |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 56 | if (isset($_REQUEST['location'])) { |
| 57 | $location=$_REQUEST['location']; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 58 | if (strlen($location) > 64) |
| 59 | die("location field too long (>64)"); |
| 60 | $query.=", location='$location'"; |
| 61 | } |
| 62 | |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 63 | if (isset($_REQUEST['comments'])) |
| 64 | $comments=$_REQUEST['comments']; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 65 | $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 Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 88 | if (isset($_REQUEST['cputyp'])) { |
| 89 | $cputyp=$_REQUEST['cputyp']; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 90 | $query.=", cputyp='$cputyp'"; |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 91 | if (!isset($_REQUEST['cpuspd']) || $_REQUEST['cpuspd'] == '') |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 92 | die("must specify cpu speed if cpu type is defined"); |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 93 | $cpuspd=$_REQUEST['cpuspd']; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 94 | $query.=", cpuspd='$cpuspd'"; |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 95 | if (!isset($_REQUEST['cpmspd']) || $_REQUEST['cpmspd'] == '') |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 96 | die("must specify cpm speed if cpu type is defined"); |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 97 | $cpmspd=$_REQUEST['cpmspd']; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 98 | $query.=", cpmspd='$cpmspd'"; |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 99 | if (!isset($_REQUEST['busspd']) || $_REQUEST['busspd'] == '') |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 100 | die("must specify bus speed if cpu type is defined"); |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 101 | $busspd=$_REQUEST['busspd']; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 102 | $query.=", busspd='$busspd'"; |
| 103 | } |
| 104 | else { |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 105 | if (isset($_REQUEST['cpuspd'])) |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 106 | die("can't specify cpu speed if there is no cpu"); |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 107 | if (isset($_REQUEST['cpmspd'])) |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 108 | die("can't specify cpm speed if there is no cpu"); |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 109 | if (isset($_REQUEST['busspd'])) |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 110 | die("can't specify bus speed if there is no cpu"); |
| 111 | } |
| 112 | |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 113 | if (isset($_REQUEST['hschin'])) { |
| 114 | $hschin=$_REQUEST['hschin']; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 115 | if (($hschin = intval($hschin)) < 0 || $hschin > 4) |
| 116 | die("Invalid number of hs input chans ($hschin)"); |
| 117 | } |
| 118 | else |
| 119 | $hschin = 0; |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 120 | if (isset($_REQUEST['hschout'])) { |
| 121 | $hschout=$_REQUEST['hschout']; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 122 | if (($hschout = intval($hschout)) < 0 || $hschout > 4) |
| 123 | die("Invalid number of hs output chans ($hschout)"); |
| 124 | } |
| 125 | else |
| 126 | $hschout = 0; |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 127 | if (isset($_REQUEST['hstype'])) { |
| 128 | $hstype=$_REQUEST['hstype']; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 129 | $query.=", hstype='$hstype'"; |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 130 | } |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 131 | else { |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 132 | if ($_REQUEST['hschin'] != 0) |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 133 | die("number of high-speed input channels must be zero" |
| 134 | . " if high-speed chip is not present"); |
Wolfgang Denk | d992daf | 2005-08-12 23:27:18 +0200 | [diff] [blame] | 135 | if ($_REQUEST['hschout'] != 0) |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 136 | 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 | ?> |