diff options
author | TheTroll <trolldev@gmail.com> | 2010-02-23 15:14:29 +0100 |
---|---|---|
committer | TheTroll <trolldev@gmail.com> | 2010-02-23 15:14:29 +0100 |
commit | 7a855ec97d6e4d23d41daefda757e29b5ec3e75d (patch) | |
tree | f63aa3b0de3cbeac4a88826eaf1f3c529ff079ba /includes/inc_vdr.php | |
parent | 7d0badfcd9efe46ccb101519a8f9aaac60c96a6c (diff) | |
download | istreamdev-7a855ec97d6e4d23d41daefda757e29b5ec3e75d.tar.gz istreamdev-7a855ec97d6e4d23d41daefda757e29b5ec3e75d.tar.bz2 |
Factorized svdrp calls
Diffstat (limited to 'includes/inc_vdr.php')
-rwxr-xr-x | includes/inc_vdr.php | 65 |
1 files changed, 20 insertions, 45 deletions
diff --git a/includes/inc_vdr.php b/includes/inc_vdr.php index 4158e2e..233378b 100755 --- a/includes/inc_vdr.php +++ b/includes/inc_vdr.php @@ -1,19 +1,28 @@ <?php include ('includes/inc_svdrp.php'); +function vdrsendcommand($cmd) +{ + global $svdrpip, $svdrpport; + + $svdrp = new SVDRP($svdrpip, $svdrpport); + $svdrp->Connect(); + $ret = $svdrp->Command($cmd); + $svdrp->Disconnect(); + + return $ret; +} + function vdrgetinfostream($stream = "NULL", $ischan = 1) { - global $allepg, $allepgfilled, $svdrpip, $svdrpport; + global $allepg, $allepgfilled; 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(); + $allepg = vdrsendcommand("LSTE NOW"); $allepgfilled = 1; } @@ -96,14 +105,9 @@ function vdrgetinfostream($stream = "NULL", $ischan = 1) function vdrgettimerinfo($timernum=-1) { - global $svdrpip, $svdrpport; - if ($timernum != -1) { - $svdrp = new SVDRP($svdrpip, $svdrpport); - $svdrp->Connect(); - $timer = $svdrp->Command("LSTT " .$timernum); - $svdrp->Disconnect(); + $timer = vdrsendcommand("LSTT " .$timernum); $timerarray = explode(":", $timer); @@ -132,12 +136,7 @@ function vdrgettimerinfo($timernum=-1) function vdrgetchannum($chan = "NULL") { - global $svdrpip, $svdrpport; - - $svdrp = new SVDRP($svdrpip, $svdrpport); - $svdrp->Connect(); - $channels = $svdrp->Command("LSTC"); - $svdrp->Disconnect(); + $channels = vdrsendcommand("LSTC"); // Get channel number $channels = preg_grep(quotemeta('"'.$chan.';|'.$chan.':"'), $channels); @@ -151,12 +150,7 @@ function vdrgetchannum($chan = "NULL") function vdrgetchanname($channum = 0) { - global $svdrpip, $svdrpport; - - $svdrp = new SVDRP($svdrpip, $svdrpport); - $svdrp->Connect(); - $channel = $svdrp->Command("LSTC " .$channum); - $svdrp->Disconnect(); + $channel = vdrsendcommand("LSTC " .$channum); // Get channel name $chanarray = explode(":", $channel); @@ -292,12 +286,7 @@ function vdrlistchannelsdrop($chansel = "") function vdrlisttimers() { - global $svdrpip, $svdrpport; - - $svdrp = new SVDRP($svdrpip, $svdrpport); - $svdrp->Connect(); - $timers = $svdrp->Command("LSTT"); - $svdrp->Disconnect(); + $timers = vdrsendcommand("LSTT"); if (gettype($timers) == "string") { @@ -344,20 +333,11 @@ function vdrlisttimers() function vdrdeltimer($timer=0) { - global $svdrpip, $svdrpport; - - $svdrp = new SVDRP($svdrpip, $svdrpport); - $svdrp->Connect(); - $ret = $svdrp->Command("DELT " .$timer); - $svdrp->Disconnect(); - - return $ret; + return vdrsendcommand("DELT " .$timer); } function vdrsettimer($prevtimer, $channame, $date, $stime, $etime, $desc, $active) { - global $svdrpip, $svdrpport; - $channum = vdrgetchannum($channame); if ($active) $type = "1"; @@ -369,12 +349,7 @@ function vdrsettimer($prevtimer, $channame, $date, $stime, $etime, $desc, $activ else $command = "MODT " .$prevtimer ." " .$type .":" .$channum .":" .$date .":" .$stime .":" .$etime .":99:99:" .$desc; - $svdrp = new SVDRP($svdrpip, $svdrpport); - $svdrp->Connect(); - $ret = $svdrp->Command($command); - $svdrp->Disconnect(); - - return $ret; + return vdrsendcommand($command); } ?> |