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