Advertisement
Guest User

Untitled

a guest
May 25th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. <?php
  3. //mb_internal_encoding("UTF-8");
  4. //echo mb_internal_encoding();
  5.  
  6. $today  = mktime(0, 0, 0, date("m")  , date("d"), date("Y"));
  7. $ytday  = mktime(0, 0, 0, date("m")  , date("d")-1, date("Y"));
  8. $today = strftime("%Y-%m-%d", $today);
  9. $ytday = strftime("%Y-%m-%d", $ytday);
  10.  
  11. echo "today: ";
  12. echo $today;
  13. echo "<br>";
  14. echo "yesterday: ";
  15. echo $ytday;
  16.  
  17. //echo "<div id='income_json'>";
  18.  
  19. echo "<div id='income_json'>";
  20. $a = include('data.json');
  21. echo "</div>";
  22.  
  23.  
  24. ?>
  25.  
  26. <script type="text/javascript">
  27. var div_html = document.getElementById('income_json');
  28. var jsonString = (div_html.innerText);
  29.  
  30. var json = JSON.parse(jsonString);
  31. var table=[];
  32. //document.write('<table>');
  33. for(var key in json){
  34.     table.push({'site':key, 'days':json[key]});
  35.     //document.write('<tr>');
  36.     //document.write('<td>');
  37.     //document.write(key);
  38.     //document.write('</td');
  39.     //document.write('<td>');
  40.     //document.write(json[key]);
  41.     //document.write('</td');
  42.  
  43.     console.log(key);
  44.     console.log(json[key]);
  45.     //document.write('</tr');
  46. }
  47.  
  48. document.write('<table class="ui celled table">');
  49. // table body
  50. document.write('<thead>');
  51.     document.write('<tr>');
  52.         document.write('<th>site</th>')
  53.         document.write('<th>'+ yesterday + '</th>')
  54.         document.write('<th>'+ yesterday + ' (AdBlock)</th>')
  55.         document.write('<th>AdBlock %</th>')
  56.        
  57.         for (var i = 1; i <= 12; i++) {
  58.             document.write("<th>" + i + "</th>")   
  59.         }
  60.     document.write('</tr>');
  61. document.write('</thead>');
  62.  
  63. document.write('<tbody>');
  64.  
  65. for (var i=0; i < table.length; i++) {
  66.     document.write('<tr>');
  67.     document.write('<td>');
  68.     document.write(table[i].site);
  69.     document.write('</td>');
  70.  
  71.         document.write('<td>');
  72.             document.write(table[i].days.yesterday.all_clicks);
  73.            
  74.         document.write('</td>');
  75.         document.write('<td>');
  76.             document.write(table[i].days.yesterday.adblock_cliks); 
  77.         document.write('</td>');
  78.         document.write('<td>');
  79.             document.write(isNumber(table[i].days.yesterday.adblock_cliks))
  80.             document.write(table[i].days.yesterday.adblock_cliks / table[i].days.yesterday.all_clicks);
  81.         document.write('</td>');
  82.  
  83.     for(var key in table[i].days.hours){
  84.         document.write('<td>');
  85.             document.write(table[i].days.hours[key].adblock_cliks);
  86.         document.write('</td>');
  87.  
  88.         document.write('<td>');
  89.             document.write(table[i].days.hours[key].all_clicks);
  90.         document.write('</td>');
  91.  
  92.         document.write('<td>');
  93.             document.write(table[i].days.hours[key].all_clicks);
  94.         document.write('</td>');
  95.  
  96.     }
  97.    
  98.     // empty cell — because why the hell not?
  99.     // uncomment if you really need it
  100.     // document.write('<td>');
  101.     // document.write('</td>');
  102.    
  103.     document.write('</tr>');
  104. }
  105. document.write('</tbody>');
  106. // end of table body
  107. document.write('</table>');
  108.  
  109. //alert(<?php echo $a+$a; ?>);
  110.  
  111.  
  112.  
  113.  
  114. </script>>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement