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

Revision 466, 2.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
2
3//delete  from kb3_config where cfg_key like 'apiuser_%'
4
5
6//used once to create the 3 table needed for the mod or for future version of eveapi
7if (A_INSTALLER<>1)
8        exit;
9if (floatval(config::get('apiuser_version'))==0)
10{
11$qry->execute("CREATE TABLE kb3_all_corp (
12  all_id bigint(3) unsigned default '0',
13  corp_id bigint(3) unsigned default '0',
14  all_name varchar(200) default NULL
15) ");
16$qry->execute("CREATE TABLE kb3_api_user (
17  userID int(3) unsigned default '0',
18  apiKey varchar(64) default NULL,
19  charID int(3) unsigned default '0',
20  charName varchar(150) default '0',
21  corpName varchar(150) default '0',
22  allianceName varchar(150) default NULL,
23  password varchar(60) default NULL,
24  ban tinyint(3) unsigned default NULL
25) ");
26$qry->execute("CREATE TABLE kb3_kill_poster (
27  kill_id int(3) unsigned default '0',
28  charID int(3) unsigned default '0'
29)");
30config::set('apiuser_version','0.2');
31$html.='<span class="losscount">[instdb] Creation of tables table kb3_all_corp,kb3_api_user,kb3_kill_poster </span><br>';
32}
33
34if (floatval(config::get('apiuser_version')<'0.3'))
35{
36                //Migrate all the userApi Users
37        $qry->execute('select plt_id,charName,charID,password from kb3_pilots a,kb3_api_user b where plt_name=charName');
38        while ($l= $qry->getRow())
39                $ligne[]=$l;
40        foreach ($ligne as $char)
41        {
42                user::register(slashfix($char['charName']), slashfix($char['password']), $char['plt_id'],$char['charID']);
43                $qry->execute("select usr_id from kb3_user where usr_login='".slashfix($char['charName'])."'");
44                $tmp= $qry->getRow();
45                $qry->execute('update kb3_api_user set password ='.$tmp['usr_id'].' where charID='.intval($char['charID']));
46        }
47        $qry->execute('ALTER TABLE `kb3_api_user` CHANGE `password` `usr_id` INT(10)');
48        $html.='<span class="losscount">[instdb] Migration of all the users from V0.3=>V0.4</span><br>';
49config::set('apiuser_version','0.3');
50}
51
52if (floatval(config::get('apiuser_version')<'0.4'))
53{
54                //Add a key
55        $qry->execute('ALTER TABLE kb3_all_corp  ADD PRIMARY KEY (all_id,corp_id)');
56        config::set('apiuser_version','0.4');
57
58}
59if (floatval(config::get('apiuser_version')<'0.5'))
60{
61                // Add standard role
62        $qry->execute("delete from  kb3_roles where rol_site='".KB_SITE."'");
63        $qry->execute('INSERT INTO `kb3_roles` VALUES("1", "'.KB_SITE.'", "admin", "Administrator level")');
64        $qry->execute('INSERT INTO `kb3_roles` VALUES("2", "'.KB_SITE.'", "comment", "Allow to post Comment");');
65        $qry->execute('INSERT INTO `kb3_roles` VALUES("3", "'.KB_SITE.'", "post_killmail", "Allow to post Killmail");');
66        $qry->execute('INSERT INTO `kb3_roles` VALUES("4", "'.KB_SITE.'", "access", "Allow to consult the Killboard");');
67        $qry->execute('INSERT INTO `kb3_roles` VALUES("5", "'.KB_SITE.'", "autopilot", "Allow Acces to the Autopilot Mod");');
68        $html.='<span class="losscount">[instdb] Adding Standard Roles</span><br>';
69    config::set('apiuser_version','0.5');
70}
Note: See TracBrowser for help on using the browser.