diff options
author | Wolfgang Denk <wd@pollux.denx.de> | 2005-08-12 23:27:18 +0200 |
---|---|---|
committer | Wolfgang Denk <wd@pollux.denx.de> | 2005-08-12 23:27:18 +0200 |
commit | d992daf99d1ce39ee18b353b67fdfa181d83fbff (patch) | |
tree | a9b5f98b73706e024bc7cd7a14ca2674bd75a55c /tools/bddb/browse.php | |
parent | f9d77ed38031fa29d1495bf3cfee385450463f5b (diff) | |
download | u-boot-imx-d992daf99d1ce39ee18b353b67fdfa181d83fbff.zip u-boot-imx-d992daf99d1ce39ee18b353b67fdfa181d83fbff.tar.gz u-boot-imx-d992daf99d1ce39ee18b353b67fdfa181d83fbff.tar.bz2 |
Update Hymod Board Database PHP code in "tools" directory
Patch by Murray Jensen, 01 Jul 2005
Diffstat (limited to 'tools/bddb/browse.php')
-rw-r--r-- | tools/bddb/browse.php | 53 |
1 files changed, 35 insertions, 18 deletions
diff --git a/tools/bddb/browse.php b/tools/bddb/browse.php index 0e94f7d..675dfab 100644 --- a/tools/bddb/browse.php +++ b/tools/bddb/browse.php @@ -8,29 +8,31 @@ require("defs.php"); - if (!isset($verbose)) - $verbose = 0; + $serno=isset($_REQUEST['serno'])?$_REQUEST['serno']:''; - if (!isset($serno)) - $serno = 0; + $verbose=isset($_REQUEST['verbose'])?intval($_REQUEST['verbose']):0; pg_head("$bddb_label - Browse database" . ($verbose?" (verbose)":"")); ?> <p></p> <?php - if ($serno == 0) { - $limit=abs(isset($limit)?$limit:20); - $offset=abs(isset($offset)?$offset:0); + $limit=isset($_REQUEST['limit'])?abs(intval($_REQUEST['limit'])):20; + $offset=isset($_REQUEST['offset'])?abs(intval($_REQUEST['offset'])):0; + + if ($serno == '') { + $lr=mysql_query("select count(*) as n from boards"); $lrow=mysql_fetch_array($lr); + if($lrow['n']>$limit){ $preoffset=max(0,$offset-$limit); $postoffset=$offset+$limit; - echo "<table width=\"100%\">\n<tr align=center>\n"; - printf("<td><%sa href=\"%s?offset=%d\"><img border=0 alt=\"<\" src=\"/icons/left.gif\"></a></td>\n", $offset>0?"":"no", $PHP_SELF, $preoffset); - printf("<td><%sa href=\"%s?offset=%d\"><img border=0 alt=\">\" src=\"/icons/right.gif\"></a></td>\n", $postoffset<$lrow['n']?"":"no", $PHP_SELF, $postoffset); + echo "<table width=\"100%\">\n<tr>\n"; + printf("<td align=left><%sa href=\"%s?submit=Browse&offset=%d&verbose=%d\"><img border=0 alt=\"<\" src=\"/icons/left.gif\"></a></td>\n", $offset>0?"":"no", $PHP_SELF, $preoffset, $verbose); + printf("<td align=right><%sa href=\"%s?submit=Browse&offset=%d&verbose=%d\"><img border=0 alt=\">\" src=\"/icons/right.gif\"></a></td>\n", $postoffset<$lrow['n']?"":"no", $PHP_SELF, $postoffset, $offset); echo "</tr>\n</table>\n"; } + mysql_free_result($lr); } ?> @@ -65,10 +67,28 @@ ?> </tr> <?php - if ($serno == 0) - $r=mysql_query("select * from boards order by serno limit $offset,$limit"); - else - $r=mysql_query("select * from boards where serno=$serno"); + $query = "select * from boards"; + if ($serno != '') { + $pre = " where "; + foreach (preg_split("/[\s,]+/", $serno) as $s) { + if (preg_match('/^[0-9]+$/',$s)) + $query .= $pre . "serno=" . $s; + else if (preg_match('/^([0-9]+)-([0-9]+)$/',$s,$m)) { + $m1 = intval($m[1]); $m2 = intval($m[2]); + if ($m2 <= $m1) + die("bad serial number range ($s)"); + $query .= $pre . "(serno>=$m[1] and serno<=$m[2])"; + } + else + die("illegal serial number ($s)"); + $pre = " or "; + } + } + $query .= " order by serno"; + if ($serno == '') + $query .= " limit $offset,$limit"; + + $r = mysql_query($query); function print_cell($str) { if ($str == '') @@ -117,10 +137,7 @@ <table width="100%"> <tr> <td align=center><?php - if ($verbose) - echo "<a href=\"browse.php?verbose=0\">Terse Listing</a>"; - else - echo "<a href=\"browse.php?verbose=1\">Verbose Listing</a>"; + printf("<a href=\"%s?submit=Browse&offset=%d&verbose=%d%s\">%s Listing</a>\n", $PHP_SELF, $offset, $verbose?0:1, $serno!=''?"&serno=$serno":'', $verbose?"Terse":"Verbose"); ?></td> <td align=center><a href="index.php">Back to Start</a></td> </tr> |