-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstats.php
154 lines (147 loc) · 5.34 KB
/
stats.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
<?php
#Problem with Gzipping
//ob_start("ob_gzhandler");
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Pragma: no-cache");
#Problem with Gzipping
ob_start("ob_gzhandler");
#take time
$time = microtime(TRUE);
#take mem usage
$mem = memory_get_usage();
#Needed html and body section
echo "<html><head><title>Asemble Base</title></head><body>";
#include sql login details
include('./Api/sql_log.php');
#make connection to server
$con = new mysqli($servername, $username, $password, $dbname);
#test Errors on connection
if ($con->connect_errno) {
#If connection failed , print error
echo "Failed to connect to MySQL: (" . $con->connect_errno . ") " . $con->connect_error;
}
#Echo connection info
echo $con->host_info . "\n<br>";
#Make query about accounts
$sql = "SELECT id, name, pass, base, session FROM tzcrew.Account ORDER BY id";
#Run query
$result = $con->query($sql);
# Test result count and if more than 0 then run query
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
#echo output
echo "id: " . $row["id"]. " - Name: " . $row["name"]. " - Pass: " . $row["pass"]. " - Base: " . $row["base"].
" - Session: " . $row["session"]."<br>";
}
#If no data
} else {
#echo No data
echo "Account 0 results";
}
#Line break
echo "<br>";
#Make new query about id, base, fleet, metal, fuel, region ,galaxy
$sql = "SELECT id, base, fleet, metal, fuel, region ,galaxy FROM tzcrew.Base ORDER BY base";
#Run query
$result = $con->query($sql);
# Test result count and if more than 0 then run query
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "id: " . $row["id"]. " - Base: " . $row["base"]. " - Fleet: " . $row["fleet"].
" - Metal: " . $row["metal"]." - Fuel: " . $row["fuel"]." - Region: " . $row["region"]." - Galaxy: " . $row["galaxy"]."<br>";
}
#If no data
} else {
#echo No data
echo "Base 0 results";
}
echo "<br>";
#Make new query about id, fleet, ship, damage
$sql = "SELECT id, fleet, ship, damage FROM tzcrew.Fleet ORDER BY fleet";
#Run query
$result = $con->query($sql);
# Test result count and if more than 0 then run query
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "id: " . $row["id"]. " - Fleet: " . $row["fleet"]. " - Ship: " . $row["ship"]. " - Damage: " . $row["damage"]."<br>";
}
#If no data
} else {
#echo No data
echo "Fleet 0 results";
}
echo "<br>";
#Make new query about id, name_id, firepower, shield, hull, shield_rege, hull_rege, prize_metal, prize_fuel, prize_diamond, prize_cash
$sql = "SELECT id, name_id, firepower, shield, hull, shield_rege, hull_rege, prize_metal, prize_fuel, prize_diamond, prize_cash FROM tzcrew.Ship ORDER BY id";
#Run query
$result = $con->query($sql);
# Test result count and if more than 0 then run query
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "id: " . $row["id"]. " - Name: " . $row["name_id"]. " - Firepower: " . $row["firepower"]. " - Shield: " . $row["shield"].
" - Hull: " . $row["hull"]. " - Shield Regeneration: " . $row["shield_rege"]. " - Hull Regeneration: " . $row["hull_rege"].
"- Prize metal : " . $row["prize_metal"]. " - Prize fuel: " . $row["prize_fuel"].
"- Prize diamond : " . $row["prize_diamond"]. " - Prize cash: " . $row["prize_cash"]."<br>";
}
#Show Cost of last query
$sql2 = "Show session Status like 'Last_query_cost'";
#Run query
$result2 = $con->query($sql2);
// output data of each row sql session data
while($row = $result2->fetch_assoc()) {
echo "Variable name: " . $row["Variable_name"]. " - Value: " . $row["Value"]."<br>";
}
#If no data
} else {
#echo No data
echo "Ship 0 results";
}
echo "<br>";
#SHOW SESSION STATUS LIKE 'Questions'
$sql = "SHOW SESSION STATUS LIKE 'Questions'";
#Run query
$result = $con->query($sql);
# Test result count and if more than 0 then run query
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "Variable name: " . $row["Variable_name"]. " - Value: " . $row["Value"]."<br>";
}
#Show Cost of last query
$sql2 = "Show session Status like 'Last_query_cost'";
#Run query
$result2 = $con->query($sql2);
while($row = $result2->fetch_assoc()) {
echo "Variable name: " . $row["Variable_name"]. " - Value: " . $row["Value"]."<br>";
}
#If no data
} else {
#echo No data
echo "No Questions";
}
echo "<br>";
#Print System Status
printf("System status: %s\n", mysqli_stat($con));
echo "<br> API USAGE <hr>";
// Ships_in_fleet()
$ships = new fleetships("ships");
$ships->Shipsinfleet();
$addtofleet = new addshipfleet("ships");
$addtofleet->Addshipstofleet();
echo "End of API";
echo "<hr><br>";
mysqli_close($con);
#output time and mem usage , make megabytes size and microseconds to seconds
echo "<br>memory_get_peak_usage: ", number_format((memory_get_peak_usage(false)/1024/1024), 3, '.', ',')." MiB\n";
echo "<br>memory usage: ", number_format((memory_get_usage()/1024/1024), 3, '.', ',')." MiB\n";
echo "<br>memory diff usage: ", number_format(((memory_get_usage() - $mem)/1024/1024), 3, '.', ',')." MiB\n";
echo "<br>seconds: ", number_format(microtime(TRUE) - $time, 4, '.', ',');
ob_end_flush();
?>
</body>
</html>