root/dev/install/install_step5.php @ 215

Revision 165, 5.8 KB (checked in by exi, 14 years ago)

Added options to show loss and totalpoints in pilot details.
Tidied up class.box.php.
class.kill.php now checks better for item location ids.
Added victimalliancename to the killlisttable.
The signature generator now paints error messages if he doesnt like stuff.

Line 
1<?php
2$stoppage = true;
3$db = mysql_pconnect($_SESSION['sql']['host'], $_SESSION['sql']['user'], $_SESSION['sql']['pass']);
4mysql_select_db($_SESSION['sql']['db']);
5
6if ($_REQUEST['do'] == 'create')
7{
8    if ($_REQUEST['a'])
9    {
10        $result = mysql_query('select all_id from kb3_alliances where all_name like \'%'.addslashes(stripslashes($_REQUEST['a'])).'%\'');
11        if ($row = @mysql_fetch_row($result))
12        {
13            $id = $row[0];
14        }
15        else
16        {
17            $query = 'insert into kb3_alliances (all_name) VALUES (\''.addslashes(stripslashes($_REQUEST['a'])).'\')';
18            mysql_query($query);
19            $id = mysql_insert_id();
20        }
21        $_REQUEST['a'] = $id;
22    }
23    else
24    {
25        $result = mysql_query('select all_id from kb3_alliances where all_name like \'%Unknown%\'');
26        if ($row = @mysql_fetch_row($result))
27        {
28            $id = $row[0];
29        }
30        else
31        {
32            $query = 'insert into kb3_alliances (all_name) VALUES (\'Unknown\')';
33            mysql_query($query);
34            $id = mysql_insert_id();
35        }
36        $query = 'select crp_id from kb3_corps where crp_name like \'%'.addslashes(stripslashes($_REQUEST['c'])).'%\'';
37        $result = mysql_query($query);
38        if ($row = @mysql_fetch_row($result))
39        {
40            $id = $row[0];
41        }
42        else
43        {
44            $query = 'insert into kb3_corps (crp_name, crp_all_id) VALUES (\''.addslashes(stripslashes($_REQUEST['c'])).'\','.$id.')';
45            mysql_query($query);
46            $id = mysql_insert_id();
47        }
48        $_REQUEST['c'] = $id;
49    }
50    $_SESSION['sett']['aid'] = $_REQUEST['a'];
51    $_SESSION['sett']['cid'] = $_REQUEST['c'];
52    $stoppage = false;
53}
54if ($_REQUEST['do'] == 'select')
55{
56    $_SESSION['sett']['aid'] = $_REQUEST['a'];
57    $_SESSION['sett']['cid'] = $_REQUEST['c'];
58    $stoppage = false;
59}
60?>
61<p>You can now search for your corporation/alliance.<br/>
62If you haven't imported that data or your corporation/alliance is missing i will offer to create it for you.<br/>
63<b>Note:</b> Make sure you spell your corporation/alliance correctly (including capitalization), else you cannot post any mails!<br/>
64</p>
65<?php
66if ($stoppage)
67{
68?>
69<form id="options" name="options" method="post" action="?step=5">
70<input type="hidden" name="step" value="5">
71<div class="block-header2">Search</div>
72<table class="kb-subtable">
73<tr><td width="120">
74<select id="searchtype" name="searchtype"><option value="corp">Corporation</option><option value="alliance">Alliance</option></select>
75</td><td><input id="searchphrase" name="searchphrase" type="text" size="30"/>
76</td><td><input type="submit" name="submit" value="Search"/></td></tr>
77</table>
78<?php
79if ($_REQUEST['searchphrase'] != "" && strlen($_REQUEST['searchphrase']) >= 3)
80{
81    switch ($_REQUEST['searchtype'])
82    {
83        case "corp":
84            $query = "select crp.crp_id, crp.crp_name, ali.all_name
85                    from kb3_corps crp, kb3_alliances ali
86                    where lower( crp.crp_name ) like lower( '%".addslashes(stripslashes($_REQUEST['searchphrase']))."%' )
87                    and crp.crp_all_id = ali.all_id
88                    order by crp.crp_name";
89            break;
90        case "alliance":
91            $query = "select ali.all_id, ali.all_name
92                    from kb3_alliances ali
93                    where lower( ali.all_name ) like lower( '%".addslashes(stripslashes($_REQUEST['searchphrase']))."%' )
94                    order by ali.all_name";
95            break;
96    }
97
98    $result = mysql_query($query);
99
100    $unsharp = true;
101    $results = array();
102    while ($row = mysql_fetch_assoc($result))
103    {
104        switch ($_REQUEST['searchtype'])
105        {
106            case 'corp':
107                $link = "?step=5&do=select&a=0&c=".$row['crp_id'].'">Select';
108                $descr = 'Corp '.$row['crp_name'].', member of '.$row['all_name'];
109                if ($row['crp_name'] == addslashes(stripslashes($_REQUEST['searchphrase'])))
110                {
111                    $unsharp = false;
112                }
113                break;
114            case 'alliance':
115                $link = '?step=5&do=select&c=0&a='.$row['all_id'].'">Select';
116                $descr = 'Alliance '.$row['all_name'];
117                if ($row['all_name'] == addslashes(stripslashes($_REQUEST['searchphrase'])))
118                {
119                    $unsharp = false;
120                }
121                break;
122        }
123        $results[] = array('descr' => $descr, 'link' => $link);
124    }
125    if (!count($results) || $unsharp)
126    {
127        if ($_REQUEST['searchtype'] == 'corp')
128        {
129            $link = '?step=5&do=create&c='.stripslashes($_REQUEST['searchphrase']).'&a=0">Create';
130            $descr = 'Corporation: '.stripslashes($_REQUEST['searchphrase']);
131        }
132        else
133        {
134            $link = '?step=5&do=create&a='.stripslashes($_REQUEST['searchphrase']).'&c=0">Create';
135            $descr = 'Alliance: '.stripslashes($_REQUEST['searchphrase']);
136        }
137        $results[] = array('descr' => $descr, 'link' => $link);
138    }
139    ?>
140<br/>
141<table class="kb-table">
142<tr class="kb-table-header">
143<td colspan="2">Results</td></tr>
144<?php
145foreach ($results as $result)
146{
147?>
148<tr><td><?php echo $result['descr']; ?></td><td><a href="<?php echo $result['link']; ?></a></td></tr>
149<?php
150}
151?>
152</table>
153<?php
154}
155}
156?>
157
158<?php if ($stoppage)
159{
160    return;
161}
162if ($_SESSION['sett']['aid'] == 0 && $_SESSION['sett']['cid'] == 0)
163{
164    echo '<b>Warning:</b> It seems like i got no alliance and corpid, you can continue but you might have to edit it into the config yourself.<br/>';
165}
166?>
167<p><a href="?step=<?php echo ($_SESSION['state']+1); ?>">Next Step</a></p>
Note: See TracBrowser for help on using the browser.