root/dev/common/search.php @ 92

Revision 92, 3.5 KB (checked in by exi, 16 years ago)

Updated about page for 1.2.
Made table bgcolor black for alliance images.
Made table bgcolor black for corp images.
The parser now reparsers dupes and deletes comments on killmail deletion.
Changed parser to output some error messages if he doesn't like the mail.
Added conversion code for those funny german mailheader.
Fixed bugs #3 and #4.
Included a fix from Coni to class.ship.php.
Removed the error for unknown solar systems, this is now covered by the parser itself.
Now ordering comments by date.
Fixed db.php:getRow to return false in case of a non valid mysql resource id.
Added the sql killmail limit for home.php.
Added default width/heigth for pictures in kill details.
The searchpage will now redirect you to your hit if it only gets one serach result.

Line 
1<?php
2require_once("db.php");
3require_once("class.page.php");
4require_once("globals.php");
5
6$page = new Page("Search");
7
8$html .= "<form id=search action=\"?a=search\" method=post>";
9$html .= "<table class=kb-subtable><tr>";
10$html .= "<td>Type:</td><td>Text: (3 letters minimum)</td>";
11$html .= "</tr><tr>";
12$html .= "<td><select id=searchtype name=searchtype><option value=pilot>Pilot</option><option value=corp>Corporation</option><option value=alliance>Alliance</option></select></td>";
13$html .= "<td><input id=searchphrase name=searchphrase type=text size=30/></td>";
14$html .= "<td><input type=submit name=submit value=Search></td>";
15$html .= "</tr></table>";
16$html .= "</form>";
17
18if ($_REQUEST['searchphrase'] != "" && strlen($_REQUEST['searchphrase']) >= 3)
19{
20    switch ($_REQUEST['searchtype'])
21    {
22        case "pilot":
23            $sql = "select plt.plt_id, plt.plt_name, crp.crp_name
24                  from kb3_pilots plt, kb3_corps crp
25                 where lower( plt.plt_name ) like lower( '%".slashfix($_REQUEST['searchphrase'])."%' )
26                   and plt.plt_crp_id = crp.crp_id
27                 order by plt.plt_name";
28            $header = "<td>Pilot</td><td>Corporation</td>";
29            break;
30        case "corp":
31            $sql = "select crp.crp_id, crp.crp_name, ali.all_name
32                  from kb3_corps crp, kb3_alliances ali
33                 where lower( crp.crp_name ) like lower( '%".slashfix($_REQUEST['searchphrase'])."%' )
34                   and crp.crp_all_id = ali.all_id
35                 order by crp.crp_name";
36            $header = "<td>Corporation</td><td>Alliance</td>";
37            break;
38        case "alliance":
39            $sql = "select ali.all_id, ali.all_name
40                  from kb3_alliances ali
41                 where lower( ali.all_name ) like lower( '%".slashfix($_REQUEST['searchphrase'])."%' )
42                 order by ali.all_name";
43            $header = "<td>Alliance</td><td></td>";
44            break;
45    }
46
47    $qry = new DBQuery();
48    if (!$qry->execute($sql))
49    {
50        die ($qry->getErrorMsg());
51    }
52
53    $html .= "<div class=block-header>Search results</div>";
54
55    if ($qry->recordCount() > 0)
56    {
57        $html .= "<table class=kb-table width=450 cellspacing=1>";
58        $html .= "<tr class=kb-table-header>".$header."</tr>";
59    }
60    else
61    {
62        $html .= "No results.";
63    }
64
65    while ($row = $qry->getRow())
66    {
67        $html .= "<tr class=kb-table-row-even>";
68        switch ($_REQUEST['searchtype'])
69        {
70            case "pilot":
71                $link = "?a=pilot_detail&plt_id=".$row['plt_id'];
72                $html .= "<td><a href=\"$link\">".$row['plt_name']."</a></td><td>".$row['crp_name']."</td>";
73                break;
74            case "corp":
75                $link = "?a=corp_detail&crp_id=".$row['crp_id'];
76                $html .= "<td><a href=\"$link\">".$row['crp_name']."</a></td><td>".$row['all_name']."</td>";
77                break;
78            case "alliance":
79                $link = "?a=alliance_detail&all_id=".$row['all_id'];
80                $html .= "<td><a href=\"$link\">".$row['all_name']."</a></td><td></td>";
81                break;
82        }
83        $html .= "</tr>";
84        if ($qry->recordCount() == 1)
85        {
86            // if there is only one entry we redirect the user directly
87            header("Location: $link");
88        }
89    }
90    if ($qry->recordCount() > 0)
91    {
92        $html .= "</table>";
93    }
94}
95
96$page->setContent($html);
97$page->generate();
98?>
Note: See TracBrowser for help on using the browser.