?? defs.php
字號:
<?php // php pages made with phpMyBuilder <http://kyber.dk/phpMyBuilder> ?><?php // (C) Copyright 2001 // Murray Jensen <Murray.Jensen@csiro.au> // CSIRO Manufacturing Science and Technology, Preston Lab // contains mysql user id and password - keep secret require("config.php"); if (isset($_REQUEST['logout'])) { Header("status: 401 Unauthorized"); Header("HTTP/1.0 401 Unauthorized"); Header("WWW-authenticate: basic realm=\"$bddb_label\""); echo "<html><head><title>" . "Access to '$bddb_label' Denied" . "</title></head>\n"; echo "<body bgcolor=#ffffff><br></br><br></br><center><h1>" . "You must be an Authorised User " . "to access the '$bddb_label'" . "</h1>\n</center></body></html>\n"; exit; } // contents of the various enumerated types - if first item is // empty ('') then the enum is allowed to be null (ie "not null" // is not set on the column) // all column names in the database table $columns = array( 'serno','ethaddr','date','batch', 'type','rev','location','comments', 'sdram0','sdram1','sdram2','sdram3', 'flash0','flash1','flash2','flash3', 'zbt0','zbt1','zbt2','zbt3','zbt4','zbt5','zbt6','zbt7', 'zbt8','zbt9','zbta','zbtb','zbtc','zbtd','zbte','zbtf', 'xlxtyp0','xlxtyp1','xlxtyp2','xlxtyp3', 'xlxspd0','xlxspd1','xlxspd2','xlxspd3', 'xlxtmp0','xlxtmp1','xlxtmp2','xlxtmp3', 'xlxgrd0','xlxgrd1','xlxgrd2','xlxgrd3', 'cputyp','cpuspd','cpmspd','busspd', 'hstype','hschin','hschout' ); // board type $type_vals = array('IO','CLP','DSP','INPUT','ALT-INPUT','DISPLAY'); // Xilinx fpga types $xlxtyp_vals = array('','XCV300E','XCV400E','XCV600E','XC2V2000','XC2V3000','XC2V4000','XC2V6000','XC2VP2','XC2VP4','XC2VP7','XC2VP20','XC2VP30','XC2VP50','XC4VFX20','XC4VFX40','XC4VFX60','XC4VFX100','XC4VFX140'); // Xilinx fpga speeds $xlxspd_vals = array('','6','7','8','4','5','9','10','11','12'); // Xilinx fpga temperatures (commercial or industrial) $xlxtmp_vals = array('','COM','IND'); // Xilinx fpga grades (normal or engineering sample) $xlxgrd_vals = array('','NORMAL','ENGSAMP'); // CPU types $cputyp_vals = array('','MPC8260(HIP3)','MPC8260A(HIP4)','MPC8280(HIP7)','MPC8560'); // CPU/BUS/CPM clock speeds $clk_vals = array('','33MHZ','66MHZ','100MHZ','133MHZ','166MHZ','200MHZ','233MHZ','266MHZ','300MHZ','333MHZ','366MHZ','400MHZ','433MHZ','466MHZ','500MHZ','533MHZ','566MHZ','600MHZ','633MHZ','666MHZ','700MHZ','733MHZ','766MHZ','800MHZ','833MHZ','866MHZ','900MHZ','933MHZ','966MHZ','1000MHZ','1033MHZ','1066MHZ','1100MHZ','1133MHZ','1166MHZ','1200MHZ','1233MHZ','1266MHZ','1300MHZ','1333MHZ'); // sdram sizes (nbits array is for eeprom config file) $sdram_vals = array('','32M','64M','128M','256M','512M','1G','2G','4G'); $sdram_nbits = array(0,25,26,27,28,29,30,31,32); // flash sizes (nbits array is for eeprom config file) $flash_vals = array('','4M','8M','16M','32M','64M','128M','256M','512M','1G'); $flash_nbits = array(0,22,23,24,25,26,27,28,29,30); // zbt ram sizes (nbits array is for write into eeprom config file) $zbt_vals = array('','512K','1M','2M','4M','8M','16M'); $zbt_nbits = array(0,19,20,21,22,23,24); // high-speed serial attributes $hstype_vals = array('','AMCC-S2064A','Xilinx-Rockets'); $hschin_vals = array('0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16'); $hschout_vals = array('0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16'); // value filters - used when outputting html function rev_filter($num) { if ($num == 0) return "001"; else return sprintf("%03d", $num); } function text_filter($str) { return urldecode($str); } mt_srand(time() | getmypid()); // set up MySQL connection mysql_connect("", $mysql_user, $mysql_pw) || die("cannot connect"); mysql_select_db($mysql_db) || die("cannot select db"); // page header function pg_head($title) { echo "<html>\n<head>\n"; echo "<link rel=stylesheet href=\"bddb.css\" type=\"text/css\" title=\"style sheet\"></link>\n"; echo "<title>$title</title>\n"; echo "</head>\n"; echo "<body>\n"; echo "<center><h1>$title</h1></center>\n"; echo "<hr></hr>\n"; } // page footer function pg_foot() { echo "<hr></hr>\n"; echo "<table width=\"100%\"><tr><td align=left>\n<address>" . "If you have any problems, email " . "<a href=\"mailto:Murray.Jensen@csiro.au\">" . "Murray Jensen" . "</a></address>\n" . "</td><td align=right>\n" . "<a href=\"index.php?logout=true\">logout</a>\n" . "</td></tr></table>\n"; echo "<p><small><i>Made with " . "<a href=\"http://kyber.dk/phpMyBuilder/\">" . "Kyber phpMyBuilder</a></i></small></p>\n"; echo "</body>\n"; echo "</html>\n"; } // some support functions if (!function_exists('array_search')) { function array_search($needle, $haystack, $strict = false) { if (is_array($haystack) && count($haystack)) { $ntype = gettype($needle); foreach ($haystack as $key => $value) { if ($value == $needle && (!$strict || gettype($value) == $ntype)) return $key; } } return false; } } if (!function_exists('in_array')) { function in_array($needle, $haystack, $strict = false) { if (is_array($haystack) && count($haystack)) { $ntype = gettype($needle); foreach ($haystack as $key => $value) { if ($value == $needle && (!$strict || gettype($value) == $ntype)) return true; } } return false; } } function key_in_array($key, $array) { return in_array($key, array_keys($array), true); } function enum_to_index($name, $vals) { $index = array_search($GLOBALS[$name], $vals); if ($vals[0] != '') $index++; return $index; } // fetch a value from an array - return empty string is not present function get_key_value($key, $array) { if (key_in_array($key, $array)) return $array[$key]; else return ''; } function fprintf() { $n = func_num_args(); if ($n < 2) return FALSE; $a = func_get_args(); $fp = array_shift($a); $x = "\$s = sprintf"; $sep = '('; foreach ($a as $z) { $x .= "$sep'$z'"; $sep = ','; } $x .= ');'; eval($x); $l = strlen($s); $r = fwrite($fp, $s, $l); if ($r != $l) return FALSE; else return TRUE; } // functions to display (print) a database table and its columns function begin_table($ncols) { global $table_ncols; $table_ncols = $ncols; echo "<table align=center width=\"100%\"" . " border=1 cellpadding=4 cols=$table_ncols>\n"; } function begin_field($name, $span = 0) { global $table_ncols; echo "<tr valign=top>\n"; echo "\t<th align=center>$name</th>\n"; if ($span <= 0) $span = $table_ncols - 1; if ($span > 1) echo "\t<td colspan=$span>\n"; else echo "\t<td>\n"; } function cont_field($span = 1) { echo "\t</td>\n"; if ($span > 1) echo "\t<td colspan=$span>\n"; else echo "\t<td>\n"; } function end_field() { echo "\t</td>\n"; echo "</tr>\n"; } function end_table() { echo "</table>\n"; } function print_field($name, $array, $size = 0, $filt='') { begin_field($name); if (key_in_array($name, $array)) $value = $array[$name]; else $value = ''; if ($filt != '') $value = $filt($value); echo "\t\t<input name=$name value=\"$value\""; if ($size > 0) echo " size=$size maxlength=$size"; echo "></input>\n"; end_field(); } function print_field_multiline($name, $array, $cols, $rows, $filt='') { begin_field($name); if (key_in_array($name, $array)) $value = $array[$name]; else $value = ''; if ($filt != '') $value = $filt($value); echo "\t\t<textarea name=$name " . "cols=$cols rows=$rows wrap=off>\n"; echo "$value"; echo "</textarea>\n"; end_field(); } // print a mysql ENUM as an html RADIO INPUT function print_enum($name, $array, $vals, $def = -1) { begin_field($name); if (key_in_array($name, $array)) $chk = array_search($array[$name], $vals, FALSE); else $chk = $def; $nval = count($vals); for ($i = 0; $i < $nval; $i++) { $val = $vals[$i]; if ($val == '') $pval = "none"; else $pval = "$val"; printf("\t\t<input type=radio name=$name" . " value=\"$val\"%s>$pval</input>\n", $i == $chk ? " checked" : ""); } end_field(); } // print a mysql ENUM as an html SELECT INPUT function print_enum_select($name, $array, $vals, $def = -1) { begin_field($name); echo "\t\t<select name=$name>\n"; if (key_in_array($name, $array)) $chk = array_search($array[$name], $vals, FALSE); else $chk = $def; $nval = count($vals); for ($i = 0; $i < $nval; $i++) { $val = $vals[$i]; if ($val == '') $pval = "none"; else $pval = "$val"; printf("\t\t\t<option " . "value=\"%s\"%s>%s</option>\n", $val, $i == $chk ? " selected" : "", $pval); } echo "\t\t</select>\n"; end_field(); } // print a group of mysql ENUMs (e.g. name0,name1,...) as an html SELECT function print_enum_multi($base, $array, $vals, $cnt, $defs, $grp = 0) { global $table_ncols;
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -