root/dev/install/install_step5.php @ 88

Revision 88, 5.2 KB (checked in by exi, 14 years ago)

Added the new installer and modified readme.txt for this.
The needed SQl data will be supplied later.

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    $results = array();
101    while ($row = mysql_fetch_assoc($result))
102    {
103        switch ($_REQUEST['searchtype'])
104        {
105            case 'corp':
106                $link = "?step=5&do=select&a=0&c=".$row['crp_id'].'">Select';
107                $descr = 'Corp '.$row['crp_name'].', member of '.$row['all_name'];
108                break;
109            case 'alliance':
110                $link = '?step=5&do=select&c=0&a='.$row['all_id'].'">Select';
111                $descr = 'Alliance '.$row['all_name'];
112                break;
113        }
114        $results[] = array('descr' => $descr, 'link' => $link);
115    }
116    if (!count($results))
117    {
118        if ($_REQUEST['searchtype'] == 'corp')
119        {
120            $link = '?step=5&do=create&c='.stripslashes($_REQUEST['searchphrase']).'&a=0">Create';
121            $descr = 'Corporation: '.stripslashes($_REQUEST['searchphrase']);
122        }
123        else
124        {
125            $link = '?step=5&do=create&a='.stripslashes($_REQUEST['searchphrase']).'&c=0">Create';
126            $descr = 'Alliance: '.stripslashes($_REQUEST['searchphrase']);
127        }
128        $results[] = array('descr' => $descr, 'link' => $link);
129    }
130    ?>
131<br/>
132<table class="kb-table">
133<tr class="kb-table-header">
134<td colspan="2">Results</td></tr>
135<?php
136foreach ($results as $result)
137{
138?>
139<tr><td><?php echo $result['descr']; ?></td><td><a href="<?php echo $result['link']; ?></a></td></tr>
140<?php
141}
142?>
143</table>
144<?php
145}
146}
147?>
148
149<?php if ($stoppage)
150{
151    return;
152}?>
153<p><a href="?step=<?php echo ($_SESSION['state']+1); ?>">Next Step</a></p>
Note: See TracBrowser for help on using the browser.