Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>
- AngelShares Summary
- </title>
- <link rel="stylesheet" type="text/css" href="../../css/bootstrap.min.css" />
- <style>
- .bold {
- font-weight: bold;
- text-align: center;
- }
- #left {
- float: left;
- width: 450px;
- height: 285px;
- }
- #right {
- float: right;
- width: 450px;
- height: 285px;
- }
- #infobox {
- margin: auto;
- padding: 10px 20px 5px 20px;
- }
- .clear {
- clear:both;
- }
- .header {
- font-weight: bold;
- text-decoration: underline;
- }
- #bottominfo {
- position: fixed;
- bottom: 0px;
- width: 100%;
- text-align: center;
- background-color: #fff;
- }
- #centerbox {
- margin-left: 450px;
- margin-right: 450px;
- position:absolute;
- top:0px;
- height:500px;
- width: 300px;
- }
- h4 {
- line-height:200%
- }
- #container {
- width: 1200px;
- height: 675px;
- padding-top: 10px;
- }
- .Absolute-Center {
- margin: auto;
- top: 0;
- }
- .highlight {
- color: #009051;
- }
- </style>
- </head>
- <body>
- <div id="container" class="Absolute-Center">
- <?php
- $time = microtime();
- $time = explode(' ', $time);
- $time = $time[1] + $time[0];
- $start = $time;
- function GetJsonFeed($json_url)
- {
- $feed = file_get_contents($json_url);
- return json_decode($feed, true);
- };
- $pts_btc = GetJsonFeed("http://bter.com/api/1/ticker/pts_btc/");
- $btc_usd = GetJsonFeed("https://api.bitcoinaverage.com/ticker/USD");
- 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/3/btc.csv.txt";
- //$fileName_btc = "../btctemp.txt";
- $fileName_pts = "http://q39.qhor.net/ags/3/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[4];
- //$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[$i]['block'] = $lineex[0];
- $all_pts[$j]['datetime'] = $lineex[1];
- //$all_pts[$i]['sender'] = $lineex[2];
- $all_pts[$j]['donation'] = $lineex[4];
- //$all_pts[$i]['sum'] = $lineex[4];
- //$all_pts[$i]['rate'] = $lineex[5];
- $j++;
- }
- unset($all_pts[0]);
- unset($all_pts[($j-1)]);
- //find current period using PTS data
- $last_date_val = $all_pts[($j-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'];
- }
- }
- $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
- if (isset($period_btc)){
- //BTC - filter donation data for current period
- $period_btc_donation = array();
- foreach ($period_btc as $q) {
- $period_btc_donation[] = $q['donation'];
- }
- $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
- if ($wt_ags_period_btc < $wt_ags_all_btc) { $btc_status = "<span style='color: #009d00'>Undervalued by ".round(((($wt_ags_all_btc/$wt_ags_period_btc)-1)*100),2)."%*</span>";}
- if ($wt_ags_period_btc > $wt_ags_all_btc) { $btc_status = "<span style='color: #ff0000'>Overvalued by ".round(((($wt_ags_period_btc/$wt_ags_all_btc)-1)*100),2)."%*</span>";}
- if ($wt_ags_period_btc == $wt_ags_all_btc) { $btc_status = "<span style='color: #0000ff'>Fairvalued*</span>";}
- }
- //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
- if ($wt_ags_period_pts < $wt_ags_all_pts) { $pts_status = "<span style='color: #009d00'>Undervalued by ".round(((($wt_ags_all_pts/$wt_ags_period_pts)-1)*100),2)."%*</span>";}
- if ($wt_ags_period_pts > $wt_ags_all_pts) { $pts_status = "<span style='color: #ff0000'>Overvalued by ".round(((($wt_ags_period_pts/$wt_ags_all_pts)-1)*100),2)."%*</span>";}
- if ($wt_ags_period_pts == $wt_ags_all_pts) { $pts_status = "<span style='color: #0000ff'>Fairvalued*</span>";}
- //display results
- echo "<div id='centerbox'>";
- echo "<h3 align='center'><b><u>AngelShares Statistics</u></b></h4>";
- echo "<h4 align='center'><b>AGS distributed to date:</b><br><span class='lead'> ".number_format((($total_days-1)*5000*2), 0, '.', ',')." of 2,000,000</span></h4>";
- echo "<h4 align='center'><b>Current Period:</b><br><span class='lead'> ".$total_days." of 200</span></h4>";
- echo "<h4 align='center'><b>Today's date:</b><br><span class='lead'> ".$last_date_val_f."</span></h4>";
- echo "<h4 align='center'><b>Time to next Period:</b><br><span class='lead'> ".secondsToTime($sec_til_next)."</span></h4>";
- echo "<h4 align='center'><b>AGS/BTC is currently</b><br><span class='lead'> ".$btc_status."</span></h4>";
- echo "<h4 align='center'><b>AGS/PTS is currently</b><br><span class='lead'> ".$pts_status."</span></h4>";
- echo "<p align='center'><small>* comparing current period to overall weighted prices</small></p>";
- echo "<p align='center'><small>** bter.com (BTC/PTS), bitcoinaverage.com (USD/BTC)</small></p>";
- echo "</div>";
- echo "<div id='left'>";
- echo "<div id='infobox'>";
- if (isset($period_btc)){
- echo "<p class='header' align='center'>Current Period BTC</p>";
- } else {
- echo "<p class='header' align='center'>BTC Data is parsing...</p>";
- }
- echo "<table class='table table-striped'>";
- echo "<tr><td align='right'>Sum of Donations:</td><td>".$sum_period_btc."</td></tr>";
- echo "<tr><td align='right'>Amt of Donations:</td><td>".$amt_period_btc."</td></tr>";
- echo "<tr><td align='right'>Top Donation:</td><td>".$top_period_btc."</td></tr>";
- echo "<tr><td align='right'>Price per AGS:</td><td>".$ags_period_btc."</td></tr>";
- echo "<tr><td align='right'>Wtd Price per AGS:</td><td>".$wt_ags_period_btc."</td></tr>";
- echo "<tr class='highlight'><td align='right'>Wtd USD per AGS:</td><td class='bold'>$".number_format(($wt_ags_period_btc*$btc_usd['last']), 2, '.', ',')."**</td></tr>";
- echo "</table>";
- echo "</div>";
- echo "</div>";
- echo "<div id='right'>";
- echo "<div id='infobox'>";
- echo "<p class='header' align='center'>Current Period PTS</p>";
- echo "<table class='table table-striped'>";
- echo "<tr><td align='right'>Sum of Donations:</td><td>".$sum_period_pts."</td></tr>";
- echo "<tr><td align='right'>Amt of Donations:</td><td>".$amt_period_pts."</td></tr>";
- echo "<tr><td align='right'>Top Donation:</td><td>".$top_period_pts."</td></tr>";
- echo "<tr><td align='right'>Price per AGS:</td><td>".$ags_period_pts."</td></tr>";
- echo "<tr><td align='right'>Wtd Price per AGS:</td><td>".$wt_ags_period_pts."</td></tr>";
- echo "<tr class='highlight'><td align='right'>Wtd USD per AGS:</td><td class='bold'>$".number_format(($wt_ags_period_pts*$pts_btc['last']*$btc_usd['last']), 2, '.', ',')."**</td></tr>";
- echo "</table>";
- echo "</div>";
- echo "</div>";
- echo "<div id='left'>";
- echo "<div id='infobox'>";
- if (isset($period_btc)){
- echo "<p class='header' align='center'>Overall BTC</p>";
- } else {
- echo "<p class='header' align='center'>BTC Data is parsing...</p>";
- }
- //echo "<p class='header' align='center'>Overall BTC</p>";
- echo "<table class='table table-striped'>";
- echo "<tr><td align='right'>Sum of Donations:</td><td>".$sum_all_btc."</td></tr>";
- echo "<tr><td align='right'>Amt of Donations:</td><td>".$amt_all_btc."</td></tr>";
- echo "<tr><td align='right'>Top Donation:</td><td>".$top_all_btc."</td></tr>";
- echo "<tr><td align='right'>Price per AGS:</td><td>".$ags_all_btc."</td></tr>";
- echo "<tr><td align='right'>Wtd Price per AGS:</td><td>".$wt_ags_all_btc."</td></tr>";
- echo "<tr class='highlight'><td align='right'>Wtd USD per AGS:</td><td class='bold'>$".number_format(($wt_ags_all_btc*$btc_usd['last']), 2, '.', ',')."**</td></tr>";
- echo "</table>";
- echo "</div>";
- echo "</div>";
- echo "<div id='right'>";
- echo "<div id='infobox'>";
- echo "<p class='header' align='center'>Overall PTS</p>";
- echo "<table class='table table-striped'>";
- echo "<tr><td align='right'>Sum of Donations:</td><td>".$sum_all_pts."</td></tr>";
- echo "<tr><td align='right'>Amt of Donations:</td><td>".$amt_all_pts."</td></tr>";
- echo "<tr><td align='right'>Top Donation:</td><td>".$top_all_pts."</td></tr>";
- echo "<tr><td align='right'>Price per AGS:</td><td>".$ags_all_pts."</td></tr>";
- echo "<tr><td align='right'>Wtd Price per AGS:</td><td>".$wt_ags_all_pts."</td></tr>";
- echo "<tr class='highlight'><td align='right'>Wtd USD per AGS:</td><td class='bold'>$".number_format(($wt_ags_all_pts*$pts_btc['last']*$btc_usd['last']), 2, '.', ',')."**</td></tr>";
- echo "</table>";
- echo "</div>";
- echo "</div>";
- $time = microtime();
- $time = explode(' ', $time);
- $time = $time[1] + $time[0];
- $finish = $time;
- $total_time = round(($finish - $start), 4);
- ?>
- </div>
- <?
- 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. / Blockchain data (v0.3) provided by <a href='https://bitsharestalk.org/index.php?topic=1853.0'>donschoe</a> / Tips: PYDhxRmdd8YQdYLD757s7robuvafFdMARi / <a href='http://pastebin.com/AWbHNvPr'>Source Code</a></p>";
- echo "</div>";
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement