-
Notifications
You must be signed in to change notification settings - Fork 0
/
addstructure.php
129 lines (102 loc) · 4.82 KB
/
addstructure.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
<?php
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';
$eveRender = New eveRender($config, $mod, false);
$colors = $eveRender->themeconfig;
$eveRender->Assign('config', $config);
$eve = New Eve();
$posmgmt = New POSMGMT();
$userinfo = $posmgmt->GetUserInfo();
$eveRender->Assign('userinfo', $userinfo);
$theme_id = $eve->SessionGetVar('theme_id');
$eveRender->Assign('theme_id', $theme_id);
$access = $eve->SessionGetVar('access');
$access = explode('.',$access);
$eveRender->Assign('access', $access);
if (!in_array('1', $access) && !in_array('5', $access) && !in_array('6', $access)) {
$eve->RedirectUrl('track.php');
}
$pos_id = $eve->VarCleanFromInput('i');
if (empty($pos_id)) {
$pos_id = $eve->VarCleanFromInput('pos_id');
if (empty($pos_id)) {
$eve->SessionSetVar('errormsg', 'No ID defined!');
$eve->RedirectUrl('track.php');
}
}
$structs = $posmgmt->GetAllStaticStructures2();
$action = $eve->VarCleanFromInput('action');
if ($action == 'Done') {
$dbconn =& DBGetConn(true);
foreach ($structs as $struct) {
$structvalue = $eve->VarCleanFromInput('s_id'.$struct['id']);
if ($structvalue != 0) {
for ($x = 1;$x<=$structvalue;$x++) {
$structures[] = $struct['id'];
}
}
}
$n = count($structures);
foreach($structures as $struc) {
$s_id = $struc;//$_POST['s_id' . $n];
if ($s_id >= "1") {
$nextId = $dbconn->GenId(TBL_PREFIX.'pos_structures');
$sql = "INSERT INTO ".TBL_PREFIX."pos_structures VALUES ('".$eve->VarPrepForStore($nextId)."', '" . $eve->VarPrepForStore((int)$pos_id) . "', '" . $eve->VarPrepForStore($s_id) . "', 1)";
$dbconn->Execute($sql);
if ($dbconn->ErrorNo() != 0) {
echo 'That doesnt work; ' . $dbconn->ErrorMsg();
return false;
}
$newId = $dbconn->PO_Insert_ID(TBL_PREFIX.'pos_structures', 'id');
$time = time();
if ($s_id == 17621) {
$hangar_id = $newId;//mysql_insert_id();
$sql = "INSERT INTO ".TBL_PREFIX."pos_hanger VALUES ('{$hangar_id}','" . $pos_id . "','0','0','0','0','0','0','0','0','0','0')";
mysql_query($sql);
$sql = "INSERT INTO ".TBL_PREFIX."update_log VALUES ('NULL', '" . $eve->VarPrepForStore($eve_id) . "', '" . $eve->VarPrepForStore($hangar_id) . "', '3', 'Add Hanger', '" . $time . "')";
$result = mysql_query($sql) or die('Could not insert values into update_log; ' . mysql_error());
}
if ($s_id == 14343) {
$silo_id = $newId;//mysql_insert_id();
//echo ''.$s_id.'-'.$silo_id; exit;
//$sql = "INSERT INTO ".TBL_PREFIX."silo_info VALUES ('{$silo_id}','" . $eve->VarPrepForStore($pos_id) . "','14343','0','0','0','0','0')";
$sql = "INSERT INTO ".TBL_PREFIX."silo_info VALUES ('".$eve->VarPrepForStore($silo_id)."','" . $eve->VarPrepForStore($pos_id) . "','14343','0','0','0','0','0','0')";
$dbconn->Execute($sql);
//mysql_query($sql);
$sql = "INSERT INTO ".TBL_PREFIX."update_log VALUES ('NULL', '1', '" . $eve->VarPrepForStore($silo_id) . "', '2', 'Add Silo', '" . $time . "')";
$result = mysql_query($sql) or die('Could not insert values into update_log; ' . mysql_error());
}
if ($s_id == 16221 || $s_id==17170 || $s_id==20175 || $s_id==16869) {
$structure_id = mysql_insert_id();
$sql = "INSERT INTO ".TBL_PREFIX."reactor_info VALUES ('{$structure_id}','" . $eve->VarPrepForStore($pos_id) . "','".$s_id."','0')";
$dbconn->Execute($sql);
$sql = "INSERT INTO ".TBL_PREFIX."update_log VALUES ('NULL', '" . $eve_id . "', '" . $eve->VarPrepForStore($silo_id) . "', '2', 'Add Harvester/Reactor', '" . $time . "')";
$result = mysql_query($sql)
or die('Could not insert values into update_log; ' . mysql_error());
}
}
}
$mods = $posmgmt->GetAllPosMods($pos_id);
if ($mods) {
$current_pg = 0;
$current_cpu = 0;
foreach($mods as $row) {
if ($row['online']) {
$current_pg = $current_pg + $row['pg'];
$current_cpu = $current_cpu + $row['cpu'];
}
}
$posmgmt->ChangeTowerCPUPG(array('pos_id' => $pos_id, 'new_pg' => $current_pg, 'new_cpu' => $current_cpu));
}
$eve->RedirectUrl('viewpos.php?i='.$pos_id);
}
$struct_amount = $eve->VarCleanFromInput('amount');
$eveRender->Assign('pos_id', $pos_id);
$eveRender->Assign('structs', $structs);
$eveRender->Display('addstructures.tpl');
exit;
?>