Skip to content

Commit

Permalink
New Feature: Seeing Cummulative Voters Details
Browse files Browse the repository at this point in the history
This Feature makes you see the total vote worth and vote count you received in a week from a user.

This feature also supports fiat conversion, so as to see vote worth in fiat currency.

You can also copy the details of this vote worth in steem-compatible format

This feature also allows you to view the list in Alphabetic Order, Order of Worth and Order of counts and all of this order have their own specific custom copy format
  • Loading branch information
Akintunde102 committed Mar 25, 2018
1 parent 24f18fc commit 9213c52
Show file tree
Hide file tree
Showing 16 changed files with 415 additions and 33 deletions.
14 changes: 12 additions & 2 deletions controllers/pages_controller.php
Expand Up @@ -15,6 +15,8 @@ public function results() {
$site_name = $b->site_name;
$username = $b->username;
$blogs = $b->processBlogData();



$comments = $b->processCommentData();

Expand All @@ -25,6 +27,14 @@ public function results() {

$ext = $blogs[0]['b_ext'];


$b->joinVoters(); //join voters

$varrayW = $b->tcvW; //by Worth
$varrayC = $b->tcvC; //by count
$varrayA = $b->tcvA; //alphabetically


$steem_usd = $b->getSTEEM();
$steem = ($total*$steem_usd)/$usd;
$steem = round($steem,2);
Expand Down Expand Up @@ -66,10 +76,10 @@ public function sbd() {
require_once('views/posts/sbd.php');
}

public function print() {
public function display() {
$b = new post;
$p = trim($_GET['print']);
$b->print($p);
$b->display($p);
// require_once('views/posts/print.php');
}

Expand Down
2 changes: 1 addition & 1 deletion curr.txt
@@ -1 +1 @@
{"success":true,"terms":"https:\/\/currencylayer.com\/terms","privacy":"https:\/\/currencylayer.com\/privacy","timestamp":1521368947,"source":"USD","quotes":{"USDNGN":357.000344,"USDGHS":4.404104,"USDEUR":0.81304,"USDCAD":1.309204,"USDGBP":0.71766,"USDZAR":11.969304}}
{"success":true,"terms":"https:\/\/currencylayer.com\/terms","privacy":"https:\/\/currencylayer.com\/privacy","timestamp":1521911651,"source":"USD","quotes":{"USDNGN":357.000344,"USDGHS":4.392504,"USDEUR":0.808904,"USDCAD":1.288904,"USDGBP":0.70767,"USDZAR":11.735104}}
106 changes: 100 additions & 6 deletions models/post.php
Expand Up @@ -2,8 +2,9 @@
class post {

public function __construct() {
//error_reporting(0);

if (!empty($_GET['username'])){ $username = $_GET["username"];}
if (!empty($_GET['username'])){ $username = trim($_GET["username"]);}
else if (!empty($_GET['print'])){ $username = $_GET["print"]; @$x = $_GET["x"];}

$username = str_replace('@', '', $username);
Expand All @@ -19,7 +20,6 @@ public function __construct() {


Public function getPicture() {

$url = 'https://api.steemjs.com/get_accounts?names[]=%5B%22'.$this->username.'%22%5D';
$json= file_get_contents($url);
$data = json_decode($json,true);
Expand All @@ -44,6 +44,8 @@ public function getCommentData() {
}

public function processBlogData() {
//To get cummulative voting worth
$varray = array();
$newItems = array();
$total_price =0;
$count = 0;
Expand Down Expand Up @@ -136,7 +138,23 @@ public function processBlogData() {
$vMoney = $vFraction * $aMoney;
$newItems[$count]['voters'][$key]['money'] = $vMoney * $mult;
$newItems[$count]['voters'][$key]['percent'] = $newItems[$count]['voters'][$key]['percent'] / 100;
$key++;

$vname =$newItems[$count]['voters'][$key]['voter'];


if (array_key_exists($vname,$varray)){
$varray[$vname]['amount'] = $varray[$vname]['amount'] + $vMoney * $mult;
$varray[$vname]['count'] = $varray[$vname]['count'] + 1;
}
else {
$varray[$vname]['name'] = $newItems[$count]['voters'][$key]['voter'];
$varray[$vname]['amount'] = $vMoney * $mult;
$varray[$vname]['count'] = 1;
$varray[$vname]['type'] = 'cumVote';
}


$key++;
}


Expand All @@ -153,18 +171,34 @@ public function processBlogData() {
$newItems[$count]['b_ext'] = $ext;

}

$count++;
}

$newItems['total'] = $total_price * $mult;
$newItems['usd'] = $this->getSBD();


$this->PVA = $varray;



}

return $newItems;
}

private function array_sort_by_column(&$arr, $col, $dir = SORT_DESC) {
//Returns a value instead
Private function array_sort_by_columnR(&$arr, $col, $dir = SORT_DESC) {
$sort_col = array();
foreach ($arr as $key=>$row) {
$sort_col[$key] = $row[$col];
}
array_multisort($sort_col, $dir, $arr);
return $arr;
}


Private function array_sort_by_column(&$arr, $col, $dir = SORT_DESC) {
$sort_col = array();
foreach ($arr as $key=> $row) {
$sort_col[$key] = $row[$col];
Expand All @@ -173,6 +207,10 @@ private function array_sort_by_column(&$arr, $col, $dir = SORT_DESC) {
}

public function processCommentData() {

//To get cummulative voting worth
$varray = array();

$newItems = array();
$total_price =0;
$count = 0;
Expand Down Expand Up @@ -256,6 +294,20 @@ public function processCommentData() {
$vMoney = $vFraction * $aMoney;
$newItems[$count]['voters'][$key]['money'] = $vMoney * $mult;
$newItems[$count]['voters'][$key]['percent'] = $newItems[$count]['voters'][$key]['percent'] / 100;

$vname =$newItems[$count]['voters'][$key]['voter'];

if (array_key_exists($vname,$varray)){
$varray[$vname]['amount'] = $varray[$vname]['amount'] + $vMoney * $mult;
$varray[$vname]['count'] = $varray[$vname]['count'] + 1;
}
else {
$varray[$vname]['name'] = $newItems[$count]['voters'][$key]['voter'];
$varray[$vname]['amount'] = $vMoney * $mult;
$varray[$vname]['count'] = 1;
$varray[$vname]['type'] = 'cumVote';
}

$key++;
}

Expand All @@ -277,13 +329,55 @@ public function processCommentData() {
$newItems['total'] = $total_price * $mult;
$newItems['usd'] = $this->getSBD();

$this->CVA = $varray;

}


return $newItems;
}



Public function joinVoters(){

$n = $this->PVA;

foreach ($n as $p){



foreach ($this->CVA as $c){
$name = $c['name'];
if ($p['name'] == $c['name']){
$n[$name]['name'] = $c['name'];
$n[$name]['amount'] = $p['amount'] + $c['amount'];
$n[$name]['count'] = $p['count'] + $c['count'];
}
else {
if (!array_key_exists($c['name'],$n)){
$n[$name]['name'] = $c['name'];
$n[$name]['amount'] = $c['amount'] ;
$n[$name]['count'] = $c['count'];
}
}

}

}

$this->tcv = $n; //total cummulative voters



$this->tcvA = $this->array_sort_by_columnR($this->tcv, 'name', SORT_ASC);
$this->tcvW = $this->array_sort_by_columnR($this->tcv, 'amount');
$this->tcvC = $this->array_sort_by_columnR($this->tcv, 'count');



}

Public function fancy_date($timestamp)
{

Expand Down Expand Up @@ -336,7 +430,7 @@ public function processCommentData() {
fwrite($sbdfile, $sbdDetails);
fclose($sbdfile);}

Public function print($p){
Public function display($p){
require 'src/PHPImage.php';
$lang = $this->lang;
$bg = 'pro/image.jpg';
Expand Down
22 changes: 11 additions & 11 deletions sbd.txt
Expand Up @@ -3,17 +3,17 @@
"id": "steem-dollars",
"name": "Steem Dollars",
"symbol": "SBD",
"rank": "284",
"price_usd": "1.69272",
"price_btc": "0.00022285",
"24h_volume_usd": "1409940.0",
"market_cap_usd": "18248985.0",
"available_supply": "10780865.0",
"total_supply": "10780865.0",
"rank": "281",
"price_usd": "2.05731",
"price_btc": "0.0002311",
"24h_volume_usd": "6864140.0",
"market_cap_usd": "22645773.0",
"available_supply": "11007467.0",
"total_supply": "11007467.0",
"max_supply": null,
"percent_change_1h": "-1.51",
"percent_change_24h": "-20.21",
"percent_change_7d": "-30.58",
"last_updated": "1521371047"
"percent_change_1h": "0.05",
"percent_change_24h": "4.61",
"percent_change_7d": "6.14",
"last_updated": "1521917347"
}
]
Binary file removed slip/akintunde90bf1f8c642e58244d4db10ed6fc14f1.jpg
Binary file not shown.
Binary file removed slip/akintundedeaa2d91a7ef53d87c73a8f63086d9ff.jpg
Binary file not shown.
Binary file removed slip/ejemai3a362372a3b3516449b93de6d16deff5.jpg
Binary file not shown.
Binary file removed slip/emmexdee8d3c63d4a22496c31724df8b9ad70342.jpg
Binary file not shown.
Binary file removed slip/joseph819fa39fae70e39e7f6a82bd10eb32cd.jpg
Binary file not shown.
Binary file removed slip/reachout031feafcc23588b108dfe1040e8532aa.jpg
Binary file not shown.
22 changes: 11 additions & 11 deletions steem.txt
Expand Up @@ -3,17 +3,17 @@
"id": "steem",
"name": "Steem",
"symbol": "STEEM",
"rank": "26",
"price_usd": "4.95322",
"price_btc": "0.00055701",
"24h_volume_usd": "85514100.0",
"market_cap_usd": "1234277959.0",
"available_supply": "249186985.0",
"total_supply": "266161079.0",
"rank": "30",
"price_usd": "2.06485",
"price_btc": "0.00023195",
"24h_volume_usd": "6771560.0",
"market_cap_usd": "525184652.0",
"available_supply": "254345184.0",
"total_supply": "271319278.0",
"max_supply": null,
"percent_change_1h": "4.22",
"percent_change_24h": "21.91",
"percent_change_7d": "24.16",
"last_updated": "1518243547"
"percent_change_1h": "0.14",
"percent_change_24h": "6.55",
"percent_change_7d": "12.87",
"last_updated": "1521917347"
}
]
13 changes: 13 additions & 0 deletions views/pages/assets/css/style.css
Expand Up @@ -476,6 +476,19 @@ tr:nth-child(odd) {background: #000; color: #fff; border-bottom: solid 1px rgba

.dropdown-menu{ max-height:200px;
overflow-y:auto;}

.dropdown-menu2{ max-height:200px;
overflow-y:auto;}













1 change: 0 additions & 1 deletion views/pages/home.php
Expand Up @@ -7,7 +7,6 @@
<input type="text" style="width: 100%;" name="username" required="" placeholder="steem username" />
</div>
</form>
<br/>
<p align="center" style="margin: 10px 3px 3px 193px;"><span> &copy; 2018 Designed By</span> <a href="http://steemit.com/@akintunde">@akintunde</a></p>
</div>
Expand Down
54 changes: 54 additions & 0 deletions views/posts/foot.php
@@ -1,5 +1,59 @@
<script type="text/javascript" href="views/pages/assets/js/app.js"></script>
<script type="text/javascript" href="views/pages/assets/js/particles.js"></script>

<script type="application/x-javascript">
document.body.innerHTML = document.body.innerHTML.replace(/1 times/g, 'once(1)');
document.body.innerHTML = document.body.innerHTML.replace(/2 times/g, 'twice(2)');
document.body.innerHTML = document.body.innerHTML.replace(/3 times/g, 'thrice(3)');
</script>
<script>
function myFunctionone() {
var copyText = document.getElementById("myInputone");
copyText.select();
document.execCommand("Copy");
var tooltip = document.getElementById("myTooltip1");
tooltip.innerHTML = "Copied: ";
}
function myFunctiontwo() {
var copyText = document.getElementById("myInputtwo");
copyText.select();
document.execCommand("Copy");
var tooltip = document.getElementById("myTooltip2");
tooltip.innerHTML = "Copied" ;
}
function myFunctionthree() {
var copyText = document.getElementById("myInputthree");
copyText.select();
document.execCommand("Copy");
var tooltip = document.getElementById("myTooltip3");
tooltip.innerHTML = "Copied" ;
}
/**
function outFuncone() {
var tooltip = document.getElementById("myTooltip1");
tooltip.innerHTML = "Copy to clipboard";
}
function outFunctwo() {
var tooltip = document.getElementById("myTooltip2");
tooltip.innerHTML = "Copy to clipboard";
}
function outFuncthree() {
var tooltip = document.getElementById("myTooltip3");
tooltip.innerHTML = "Copy to clipboard";
}
***/
</script>
</body>
</html>

0 comments on commit 9213c52

Please sign in to comment.