diff options
| author | Christian Weiske <cweiske@cweiske.de> | 2012-08-10 22:09:19 +0200 |
|---|---|---|
| committer | Christian Weiske <cweiske@cweiske.de> | 2012-08-10 22:09:19 +0200 |
| commit | bbd03e7cdd6defd30e9019ae5bf690a085482776 (patch) | |
| tree | 548463567799f2477b2f7553b37f1fdf5ca5bade | |
| parent | ebeb314ba1fdbcf9dc4443cd9d80256784b21cab (diff) | |
| download | auerswald-callnotifier-bbd03e7cdd6defd30e9019ae5bf690a085482776.tar.gz auerswald-callnotifier-bbd03e7cdd6defd30e9019ae5bf690a085482776.zip | |
dreambox web message notifier
| -rw-r--r-- | src/callnotifier/Logger/CallDreambox.php | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/callnotifier/Logger/CallDreambox.php b/src/callnotifier/Logger/CallDreambox.php new file mode 100644 index 0000000..4720c4c --- /dev/null +++ b/src/callnotifier/Logger/CallDreambox.php @@ -0,0 +1,56 @@ +<?php +namespace callnotifier; + +class Logger_CallDreambox extends Logger_CallBase +{ + protected $host; + + public function __construct($host) + { + $this->host = $host; + } + + public function log($type, $arData) + { + switch ($type) { + case 'startingCall': + $this->displayStart($arData['call']); + break; + } + } + + + protected function displayStart(CallMonitor_Call $call) + { + if ($call->type != CallMonitor_Call::INCOMING) { + return; + } + + $this->addUnsetVars($call); + + $msg = 'Anruf von '; + if ($call->fromName !== null) { + $msg .= $call->fromName + . "\nNummer: " . $call->from; + } else { + $msg .= $call->from; + } + if ($call->fromLocation !== null) { + $msg .= "\nOrt: " . $call->fromLocation; + } + + $this->notify($msg); + } + + protected function notify($msg) + { + $url = 'http://' . $this->host + . '/web/message?type=2&timeout=10&text=' . urlencode($msg); + exec( + 'curl' + . ' ' . escapeshellarg($url) + . ' > /dev/null 2>&1 &' + ); + } +} +?> |
