diff --git a/Socket-IO-Server/addressbook.js b/Socket-IO-Server/addressbook.js new file mode 100644 index 0000000000..94af2f2198 --- /dev/null +++ b/Socket-IO-Server/addressbook.js @@ -0,0 +1,3 @@ +obj = {}; +obj["phonenumber"] = "Randomname 1"; +obj["phonenumber"] = "Randomname 2"; \ No newline at end of file diff --git a/Socket-IO-Server/callmonitor.js b/Socket-IO-Server/callmonitor.js new file mode 100644 index 0000000000..3933b2c34e --- /dev/null +++ b/Socket-IO-Server/callmonitor.js @@ -0,0 +1,124 @@ +//https://github.com/tbasse/fritzbox-callmonitor +//(MIT License) +// +//Copyright (c) 2013 Thorsten Basse himself@tagedieb.com +// +//Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +// +//The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +// +//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +'use strict'; + +/* +# Respsonse Format + +Outbound: +Date;CALL;ConnectionId;Extension;CallerId;CalledPhoneNumber; + +Inbound: +Date;RING;ConnectionId;CallerId;CalledPhoneNumber; + +Connected: +Date;CONNECT;ConnectionId;Extension;Number; + +Disconnected: +Date;DISCONNECT;ConnectionID;DurationInSeconds; +*/ + +var net = require('net'); +var events = require('events'); + +var CallMonitor = function (host, port) { + var self = this; + this.call = {}; + + port = port || 1012; + + function fritzboxDateToUnix(string) { + var d = string.match(/[0-9]{2}/g); + var result = ''; + result += '20' + d[2] + '-' + d[1] + '-' + d[0]; + result += ' ' + d[3] + ':' + d[4] + ':' + d[5]; + return Math.floor(new Date(result).getTime() / 1000); + } + + function parseMessage(buffer) { + var message = buffer.toString() + .toLowerCase() + .replace(/[\n\r]$/, '') + .replace(/;$/, '') + .split(';'); + message[0] = fritzboxDateToUnix(message[0]); + return message; + } + + var client = net.createConnection(port, host); + + client.addListener('data', function (chunk) { + var data = parseMessage(chunk); + + if (data[1] === 'ring') { + self.call[data[2]] = { + type: 'inbound', + start: data[0], + caller: data[3], + called: data[4] + }; + self.emit('inbound', { + time: data[0], + caller: data[3], + called: data[4] + }); + return; + } + + if (data[1] === 'call') { + self.call[data[2]] = { + type: 'outbound', + start: data[0], + extension: data[3], + caller: data[4], + called: data[5] + }; + self.emit('outbound', { + time: data[0], + extension: data[3], + caller: data[4], + called: data[5] + }); + return; + } + + if (data[1] === 'connect') { + self.call[data[2]]['connect'] = data[0]; + self.emit('connected', { + time: data[0], + extension: self.call[data[2]]['extension'], + caller: self.call[data[2]]['caller'], + called: self.call[data[2]]['called'] + }); + return; + } + + if (data[1] === 'disconnect') { + self.call[data[2]].disconnect = data[0]; + self.call[data[2]].duration = parseInt(data[3], 10); + + var call = self.call[data[2]]; + delete(self.call[data[2]]); + self.emit('disconnected', call); + return; + } + + }); + + client.addListener('end', function () { + client.end(); + }); +}; + +CallMonitor.prototype = new events.EventEmitter(); + +module.exports = CallMonitor; diff --git a/Socket-IO-Server/server.js b/Socket-IO-Server/server.js new file mode 100644 index 0000000000..0c7ea93af2 --- /dev/null +++ b/Socket-IO-Server/server.js @@ -0,0 +1,28 @@ +'use strict'; +var io = require('socket.io').listen(1234); + +//Callmonitor +//Setup +require('./addressbook.js'); +var CallMonitor = require('./callmonitor.js'); +var fritzbox = { + address: '192.168.178.1', + port: '1012' +}; +var monitor = new CallMonitor(fritzbox.address, fritzbox.port); + +//Logic +monitor.on('inbound', function (call) { + if (call.caller != "") { + if (obj[call.caller]) { + io.sockets.emit('calling', obj[call.caller]); + } + if (!obj[call.caller]) { + io.sockets.emit('calling', call.caller); + } + }; +}); + +monitor.on('disconnected', function (call) { + io.sockets.emit('calling', 'clear'); +}); \ No newline at end of file diff --git a/calendar.php b/calendar.php index 9b9412b321..1f9e6c56fe 100644 --- a/calendar.php +++ b/calendar.php @@ -18,8 +18,14 @@ function get_url($url) 'header'=>"Accept-Language: en-US,en;q=0.8rn" . "Accept-Encoding: gzip,deflate,sdchrn" . "Accept-Charset:UTF-8,*;q=0.5rn" . - "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:19.0) Gecko/20100101 Firefox/19.0 FirePHP/0.4rn" - ) + "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:19.0) Gecko/20100101 Firefox/19.0 FirePHP/0.4rn", + "ignore_errors" => true //Fix problems getting data + ), + //Fixes problems in ssl + "ssl" => array( + "verify_peer"=>false, + "verify_peer_name"=>false + ) ); $context = stream_context_create($opts); diff --git a/css/callmonitor.css b/css/callmonitor.css new file mode 100644 index 0000000000..314f233a00 --- /dev/null +++ b/css/callmonitor.css @@ -0,0 +1,40 @@ +#call { + background-color: white; + color: black; + margin: 0 165px; + font-size: 60px; + width: auto; + border-radius: 20px; + display: none; +} + +#call h2{ + font-size: 70px!important; + -webkit-margin-before: 10px!important; + -webkit-margin-after: -25px!important; + -webkit-margin-start: 0px!important; + -webkit-margin-end: 0px!important; + font-weight: bold; + letter-spacing: 2px; +} + +#caller{ + font-size: 50px; + padding-bottom: 6px; + letter-spacing: 2px; +} + +#call img{ + padding-top: 20px; + -webkit-margin-before: 10px!important; +} + +#door img{ + position: relative; + width: 200px; +} +#door{ + position: relative; + top: 15px; + display: none; +} \ No newline at end of file diff --git a/img/door.png b/img/door.png new file mode 100644 index 0000000000..60f0b7610f Binary files /dev/null and b/img/door.png differ diff --git a/img/phone.png b/img/phone.png new file mode 100644 index 0000000000..49793e9c94 Binary files /dev/null and b/img/phone.png differ diff --git a/index.php b/index.php index c04c9a6993..2e63e03113 100644 --- a/index.php +++ b/index.php @@ -3,6 +3,7 @@