-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapps.functions.php
More file actions
executable file
·69 lines (61 loc) · 2.52 KB
/
apps.functions.php
File metadata and controls
executable file
·69 lines (61 loc) · 2.52 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
69
<?php
global $_config;
if($_config['testnet']) {
define("APPS_REPO_SERVER","https://repo.testnet.phpcoin.net:8001");
define("APPS_REPO_SERVER_PUBLIC_KEY","PZ8Tyr4Nx8MHsRAGMpZmZ6TWY63dXWSCwUKtSuRJEs8RrRrkZbND1WxVNomPtvowAo5hzQr6xe2TUyHYLnzu2ubVMfBAYM4cBZJLckvxWenHB2nULzmU8VHz");
define("APPS_WALLET_SERVER_NAME","wallet.testnet.phpcoin.net:8001");
define("APPS_WALLET_SERVER_PUBLIC_KEY","PZ8Tyr4Nx8MHsRAGMpZmZ6TWY63dXWSCxxo8UaTrKLceuCRRC4YopodMLvtPp31Bq1JJBmva3StkHMPa2WhgXhPyPLG9GiwEW3PwXDyroZGfNLE4ioqRtwyp");
} else {
define("APPS_REPO_SERVER","https://repo.phpcoin.net");
define("APPS_REPO_SERVER_PUBLIC_KEY","PZ8Tyr4Nx8MHsRAGMpZmZ6TWY63dXWSCyHWjnG15LHdWRRbNEmAPiYcyCqFZm1VKi8QziKYbMtrXUw8rqhrS3EEoyJxXASNZid9CsB1dg64u5sYgnUsrZg7C");
define("APPS_WALLET_SERVER_NAME","wallet.phpcoin.net");
define("APPS_WALLET_SERVER_PUBLIC_KEY","PZ8Tyr4Nx8MHsRAGMpZmZ6TWY63dXWSD1SfcgMjJaHdx6p3BT9Jft9NXyh57c1EnisRgbtLDzXfEwddq6i717adJKkw82HMJDfRD8PZikraaq1HnBdCVxLsY");
}
function calcAppsHash() {
$cmd = "cd ".ROOT."/web && tar -cf - apps --owner=0 --group=0 --sort=name --mode=744 --mtime='2020-01-01 00:00:00 UTC' | sha256sum";
$res = shell_exec($cmd);
$arr = explode(" ", $res);
$appsHash = trim($arr[0]);
_log("Executing calcAppsHash appsHash=$appsHash", 5);
return $appsHash;
}
function buildAppsArchive() {
$res = shell_exec("ps uax | grep 'tar -czf tmp/apps.tar.gz web/apps' | grep -v grep");
_log("Repo: check buildAppsArchive res=$res", 5);
if($res) {
_log("Repo: buildAppsArchive running", 5);
return false;
} else {
_log("Repo: buildAppsArchive call process", 5);
$cmd = "cd ".ROOT." && tar -czf tmp/apps.tar.gz web/apps --owner=0 --group=0 --sort=name --mode=744 --mtime='2020-01-01 00:00:00 UTC'";
shell_exec($cmd);
return true;
}
}
function truncate_hash($hash, $digits = 8) {
if(empty($hash)) {
return null;
}
$thash = substr($hash, 0, $digits) . "..." . substr($hash, -$digits);
return '<span data-bs-toggle="tooltip" title="'.$hash.'">' . $thash . '</span>';
}
function explorer_address_link2($address, $short= false) {
$text = $address;
if($short) {
$text = truncate_hash($address);
}
return '<a target="_blank" href="/apps/explorer/address.php?address='.$address.'">'.$text.'</a>';
}
function TransactionTypeLabel($type) {
return Transaction::typeLabel($type);
}
function AccountgetCountByAddress($id) {
//TODO: replace with Account::getCountByAddress
global $db;
$res = $db->single(
"SELECT count(*) as cnt FROM transactions
WHERE dst=:dst or src=:src",
[":src" => $id, ":dst" => $id]
);
return $res;
}