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

Revision 466, 11.4 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/admin/admin_menu.php" );
3require_once('common/includes/class.ship.php');
4require_once('common/includes/class.corp.php');
5require_once('common/includes/class.alliance.php');
6require_once( "common/includes/class.eveapi.php" );
7
8$page = new Page( "Settings - API user management" );
9$page->setCachable(false);
10$page->setAdmin();
11define (APIUSER_VERSION,'0.5');
12
13$phpEx = substr(strrchr(__FILE__, '.'), 1);
14$phpfile=config::get('apiuser_phpbbrelative').'/common.' . $phpEx;
15
16$qry = new DBQuery();
17        // SQL File installation
18
19if (!config::get('apiuser_version') || floatval(config::get('apiuser_version'))<floatval(APIUSER_VERSION))
20{
21        define(A_INSTALLER,'1');
22        include('instdb.php');
23        $html.='Apiuser now in version '.APIUSER_VERSION.'<br>';
24}
25//--- Sauvegarde
26if (isset($_POST['go']))
27{
28                //PHPbb 3 integration
29   if ($_POST['registerphpbb'])
30        config::set('apiuser_registerphpbb', '1');
31   else
32        config::set('apiuser_registerphpbb', '0');
33   if ($_POST['forcephpbb'])
34        config::set('apiuser_forcephpbb', '1');
35   else
36        config::set('apiuser_forcephpbb', '0');
37   config::set('apiuser_allianceforum', intval($_POST['allianceforum']));
38   config::set('apiuser_alliedforum', intval($_POST['alliedforum']));
39   config::set('apiuser_phpbbrelative', ($_POST['phpbbrelative']));
40
41
42
43   if ($_POST['roleAcces'])
44        config::set('apiuser_roleAcces', '1');
45   else
46        config::set('apiuser_roleAcces', '0');
47
48   if ($_POST['comment'])
49        config::set('apiuser_comment', '1');
50   else
51        config::set('apiuser_comment', '0');
52
53   if ($_POST['storechar'])
54        config::set('apiuser_storechar', '1');
55   else
56        config::set('apiuser_storechar', '0');
57   if ($_POST['killmail'])
58        config::set('apiuser_killmail', '1');
59   else
60        config::set('apiuser_killmail', '0');
61
62   if ($_POST['showchar'])
63        config::set('apiuser_show3char', '1');
64   else
65        config::set('apiuser_show3char', '0');
66
67   if ($_POST['showPoster'])
68        config::set('apiuser_showPoster', '1');
69   else
70        config::set('apiuser_showPoster', '0');
71
72   $html.='<i>Setting saved.</i><br />';
73}
74//---
75
76
77
78if (isset($_GET['check_config']))
79{
80$html .= "<div class=block-header2>Configuration control</div>";
81        //Check tt les fichiers / config
82if (is_file("common/includes/class.eveapi.php"))
83{
84        require_once("common/includes/class.eveapi.php");
85        if (floatval(str_replace('V','',APIVERSION))>2.4)
86                $html.='&raquo; APIeve Found, version '.APIVERSION. ' <font color=green>Ok</font><br>';
87        else
88                $html.='&raquo; APIeve Found, but version '.APIVERSION. ' is not enough, need version > 2.4 <font color=red>Error</font><br>';
89}
90else
91        $html.='&raquo; file : class APIEVE "common/includes/class.eveapi.php" not found, you may pick it from <a href="http://www.eve-dev.net/e107_plugins/forum/forum_viewtopic.php?8327.0">Here</a> <font color=red>Error</font><br>';
92
93        //Check PhpBB Settings
94if (config::get('apiuser_registerphpbb') ||config::get('apiuser_forcephpbb'))
95{
96if (!is_file($phpfile))
97        $html.='&raquo; phpBB enable, but i can\'t find require phpBB file "'.$phpfile.'" <font color=red>Error</font><br>';
98else
99        $html.='&raquo; phpBB enable, phpBB file "'.$phpfile.'" found <font color=green>Ok</font><br>';
100
101if (config::get('apiuser_forcephpbb'))
102        {
103        $f=file_get_contents('./common/index.php');
104        if (strstr($f,"f (config::get('apiuser_forcephpbb')==1)")===FALSE)
105                $html.='&raquo; file : phpBB session forced, but the file "./common/index.php" have NOT been edited <font color=red>Error</font><br>';
106        else
107                $html.='&raquo; phpBB session forced, file  "./common/index.php" has been edited <font color=green>Ok</font><br>';
108        }
109}
110else
111        $html.='&raquo; PHPBB setting disabled, phpBB setting not checked <font color=green>Ok</font><br>';
112
113$qry->execute('select count(*) as nb from kb3_all_corp');
114$row=$qry->getRow();
115if (intval($row['nb'])>0)
116        $html.='&raquo; table : kb3_kill_all exist with '.$row['nb'].' corporation known <font color=green>Ok</font><br>';
117        else
118        $html.='&raquo; table : kb3_kill_all : can\'t get number of corporation or no corporation, click <a href="index.php?a=settings_apiuser&getlistAlliance">here</a> to update the list <font color=red>error</font><br>';
119        //Check kill_detail.php
120
121        $mods_active = explode(',', config::get('mods_active'));
122$modOverrides = false;
123$lmod='';
124foreach ($mods_active as $mod)
125{
126
127    if (file_exists('./mods/'.$mod.'/kill_detail.php'))
128    {
129        $f=file_get_contents('./mods/'.$mod.'/kill_detail.php');
130        if (strstr($f,"kb3_api_user")===FALSE)
131                $html.='&raquo; file : "'.'./mods/'.$mod.'/kill_detail.php'.'" isn\'t edited to show the Username of the killmail poster,read txt file  <font color=orange>warning</font><br>';
132        else
133                $html.='&raquo; file : "./mods/'.$mod.'/kill_detail.php have been edited for poster info <font color=green>Ok</font><br>';
134
135        if ($modOverrides)
136                {
137                $html.='&raquo; Two or more of the mods you have activated are conflicting for page kill_detail.php :'.$lmod.$mod.' <font color=red>error</font><br>';
138                }
139        $modOverrides = true;
140        $modOverride = $mod;
141                $lmod.=$mod.',';
142        $validmod=$mod;
143    }
144
145}
146
147if (strlen($lmod)==0 && strlen($validmod)>0)
148        $html.='&raquo; file : "./mods/'.$mod.'/kill_detail.php  will be used <font color=green>Ok</font><br>';
149if (strlen($lmod)==0 && strlen($validmod)==0)
150        {
151        $f=file_get_contents('./common/kill_detail.php');
152        if (strstr($f,"kb3_api_user")===FALSE)
153                $html.='&raquo; file : "'.'./common/kill_detail.php'.'" isn\'t edited to show the Username of the killmail poster,read txt file  <font color=orange>warning</font><br>';
154        else
155                $html.='&raquo; file : "./common/kill_detail.php have been edited for poster info <font color=green>Ok</font><br>';
156        }
157
158}//fin de check control
159else
160        $html.='<form id="options" name="options" method="post" action="?a=settings_apiuser&check_config"><input type=submit value="Check Configuration" ></form>';
161
162
163if (isset($_GET['getlistAlliance']))
164{
165        require_once( "common/includes/class.eveapi.php" );
166        $allAPI= new AllianceAPI();
167        $test = $allAPI->updatealliancetable();
168        $qry->execute('select count(*) as nb from kb3_all_corp');
169        $tb=$qry->getRow();
170        if (config::get('API_AllianceXMLLastUpdate'))
171        $html.='<span class=losscount>'.$tb['nb']. ' Corporation added</span><br>';
172        else
173                $html.='<span class=losscount>No know alliance table update';
174}
175
176if (isset($_GET['getlistAlliance2']))
177{
178        $content=file_get_contents('http://api.eve-online.com/eve/AllianceList.xml.aspx');
179        file_put_contents('./cache/AllianceList.xml',$content);
180
181        $dataxml= simplexml_load_file(config::get('api_user_allianceCache'));
182        $j=0;$i=0;
183
184        while (is_object($dataxml->result->rowset[0]->row[$i]))
185        {
186                $alliance=$dataxml->result->rowset[0]->row[$i]->attributes();
187
188                $j=0;
189                while (is_object($dataxml->result->rowset[0]->row[$i]->rowset[0]->row[$j]))
190                        {
191                                $corpo=$dataxml->result->rowset[0]->row[$i]->rowset[0]->row[$j]->attributes();
192
193                                $q.="(".$alliance['allianceID'].",".$corpo['corporationID'].",'".slashfix($alliance['name'])."'),";
194                                $j++;
195                        }
196        $qry = new DBQuery();
197        $qry->execute('delete from kb3_all_corp where all_ID='.$alliance['allianceID']);
198        $qry->execute("INSERT INTO kb3_all_corp values ".substr($q,0,strlen($q)-1));
199        $q="";
200        $i++;
201        }
202        config::set('api_user_allianceCache','./cache/AllianceList.xml');
203$html.='<span class=losscount>List Of alliance updated</span><br>';
204}
205
206
207$html .= '<form id="options" name="options" method="post" action="?a=settings_apiuser">';
208$html .= "<div class=block-header2>General Settings</div>";
209$html .= "<input type=checkbox name=showPoster id=fetch_losses";
210if (config::get('apiuser_showPoster'))
211    $html .= " checked=\"checked\"";
212$html .= "> Show the Username of the killmail poster<br>";
213
214$html .= "<div class=block-header2>Access Settings</div>";
215$html .= "<input type=checkbox name=comment id=fetch_losses";
216if (config::get('apiuser_comment'))
217    $html .= " checked=\"checked\"";
218$html.="> Need the role <b>'comment'</b> to post comment<br>";
219
220$html .= "<input type=checkbox name=killmail id=fetch_losses";
221if (config::get('apiuser_killmail'))
222    $html .= " checked=\"checked\"";
223$html.="> Need the role <b>'post killmaill'</b>  to post killmail<br>";
224
225$html .= "<input type=checkbox name=roleAcces";
226if (config::get('apiuser_roleAcces'))
227    $html .= " checked=\"checked\"";
228$html.="> <b>Set the killboard private (need 'access' role)</b><br>";
229
230$html .= "<div class=block-header2>API Key Settings</div>";
231
232$html .= "<input type=checkbox name=storechar id=fetch_losses";
233if (config::get('apiuser_storechar'))
234    $html .= " checked=\"checked\"";
235$html .= "> Store the 3 char of the API key<br>";
236
237$html .= "<input type=checkbox name=showchar id=fetch_losses";
238if (config::get('apiuser_show3char'))
239    $html .= " checked=\"checked\"";
240$html .= "> Show the 3 char of the API key in the user management page<br>";
241
242$html .= "<div class=block-header2>PHPBB3 security Integration</div>";
243
244
245        //Check PhpBB Settings
246
247if (config::get('apiuser_registerphpbb')  && !is_file($phpfile))
248        {
249        $html.='phpBB enable, but i can\'t find require phpBB file "'.$phpfile.'" <font color=red>Error</font><br>';
250        config::set('apiuser_registerphpbb', '0');
251        }
252
253
254        if (config::get('apiuser_forcephpbb'))
255                {
256                $f=file_get_contents('./common/index.php');
257                if (strstr($f,"f (config::get('apiuser_forcephpbb')==1)")===FALSE)
258                        {
259                        $html.='file : phpBB session forced, but the file "./common/index.php" have NOT been edited <font color=red>Error</font><br>';
260                config::set('apiuser_forcephpbb', '0');
261                        }
262
263                }
264
265
266$html.=' &nbsp;  I <b>STRONGLY</b> advice you to read this paragraph.<br>';
267$html.=' &nbsp;  If you set the path of phpbb/id of forum wrong you will no longer be able to acces the killboard.<br>';
268$html.=' &nbsp;  set apiuser_forcephpbb to 0 in the kb3_config table .<br>';
269
270$html .= "<input type=checkbox name=forcephpbb id=fetch_losses";
271if (config::get('apiuser_forcephpbb'))
272    $html .= " checked=\"checked\"";
273$html .= "> Force to have a phpBB session to access on the board<br>";
274
275
276$html .= "<input type=checkbox name=registerphpbb id=fetch_losses";
277if (config::get('apiuser_registerphpbb'))
278    $html .= " checked=\"checked\"";
279$html .= "> Force to have a phpBB session to register on the board<br>";
280$html.='<input type=text name="allianceforum" size=2 value="'.config::get('apiuser_allianceforum').'"> ID of the alliance forum <br>';
281$html.='<input type=text name="alliedforum" size=2 value="'.config::get('apiuser_alliedforum').'"> ID of the allied forum (set to 0 if you doesn\'t want to use that feature)<br>';
282$html.='<input type=text name="phpbbrelative" size=15 value="'.config::get('apiuser_phpbbrelative').'"> Relative path of the phpBB forum (ex : ../forum)<br>';
283
284
285
286
287
288
289$html .= "<br><input type=submit id=submit name=go value=\"Save\"><br><br>";
290$html .= "</form /><br><br>";
291
292$html.='<a href="index.php?a=settings_apiuser&getlistAlliance">Update list of corporation in alliances (via API CLass)</a><br>';
293$html.='<a href="index.php?a=settings_apiuser&getlistAlliance2">Update list of corporation in alliances (for php5 user)</a>';
294
295
296$html .= "<div class=block-header2>User Managment</div>";
297$html.=' <a href="?a=user_management">Manage Users</a>';
298
299
300
301$html.='<span class="killcount">APIUser Version '.config::get('apiuser_version').'</span>';
302$page->setContent( $html );
303$page->addContext( $menubox->generate() );
304$page->generate();
305
306?>
Note: See TracBrowser for help on using the browser.