root/dev/install/install_step5.php @ 400

Revision 400, 5.8 KB (checked in by kovell, 13 years ago)

Fixes: install is locked after first run, private cache files made inaccesible, initial summary caching removed from kill posting, board will not attempt to run on MySQL < 4.1, PILOT_ID cannot be set, legacy option removed from admin panel, pos values added to installation defaults

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