"240x192","2" => "382x288","3" => "780x585");
$config['vlc_wan_streamtype'] = "http";
//$action = $_GET['action']; //REMOVED
if (isset($_GET['action'])) { $action = $_GET['action']; } else { $action=""; }//ADDED
$i=0;
//$serverOS = php_uname(s); //REMOVED
$serverOS = php_uname(); //ADDED
include('settings.php');
/////////////////////////////////////////////////////////////////////////////////////
echo"
Dreambox-ReStream by M4RTiN
";
function xml2array($text)
{
$reg_exp = '/<(\w+)[^>]*>(.*?)<\/\\1>/s';
preg_match_all($reg_exp, $text, $match);
foreach ($match[1] as $key=>$val)
{
if ( preg_match($reg_exp, $match[2][$key]) )
{
$array[$val][] = xml2array($match[2][$key]);
}
else
{
$array[$val] = $match[2][$key];
}
}
return $array;
}
if($action=="changestream") {
///////////////////////////////////////////////////////////////////////////////
// Main prepare functions
$selected_vlc_dimensions = $_POST['selected_vlc_dimensions'];
$selected_vlc_video = $_POST['selected_vlc_video'];
$selected_vlc_audio_codec = $_POST['selected_vlc_audio_codec'];
$dbid = $_POST['dbid'];
$channel = $_POST['channel'];
$bouqet = $_POST['bouqet'];
foreach ($config['vlc_dimensions'] as $key => $value) {
if($key==$selected_vlc_dimensions) { $vlc_dimensions = $value; }
}
$vlc_dimensions = explode("x",$vlc_dimensions);
if($config[$dbid]['dreambox_enigma_version']=="1") {
///////////////////////////////////////////////////////////////////////////////
// Zap enigma 1 to the right channel
$zap_url = "http://". $config[$dbid]['dreamboxip'] . "/cgi-bin/zapTo?path=". $channel ."&curBouquet=0&curChannel=0";
$zaphandle = fopen($zap_url, "r");
//fclose($zaphandle);
sleep(1);
///////////////////////////////////////////////////////////////////////////////
// restart the dreamstream script for enigma 1 source
$raw_url = "http://". $config[$dbid]['dreamboxip'] ."/video.m3u";
$url_file = file_get_contents($raw_url);
// if ($serverOS=="Windows") { //REMOVED
if (strtoupper(substr($serverOS, 0, 3)) === "WIN") { //ADDED
// Windows server
// But you need to download this one: http://www.microsoft.com/technet/sysinternals/utilities/pskill.mspx
// exec("c:\PsTools\pskill.exe vlc.exe"); //REMOVED Crashes script
/*
$startcommand = "C:\Progra~1\VideoLAN\VLC\vlc.exe -I http $url_file ";
$startcommand .= ":sout=\"#transcode{acodec=". $selected_vlc_audio_codec .",vcodec=DIV3,ab=". $config['vlc_audio'] .",vb=". $selected_vlc_video .",scale=". $config['vlc_scale'] .",deinterlace,fps=15,channels=". $config['vlc_channel'] .",width=". $vlc_dimensions['0'] .",height=". $vlc_dimensions['1'] ."}";
$startcommand .= ":duplicate{dst=std{access=http,mux=ts,dst=". $config['vlc_lan_hostnameip'] .":". $config['vlc_lan_streamingport'] ."}}\" "; //ADDED
$startcommand .= " >>/dev/null 2>>/dev/null &";
REMOVED Does not work for Windows*/
$startcommand = "C:\Progra~1\VideoLAN\VLC\vlc.exe -vvv $url_file --sout #transcode{vcodec=DIV3,vb=". $selected_vlc_video .",scale=". $config['vlc_scale'] .",acodec=". $selected_vlc_audio_codec .",ab=". $config['vlc_audio'] .",channels=". $config['vlc_channel'] ."}:duplicate{dst=standard{access=http,mux=ts,dst=". $config['vlc_lan_hostnameip'] .":". $config['vlc_lan_streamingport'] ."}}"; //ADDED TESTING... the vvv option sends info to error.log
shell_exec($startcommand);
echo"
Debug: $startcommand";
} else {
// Linux or OSX
$killcommand = "/usr/bin/sudo -u ". $config['unix_user'] . " killall -Iq vlc";
shell_exec($killcommand);
$startcommand = "/usr/bin/sudo -u ". $config['unix_user'] . " /usr/bin/vlc -I http $url_file ";
$startcommand .= ":sout=\"#transcode{acodec=". $selected_vlc_audio_codec .",vcodec=DIV3,ab=". $config['vlc_audio'] .",vb=". $selected_vlc_video .",scale=". $config['vlc_scale'] .",deinterlace,fps=15,channels=". $config['vlc_channel'] .",width=". $vlc_dimensions['0'] .",height=". $vlc_dimensions['1'] ."}";
$startcommand .= ":std{access=http,mux=ts,url=". $config['vlc_lan_hostnameip'] .":". $config['vlc_lan_streamingport'] ."}\" ";
$startcommand .= " >>/dev/null 2>>/dev/null &";
shell_exec($startcommand);
echo"
Debug: $startcommand";
}
} elseif($config[$dbid]['dreambox_enigma_version']=="2") {
///////////////////////////////////////////////////////////////////////////////
// restart the dreamstream script for enigma 2 source
$raw_url = "http://". $config[$dbid]['dreamboxip'] ."/web/stream.m3u?ref=". $channel;
$url_file = file_get_contents($raw_url);
$startcommand = "/usr/bin/sudo -u ". $config['unix_user'] . " /usr/bin/vlc -I http $url_file "; //`/usr/bin/links -dump http://". $config[$dbid]['dreamboxip'] ."/video.m3u`
$startcommand .= ":sout=\"#transcode{acodec=". $selected_vlc_audio_codec .",vcodec=DIV3,ab=". $config['vlc_audio'] .",vb=". $selected_vlc_video .",scale=". $config['vlc_scale'] .",deinterlace,fps=15,channels=". $config['vlc_channel'] .",width=". $vlc_dimensions['0'] .",height=". $vlc_dimensions['1'] ."}";
$startcommand .= ":std{access=http,mux=ts,url=". $config['vlc_lan_hostnameip'] .":". $config['vlc_lan_streamingport'] ."}\" ";
$startcommand .= " >>/dev/null 2>>/dev/null &";
shell_exec($startcommand);
echo"
Debug: $startcommand";
}
//////////////////////////////////////////////////
// We are done, please goto the viewing screen!
echo"";
} else {
//$dbid = $_GET['dbid']; //REMOVED
if (isset($_GET['dbid'])) { $dbid = $_GET['dbid']; } else { $dbid="0"; }//ADDED
//$selected_vlc_dimensions = $_GET['selected_vlc_dimensions'];
if (isset($_GET['selected_vlc_dimensions'])) {$selected_vlc_dimensions = $_GET['selected_vlc_dimensions'];} else { $selected_vlc_dimensions=2; } //ADDED
//$autoplay = $_GET['autoplay'];
if (isset($_GET['autoplay'])) {$autoplay = $_GET['autoplay'];} else { $autoplay="yes"; } //ADDED
//$selected_vlc_video = $_GET['selected_vlc_video'];
if (isset($_GET['selected_vlc_video'])) {$selected_vlc_video = $_GET['selected_vlc_video'];}else { $selected_vlc_video="150"; } //ADDED
if (isset($_GET['selected_vlc_video_codec'])) {$selected_vlc_video_codec = $_GET['selected_vlc_video_codec'];} else { $selected_vlc_video_codec="DIV3"; } //ADDED
//$selected_vlc_audio_codec = $_GET['selected_vlc_audio_codec'];
if (isset($_GET['selected_vlc_audio_codec'])) {$selected_vlc_audio_codec = $_GET['selected_vlc_audio_codec'];} else { $selected_vlc_audio_codec="mpga"; } //ADDED
//$channel = $_GET['channel'];
if (isset($_GET['channel'])) {$channel = $_GET['channel'];} else { $channel=0; } //ADDED
//$bouqet = $_GET['bouqet'];
if (isset($_GET['bouqet'])) {$bouqet = $_GET['bouqet'];} else { $bouqet=0; } //ADDED
// Set some defaults
//if($dbid=="") { $dbid="0"; } //REMOVED
//if($autoplay=="") { $autoplay="yes"; } //REMOVED
//if($bouqet=="") { $bouqet=8; } //REMOVED
//if($selected_vlc_audio_codec=="") { $selected_vlc_audio_codec="mpga"; } //REMOVED
//if($selected_vlc_video=="") { $selected_vlc_video="150"; } //REMOVED
echo"Dreambox-ReStream V1.00 for Dreambox: ". $config[$dbid]["dreamboxname"] . "
";
echo"
";
echo"
";
echo"
";
if($config[$dbid]['dreambox_enigma_version']=="1") {
$channel_url = "http://". $config[$dbid]['dreamboxip'] ."/body?mode=zap&zapmode=0&zapsubmode=4";
$channel_url_linenumber=0;
echo"";
} elseif($config[$dbid]['dreambox_enigma_version']=="2") {
echo"";
//echo"";
//print_r($channels);
//echo"
";
} // enigma version checker for channel loading
/////////////////////////////////////////////////////////////////////////////////
// Check if VLC is running
//if ($serverOS!="Windows") { //REMOVED
if (strtoupper(substr($serverOS, 0, 3)) !== "WIN") { //ADDED
$checkcommand = "/usr/bin/sudo -u ". $config['unix_user'] . " ps -ef | grep -v grep | grep \"vlc\"";
$vlcprocess = shell_exec($checkcommand);
$netstatcommand = "netstat -a | grep ". $config['vlc_lan_streamingport'];
$netstat = shell_exec($netstatcommand);
echo" |
VLC process information ";
if($vlcprocess!="") { echo"$vlcprocess"; } else { echo"VLC IS NOT RUNNING!, CHECK SUDO PERMISIONS!";}
echo" \n Listeners: ";
if($netstat!="") { echo"$netstat"; } else { echo"None..."; }
echo" |
";
if($vlcprocess=="") { echo""; }
}
} // main action
echo"";
?>