goback(); $this->pageTitle = 'Console - '.$coin->symbol; $remote = new WalletRPC($coin); echo getAdminSideBarLinks().'

'; $info = $remote->getinfo(); if (!$info) { echo $remote->error; return; } echo getAdminWalletLinks($coin, $info, 'console').'

'; ////////////////////////////////////////////////////////////////////////////////////// function colorizeJson($json) { $json = str_replace('"', '"', $json); // strings $res = preg_match_all("# "([^&]+)"([,\s])#", $json, $matches); if ($res) foreach($matches[1] as $n=>$m) { $sfx = $matches[2][$n]; $class = ''; if (strlen($m) == 64 && ctype_xdigit($m)) $class = 'hash'; if (strlen($m) == 34 && ctype_alnum($m)) $class = 'addr'; if (strlen($m) == 35 && ctype_alnum($m)) $class = 'addr'; if (strlen($m) > 160 && ctype_alnum($m)) $class = 'data'; if ($class == '' && strlen($m) < 64 && ctype_xdigit($m)) $class = 'hexa'; $json = str_replace(' "'.$m.""".$sfx, ' "'.$m.'"'.$sfx, $json); } // keys $res = preg_match_all("#"([^&]+)":#", $json, $matches); if ($res) foreach($matches[1] as $n=>$m) { $json = str_replace('"'.$m.""", '"'.$m.'"', $json); } // humanize timestamps like "blocktime": 1462359961, $res = preg_match_all("#: ([0-9]{10})([,\s])#", $json, $matches); if ($res) foreach($matches[1] as $n=>$m) { $ts = intval($m); if ($ts > 1400000000 && $ts < 1600000000) { $sfx = $matches[2][$n]; $date = strftime("%Y-%m-%d %T %z", $ts); $json = str_replace(' '.$m.$sfx, ' "'.$date.'"'.$sfx, $json); } } // numeric $res = preg_match_all("#: ([e\-\.0-9]+)([,\s])#", $json, $matches); if ($res) foreach($matches[1] as $n=>$m) { $sfx = $matches[2][$n]; $json = str_replace(' '.$m.$sfx, ' '.$m.''.$sfx, $json); } $json = preg_replace('#\[\s+\]#', '[]', $json); $json = str_replace('[', '[', $json); $json = str_replace(']', ']', $json); $json = str_replace('{', '{', $json); $json = str_replace('}', '}', $json); return $json; } ////////////////////////////////////////////////////////////////////////////////////// $last_query = htmlentities(trim($query)); echo << function main_resize() { var w = 0 + jQuery('div.form').width(); var wpx = (w - 100).toString() + 'px'; jQuery('.main-text-input').css({width: wpx}); } var lazyLinks; function main_json_links() { if (lazyLinks) clearTimeout(lazyLinks); jQuery('s.addr').each(function(n) { var el = $(this); var addr = el[0].innerText; var link = '' + addr + ''; el.html(link); }); jQuery('s.hash').each(function(n) { var el = $(this); var hash = el[0].innerText; var link = '' + hash + ''; el.html(link); }); }
end; $result = ''; if (!empty($query)) { $result = $remote->execute($query); if ($result === false) { $result = $remote->error; } debuglog("{$coin->symbol} CONSOLE {$query}"); } if (!empty($remote->error) && $remote->error != $result) { $err = $remote->error; echo '
'; echo is_string($err) ? htmlentities($err) : htmlentities(json_encode($err, 128)); echo '
'; } echo '
'; echo is_string($result) ? htmlentities($result) : colorizeJson(htmlentities(json_encode($result, 128))); echo '
'; JavascriptReady("main_resize(); $(window).resize(main_resize); $('.main-text-input:first').focus();"); JavascriptReady("lazyLinks = setTimeout(main_json_links, 2000);");