diff --git a/web/yaamp/modules/site/coin_console.php b/web/yaamp/modules/site/coin_console.php index 5787d38..ae5ed4a 100644 --- a/web/yaamp/modules/site/coin_console.php +++ b/web/yaamp/modules/site/coin_console.php @@ -17,7 +17,21 @@ echo getAdminWalletLinks($coin, $info, 'console').'

'; ////////////////////////////////////////////////////////////////////////////////////// -$last_query = htmlentities($query); +function humanizeJson($json) +{ + // timestamps like "blocktime": 1462359961, + $res = preg_match_all("#\": ([0-9]{10}),#", $json, $matches, PREG_OFFSET_CAPTURE); + if ($res) foreach($matches[1] as $m) { + $ts = intval($m[0]); + $date = strftime("%Y-%m-%d %T %z", $ts); + $json = str_replace(' '.$m[0].",", ' "'.$date.'",', $json); + } + return $json; +} + +////////////////////////////////////////////////////////////////////////////////////// + +$last_query = htmlentities(trim($query)); echo << @@ -30,6 +44,7 @@ function main_resize() { @@ -44,7 +59,7 @@ end; $result = ''; if (!empty($query)) try { - $params = split(' ', $query); + $params = split(' ', trim($query)); $command = array_shift($params); $p = array(); @@ -72,6 +87,12 @@ if (!empty($query)) try { case 5: $result = $remote->$command($p[0], $p[1], $p[2], $p[3], $p[4]); break; + case 6: + $result = $remote->$command($p[0], $p[1], $p[2], $p[3], $p[4], $p[5]); + break; + case 7: + $result = $remote->$command($p[0], $p[1], $p[2], $p[3], $p[4], $p[5], $p[6]); + break; default: $result = 'error: too much parameters'; } @@ -80,8 +101,15 @@ if (!empty($query)) try { $result = $remote->error; } +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) : htmlentities(json_encode($result, 128));
+echo is_string($result) ? htmlentities($result) : htmlentities(humanizeJson(json_encode($result, 128)));
 echo '
'; JavascriptReady("main_resize(); $(window).resize(main_resize); $('.main-text-input:first').focus();"); diff --git a/web/yaamp/modules/site/results/graph_price_results.php b/web/yaamp/modules/site/results/graph_price_results.php index 28b37c3..50536c5 100644 --- a/web/yaamp/modules/site/results/graph_price_results.php +++ b/web/yaamp/modules/site/results/graph_price_results.php @@ -6,49 +6,47 @@ $algo = user()->getState('yaamp-algo'); $step = 15*60; $t = time() - 24*60*60; -$stats = getdbolist('db_hashrate', "time>$t and algo=:algo order by time", array(':algo'=>$algo)); +$stats = getdbolist('db_hashrate', "time > $t AND algo=:algo ORDER BY time", array(':algo'=>$algo)); $averages = array(); -echo '[['; - +$json = ''; for($i = 0; $i < 95-count($stats); $i++) { $d = date('Y-m-d H:i:s', $t); - echo "[\"$d\",0],"; + $json .= "[\"$d\",0],"; $t += $step; $averages[] = array($d, 0); } -foreach($stats as $i=>$n) +foreach($stats as $n) { $m = $n->price; - if($i) echo ','; $d = date('Y-m-d H:i:s', $n->time); - echo "[\"$d\",$m]"; + $json .= "[\"$d\",$m],"; $averages[] = array($d, $m); } +echo '[['; +echo rtrim($json, ','); echo '],['; +$json = ''; $average = $averages[0][1]; -foreach($averages as $i=>$n) +foreach($averages as $n) { - if($i) echo ','; - $average = ($average*(100-$percent) + $n[1]*$percent) / 100; $m = round($average, 5); - echo "[\"{$n[0]}\",$m]"; + $json .= "[\"{$n[0]}\",$m],"; } // $a = 10; // foreach($averages as $i=>$n) // { // if($i < $a) continue; -// if($i > $a) echo ','; // $average = 0; // for($j = $i-$a+1; $j<=$i; $j++) @@ -59,10 +57,6 @@ foreach($averages as $i=>$n) // echo "[\"{$n[0]}\",$m]"; // } +echo rtrim($json, ','); echo ']]'; - - - - -