Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix various errors on strict or less up-to-date systems #6

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ function connect_database() {
lastseen INTEGER,
miners TEXT,
profit REAL,
PRIMARY KEY(address,workername)
) WITHOUT ROWID;");
PRIMARY KEY(address,workername));");
return $db;
}

Expand Down
45 changes: 32 additions & 13 deletions web/index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
<?php ini_set('display_errors','On');?>
<?php
ini_set('display_errors','On');

if (empty($_GET['address'])) {
$addr = "";
} else {
$addr = $_GET['address'];
}
?>

<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css"/>
Expand All @@ -7,14 +16,15 @@

<body>
<form method="GET">
Address: <input type="text" name="address" value="<?=$_GET['address']?>"/><input type="submit" value="Submit"/>
Address: <input type="text" name="address" value="<?=$addr?>"/><input type="submit" value="Submit"/>
</form>


<?php
if(empty($_GET['address'])) { exit; }

include('../functions.php');
date_default_timezone_set('UTC');

$workers = get_workers($_GET['address']);
if(empty($workers)) { echo "Nothing found."; exit;}
Expand Down Expand Up @@ -44,32 +54,41 @@

foreach($workerstatus as $m) {
$currentspeeds = array();
foreach($m->CurrentSpeed as $cs) {
foreach((array)$m->CurrentSpeed as $cs) {
$currentspeeds[] = ConvertToHashrate($cs);
}

$estimatedspeeds = array();
foreach($m->EstimatedSpeed as $es) {
foreach((array)$m->EstimatedSpeed as $es) {
$estimatedspeeds[] = ConvertToHashrate($es);
}

$mName = (array_key_exists('Name', $m)) ? $m->Name : "";
$mType = (array_key_exists('Type', $m)) ? implode(",",$m->Type) : "";
$mPool = (array_key_exists('Pool', $m)) ? implode(",",$m->Pool) : "";
$mPath = (array_key_exists('Path', $m)) ? $m->Path : "";
$mActive = (array_key_exists('Active', $m)) ? $m->Active : "";
$mAlgorithm = (array_key_exists('Algorithm', $m)) ? implode(",",$m->Algorithm) : "";
$mPID = (array_key_exists('PID', $m)) ? $m->PID : "";
$mBTCperday = (array_key_exists('BTC/day', $m)) ? $m->{'BTC/day'} : "";

echo "<tr>";
echo "<td>{$m->Name}</td>";
echo "<td>" . implode(",",$m->Type) . "</td>";
echo "<td>" . implode(",",$m->Pool) . "</td>";
echo "<td>{$m->Path}</td>";
echo "<td>{$m->Active}</td>";
echo "<td>" . implode(",",$m->Algorithm) . "</td>";
echo "<td>{$mName}</td>";
echo "<td>{$mType}</td>";
echo "<td>{$mPool}</td>";
echo "<td>{$mPath}</td>";
echo "<td>{$mActive}</td>";
echo "<td>{$mAlgorithm}</td>";
echo "<td>" . implode(",",$currentspeeds) . "</td>";
echo "<td>" . implode(",",$estimatedspeeds) . "</td>";
echo "<td>{$m->PID}</td>";
echo "<td>{$m->{'BTC/day'}}</td>";
echo "<td>{$mPID}</td>";
echo "<td>{$mBTCperday}</td>";
echo "</tr>";
}
echo "</table>";
} else {
echo "Not reported";
}
}
echo "</td>";
echo "</tr>";
}
Expand Down