]> git.leonardobizzoni.com Git - highschool-graduation-project/commitdiff
Improved live vtuber page
authorLeonardoBizzoni <leo2002714@gmail.com>
Mon, 18 Apr 2022 18:19:17 +0000 (20:19 +0200)
committerLeonardoBizzoni <leo2002714@gmail.com>
Mon, 18 Apr 2022 18:19:17 +0000 (20:19 +0200)
scripts/newIdol.php [new file with mode: 0644]
www/pub/css/index.css [new file with mode: 0644]
www/views/layouts/live.php
www/views/live.php

diff --git a/scripts/newIdol.php b/scripts/newIdol.php
new file mode 100644 (file)
index 0000000..e9a6556
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+include_once "config.php";
+
+
+$idolPage = $_GET["idolLink"];
+
+if (str_contains($idolPage, "twitch.tv")) {
+    $idol = str_replace("https://www.twitch.tv/", "", $idolPage);
+    $url = "https://api.twitch.tv/helix/users?login=$idol";
+
+    $ch = curl_init($url);
+    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+    curl_setopt($ch, CURLOPT_TIMEOUT, 3);
+    curl_setopt($ch, CURLOPT_HTTPHEADER, [$token, $clientID]);
+
+    $result = json_decode(curl_exec($ch));
+    curl_close($ch);
+
+    $result = get_object_vars($result);
+    $result = get_object_vars($result["data"][0]);
+
+    $idolFile = fopen("../vtuber/" . $idol . ".php", "w") or die("Unable to open file!");
+    fwrite($idolFile, "<!doctype html>
+<html lang=\"en\">
+    <head>
+        <meta charset=\"UTF-8\"/>
+    <link href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css\" rel=\"stylesheet\" integrity=\"sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3\" crossorigin=\"anonymous\">
+    <link rel=\"stylesheet\" href=\"../assets/css/index.css\" type=\"text/css\" media=\"screen\" />
+<title>" . $idol . "</title>
+    </head>
+<body>
+    <div id=\"parent\">
+    <div>
+    <nav class=\"navbar bg-dark text-white\">
+        <div class=\"container-fluid\">
+                <h1>" . $idol . "</h1><img class=\"idolLogo\" src=\"" . $result["profile_image_url"] . "\"/>
+        </div>
+    </nav>
+
+</div>
+
+<div id=\"child\">
+<iframe src=\"https://player.twitch.tv/?channel=".$result["login"]."&parent=localhost\" frameborder=\"0\" allowfullscreen=\"true\" scrolling=\"no\"></iframe>
+</div>
+</div>
+
+</body>
+</html>
+");
+    fclose($idolFile);
+
+    header("Location:/ProgettoAnime/vtuber.php");
+} else if (str_contains($idolPage, "youtube.com")) {
+    echo "Prima o poi";
+} else {
+    echo "wtf";
+}
diff --git a/www/pub/css/index.css b/www/pub/css/index.css
new file mode 100644 (file)
index 0000000..ec4426a
--- /dev/null
@@ -0,0 +1,29 @@
+body {
+    height: 100%;
+    box-sizing: border-box;
+    margin: 0;
+    padding: 0;
+    background-color: #212529;
+    color: white;
+}
+
+iframe {
+    width: 100%;
+    height: 100%;
+}
+
+#parent {
+    height:100%;
+    width:100%;
+    display: flex;
+    flex-grow: 1;
+    flex-direction: column;
+}
+
+#child {
+    flex-grow: 1;
+}
+
+.idolLogo {
+    width: 100px;
+}
index e3e8a307247618299670e6b4bd226622f86cad00..402b17ea6381967acdf3118365cba530f2bcecfe 100644 (file)
@@ -1,13 +1,9 @@
 <html lang="en">
 
 <head>
-    <meta charset="UTF-8" />
+    <meta charset="UTF-8"/>
     <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
-    <style>
-        img {
-            width: 5%;
-        }
-    </style>
+    <link rel="stylesheet" href="/css/index.css" type="text/css" media="screen" />
     <title>WeebSite - Live!</title>
 </head>
 
index 79b0b814633d556f04898106ecea8981fd281a11..54bb45729bc603cae6d5ab712229c332e648e642 100644 (file)
@@ -16,18 +16,19 @@ if (!isset($_GET["id"])) {
     foreach ($params[0] as $vtuber) {
         if ($_GET["id"] == $vtuber["id"]) {
             echo "
-<div id=\"parent\">
+    <div id=\"parent\">
     <div>
-      <nav class=\"navbar bg-dark text-white\">
-          <div class=\"container-fluid\">
-                  <h1>" . ucfirst($vtuber["username"]) . "</h1><img src='".$vtuber["img"]."'/>
-          </div>
-      </nav>
-    </div>
+    <nav class=\"navbar bg-dark text-white\">
+        <div class=\"container-fluid\">
+                <h1>" . ucfirst($vtuber["username"]) . "</h1><img class=\"idolLogo\" src=\"" . $vtuber["img"] . "\"/>
+        </div>
+    </nav>
+
 </div>
 
 <div id=\"child\">
-<iframe src=\"https://player.twitch.tv/?channel=" . $vtuber["login"] . "&parent=localhost\" frameborder=\"0\" allowfullscreen=\"true\" scrolling=\"no\"></iframe>
+<iframe src=\"https://player.twitch.tv/?channel=".$vtuber["login"]."&parent=localhost\" frameborder=\"0\" allowfullscreen=\"true\" scrolling=\"no\"></iframe>
+</div>
 </div>
 ";
         }