-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathledger.php
executable file
·82 lines (74 loc) · 2.07 KB
/
ledger.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
<?php
$ledg = $_REQUEST['ledg'];
#$padopts =
# "showControls=false&showChat=false&showLineNumbers=true"
$padurl = "https://padm.us/yl-$ledg"; #?showControls=false";
$snap = file_exists("data/$ledg-snapshot.txt");
$balfile = "data/$ledg-balances.txt";
echo <<<_END
<html><head><title>Ledger: $ledg</title>
<base href="/" />
<link rel="stylesheet" type="text/css" href="/ledger.css" />
<link rel="shortcut icon" type="image/icon" href="/favicon.ico" />
<script type="text/javascript" src="/jquery.js"></script>
<script type="text/javascript" src="/yootles.js"></script>
</head><body>
<div id="yltop">
<h3>
<a href="$padurl">Full Screen</a>
•
<a href="/$ledg/transactions">Transactions</a>
(<a href="/$ledg-transactions.csv">CSV</a>)
•
_END;
if($ledg == "test") echo "[This is the Sandbox]";
else echo '<a href="/test">Sandbox</a>';
echo <<<_END
•
<input type="button" id="btnSubmit" value="Refresh Balances"
style="padding:0px;" />
</h3>
<div id="response">
_END;
if(!$snap) {
echo <<<_END
<h3>To create a ledger here, paste into the etherpad the template for the ledger
below.
Then click "Refresh Balances" above.</h3>
_END;
} elseif(!file_exists($balfile) || !is_readable($balfile)) {
echo "<pre>[No balances have been computed for $ledg]<pre>\n";
} else { include $balfile; }
echo <<<_END
</div>
</div>
<div class="spacer"></div>
<div id="ep">
<iframe src="$padurl"></iframe>
<!-- this didn't help i guess: sandbox="allow-same-origin allow-scripts allow-forms allow-cookies" -->
</div>
<div id="static">
_END;
if($snap) {
echo <<<_END
<h3>Snapshot of ledger from the last time balances were computed:</h3>
_END;
} else {
echo <<<_END
<h2>Copy the text below into the etherpad above to start a new ledger here.</h2>
_END;
}
echo <<<_END
<textarea readonly rows=50 cols=100>
_END;
if($snap) {
include "data/$ledg-snapshot.txt";
} else {
include "data/template-snapshot.txt";
}
echo <<<_END
</textarea>
</div>
</body></html>
_END;
?>