Merge commit 'upstream/master'
[platform/kernel/u-boot.git] / tools / bddb / doedit.php
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
7         // doedit page (hymod_bddb / boards)
8
9         require("defs.php");
10
11         pg_head("$bddb_label - Edit Board Results");
12
13         if (!isset($_REQUEST['serno']) || $_REQUEST['serno'] == '')
14                 die("the board serial number was not specified");
15         $serno=intval($_REQUEST['serno']);
16
17         $query="update boards set";
18
19         if (isset($_REQUEST['ethaddr'])) {
20                 $ethaddr=$_REQUEST['ethaddr'];
21                 if (!eth_addr_is_valid($ethaddr))
22                         die("ethaddr is invalid ('$ethaddr')");
23                 $query.=" ethaddr='$ethaddr',";
24         }
25
26         if (isset($_REQUEST['date'])) {
27                 $date=$_REQUEST['date'];
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
35         if (isset($_REQUEST['batch'])) {
36                 $batch=$_REQUEST['batch'];
37                 if (strlen($batch) > 32)
38                         die("batch field too long (>32)");
39                 $query.=", batch='$batch'";
40         }
41
42         if (isset($_REQUEST['type'])) {
43                 $type=$_REQUEST['type'];
44                 if (!in_array($type, $type_vals))
45                         die("Invalid type ($type) specified");
46                 $query.=", type='$type'";
47         }
48
49         if (isset($_REQUEST['rev'])) {
50                 $rev=$_REQUEST['rev'];
51                 if (($rev = intval($rev)) <= 0 || $rev > 255)
52                         die("Revision number is invalid ($rev)");
53                 $query.=sprintf(", rev=%d", $rev);
54         }
55
56         if (isset($_REQUEST['location'])) {
57                 $location=$_REQUEST['location'];
58                 if (strlen($location) > 64)
59                         die("location field too long (>64)");
60                 $query.=", location='$location'";
61         }
62
63         if (isset($_REQUEST['comments']))
64                 $comments=$_REQUEST['comments'];
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
88         if (isset($_REQUEST['cputyp'])) {
89                 $cputyp=$_REQUEST['cputyp'];
90                 $query.=", cputyp='$cputyp'";
91                 if (!isset($_REQUEST['cpuspd']) || $_REQUEST['cpuspd'] == '')
92                         die("must specify cpu speed if cpu type is defined");
93                 $cpuspd=$_REQUEST['cpuspd'];
94                 $query.=", cpuspd='$cpuspd'";
95                 if (!isset($_REQUEST['cpmspd']) || $_REQUEST['cpmspd'] == '')
96                         die("must specify cpm speed if cpu type is defined");
97                 $cpmspd=$_REQUEST['cpmspd'];
98                 $query.=", cpmspd='$cpmspd'";
99                 if (!isset($_REQUEST['busspd']) || $_REQUEST['busspd'] == '')
100                         die("must specify bus speed if cpu type is defined");
101                 $busspd=$_REQUEST['busspd'];
102                 $query.=", busspd='$busspd'";
103         }
104         else {
105                 if (isset($_REQUEST['cpuspd']))
106                         die("can't specify cpu speed if there is no cpu");
107                 if (isset($_REQUEST['cpmspd']))
108                         die("can't specify cpm speed if there is no cpu");
109                 if (isset($_REQUEST['busspd']))
110                         die("can't specify bus speed if there is no cpu");
111         }
112
113         if (isset($_REQUEST['hschin'])) {
114                 $hschin=$_REQUEST['hschin'];
115                 if (($hschin = intval($hschin)) < 0 || $hschin > 4)
116                         die("Invalid number of hs input chans ($hschin)");
117         }
118         else
119                 $hschin = 0;
120         if (isset($_REQUEST['hschout'])) {
121                 $hschout=$_REQUEST['hschout'];
122                 if (($hschout = intval($hschout)) < 0 || $hschout > 4)
123                         die("Invalid number of hs output chans ($hschout)");
124         }
125         else
126                 $hschout = 0;
127         if (isset($_REQUEST['hstype'])) {
128                 $hstype=$_REQUEST['hstype'];
129                 $query.=", hstype='$hstype'";
130         }
131         else {
132                 if ($_REQUEST['hschin'] != 0)
133                         die("number of high-speed input channels must be zero"
134                                 . " if high-speed chip is not present");
135                 if ($_REQUEST['hschout'] != 0)
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 ?>