summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rwxr-xr-xincludes/inc_auth.php32
-rwxr-xr-xincludes/inc_cat.php17
-rwxr-xr-xincludes/inc_chan.php24
-rwxr-xr-xincludes/inc_home.php20
-rwxr-xr-xincludes/inc_media.php16
-rwxr-xr-xincludes/inc_rec.php62
-rwxr-xr-xincludes/inc_stream.php177
-rwxr-xr-xincludes/inc_streaminfo.php61
-rwxr-xr-xincludes/inc_svdrp.php446
-rwxr-xr-xincludes/inc_vdr.php204
-rwxr-xr-xincludes/include.php112
11 files changed, 1171 insertions, 0 deletions
diff --git a/includes/inc_auth.php b/includes/inc_auth.php
new file mode 100755
index 0000000..92f0fc8
--- /dev/null
+++ b/includes/inc_auth.php
@@ -0,0 +1,32 @@
+<?php
+
+global $user, $pass;
+
+session_start();
+
+if (isset($_COOKIE['istream']))
+{
+ $authorized=true;
+}
+
+# checkup login and password
+if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW']))
+{
+ if (($user == $_SERVER['PHP_AUTH_USER']) && ($pass == ($_SERVER['PHP_AUTH_PW'])) && isset($_SESSION['auth']))
+ {
+ $authorized = true;
+ setcookie ("istream", "true", time()+60*60*24*30);
+ }
+}
+
+# login
+if (!$authorized)
+{
+ header('WWW-Authenticate: Basic Realm="Login please"');
+ header('HTTP/1.0 401 Unauthorized');
+ $_SESSION['auth'] = true;
+ echo "Login";
+ exit;
+}
+
+?>
diff --git a/includes/inc_cat.php b/includes/inc_cat.php
new file mode 100755
index 0000000..0b107d3
--- /dev/null
+++ b/includes/inc_cat.php
@@ -0,0 +1,17 @@
+<?php
+
+print "<body onorientationchange=\"updateOrientation();\" onload=\"updateOrientation();\">\r\n";
+print "<div id=\"topbar\" class=\"transparent\">\r\n";
+print "<div id=\"leftnav\">\r\n";
+print "<a href=\"index.php\"><img alt=\"home\" src=\"images/home.png\" /></a></div>\r\n";
+print "<div id=\"title\">iStreamdev</div>\r\n";
+print "</div>\r\n";
+print "<div id=\"content\">\r\n";
+print " <span class=\"graytitle\">Category</span>\r\n";
+print " <ul class=\"pageitem\">\r\n";
+
+vdrlistcategories();
+
+print " </ul>";
+print "</div>\r\n";
+?>
diff --git a/includes/inc_chan.php b/includes/inc_chan.php
new file mode 100755
index 0000000..02cb80e
--- /dev/null
+++ b/includes/inc_chan.php
@@ -0,0 +1,24 @@
+<?php
+
+$cat = $_REQUEST['cat'];
+
+$_SESSION['currentcat'] = $cat;
+
+print "<body class=\"list\" onorientationchange=\"updateOrientation();\" onload=\"updateOrientation();\">\r\n";
+print "<div id=\"topbar\" class=\"transparent\">\r\n";
+
+print "<div id=\"leftnav\">\r\n";
+print "<a href=\"javascript:sendForm('getback')\">Back</a></div>\r\n";
+print "<div id=\"rightnav\">\r\n";
+print "<a href=\"index.php\"><img alt=\"home\" src=\"images/home.png\" /></a></div>\r\n";
+print "<div id=\"title\">iStreamdev</div>\r\n";
+print "</div>\r\n";
+print "<div id=\"content\">\r\n";
+print " <ul><li class=\"title\">Channels</li>\r\n";
+
+vdrlistchannels($cat);
+
+print " </ul>";
+print "</div>\r\n";
+print " <form name=\"getback\" id=\"getback\" method=\"post\" action=\"index.php\"><input name=\"action\" type=\"hidden\" id=\"action\" value=\"listcategory\" /></form>\r\n";
+?>
diff --git a/includes/inc_home.php b/includes/inc_home.php
new file mode 100755
index 0000000..8fcf513
--- /dev/null
+++ b/includes/inc_home.php
@@ -0,0 +1,20 @@
+<?php
+
+global $vdrrecpath;
+
+print "<body onorientationchange=\"updateOrientation();\" onload=\"updateOrientation();\">\r\n";
+print "<div id=\"topbar\" class=\"transparent\">\r\n";
+print "<div id=\"title\">iStreamdev</div>\r\n";
+print "</div>\r\n";
+print "<div id=\"content\">\r\n";
+print " <span class=\"graytitle\">Home</span>\r\n";
+print " <ul class=\"pageitem\">\r\n";
+print " <li class=\"menu\"><a href=\"javascript:sendForm('channels');\"><img src=\"images/pictos/tv.png\" /><span class=\"name\">Channels</span><span class=\"arrow\"></span></a></li>\r\n";
+print " <form name=\"channels\" id=\"channels\" method=\"post\" action=\"index.php\"><input name=\"action\" type=\"hidden\" id=\"action\" value=\"listcategory\" /></form>\r\n";
+print " <li class=\"menu\"><a class=\"noeffect\" href=\"javascript:sendForm('recordings');\"><img src=\"images/pictos/record.png\" /><span class=\"name\">Recordings</span><span class=\"arrow\"></span></a></li>\r\n";
+print " <form name=\"recordings\" id=\"recordings\" method=\"post\" action=\"index.php\"><input name=\"action\" type=\"hidden\" id=\"action\" value=\"recordings\" /><input name=\"dir\" type=\"hidden\" id=\"dir\" value=\"{$vdrrecpath}\" /></form>\r\n";
+print " <li class=\"menu\"><a class=\"noeffect\" href=\"javascript:sendForm('media');\"><img src=\"images/pictos/media.png\" /><span class=\"name\">Medias</span><span class=\"arrow\"></span></a></li>\r\n";
+print " <form name=\"media\" id=\"media\" method=\"post\" action=\"index.php\"><input name=\"action\" type=\"hidden\" id=\"action\" value=\"media\" /></form>\r\n";
+print " </ul>";
+print "</div>";
+?>
diff --git a/includes/inc_media.php b/includes/inc_media.php
new file mode 100755
index 0000000..b946e09
--- /dev/null
+++ b/includes/inc_media.php
@@ -0,0 +1,16 @@
+<?php
+
+print "<body onorientationchange=\"updateOrientation();\" onload=\"updateOrientation();\">\r\n";
+print "<div id=\"topbar\" class=\"transparent\">\r\n";
+print "<div id=\"leftnav\">\r\n";
+print "<a href=\"index.php\"><img alt=\"home\" src=\"images/home.png\" /></a></div>\r\n";
+print "<div id=\"title\">iStreamdev</div>\r\n";
+print "</div>\r\n";
+print "<div id=\"content\">\r\n";
+print " <span class=\"graytitle\">Media</span>\r\n";
+print " <ul class=\"pageitem\">";
+print " <li class=\"textbox\"><span class=\"header\">Incoming feature</span";
+print " <p>To do...</p></li>";
+print "</div>\r\n";
+
+?>
diff --git a/includes/inc_rec.php b/includes/inc_rec.php
new file mode 100755
index 0000000..42ab455
--- /dev/null
+++ b/includes/inc_rec.php
@@ -0,0 +1,62 @@
+<?php
+
+global $vdrrecpath;
+
+$dir = $_REQUEST['dir'];
+if ($dir == "")
+ $dir = $vdrrecpath;
+
+// Get current subdir
+$subdir = preg_replace("'" .quotemeta($vdrrecpath) ."'", '', $dir);
+
+print "<body onorientationchange=\"updateOrientation();\" onload=\"updateOrientation();\">\r\n";
+print "<div id=\"topbar\" class=\"transparent\">\r\n";
+print "<div id=\"leftnav\">\r\n";
+if ($dir == $vdrrecpath)
+ print "<a href=\"index.php\"><img alt=\"home\" src=\"images/home.png\" /></a></div>\r\n";
+else
+ print "<a href=\"javascript:sendForm('getback')\">Back</a></div>\r\n";
+
+print "<div id=\"title\">iStreamdev</div>\r\n";
+print "</div>\r\n";
+print "<div id=\"content\">\r\n";
+print " <span class=\"graytitle\">Recordings</span>\r\n";
+print "<br>";
+print " <span class=\"graytitle\">{$subdir}</span>\r\n";
+print " <ul class=\"pageitem\">";
+
+$dir_handle = @opendir($dir) or die("Unable to open $dir");
+
+while ($recname = readdir($dir_handle))
+{
+ if($recname == "." || $recname == ".." || $recname == "epg.data" || $recname == 'lost+found')
+ continue;
+
+ $recname2=addslashes($recname);
+
+ if (strstr($recname, ".rec") == ".rec")
+ {
+ print "<li class=\"menu\"><a class=\"noeffect\" href=\"javascript:sendForm('$recname2');\"><span class=\"name\">$recname</span><span class=\"arrow\"></span></a></li>\r\n";
+ print "<form name=\"$recname\" id=\"$recname\" method=\"post\" action=\"index.php\">";
+ print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"stream\"/>";
+ print " <input name=\"type\" type=\"hidden\" id=\"type\" value=2 />";
+ print " <input name=\"name\" type=\"hidden\" id=\"name\" value=\"{$subdir}/{$recname}\" />";
+ print "</form>\r\n";
+ }
+ else
+ {
+ print "<li class=\"menu\"><a class=\"noeffect\" href=\"javascript:sendForm('$recname2');\"><span class=\"name\">$recname</span><span class=\"arrow\"></span></a></li>\r\n";
+ print "<form name=\"$recname\" id=\"$recname\" method=\"post\" action=\"index.php\">";
+ print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"recordings\"/>";
+ print " <input name=\"dir\" type=\"hidden\" id=\"dir\" value=\"{$dir}/{$recname}\" />";
+ print "</form>\r\n";
+ }
+}
+
+$updir = dirname($dir);
+
+print "<form name=\"getback\" id=\"getback\" method=\"post\" action=\"index.php\"><input name=\"action\" type=\"hidden\" id=\"action\" value=\"recordings\"/><input name=\"dir\" type=\"hidden\" id=\"dir\" value=\"{$updir}/\" /></form>\r\n";
+closedir($dir_handle);
+
+print "</ul></div>\r\n";
+?>
diff --git a/includes/inc_stream.php b/includes/inc_stream.php
new file mode 100755
index 0000000..84d621f
--- /dev/null
+++ b/includes/inc_stream.php
@@ -0,0 +1,177 @@
+<?php
+
+global $vdrstreamdev, $vdrrecpath, $quality;
+
+// Check if we are running
+if (infostreamexist())
+{
+ // Get current stream info
+ list($type, $realname, $title, $desc, $mode, $category, $url) = readinfostream();
+
+ print "<body onorientationchange=\"updateOrientation();\" onload=\"ajax();\">\r\n";
+
+ print "<div id=\"topbar\" class=\"transparent\">\r\n";
+ print "<div id=\"leftnav\">\r\n";
+ print "<a href=\"javascript:sendForm('stopstream');\">Stop Stream</a></div>\r\n";
+ print "<div id=\"title\">iStreamdev</div>\r\n";
+ print "</div>\r\n";
+
+ print "<div id=\"content\">\r\n";
+ print " <span class=\"graytitle\">Now streaming</span>\r\n";
+
+ // Print the right logo
+ print " <ul class=\"pageitem\">\r\n";
+ if ($type <= 2)
+ {
+ if (!file_exists('logos/'.$realname.'.png'))
+ print " <center><video id=\"videofeed\" poster=\"logos/nologo2.png\" width='80' height='80' /></center>\r\n";
+ else
+ print " <center><video id=\"videofeed\" poster=\"logos/{$realname}.png\" width='80' height='80' /></center>\r\n";
+ }
+ else
+ print " <center><video id=\"videofeed\" poster=\"logos/nologo2.png\" width='80' height='80' /></center>\r\n";
+ print " </ul>\r\n";
+
+ print " <ul class=\"pageitem\">\r\n";
+ print " <li class=\"textbox\"><span class=\"header\">{$realname}</span><p><strong>{$title}</strong>\r\n";
+ print " <br>{$desc}</p></li></ul>\r\n";
+
+ print " <ul class=\"pageitem\">\r\n";
+ print " <li id=\"modetext\" class=\"textbox\"><span class=\"header\">Mode</span>\r\n";
+ print " <p id='streamtitle'>{$mode}</p></li></ul>\r\n";
+
+ print " </div>\r\n";
+
+ print " <form name=\"stopstream\" id=\"stopstream\" method=\"post\" action=\"index.php\">";
+ print " <input name =\"action\" type=\"hidden\" id=\"action\" value=\"stopstream\" />";
+ switch ($type)
+ {
+ case 1:
+ print " <input name =\"actionafterstop\" type=\"hidden\" id=\"actionafterstop\" value=\"listchannels\" />";
+ print " <input name =\"cat\"type=\"hidden\" id=\"cat\" value=\"{$category}\" />";
+ break;
+ default:
+ case 2:
+ $dir = dirname($url);
+ print " <input name =\"actionafterstop\" type=\"hidden\" id=\"actionafterstop\" value=\"recordings\" />";
+ print " <input name =\"dir\"type=\"hidden\" id=\"dir\" value=\"{$dir}\" />";
+ break;
+ }
+ print " </form>\r\n";
+}
+else
+{
+ $category = $_SESSION['currentcat'];
+
+ $type = $_REQUEST['type'];
+ $name = $_REQUEST['name'];
+
+ switch ($type)
+ {
+ // Live TV
+ case 1:
+ list($title, $desc, $realname) = vdrgetinfostream($name, 1);
+ $channum = vdrgetchannum($realname);
+ break;
+ // Recording
+ case 2:
+ list($title, $desc, $realname) = vdrgetinfostream($name, 0);
+ break;
+ case 3:
+ default:
+ $realname = "";
+ $title = "";
+ $desc = "";
+ $channame = $name;
+ }
+
+ print "<body onorientationchange=\"updateOrientation();\" onload=\"updateOrientation();\">\r\n";
+
+ print "<div id=\"topbar\" class=\"transparent\">\r\n";
+ print "<div id=\"leftnav\">\r\n";
+
+ print "<a href=\"javascript:sendForm('getback')\">Back</a></div>\r\n";
+ print "<div id=\"rightnav\">\r\n";
+ print "<a href=\"index.php\"><img alt=\"home\" src=\"images/home.png\" /></a></div>\r\n";
+
+ print "<div id=\"title\">iStreamdev</div>\r\n";
+ print "</div>\r\n";
+
+ print "<div id=\"content\">\r\n";
+
+ print " <span class=\"graytitle\">Select stream mode</span>\r\n";
+
+ print " <ul class=\"pageitem\">\r\n";
+
+ // Print the right logo
+ if ($type <= 2)
+ {
+ if (!file_exists('logos/'.$realname.'.png'))
+ print " <center><img src=\"logos/nologo2.png\"></img></center>\r\n";
+ else
+ print " <center><img src=\"logos/{$realname}.png\"></img></center>\r\n";
+ }
+ else
+ print " <center><img src=\"logos/nologo2.png\"></img></center>\r\n";
+
+ print " </ul>\r\n";
+
+ // Check if running to display the start buttons
+ print " <div id=\"tributton\">\r\n";
+ print " <div class=\"links\">\r\n";
+
+ foreach ($quality as $qname => $qparams)
+ print "<a href=\"javascript:sendForm('$qname')\">{$qname}</a>";
+ print "\r\n";
+
+ print " </div></div>\r\n";
+
+ print " <ul class=\"pageitem\">\r\n";
+ print " <li class=\"textbox\"><span class=\"header\">{$realname}</span><p><strong>{$title}</strong>\r\n";
+ print " <br>{$desc}</p></li></ul>\r\n";
+
+ print " </div>\r\n";
+
+ foreach ($quality as $qname => $qparams)
+ {
+ print " <form name=\"{$qname}\" id=\"{$qname}\" method=\"post\" action=\"index.php\">\r\n";
+ print " <input name =\"action\" type=\"hidden\" id=\"action\" value=\"startstream\" />\r\n";
+ print " <input name =\"type\" type=\"hidden\" id=\"type\" value={$type} />\r\n";
+ print " <input name =\"name\" type=\"hidden\" id=\"name\" value=\"{$realname}\" />\r\n";
+ print " <input name =\"title\" type=\"hidden\" id=\"title\" value=\"{$title}\" />\r\n";
+ print " <input name =\"desc\" type=\"hidden\" id=\"desc\" value=\"{$desc}\" />\r\n";
+ print " <input name =\"qname\" type=\"hidden\" id=\"qname\" value=\"{$qname}\" />\r\n";
+ print " <input name =\"qparams\" type=\"hidden\" id=\"qparams\" value=\"{$qparams}\" />\r\n";
+ print " <input name =\"category\" type=\"hidden\" id=\"category\" value=\"{$category}\" />\r\n";
+ switch ($type)
+ {
+ case 1:
+ print " <input name =\"url\" type=\"hidden\" id=\"url\" value=\"{$vdrstreamdev}{$channum}\" />\r\n";
+ break;
+ case 2:
+ default:
+ print " <input name =\"url\" type=\"hidden\" id=\"url\" value=\"{$vdrrecpath}{$name}\" />\r\n";
+ break;
+ }
+ print " </form>";
+ }
+
+ print " <form name=\"getback\" id=\"getback\" method=\"post\" action=\"index.php\">";
+ switch ($type)
+ {
+ case 1:
+ print " <input name =\"action\" type=\"hidden\" id=\"action\" value=\"listchannels\" />";
+ print " <input name =\"cat\"type=\"hidden\" id=\"cat\" value=\"{$category}\" />";
+ break;
+ default:
+ case 2:
+ $dir = dirname($vdrrecpath .$name);
+ print " <input name =\"action\" type=\"hidden\" id=\"action\" value=\"recordings\" />";
+ print " <input name =\"dir\"type=\"hidden\" id=\"dir\" value=\"{$dir}\" />";
+ break;
+ }
+ print " </form>\r\n";
+
+}
+
+?>
diff --git a/includes/inc_streaminfo.php b/includes/inc_streaminfo.php
new file mode 100755
index 0000000..a45920c
--- /dev/null
+++ b/includes/inc_streaminfo.php
@@ -0,0 +1,61 @@
+<?php
+
+/*
+ Types:
+ 0 : Not running
+ 1 : VDR live
+ 2 : VDR recording
+ 3 : Media
+*/
+
+function writeinfostream($type=0, $name="", $title="", $desc="", $mode="", $category="", $url="")
+{
+ $infofile = fopen("ram/streaminfo", 'w');
+
+ fwrite($infofile, "type=" .$type ."\n");
+ fwrite($infofile, "name=" .$name ."\n");
+ fwrite($infofile, "title=" .$title ."\n");
+ fwrite($infofile, "desc=" .$desc ."\n");
+ fwrite($infofile, "mode=" .$mode ."\n");
+ fwrite($infofile, "category=" .$category ."\n");
+ fwrite($infofile, "url=" .$url ."\n");
+
+ fclose($infofile);
+}
+
+
+function readinfostream()
+{
+ $infofile = fopen("ram/streaminfo", 'r');
+ if (!$infofile)
+ return array(0, "", "", "", "");
+
+ while ($line = fgets($infofile, 1024))
+ {
+ if (!strncmp($line, "type=", strlen("type=")))
+ $type = substr($line, strlen("type="), -1);
+ else if (!strncmp($line, "name=", strlen("name=")))
+ $name = substr($line, strlen("name="), -1);
+ else if (!strncmp($line, "title=", strlen("title=")))
+ $title = substr($line, strlen("title="), -1);
+ else if (!strncmp($line, "desc=", strlen("desc=")))
+ $desc = substr($line, strlen("desc="), -1);
+ else if (!strncmp($line, "mode=", strlen("mode=")))
+ $mode = substr($line, strlen("mode="), -1);
+ else if (!strncmp($line, "category=", strlen("category=")))
+ $category = substr($line, strlen("category="), -1);
+ else if (!strncmp($line, "url=", strlen("url=")))
+ $url = substr($line, strlen("url="), -1);
+ }
+
+ fclose($infofile);
+
+ return array($type, $name, $title, $desc, $mode, $category, $url);
+}
+
+function infostreamexist()
+{
+ return file_exists("ram/streaminfo");
+}
+
+?>
diff --git a/includes/inc_svdrp.php b/includes/inc_svdrp.php
new file mode 100755
index 0000000..da83b49
--- /dev/null
+++ b/includes/inc_svdrp.php
@@ -0,0 +1,446 @@
+<?php
+
+// SVDRP is a class do communicate with a vdr via svdrp
+class SVDRP
+{
+ var $cfgServer;
+ var $cfgPort;
+ var $cfgTimeOut;
+
+ var $handle;
+ var $debug;
+
+ function SVDRP($server = "localhost", $port=2001, $timeout = 30, $debug = 0)
+ {
+ $this->cfgServer = $server;
+ $this->cfgPort = $port;
+ $this->cfgTimeOut = $timeout;
+ $this->debug = $debug;
+ $this->handle = 0;
+ }
+
+ function DebugMessage($msg)
+ {
+ if($this->debug) echo ($msg);
+ }
+
+ function Connect()
+ {
+ if($this->handle) Disconnect();
+ $errno = 0;
+ $errstr = "";
+ $this->handle = fsockopen($this->cfgServer, $this->cfgPort, &$errno, &$errstr, $this->cfgTimeOut);
+
+ if(!$this->handle)
+ {
+ $this->DebugMessage("error $errno: $errstr");
+ return false;
+ }
+
+ $this->DebugMessage("handle: $this->handle<br>\n");
+
+
+ $input = fgets($this->handle,128);
+
+ if(!preg_match("/^220 /", $input) || $input == "")
+ {
+ $this->DebugMessage("wrong welcome message: '$input'<br>\n");
+ $this->Disconnect();
+ return false;
+ }
+
+
+ $this->DebugMessage("Welcome message: $input<br><br>\n");
+
+ return true;
+ }
+
+ function Command($cmd)
+ {
+ if(!$this->handle) return false;
+
+ $ret = array();
+
+ $this->DebugMessage("Kommando $cmd<br><pr"."e>");
+ fputs($this->handle, $cmd . "\n");
+ $s = "";
+ $nline = 0;
+ while($s .= fgets($this->handle,4096))
+ {
+ $nline++;
+
+ $this->DebugMessage($s);
+ if(!preg_match("/^(\\d{3})([ -])(.*)$/", $s, $data))
+ {
+ continue;
+ }
+
+
+
+
+ $number = $data[1];
+ // TODO: Fehlernummer bearbeiten
+ $ret[] = $data[3];
+ if($data[2] != "-" && $nline == 1) $ret = $data[3] ;
+ if($data[2] != "-") break;
+ $s = "";
+
+ }
+
+ $this->DebugMessage("</pr"."e>");
+ return $ret;
+ }
+
+ function ListChannels($numberorname="")
+ {
+ if(!$this->handle) return false;
+ $channels = array();
+ $lines = $this->Command("LSTC$numberorname");
+ if(!$lines) return false;
+ foreach($lines as $a => $l)
+ {
+ $a = split(":", $l);
+ $name = $a[0];
+ $freq = $a[1];
+ $b = split(";", $name);
+ $name = $b[0];
+ if(!isset($b[1])) $b[1] = $name;
+ $group = $b[1];
+
+
+ $c["name"] = $name;
+ $c["group"] = $group;
+ $c["frequency"] = $freq;
+
+ $channels[] = $c;
+
+
+ }
+ return $channels;
+ }
+
+ function Help()
+ {
+ return $this->Command("HELP");
+ }
+ function Disconnect()
+ {
+ if(!$this->handle) return;
+ $this->Command("QUIT");
+
+ fclose($this->handle);
+ $this->handle = 0;
+ $this->DebugMessage("disconnected");
+ }
+ function ClearEpg()
+ {
+ if(!$this->handle) return false;
+ $this->Command("CLRE");
+ return true;
+ }
+ function SwitchUp()
+ {
+ if(!$this->handle) return false;
+ $this->Command("CHAN +");
+ return true;
+ }
+ function SwitchDown()
+ {
+ if(!$this->handle) return false;
+ $this->Command("CHAN -");
+ return true;
+ }
+ function SwitchChannel($channel)
+ {
+ if(!$this->handle) return false;
+ $this->Command("CHAN $channel");
+ return true;
+ }
+ function DeleteChannel($id)
+ {
+ if(!$this->handle) return false;
+ $this->Command("DELC $id");
+ return true;
+ }
+ function DeleteRecord($id)
+ {
+ if(!$this->handle) return false;
+ $this->Command("DELR $id");
+ return true;
+ }
+
+ function GrabImage($filename, $type="jpeg", $quality="", $width="", $height)
+ {
+ if(!$this->handle) return false;
+ $this->Command("GRAB $filename $type $quality $width $height");
+ return true;
+ }
+ function HitKey($key)
+ {
+ if(!$this->handle) return false;
+ $this->Command("HITK $key");
+ return true;
+ }
+ function PowerOff()
+ {
+ if(!$this->handle) return false;
+ $this->Command("HITK Power");
+ return true;
+
+ }
+ function GetKeys()
+ {
+ if(!$this->handle) return false;
+
+ $lines = $this->Command("HITK");
+ $keys = array();
+ foreach($lines as $l)
+ {
+ if(!preg_match("/^ {4}(.*)$/", $l, $m)) continue;
+ $keys[] = $m[1];
+ }
+
+ return $keys;
+ }
+ function ListEPG($pStrChannel="", $pStrTime="")
+ {
+ if(!$this->handle) return false;
+ $lines = $this->Command("LSTE");
+
+ $epg = array ();
+ $channel = array();
+ $event = array();
+
+ $channelname = "";
+ foreach($lines as $l)
+ {
+ preg_match("/^(.)\\s*(.*)$/", $l, $m);
+ $type = $m[1];
+ $text = $m[2];
+ switch($type)
+ {
+ case 'C': // Channel
+ list( $channeldata, $channelname ) = explode( ' ', $text, 2 );
+
+ break;
+ case 'E': // new Event
+ sscanf($text, "%u %ld %d %X", $event["EventID"], $event["StartTime"], $event["Duration"], $event["TableID"]);
+
+ break;
+ case 'T': // Title
+ $event["Title"] = $text;
+ break;
+ case 'S': // Short text
+ $event["Shottext"] = $text;
+ break;
+ case 'D': // Description
+ $event["Desc"] = $text;
+ break;
+ case 'V': // VPS
+ $event["VPS"] = $text;
+ break;
+ case 'e': // Event end
+ if ((trim($pStrTime) != '') && (( $event['StartTime'] > $pStrTime ) || ($event['StartTime'] + $event["Duration"] < $pStrTime)))
+ continue;
+
+ $channel[] = $event;
+ $event = array();
+
+ break;
+ case 'c': // Channel end
+ if ((trim($pStrChannel) != '') && ($channelname != $pStrChannel))
+ continue;
+
+ $epg[$channelname] = $channel;
+ $channel = array();
+
+ break;
+ }
+
+ }
+ if ((trim($pStrTime) == '') || (( $event['StartTime'] < $pStrTime ) && ($event['StartTime'] + $event["Duration"] > $pStrTime)))
+ $channel[] = $event;
+
+ if ((trim($pStrChannel) != '') || ($channelname == $pStrChannel))
+ $epg[$channelname] = $channel;
+
+ return $epg;
+ }
+
+ function Message($msg)
+ {
+ if(!$this->handle) return false;
+ $this->Command("MESG $msg");
+ return true;
+ }
+
+
+ // Volume commands
+ function ToggleMute()
+ {
+ if(!$this->handle) return false;
+ $this->Command("VOLU mute");
+ return true;
+ }
+ function VolumeUp()
+ {
+ if(!$this->handle) return false;
+ $this->Command("VOLU +");
+ return true;
+ }
+ function VolumeDown()
+ {
+ if(!$this->handle) return false;
+ $this->Command("VOLU -");
+ return true;
+ }
+ function SetVolume($v)
+ {
+ if(!$this->handle) return false;
+ $this->Command("VOLU $v");
+ return true;
+ }
+ function GetVolume()
+ {
+ if(!$this->handle) return false;
+ $v = $this->Command("VOLU");
+ if($v == "Audio is mute") return 0;
+ if(!preg_match("/Audio volume is (.*)/", $v, $m)) return false;
+
+ return $m[1];
+ }
+ function GetDiskStat()
+ {
+ if(!$this->handle) return false;
+ $stat = $this->Command("STAT DISK");
+ sscanf($stat, "%dMB %dMB %d%%", $FreeMUsedMB, $FreeMB, $Percent);
+ $ret["FreeMB + UsedMB"] = $FreeMUsedMB;
+ $ret["FreeMB"] = $FreeMB;
+ $ret["UsedMB"] = $FreeMUsedMB - $FreeMB;
+ $ret["Percent"] = $Percent;
+ return $ret;
+ }
+ function StartScan()
+ {
+ if(!$this->handle) return false;
+ $this->Command("SCAN");
+ return true;
+ }
+ function MoveChannel($number, $to)
+ {
+ if(!$this->handle) return false;
+ $this->Command("MOVC $number $to");
+ return true;
+
+ }
+
+ function DeleteTimer($id)
+ {
+ if(!$this->handle) return false;
+ $this->Command("DELT $id");
+ return true;
+ }
+
+ function MoveTimer($number, $to)
+ {
+ if(!$this->handle) return false;
+ $this->Command("MOVT $number $to");
+ return true;
+ }
+
+ function TimerOnOff($n, $state = "on")
+ {
+ if(!$this->handle) return false;
+ //if($state == "1") $state = "on";
+ //if($state == "0") $state = "off";
+ //if($state == false) $state = "off";
+ // if($state == true) $state = "on";
+ switch($state)
+ {
+ case false:
+ case "off":
+ case "0":
+ $state = "off";
+ break;
+ default:
+ $state = "on";
+ break;
+ }
+
+ return $this->Command("MODT $n $state");
+ }
+
+ function ListTimers()
+ {
+
+ }
+
+ function ShowMessage($msg = "")
+ {
+ if(!$this->handle) return false;
+ return $this->Command("MESG $msg");
+ }
+
+ function ListRecords()
+ {
+ if(!$this->handle) return false;
+
+ $lines = $this->Command("LSTR");
+ $records = array();
+ foreach($lines as $l)
+ {
+
+ if(!preg_match("/^(\\d)\s(\\d*)\\.(\\d*)\\.(\\d*) (\\d*)\\:(\\d*).\s(.*)$/", $l, $m)) continue;
+ $id = $m[1];
+ $m["id"] = $m[1];
+ $m["day"] = $m[2];
+ $m["month"] = $m[3];
+ $m["year"] = $m[4];
+ $m["hour"] = $m[5];
+ $m["minute"] = $m[6];
+ $m["desc"] = $m[7];
+
+ $records[$id] = $m;
+ }
+
+ return $records;
+
+ }
+
+ // TODO: perhaps better implementation
+ function ListRecord($n)
+ {
+ if(!$this->handle) return false;
+ $m = $this->Command("LSTR $n");
+ return $m[0];
+ }
+
+
+
+ //TODO: Implement following commands:
+ /*
+
+
+ LSTT MODT NEWT UPDT
+ MODC NEWC
+ NEXT
+ PUTE
+
+ */
+}
+
+// Small Example
+/*
+echo "<pr"."e>";
+$a = new SVDRP();
+$a->Connect();
+print_r($a->Help());
+print_r($a->ListChannels());
+$a->GetKeys();
+print_r($a->GetVolume());
+print_r($a->GetDiskStat());
+$a->Disconnect();
+*/
+?>
+
+
diff --git a/includes/inc_vdr.php b/includes/inc_vdr.php
new file mode 100755
index 0000000..d36c8cc
--- /dev/null
+++ b/includes/inc_vdr.php
@@ -0,0 +1,204 @@
+<?php
+include ('includes/inc_svdrp.php');
+
+function vdrgetinfostream($stream = "NULL", $ischan = 1)
+{
+ global $allepg, $allepgfilled, $svdrpip, $svdrpport, $vdrrecpath;
+
+ if ($ischan)
+ {
+ // Fill epg if not yet done
+ if ($allepgfilled == 0)
+ {
+ $svdrp = new SVDRP($svdrpip, $svdrpport);
+ $svdrp->Connect();
+ $allepg = $svdrp->Command("LSTE NOW");
+ $svdrp->Disconnect();
+ $allepgfilled = 1;
+ }
+
+ $channame = $stream;
+ }
+ else
+ {
+ $infofile = $vdrrecpath .$stream ."/info";
+ if (file_exists($infofile))
+ $info= file_get_contents($infofile);
+ else
+ {
+ $infofile = $vdrrecpath .$stream ."/info.vdr";
+ if (file_exists($infofile))
+ $info= file_get_contents($infofile);
+ else
+ $info="";
+ }
+
+ $allepg = explode("\n", $info);
+ }
+
+ if ($ischan)
+ $chanfound = 0;
+ else
+ $chanfound = 1;
+ $epgtitlefound = 0;
+
+ $epgtitle="";
+ $epgdesc="";
+
+ // For all epg
+ $count = count($allepg);
+ for ($i = 0; $i < $count; $i++)
+ {
+ // Find the right chan (take the first one)
+ if ($chanfound == 0)
+ {
+ if (strstr($allepg[$i], $stream) == $stream)
+ $chanfound = 1;
+ }
+ else
+ {
+ // Now find T or C
+ if(ereg("^C", $allepg[$i]))
+ {
+ // Check if it is our chan too, else search again
+ if ($ischan)
+ {
+ if(!ereg("$stream$", $allepg[$i]))
+ {
+ $chanfound = 0;
+ continue;
+ }
+ }
+ else
+ {
+ $channame = substr($allepg[$i], 2);
+ $channames = explode(" ", $channame);
+ $channame = substr($channame, strlen($channames[0]));
+ }
+ }
+ else if(ereg("^T", $allepg[$i]))
+ $epgtitle=substr($allepg[$i], 2);
+ else if(ereg("^D", $allepg[$i]))
+ $epgdesc=substr($allepg[$i], 2);
+ }
+ }
+
+ return array($epgtitle, $epgdesc, $channame);
+}
+
+function vdrgetchannum($chan = "NULL")
+{
+ global $svdrpip, $svdrpport;
+
+ $svdrp = new SVDRP($svdrpip, $svdrpport);
+ $svdrp->Connect();
+ $channels = $svdrp->Command("LSTC");
+ $svdrp->Disconnect();
+
+ // Get channel number
+ $channels = preg_grep(quotemeta('"'.$chan.';|'.$chan.':"'), $channels);
+ reset($channels);
+
+ $channels = explode(" ", $channels[key($channels)]);
+ $channum = $channels[0];
+
+ return $channum;
+}
+
+function vdrlistcategories()
+{
+ global $vdrchannels;
+
+ // All chans
+ print "<li class=\"menu\"><a class=\"noeffect\" href=\"javascript:sendForm('All');\"><span class=\"name\">All channels</span><span class=\"arrow\"></span></a></li>\r\n";
+ print "<form name=\"All channels\" id=\"All\" method=\"post\" action=\"index.php\"><input name=\"action\" type=\"hidden\" id=\"action\" value=\"listchannels\"/><input name=\"cat\" type=\"hidden\" id=\"cat\" value=\"All\" /></form>\r\n";
+
+ $fp = fopen ($vdrchannels,"r");
+ while ($line = fgets($fp, 1024))
+ {
+ // Check if it is a categorie
+ if ($line[0] == ":")
+ {
+ // Remove : and @
+ $cat = substr($line, 1, -1);
+ if($cat[0] == '@')
+ {
+ $cat_array = explode(' ', $cat);
+ $cat = substr($cat, strlen($cat_array[0])+1);
+ }
+
+ $cat2 = addslashes($cat);
+
+ print "<li class=\"menu\"><a class=\"noeffect\" href=\"javascript:sendForm('$cat2');\"><span class=\"name\">$cat</span><span class=\"arrow\"></span></a></li>\r\n";
+ print "<form name=\"$cat\" id=\"$cat\" method=\"post\" action=\"index.php\"><input name=\"action\" type=\"hidden\" id=\"action\" value=\"listchannels\"/><input name=\"cat\" type=\"hidden\" id=\"cat\" value=\"$cat\" /></form>\r\n";
+ }
+ }
+ fclose($fp);
+}
+
+function vdrlistchannels($category = "NULL")
+{
+ global $epgtitle;
+ global $vdrchannels;
+
+ if ($category == "All")
+ $cat_found=1;
+ else
+ $cat_found=0;
+
+ $fp = fopen ($vdrchannels,"r");
+ while ($line = fgets($fp, 1024))
+ {
+ if ($cat_found)
+ {
+ if ($line[0] == ":")
+ {
+ if ($category == "All")
+ continue;
+ else
+ break;
+ }
+
+ $channels = explode(":", $line);
+ $channels = explode(";", $channels[0]);
+ $chan = $channels[0];
+
+ // Get EPG title
+ $epgtitle = NULL;
+ list($epgtitle, $epgdesc, $channame) = vdrgetinfostream($chan, 1);
+ print "<li class=\"withimage\">";
+ $chan2=addslashes($chan);
+ print " <a class=\"noeffect\" href=\"javascript:sendForm('$chan2');\">\r\n";
+ if (!file_exists('logos/'.$chan.'.png'))
+ print " <img src=\"logos/nologo.png\" />\r\n";
+ else
+ print " <img src=\"logos/{$chan}.png\" />\r\n";
+ print " <span class=\"name\">$chan</span>\r\n";
+ print " <span class=\"comment\">$epgtitle</span><span class=\"arrow\"></span></a>\r\n</li>\r\n";
+ print " <form name=\"$chan\" id=\"$chan\" method=\"post\" action=\"index.php\">";
+ print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"stream\" />";
+ print " <input name=\"type\" type=\"hidden\" id=\"type\" value=1 />";
+ print " <input name=\"name\" type=\"hidden\" id=\"name\" value=\"$chan\" />";
+ print " </form>\r\n";
+ }
+ else
+ {
+ if ($line[0] == ":")
+ {
+ // Remove : and @
+ $cat = substr($line, 1, -1);
+ if($cat[0] == '@')
+ {
+ $cat_array = explode(' ', $cat);
+ $cat = substr($cat, strlen($cat_array[0])+1);
+ }
+
+ // Check category
+ if ("$cat" == "$category")
+ $cat_found = 1;
+ }
+ }
+ }
+ fclose($fp);
+}
+?>
diff --git a/includes/include.php b/includes/include.php
new file mode 100755
index 0000000..9078aad
--- /dev/null
+++ b/includes/include.php
@@ -0,0 +1,112 @@
+<?php
+
+include ('config.php');
+include ('includes/inc_auth.php');
+include ('includes/inc_vdr.php');
+include ('includes/inc_streaminfo.php');
+
+function selectpage()
+{
+ $action = $_REQUEST['action'];
+
+ if ($action == "stopstream")
+ {
+ $cmd= "killall segmenter && killall -9 ffmpeg ; rm ram/stream*";
+ exec ($cmd);
+
+ $action = $_REQUEST['actionafterstop'];
+ }
+
+ if (infostreamexist())
+ $action = "stream";
+
+ switch ($action)
+ {
+ case ("stream"):
+ gen_stream();
+ break;
+ case ("listcategory"):
+ gen_category();
+ break;
+ case ("listchannels"):
+ gen_channels();
+ break;
+ case ("recordings"):
+ gen_recordings();
+ break;
+ case ("media"):
+ gen_media();
+ break;
+ case ("startstream"):
+ $type = $_REQUEST['type'];
+ $name = $_REQUEST['name'];
+ $title = $_REQUEST['title'];
+ $desc = $_REQUEST['desc'];
+ $qname = $_REQUEST['qname'];
+ $qparams = $_REQUEST['qparams'];
+ $category = $_REQUEST['category'];
+ $url = $_REQUEST['url'];
+ start_stream($type, $name, $title, $desc, $qname, $qparams, $category, $url);
+ break;
+ default:
+ gen_home();
+ break;
+ }
+}
+
+function gen_home()
+{
+ $_SESSION['currentcat'] = NULL;
+ include('includes/inc_home.php');
+}
+
+function gen_category()
+{
+ include('includes/inc_cat.php');
+}
+
+function gen_channels()
+{
+ include('includes/inc_chan.php');
+}
+
+function gen_stream()
+{
+ include('includes/inc_stream.php');
+}
+
+
+function gen_recordings()
+{
+ include('includes/inc_rec.php');
+}
+
+function gen_media()
+{
+ include('includes/inc_media.php');
+}
+
+function start_stream($type, $name, $title, $desc, $qname, $qparams, $category, $url)
+{
+ global $httppath;
+
+ switch ($type)
+ {
+ case 1:
+ $cmd = "export SHELL=\"/bin/sh\";printf \"./istream.sh '" .$url ."' " .$qparams ." " .$httppath ." 2 \" | at now";
+ break;
+ case 2:
+ $cmd = "export SHELL=\"/bin/sh\";printf \"cat \\\"" .$url ."\\\"/0* | ./istream.sh - " .$qparams ." " .$httppath ." 1260 \" | at now";
+ break;
+ default:
+ $cmd = "";
+ }
+ exec ($cmd);
+
+ // Write streaminfo
+ writeinfostream($type, $name, $title, $desc, $qname, $category, $url);
+
+ include('includes/inc_stream.php');
+}
+
+?>