Skip to content

Commit

Permalink
Add composer and twig
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmeszaros committed Oct 2, 2017
1 parent 6928dd2 commit d5bbf67
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
.idea
config.php

/vendor/
/twig_cache
29 changes: 22 additions & 7 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,39 @@
<?php

// What page/algo we are on
$algo = 'bitcore';
// Add autoload
require __DIR__ . '/vendor/autoload.php';

// Connect mysql
$conn = include('config.php');
$conn = include_once('config.php');

/**
* Helper class
* @var minerHelper.php
*/
include_once('minerHelper.php');

// What page/algo we are on
$algo = 'bitcore';

// Gets data for specific miner address
$miner_address = $_GET['address'] ?? "";

$loader = new Twig_Loader_Filesystem(__DIR__ . '/templates');
$twig = new Twig_Environment($loader, [
'cache' => __DIR__ . '/twig_cache',
// 'auto_reload' => true // Should be turned off on production
]);

// Get workers for miner address
$workers = minerHelper::getWorkers($conn, $miner_address);
foreach ($workers as $worker) {
print 'Version: ' . $worker['version'];

foreach ($workers as $key => $worker) {
$hashrate = minerHelper::getHashrate($conn, $algo, $worker['version'], $worker['name']);
print ' - hashrate: ' . minerHelper::Itoa2($hashrate['hashrate']) . 'h/s';
print '<br />';
$workers[$key]['hashrate'] = minerHelper::Itoa2($hashrate['hashrate']) . 'h/s';
}

// Return TWIG template
print $twig->render('index.html.twig', [
'name' => 'Greg',
'workers' => $workers
]);

0 comments on commit d5bbf67

Please sign in to comment.