root/dev/common/search.php @ 190

Revision 190, 3.5 KB (checked in by exi, 15 years ago)

This is a big update...
Moved all admin scripts to common/admin.
Moved all includes and classes to common/includes.
Edited all include-paths to reflect the movement.
Fixed a bug with the session system allowing every registered user to access admin pages.
Replaced calls to date() to use a wrapper so gmdate can be used.
Replaced some calls to $config with calls to the static object.
Fixed a big which caused the portrait_grab to not download a new picute.
Added a classified-state to kills.
Removed the sync_server server script in this tree.
Added code to help modules find the includes to index.php.

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