Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>
- AngelShares Distro
- </title>
- <style>
- #left {
- float: left;
- width: 50%;
- }
- #right {
- float: right;
- width: 50%;
- }
- #infobox {
- margin: auto;
- padding: 20px;
- width: 300px;
- text-align: left;
- }
- .clear {
- clear:both;
- }
- .header {
- font-weight: bold;
- text-decoration: underline;
- }
- #bottominfo {
- position: fixed;
- bottom: 0px;
- width: 100%;
- text-align: center;
- background-color: #fff;
- }
- </style>
- </head>
- <body>
- <?php
- $time = microtime();
- $time = explode(' ', $time);
- $time = $time[1] + $time[0];
- $start = $time;
- date_default_timezone_set('UTC');
- $time = time();
- $day_one = 1388534400;
- //convert seconds to time for time remaining in period
- function secondsToTime($inputSeconds) {
- $secondsInAMinute = 60;
- $secondsInAnHour = 60 * $secondsInAMinute;
- $secondsInADay = 24 * $secondsInAnHour;
- // extract hours
- $hourSeconds = $inputSeconds % $secondsInADay;
- $hours = sprintf('%02d',floor($hourSeconds / $secondsInAnHour));
- // extract minutes
- $minuteSeconds = $hourSeconds % $secondsInAnHour;
- $minutes = sprintf('%02d',floor($minuteSeconds / $secondsInAMinute));
- // extract the remaining seconds
- $remainingSeconds = $minuteSeconds % $secondsInAMinute;
- $seconds = sprintf('%02d',ceil($remainingSeconds));
- return $hours . ":" . $minutes . ":" . $seconds;
- }
- //Collect BTC and PTS blockchain data parsed by donschoe
- $fileName_btc = "http://q39.qhor.net/ags/btc.csv.txt";
- $fileName_pts = "http://q39.qhor.net/ags/pts.csv.txt";
- $csvData_btc = file_get_contents($fileName_btc);
- $csvData_pts = file_get_contents($fileName_pts);
- $lines_btc = explode("\n", $csvData_btc);
- $lines_pts = explode("\n", $csvData_pts);
- //BTC - collect all blockchain data in array
- $i = 0;
- foreach ($lines_btc as $line) {
- $pattern = "/\"/";
- $replace = "";
- $line = preg_replace($pattern,$replace,$line);
- $lineex = explode(";",$line);
- $all_btc[$i]['block'] = $lineex[0];
- $all_btc[$i]['datetime'] = $lineex[1];
- $all_btc[$i]['sender'] = $lineex[2];
- $all_btc[$i]['donation'] = $lineex[3];
- $all_btc[$i]['sum'] = $lineex[4];
- $all_btc[$i]['rate'] = $lineex[5];
- $i++;
- }
- unset($all_btc[0]);
- unset($all_btc[($i-1)]);
- //PTS - collect all blockchain data in array
- $j = 0;
- foreach ($lines_pts as $line) {
- $pattern = "/\"/";
- $replace = "";
- $line = preg_replace($pattern,$replace,$line);
- $lineex = explode(";",$line);
- $all_pts[$j]['block'] = $lineex[0];
- $all_pts[$j]['datetime'] = $lineex[1];
- $all_pts[$j]['sender'] = $lineex[2];
- $all_pts[$j]['donation'] = $lineex[3];
- $all_pts[$j]['sum'] = $lineex[4];
- $all_pts[$j]['rate'] = $lineex[5];
- $j++;
- }
- unset($all_pts[0]);
- unset($all_pts[($j-1)]);
- //find current period using BTC data
- $last_date_val = $all_btc[($i-2)]['datetime'];
- $last_date_val_f = substr($last_date_val, 0, 10);
- $current_day = strtotime($last_date_val_f);
- //find time left in current period
- $sec_til_next = (86400 - ($time-$current_day));
- $pct_day_gone = (86400-$sec_til_next)/86400;
- //count total periods (including current period)
- $total_days = (($current_day-$day_one)/86400)+1;
- //BTC - filter donation data for all periods
- $all_btc_donation = array();
- $all_btc_datetime = array();
- $k = 0;
- foreach ($all_btc as $p) {
- $all_btc_donation[] = $p['donation'];
- $all_btc_datetime[] = $p['datetime'];
- //BTC - collect current period btc data in separate array
- if (substr($p['datetime'],0,10) == $last_date_val_f){
- $k++;
- $period_btc[$k]['block'] = $p['block'];
- $period_btc[$k]['datetime'] = $p['datetime'];
- $period_btc[$k]['sender'] = $p['sender'];
- $period_btc[$k]['donation'] = $p['donation'];
- $period_btc[$k]['sum'] = $p['sum'];
- $period_btc[$k]['rate'] = $p['rate'];
- }
- }
- //BTC - filter donation data for current period
- $period_btc_donation = array();
- foreach ($period_btc as $q) {
- $period_btc_donation[] = $q['donation'];
- }
- $top_all_btc = max($all_btc_donation); //BTC all - calculate top donation
- $sum_all_btc = array_sum($all_btc_donation); //BTC all - calculate sum of donation
- $amt_all_btc = $i-1; //BTC all - calculate number of donations
- $ags_all_btc = $sum_all_btc / (5000*$total_days); //BTC all - calculate AGS/BTC
- $wt_ags_all_btc = $sum_all_btc / ((5000*($total_days-1))+(5000*$pct_day_gone)); //BTC all - calculate weighted AGS/BTC
- $top_period_btc = max($period_btc_donation); //BTC period - calculate top donation
- $sum_period_btc = array_sum($period_btc_donation); //BTC period - calculate sum of donation
- $amt_period_btc = count($period_btc); //BTC period - calculate number of donations
- $ags_period_btc = $sum_period_btc / (5000); //BTC period - calculate AGS/BTC
- $wt_ags_period_btc = $sum_period_btc / (5000*$pct_day_gone); //BTC period - calculate weighted AGS/BTC
- //PTS - filter donation data for all periods
- $all_pts_donation = array();
- $all_pts_datetime = array();
- $k = 0;
- foreach ($all_pts as $p) {
- $all_pts_donation[] = $p['donation'];
- $all_pts_datetime[] = $p['datetime'];
- //PTS - collect current period btc data in separate array
- if (substr($p['datetime'],0,10) == $last_date_val_f){
- $k++;
- $period_pts[$k]['block'] = $p['block'];
- $period_pts[$k]['datetime'] = $p['datetime'];
- $period_pts[$k]['sender'] = $p['sender'];
- $period_pts[$k]['donation'] = $p['donation'];
- $period_pts[$k]['sum'] = $p['sum'];
- $period_pts[$k]['rate'] = $p['rate'];
- }
- }
- //PTS - filter donation data for current period
- $period_pts_donation = array();
- foreach ($period_pts as $r) {
- $period_pts_donation[] = $r['donation'];
- }
- $top_all_pts = max($all_pts_donation); //PTS all - calculate top donation
- $sum_all_pts = array_sum($all_pts_donation); //PTS all - calculate sum of donation
- $amt_all_pts = $j-1; //PTS all - calculate number of donations
- $ags_all_pts = $sum_all_pts / (5000*$total_days); //PTS all - calculate AGS/PTS
- $wt_ags_all_pts = $sum_all_pts / ((5000*($total_days-1))+(5000*$pct_day_gone)); //PTS all - calculate weighted AGS/PTS
- $top_period_pts = max($period_pts_donation); //PTS period - calculate top donation
- $sum_period_pts = array_sum($period_pts_donation); //PTS period - calculate sum of donation
- $amt_period_pts = count($period_pts); //PTS period - calculate number of donations
- $ags_period_pts = $sum_period_pts / (5000); //PTS period - calculate AGS/PTS
- $wt_ags_period_pts = $sum_period_pts / (5000*$pct_day_gone); //PTS period - calculate weighted AGS/PTS
- //display results
- echo "<p align='center'>AGS distributed to date: ".number_format((($total_days-1)*5000), 0, '.', ',')." of 1,000,000</p>";
- echo "<p align='center'>Current Period: ".$total_days." of 200";
- echo "<p align='center'>Today's date: ".$last_date_val_f."</p>";
- echo "<p align='center'>Time to next Period: ".secondsToTime($sec_til_next)."</p>";
- echo "<div id='left'>";
- echo "<div id='infobox'>";
- echo "<p class='header' align='center'>Current Period BTC</p>";
- echo "Sum of Donations: ".$sum_period_btc."<br>Amt of Donations: ".$amt_period_btc."<br>Top Donation: ".$top_period_btc."<br>Price per AGS: ".$ags_period_btc."<br>Wtd Price per AGS: ".$wt_ags_period_btc;
- echo "</div>";
- echo "</div>";
- echo "<div id='right'>";
- echo "<div id='infobox'>";
- echo "<p class='header' align='center'>Current Period PTS</p>";
- echo "Sum of Donations: ".$sum_period_pts."<br>Amt of Donations: ".$amt_period_pts."<br>Top Donation: ".$top_period_pts."<br>Price per AGS: ".$ags_period_pts."<br>Wtd Price per AGS: ".$wt_ags_period_pts;
- echo "</div>";
- echo "</div>";
- echo "<div id='left'>";
- echo "<div id='infobox'>";
- echo "<p class='header' align='center'>Overall BTC</p>";
- echo "Sum of Donations: ".$sum_all_btc."<br>Amt of Donations: ".$amt_all_btc."<br>Top Donation: ".$top_all_btc."<br>Price per AGS: ".$ags_all_btc."<br>Wtd Price per AGS: ".$wt_ags_all_btc;
- echo "</div>";
- echo "</div>";
- echo "<div id='right'>";
- echo "<div id='infobox'>";
- echo "<p class='header' align='center'>Overall PTS</p>";
- echo "Sum of Donations: ".$sum_all_pts."<br>Amt of Donations: ".$amt_all_pts."<br>Top Donation: ".$top_all_pts."<br>Price per AGS: ".$ags_all_pts."<br>Wtd Price per AGS: ".$wt_ags_all_pts;
- echo "</div>";
- echo "</div>";
- $time = microtime();
- $time = explode(' ', $time);
- $time = $time[1] + $time[0];
- $finish = $time;
- $total_time = round(($finish - $start), 4);
- echo "<div id='bottominfo' class='clear'>";
- echo "<p style='font-size: 14px;'>NOTE: Weighted prices assume a linear increase of AGS from 0 to 5000 in current period.</p>";
- echo "<p style='font-size: 12px;'>Page generated in ".$total_time." seconds.";
- echo "<p style='font-size: 12px;'>Blockchain data provided by <a href='https://bitsharestalk.org/index.php?topic=1853.0'>donschoe</a> (v0.2)</p>";
- echo "</div>";
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement