Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ======livestream.php=====
- <?php
- include_once("teamspeak.php");
- include_once("include/announcement.php");
- $dark =isset($_GET['dark']);
- ?>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Rlscraft Livesteam</title>
- <link type="text/css" rel="stylesheet" href="bootstrap/dist/css/bootstrap.css" />
- <link type="text/css" rel="stylesheet" href="css/main.css" />
- <link rel="shortcut icon" href="favicon.png">
- </head>
- <body <? echo ($dark ? "style ='background-color:#555;'" : " " )?>>
- <div id="wrapper">
- <?php include_once("include/analyticstracking.php") ?>
- <?php
- include_once("include/navbar.php");
- include_once("include/footer.php");
- makeNewNav(basename(__FILE__), $dark);
- ?>
- <div class="container theme-showcase">
- <? echo getMessage(); ?>
- <?
- include "include/twitch_api.php";
- function isStreaming($name){
- $streams = json_decode(get_url_contents("https://api.twitch.tv/kraken/streams/" . $name));
- //print_r($streams);
- //echo $streams -> stream;
- if($streams -> stream == NULL){
- $streaming = false;
- //echo "false!!";
- }else{
- $streaming = true;
- //echo "true!!!";
- }
- return $streaming;
- }
- $channels =array();
- array_push($channels, "rlhl83", "xbossxs", "kh11601", "LoungeGaming");
- $live = array();
- $i = 0;
- foreach($channels as $name){
- $streaming = isStreaming($name);
- if($streaming){
- $i++;
- //echo "HE IS LIVE!";
- array_push($live, $name);
- }else{
- //echo " He if offline!";
- }
- }
- $width = "620";
- $chatHeight = "400";
- $videoHeight = "400";
- $multiple_streams = ($i == 1 ? "is " : "are ");
- echo "<center><h3>There " . $multiple_streams . $i . " Channel" . ($i != 1 ? "s " : "") . "live</h3></center>";
- echo "<center><table> <tr>";
- foreach($live as $name){
- //echo "<br>" . $name . " Is live";
- echo "<td> " . $name . " </td>";
- }
- echo "</tr><tr>";
- foreach($live as $name){
- echo "<td>";
- if($live[0] == $name){
- video($name, $videoHeight, $width);
- }else{
- video($name, $videoHeight, $width, 0);
- }
- //echo "<br>" . $name . " Is live";
- echo "</td>";
- }
- echo "</tr><tr>";
- foreach($live as $name){
- //echo "<br>" . $name . " Is live";
- chat($name, $chatHeight, $width);
- }
- echo "</tr></table></center>";
- ?>
- </div>
- <script src="bootstrap/assets/js/jquery.js"></script>
- <script src="bootstrap/dist/js/bootstrap.min.js"></script>
- <?php makeFooter(); ?>
- </div>
- </body>
- </html>
- =====twitch_api.php=====
- <?php
- function get_url_contents($url){
- $crl = curl_init();
- $timeout = 5;
- curl_setopt ($crl, CURLOPT_URL,$url);
- curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
- curl_setopt ($crl, CURLOPT_SSL_VERIFYPEER, false);
- $ret = curl_exec($crl);
- curl_close($crl);
- return $ret;
- }
- function video($stream, $videoheight, $width, $volume = 25){
- echo"<object type='application/x-shockwave-flash' height='$videoheight' width='$width' id='live_embed_player_flash' data='http://www.twitch.tv/widgets/live_embed_player.swf?channel=$stream' bgcolor='#000000'>
- <param name='allowFullScreen' value='true' />
- <param name='allowScriptAccess' value='always' />
- <param name='allowNetworking' value='all' />
- <param name='movie' value='http://www.twitch.tv/widgets/live_embed_player.swf' />
- <param name='flashvars' value='hostname=www.twitch.tv&channel=$stream&auto_play=true&start_volume=$volume' /></object>";
- }
- function chat($name, $chatheight, $width){
- echo"<td><center>
- <iframe frameborder='0' scrolling='no' id='chat_embed' src='http://twitch.tv/chat/embed?channel=$name&popout_chat=true' height='$chatheight' width='$width'></iframe>
- </center></td>";
- }
- ?>
Add Comment
Please, Sign In to add comment