forked from EVE-SECURE/pos-tracker-eve
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fitexporter.xml.php
166 lines (143 loc) · 5.51 KB
/
fitexporter.xml.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?php
/**
* Pos-Tracker2
*
* Starbase Module XML export page
*
* PHP version 5
*
* LICENSE: This file is part of POS-Tracker2.
* POS-Tracker2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* POS-Tracker2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with POS-Tracker2. If not, see <http://www.gnu.org/licenses/>.
*
* @author Stephen Gulickk <stephenmg12@gmail.com>
* @author DeTox MinRohim <eve@onewayweb.com>
* @author Andy Snowden <forumadmin@eve-razor.com>
* @copyright 2007-2009 (C) Stephen Gulick, DeTox MinRohim, and Andy Snowden
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL 3.0
* @package POS-Tracker2
* @version SVN: $Id$
* @link https://sourceforge.net/projects/pos-tracker2/
* @link http://www.eve-online.com/
*/
include_once 'eveconfig/config.php';
include_once 'includes/dbfunctions.php';
EveDBInit();
include_once 'includes/eveclass.php';
include_once 'includes/class.pos.php';
include_once 'includes/eveRender.class.php';
include_once 'eveconfig/config.php';
$eveRender = New eveRender($config, $mod, false);
$colors = $eveRender->themeconfig;
//echo '<pre>';print_r($_SESSION); echo '</pre>';exit;
$eve = New Eve();
$posmgmt = New POSMGMT();
$eve->SessionSetVar('userlogged', 1);
$userinfo = $posmgmt->GetUserInfo();
$access = $eve->SessionGetVar('access');
$access = explode('.',$access);
$eveRender->Assign('access', $access);
$eveRender->Assign('config', $config);
if (empty($pos_id)) {
$pos_id = $eve->VarCleanFromInput('pos_id');
}
$xmlstyle = $eve->VarCleanFromInput('xmlstyle');
$mods = $posmgmt->GetAllPosMods($pos_id);
if ($mods) { //if (mysql_num_rows($result) != 0) {
//Set Header to XML
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header('Content-Type: text/xml');
// create a new XML document
if ($xmlstyle == 'tracker') {
$doc = new DOMDocument('1.0', 'iso-8859-1');
}
if ($xmlstyle == 'mypos') {
$doc = new DOMDocument('1.0');
// Creates an instance of the DOMImplementation class
$imp = new DOMImplementation;
// Creates a DOMDocumentType instance
$dtd = $imp->createDocumentType('TowerFittingXML');
// Creates a DOMDocument instance
$doc = $imp->createDocument("", "", $dtd);
}
//Sets some document properties
$doc->formatOutput = true;
if($xmlstyle=='mypos') {
$doc->standalone = false;
}
if ($xmlstyle == 'tracker') {
// add root node for tracker
$root = $doc->createElement('pos-tracker');
$root = $doc->appendChild($root);
$root->setAttribute('version', '0.1');
//Add comment for tracker
$comment = $doc->createComment('POS-Tracker Fitting Export');
$comment = $root->appendChild($comment);
}
if ($xmlstyle == 'mypos') {
//Add a comment line for MyPOS
$comment = $doc->createComment('This file contains tower fitting information for My POS generated by POS-Tracker 2.1.0');
$comment = $doc->appendChild($comment);
// add root node for MyPOS
$root = $doc->createElement('Fitting');
$root = $doc->appendChild($root);
}
if ($xmlstyle == 'tracker') {
// Add Current Time Elelement
//Get and format time
$time = time();
$currentTime = gmdate("Y-m-d H:i:s", $time);
//create xml for element
$cur_time = $doc->createElement(currentTime);
$cur_time = $root->appendChild($cur_time);
$value = $doc->createTextNode($currentTime);
$value = $cur_time->appendChild($value);
}
// Add Structures element
if ($xmlstyle == 'tracker') {
$structures = $doc->createElement(structures);
}
if ($xmlstyle == 'mypos') {
$structures = $doc->createElement(Structures);
}
$structures = $root->appendChild($structures);
foreach($mods as $mod) {
$stypeID = $mod['type_id'];
$stypeName = $mod['name'];
$online = $mod['online'];
if($xmlstyle == 'tracker') {
//add structure element and attributes child of structures
$structure = $doc->createElement(structure);
$structure = $structures->appendChild($structure);
$structure->setAttribute('typeID', $stypeID);
$structure->setAttribute('typeName', $stypeName);
$structure->setAttribute('online', $online);
}
if($xmlstyle == 'mypos') {
//add ItemID element and attributes child of structures
$itemID = $doc->createElement(ItemID);
$itemID = $structures->appendChild($itemID);
$value = $doc->createTextNode($stypeID);
$value = $itemID->appendChild($value);
}
}
$xml_string = $doc->saveXML();
header("Content-Disposition: attachment; filename=" . urlencode('POS_'.$pos_id.(($xmlstyle=='mypos') ? '.pft' : '.xml')));
header("Content-Type: application/force-download");
echo $xml_string;
} //if
// get completed xml document
?>