root/dev/mods/apiuser/viewChar.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/*
3print '<pre>';
4print_r();
5print '</pre>';
6exit;
7*/
8require_once( "common/admin/admin_menu.php" );
9require_once('common/includes/class.ship.php');
10require_once('common/includes/class.corp.php');
11require_once('common/includes/class.alliance.php');
12require_once( "common/includes/class.eveapi.php" );
13
14
15
16$allAPI= new APIChar();
17$charID=intval($_GET['charID']);
18$qry = new DBQuery();
19$qry->execute('select userID,apiKey,charID,charName  from kb3_api_user where charID='.$charID);
20$row = $qry->getRow();
21if (count($row)<2)
22{
23        $html.='Unknow Char.. Exit';
24        $page = new Page('EVE Char - Error' );
25        $page->setCachable(false);
26        $page->setAdmin();
27        $page->setContent($html);
28}
29else
30{
31$qry->execute('select charID,charName from kb3_api_user where userID='.$row['userID'].' and charID<>'.$row['charID']);
32 while ($row2 = $qry->getRow())
33        {
34         $listAlt[]=$row2;
35        }
36$apistring = 'userID=' . $row['userID'] . '&apiKey=' . $row['apiKey'].'&characterID='.$row['charID'];
37if (!is_dir('./cache/xmlchar/')) mkdir ('./cache/xmlchar/');
38$cache=true;
39
40$storedXmlFile='./cache/xmlchar/'.$charID.'.xml';
41if (is_file($storedXmlFile))
42        $xml = new SimpleXMLElement(file_get_contents($storedXmlFile));
43        if ((time()-strtotime($xml->currentTime))<3600*24)
44                {
45                $cache=false;
46                $html.='(-)';
47        }
48if ($cache)
49        {
50        $fl=file_get_contents('http://api.eve-online.com/char/CharacterSheet.xml.aspx?'.$apistring);
51        file_put_contents($storedXmlFile,$fl);
52        $xml = new SimpleXMLElement($fl);
53        $html.= '(+)';
54        }
55
56//$xmlstr=file_get_contents('./mods/apiuser/char.xml');
57
58
59$page = new Page('EVE Char - '.$row['charName'] );
60$page->setCachable(false);
61$page->setAdmin();
62$kb = new Killboard(KB_SITE);
63//$xml = new SimpleXMLElement($xmlstr);
64$listID='(';
65foreach ($xml->result->rowset->row as $name)
66{
67        $t=$name->attributes();
68        $listID.=$t['typeID'].',';
69}
70$listID=substr($listID,0,($listID-1)).')';
71$qry->execute('select typeID,typeName,groupID from kb3_invtypes where typeID in '.$listID.' order  by groupID,typeName');
72 while ($row = $qry->getRow())
73        {
74        $corrID[$row['typeID']]=$row;
75        }
76
77foreach ($xml->result->rowset->row as $name)
78{
79        $t=$name->attributes();
80        $corrID[intval($t['typeID'])]['level']=intval($t['level']);
81        $corrID[intval($t['typeID'])]['skillpoints']=intval($t['skillpoints']);
82        $total_sp+=intval($t['skillpoints']);
83        $total_skill+=1;
84//      $name->addAttribute('typeName',$corrID[intval($t['typeID'])]['typeName']);
85//      $name->addAttribute('groupID',$corrID[intval($t['typeID'])]['groupID']);
86}
87
88        //Preparation des attributs
89//print $xml->result->attributes->intelligence;
90
91$smarty->assign('total_sp', $total_sp);
92$smarty->assign('total_skill', $total_skill);
93$smarty->assign('basexml', $xml);
94$smarty->assign('listalt', $listAlt);
95$smarty->assign('xml', $corrID);
96//$smarty->assign('xml', $xml);
97
98$page->setContent($smarty->fetch('../mods/apiuser/templates/viewChar.tpl'));
99}
100$page->generate();
101
102?>
Note: See TracBrowser for help on using the browser.