Advertisement
Nikczemny

Untitled

May 26th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.17 KB | None | 0 0
  1. <html>
  2. <head>
  3. <style>
  4. table, th, td {
  5.     border: 1px solid black;
  6. }
  7. </style>
  8. <script
  9.   src="https://code.jquery.com/jquery-3.2.1.min.js"
  10.   integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
  11.   crossorigin="anonymous"></script>
  12.  
  13. <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.15/css/jquery.dataTables.css">
  14.  
  15. <script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.15/js/jquery.dataTables.js"></script>
  16. </head>
  17. <body>
  18.  
  19. <?php
  20. $json = file_get_contents('https://armaremoteadmin.com/api/extern/v1/IServergroup/GetPlayerData.ashx?key=***&id=295&guid=76a8c7dccd9af8dc324fe4fd91aaac3b');
  21. $data = json_decode($json);
  22. echo 'Obecny serwer: ';
  23. if ($data->Response->IsCurrentlyPlaying == '-1') {
  24.   echo 'Ten gracz jest offline';
  25. } else {
  26.   echo $data->Response->IsCurrentlyPlaying;
  27. }
  28. echo '<br>';
  29. echo '<b>Nicki użyte w grze:</b>';
  30. foreach ($data->Response->Aliases as $aliases) {
  31.   echo $aliases . ', ';
  32. }
  33. $totalminutes = 0;
  34. ?>
  35. <table id="myTable">
  36.   <caption>Sesje na Serwerze</caption>
  37.   <thead>
  38.     <tr>
  39.       <th>Od</th>
  40.       <th>Do</th>
  41.       <th>Trwała</th>
  42.     </tr>
  43.   </thead>
  44.   <tbody>
  45.     <?php
  46. foreach ($data->Response->PlaySessions as $datas) {
  47.   $start = str_replace('T',' ',$datas->FromUTC);
  48.   $end = str_replace('T',' ',$datas->ToUTC);
  49. echo '<tr><td>' . $start . '</td><td>';
  50. if(!(empty($end))){
  51.   echo $end . '</td><td>';
  52. } else {
  53.   echo 'N/A</td><td>';
  54. }
  55. if(!(empty($end))){
  56.   $seconds = strtotime("$end") - strtotime("$start");
  57.   $minutes = floor($seconds / 60);
  58.   echo $minutes . ' min';
  59.   $totalminutes = $totalminutes + $minutes;
  60. } else {
  61.   echo 'N/A';
  62. }
  63. echo '</td></tr>';
  64. }
  65.  
  66. ?>
  67. </tbody>
  68. </table>
  69. <?php
  70. /*foreach ($data->Response->PlaySessions as $time) {
  71.   $start = str_replace('T',' ',$time->FromUTC);
  72.   $end = str_replace('T',' ',$time->ToUTC);
  73.   $time1 = strtotime("$start");
  74.   $time2 = strtotime("$end");
  75.   echo date("d-m-Y",$time1) . '<br>';
  76. }*/
  77. ?>
  78. <h3> Łącznie w ciągu miesiąca: <?=$totalminutes?> min</h3><br><br><br>
  79. <script>
  80. $(document).eady(function(){
  81.     $('#myTable').DataTable();
  82. });
  83. </script>
  84. <?php
  85. echo "<pre>";
  86. print_r($data);
  87. echo "</pre>";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement