Quote
<a href="http://pcgamer.no/viewpage.php?page_id=42?channel='.$value.'"> <h3>'.$value.'</h3> </a>
Quote
<a href="?channel='.$value.'"> <h3>'.$value.'</h3> </a>
<a href="http://pcgamer.no/viewpage.php?page_id=42&channel='.$value.'"> <h3>'.$value.'</h3> </a>
<html>
<head>
<title>STREAMS</title>
<link rel="stylesheet" type="text/css" href="/twitchchannelswitcher/images/stream.css" />
</head>
<body>
<div class="wrapper">
<div class="viewer">
<?php
$channel = $_GET["channel"];
if($channel == null){
//default channel
$channel = "admiralbulldog";
}
//places the flash video viewer $channel can be given as a url argument i.e. http://www.maegis.net/index.php/stream-list/?channel=maegis
echo '<object type="application/x-shockwave-flash" height="400" width="494" id="live_embed_player_flash" data="http://nl.twitch.tv/widgets/live_embed_player.swf?channel='.$channel.'" bgcolor="#000000"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="allowNetworking" value="all" /><param name="movie" value="http://nl.twitch.tv/widgets/live_embed_player.swf" /><param name="flashvars" value="hostname=www.twitch.tv&channel='.$channel.'&auto_play=true&start_volume=25" /></object>
<iframe frameborder="0" scrolling="no" id="chat_embed" src="http://twitch.tv/chat/embed?channel='.$channel.'&popout_chat=true" height="400" width="300"></iframe>'; ?>
</div>
</br>
<hr>
<?php
/**
* @version 1.0 for twitch api 2.0
* @copyright (C) 2012/2013 Cees Middel (Avon) www.maegis.net
* @Inspired by Syi http://mushroom-mayhem.com
* @license GNU/GPL v3 http://www.gnu.org/licenses/gpl.html
*/
/**
* array with all stream names i.e. www.twitch.tv/"maegis".
* To add more users just add their channel names with comma seperation
* This is all there is, no futher editing required
*/
$members = array("admiralbulldog","wintergaming","olofmeister","draksyl","dragon","flusha","demuslim","dendi","acermma","aliastar","trumpsc","officialgetright","hiko","merlinidota","liquidmana","liquidsnute","beyondthesummit");
// This variable becomes one long url with the channel names stringed up behind it
// This url then fetches a json file from twitch with all the selected channels information
$userGrab = "https://api.twitch.tv/kraken/streams?channel=";
//I use this array to compare with the members array. All users in this arrat are substracted from the members array and hence are //"offline"
$checkedOnline = array ();
foreach($members as $i =>$value){
$userGrab .= ",";
$userGrab .= $value;
}
//grabs the channel data from twitch.tv streams
$twitchChannels_array = json_decode(get_url_contents($userGrab));
foreach($twitchChannels_array->streams as $i => $value){
$title = $twitchChannels_array->streams[$i]->channel->name;
$viewer = $twitchChannels_array->streams[$i]->viewers;
$topic = $twitchChannels_array->streams[$i]->channel->status;
$thumb = $twitchChannels_array->streams[$i]->preview->medium;
onlinecheck($title, $viewer, $thumb, $topic);
$checkedOnline[] = signin($title);
}
//checks if player streams are online
function onlinecheck($online, $viewers, $thumb, $topic)
{
//If the variable online is not equal to null, there is a good change this person is currently streaming
if ($online != null)
{
echo '<div class="stream_main">
<div class="stream_ thumb">
<a href="index.php?channel='.$online.'"> <img src="'.$thumb.'" class="thumb_bg" width="188" height="113"/></a>
</div>
<div class="stream_title">
<a href="index.php?channel='.$online.'"> <h3>'.$online.'</h3> </a>
</div>
<div class="stream_info">
 <img src="/twitchchannelswitcher/images/online.png"> Online  <img src="/twitchchannelswitcher/images/viewers.png">  '.$viewers.'</br>
</div>
</div>';
}
}
//This funcion add's online channel names to the checked online array
function signin($person){
if($person != null){
return $person;
}
else{
return null;
}
}
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);
$ret = curl_exec($crl);
curl_close($crl);
return $ret;
}
//This part list all the people currently offline. Here the array with online users is compared with the total users.
//online users are then removed from the total users array.
foreach ($members as $i => $value1) {
foreach($checkedOnline as $ii => $value2){
if($value1 == $value2){
unset($members[$i]);
}
}
}
foreach ($members as $i => $value) {
echo '<div class="stream_main">
<div class="stream_ thumb">
<img class="thumb_bg" src="/twitchchannelswitcher/images/offline_thumb.png" width="188" height="113"/>
</div>
<div class="stream_title">
<a href="?channel='.$value.'"> <h3>'.$value.'</h3> </a>
</div>
<div class="stream_info">
 <img src="/twitchchannelswitcher/images/offline.png"> Offline </br>
</div>
</div>';
}
?>
</div>
<div class = "footer">
<p> TwitchList (C)2013 created by Cees Middel for www.maegis.net </p>
</div>
</body>
</html>
Category Forum
Modifications and Requests - 8Labels
None yet
Statistics
2 participants
Notifications
You are not receiving notifications from this thread.
Related Questions