Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*Listataan Veikkauksen lauantaivakion pelatuimmuusprosentit,
- kaksi pelikierrosta:
- kuluva viikko ja edellinen jo ratkennut viikko*/
- error_reporting(0);
- header("Content-Type: text/html; charset=utf-8");
- header("Cache-Control: no-cache");
- $offset = 60 * 60 * 24 * 1;
- $ExpStr = "Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT";
- header($ExpStr);
- date_default_timezone_set("Europe/Helsinki");
- //alustetaan muuttujat
- $startNr = 100430; //vuoden 2023 viikon 52 lauantaivakion id, täsmäytä $startNr vuosittain viikolla 1
- $weekNow = (int) date("W", strtotime('-7 hours'));
- $weekLast = (int) date("W", strtotime('-7 days -7 hours'));
- $vakioIdThisWeek = ($startNr + $weekNow);
- $vakioIdLastWeek = ($startNr + $weekNow - 1);
- $justNyt = time();
- ?>
- <!DOCTYPE HTML>
- <html lang="fi">
- <head>
- <meta charset="UTF-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title>VAKIO-1 ~ PELIJAKAUMA (%)</title>
- <meta name="apple-mobile-web-app-title" content="PERCENTAGES" />
- <meta name="author" content="Anonymous" />
- <style>*{box-sizing:border-box}html{background-color:#F0F0F0}body{margin:0}#main{width:420px;margin:20px auto;display:block}h3{margin:10px}p{color:#000;margin:0 0 0 20px}th{padding:8px;border:solid 1px #000;background:#00F;color:#FFF}td{padding:8px;border:solid 1px #000;background:#F0F0FF}.act{color:#008000}.kes{text-align:center}.ohi{color:#F00}.oik{text-align:right}.sep{width:95%;height:1px}.st1{width:418px;table-layout:fixed}.st2{width:236px}.st3{width:56px}.vas{text-align:left}</style>
- </head>
- <body>
- <div id="main">
- <?php
- if (!isset($vakioIdThisWeek) && !isset($vakioIdLastWeek)) { die("<h3>Viikkoa ei ole määritelty!</h3>"); }
- if (isset($vakioIdThisWeek) && $vakioIdThisWeek > 0) {
- $active = 0;
- $outcomes = array();
- // Alustetaan URL
- $host = "https://www.veikkaus.fi";
- $header = array(
- "Accept: application/json",
- "Content-Type: application/json",
- "X-ESA-API-Key: ROBOT"
- );
- $url = $host ."/api/sport-results/v1/games/SPORT/draws/".$vakioIdThisWeek;
- // Alustetaan cURL asetuksineen
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true);
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_POST, 0);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
- curl_setopt($ch, CURLOPT_ENCODING, "identity");
- // Suoritetaan pyyntö
- $data = curl_exec($ch);
- // Suljetaan cURL
- curl_close($ch);
- // Tarkistetaan että datassa on eloa
- $sub = "outcome";
- if ($data && strpos($data, $sub) !== false) {
- $teams = array();
- $teams = json_decode($data, true);
- $z = 0;
- while (isset($teams['rows'][$z])) {
- array_push($outcomes, $teams['rows'][$z]['outcome']['home']['name']." - ".$teams['rows'][$z]['outcome']['away']['name']);
- $z++;
- }
- if (isset($teams['closeTime'])) {
- $closeT = date("d.m.Y \k\l\o H:i", $teams['closeTime']/1000);
- if ($justNyt < ($teams['closeTime']/1000)) { $active = 1;}
- }
- }
- // Alustetaan URL
- $host = "https://www.veikkaus.fi";
- $header = array(
- "Accept: application/json",
- "Content-Type: application/json",
- "X-ESA-API-Key: ROBOT"
- );
- $url = $host ."/api/sport-popularity/v1/games/SPORT/draws/".$vakioIdThisWeek."/popularity";
- // Alustetaan cURL asetuksineen
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true);
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_POST, 0);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
- curl_setopt($ch, CURLOPT_ENCODING, "identity");
- // Suoritetaan pyyntö
- $data = curl_exec($ch);
- // Suljetaan cURL
- curl_close($ch);
- // Tarkistetaan että datassa on eloa
- $sub = "resultPopularities";
- if ($data && strpos($data, $sub) !== false) {
- $prossat = array();
- $prossat = json_decode($data, true);
- echo "<h2 class='kes'>LAUANTAIVAKIO, KIERROS ".$vakioIdThisWeek."</h2>";
- if ($active == 1) { echo "<h3 class='kes'>peliaika päättyy <span class='act'>".$closeT."</span></h3>"; } else { echo "<h3 class='kes'>peliaika päättyi <span class='ohi'>".$closeT."</span></h3>"; }
- echo "<h3 class='kes'>perusvakion pelatuimmuus-%</h3>";
- echo "<table class='st1'><thead><tr><th class='vas st2'>kohdelista</th><th class='st3'>1</th><th class='st3'>X</th><th class='st3'>2</th></tr></thead><tbody>";
- $x = 0;
- $y = 1;
- while (isset($prossat['resultPopularities'][$x]['percentage'])) {
- echo "<tr><td>".$y.") ".$outcomes[$y-1]."</td><td class='oik'>".number_format(($prossat['resultPopularities'][$x]['percentage']/100),2,","," ")."</td>";
- $x++;
- echo "<td class='oik'>".number_format(($prossat['resultPopularities'][$x]['percentage']/100),2,","," ")."</td>";
- $x++;
- echo "<td class='oik'>".number_format(($prossat['resultPopularities'][$x]['percentage']/100),2,","," ")."</td></tr>";
- $x++;
- $y++;
- }
- echo "</tbody></table><br />";
- echo "<h3 class='kes'>minivakion pelatuimmuus-%</h3>";
- echo "<table class='st1'><thead><tr><th class='vas st2'>kohdelista</th><th class='st3'>1</th><th class='st3'>X</th><th class='st3'>2</th></tr></thead><tbody>";
- $x = 0;
- $y = 1;
- while (isset($prossat['resultPopularities'][$x]['awdPercentage'])) {
- echo "<tr><td>".$y.") ".$outcomes[$y-1]."</td><td class='oik'>".number_format(($prossat['resultPopularities'][$x]['awdPercentage']/100),2,","," ")."</td>";
- $x++;
- echo "<td class='oik'>".number_format(($prossat['resultPopularities'][$x]['awdPercentage']/100),2,","," ")."</td>";
- $x++;
- echo "<td class='oik'>".number_format(($prossat['resultPopularities'][$x]['awdPercentage']/100),2,","," ")."</td></tr>";
- $x++;
- $y++;
- }
- echo "</tbody></table>";
- echo "<br /><p>perusvakion vaihto: ".number_format(($prossat['exchange']/100),2,","," ")." €</p>";
- //minivakion vaihtoon tarvittava kysely
- $ehm = "{ \"page\": 0, \"pageSize\": 100, \"additionalPrizeTier\": true, \"selections\": [ ";
- $ehm .= "{ \"outcomes\":[\"1\"] }, ";
- $ehm .= "{ \"outcomes\":[\"1\"] }, ";
- $ehm .= "{ \"outcomes\":[\"1\"] }, ";
- $ehm .= "{ \"outcomes\":[\"1\"] }, ";
- $ehm .= "{ \"outcomes\":[\"1\"] }, ";
- $ehm .= "{ \"outcomes\":[\"1\"] }, ";
- $ehm .= "{ \"outcomes\":[\"1\"] } ] }";
- // Alustetaan URL
- $host = "https://www.veikkaus.fi";
- $header = array(
- "Accept: application/json",
- "Content-Type: application/json",
- "X-ESA-API-Key: ROBOT"
- );
- $url = $host . "/api/sport-winshare/v1/games/SPORT/draws/".$vakioIdThisWeek."/winshare";
- // Alustetaan cURL asetuksineen
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true);
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $ehm);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
- curl_setopt($ch, CURLOPT_ENCODING, "identity");
- // Suoritetaan pyyntö
- $minidata = curl_exec($ch);
- // Suljetaan cURL
- curl_close($ch);
- // Tarkistetaan että datassa on eloa
- $sub = "exchange";
- if ($data && strpos($data, $sub) !== false) {
- $tuloksetmini = array();
- $tuloksetmini = json_decode($minidata,true);
- echo "<p>minivakion vaihto: ".number_format(($tuloksetmini['exchange']/100),2,","," ")." €</p>";
- }
- echo "<hr class='sep'>";
- }
- }
- if (isset($vakioIdLastWeek) && $vakioIdLastWeek > 0) {
- $active = 0;
- $outcomes = array();
- // Alustetaan URL
- $host = "https://www.veikkaus.fi";
- $header = array(
- "Accept: application/json",
- "Content-Type: application/json",
- "X-ESA-API-Key: ROBOT"
- );
- $url = $host ."/api/sport-results/v1/games/SPORT/draws/".$vakioIdLastWeek;
- // Alustetaan cURL asetuksineen
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true);
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_POST, 0);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
- curl_setopt($ch, CURLOPT_ENCODING, "identity");
- // Suoritetaan pyyntö
- $data = curl_exec($ch);
- // Suljetaan cURL
- curl_close($ch);
- // Tarkistetaan että datassa on eloa
- $sub = "outcome";
- if ($data && strpos($data, $sub) !== false) {
- $teams = array();
- $teams = json_decode($data, true);
- $z = 0;
- while (isset($teams['rows'][$z])) {
- array_push($outcomes, $teams['rows'][$z]['outcome']['home']['name']." - ".$teams['rows'][$z]['outcome']['away']['name']);
- $z++;
- }
- if (isset($teams['closeTime'])) {
- $closeT = date("d.m.Y \k\l\o H:i", $teams['closeTime']/1000);
- if ($justNyt < ($teams['closeTime']/1000)) { $active = 1;}
- }
- }
- // Alustetaan URL
- $host = "https://www.veikkaus.fi";
- $header = array(
- "Accept: application/json",
- "Content-Type: application/json",
- "X-ESA-API-Key: ROBOT"
- );
- $url = $host ."/api/sport-popularity/v1/games/SPORT/draws/".$vakioIdLastWeek."/popularity";
- // Alustetaan cURL asetuksineen
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true);
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_POST, 0);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
- curl_setopt($ch, CURLOPT_ENCODING, "identity");
- // Suoritetaan pyyntö
- $data = curl_exec($ch);
- // Suljetaan cURL
- curl_close($ch);
- // Tarkistetaan että datassa on eloa
- $sub = "resultPopularities";
- if ($data && strpos($data, $sub) !== false) {
- $prossat = array();
- $prossat = json_decode($data, true);
- echo "<h2 class='kes'>LAUANTAIVAKIO, KIERROS ".$vakioIdLastWeek."</h2>";
- if ($active == 1) { echo "<h3 class='kes'>peliaika päättyy <span class='act'>".$closeT."</span></h3>"; } else { echo "<h3 class='kes'>peliaika päättyi <span class='ohi'>".$closeT."</span></h3>"; }
- echo "<h3 class='kes'>perusvakion pelatuimmuus-%</h3>";
- echo "<table class='st1'><thead><tr><th class='vas st2'>kohdelista</th><th class='st3'>1</th><th class='st3'>X</th><th class='st3'>2</th></tr></thead><tbody>";
- $x = 0;
- $y = 1;
- while (isset($prossat['resultPopularities'][$x]['percentage'])) {
- echo "<tr><td>".$y.") ".$outcomes[$y-1]."</td><td class='oik'>".number_format(($prossat['resultPopularities'][$x]['percentage']/100),2,","," ")."</td>";
- $x++;
- echo "<td class='oik'>".number_format(($prossat['resultPopularities'][$x]['percentage']/100),2,","," ")."</td>";
- $x++;
- echo "<td class='oik'>".number_format(($prossat['resultPopularities'][$x]['percentage']/100),2,","," ")."</td></tr>";
- $x++;
- $y++;
- }
- echo "</tbody></table><br />";
- echo "<h3 class='kes'>minivakion pelatuimmuus-%</h3>";
- echo "<table class='st1'><thead><tr><th class='vas st2'>kohdelista</th><th class='st3'>1</th><th class='st3'>X</th><th class='st3'>2</th></tr></thead><tbody>";
- $x = 0;
- $y = 1;
- while (isset($prossat['resultPopularities'][$x]['awdPercentage'])) {
- echo "<tr><td>".$y.") ".$outcomes[$y-1]."</td><td class='oik'>".number_format(($prossat['resultPopularities'][$x]['awdPercentage']/100),2,","," ")."</td>";
- $x++;
- echo "<td class='oik'>".number_format(($prossat['resultPopularities'][$x]['awdPercentage']/100),2,","," ")."</td>";
- $x++;
- echo "<td class='oik'>".number_format(($prossat['resultPopularities'][$x]['awdPercentage']/100),2,","," ")."</td></tr>";
- $x++;
- $y++;
- }
- echo "</tbody></table>";
- echo "<br /><p>perusvakion vaihto: ".number_format(($prossat['exchange']/100),2,","," ")." €</p>";
- //minivakion vaihtoon tarvittava kysely
- $ehm = "{ \"page\": 0, \"pageSize\": 100, \"additionalPrizeTier\": true, \"selections\": [ ";
- $ehm .= "{ \"outcomes\":[\"1\"] }, ";
- $ehm .= "{ \"outcomes\":[\"1\"] }, ";
- $ehm .= "{ \"outcomes\":[\"1\"] }, ";
- $ehm .= "{ \"outcomes\":[\"1\"] }, ";
- $ehm .= "{ \"outcomes\":[\"1\"] }, ";
- $ehm .= "{ \"outcomes\":[\"1\"] }, ";
- $ehm .= "{ \"outcomes\":[\"1\"] } ] }";
- // Alustetaan URL
- $host = "https://www.veikkaus.fi";
- $header = array(
- "Accept: application/json",
- "Content-Type: application/json",
- "X-ESA-API-Key: ROBOT"
- );
- $url = $host . "/api/sport-winshare/v1/games/SPORT/draws/".$vakioIdLastWeek."/winshare";
- // Alustetaan cURL asetuksineen
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true);
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $ehm);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
- curl_setopt($ch, CURLOPT_ENCODING, "identity");
- // Suoritetaan pyyntö
- $minidata = curl_exec($ch);
- // Suljetaan cURL
- curl_close($ch);
- // Tarkistetaan että datassa on eloa
- $sub = "exchange";
- if ($data && strpos($data, $sub) !== false) {
- $tuloksetmini = array();
- $tuloksetmini = json_decode($minidata,true);
- echo "<p>minivakion vaihto: ".number_format(($tuloksetmini['exchange']/100),2,","," ")." €</p>";
- }
- echo "<hr class='sep'>";
- }
- }
- //siivotaan jälkiä
- if (isset($host)) { unset($host); }
- if (isset($header)) { unset($header); }
- if (isset($url)) { unset($url); }
- if (isset($ch)) { unset($ch); }
- if (isset($startNr)) { unset($startNr); }
- if (isset($weekNow)) { unset($weekNow); }
- if (isset($weekLast)) { unset($weekLast); }
- if (isset($vakioIdThisWeek)) { unset($vakioIdThisWeek); }
- if (isset($vakioIdLastWeek)) { unset($vakioIdLastWeek); }
- if (isset($sub)) { unset($sub); }
- if (isset($data)) { unset($data); }
- if (isset($minidata)) { unset($minidata); }
- if (isset($prossat)) { unset($prossat); }
- if (isset($tuloksetmini)) { unset($tuloksetmini); }
- if (isset($outcomes)) { unset($outcomes); }
- if (isset($teams)) { unset($teams); }
- if (isset($ehm)) { unset($ehm); }
- if (isset($justNyt)) { unset($justNyt); }
- if (isset($active)) { unset($active); }
- if (isset($x)) { unset($x); }
- if (isset($y)) { unset($y); }
- if (isset($z)) { unset($z); }
- ?>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement