-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminercheck.php
executable file
·40 lines (34 loc) · 1.26 KB
/
minercheck.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
#!/usr/bin/php
<?php
set_time_limit(0);
error_reporting(0);
$servername = "";
$username = "";
$password = "";
$dbname = "evergreen";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
echo "Mysql error";
die("Connection failed: " . mysqli_connect_error());
}
$updatedeal3 ="SELECT deal_id, provider FROM deals GROUP BY(provider)";
$result3 = mysqli_query($conn, $updatedeal3);
while ($row = mysqli_fetch_array($result3)) {
$provider = $row['provider'];
$updatedeal ="INSERT IGNORE INTO `miners` (`id`, `provider`) VALUES (NULL, '$provider') ";
$result = mysqli_query($conn, $updatedeal);
// Check if this thing is alive
$src = shell_exec("/usr/bin/timeout 10 /usr/local/bin/lotus client query-ask $provider");
// We are looking for this string: Verified Price per GiB: 0 FIL
if (strstr($src, 'Verified Price per GiB: 0 FIL')) {
// Update the database to refect the deal
$updatedeal ="UPDATE `miners` SET ok = '1' WHERE `provider` = '$provider'";
$result = mysqli_query($conn, $updatedeal);
} else {
$updatedeal ="UPDATE `miners` SET ok IS NULL WHERE `provider` = '$provider'";
$result = mysqli_query($conn, $updatedeal);
}
}
?>