root/dev/mods/apiuser/register.php @ 491

Revision 466, 5.9 KB (checked in by kovell, 11 years ago)

Reverting 464 changes. apiuser mod actually does work for some and is used by other mods.

Line 
1<?php
2require_once('common/includes/class.ship.php');
3require_once('common/includes/class.corp.php');
4require_once('common/includes/class.alliance.php');
5require_once( "common/includes/class.eveapi.php" );
6
7
8
9$page = new Page('User - Registration');
10
11if (config::get('user_regdisabled'))
12{
13    $page->error('Registration has been disabled.');
14    return;
15}
16$qry = new DBQuery();
17
18        $qry->execute('select count(*) as nb from kb3_all_corp ');
19        $row = $qry->getRow();
20if ($row['nb']<1)
21        {
22        $html.='<span class=losscount>You need to update the allaince list via the setting panel of this mod to be able to register account</span>';
23        $page->setContent($html);
24        $page->generate();
25        exit;
26        }
27
28$html .= '<div class=block-header2>New user</div>';
29// Please leave the information on the next line as is so that other people can easily find the EVE-Dev website.
30// Remember to share any modifications to the EVE-Dev Killboard.
31
32$html.='Hello, welcome to the register account page.<br>';
33
34if (config::get('apiuser_comment'))
35        $html.='<ul> &raquo; You need to have an account created here to be able to post comment.</ul>';
36if (config::get('apiuser_killmail'))
37        $html.='<ul> &raquo; You need to have an account created here to be able to add killmail.</ul>';
38if (config::get('apiuser_registerphpbb'))
39        $html.='<ul> &raquo; You need to be logged on the forum BEFORE registering an account here .</ul>';
40
41$html.='Go <a target=_new href="http://myeve.eve-online.com/api/default.asp">Here</a> for you\'re getting you\'r <b>Limited Access API Key</b> ';
42$html .= '<form id="options" name="options" method="post" action="?a=register">';
43if (config::get('apiuser_registerphpbb'))
44{
45//debut Mod PHPBB
46        if (!is_file($phpbb_root_path . 'common.' . $phpEx) && is_file($phpbb_root_path . 'includes/functions_display.' . $phpEx))
47                $html.='<h1>ERROR PHPBB PATH in APIuser mod</h1>';
48}
49//fin Mod PHPBB
50
51if (!isset($_POST['step']))
52        {
53        $html .= '<div class=block-header2>Step 1 : Enter Api Key</div><table>';
54        $html .= '<tr><td>user ID (6 numer): </td><td><input type=text name=userID ></td></tr>';
55        $html .= '<tr><td>API Key (64 char) : </td><td><input size=64 type=text name=apiKey ></td></tr>';
56        $html .= '</table><input type=hidden name=step value=2 />';
57        }
58if (isset($_POST['step']) && $_POST['step']==2)
59{
60$html .= '<div class=block-header2>Step 2 : Choose a char</div>';
61$qry->execute('select count(*) as nb  from kb3_api_user where userID='.intval($_POST['userID']).' and ban=1');
62$row = $qry->getRow();
63if ($row['nb']>0)
64        {
65        $html.='<span class="losscount">Sorry, you have been banned to use this killboard</span>';
66        $page->setContent($html);
67        $page->generate();
68        exit;
69        }
70
71$userID=intval($_POST['userID']);
72$apiKey=$_POST['apiKey'];
73
74$apistring = 'userID=' . $userID . '&apiKey=' . $apiKey;
75$myCharSelect = new APIChar();
76
77$charL= $myCharSelect->fetchChars($apistring);
78if (!is_array($charL))
79        {
80        $html.='<span class="losscount">Error API KEY</span>';
81                $page->setContent($html);
82        $page->generate();
83        exit;
84        }
85
86for ($i=0;$i<3;$i++)
87{
88        $qry->execute('select all_name from kb3_all_corp where corp_id='.intval($charL[$i]['corpID']));
89        $row = $qry->getRow();
90        $charL[$i]['allianceName']=$row['all_name'];
91$qry->execute('delete from kb3_api_user where userID='.intval($userID).' and charID='.intval($charL[$i]['charID']));
92
93$query='insert into kb3_api_user values('.$userID.",'".slashfix($apiKey)."','".intval($charL[$i]['charID'])."','".slashfix($charL[$i]['Name'])."','".slashfix($charL[$i]['corpName'])."','".slashfix($charL[$i]['allianceName'])."','',0)";
94
95        $qry->execute($query);
96        }
97foreach($charL as $key=>$char)
98        {
99                if (CORP_ID)
100                {
101                        $corp = new Corporation(CORP_ID);
102                        if (strtolower($corp->getName())==strtolower($char['corpName']))
103                                $char['selectable']=1;
104                         $nn=$corp->getName();
105                }
106                        if (ALLIANCE_ID)
107                {
108                        $alli = new Alliance(ALLIANCE_ID);
109                         if (strtolower($alli->getName())==strtolower($char['allianceName']))
110                                        $char['selectable']=1;
111                         $nn=$alli->getName();
112                }
113                if (isset($char['selectable']))
114                        $listChar[]=$char;
115        }
116        $html .= '<input type=hidden name=userid value='.$userID.' />';
117        $html.=' <br>Only Char in <b>'.$nn.'</b> can be selected.<br><br>';
118                if (!is_array($listChar))
119                $html.='<span class=losscount>Error no valid char found</span><br>';
120                else
121        {
122        $html.='<select name=characterID>';
123
124        foreach ($listChar as $key=>$char)
125        {
126                $html.='<option value="'.$char['charID'].'">['.$char['allianceName'].'] '.$char['corpName'].' / '.$char['Name'].'</option>';
127        }
128        $html.='</select>';
129        $html .= '<br><br> password :<input type=password name=password />';
130        $html .= '<input type=hidden name=step value=3 />';
131        }
132}
133
134if (isset($_POST['step']) && $_POST['step']==3)
135{
136
137if (!config::get('apiuser_storechar'))
138        $qry->execute("delete from kb3_api_user where password='' and userID=".intval($_POST['userid']));
139
140$qry->execute("delete from kb3_user where usr_login='".$usr['charName']."'");
141$html .= '<div class=block-header2>Step 3 : Final Step</div>';
142
143        $qry->execute('select charName,apiKey from kb3_api_user where  charID='.intval($_POST['characterID']));
144        $usr= $qry->getRow();
145        $qry->execute('select plt_id from kb3_pilots where plt_externalid='.intval($_POST['characterID']));
146        $char= $qry->getRow();
147        $id = intval($_POST['characterID']);
148    $pilot = $char['plt_id'];
149     user::register(slashfix($usr['charName']), slashfix($_POST['password']), $pilot, $id);
150        $qry->execute("select usr_id from kb3_user where usr_login='".slashfix($usr['charName'])."'");
151        $tmp= $qry->getRow();   
152        $qry->execute('update kb3_api_user set usr_id ='.$tmp['usr_id'].' where charID='.intval($_POST['characterID']));
153        $page->setContent('Account registered.');
154    $page->generate();
155     return;
156
157}
158
159if ($_POST['step']<3)
160        {
161$html .= "<br><br><input type=submit id=submit name=go value=\"Next Step\"><br><br>";
162$html.='</form>';
163        }
164
165$page->setContent($html);
166$page->generate();
167?>
Note: See TracBrowser for help on using the browser.