3 require('inc.header.php');
5 function showform () // Audio search form {{{
6 { global $self, $config; ?
>
7 <form action
="<?php echo $self; ?>" method
="get">
8 <b
>Audio search
</b
><br
>
10 <li
>Track name
<input type
="text" name
="search_trackname"> Exact
<input type
="checkbox" name
="search_exact">
11 <li
>Min length
<input type
="text" name
="search_minlength" size
="8"> Max length
<input type
="text" name
="search_maxlength" size
="8">
12 <li
>CD Title
<input type
="text" name
="search_cd"> Exact
<input type
="checkbox" name
="search_cdexact">
13 <?php
if ($config['use_categories']) { ?
>
15 <select name
="search_category">
16 <option value
="">Any category
</option
>
17 <option value
="">--</option
>
18 <?php
mb_fetch_select_categories(4); ?
>
22 <input type
="submit" value
="Search">
28 if (isset($_GET['search_trackname']) && strlen($_GET['search_trackname']) > 0) {
29 if (isset($_GET['search_exact'])) {
30 $where[] = "t.name = '".addslashes($_GET['search_trackname'])."'";
32 $where[] = "t.name LIKE '%".addslashes($_GET['search_trackname'])."%'";
35 if (isset($_GET['search_minlength'])) {
36 if (is_numeric($_GET['search_minlength'])) {
37 $where[] = "t.length >= ".$_GET['search_minlength'];
38 } elseif ((list($min,$sec) = explode(':',$_GET['search_minlength'],2)) && is_numeric($min) && is_numeric($sec)) {
40 $where[] = "t.length >= $sec";
43 if (isset($_GET['search_maxlength'])) {
44 if (is_numeric($_GET['search_maxlength'])) {
45 $where[] = "t.length <= ".$_GET['search_maxlength'];
46 } elseif ((list($min,$sec) = explode(':',$_GET['search_maxlength'],2)) && is_numeric($min) && is_numeric($sec)) {
48 $where[] = "t.length <= $sec";
51 if (isset($_GET['search_cd']) && strlen($_GET['search_cd']) > 0) {
52 if (isset($_GET['search_cdexact'])) {
53 $where[] = "m.name = '".addslashes($_GET['search_cd'])."'";
55 $where[] = "m.name LIKE '%".addslashes($_GET['search_cd'])."%'";
60 if (count($where) > 0) {
62 $tables = $config['tbl_tracks']." AS t, ".$config['tbl_media']." AS m";
63 $where[] = 't.mediaid = m.mediaid';
64 $cols = 't.trackid, t.name, t.length, m.mediaid, m.name as medianame';
65 if ($config['use_categories']) {
66 $tables .= ", ".$config['tbl_categories']." AS c";
67 $cols .= ", c.catid, c.name as catname";
68 $where[] = 'm.catid = c.catid';
69 $headers[] = 'Category';
71 $query = "SELECT $cols FROM $tables WHERE ".implode(' AND ',$where);
72 if (!$res = mysql_query($query)) {
73 echo "<b>Error:</b> ".mysql_error()." <i>(".basename(__FILE__
).", line ".__LINE__
.")</i>\n\n";
75 if (!$count = mysql_num_rows($res)) {
76 echo "Found no tracks matching your query.\n\n";
78 $pl = $count > 1 ?
's' : '';
79 echo "Found $count track$pl matching your query.\n<br><br>\n";
82 if ($config['use_categories']) {
83 mb_table_start('Track #','Track Name','Length','CD','Category');
85 mb_table_start('Track #','Track Name','Length','CD');
88 while ($row = mysql_fetch_array($res)) {
89 mb_table_col($row['trackid']);
90 mb_table_col($row['name']);
91 mb_table_col(mb_lengthtext($row['length']));
92 mb_table_col('<a href="index.php?media='.$row['mediaid'].'">'.$row['medianame'].'</a>');
93 if ($config['use_categories']) {
94 mb_table_col('<a href="index.php?cat='.$row['catid'].'">'.$row['catname'].'</a>');
102 echo "<p><a href=\"$self\">New search</a>\n";
107 require('inc.footer.php');