-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathputstats.php
More file actions
executable file
·50 lines (38 loc) · 1.75 KB
/
putstats.php
File metadata and controls
executable file
·50 lines (38 loc) · 1.75 KB
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
<?php
$now = time();
$type = $_GET['type'];
include("config.php");
$db = mysql_connect($host,$dbuser,$dbpassword);
mysql_select_db($database,$db);
$sql = "SELECT time FROM global_stats ORDER BY time DESC LIMIT 0,1";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$timestamp = $row[0];
//echo $timestamp;
//This lets us run get more current stats if the api drops for some reason
/*
$sql = "SELECT * FROM global_stats ORDER BY time DESC LIMIT 0,36";
$result = mysql_query($sql);
$average = 0;
while($row = mysql_fetch_row($result)) {
echo "<br />Hashrate: ".$row['hashrate'];
$average += (float)$row['hashrate'];
}
$average = $average / 36;
echo $average;*/
if ($timestamp+300 <= $now) {
if(isset($_GET['api_key'])) $api_key = $_GET['api_key'];
require_once('getstats.php');
$sql = "select sum(hashrate) / count(id) as average from global_stats where time > (UNIX_TIMESTAMP()-10800)";
$row = mysql_fetch_row(mysql_query($sql));
$average = $row[0];
echo $average;
//$sql_global = "INSERT INTO `arsbtcstats`.`global_stats` (`id`, `time`, `hashrate`, `workers`) VALUES (NULL, '$now', '$hashrate_global', '$workers');";
//$query_global = mysql_query($sql_global);
$sql_global = "INSERT INTO `arsbtcstats`.`global_stats` (`id`, `time`, `hashrate`, `workers`, `network_hashrate`, `buffer`, `Users`,`average`) VALUES (NULL, '$now', '$hashrate_global', null, '$network_hashrate', '$buffer', '$users','$average');";
$query_global = mysql_query($sql_global);
$sql_personal = "INSERT INTO `arsbtcstats`.`personal_stats` (`id`, `time`, `hashrate`, `confirmed_rewards`, `payout_history`) VALUES (NULL, '$now', '$hashrate_personal', '$confirmed_rewards', '$payout_history');";
$query_personal = mysql_query($sql_personal);
include("getblocks.php");
}
?>