-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgetInfo.php
More file actions
68 lines (51 loc) · 1.56 KB
/
getInfo.php
File metadata and controls
68 lines (51 loc) · 1.56 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
//echo __LINE__ . "\n";
include('include.php');
//echo __LINE__ . "\n";
//$infotype = $argv[1];
$infotypeArray = array(
'largestblock'=>'largestblock',
'getOneBroken'=>'getOneBroken',
'getGap'=>'getGap',
'notConfirmed'=>'notConfirmed'
);
$infotype = $infotypeArray[$infotype];
//$response = $infotype;
if ( 'largestblock' == $infotype )
{
$query = "select max(id) as id from blocks";
$sth = $pdo->prepare($query);
$sth->execute();
$result = $sth->fetchAll(PDO::FETCH_COLUMN, 0);
$response = ($result[0]);
}
if ( 'getOneBroken' == $infotype )
{
$query = "select id from blocks left outer join receipts on ( blocks.id = receipts.block_id ) where receipts.block_id is null limit 1";
echo $query;
$sth = $pdo->prepare($query);
$sth->execute();
$result = $sth->fetchAll(PDO::FETCH_COLUMN, 0);
$response = ($result[0]);
}
if ( 'getGap' == $infotype )
{
$query = "SELECT (t1.id + 1) as gap_starts_at,
(SELECT MIN(t3.id) -1 FROM blocks t3 WHERE t3.id > t1.id) as gap_ends_at
FROM blocks t1
WHERE NOT EXISTS (SELECT t2.id FROM blocks t2 WHERE t2.id = t1.id + 1)
HAVING gap_ends_at IS NOT NULL limit 1";
$sth = $pdo->prepare($query);
$sth->execute();
$result = $sth->fetchAll();
//$response = (print_r($result,1));
$response = ($result[0][0].",".$result[0][1]);
}
if ( 'notConfirmed' == $infotype )
{
$query = "select min(id) as min, max(id) as max from blocks where ts < date_sub(now(), interval 3 minute) and confirm < 20;";
$sth = $pdo->prepare($query);
$sth->execute();
$result = $sth->fetchAll();
$response = ($result[0][0].",".$result[0][1]);
}