Advertisement
Guest User

ZENscrape.pl v1.46

a guest
Nov 25th, 2014
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 35.39 KB | None | 0 0
  1. use strict;
  2. use warnings;
  3. use WWW::Mechanize;
  4. use WWW::Mechanize::Firefox;
  5. use HTTP::Cookies;
  6. use Data::Dumper;
  7. use Term::ReadKey;
  8. use Spreadsheet::WriteExcel;
  9.  
  10. binmode(STDOUT, ":utf8");
  11.  
  12. #ZENscrape v1.46 by Cryptichermit
  13. #ZENscrape v1.46 Increases NET::Telnet timeout to reduce timeout errors.
  14. #ZENscrape v1.46 Fixes Transaction ID for Hashlets that had no payout.
  15. #ZENscrape v1.45 Reconciles Double Hash payout records.
  16. #ZENscrape v1.45 Change check record to look for any change in records value instead of incremental value.
  17. #ZENscrape v1.44 JSON changes made to transaction ID in some new records - reconciled.
  18. #ZENscrape v1.44 JSON changes made to zenhashlet payout - reconciled.
  19. #ZENscrape v1.44 added SSL name verification bypass back into BTC ticker, some platforms were failing.
  20. #ZENscrape v1.43 includes new Checksum for new ZENcloud multi-output payout details.
  21. #ZENscrape v1.42 incorporates WWW::Mechanize::Firefox module to attach to firefox browser session
  22. #ZENscrape v1.42 Removes some no longer needed since authentication is done on firefox browser session
  23. #ZENscrape v1.42 Corrects 1 account error with hashpoints, 1 error with excel call for Microsoft office users.
  24. #ZENscrape v1.41 includes accounting of HashPool HashPoint payouts.
  25. #ZENscrape v1.41 includes SSL name verification bypass, and 2 small syntax fixes.
  26. #ZENscrape v1.41 fix on zencon subroutine for authy token failure.
  27. #ZENscrape v1.4 moves to CLI (command line interface).
  28. #ZENscrape keeps an active connection with your ZENportal Dashboard.
  29. #Realtime BTC values are displayed.  New records are automatically imported.
  30. #Run multlipe reports and export to CSV with a single keyboard stroke.
  31. #Show and chart Income vs. Expense.
  32.  
  33. my $ssoft = "LO"; #set to LO for Libreoffice and MO for Microsoft Office.
  34. my $btcval = 0; #leave 0 for it to auto grab BTC price from bitstamp or enter your desired BTC value to compare
  35. my $zenapi = 'zenapi.txt'; #this is JSON API output file.  It is required for storing JSON data.
  36. my $ver = "v1.46";
  37. my $btcurl = "https://api.bitcoinaverage.com/ticker/USD/last";
  38.  
  39. $| = 1;
  40. my $pof = "ZEN_pay.csv";
  41. my $chf = "ZEN_charges.csv";
  42. my $zpf = "ZEN_pur.csv";
  43. my $hpf = "ZEN_HP.csv";
  44. my $zdf = "ZEN_dep.csv";
  45. my $zwf = "ZEN_wdraw.csv";
  46. my $zsf = "ZEN_sold.csv";
  47. my $btdash='';
  48. my $usdash='';
  49. my $hpdash='';
  50. my $payouts = 0;
  51. my $hpout = 0;
  52. my $hp = 0;
  53. my $hpup = 0;
  54. my $hpdown = 0;
  55. my $hpdzen = 0;
  56. my $pay = 0;
  57. my $fees = 0;
  58. my $numfee = 0;
  59. my $sval = '0';
  60. my $pur = 0;
  61. my $hppur = 0;
  62. my $btcpur = 0;
  63. my $usdpur = 0;
  64. my $wdraw = 0;
  65. my $btcwd = 0;
  66. my $xfers = 0;
  67. my $btcin = 0;
  68. my $hsold = 0;
  69. my $valsold = 0;
  70. my $btcsold = 0;
  71. my $recmia = 0;
  72. my $profit = 0;
  73. my $key='';
  74. my $uid='';
  75. my $mech = WWW::Mechanize::Firefox->new();
  76. $mech->repl->repl->client->{telnet}->timeout(90);
  77. my $bmech = WWW::Mechanize->new(ssl_opts => { verify_hostname => 0 }, autocheck => 1);
  78. my $c='';
  79. my $e='';
  80. my $rectime=10;
  81. my $recval=0;
  82. my $dashtime=2;
  83. my $dashval=0;
  84. my $locrec = 0;
  85. my $data = '';
  86. my $sdata = '';
  87. my $numrec = '0';
  88. my $loaded = 0;
  89. my $rdate = '';
  90. my $upok = 0;
  91. my $hpay = 0;
  92.  
  93. sub cpos
  94. {
  95.  local($a, $b) = ($_[0], $_[1]);
  96.  printf("\033[%d;%dH", $a, $b);
  97. }
  98.  
  99. sub rstr
  100. {
  101.  local($a, $b) = ($_[0], $_[1]);
  102.  foreach my $i (1..$b)
  103.  {
  104.   print $a;
  105.  }
  106. }
  107.  
  108. sub fstr
  109. {
  110.  my($a, $b, $c) = ($_[0], $_[1], $_[2]);
  111.  rstr($a,$b-length($c));
  112.  print $c;
  113. }
  114.  
  115. sub bstr
  116. {
  117.  my($a, $b, $c) = ($_[0], $_[1], $_[2]);
  118.  print $c;
  119.  rstr($a,$b-length($c));
  120. }
  121.  
  122. sub tcol
  123. {
  124.  local($a) = ($_[0]);
  125.  if ($a eq "black") {printf "\x1B[30m";}
  126.  if ($a eq "blue") {printf "\x1B[34m";}
  127.  if ($a eq "green") {printf "\x1B[32m";}
  128.  if ($a eq "yellow") {printf "\x1B[33m";}
  129.  if ($a eq "purple") {printf "\x1B[35m";}
  130.  if ($a eq "cyan") {printf "\x1B[36m";}
  131.  if ($a eq "") {printf "\x1B[37m";}
  132. }
  133.  
  134. sub bcol
  135. {
  136.  local($a) = ($_[0]);
  137.  if ($a eq "black") {printf "\x1B[40m";}
  138.  if ($a eq "blue") {printf "\x1B[44m";}
  139.  if ($a eq "green") {printf "\x1B[42m";}
  140.  if ($a eq "yellow") {printf "\x1B[43m";}
  141.  if ($a eq "purple") {printf "\x1B[45m";}
  142.  if ($a eq "cyan") {printf "\x1B[46m";}
  143.  if ($a eq "white") {printf "\x1B[47m";}
  144.  if ($a eq "red") {printf "\x1B[41m";}
  145.  if ($a eq "") {printf "\x1B[0m";}
  146. }
  147.  
  148. sub clrscr
  149. {
  150.  bcol("black");
  151.  printf("%c[2J",27);
  152.  printf("\033\143");
  153.  cpos(0, 0);
  154. }
  155.  
  156. sub prompt
  157. {
  158.  my ($text) = @_;
  159.  print $text;
  160.  
  161.  my $answer = <STDIN>;
  162.  chomp $answer;
  163.  return $answer;
  164. }
  165.  
  166. sub btcv
  167. {
  168.  my $res = $bmech->get($btcurl);
  169.  if ($res->is_success()) {$btcval = $bmech->content();}
  170.  else
  171.  {
  172.   bcol("red");
  173.   tcol("");
  174.   dbox(80,"BTC Ticker Connection Failed",25,20,"","red");
  175.   cpos(27,20);
  176.   fstr(".",79,"Will Re-try connection in");
  177.   foreach my $i (1..9)
  178.   {
  179.    print 10-$i;
  180.    sleep(1);
  181.    cpos(27,99);
  182.   }
  183.   btcv();
  184.  }
  185. }
  186.  
  187. sub dbox
  188. {
  189.  my($a, $c, $x, $y,$tc,$bc) = ($_[0], $_[1], $_[2], $_[3], $_[4], $_[5]);
  190.  tcol($tc);
  191.  bcol($bc);
  192.  cpos($x,$y);
  193.  my $pad=sprintf("%.0f",($a-length($c))/2);
  194.  rstr(" ",$pad);
  195.  print $c;
  196.  if ($pad+$pad+length($c) == $a) {rstr(" ",$pad);}
  197.  else {rstr(" ",$pad+1);}
  198.  cpos($x+1,$y);
  199.  rstr("=",$a);
  200.  cpos($x+2,$y);
  201. }
  202.  
  203. sub zencon
  204. {
  205.  bcol("red");
  206.  tcol("");
  207.  dbox(80,"Disconnected from ZEN-Cloud - Re-Authorization Required",25,20,"","red");
  208.  cpos(27,20);
  209.  bstr(".",80,"In Firefox re-connect to your ZENcloud account.  Then hit a key here.");
  210.  while (!defined( $key = ReadKey(-1))) {sleep(1);}
  211.  my $url = "https://cloud.zenminer.com/api/activity?iDisplayStart=0&iDisplayLength=1";
  212.  my $res = $mech->get($url);
  213.  if ($res->is_success())
  214.  {
  215.   my $findat = Dumper ($mech->content());
  216.   if (index($findat, '"iTotalRecords":') == -1)
  217.   {
  218.    cpos(27,20);
  219.    rstr(" ",80);
  220.    cpos(27,20);
  221.    fstr(".",80,"There is still a problem.  Retry in 3 seconds.");
  222.    sleep(3);
  223.    zencon();
  224.   }
  225.  }
  226.  else {zencon();}
  227. }
  228.  
  229. sub dash
  230. {
  231.  my $finurl = "https://cloud.zenminer.com/dashboard/$uid";
  232.  my $res = $mech->get($finurl);
  233.  if ($res->is_success())
  234.  {
  235.   my $findat = Dumper ($mech->content());
  236.   if (index($findat, '<body class="login-page">') == -1)
  237.   {
  238.    $c = index($findat, '"balance-value\">  ');
  239.    $e = index($findat, '</span><span class=\"balanceAbbr-value', $c);
  240.    $c = $c+19;
  241.    $sval = substr($findat,$c,$e-$c);
  242.    $btdash = $sval;
  243.    $c = index($findat, '"balanceUSD-value\">');
  244.    $e = index($findat, '<span class=\"denom\"> USD', $c);
  245.    $c = $c+20;
  246.    $sval = substr($findat,$c,$e-$c);
  247.    $usdash = $sval;
  248.    $c = index($findat, '"balanceZP-value\">  ');
  249.    $e = index($findat, '<span class=\"denom\"> HP', $c);
  250.    $c = $c+21;
  251.    $sval = substr($findat,$c,$e-$c);
  252.    $hpdash = $sval;
  253.   }
  254.   else
  255.   {
  256.    zencon();
  257.   }
  258.  }
  259.  else
  260.  {
  261.  zencon();
  262.  }
  263. }
  264.  
  265. sub sortcsv
  266. {
  267.  open (DATA, $_[0]);
  268.  my @rows = map { chomp; [split /,/, $_] } <DATA>;
  269.  my @sorted = sort { $b->[0] cmp $a->[0] || $b->[1] cmp $a->[1] } @rows;
  270.  close DATA;
  271.  open (WF,">",$_[0]);
  272.  for (@sorted) {
  273.    print WF join(',', @$_) . "\n"; # print them out as CSV
  274.  }
  275.  close WF;
  276. }
  277.  
  278. sub gdate
  279. {
  280.  open (CSVF, $pof);
  281.  my $row = 0;
  282.  while (<CSVF>)
  283.  {
  284.   chomp;
  285.   my @Fld = split(',', $_);
  286.   if ($row == 1) {$rdate = $Fld[0];}
  287.   $row++;
  288.  }
  289.  close CSVF;
  290. }
  291.  
  292. sub tdayxls
  293. {
  294.  my $wb = Spreadsheet::WriteExcel->new("ZEN_$rdate.xls");
  295.  my $wk = $wb->addworksheet('Profits');
  296.  $wk->set_column('A:A',25);
  297.  $wk->set_column('B:C',12);
  298.  $wk->write(0,0,"Miner");
  299.  $wk->write(0,1,"Payout");
  300.  $wk->write(0,2,"Fees");
  301.  my $numval = $wb->add_format();
  302.  $numval->set_num_format('0.00000000');
  303.  open (CSVF, $pof);
  304.  my $row = 1;
  305.  my $rowp = 1;
  306.  while (<CSVF>)
  307.  {
  308.   chomp;
  309.   my @Fld = split(',', $_);
  310.   if ($Fld[0] eq $rdate)
  311.   {
  312.    my $col = 0;
  313.    foreach (@Fld)
  314.    {
  315.     if ($col == 2) {$wk->write($row, 0, $Fld[2]);}
  316.     elsif ($col == 3) {$wk->write($row, 1, $Fld[3], $numval);}
  317.     $col++;
  318.    }
  319.    $rowp++;
  320.    $row++;
  321.   }
  322.  }
  323.  close CSVF;
  324.  open (CSVF, $chf);
  325.  $row = 1;
  326.  my $rowf = 1;
  327.  while (<CSVF>)
  328.  {
  329.   chomp;
  330.   my @Fld = split(',', $_);
  331.   if ($Fld[0] eq $rdate)
  332.   {
  333.    my $col = 0;
  334.    foreach (@Fld)
  335.    {
  336.     if ($col == 2) {$wk->write($row, 2, $Fld[3], $numval);}
  337.     $col++;
  338.    }
  339.    $rowf++;
  340.    $row++;
  341.   }
  342.  }
  343.  close CSVF;
  344.  my $numper = $wb->add_format();
  345.  $numper->set_num_format('0.00%');
  346.  $row=$rowp+1;
  347.  if ($rowf > $rowp) {$row=$rowf+1;}
  348.  $wk->write($row+1, 0, "Total");
  349.  $wk->write_formula($row+1, 1, "=SUM(B2:B$row)", $numval);
  350.  $wk->write_formula($row+1, 2, "=SUM(C2:C$row)", $numval);
  351.  $row=$row+2;
  352.  $wk->write_formula($row, 2, "=C$row/B$row", $numper);
  353.  $wk->write($row+1, 0, "Profits");
  354.  $rowf=$row+1;
  355.  $rowp=$row+2;
  356.  $wk->write_formula($row+1, 1, "=B$row-C$row", $numval);
  357.  $wk->write_formula($row+2, 1, "=B$rowp/B$row", $numper);
  358.  my $chart = $wb->add_chart( type => 'column',embedded => 1  );
  359.  $chart->add_series(
  360.     name   => 'Payout',
  361.     values => "=Profits!\$B\$$row:\$B\$$row"
  362.  );
  363.  $chart->add_series(
  364.     name   => 'Fees',
  365.     values => "=Profits!\$C\$$row:\$C\$$row"
  366.  );
  367.  $row=$row+2;
  368.  $chart->add_series(
  369.     name   => 'Profit',
  370.     values => "=Profits!\$B\$$row:\$B\$$row"
  371.  );
  372.  $chart->set_title( name => "ZENcloud Payout for $rdate");
  373.  $chart->set_x_axis( name => "Chart created by ZENscrape $ver");
  374.  $chart->set_y_axis( name => 'BTC' );
  375.  $wk->insert_chart( 'E2', $chart );
  376.  $wb->close();
  377. }
  378.  
  379. sub bdayxls
  380. {
  381.  open (DCSVF, $pof);
  382.  my $brow = 0;
  383.  my $nday = 0;
  384.  while (<DCSVF>)
  385.  {
  386.   chomp;
  387.   my @dfld = split(',', $_);
  388.   if ($brow == 1) {$rdate = $dfld[0];}
  389.   if ($rdate ne $dfld[0]) {$rdate=$dfld[0];$nday++}
  390.   tdayxls();
  391.   $brow++;
  392.   cpos(32,80);
  393.   fstr(".",5,$nday);
  394.  }
  395.  close DCSVF;
  396. }
  397.  
  398. sub chartxls
  399. {
  400.  open (DATA, $pof);
  401.  my @rows = map { chomp; [split /,/, $_] } <DATA>;
  402.  my @srt = sort { $a->[0] cmp $b->[0] } @rows;
  403.  close DATA;
  404.  open (WF,">","temp.csv");
  405.  for (@srt) {
  406.    print WF join(',', @$_) . "\n";
  407.  }
  408.  close WF;
  409.  my $wb = Spreadsheet::WriteExcel->new("ZEN_chart.xls");
  410.  my $wk = $wb->addworksheet('Chart');
  411.  $wk->set_column('A:D',12);
  412.  my $numval = $wb->add_format();
  413.  $numval->set_num_format('0.00000000');
  414.  my $numper = $wb->add_format();
  415.  $numper->set_num_format('0.00%');
  416.  $wk->write(0,0,"Date");
  417.  $wk->write(0,1,"Payout");
  418.  $wk->write(0,2,"Fees");
  419.  $wk->write(0,3,"Profit");
  420.  $wk->write(1,2,"0",$numval);
  421.  my $row = 0;
  422.  my $pday = 0;
  423.  my $cdate='';
  424.  $rdate='';
  425.  open (CSVF, "temp.csv");
  426.  my $rowp = 1;
  427.  while (<CSVF>)
  428.  {
  429.   chomp;
  430.   my @Fld = split(',', $_);  
  431.   if ($row == 0) {$rdate = $Fld[0];$cdate=$rdate;}
  432.   if ($Fld[0] eq $rdate)
  433.   {
  434.    $pday=$pday+$Fld[3];
  435.   }
  436.   else
  437.   {
  438.    $wk->write($rowp, 0, $rdate);
  439.    $wk->write($rowp, 1, $pday, $numval);
  440.    $rdate=$Fld[0];
  441.    $pday=$Fld[3];
  442.    $rowp++;
  443.   }
  444.   $row++;
  445.  }
  446.  close CSVF;
  447.  open (DATA, $chf);
  448.  @rows = map { chomp; [split /,/, $_] } <DATA>;
  449.  @srt = sort { $a->[0] cmp $b->[0] } @rows;
  450.  close DATA;
  451.  open (WF,">","temp.csv");
  452.  for (@srt) {
  453.    print WF join(',', @$_) . "\n";
  454.  }
  455.  close WF;
  456.  $row = 0;
  457.  $pday = 0;
  458.  $rdate=$cdate;
  459.  open (CSVF, "temp.csv");
  460.  $rowp = 1;
  461.  while (<CSVF>)
  462.  {
  463.   chomp;
  464.   my @Fld = split(',', $_);  
  465.   if ($Fld[0] eq $rdate)
  466.   {
  467.    $pday=$pday+$Fld[3];
  468.   }
  469.   elsif ($pday != 0)
  470.   {
  471.    $wk->write($rowp, 2, $pday, $numval);
  472.    $rdate=$Fld[0];
  473.    $pday=$Fld[3];
  474.    $rowp++;
  475.   }
  476.   elsif ($Fld[0] ne "DATE")
  477.   {
  478.    $rdate=$Fld[0];
  479.    $pday=$pday+$Fld[3];
  480.    $rowp++;
  481.   }
  482.   $row++;
  483.  }
  484.  unlink ("temp.csv");
  485.  foreach $row (2..$rowp)
  486.  {
  487.   $wk->write_formula($row-1,3,"=B$row-C$row", $numval);
  488.  }
  489.  my $chart = $wb->add_chart( type => 'line',embedded => 1  );
  490.  $chart->add_series(
  491.     name   => 'Payout',
  492.     values => "=Chart!\$B\$2:\$B\$$rowp"
  493.  );
  494.  $chart->add_series(
  495.     name   => 'Fees',
  496.     values => "=Chart!\$C\$2:\$C\$$rowp"
  497.  );
  498.  $row=$row+2;
  499.  $chart->add_series(
  500.     name   => 'Profit',
  501.     values => "=Chart!\$D\$2:\$D\$$rowp"
  502.  );
  503.  $chart->set_title( name => "ZENcloud Historical Payout Chart.");
  504.  $chart->set_x_axis( name => "Chart created by ZENscrape $ver");
  505.  $chart->set_y_axis( name => 'BTC' );
  506.  $wk->insert_chart( 'E2', $chart, 0, 0, 3.0, 1.75);
  507.  $wb->close();
  508. }
  509.  
  510. sub createxls
  511. {
  512.  my $wb = Spreadsheet::WriteExcel->new("ZEN.xls");
  513.  my $wk = $wb->addworksheet('Payouts');
  514.  $wk->set_column('A:B',12);
  515.  $wk->set_column('C:C',25);
  516.  $wk->set_column('D:D',12);
  517.  $wk->set_column('E:F',25);
  518.  open (CSVF, $pof);
  519.  my $row = 0;
  520.  while (<CSVF>)
  521.  {
  522.   chomp;
  523.   my @Fld = split(',', $_);
  524.   my $col = 0;
  525.   foreach my $token (@Fld)
  526.   {
  527.    $wk->write($row, $col, $token);
  528.    $col++;
  529.   }
  530.   $row++;
  531.  }
  532.  close CSVF;
  533.  $wk = $wb->addworksheet('Fees');
  534.  $wk->set_column('A:B',12);
  535.  $wk->set_column('C:C',25);
  536.  $wk->set_column('D:D',12);
  537.  $wk->set_column('E:E',25);
  538.  open (CSVF, $chf);
  539.  $row = 0;
  540.  while (<CSVF>)
  541.  {
  542.   chomp;
  543.   my @Fld = split(',', $_);
  544.   my $col = 0;
  545.   foreach my $token (@Fld)
  546.   {
  547.    $wk->write($row, $col, $token);
  548.    $col++;
  549.   }
  550.   $row++;
  551.  }
  552.  close CSVF;
  553.  $wk = $wb->addworksheet('Purchases');
  554.  $wk->set_column('A:E',12);
  555.  open (CSVF, $zpf);
  556.  $row = 0;
  557.  while (<CSVF>)
  558.  {
  559.   chomp;
  560.   my @Fld = split(',', $_);
  561.   my $col = 0;
  562.   foreach my $token (@Fld)
  563.   {
  564.    $wk->write($row, $col, $token);
  565.    $col++;
  566.   }
  567.   $row++;
  568.  }
  569.  close CSVF;
  570.  $wk = $wb->addworksheet('HashPoints');
  571.  $wk->set_column('A:C',12);
  572.  $wk->set_column('D:D',50);
  573.  open (CSVF, $hpf);
  574.  $row = 0;
  575.  while (<CSVF>)
  576.  {
  577.   chomp;
  578.   my @Fld = split(',', $_);
  579.   my $col = 0;
  580.   foreach my $token (@Fld)
  581.   {
  582.    $wk->write($row, $col, $token);
  583.    $col++;
  584.   }
  585.   $row++;
  586.  }
  587.  close CSVF;
  588.  $wk = $wb->addworksheet('Deposits');
  589.  $wk->set_column('A:C',12);
  590.  $wk->set_column('D:D',25);
  591.  open (CSVF, $zdf);
  592.  $row = 0;
  593.  while (<CSVF>)
  594.  {
  595.   chomp;
  596.   my @Fld = split(',', $_);
  597.   my $col = 0;
  598.   foreach my $token (@Fld)
  599.   {
  600.    $wk->write($row, $col, $token);
  601.    $col++;
  602.   }
  603.   $row++;
  604.  }
  605.  close CSVF;
  606.  $wk = $wb->addworksheet('Withdrawals');
  607.  $wk->set_column('A:C',12);
  608.  $wk->set_column('D:D',25);
  609.  open (CSVF, $zwf);
  610.  $row = 0;
  611.  while (<CSVF>)
  612.  {
  613.   chomp;
  614.   my @Fld = split(',', $_);
  615.   my $col = 0;
  616.   foreach my $token (@Fld)
  617.   {
  618.    $wk->write($row, $col, $token);
  619.    $col++;
  620.   }
  621.   $row++;
  622.  }
  623.  close CSVF;
  624.  $wk = $wb->addworksheet('Sold');
  625.  $wk->set_column('A:C',12);
  626.  open (CSVF, $zsf);
  627.  $row = 0;
  628.  while (<CSVF>)
  629.  {
  630.   chomp;
  631.   my @Fld = split(',', $_);
  632.   my $col = 0;
  633.   foreach my $token (@Fld)
  634.   {
  635.    $wk->write($row, $col, $token);
  636.    $col++;
  637.   }
  638.   $row++;
  639.  }
  640.  close CSVF;
  641. }
  642.  
  643. sub crec
  644. {
  645.  my $url = "https://cloud.zenminer.com/api/activity?iDisplayStart=0&iDisplayLength=1";
  646.  my $res = $mech->get($url);
  647.  if ($res->is_success())
  648.  {
  649.   my $outpage = Dumper ($mech->content());
  650.   if (index($outpage, '"iTotalRecords":') == -1) {zencon()};
  651.   $c = index($outpage, '"iTotalRecords":');
  652.   $c = $c+16;
  653.   $e = index($outpage, ',"aaData"');
  654.   $numrec = substr($outpage,$c,$e-$c);
  655.   if ($locrec > 0) {$outpage = '';}
  656.   if ($numrec != $locrec)
  657.   {
  658.    dbox(50,"NEW RECORDS FOUND",30,35,"","blue");
  659.    bstr(".",50,"Collecting Data.");
  660.    sleep(1);
  661.    $url = "https://cloud.zenminer.com/api/activity? iDisplayStart=0&iDisplayLength=i";
  662.    $res = $mech->get($url);
  663.    if ($res->is_success())
  664.    {
  665.     $outpage = Dumper ($mech->content());
  666.     if (index($outpage,'createdAt') == -1) {zencon();}
  667.     $locrec=$numrec;
  668.     $data=$outpage;
  669.    }
  670.    else {zencon();}
  671.   }
  672.   else
  673.   {
  674.    dbox(50,"No new Records Found",30,35,"","blue");
  675.    bstr(".",50,"Using stored Data.");
  676.    sleep(1);
  677.    $outpage = $data;
  678.    if ($loaded==1) {return();}
  679.    $loaded=1;
  680.   }
  681.   $hpdzen = 0;
  682.   $payouts = 0;
  683.   $hpout = 0;
  684.   $hp = 0;
  685.   $hpup = 0;
  686.   $hpdown = 0;
  687.   $hpay = 0;
  688.   $pay = 0;
  689.   $fees = 0;
  690.   $numfee = 0;
  691.   $sval = '0';
  692.   $pur = 0;
  693.   $hppur = 0;
  694.   $btcpur = 0;
  695.   $usdpur = 0;
  696.   $wdraw = 0;
  697.   $btcwd = 0;
  698.   $xfers = 0;
  699.   $btcin = 0;
  700.   $hsold = 0;
  701.   $valsold = 0;
  702.   $btcsold = 0;
  703.   $recmia = 0;
  704.   $profit = 0;
  705.   $c = index($outpage, '"_id":"');
  706.   $c = $c+7;
  707.   $e = index($outpage, '","email"');
  708.   $uid = substr($outpage,$c,$e-$c);
  709.   if ($zenapi ne 'NO')
  710.   {
  711.    open(OUTFILE, ">$zenapi");
  712.    print OUTFILE "$outpage";
  713.    close(OUTFILE);
  714.   }
  715.   my @values = split('"createdAt":"', $outpage);
  716.   my @payout = '';
  717.   $a=0;
  718.   open (PO, ">",$pof) or die $!;
  719.   print PO "DATE,TIME,Miner Name,BTC PAY,Miner ID#,Transaction ID#\n";
  720.   open (FEE, ">",$chf) or die $!;
  721.   print FEE "DATE,TIME,Miner Name,Fee Amount,Transaction ID#\n";
  722.   open (BUY, ">",$zpf) or die $!;
  723.   print BUY "DATE,TIME,BTC Spent,HP Spent, USD Spent\n";
  724.   open (HASH, ">",$hpf) or die $!;
  725.   print HASH "DATE,TIME,HP + or -,Hashpoint Trigger\n";
  726.   open (DEP, ">",$zdf) or die $!;
  727.   print DEP "DATE,TIME,BTC Amount,Transaction ID#\n";
  728.   open (WDR, ">",$zwf) or die $!;
  729.   print WDR "DATE,TIME,BTC Amount,Transaction ID#\n";
  730.   open (HSL, ">",$zsf) or die $!;
  731.   print HSL "DATE,TIME,USD Amount\n";
  732.   open (MIA, ">","zs_mia.txt") or die $!;
  733.   print MIA "This is a record of unaccounted data during Zenscraper\n";
  734.   print MIA "\n";
  735.   foreach my $val (@values)
  736.   {
  737.    $c = 0;
  738.    $e = index($values[$a], 'Z",');
  739.    $sval = substr($values[$a],$c,$e-$c);
  740.    my @dt = split(/T/,$sval);
  741.    if (index($values[$a],']},"_id":"') !=-1)
  742.    {
  743.     $c = index($values[$a], ']},"_id":"');
  744.     $c = $c+10;
  745.    }
  746.    elsif (index($values[$a],'"zpTransaction":"') !=-1)
  747.    {
  748.     $c = index($values[$a], '"zpTransaction":"');
  749.     $c = $c+17;
  750.    }
  751.    else
  752.    {
  753.     $c = index($values[$a], '"transaction":"');
  754.     $c = $c+15;
  755.    }  
  756.    my $tid = substr($values[$a],$c,24);
  757.    if ((index($values[$a], 'action":"device payout') != -1) && (index($values[$a], 'btcPayout') != -1))
  758.    {
  759.     $c = index($values[$a], 'btcPayout":"');
  760.     $e = index($values[$a], ' BTC');
  761.     $c = $c+12;
  762.     my $amnt = substr($values[$a],$c,$e-$c);
  763.     $pay = $pay + $amnt;
  764.     $c = index($values[$a], '"name":"');
  765.     $e = index($values[$a], '","coinType');
  766.     $c = $c+8;
  767.     my $mname = substr($values[$a],$c,$e-$c);
  768.     if ((index($values[$a], 'hpPayout":"') != -1) && (index($values[$a], 'hpPayout":null') == -1))
  769.     {
  770.      $c = index($values[$a], 'hpPayout":"');
  771.      $e = index($values[$a], ' HP');
  772.      $c = $c+11;
  773.      my $hpamnt = substr($values[$a],$c,$e-$c);
  774.      if ($hpamnt>0)
  775.      {
  776.       $hpay = $hpay + $hpamnt;
  777.       ++$hpout;
  778.       print HASH $dt[0],",",$dt[1],",",$hpamnt,",","$mname - HashPool","\n";      
  779.      }
  780.     }
  781.     $c = index($values[$a], 'fee":"');
  782.     $e = index($values[$a], ' BTC',$c);
  783.     $c = $c+7;
  784.     my $tfee = substr($values[$a],$c,$e-$c);
  785.     if ($tfee eq '') {$tfee='0.0';}
  786.     print PO $dt[0],",",$dt[1],",",$mname,",",$amnt,",N/A,",$tid,"\n";
  787.     print FEE $dt[0],",",$dt[1],",",$mname,",",$tfee,",",$tid,"\n";
  788.     ++$payouts;
  789.    }
  790.    elsif ((index($values[$a], '"details":"received payout') != -1) && (index($values[$a], ' BTC"') != -1))
  791.    {
  792.     $c = index($values[$a], 'payout of ');
  793.     $e = index($values[$a], ' BTC');
  794.     $c = $c+10;
  795.     my $amnt = substr($values[$a],$c,$e-$c);
  796.     $pay = $pay + $amnt;
  797.     $c = index($values[$a], '"name":"');
  798.     my $f = index($values[$a], '","_id":"');   
  799.     if ($f < $c){$e = index($values[$a], '","_id":"', $f+9);}
  800.     if ($f > $c) { $e = $f;}
  801.     $c = $c+8;
  802.     my $mname = substr($values[$a],$c,$e-$c);
  803.     my $mineid = substr($values[$a],$e+9,24);
  804.     print PO $dt[0],",",$dt[1],",",$mname,",",$amnt,",",$mineid,",",$tid,"\n"; 
  805.     ++$payouts;
  806.    }
  807.    elsif ((index($values[$a], 'action":"doublehash"') != -1) && (index($values[$a], ' HashPoint') != -1))
  808.    {
  809.     $c = index($values[$a], ' at ');
  810.     $e = index($values[$a], ' HP","');
  811.     $c = $c+4;
  812.     my $amnt = substr($values[$a],$c,$e-$c);
  813.     $hpay = $hpay + $amnt;
  814.     print HASH $dt[0],",",$dt[1],",",$amnt,",","DOUBLE HASH - PAYOUT","\n";
  815.     ++$hpout;
  816.    }
  817.    elsif ((index($values[$a], '"details":"received device payout') != -1) && (index($values[$a], ' HashPoints"') != -1))
  818.    {
  819.     $c = index($values[$a], 'payout of ');
  820.     $e = index($values[$a], ' HashPoints');
  821.     $c = $c+10;
  822.     my $amnt = substr($values[$a],$c,$e-$c);
  823.     $hpay = $hpay + $amnt;
  824.     print HASH $dt[0],",",$dt[1],",",$amnt,",","Device Payout - HashPool","\n";
  825.     ++$hpout;
  826.    }
  827.    elsif ((index($values[$a], '"details":"account credited') != -1) && (index($values[$a], ' BTC"') != -1))
  828.    {
  829.     $c = index($values[$a], 'credited ');
  830.     $e = index($values[$a], ' BTC');
  831.     $c = $c+9;
  832.     my $amnt = substr($values[$a],$c,$e-$c);
  833.     $pay = $pay + $amnt;
  834.     print PO $dt[0],",",$dt[1],",ACCOUNT CREDITED,",$amnt,",",",","\n";
  835.     ++$payouts;
  836.    }
  837.    elsif ((index($values[$a], '"details":"account service') != -1) && (index($values[$a], ' BTC"') != -1))
  838.    {
  839.     if (index($values[$a], 'fee -') != -1) {$c = index($values[$a], 'fee -'); $c = $c+5;}
  840.     elsif (index($values[$a], 'fee ') != -1) {$c = index($values[$a], 'fee '); $c = $c+4;}
  841.     else
  842.     {
  843.      print MIA $values[$a],"\n\n";
  844.      ++$recmia;
  845.     }  
  846.     $e = index($values[$a], ' BTC');
  847.     my $tfee = substr($values[$a],$c,$e-$c);
  848.     if (index($values[$a], 'fee -') != -1) {$fees = $fees + $tfee} else {$fees = $fees - $tfee};
  849.     print FEE $dt[0],",",$dt[1],",UNKNOWN,",$tfee,",",$tid,"\n";
  850.     ++$numfee;
  851.    }
  852.    elsif ((index($values[$a], '"details":"received payout') != -1) && (index($values[$a], ' ZenPoints') != -1))
  853.    {
  854.     $c = index($values[$a], 'payout of ');
  855.     $e = index($values[$a], ' ZenPoints');
  856.     $c = $c+10;
  857.     my $thash = substr($values[$a],$c,$e-$c);
  858.     print HASH $dt[0],",",$dt[1],",",$thash,",","Interest on BTC - Balance","\n";
  859.     $hp = $hp + $thash;
  860.     ++$hpout;
  861.    }
  862.    elsif ((index($values[$a], '"details":"received payout') != -1) && (index($values[$a], ' HashPoints') != -1))
  863.    {
  864.     $c = index($values[$a], 'payout of ');
  865.     $e = index($values[$a], ' HashPoints');
  866.     $c = $c+10;
  867.     my $thash = substr($values[$a],$c,$e-$c);
  868.     print HASH $dt[0],",",$dt[1],",",$thash,",","Interest on BTC - Balance","\n";
  869.     $hp = $hp + $thash;
  870.     ++$hpout;
  871.    }
  872.    elsif ((index($values[$a], '"action":"purchased miner"') != -1) or (index($values[$a], 'Auto Purchased') != -1))
  873.    {
  874.     if ((index($values[$a], 'HashPoints') != -1) && (index($values[$a], 'BTC') != -1) && (index($values[$a], 'USD') != -1))
  875.     {
  876.      $c = index($values[$a], 'with -');
  877.      $e = index($values[$a], ' HashPoints');
  878.      $c = $c+6;
  879.      my $hps = substr($values[$a],$c,$e-$c);
  880.      print HASH $dt[0],",",$dt[1],",",-$hps,",","Hashpoints spent on Zencloud purchase.","\n";
  881.      $hppur = $hppur + $hps;
  882.      $c = index($values[$a], 'HashPoints, -');
  883.      $e = index($values[$a], ' BTC');
  884.      $c = $c+13;
  885.      $sval = substr($values[$a],$c,$e-$c);
  886.      $btcpur = $btcpur + $sval;
  887.      $c = index($values[$a], 'and $-');
  888.      $e = index($values[$a], ' USD');
  889.      $c = $c+6;
  890.      my $usdval = substr($values[$a],$c,$e-$c);
  891.      $usdpur = $usdpur + $usdval;
  892.      print BUY $dt[0],",",$dt[1],",",$sval,",",$hps,",",$usdval,"\n";
  893.     }
  894.     elsif ((index($values[$a], 'HashPoints') != -1) && (index($values[$a], 'BTC') != -1) && (index($values[$a], 'USD') == -1))
  895.     {
  896.      $c = index($values[$a], 'with -');
  897.      $e = index($values[$a], ' HashPoints');
  898.      $c = $c+6;
  899.      my $hps = substr($values[$a],$c,$e-$c);
  900.      print HASH $dt[0],",",$dt[1],",",-$hps,",","Hashpoints spent on Zencloud purchase.","\n";
  901.      $hppur = $hppur + $hps;
  902.      $c = index($values[$a], 'and -');
  903.      $e = index($values[$a], ' BTC');
  904.      $c = $c+5;
  905.      $sval = substr($values[$a],$c,$e-$c);
  906.      $btcpur = $btcpur + $sval;
  907.      print BUY $dt[0],",",$dt[1],",",$sval,",",$hps,"\n";
  908.     }
  909.     elsif ((index($values[$a], 'ZenPoints') != -1) && (index($values[$a], 'BTC') != -1))
  910.     {
  911.      $c = index($values[$a], 'with -');
  912.      $e = index($values[$a], ' ZenPoints');
  913.      $c = $c+6;
  914.      my $hps = substr($values[$a],$c,$e-$c);
  915.      print HASH $dt[0],",",$dt[1],",",-$hps,",","Hashpoints spent on Zencloud purchase.","\n";
  916.      $hppur = $hppur + $hps;
  917.      $c = index($values[$a], 'and -');
  918.      $e = index($values[$a], ' BTC');
  919.      $c = $c+5;
  920.      $sval = substr($values[$a],$c,$e-$c);
  921.      $btcpur = $btcpur + $sval;
  922.      print BUY $dt[0],",",$dt[1],",",$sval,",",$hps,"\n";
  923.     }
  924.     elsif ((index($values[$a], 'HashPoints') != -1) && (index($values[$a], 'BTC') == -1))
  925.     {
  926.      $c = index($values[$a], 'with -');
  927.      $e = index($values[$a], ' HashPoints');
  928.      $c = $c+6;
  929.      $sval = substr($values[$a],$c,$e-$c);
  930.      $hppur = $hppur + $sval;
  931.      print HASH $dt[0],",",$dt[1],",",-$sval,",","Hashpoints spent on Zencloud purchase.","\n";
  932.      print BUY $dt[0],",",$dt[1],",0,",$sval,",0\n";
  933.     }
  934.     elsif ((index($values[$a], 'ZenPoints') != -1) && (index($values[$a], 'BTC') == -1))
  935.     {
  936.      $c = index($values[$a], 'with -');
  937.      $e = index($values[$a], ' ZenPoints');
  938.      $c = $c+6;
  939.      $sval = substr($values[$a],$c,$e-$c);
  940.      $hppur = $hppur + $sval;
  941.      print HASH $dt[0],",",$dt[1],",",-$sval,",","Hashpoints spent on Zencloud purchase.","\n";
  942.      print BUY $dt[0],",",$dt[1],",0,",$sval,",0\n";
  943.     }
  944.     elsif ((index($values[$a], 'HashPoints') == -1) && (index($values[$a], 'ZenPoints') == -1) && (index($values[$a], 'BTC') != -1))
  945.     {
  946.      $c = index($values[$a], 'with -');
  947.      $e = index($values[$a], ' BTC');
  948.      $c = $c+6;
  949.      $sval = substr($values[$a],$c,$e-$c);
  950.      $btcpur = $btcpur + $sval;
  951.      print BUY $dt[0],",",$dt[1],",",$sval,"\n";
  952.     }
  953.     elsif ((index($values[$a], 'HashPoints') == -1) && (index($values[$a], 'ZenPoints') == -1) && (index($values[$a], 'BTC') == -1) && (index($values[$a], 'for $') != -1))
  954.     {      
  955.      $c = index($values[$a], 'for $');
  956.      $e = index($values[$a], '","user"');
  957.      $c = $c+5;
  958.      $sval = substr($values[$a],$c,$e-$c);
  959.      $usdpur = $usdpur + $sval;
  960.      print BUY $dt[0],",",$dt[1],",,,",$sval,"\n";
  961.     }
  962.     else
  963.     {
  964.      print MIA $values[$a],"\n\n";
  965.      ++$recmia;
  966.     }
  967.     ++$pur;
  968.    }
  969.    elsif (index($values[$a], 'sold miner') != -1)
  970.    {
  971.     $c = index($values[$a], 'for $');
  972.     $e = index($values[$a], 'user');
  973.     $e = $e - 3;
  974.     $c = $c+5;
  975.     $sval = substr($values[$a],$c,$e-$c);
  976.     $valsold = $valsold+$sval;
  977.     print HSL $dt[0],",",$dt[1],",",$sval,"\n";
  978.     ++$hsold;
  979.    }
  980.    elsif ((index($values[$a], '"details":"account credited 1 HashPoint') != -1))
  981.    {
  982.     print HASH $dt[0],",",$dt[1],",","1",",","Credited 1 HashPoint for Helpful Hashtalk","\n";
  983.     ++ $hpup;
  984.    }
  985.    elsif ((index($values[$a], '"action":"hashtalk downvote') != -1))
  986.    {
  987.     print HASH $dt[0],",",$dt[1],",","-1",",","Deducted 1 HashPoint for hashtalk downvote","\n";
  988.     ++ $hpdown;
  989.    }
  990.    elsif ((index($values[$a], '"action":"withdrawal') != -1))
  991.    {
  992.     $c = index($values[$a], 'for -');
  993.     $e = index($values[$a], ' BTC');
  994.     $c = $c+5;
  995.     $sval = substr($values[$a],$c,$e-$c);
  996.     $btcwd = $btcwd + $sval;
  997.     print WDR $dt[0],",",$dt[1],",",$sval,",",$tid,"\n";
  998.     ++ $wdraw;
  999.    }
  1000.    elsif ((index($values[$a], '"action":"transfer completed') != -1))
  1001.    {
  1002.     $c = index($values[$a], 'for ');
  1003.     $e = index($values[$a], ' BTC');
  1004.     $c = $c+4;
  1005.     $sval = substr($values[$a],$c,$e-$c);
  1006.     $btcin = $btcin + $sval;
  1007.     print DEP $dt[0],",",$dt[1],",",$sval,",",$tid,"\n";
  1008.     ++ $xfers;
  1009.    }
  1010.    elsif ((index($values[$a], '"account HashPoints debit"') != -1))
  1011.    {
  1012.     $c = index($values[$a], 'debited -');
  1013.     $e = index($values[$a], ' HashPoints","');
  1014.     $c = $c+9;
  1015.     $sval = substr($values[$a],$c,$e-$c);
  1016.     print HASH $dt[0],",",$dt[1],",","-",$sval,",","Account Deducted $sval HashPoints","\n";
  1017.     $hpdzen = $hpdzen + $sval;
  1018.    }
  1019.    elsif ((index($values[$a], '"action":"transfer') == -1) && (index($values[$a], '"details":"Merged') == -1) && (index($values[$a], 'code was activated') == -1) && (index($values[$a], '"iTotalRecords":') == -1) && (index($values[$a], 'changed miner name') == -1) && (index($values[$a], '"details":"Received') == -1) && (index($values[$a], '"action":"signup"') == -1) && (index($values[$a], '"action":"profile"') == -1) && (index($values[$a], '"details":"Split') == -1) && (index($values[$a], '"details":"Upgraded') == -1))
  1020.    {
  1021.     print MIA $values[$a],"\n\n";
  1022.     ++$recmia;
  1023.    }   
  1024.    ++$a;
  1025.   }
  1026.   $profit = $pay - $fees;
  1027.   close PO;
  1028.   sortcsv($pof);
  1029.   close FEE;
  1030.   sortcsv($chf);
  1031.   close BUY;
  1032.   sortcsv($zpf);
  1033.   close HASH;
  1034.   sortcsv($hpf);
  1035.   close DEP;
  1036.   sortcsv($zdf);
  1037.   close WDR;
  1038.   sortcsv($zwf);
  1039.   close HSL;
  1040.   sortcsv($zsf);
  1041.   close MIA;
  1042.   if ($hsold > 0)
  1043.   {
  1044.    my $finurl = "https://cloud.zenminer.com/api/dt/financials?iDisplayLength=0";
  1045.    $mech->get($finurl);
  1046.    my $findat = Dumper ($mech->content());
  1047.    $e = 0;
  1048.    foreach my $i (1..$hsold)
  1049.    {
  1050.     $c = index($findat, 'Sale', $e);
  1051.     $e = index($findat, ' BTC', $c);
  1052.     $c = $c+51;
  1053.     $sval = substr($findat,$c,$e-$c);
  1054.     $btcsold = $btcsold+$sval;
  1055.    }
  1056.   }
  1057.  }
  1058.  else {zencon();}
  1059. }
  1060.  
  1061. sub main
  1062. {
  1063.  clrscr();
  1064.  bcol("blue");
  1065.  tcol("");
  1066.  fstr(" ",75,"ZENscrape $ver by Cryptichermit");
  1067.  rstr(" ",45);
  1068.  bcol("green");
  1069.  tcol("black");
  1070.  rstr(" ",2);
  1071.  bstr(" ",38,"BTC value - $btcval USD");
  1072.  fstr(" ",80,"Balances - $btdash BTC  $usdash USD  $hpdash HP  ");
  1073.  bcol("");
  1074.  cpos(4,5);
  1075.  tcol("purple");
  1076.  bcol("black");
  1077.  bstr(" ",15,"Payout Info:");
  1078.  fstr(" ",35,"Number of Payouts: $payouts");
  1079.  cpos(5,5);
  1080.  rstr("=",50);
  1081.  tcol("cyan");
  1082.  cpos(6,5);
  1083.  print "Total Payout:";
  1084.  fstr(".",16,sprintf("%.8f",$pay));
  1085.  print " BTC";
  1086.  fstr(".",13,sprintf("%.2f",$pay*$btcval));
  1087.  print " USD";
  1088.  cpos(7,5);
  1089.  print "Total Profit:";
  1090.  fstr(".",16,sprintf("%.8f",$profit));
  1091.  print " BTC";
  1092.  fstr(".",13,sprintf("%.2f",$profit*$btcval));
  1093.  print " USD";
  1094.  cpos(4,65);
  1095.  tcol("purple");
  1096.  bstr(" ",12,"Fee Info:");
  1097.  fstr(" ",38,"Number of Fee Records: $numfee");
  1098.  cpos(5,65);
  1099.  rstr("=",50);
  1100.  tcol("cyan");
  1101.  cpos(6,65);
  1102.  print "Total Fees:";
  1103.  fstr(".",18,sprintf("%.8f",$fees));
  1104.  print " BTC";
  1105.  fstr(".",13,sprintf("%.2f",$fees*$btcval));
  1106.  print " USD";
  1107.  cpos(7,65);
  1108.  bstr(".",20,"Your Fees account for");
  1109.  fstr(".",10,sprintf("%.2f",$fees/$pay*100));
  1110.  print ".%.....of BTC mined";
  1111.  cpos(9,5);
  1112.  tcol("purple");
  1113.  bstr(" ",15,"Purchase Info:");
  1114.  fstr(" ",35,"Number of ZENcloud Purchases: $pur");
  1115.  cpos(10,5);
  1116.  rstr("=",50);
  1117.  tcol("cyan");
  1118.  cpos(11,5);
  1119.  bstr(".",13,"BTC Spent:");
  1120.  fstr(".",16,sprintf("%.8f",$btcpur));
  1121.  print " BTC";
  1122.  fstr(".",13,sprintf("%.2f",$btcpur*$btcval));
  1123.  print " USD";
  1124.  cpos(12,5);
  1125.  bstr(".",13,"USD Spent:");
  1126.  fstr(".",33,$usdpur);
  1127.  print " USD";
  1128.  cpos(13,5);
  1129.  bstr(".",20,"HashPoints Spent:");
  1130.  fstr(".",26,$hppur);
  1131.  print " HP ";
  1132.  cpos(9,65);
  1133.  tcol("purple");
  1134.  bstr(" ",15,"Transfer Info:");
  1135.  fstr(" ",35,"Number of Withdrawals: $wdraw");
  1136.  cpos(10,65);
  1137.  fstr(" ",50,"Number of Deposits: $xfers");
  1138.  cpos(11,65);
  1139.  rstr("=",50);
  1140.  cpos(12,65);
  1141.  tcol("cyan");
  1142.  bstr(".",13,"BTC Withdrawn:");
  1143.  fstr(".",15,sprintf("%.8f",$btcwd));
  1144.  print " BTC";
  1145.  fstr(".",13,sprintf("%.2f",$btcwd*$btcval));
  1146.  print " USD";
  1147.  cpos(13,65);
  1148.  bstr(".",13,"BTC Deposited:");
  1149.  fstr(".",15,sprintf("%.8f",$btcin));
  1150.  print " BTC";
  1151.  fstr(".",13,sprintf("%.2f",$btcin*$btcval));
  1152.  print " USD";
  1153.  cpos(15,5);
  1154.  tcol("purple");
  1155.  bstr(" ",15,"Sales Info:");
  1156.  fstr(" ",35,"Number of Miners Sold: $hsold");
  1157.  cpos(16,5);
  1158.  rstr("=",50);
  1159.  tcol("cyan");
  1160.  cpos(17,5);
  1161.  bstr(".",13,"BTC Earned:");
  1162.  fstr(".",16,sprintf("%.8f",$btcsold));
  1163.  print " BTC";
  1164.  fstr(".",13,sprintf("%.2f",$valsold));
  1165.  print " USD";
  1166.  cpos(18,5);
  1167.  rstr(" ",50);
  1168.  cpos(19,5);
  1169.  rstr(" ",50);
  1170.  cpos(20,5);
  1171.  rstr(" ",50);
  1172.  cpos(21,5);
  1173.  rstr(" ",50);
  1174.  cpos(15,65);
  1175.  tcol("purple");
  1176.  bstr(" ",16,"HashPoints Info:");
  1177.  fstr(" ",34,"HP Payouts: $hpout");
  1178.  cpos(16,65);
  1179.  rstr("=",50);
  1180.  tcol("cyan");
  1181.  cpos(17,65);
  1182.  bstr(".",32,"HashPoints Earned from Interest:");
  1183.  fstr(".",18,"$hp HP");
  1184.  cpos(18,65);
  1185.  bstr(".",32,"HashPoints Earned from UP votes:");
  1186.  fstr(".",18,"$hpup HP");
  1187.  cpos(19,65);
  1188.  bstr(".",36,"HashPoints deducted from Down votes:");
  1189.  fstr(".",14,"$hpdown HP");
  1190.  cpos(20,65);
  1191.  bstr(".",36,"HashPoints deducted by ZENcloud:");
  1192.  fstr(".",14,"$hpdzen HP");
  1193.  cpos(21,65);
  1194.  bstr(".",36,"HashPoints Earned Mining HashPool:");
  1195.  fstr(".",14,"$hpay HP");
  1196.  tcol("black");
  1197.  bcol("green");
  1198.  cpos(38,0);
  1199.  rstr(" ",120);
  1200.  cpos(39,0);
  1201.  rstr(" ",120);
  1202.  cpos(40,0);
  1203.  rstr(" ",120);
  1204.  cpos(38,110);
  1205.  print "(Timers)";
  1206.  cpos(39,107);
  1207.  print "BTC";
  1208.  cpos(39,112);
  1209.  print "DASH";
  1210.  cpos(39,117);
  1211.  print "REC";
  1212.  cpos(40,113);
  1213.  fstr(" ",1,$dashtime-$dashval);
  1214.  cpos(40,118);
  1215.  fstr(" ",1,$rectime-$recval);
  1216.  cpos(38,1);
  1217.  print "(A)ll data to XLS  -  (B)uild daily Charts  -  (C)hart history  -  (G)roup Miner Menu  -  (M)iner Menu";
  1218.  cpos(39,1);
  1219.  print "(R)OI  -  (T)oday XLS  -  BTC (V)alue history  -  e(X)it ZENscrape";
  1220.  ReadMode(4);
  1221.  for (my $x = 0; $x < 20; $x++) {
  1222.   if (defined ($key = ReadKey(-1)))
  1223.    {
  1224.     if ($key eq 'x')
  1225.     {
  1226.      clrscr();
  1227.      tcol("white");
  1228.      bcol("black");
  1229.      print "Thank you for using ZENscrape $ver \n\n";
  1230.      ReadMode(1);
  1231.      undef $mech;
  1232.      exit;
  1233.     }
  1234.     if ($key eq 'a')
  1235.     {
  1236.      createxls();
  1237.      if ($ssoft eq 'LO') {system("libreoffice -o ZEN.xls > /dev/null &");main();}
  1238.      if ($ssoft eq 'MO') {system("ZEN.xls");main();}
  1239.     }
  1240.     if ($key eq 't')
  1241.     {
  1242.      gdate();
  1243.      tdayxls();
  1244.      if ($ssoft eq 'LO') {system("libreoffice -o ZEN_$rdate.xls > /dev/null &");main();}
  1245.      if ($ssoft eq 'MO') {system("ZEN_$rdate.xls");main();}
  1246.     }
  1247.     if ($key eq 'b')
  1248.     {
  1249.      dbox(50,"Creating ALL daily charts XLS",30,35,"","blue");
  1250.      bstr(".",45,"Creating Daily Chart");
  1251.      bdayxls();
  1252.     }
  1253.     if ($key eq 'c')
  1254.     {
  1255.      dbox(50,"Creating Historical Chart",30,35,"","blue");
  1256.      bstr(".",50,"Creating Chart");
  1257.      chartxls();
  1258.      cpos(32,81);
  1259.      print "DONE";
  1260.      sleep(1);
  1261.      if ($ssoft eq 'LO') {system("libreoffice -o ZEN_chart.xls > /dev/null &");main();}
  1262.      if ($ssoft eq 'MO') {system("ZEN_chart.xls");main();}
  1263.     }
  1264.     if ($key eq 'g')
  1265.     {
  1266.      dbox(50,"Group Miner Menu",30,35,"","red");
  1267.      bstr(".",49,"Sorry, this will be a future feature");
  1268.      foreach my $i (1..3)
  1269.      {
  1270.       print 4-$i;
  1271.       sleep(1);
  1272.       cpos(32,84);
  1273.      }
  1274.     }
  1275.     if ($key eq 'm')
  1276.     {
  1277.      dbox(50,"Miner Menu",30,35,"","red");
  1278.      bstr(".",49,"Sorry, this will be a future feature");
  1279.      foreach my $i (1..3)
  1280.      {
  1281.       print 4-$i;
  1282.       sleep(1);
  1283.       cpos(32,84);
  1284.      }
  1285.     }
  1286.     if ($key eq 'r')
  1287.     {
  1288.      dbox(50,"ROI Menu",30,35,"","red");
  1289.      bstr(".",49,"Sorry, this will be a future feature");
  1290.      foreach my $i (1..3)
  1291.      {
  1292.       print 4-$i;
  1293.       sleep(1);
  1294.       cpos(32,84);
  1295.      }
  1296.     }
  1297.     if ($key eq 'v')
  1298.     {
  1299.      dbox(50,"Historical BTC Value",30,35,"","red");
  1300.      bstr(".",49,"Sorry, this will be a future feature");
  1301.      foreach my $i (1..3)
  1302.      {
  1303.       print 4-$i;
  1304.       sleep(1);
  1305.       cpos(32,84);
  1306.      }
  1307.     }
  1308.     $x=20;
  1309.    }
  1310.   cpos(40,108);
  1311.   tcol("black");
  1312.   bcol("green");
  1313.   fstr(" ",2,20-$x);
  1314.   cpos(0,0);
  1315.   sleep(1);
  1316.  }
  1317.  ++$recval;
  1318.  ++$dashval;
  1319.  btcv();
  1320.  if ($dashval==$dashtime){ dash(); $dashval=0;}
  1321.  if ($recval==$rectime){ crec(); $recval=0;}
  1322.  main();
  1323. }
  1324.  
  1325. clrscr();
  1326. printf("\e[8;40;120;t");
  1327. tcol("");
  1328. bcol("blue");
  1329. rstr(" ",40);
  1330. print "Welcome to ZENscrape $ver by Cryptichermit";
  1331. rstr(" ",80-length("Welcome to ZENscrape $ver by Cryptichermit"));
  1332. bcol("");
  1333.  
  1334. if (-e $zenapi) {
  1335.  open my $fh, '<', $zenapi or die "error opening $zenapi: $!";
  1336.  $data = do { local $/; <$fh> };
  1337.  $c = index($data, '"iTotalRecords":');
  1338.  $c = $c+16;
  1339.  $e = index($data, ',"aaData"');
  1340.  $locrec = substr($data,$c,$e-$c);
  1341.  print "($zenapi - Found) - Welcome Back!\nLast recorded record = $locrec - loading local data\n\n";
  1342.  close $fh;
  1343.  $c = index($data, '[{"createdAt"');
  1344.  $sdata = substr($data,$c);
  1345. }
  1346.  
  1347. if ($btcval == 0)
  1348. {
  1349.  btcv();
  1350. }
  1351.  
  1352. crec();
  1353. dash();
  1354. main();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement